akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 1e5 + 10;
const int INF = 1e9 + 10;
using namespace std;

int n, m, T, kase = 1;
int a[maxn];

int main() {
    ios::sync_with_stdio(0);
    cin >> n >> m; int ans = INF, k = m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = m; i <= n; i++) {
        if(a[i] <= 0 && a[i - k + 1] <= 0) ans = min(ans, -a[i - k + 1]);
        if(a[i] >= 0 && a[i - k + 1] >= 0) ans = min(ans, a[i]);
        if(a[i] >= 0 && a[i - k + 1] <= 0) ans = min(ans, a[i] - a[i - k + 1] + min(-a[i - k + 1], a[i]));
    } 
    cout << ans << endl;
    return 0;
}

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


ll a[410],s[410];
ll dp[410][410];

int main(int argc, char const *argv[])
{
	int n;cin>>n;

	rep(i,n) cin>>a[i];
	rep(i,n) s[i+1]=s[i]+a[i];
	rep(i,n+1) {
		rep(j,n+1) {
			dp[i][j]=INF;
		}
	}

	rep(i,n) {
		dp[i][i+1]=0;
	}

	for (int width=2;width<=n;width++) {
		for (int l=0;l<n-1;l++) {
			for (int mid=l+1;mid<=l+width-1;mid++) {
				if(l+width<=n)dp[l][l+width]=min(dp[l][l+width],dp[l][mid]+dp[mid][l+width]+s[l+width]-s[l]);
			}
		}
	}

	cout<<dp[0][n]<<endl;

	return 0;
}

Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main(void){
    int n=0;
    int l[100]={0};
    int sum=0;
    int max=0;

    cin >> n;

    for(int count=0;count<n;count++){
        cin >> l[count];
        sum+=l[count];
        if(max<=l[count])max=l[count];
    }

    sum=sum-max;

    if(max<sum)cout << "Yes" << endl;
    else if(max>=sum) cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
Q = int(input())
mod = 10**6+3

fact_memo = [0]*mod
fact_memo[0] = 1
for n in range(mod-1):
    fact_memo[n+1] = (n+1)*fact_memo[n]%mod

def fact(n):
    if n>=mod:
        return 0
    else:
        return fact_memo[n]

def inv(n):
    n %= mod
    return pow(n,mod-2,mod)

def cal(x,d,n):
    if x == 0:
        print(0)
        return
    if d == 0:
        print(pow(x,n,mod))
        return
    ans = pow(d,n,mod)
    y = x*inv(d)%mod
    ans *= fact(y+n-1)
    ans %= mod
    ans *= inv(fact(y-1))
    ans %= mod
    print(ans)

for i in range(Q):
    cal(*map(int,input().split()))

Measured memory_bytes: 62172
import java.util.Scanner;

/**
 * Created by zhangrunfeng on 2/16/20
 */
public class Main {

    class Card{
        public char suit;
        public int value;

        public Card(char suit, int value) {
            this.suit = suit;
            this.value = value;
        }

        @Override
        public String toString() {
            return Character.toString(suit) + Integer.toString(value);
        }
    }

    private int N;
    private Card[] arr1;
    private Card[] arr2;

    public Main(Scanner sc) {
        N = sc.nextInt();
        arr1 = new Card[N];
        arr2 = new Card[N];
        for (int i = 0; i < N; i++) {
            String str = sc.next();
            arr1[i] = new Card(str.charAt(0), Integer.parseInt(str.substring(1)));
            arr2[i] = arr1[i];
        }
    }

    public void printArray(Card arr[], int N) {
        for (int i = 0; i < N-1; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println(arr[N-1]);
    }

    public void bubbleSort(Card[] arr, int N) {
        for (int endIx = 0; endIx < N; endIx++) {
            boolean flag = true;
            for (int i = N-1; i > endIx; i--) {
                if (arr[i-1].value > arr[i].value) {
                    flag = false;
                    Card tmp = arr[i];
                    arr[i] = arr[i-1];
                    arr[i-1] = tmp;
                }
            }
            if (flag) {
                break;
            }
        }
    }

    public void selectionSort(Card[] arr, int N) {
        for (int i = 0; i < N-1; i++) {
            int minIx = i;
            for (int j = minIx+1; j < N; j++) {
                if (arr[j].value < arr[minIx].value) {
                    minIx = j;
                }
            }
            if (minIx != i) {
                // swap arr[i] & arr[minIx]
                Card tmp = arr[i]; arr[i] = arr[minIx]; arr[minIx] = tmp;
            }
        }
    }

    private boolean isStable(Card[] arr1, Card[] arr2, int N) {
        boolean res = true;
        for (int i = 0; i < N; i++) {
            if (arr1[i].suit != arr2[i].suit || arr1[i].value != arr2[i].value) {
                res = false;
                break;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.bubbleSort(m.arr1, m.N);
        m.printArray(m.arr1, m.N);
        System.out.println("Stable");
        m.selectionSort(m.arr2, m.N);
        m.printArray(m.arr2, m.N);

        boolean isStable = m.isStable(m.arr1, m.arr2, m.N);
        if (isStable) {
            System.out.println("Stable");
        } else {
            System.out.println("Not stable");
        }
    }
}


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

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

    //freopen("test.inp" , "r" , stdin);
    //freopen("test.out" , "w" , stdout);

    int a, b; cin >> a >> b;
    if (a > 9 || b > 9)
        cout << -1;
    else cout << a * b;
}



Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    int n ; 
    cin >> n ; 
    int ans = 0 ; 
    for(int i=1;i<=n;i++){
    	int cnt = 0 ; 
    	int cur = i ; 
    	while(cur != 0 ){
    		cur/=10 ; 
    		cnt++ ; 
    	}
    	if ( cnt & 1 ) ans++ ; 
    }
    cout << ans << endl;
    return 0 ; 
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>

using namespace std;

typedef long long ll;
ll deg(ll n){
    ll count = 0;
    while(n!= 0){
        n/=10;
        count++;
    }
    return count;
}
int main(){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    int sum = 1;
    while(sum < b){
        ans++;
        sum += a-1;
    }
    cout << ans << endl;
}

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

const double PI = M_PI;
double a, b, x;
void solve() {
    cin >> a >> b >> x;
    double y = min(x, a * a * b - x);
    if(x == y) {
        printf("%.9lf\n", atan(a * b * b / (2 * y)) * 180 / PI);
    } else {
        printf("%.9lf\n", atan(2 * y / (a * a * a)) * 180 / PI);
    }
}

int main() {
    solve();
    return 0;
}



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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	bool yes = true;
	for (int k = 0; k < n; k++) {
		if (p[k] != k + 1) yes = false;
	}
	if (yes) {
		cout << "YES\n";
		return 0;
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < i; j++) {
			swap(p[i], p[j]);
			bool yes = true;
			for (int k = 0; k < n; k++) {
				if (p[k] != k + 1) yes = false;
			}
			if (yes) {
				cout << "YES\n";
				return 0;
			}
			swap(p[i], p[j]);
		}
	}
	cout << "NO\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define db long double
#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define gc() getchar()
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
inline ll rd()
{
	ll x=0;char c=gc();while(!isdigit(c))c=gc();
	while(isdigit(c))x=x*10+c-48,c=gc();return x;
}
const int N=1000005,B=90,P=1e9+7;
ll f[B+5];vector<pii>V[B+5];
int main()
{
	f[0]=f[1]=1;rep(i,2,B)f[i]=f[i-1]+f[i-2];
	V[1].pb(mp(1,2));V[1].pb(mp(1,3));V[1].pb(mp(1,4));
	rep(i,1,B-3)fore(j,V[i])
	{
		ll x=V[i][j].X,y=V[i][j].Y;y+=x;x=y-x;
		while(y<=f[i+3]+f[i-1])V[i+1].pb(mp(x,y)),y+=x;
	}
    int T=rd();
    while(T--)
    {
    	ll x=rd(),y=rd(),K=1;if(x>y)swap(x,y);
		while(f[K+1]<=x&&f[K+2]<=y)K++;printf("%d ",K);
		if(K==1){printf("%d\n",x*y%P);continue;}
		ll ans=0;
		fore(i,V[K-1]) 
		{
			ll a=V[K-1][i].X,b=V[K-1][i].Y;
			if(b<=x)ans=(ans+(y-a)/b)%P;
			if(b<=y)ans=(ans+(x-a)/b)%P;
		}
        printf("%lld\n",ans);
	}
	return 0;
}

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

string s, t;
vector<int> z(string s) {
  int n = s.size();
  vector<int> z(n);
  int x = 0, y = 0;
  for (int i = 1; i < n; ++i) {
    z[i] = max(0, min(z[i - x], y - i + 1));
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
      x = i;
      y = i + z[i];
      ++z[i];
    }
  }
  return z;
}
bool match(string x, int cz){
  auto Z = z(x);
  return *max_element(Z.begin() + cz, Z.end()) == cz;
}
bool valid(int m){
  string a;
  for(int i = 0; i < m; ++i) a += t;
  a += "$" + s;
  return match(a, m * t.size());
}
int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
//  freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
  cin >> s >> t;
  s += s;
  while(s.size() < 5 * t.size()) s += s;
  int l = 0, r = 1e6;
  while(l < r){
    int mid = l + (r - l + 1) / 2;
    if(1LL * t.size() * mid > s.size()) r = mid - 1;
    else if(!valid(mid)) r = mid - 1;
    else l = mid;
  }
  s += s;
  if(valid(l + 1)) l = -1;
  cout << l << '\n';
  return 0;
}


Measured memory_bytes: 105360
#include<bits/stdc++.h>
#include<cstdio>
#define ll long long int
#define pb push_back
using namespace std;
int main()
{
    string s;
    map<char,ll>m;
    ll i,j,k,n,f=0;
    cin>>s;
    n=s.length();
    for(i=0;i<n;i++)
    {
        m[s[i]]++;
    }
    for(auto x:m)
    {
        if(x.second>1)
        {
            f=1;
            break;
        }
    }
    if(f==0)
    {
        cout<<"yes"<<endl;
    }
    else
        cout<<"no"<<endl;
    return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
        MSG(0)
    else
        MSG(min(a * b, min(b * c, c * a)))
}


Measured memory_bytes: 256
#define PI 3.14159265
#include<math.h>
#include<stdio.h>

int main(void)
{
	double a,b,c,deg,S,L,h,rad;

	scanf("%lf %lf %lf",&a,&b,&deg);
	rad=deg*PI/180;

	S=a*b*sin(rad)/2;
	c=sqrt(a*a+b*b-2*a*b*cos(rad));
	L=a+b+c;
	h=b*sin(rad);
	
	printf("%lf\n%lf\n%lf",S,L,h);

	return 0;
}


Measured memory_bytes: 2044
# dpD
import sys
input = sys.stdin.readline

def main():
    N, W = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N))
    dp = [0] * (W + 1)
    for i in range(N):
        for j in range(W, A[i][0] - 1, -1):
            dp[j] = max(dp[j], dp[j - A[i][0]] + A[i][1])
    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 39920
import sys
from collections import deque
readline = sys.stdin.readline
n, m = map(int, readline().split())
P = list(map(lambda x:int(x)-1, readline().split()))
G = [set() for _ in range(n)]
for i in range(m):
    x, y = map(lambda x:int(x)-1, readline().split())
    G[x].add(y)
    G[y].add(x)

D = {}
cnt = 0
V = [-1]*n
for i in range(n):
    if V[i]!=-1: continue
    V[i] = cnt
    que = deque([i])
    D[cnt] = set([P[i]])
    while que:
        nw = que.popleft()
        for nx in G[nw]:
            if V[nx] != -1: continue
            D[cnt].add(P[nx])
            V[nx] = cnt
            que.append(nx)
    cnt += 1
print(sum([int(i in D[V[i]]) for i in range(n)]))

Measured memory_bytes: 89772
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  vector<vector<int> > c(3, vector<int>(3));
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> c[i][j];
    }
  }
  vector<int> a(3), b(3);
  a[0] = 0;
  b[0] = c[0][0], b[1] = c[0][1], b[2] = c[0][2];
  a[1] = c[1][0] - b[0], a[2] = c[2][0] - b[0];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (a[i] + b[j] != c[i][j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main(){
  long long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  long long one=min({4*Q, 2*H, S});
  long long two=min({2*one, D});
  cout << (N%2)*one+(N/2)*two << endl;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define INF 1000000007LL
int t[101];
int pri[26];
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[y] = px;
	}
	else {
		pr[x] = py;
	}
	return true;
}
struct edge {
	int to;
	bool use = false;
	edge(int _to) : to(_to) {}
};
ll calc(ll v) {
	if (v == 0) return 0;
	ll sa = 1;
	int to = 10;
	for (ll j = 0; j < to; j++)
	{
		sa *= v;
		sa %= INF;
	}

	return sa;
}

ll dp[200010][50];
void solv() {

	string a;
	cin >> a;
	int n = a.size();
	ll res = 1;
	for (size_t i = 1; i <= n; i++)
	{

		for (size_t j = 0; j < 50; j++)
		{
			dp[i][j] = dp[i - 1][j];
		}
		int c = a[i - 1] - 'a';
		res += (i - 1) - dp[i][c];
		dp[i][c]++;
	}

	cout << res << endl;
}


int main() {
	solv();

	return 0;
}


Measured memory_bytes: 78724
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  float x[10000];
  string u[10000];
  float ans = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x[i] >> u[i];
  }
  for(int i=0;i<n;i++){
    if(u[i]=="JPY"){
      ans = ans + x[i];
    } else {
      ans = ans + x[i]*380000.0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
N=int(input())
# 文字列の入力
#s = input()
d=[]
for i in range(N):
    d.append(int(input()))

#print(d)

print(len(set(d)))

#print(s[0:K-1]+s[K-1].lower()+s[K:N])


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

int main(){
    int c[3][3];
    for (int i=0; i<3; ++i) for (int j=0; j<3; ++j) cin >> c[i][j];
    if (
        (c[0][0] - c[0][1] == c[1][0] - c[1][1]) &&
        (c[0][2] - c[0][1] == c[1][2] - c[1][1]) &&
        (c[2][0] - c[2][1] == c[1][0] - c[1][1]) &&
        (c[2][2] - c[2][1] == c[1][2] - c[1][1]) &&
        (c[0][0] - c[1][0] == c[0][1] - c[1][1]) &&
        (c[2][0] - c[1][0] == c[2][1] - c[1][1]) &&
        (c[0][2] - c[1][2] == c[0][1] - c[1][1]) &&
        (c[2][2] - c[1][2] == c[2][1] - c[1][1])
    ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  string s = S;
  int l = s.size();
  int res = 0;
  rep(i,l-1){
    if(s[i]=='0'&&s[i+1]=='0') {
      s[i+1] = '1';
      res++;
    }
    else if(s[i]=='1'&&s[i+1]=='1') {
      s[i+1] = '0';
      res++;
    }
  }
  int ans = 0;
  repr(i,l-1){
    if(S[i]=='0'&&S[i-1]=='0') {
      S[i-1] = '1';
      ans++;
    }
    else if(S[i]=='1'&&S[i-1]=='1') {
      S[i-1] = '0';
      ans++;
    }
  }
  cout << min(res,ans) << endl;
}



Measured memory_bytes: 512
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
#include<bits/extc++.h>
using namespace __gnu_pbds;
using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 1<<17, mod = 1e9 + 7, lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, m;
vi cur[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for(int a, b, i = 0; i < n; i++) {
		cin >> a >> b;
		cur[a].pb(b);
	}
	multiset<int, greater<int>> orz;
	int ans = 0;
	for(int i = 1; i <= m; i++) {
		for(auto j : cur[i]) orz.insert(j);
		if(!orz.empty()) {
		ans += *orz.begin();
		orz.erase(orz.begin());}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 8960
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;

void solve(){
    string s;
    cin>>s;
    rep(i,s.size()){
      s[i]='x';
    }
    cout<<s<<endl;
}


int main()
{
  solve();
}

Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

int main() {
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (a - b) * (k % 2 ? -1 : 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
const ll MOD = 1000000007ll;
int N;
int D[55];
bool check(int x){
	int l = x, r = 24-x;
	for(int i=0;i<N;i++){
		if(r<l)return false;
		if(D[i]>=l){
			l = D[i]+x;
		}else{
			if(24-D[i]>r||24-D[i]<l)return false;
			r = 24-D[i]-x;
		}
	}
	return true;
}
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&D[i]);
		D[i] = min(D[i],24-D[i]);
 	}
 	sort(D,D+N);
	int l = 0, r = 13;
	while(r-l>1){
		int mid = (l+r)/2;
		if(check(mid))l = mid;
		else r = mid;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,m=MI()
    if n%2:
        for i in range(m):
            print(1+i,n-i)
    else:
        i=1
        j=n//2
        while m and i<j:
            print(i,j)
            i+=1
            j-=1
            m-=1

        i=n//2+2
        j=n
        while m and i<j:
            print(i,j)
            i+=1
            j-=1
            m-=1

main()

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

int main(){
  int N;
  cin >>N;
  
  //N=1ddddddddddddddddddd
  if(N==1){cout <<1<<endl;}
  else{
  
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>>d.at(i);
  }

//    for(int i=0;i<N;i++){
//    cout <<d.at(i)<<endl;}
    
  sort(d.begin(),d.end());
  
   //     for(int i=0;i<N;i++){
    //cout <<d.at(i)<<endl;}
    
    
    
  int c=1;
  
  for(int i=0;i<N-1;i++){
    if(d.at(i)<d.at(i+1)){
    c++;}
  
  }
  cout <<c<<endl;
  }


}

Measured memory_bytes: 384
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		double[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),double.Parse);
    Array.Sort(nums);

    for(int i = 1; i < n; i++)
    {
      nums[i] = (nums[i]+nums[i-1])/2;
    }

		Console.WriteLine(nums[n-1]);
	}
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int h,w,n;
    cin >> h >> w >> n;
    int sr, sc;
    cin >> sr >> sc;
    sr--; sc--;
    string s,t;
    cin >> s >> t;

    int safe_start = 0, safe_end = w;
    bool r_bool = false;
    for(int i = n-1; i >= 0; i--){
        if(t[i] == 'R'){
            if(safe_start < w-1){
                safe_start--;
                safe_start = max(0,safe_start);
            }
        }else if(t[i] == 'L'){
            if(safe_end > 0){
                safe_end++;
                safe_end = min(w,safe_end);
            }
        }

        if(s[i] == 'R'){
            safe_end--;
            safe_end = max(0, safe_end);
        }else if(s[i] == 'L'){
            safe_start++;
            safe_start = min(w,safe_start);
        }
    }
    if(safe_start <= sc && sc < safe_end) r_bool = true;

    safe_start = 0, safe_end = h;
    bool c_bool = false;
    for(int i = n-1; i >= 0; i--){
        if(t[i] == 'D'){
            if(safe_start < h-1){
                safe_start--;
                safe_start = max(0,safe_start);
            }
        }else if(t[i] == 'U'){
            if(safe_end > 0){
                safe_end++;
                safe_end = min(h,safe_end);
            }
        }

        if(s[i] == 'D'){
            safe_end--;
            safe_end = max(0, safe_end);
        }else if(s[i] == 'U'){
            safe_start++;
            safe_start = min(h,safe_start);
        }
    }
    if(safe_start <= sr && sr < safe_end) c_bool = true;

    cout << ((r_bool && c_bool) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 920
#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 INF = 1001001001;

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;
}

int main() {
    int h, n;
    cin >> h >> n;
    vector<vector<int>> dp(n+1, vector<int>(h+1));
    rep(i,n+1)rep(j,h+1) {
        if (j == 0) dp[i][j] = 0;
        else dp[i][j] = INF;
        //dp[i][j] = INF;
    }
    //dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        for (int j = 0; j <= h; j++) {
            //chmin(dp[i+1][j], dp[i][j]);
            if (j - a >= 0) chmin(dp[i+1][j], dp[i+1][j-a] + b);
            else chmin(dp[i+1][j], b);
            chmin(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}


Measured memory_bytes: 42336
#include<stdio.h>
int main(void)
{
	int a,b,c,s,x;
	while(1){
	scanf("%d%d",&a,&b);
	if(a==0&&b==0) break;
		s=0;
		if(a<b){
			s=a;
			a=b;
			b=s;
		}
		x=0;
		while(1){
			a=a%b;
			s=a;
			a=b;
			b=s;
			x++;
			if(b==0) break;
		}
		printf("%d %d\n",a,x);
	}
	return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> p(m);
	vector<string> s(m);
	for(int i=0; i<m; i++){
		int a;
		cin >> a >> s.at(i);
		a--;
		p.at(i) = a;
	}
	vector<bool> ac(n);
	vector<int> num(n);
	for(int i=0; i<n; i++){
		ac.at(i) = false;
		num.at(i) = 0;
	}
	int score = 0;
	int pena = 0;
	for(int i=0; i<m; i++){
		if(s.at(i) == "WA"){
			if(!ac.at(p.at(i))){
				num.at(p.at(i))++;
			}
		}else{
			if(!ac.at(p.at(i))){
				score++;
				ac.at(p.at(i))=true;
			}
		}
	}
	for(int i=0; i<n; i++){
		if(ac.at(i)){
			pena += num.at(i);
		}
	}
	cout << score << " " << pena << endl;  	
}



Measured memory_bytes: 6528
int main(){int n,m,p,i;for(;scanf("%d%d",&n,&m),n|m;printf("%d\n",p)){int f[12]={0};for(i=n;i--;f[p]+=n)scanf("%d%d",&n,&p);p=0;for(i=10;i>=0;p+=f[i]*i,i--)for(;f[i]&&m;)m--,f[i]--;}}

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

const int MAXV = 101;
int visited[MAXV][MAXV], dist[MAXV][MAXV];
pair<int, int> parent[MAXV][MAXV];

const int offset[4][2] = {
    { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 }
};



int wall1[MAXV][MAXV][MAXV];
int wall2[MAXV][MAXV][MAXV];
int H, W;


void bfs(int i, int j){
    memset(parent, -1, sizeof(parent));
    memset(dist, 0, sizeof(dist));
    memset(visited, 0, sizeof(visited));
    
    
    queue<pair<int, int>> q;
    q.push(make_pair(i, j));
    visited[i][j] = 1, dist[i][j] = 0;
    
    while (!q.empty()) {
        pair<int, int> u = q.front();
        q.pop();
        
        for (int k = 0; k < 4; k++) {
            int ii = u.first + offset[k][0], jj = u.second + offset[k][1];
            if (ii < 0 || jj < 0 || ii >= H || jj >= W) {
                continue;
            }
            if (!visited[ii][jj]) {
                if (u.first == ii && !wall1[u.first][u.second][jj]) {
                    visited[ii][jj] = 1, parent[ii][jj] = u;
                    dist[ii][jj] = dist[u.first][u.second] + 1;
                    q.push(make_pair(ii, jj));
                } else if (u.second == jj && !wall2[u.first][ii][u.second]){
                    visited[ii][jj] = 1, parent[ii][jj] = u;
                    dist[ii][jj] = dist[u.first][u.second] + 1;
                    q.push(make_pair(ii, jj));
                }
            }
        }
    }
}



int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    memset(wall1, -1, sizeof(wall1));
    memset(wall2, -1, sizeof(wall2));
    
    while (cin >> W >> H, W > 0 && H > 0) {
        for (int i = 0; i < H; i++) {
            for (int j = 1; j < W; j++) {
                cin >> wall1[i][j-1][j];
                wall1[i][j][j-1] = wall1[i][j-1][j];
            }
            if (i == H - 1) {
                continue;
            }
            for (int j = 0; j < W; j++) {
                cin >> wall2[i][i+1][j];
                wall2[i+1][i][j] = wall2[i][i+1][j];
            }
        }
        bfs(0, 0);
        if (!dist[H-1][W-1]) {
            cout << dist[H-1][W-1] << endl;
        } else {
            cout << dist[H-1][W-1]+1 << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 11240
# ALDS1_2_C: Stable Sort
N = int(input())
A = input().split()

#N = 5
#A = "H4 C9 S4 D2 C3".split()

#N = 2
#A = "S1 H1".split()

def insertionSort(A, N):
    #print(" ".join(map(str, A)))
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and int(A[j][1]) > int(v[1]):
            A[j+1] = A[j]
            j = j - 1
        A[j+1] = v
    #print(" ".join(map(str, A)))
    return " ".join(map(str, A))
    
stablesort = insertionSort(A.copy(), N)

def bubbleSort(A, N):
    flag = True
    i = 0
    while(flag):
        flag = False
        for j in reversed(range(1, N)):
            if int(A[j][1]) < int(A[j-1][1]):                
                A[j], A[j-1] = A[j-1], A[j]
                flag = True
                i += 1
                #print(A)
    print(" ".join(map(str, A)))
    #print(i)
    return " ".join(map(str, A))
    
bubble = bubbleSort(A.copy(), N)
if bubble == stablesort:
    print("Stable")
else:
    print("Not stable")

def selectionSort(A, N):
    e = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if int(A[j][1]) < int(A[minj][1]):
                minj = j
        if i != minj:
            A[i], A[minj] = A[minj], A[i]
            e += 1
            #print(A)
    print(" ".join(map(str, A)))
    #print(e)
    return " ".join(map(str, A))
    
selection = selectionSort(A.copy(), N)
if selection == stablesort:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5608
/**
  *    █████╗  ██████╗       ██████╗ ██╗     ███████╗
  *   ██╔══██╗██╔════╝       ██╔══██╗██║     ╚══███╔╝
  *   ███████║██║            ██████╔╝██║       ███╔╝
  *   ██╔══██║██║            ██╔═══╝ ██║      ███╔╝
  *   ██║  ██║╚██████╗▄█╗    ██║     ███████╗███████╗
  *   ╚═╝  ╚═╝ ╚═════╝╚═╝    ╚═╝     ╚══════╝╚══════╝
  *
  *  @Author: TieWay59
  *  @Created: 2019/11/24 20:36
  *  @Link: https://atcoder.jp/contests/abc146/tasks/abc146_a
  *  @Tags:
  *
  *******************************************************/


#include <bits/stdc++.h>

#ifdef DEBUG
//#define debug(x)  cerr <<#x << " = "<<x<<endl;
#include "libs59/debugers.h"

#else
#define endl '\n'
#define debug(...)  59
#endif

#define STOPSYNC ios::sync_with_stdio(false);cin.tie(nullptr)
#define MULTIKASE int Kase=0;cin>>Kase;for(int kase=1;kase<=Kase;kase++)
typedef long long ll;
const int MAXN = 2e5 + 59;
const int MOD = 1e9 + 7;
const int INF = 0x3F3F3F3F;
const ll llINF = 0x3F3F3F3F3F3F3F3F;
using namespace std;

string s[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int a[7];

void solve(int kaseId = -1) {
    string t;
    cin >> t;
    int ans = 0;
    for (int i = 0, start = 0;; i = (i + 1) % 7) {

        if (s[i] == "SUN" && start == 1) {
            break;
        }
        if (s[i] == t) {
            start = 1;
        }
        if (start) {
            ans++;
        }
    }
    cout << ans << endl;
}

void solves() {
    MULTIKASE {
        solve(kase);
    }
}

int main() {
    STOPSYNC;
    solve();
    return 0;
}
/*

 */

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int matrix[101][101];
    int b[101],c[101];
    int i,j,k;

    for(i=1; i<=100; i++){
        for(j=1; j<=100; j++){
            matrix[i][j] = 0;
        }
    }
    for(i=1; i<=100; i++){
        b[i] = 0;
        c[i] = 0;
    }
    int n;
    int row_num, column_num;
    char op;
    scanf("%d %d", &row_num, &column_num);
    /*for(i=0; i<n; i++){
        op = getchar();
        scanf("%d %d %d %d", &b, &f, &r, &v);
        house_status[b][f][r] += v;
    }*/
    for(i=1; i<=row_num; i++){
        op = getchar();
        for(j=1; j<=column_num; j++){
            scanf("%d", &matrix[i][j]);
        }
    }
    /*for(i=1; i<=row_num; i++){
        for(j=1; j<=column_num; j++){
            printf("%d ", matrix[i][j]);
        }
        printf("\n");
    }*/
    for(i=1; i<=column_num; i++){
        op = getchar();
        scanf("%d", &b[i]);
    }
    for(i=1; i<=row_num; i++){
        for(j=1; j<=column_num; j++){
            c[i] += matrix[i][j] * b[j];
        }
    }
    for(i=1; i<=row_num; i++){
        printf("%d\n", c[i]);
    }
}



Measured memory_bytes: 2064
#include<iostream>
#include<string>

using namespace std;

int main(void){
  int a,b;
  cin >> a >> b;
  if (a  >= 13) {
	cout << b << endl;
  }else if (13 > a and a >= 6){
    cout << b/2 << endl;
  }else{
    cout << 0 <<endl;
  }
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

std::vector<int> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}


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

    int tot_num = 0;
    for(int j=1;j<N+1;j++){
        //交差がjで初項がlast_numの等差数列の和を考えればよい
        int last_num = j*(N/j);
        tot_num += (last_num + j) * (N/j)/2;

//        for(int i=1;i<N+1;i++){
//            if(i%j==0)tot_num +=i;
//        }
    }
    cout<<tot_num<<endl;



    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

char a[100][100];
char b[100][100];
int tate = 0;
int yoko = 0;

bool check(int t, int y) {
  bool f1 = false;
  bool f2 = false;

  for (int i = 0; i < 100; ++i) {
    if (a[t][i] == '#') {
      f1 = true;
    }
  }

  for (int j = 0; j < 100; ++j) {
    if (a[j][y] == '#') {
      f2 = true;
    }
  }

  if (f1 && f2) {

    return true;

  } else {
    return false;
  }
}

int main() {
  int h, w;
  cin >> h >> w;

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < h; ++i) {
    bool flag = false;
    for (int j = 0; j < w; ++j) {
      if (check(i, j)) {
        cout << a[i][j];
        flag = true;
      }
    }
    if (flag) {
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
// Abu Hurayra (HurayraIIT)
// IIT, Jahangirnagar University

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;

typedef long long LL;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef vector<int> vi; 

#define READ freopen("input.txt", "r", stdin);
#define WRITE freopen("output.txt", "w", stdout);
#define fast_io ios_base::sync_with_stdio(0);  cin.tie(0);
#define sz(a) int((a).size())
#define space " "
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define pi acos(-1.0)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define MOD 1000000007
#define PRECISION(x) cout << fixed << setprecision(x); 
 
LL mem[100];
 LL num ( LL n )
 {
     if(n==0) return 2 ;
     if(n==1) return 1 ;
     if(mem[n]!=0) return mem[n];
     mem[n] = num(n-1) + num(n-2);
     return mem[n];
 }
 
int main()
{
    fast_io
    LL n ;
    cin >> n ;
    cout << num(n) << endl;
 
    
    
    return 0;
}


 

Measured memory_bytes: 3636
using System;
using System.Linq;
 
class C
{
	static void Main()
	{
		Func<long[]> read = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
		var h = read();
		long m = h[1], v = 0L;
		foreach (var x in new int[h[0]].Select(_ => read()).OrderBy(x => x[0]))
		{
			if (x[1] >= m) { v += x[0] * m; break; }
			v += x[0] * x[1];
			m -= x[1];
		}
		Console.WriteLine(v);
	}
}

Measured memory_bytes: 27576
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		long x = sc.nextInt();
		long y = sc.nextInt();
		long total = a * x + b * y;
		if (x > y) {
			total = Math.min(total, x * 2 * c);
			total = Math.min(total, y * 2 * c + (x - y) * a);
		} else {
			total = Math.min(total, y * 2 * c);
			total = Math.min(total, x * 2 * c + (y - x) * b);
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 23764
from heapq import *

q = int(input())
b_cur = 0
diff = 0
lefts, rights = [], []

for i in range(q):
    query = input()
    if len(query) > 1:
        _, a, b = map(int, query.split())
        b_cur += b
        if len(lefts) == 0:
            heappush(lefts, -a)
        else:
            diff += abs(a + lefts[0])
            if a <= -lefts[0]:
                heappush(lefts, -a)
            else:
                heappush(rights, a)

        if len(lefts) < len(rights):
            med_r = heappop(rights)
            med_l = -lefts[0]
            diff += med_l - med_r
            heappush(lefts, -med_r)
        elif len(lefts) > len(rights)+1:
            med_l = -heappop(lefts)
            med_r = rights[0] if len(rights) > 0 else 0
            heappush(rights, med_l)
            
    else:
        print(-lefts[0], b_cur+diff)

Measured memory_bytes: 11140
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1,n,a,b,m;
    //cin>>t;
    string s,comb="";
    cin>>n;
    cin>>s;
    //s="00"+s;
    ll ans=0;
    for(ll i=0;i<10;i++){
        for(ll j=0;j<10;j++){
            ll cnt=0;
            for(ll k=0;k<10;k++){
                //if(i!=0)
                comb+='0'+i;
                //if(j!=0 || i)
                comb+='0'+j;
                comb+='0'+k;
                ll x=0;
                //cout<<comb<<" ";
                cnt=0;
                for(ll g=0;s[g];g++){
                    if(s[g]==comb[x]){
                        cnt++;
                        x++;
                    }
                    if(cnt==comb.length()){
                        //cout<<comb<<" ";
                        break;
                    }
                }
                if(cnt==comb.length())
                    ans++;
                comb="";
            }
            //comb="";
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll cnt(ll x){
  ll ans=0,count=1;
  while(true){
    if(x==1){
      ans+=count;
      break;
    }
    else{
      ans+=count;
      x/=2;
      count*=2;
    }
  }
  return ans;
}
      
int main(){
  ll H;
  cin>>H;
  cout<<cnt(H)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

	int n, m;
	std::cin >> n >> m;
	std::vector<std::vector<std::pair<int, int>>> city(n, std::vector<std::pair<int, int>>());
	rep(i, m) {
		int p, y;
		std::cin >> p >> y;
		city[p - 1].push_back({ y, i });
	}
	rep(i, n) {
		std::sort(allof(city[i]));
	}

	std::vector<std::pair<int, int>> ans(m);
	rep(i, n) {
		rep(j, (int)city[i].size()) {
			ans[city[i][j].second] = { i + 1, j + 1 };
		}
	}

	rep(i, m) {
		int first = ans[i].first;
		int second = ans[i].second;
		// 桁数を見て先頭を0で埋める
		int fDigit = 0;
		while (first > 0) {
			first /= 10;
			fDigit++;
		}
		int sDigit = 0;
		while (second > 0) {
			second /= 10;
			sDigit++;
		}
		rep(j, 6 - fDigit) {
			std::cout << 0;
		}
		std::cout << ans[i].first;
		rep(j, 6 - sDigit) {
			std::cout << 0;
		}
		std::cout << ans[i].second << std::endl;
	}

	return 0;
}

Measured memory_bytes: 7808
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

def train(X, Y, T):  # O(N)    ans: 回数
    ans = 0
    for i in range(len(X)):
        ans += max(0, X[i] - T // Y[i])
    return ans


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))
    A.sort(reverse=True)  # 0(NlogN)
    F.sort()  # O(NlogN)



    if K>=10**12:
        print(0)
        exit()

    ok = 10**12+1 #時間
    ng = -1

    # O(Nlog(maxK)?)
    while ok - ng > 1:
        mid = (ok + ng) // 2 #時間
        ans = train(A,F,mid)  #kaisuu
        if ans >K:
            ng =mid
        else:
            ok =mid

    print(ok)


if __name__ == "__main__":
    main()


Measured memory_bytes: 113620
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
vidited = [False] * (N+1)
ans = [1, A[1]]
vidited[1] = True
vidited[A[1]] = True
step = 1
n2i = {1:0, A[1]:1}
while step < K:
    next_a = A[ans[-1]]
    if vidited[next_a]:
        break
    # if next_a == 1:
    #     break
    step += 1
    n2i[next_a] = step
    vidited[next_a] = True
    ans += [next_a]
# print(ans)
# print(ans[(K)%len(ans)])
if step >= K:
    print(ans[K])
else:
    # print(step, n2i[next_a])
    # print(n2i[next_a], K-n2i[next_a], step-n2i[next_a])
    print(ans[n2i[next_a]+(K-n2i[next_a])%(step+1-n2i[next_a])])


Measured memory_bytes: 117144
#include<stdio.h>
#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 <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//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 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())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

const string YES = "YES";
const string NO = "NO";

void solve(std::string A, std::string B, std::string C){
    if(A[A.size()-1]==B[0] && B[B.size()-1] == C[0])cout<<YES<<endl;
    else cout<<NO<<endl;
    return;;
}

int main(){
    std::string A;
    std::cin >> A;
    std::string B;
    std::cin >> B;
    std::string C;
    std::cin >> C;
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
a = 1
b = 1
for i in range(n-1):
  tmp1 = 0
  tmp2 = 0
  for j in range(i):
    if p[i] > p[j]:
      tmp1 += 1
    if q[i] > q[j]:
      tmp2 += 1
  a += (p[i]-1-tmp1)*math.factorial(n-1-i)
  b += (q[i]-1-tmp2)*math.factorial(n-1-i)

print(abs(a-b))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  long long ans[2]={},n=s.size();
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      int tmp=i^(j%2);
      if(s[j]-'0' != tmp) ans[i]++;
    }
  }
  cout << min(ans[0], ans[1]) << endl;
  return 0;
}


Measured memory_bytes: 512
X, Y = map(int, input().split())
import math
mod = 10**9+7

def comb(n,r,mod):
  ans = 1
  for i in range(r):
    ans *= n-i
    ans %= mod
  for i in range(1,r+1):
    ans *= pow(i,mod-2,mod)
    ans %= mod
  return ans
  
if (2*X-Y)%3!=0 or 2*X-Y<0 or (-1)*X+2*Y<0:
  print(0)
else:
  p = (2*X-Y)//3
  q = ((-1)*X+2*Y)//3
  print(comb(p+q,p,mod))

Measured memory_bytes: 3064
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cctype>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn = 1e5 + 11;
int a[1000][1000];
int main(){
	int n; cin >> n;
	int i;
	bool flag = 1;
	for(i = 1;i < 1e3;i++){
		if(i * (i+1) == 2*n) break;
		if(i*(i+1) > 2*n) {flag = 0;break;}
	}
	if(!flag) cout << "No" << endl;
	else {
		int x = 1;
		for(int j = 1;j <= i;j++){
			for(int k = j;k <= i;k++){
				a[j][k] = x;
				a[k+1][j] = x++;
			}
		}
		cout << "Yes" << endl << i+1 << endl;
		for(int j = 1;j <= i+1;j++){
			cout << i;
			for(int k = 1;k <= i;k++)
				cout << " " << a[j][k];
			cout << endl;
		}
	}
	return 0;
}












Measured memory_bytes: 3200