akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(), (a).end()
#define pb emplace_back
#define INF (1e9+1)


int main(){
    int n,m;
    cin>>n>>m;
    
    vector<int> a(n), b(n), c(n);
    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    
    static int dp[10001][101];
    rep(i,10001)rep(j,101)dp[i][j] = -INF;
    dp[0][0] = 0;
    rep(i,n){
        for(int j = 10000;j>=0;j--){
            for(int k = 100;k>=0;k--){
                if(dp[j][k]<0)continue;
                int A = j, B = dp[j][k], C = k;
                if( A+a[i]<=10000 && C+c[i]<=100 )dp[A+a[i]][C+c[i]] = max(dp[A+a[i]][C+c[i]], B + b[i]);
                if( A+b[i]>=B+a[i] && A+b[i]<=10000 && C+c[i]<=100 ){
                    dp[A+b[i]][C+c[i]] = max(dp[A+b[i]][C+c[i]], B + a[i]);
                }
                if( A+b[i]<=B+a[i] && B+b[i]<=10000 && C+c[i]<=100){
                    dp[B+a[i]][C+c[i]] = max(dp[B+a[i]][C+c[i]], A + b[i]);
                }
            }
        }
    }
    int ans = -INF;
    rep(i,10001)rep(j,m+1){
        assert(i>=dp[i][j]);
        ans = max(ans,dp[i][j]);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 7044
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    int flag=1;
    string s;cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]!='h') flag=0;
        }
        else{
            if(s[i]!='i') flag=0;
        }
    }
    if(s.size()%2!=0) flag=0;
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const int N = 200005;
LL dp[N][5];
int a[N];

int main() {
	int n;
	cin >> n;
	REP(i, n)scanf("%d", &a[i]);
	memset(dp, 0x7f, sizeof(dp));
	REP(i, 5)dp[0][i] = 0;
	REP(i, n) {
		dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + a[i]);
		FOR(j, 1, 5) {
			REP(k,  j+1) {
				int x;
				if (j == 4) {
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][k] + a[i]);
				}
				else if (a[i] == 0) {
					dp[i + 1][j] = min(dp[i + 1][j], dp[i][k] + ((j == 2) ? 1 : 2));
				}
				else {
					if (j == 2)dp[i + 1][j] = min(dp[i + 1][j], dp[i][k] + 1 - a[i] % 2);
					else dp[i + 1][j] = min(dp[i + 1][j], dp[i][k] + a[i] % 2);
				}
			}
		}
	}
	LL ret = 2e18;
	REP(j, 5)ret = min(ret, dp[n][j]);
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

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

  int n;
  cin >> n;
  int k;
  vector<int> a(n);
  rep(i,n-1){
    cin >> k;
    k--;
    a[k]++;
  }
  
  rep(i,n){
    cout << a[i] << endl;
  }
  return 0;
  }


Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

vi adj[100001];

vi bfs(int src)
{
    vector<bool> vis(100001,false);
    vi dist(100001,0);
    // memset(dist,0,sizeof(dist));

    queue<int>q;
    q.push(src);
    dist[src]=0;
    vis[src]=true;
    while(!q.empty()){
        int node= q.front();
        q.pop();
        for(auto x:adj[node]){
            if(!vis[x]){
                vis[x]=true;
                q.push(x);
                dist[x]=1+dist[node];
            }
        }
    }
    return dist;
}

int32_t main()
{
    int n,U,V;cin>>n>>U>>V;

    int u,v;
    for(int i=0;i<n-1;i++){
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    vi a= bfs(U);
    vi b= bfs(V);

    int ans=0;
    for(int i=1;i<=n;i++){
        if(a[i] < b[i])
            ans=max(ans,b[i]);
    }

    ans-=1;
    cout<<ans<<endl;
    return 0;
}

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

int pow(long long a, long long b){
  if(b==0) return 1;
  if(b==1) return a;
  if(b%2==0) return pow((a*a)%2019,b/2);
  else return (pow(a,b-1)*a)%2019;
}

int main(){
  string s;
  cin >> s;
  vector<int> v(s.length()),mod(2019);
  v[s.length()-1] = (int)(s[s.length()-1]-'0');
  for(int i=s.length()-2;i>=0;i--){
    v[i] = (v[i+1] + (int)(s[i]-'0')*pow(10,s.length()-1-i)) % 2019;
  }
  for(int i=0;i<s.length();i++){
    mod[v[i]]++;
  }
  mod[0]++;
  long long cnt = 0;
  for(int i=0;i<2019;i++){
    cnt += mod[i] * (mod[i]-1) / 2;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4288
#include <iostream>
#include <cmath>
#include <sstream>
using namespace std;
int main()
{
    int a,b,c,d,ab,cd;
    cin >>a>>b>>c>>d;
    ab=a+b;
    cd=c+d;
    if (cd==ab)
    cout << "Balanced";
    if (cd>ab)
    cout << "Right";
    if (cd<ab)
    cout << "Left";

}


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

int compare (const void *p, const void *q) {
    return *(int*)p - *(int*)q;
}

int compare2 (const void *p, const void *q) {
    return *((int*)q + 1) - *((int*)p + 1);
}

int main (void) {
    int n, red[100][2], blue[100][2], i, j, x = 0;

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

    qsort(red, n, sizeof(int) * 2, compare2);
    qsort(blue, n, sizeof(int) * 2, compare);

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (red[i][0] < blue[j][0] && red[i][1] < blue[j][1]) {
                x++;
                blue[j][0] = -1;
                break;
            }
        }
    }

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


Measured memory_bytes: 128
##   __      __       .__           .____________                   __________        __ ________   __                 
##  /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
##  \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
##   \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
##    \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
##         \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

from sys import *
import collections
import math

def solve() :
    n = int(input())
    if n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8 :
        print("pon")
    elif n % 10 == 2 or n % 10 == 4 or n % 10 == 5 or n % 10 == 7 or n % 10 == 9 :
        print("hon")
    else :
        print("bon")

t = 1
#t = input()
for _ in range (0, t) :
	solve()

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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = nm[0];
        int m = nm[1];

        int[] s = new int[m];
        int[] c = new int[m];
        for (int i = 0; i < m; i++)
        {
            int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            s[i] = tmp[0];
            c[i] = tmp[1];
        }

        // ダメなパターン
        // 一桁目0
        for (int i = 0; i < m; i++)
        {
            if (s[i] == 1 && c[i] == 0 && n != 1)
            {
                Console.WriteLine("-1");
                return;
            }
        }

        // 同じ桁で異なる条件
        for (int i = 0; i < m; i++)
        {
            for (int k = 0; k < m; k++)
            {
                if (s[i] == s[k] && c[i] != c[k])
                {
                    Console.WriteLine("-1");
                    return;
                }
            }
        }

        //　OKパターン
        StringBuilder ans = new StringBuilder("");
        for (int i = 0; i < n; i++)
        {
            ans.Append("0");
        }

        for (int i = 0; i < m; i++)
        {
            ans.Replace("0", c[i].ToString(), s[i] - 1, 1);
        }

        //all 0の場合
        if (n == 1 && ans[0] == '0')
        {
            Console.WriteLine("0");
            return;

        }


        //一桁目が0なら1に置き換える
        if (ans[0] == '0')
        {
            ans.Replace("0", "1", 0, 1);
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
    int n;
    cin >> n;
    VI a(n);
    rep(i,n)cin >> a.at(i);
    int chk=1;
    int cnt=0;
    rep(i,n){
        if(a.at(i)==chk){
          chk++;
        }
        else{
          cnt++;
        }
    }
    if(chk==1)cnt=-1;
    cout << cnt << endl;
    
  }


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

#include <sstream>
#include <istream>

using namespace std;

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


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

	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			if(4*i+7*j==n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

LL A,B,C,D;
LL gcd(LL a,LL b){
	if(a<b)return gcd(b,a);
	if(b==0)return a;
	return gcd(b,a%b);
}

LL cnt(LL a,LL x){
	return a/x;
}

int main(){
	cin>>A>>B>>C>>D;
	cout<<(B-A+1)-(cnt(B,C)+cnt(B,D)-cnt(B,C*D/gcd(C,D))-(cnt(A-1,C)+cnt(A-1,D)-cnt(A-1,C*D/gcd(C,D))))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[111111];
  int ans=0;
  cin>>a;
  for(int i=1;i<strlen(a);i++){
    if(a[0]!=a[i]){
      ans++;
      a[0]=a[i];
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 384
// Problem : A - Poor
// Contest : AtCoder Beginner Contest 155
// URL : https://atcoder.jp/contests/abc155/tasks/abc155_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3];
	for(int i=0;i<3;++i)
	cin >> a[i];
	sort(a,a+3);
	if((a[0]==a[1] && a[1]!=a[2]) || (a[0]!=a[1] && a[1]==a[2]))
	cout << "Yes" << endl;
	else
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop
import bisect


"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""


A = list(map(int,input().split()))

for i in range(5):
  if A[i] == 0:
    print(i+1)
    exit()

Measured memory_bytes: 72936
n = int(input())
mod = 10 ** 9 + 7

def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1
    a=factorial(n) %p
    b=factorial(k) %p
    c=factorial(n-k) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p

ans = power_func(10, n, mod) - 2 * power_func(9, n, mod) + power_func(8, n, mod)
ans %= mod
print(ans)


Measured memory_bytes: 61944
N,Y = map(int,input().split())

Y = Y/1000
kill = 0
for x in range(N+1):
  for y in range(N-x+1):
    if N + 9*x + 4*y == Y:
      print(x,y,N-x-y)
      kill = 1
      break
  if kill == 1:
    break
if kill == 0:
  print(-1,-1,-1)

Measured memory_bytes: 3060
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000000ll
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
ll dp[3005][3005][4];
ll t[3005][3005];

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

    int r,c,k;
    cin>>r>>c>>k;
    rep(i,k){
        int a,b,tt;
        cin>>a>>b>>tt;
        a--;b--;
        t[a][b] = tt;
    }
    rep(i,r+1)rep(j,c+1)rep(l,4){
        dp[i][j][l] = 0;
    }
    dp[0][0][1] = t[0][0];
    
    rep(i,r){
        rep(j,c){
            for(int l = 0; l < 4; l++){
                if(i + 1<r){
                    //下に移動
                    dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][l]);
                    //下に移動して宝をとる
                    dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][l] + t[i+1][j]);
                }

                if(j + 1 <c){
                    //右に移動
                    dp[i][j+1][l] = max(dp[i][j+1][l], dp[i][j][l]);
                    //右に移動して宝をとる(今回は制約ありver.)
                    if(l+1 <= 3){
                        dp[i][j+1][l+1] = max(dp[i][j+1][l+1], dp[i][j][l] + t[i][j+1]);
                    }
                }
            }
        }
    }

    //出力
    cout<< *max_element(dp[r-1][c-1], dp[r-1][c-1] + 4) <<endl;
}


Measured memory_bytes: 355764
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    cout<<setprecision(16);
    long double a,b;
    cin>>a>>b;
    long double sum = a*b;
    cout<<(long long)(sum+0.001)<<endl;


    
return 0;
}


Measured memory_bytes: 3700
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
string a;
long long S,T,ans;
int main()
{
	cin>>a;
	ans=a.size();
	for(int s=0;s<a.size();s++)
	{
		if(a[s]=='S')S++;
		else T++;
		while(T>0&&S>0)
		{
			ans-=2;
			T--,S--;
		}
		T=0;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
N, K = map(int,input().split())
x = list(map(int,input().split()))
ans = []
for i in range(N-K+1):
    l=x[i]
    r=x[i+K-1]
    ans.append(min(abs(l)+abs(r-l),abs(r)+abs(l-r)))
print(min(ans))


Measured memory_bytes: 14392
n = int(input())
r_min = int(input())
r_t   = int(input())
g_max = r_t - r_min
r_min = min(r_t,r_min)
for _ in range(n-2):
    r_t = int(input())
    g_max = max(g_max, r_t-r_min)
    r_min = min(r_t,r_min)
print(g_max)


Measured memory_bytes: 5608
#include <iostream>
using namespace std;
int main(int argc,char const *argv[])
{
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int sum = 0;
	for(int i = 0;i <= a; ++i)
	{
		for(int j = 0;j <= b; ++j)
		{
			for(int k = 0;k <= c; ++k)
			{
				if(i * 500 + j * 100 + k * 50 == x)
				{
					sum++;
				}
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;
const int N=4e5+7;
const int maxn = 400000;
const int inf = 0x7f7f7f7f;
struct Treap {
    int ch[maxn][2], s[maxn], sum[maxn], key[maxn], root, tot;
    ll val[maxn];
    Treap() {
        root = tot=0;
    }
    void up(int x) {
        s[x] = sum[x] + s[ch[x][0]] + s[ch[x][1]];
    }
    void rotate(int& x, int d) {
        int t = ch[x][d ^ 1];
        ch[x][d ^ 1] = ch[t][d];
        ch[t][d] = x;
        up(x);
        up(t);
        x = t;
    }

    int newnode(ll x) {
        int t = ++tot;
        sum[t] = s[t] = 1;
        ch[t][0] = ch[t][1] = 0;
        val[t] = x;
        key[t] = rand();
        return t;
    }
    void insert(int& u, ll x) {
        if(!u) {
            u = newnode(x);
            return;
        }

        if(x == val[u]) {
            sum[u]++;
            up(u);
            return;
        }

        int d = 0;

        if(x < val[u])insert(ch[u][d], x);
        else insert(ch[u][d ^= 1], x);

        if(key[ch[u][d]] < key[u])rotate(u, d ^ 1);

        up(u);
    }
    int getrank(int u, ll x) {
        if(!u)return 0;

        if(val[u] == x)return s[ch[u][0]] + sum[u];

        if(val[u] < x)return s[ch[u][0]] + sum[u] + getrank(ch[u][1], x);
        else return getrank(ch[u][0], x);
    }
} T;
int n,a[N],K;
ll s[N],ans=0;
int main(){
	scanf("%d%d",&n,&K);
	rep(i,1,n)scanf("%d",&a[i]),a[i]-=K;
	
	T.insert(T.root,0ll);
	rep(i,1,n){
		s[i]=s[i-1] + a[i];
		int res=T.getrank(T.root,s[i]);
		T.insert(T.root,s[i]);
		ans+=res;
	}
	printf("%lld\n",ans);
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();

            Console.WriteLine(input[0] < input[1] ? 0 : 10);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

int main(){
    int h, w;
    while(cin >> h >> w, h){
        vector<string> r(h);
        for(int i = 0 ; i < h ; ++i){
            cin >> r[i];
        }

        string s;
        cin >> s;

        int y = 0, x = 0;
        int ans = 0;
        for(auto c : s){
            for(int i = 0 ; i < h ; ++i){
                for(int j = 0 ; j < w ; ++j){
                    if(r[i][j] == c){
                        ans += abs(i - y) + abs(j - x) + 1;
                        y = i;
                        x = j;
                    }
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  
  int ans = 0;
  for(int i=0;i<N;i++){
    if(a[i] >= K) ans ++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		String ans = ":(";
		for(int i = 0;i <= N;i++) {
			if(N == Math.floor(i*1.08))ans = "" + i;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21824
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
  int n,k;
  cin>>n>>k;
  int num=1;
  for(int i=0;i<n;i++){
    int a,b;
    a=num*2;
    b=num+k;
    num=min(a,b);
  }
  cout<<num<<endl;
  return 0;
}


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

int main(){
  double n,m,d;
  cin>>n>>m>>d;
  int a=1;
  if(d>0){
    a++;
  }
  cout<<fixed<<setprecision(15);
  cout<<(m-1)*(a*(n-d))/(n*n)<<endl;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007
#define INV_10 299473306
#define INF 1000000000
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a, b, c, k, sum=0;
	cin >> a >> b >> c >> k;
	if(k > 0)
	{
		sum+=min(a, k);
		k-=a;
	}
	if(k > 0)
	{
		k-=b;
	}
	if(k > 0)
	{
		sum-=min(k, c);
	}
	cout << sum << '\n';
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for (int i = 0; i < k; i++) {
    vec.pop_back();
  }
  long long sum = 0;
  for (int i = 0;i < n - k; i++) {
    sum += vec.at(i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define retunr return
#define pb push_back
#define mp make_pair
#define null NULL
#define sc(x) scanf("%d", &x)
#define sc64(x) scanf("%I64d", &x)
#define pr(x) printf("%d", (x))
#define sp putchar(' ')
#define ln putchar('\n')
#define pr64(x) printf("%I64d", (x))
#define rep(i,l,r) for (int i = l, lim = r;i <= lim; ++i)
#define repr(i,l,r) for (int i = r, lim = l;i >= lim; --i)
#define fi first
#define se second
#define SET(__set, val) memset(__set, val, sizeof __set)
#define fill(a,v,n) memset((a),(v),sizeof(a[0])*(n))
#define copy(a,b,n) memcpy((a),(b),sizeof(a[0])*(n))
#define ALL(x) (x.begin(),x.end())
#define prf(x) printf("%.20f", x)
#define for_each_edge(u) for(int i = point[u];i;i=G[i].n)
typedef unsigned int uint;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 200010
#define M 1024
#define MOD 1000000007
void _add(int &a, int b){a = (a+b)%MOD;}
void _sub(int &a, int b){a = (a+MOD-b)%MOD;}
void _mul(int &a, int b){a = (ll)a*b%MOD;}
void _max(int &a, int b){a = max(a,b);}
void _min(int &a, int b){a = min(a,b);}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b,a%b);}
ll pw(ll a, ll b){ll res(1);while(b){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
ll pwM(ll a, ll b, ll mod){ll res(1);while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int infi = 2147483647;
const ll infl = 9223372036854775807ll;
const db PI = 3.14159265358979323846;

/*
struct E{
	int v, w, n;
}G[N];
int cnt, point[N];
void adde(int u, int v, int w = 0){
	G[++cnt]=(E){v,w,point[u]},point[u]=cnt;
	G[++cnt]=(E){u,w,point[v]},point[v]=cnt;
}
void Ginit(){
	cnt = 0;
	SET(point,0);
}
*/
struct hh{
	int a, b, i;
	bool operator < (const hh &x) const{
		if(a==x.a)return b<x.b;
		return a>x.a;
	}
	void in(){
		sc(a),sc(b);
	}
}a[N],b[N];
int tr[N],ans[N];
int n, m, k,q;
void upd(int d, int x){
	for(;d<=n;d+=d&-d)tr[d]+=x;
}
int ask(int d){
	int res(0);
	for(;d>0;d-=d&-d)res+=tr[d];
	return res;
}
int main(){
//	freopen("1", "r", stdin);
	sc(n),sc(m),sc(q);
	rep(i,1,m){
		a[i].in();
	}
	sort(a+1,a+1+m);
	rep(i,1,q){
		b[i].in();
		b[i].i = i;
	}
	sort(b+1,b+1+q);
	int j = 1;
	rep(i,1,q){
		while(j <= m && a[j].a >= b[i].a){
			upd(a[j].b,1);
			j++;
		}
		ans[b[i].i] = ask(b[i].b);
	}
	rep(i,1,q)pr(ans[i]),ln;
/*
	int Case;
	sc(Case);
	rep(ca, 1, Case){
	    printf("Case #%d: ", ca);
	}
*/
	return 0;
}


Measured memory_bytes: 6016
#include<stdio.h>

int data[10];
int sp=0;
int top() {
    return data[sp-1];
}
void pop() {
    sp--;
}
void push(int n) {
    if(n>0) {
        data[sp] = n;
        sp++;
    }
}

int main() {
    int n;
    while(scanf("%d",&n) != EOF) {
        if(n==0) {
            printf("%d\n",top());
            pop();
        }else{
            push(n);
        }
    }
    return 0;
}

Measured memory_bytes: 1720
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[100001];

int main(){

	scanf("%s",buf);

	int length;
	for(length = 0; buf[length] != '\0'; length++);

	int ans = BIG_NUM;
	for(int i = 0; i < length-1; i++){
		if(buf[i] != buf[i+1]){
			ans = min(ans,max(i+1,length-(i+1)));
		}
	}

	if(ans == BIG_NUM){
		printf("%d\n",length);
	}else{
		printf("%d\n",ans);
	}

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

using namespace std;

int main() 
{   
    int n; cin >> n;
    string s; cin >> s;
    string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    alpha += alpha;

    rep(i,s.size()) {
        s[i] = alpha[alpha.find_first_of(s[i])+n]; 
    }
    cout << s << endl;
    return 0;
}



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


using namespace std;


int main() {
	string S;
	cin >> S;
	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
N = int(input())
dp = [0 for j in range(4)]
dp[0] = 1
M = 1_000_000_007;
for i in range(N):
    x = dp[0]
    y = dp[1]
    z = dp[2]
    dp[0] = (x * 8) % M
    dp[1] = (y * 9 + x) % M
    dp[2] = (z * 9 + x) % M
    dp[3] = (dp[3] * 10 + y + z) % M
print(dp[3])

Measured memory_bytes: 64500
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using str = string;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    for(ll i = 1; i <= n; i++){
        ll a = n/i;
        sum += i*a*(a+1)/2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3628
//Counter-Clockwise
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

static const double ESP = 1e-10;

bool equals(double a, double b) { return fabs(a - b) < ESP; }

class Point {
public:
    double x, y;

    explicit Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (const Point &p) const { return Point(x + p.x, y + p.y); }
    Point operator - (const Point &p) const { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(a / x, a / y); }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < ESP && fabs(y - p.y) < ESP;
    }
};

typedef Point Vector;

struct Segment {
    Point p1, p2;
    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

bool isParallel(Vector v1, Vector v2) {
    return equals(cross(v1, v2), 0.0);
}

bool isOrthogonal(Vector v1, Vector v2) {
    return equals(dot(v1, v2), 0.0);
}

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    return s.p1 + (base * (dot(base, p - s.p1) / base.norm()));
}

Point reflect(Segment s, Point p) {
    return p + (project(s, p) - p) * 2;
}

enum {
    COUNTER_CLOCKWISE = 1,
    CLOCKWISE = -1,
    ONLINE_BACK = 2,
    ONLINE_FRONT = -2,
    ON_SEGMENT = 0
};

int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > ESP) return COUNTER_CLOCKWISE;
    else if (cross(a, b) < -ESP) return CLOCKWISE;
    else if (dot(a, b) < -ESP) return ONLINE_BACK;
    else if (a.norm() < b.norm()) return ONLINE_FRONT;
    else return ON_SEGMENT;
}

bool intersect(Point p0, Point p1, Point p2, Point p3) {
    return (ccw(p0, p1, p2) * ccw(p0, p1, p3) <= 0 && ccw(p2, p3, p0) * ccw(p2, p3, p1) <= 0);
}

bool intersect(Segment s1, Segment s2) {
    return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

int main() {
    int q;
    double x0, y0, x1, y1, x2, y2, x3, y3;
    cin >> q;
    for(int i = 0; i < q; i++) {
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Segment s1 = Segment(Point(x0, y0), Point(x1, y1));
        Segment s2 = Segment(Point(x2, y2), Point(x3, y3));
        if(intersect(s1, s2)) cout << 1 << endl;
        else cout << 0 << endl;
    }
}


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

int main()
{
    int A, B, C ;
    cin >> A >> B >> C ;
    
    if( A*B*C == 175 && A+B+C == 17 )
    cout << "YES\n" ;
    else
    cout << "NO\n" ;
    

    return 0 ;
} 

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

int main(void){
  string s, t;
  int A = 0;
  cin >> s >> t;

  size_t size = s.length();

  for(int i=0;i < size; i++){
    if(s[i]!=t[i]){
      A = (A + 1);
    }
  }
  cout << A << endl;

}

Measured memory_bytes: 3476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		double[] dp=new double[N+1];
		for(int i=0; i<=N; i++) {
			dp[i]=0;
		}
		//ここでのDPは確率的なところ
		dp[0]=1;
		double[] kakuritu=new double[N];
		for(int i=0; i<N; i++) {
			kakuritu[i]=sc.nextDouble();
		}

		for(int i=0; i<N; i++) {
			for(int j=i; j>=0; j--) {
				dp[j+1]+=dp[j]*kakuritu[i];
				dp[j]*=(1.000d-kakuritu[i]);
			}
		}
		double sum=0;
		for(int i=(N+1)/2; i<=N; i++) {
			sum+=dp[i];
		}
		pl(sum);
	}

	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 24788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    long x;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        x = sc.nextLong();
        solve();
    }

    void solve() {
        long remainder = x % 11;
        long ans = x / 11 * 2;
        if (remainder > 6) {
            ans += 2;
        } else if (remainder > 0) {
            ans++;
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21200
from collections import deque
def main():
    N,M,*AB=map(int,open(0).read().split())
    g=[[] for _ in range(N+1)]
    for a,b in zip(*[iter(AB)]*2):
        g[a].append(b)
        g[b].append(a)
    q=deque([1])
    s=[0]*(N+1)
    s[1]=1
    while q:
        u=q.popleft()
        for v in g[u]:
            if not s[v]:
                s[v] = u
                q.append(v)
    print("Yes")
    print("\n".join(map(str, s[2:])))
if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;
ll MOD=1e9+7;

const int N=2002;
ll C[N][N];

int main()
{
    for(int i=0;i<N;i++)
    C[i][0]=C[i][i]=1;
    for(int i=2;i<N;i++)
    {
        for(int j=1;j<i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
    }

    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++)
    {
        ll ans=(C[k-1][i-1]*C[n-k+1][i])%MOD;
        cout<<ans<<endl;
    }
}


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

ll n;
ll h[200001];
ll a[200001];
ll s[1000001];
ll dp[200001];

ll getMax(ll l, ll r, ll il, ll ir, ll i)
{
    if(l>=il && r<=ir)
        return s[i];
    else if(l>ir || r<il)
        return 0;
    else
    {
        ll mid = (l+r)/2;
        return max(getMax(l,mid,il,ir,2*i+1),getMax(mid+1,r,il,ir,2*i+2));
    }
}

void updateMax(ll l, ll r, ll i, ll diff, ll index)
{
    if(i<l || i>r)
        return;

    if(l==r)
    {
        if(l==i)
            s[index] = diff;
        return;
    }

    ll mid = (l+r)/2;
    updateMax(l,mid,i,diff,2*index+1);
    updateMax(mid+1,r,i,diff,2*index+2);
    s[index] = max(s[2*index +1],s[2*index + 2]);
}

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

    cin >> n;

    fr(i,1,n)
    {
        cin >> h[i];
    }

    fr(i,1,n)
    {
        cin >> a[i];
    }
    
    fr(i,1,n)
    {
        updateMax(1,200000,h[i],getMax(1,200000,1,h[i]-1,1)+a[i],1);
    }

    cout << s[1] << endl;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
long long a[20][20];
long long f[100010];
long long dp[100010];
int n,s;

int main(){
	cin>>n;
	s=1<<n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<s;i++){
		int t[20],lt=0;
		int x=i;
		for(int j=n-1;j>=0;j--){
			if(x>=(1<<j)){
				t[++lt]=j+1;
				x-=(1<<j);
			}
		}
		for(int x=1;x<lt;x++){
			for(int y=x+1;y<=lt;y++){
				f[i]+=a[t[x]][t[y]];
			}
		}
	}
	dp[0]=0;
	for(int i=1;i<s;i++) dp[i]=-1e18;
	for(int i=1;i<s;i++){
		for(int j=i;j;j=(j-1)&i){
			dp[i]=max(dp[i],dp[i^j]+f[j]);
		}
	}
	cout<<dp[s-1]<<endl;

	return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  multiset<int> as;
  F0R(i, N) {
    int a;
    cin >> a;
    as.insert(a);
  }
  F0R(i, M) {
    int n = *as.rbegin();
    as.erase(--as.end());
    n /= 2;
    as.insert(n);
  }
  i64 result = 0;
  for (auto a : as) {
    result += a;
  }
  cout << result;
}
#endif


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

namespace _0140
{
    public class Program

    {
        static string busStop = "56789543210123456789";
        public static void Main(string[] args)
        {
            int n = RInt();
            int startIdx = -1;
            int endIdx = -1;

            for (int k = 0 ; k < n ; k++)
            {
                int[] startEnd = RIntAr();
                for (int i = 0 ; i < busStop.Length ; i++)
                {
                    if (int.Parse(busStop[i].ToString()) == startEnd[0])
                    {
                        for (int j = i ; j < busStop.Length ; j++)
                        {
                            if (int.Parse(busStop[j].ToString()) == startEnd[1])
                            {
                                startIdx = i;
                                endIdx = j;
                                break;
                            }
                        }
                    }
                }
                Console.WriteLine(WAr(busStop.Substring(startIdx, endIdx - startIdx + 1), " "));
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 18272
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll fun(string &l,ll index)
{
    if(index==sz(l)-1)
    {
        if(l.back()=='0')
        {
            return 1;
        }
        else
        {
            return 3;
        }
    }
    if(l[index]=='0')
    {
        return (fun(l,index+1))%mod;
    }
    else
    {
        ll ans=(2*fun(l,index+1))%mod;

        //index+1,..sz(l-1)

        ll length=sz(l)-1-index;
        ans=(ans+power(3,length))%mod;
        return ans;
    }
}

int main()
{
    fast();
    string l;
    cin>>l;
    ll ans=fun(l,0);
    cout<<ans<<nl;
}


Measured memory_bytes: 6904
a=Array.new(26,0)

s=""
while STDIN.eof == false
        s+=gets.downcase
        break if s.match(/^$/)
end
s=s.unpack("C*")
for x in 0..s.length-1 do
        i=(s[x]-"a".ord)
        if i>=0 then a[i]=a[i]+1 end
end
for i in 0..25 do
        printf("%s : %d\n",(97+i).chr,a[i])
end

Measured memory_bytes: 8648
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a*b) % 2 == 0)
			System.out.println("Even");
		else System.out.println("Odd");
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------
ll a, b, k;
void search(ll i){
    if(i%2==0){
        if(a%2==1){
            a--;
        }
        b += a/2;
        a /= 2;
    }else{
        if(b%2==1){
            b--;
        }
        a += b/2;
        b /= 2;
    }
}
int main(){
    cin>>a>>b>>k;
    for(ll i=0;i<k;++i){
        search(i);
    }
    cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256