akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  string s; cin>>s;
  string t; cin>>t;
  vector<vector<ll> > m(30);

  rep(i,s.size()){
    char c = s[i];
    ll d = c - 'a';
    m[d].pb(i);
  }

/*
  rep(i,26){
    rep(j,m[i].size()){
      cout<<i<<" "<<m[i][j]<<" ";
    }
    cout<<endl;
  }
*/

  //ない場合は-1を出力
  rep(i,t.size()){
    char tc = t[i];
    ll td = tc - 'a';
    if(m[td].size() == 0){
      cout<<-1<<endl;
      return 0;
    }
  }

  ll ans = 0;
  ll cnt = 1;
  ll ts = t[0] - 'a';
  ll tmp = m[ts][0];

  for(ll i = 1; i < t.size(); i++){
    ll ts = t[i] - 'a';
    ll next = POSU(m[ts] , tmp);
    if(next == m[ts].size()){
      tmp = m[ts][0];
      cnt++;
    }
    else{
      tmp = m[ts][next];
    }
    // cout<<t[i]<<" "<<cnt<<" "<<tmp<<endl;
  }
//  cout<<cnt<<endl;
  ans = (ll)s.size() * (ll)(cnt-1) + (ll)tmp + 1;
  cout<<ans<<endl;
}


Measured memory_bytes: 1724
a,b,c,d = gets.split.map(&:to_i)

c_l = b/c
c_s = a%c==0 ? a/c : (a/c+1)
c_sum = c_l - c_s + 1

d_l = b/d
d_s = a%d==0 ? a/d : (a/d+1)
d_sum = d_l - d_s + 1

cd_l = b/c.lcm(d)
cd_s = a%d==0 ? a/c.lcm(d) : (a/c.lcm(d) + 1)
cd_sum = cd_l - cd_s + 1

puts b - a + 1 - (c_sum + d_sum - cd_sum)

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 200005;

int n, m, a[N], nx[N], pos[N];
long long k;
bool vis[N];

int main() {
	read(n), read(k);
	for (int i = 0; i < n; ++i) {
		read(a[i]), --a[i];
		m = std::max(m, a[i] + 1);
	}
	for (int i = 0; i < m; ++i) {
		pos[i] = n;
	}
	for (int i = n - 1; ~i; --i) {
		nx[i] = pos[a[i]];
		pos[a[i]] = i;
	}
	for (int i = 0; i < n; ++i) {
		if (nx[i] == n) {
			nx[i] = pos[a[i]];
		}
	}
	int p = 0, len = 0;
	do {
		int w = (nx[p] <= p) + (nx[p] == n - 1);
		len += w;
		p = (nx[p] + 1) % n;
	} while (p != 0);
	if (k % len == 0) {
		return 0;
	}
	k %= len;
	while (k > 1) {
		int w = (nx[p] <= p) + (nx[p] == n - 1);
		k -= w;
		p = (nx[p] + 1) % n;
	}
	std::vector<int> s;
	for (int i = p; i < n; ++i) {
		if (vis[a[i]]) {
			while (vis[a[i]]) {
				vis[s.back()] = 0;
				s.pop_back();
			}
		} else {
			s.push_back(a[i]);
			vis[a[i]] = 1;
		}
	}
	for (int v : s) {
		print(v + 1, ' ');
	}
	putchar('\n');
}


Measured memory_bytes: 8912
#include <bits/stdc++.h>
using namespace std ;
void Read ( int &x, char c = getchar(), bool f = 0 ) {
	for ( x = 0 ; !isdigit(c) ; c = getchar() ) if (c == '-') f = 1 ;
	for ( ; isdigit(c) ; c = getchar() ) x = 10*x + c - '0' ;
	if (f) x = -x ;
}
const int maxN = 2005 ;
int n, m, Begin[maxN], Next[maxN*2], To[maxN*2], dis[maxN], e = 1, ans ;
bool vis[maxN] ;
void add ( int x, int y ) {
	To[++e] = y ;
	Next[e] = Begin[x] ;
	Begin[x] = e ;
}
void dfs ( int x ) {
	int i, u ;
	if (dis[x] == m) return ;
	for ( i = Begin[x] ; i ; i = Next[i] ) {
		u = To[i] ;
		if (vis[u]) continue ;
		dis[u] = dis[x]+1 ;
		vis[u] = 1 ;
		dfs(u) ;
	}
}
void solve_even() {
	int i, j, x ;
	m >>= 1 ;
	for ( i = 1 ; i <= n ; i ++ ) {
		memset ( dis, 0, sizeof dis ) ;
		memset ( vis, 0, sizeof vis ) ;
		vis[i] = 1 ;
		dfs(i) ;
		for ( j = 1, x = n ; j <= n ; j ++ )
			if (vis[j]) x -- ;
		ans = min(ans, x) ;
	}
}
void solve_odd() {
	int i, j, x ;
	m >>= 1 ;
	for ( i = 2 ; i <= e ; i += 2 ) {
		memset ( dis, 0, sizeof dis ) ;
		memset ( vis, 0, sizeof vis ) ;
		vis[To[i]] = vis[To[i^1]] = 1 ;
		dfs(To[i]) ;
		dfs(To[i^1]) ;
		for ( j = 1, x = n ; j <= n ; j ++ )
			if (vis[j]) x -- ;
		ans = min(ans, x) ;
	}
}
int main() {
	int i, x, y ;
	Read(n) ; Read(m) ;
	for ( i = 1 ; i < n ; i ++ ) {
		Read(x) ; Read(y) ;
		add ( x, y ) ;
		add ( y, x ) ;
	}
	ans = n ;
	if (m&1) solve_odd() ;
	else solve_even() ;
	printf ( "%d\n", ans ) ;
	return 0 ;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

vector<ll> all_divs(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N,M;
    cin >> N >> M;
    // 最大公約数を X とすると
    // α X = Mとなる
    vector<ll> divs = all_divs(M);
    sort(divs.begin(), divs.end());
    ll i = 0;
    ll ans;
    for(i=0;i<divs.size(); i++)
    {
        if(divs[i]  <=  M / N) ans = divs[i];
        //cerr << divs[i] << endl;
    }
    cout << ans << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#define Max 1000
#define INF 1000000000000000000
using namespace std;

long long int graph[Max][Max];
long long int nodes[Max][Max];


int main(){

	int n,m,l,i,j,k,x,y,z;
	
	for(i=0;i<Max;i++){
		for(j=0;j<Max;j++){
			graph[i][j] = INF;
			nodes[i][j] = INF;
		}
	}

	scanf("%d%d%d",&n,&m,&l);
	
	for(i=0;i<m;i++){
		scanf("%d%d%d",&x,&y,&z);
		graph[x][y] = z;
		graph[y][x] = z;			
	}

	for(i=1;i<=n;i++)
		graph[i][i] = 0;

	for(k=1;k<=n;k++){
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++){
				if(graph[i][j] > graph[i][k]+graph[k][j]){
					graph[i][j] = graph[i][k]+graph[k][j];
					//graph[j][i] = graph[i][j];
				}
			}
	}


	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(graph[i][j] <= l)
				nodes[i][j] = 1;
		}
		nodes[i][i] = 0;
	}
	

	for(k=1;k<=n;k++){
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++){
				if(nodes[i][j] > nodes[i][k]+nodes[k][j]){
					nodes[i][j] = nodes[i][k]+nodes[k][j];
					//nodes[j][i] = nodes[i][j];
				}
			}
	}

	int q;
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&x,&y);
		if(nodes[x][y] >= INF)
			printf("-1\n");
		else
			printf("%lld\n",nodes[x][y]-1);
		
	}

	return 0;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18


int d[2005];

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;
    rep(i, n)rep(j, n){
        if(i<j){
            int tmp = j-i;
            if(i<=x && j>=y){
                tmp -= (y-x-1);
            }else if(x <= i && i < y && y <= j){
                // printf("aida\n");
                tmp = min(j-y+i-x+1, j-i);
            }else if(x < j && j < y && i<=x){
                // printf("aida shita\n");
                tmp = min(x-i+y-j+1, j-i);
            }else if(x < i && j < y){
                tmp = min(y-j+i-x+1, j-i);
            }
            d[tmp]++;
        }
    }

    for (int i = 1; i < n; i++)
    {
        cout << d[i] << endl;
    }
    
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N+1);
    rep(i,N) cin >> A[i+1];

    int ans = 0;
    rep(i,N+1) {
        if (i%2==1 and A[i]%2==1) ans++;
    }

    cout << ans << ln;
}

Measured memory_bytes: 3652
n = gets.chomp.to_i
array = gets.chomp.split(" ").map(&:to_i)

result = 0

catch(:break_loop) do
  while true
    array.map! do |a|
      throw :break_loop if a % 2 == 1
      a / 2
    end
    result += 1
  end
end

puts result

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>

using namespace std;

int N;
int A[200010], B[200010];
pair<int, int> C[200010];

int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i] >> B[i];
        //<b, i>のpairを作りAにアクセスできるようにする
        C[i] = {B[i], i};
    }
    sort(C+1, C+N+1);
    int time = 0;
    for(int i=1;i<=N;i++){
        int id = C[i].second;
        if(time + A[id] <= B[id]) time += A[id];
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int rightSide(int top, int face){
	int result = -1;
	top %= 6;
	face %= 6;
	if(top == 0){
		if(face == 1){ result = 2; }
		else if(face == 2){ result = 4;}
		else if(face == 4){ result = 3;}
		else if(face == 3){ result = 1;}
	}else if(top == 1){
		if(face == 0){ result = 3; }
		else if(face == 3){ result = 5;}
		else if(face == 5){ result = 2;}
		else if(face == 2){ result = 0;}		
	}else if(top == 2){
		if(face == 4){ result = 0; }
		else if(face == 0){ result = 1;}
		else if(face == 1){ result = 5;}
		else if(face == 5){ result = 4;}		
	}else if(top == 3){
		if(face == 5){ result = 1; }
		else if(face == 1){ result = 0;}
		else if(face == 0){ result = 4;}
		else if(face == 4){ result = 5;}		
	}else if(top == 4){
		if(face == 2){ result = 5; }
		else if(face == 5){ result = 3;}
		else if(face == 3){ result = 0;}
		else if(face == 0){ result = 2;}		
	}else if(top == 5){
		if(face == 4){ result = 2; }
		else if(face == 2){ result = 1;}
		else if(face == 1){ result = 3;}
		else if(face == 3){ result = 4;}		
	}

	return result;
}
int searchIndex(int dice[], int n){
	for(int i = 0; i < 6; i++){
		if(dice[i] == n){
			return i;
		}
	}
	return -1;
}

int isSameDice(int dice1[], int dice2[]){
	int top, face;
	int indexOfTop, indexOfFace;
	int right1, right2;
	int ngcount = 0;
	for(int i = 0; i < 6; i++){
		for(int j = i+1; j < 6; j++){
			indexOfTop = searchIndex(dice2,dice1[i]);
			indexOfFace = searchIndex(dice2,dice1[j]);
			right1 = rightSide(i, j);
			right2 = rightSide(indexOfTop,indexOfFace);
			if(right1 != -1 && right2 != -1){
				if(dice1[right1] == dice2[right2]){
				}
				else{
					ngcount++;
				}
			}
		}
	}
	if(ngcount){
		return 0;
	}
	else{
		return 1;
	}

	return 0;
}

int main(){
	int n;
	int dices[100][6];

	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 6; j++){
			cin >> dices[i][j];
		}
	}

	int sameCount = 0;
	for(int i = 0; i < n-1; i++){
		for(int j = i+1; j < n; j++){
			if(isSameDice(dices[i], dices[j])){

				//cout << "[" << i << "," << j << "] : "  << isSameDice(dices[i], dices[j]) << endl;
				for(int ii = 0; ii < 6; ii++){
					//cout << dices[i][ii] << " ";
				}
				//cout << endl;
				for(int ii = 0; ii < 6; ii++){
					//cout << dices[j][ii] << " ";
				}
				//cout << endl;
			}
			sameCount += isSameDice(dices[i], dices[j]);
			if(sameCount != 0) break;
		}
	}

	//cout << sameCount << endl;
	if(sameCount == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
from collections import defaultdict
from bisect import bisect

n, k = list(map(int, input().split()))
al = [0] * n
for i in range(n):
    al[i] = int(input())
max_al = max(al)
min_al = min(al)

# N: 処理する区間の長さ
N = max(al)+1
N0 = 2**(N-1).bit_length()
INF = 2**31-1
data = [INF]*(2*N0)
# a_k の値を x に更新


def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])
# 区間[l, r)の最小値


def query(l, r):
    L = l + N0
    R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1
        R >>= 1
    return s


for i in range(n):
    update(al[i], n)

for a in al:
    v = query(max(min_al, a-k), min(a+k, max_al)+1)
    update(a, n-((n-v)+1))
v = query(min_al, max_al+1)
print(n-v)


Measured memory_bytes: 109988
#!/usr/bin/python3

import array
from fractions import Fraction
import math
import os
import sys


def main():
    N = read_int()
    P = [Vec(x, y) for x, y in [read_ints() for _ in range(N)]]
    s = solve(N, P)
    i = int(s)
    if s % 1 == 0:
        ans = '{}.0'.format(i)
    else:
        ans = '{}.5'.format(i)
    print(ans)


def solve(N, P):
    a = P[0]
    ans = 0
    for i in range(1, N - 1):
        b = P[i]
        c = P[i + 1]
        ans += Fraction((b - a).cross(c - a), 2)
    return ans


###############################################################################
# AUXILIARY FUNCTIONS
class Vec(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y
        super().__init__()

    def __add__(self, other):
        return Vec(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vec(self.x - other.x, self.y - other.y)

    def __mul__(self, scalar):
        return Vec(self.x * scalar, self.y * scalar)

    def __rmul__(self, scalar):
        return Vec(self.x * scalar, self.y * scalar)

    def __truediv__(self, scalar):
        return Vec(self.x / scalar, self.y / scalar)

    def __iadd__(self, other):
        self.x += other.x
        self.y += other.y
        return self

    def __isub__(self, other):
        self.x -= other.x
        self.y -= other.y
        return self

    def __imul__(self, scalar):
        self.x *= scalar
        self.y *= scalar
        return self

    def __idiv__(self, scalar):
        self.x /= scalar
        self.y /= scalar
        return self

    def __neg__(self):
        return Vec(-self.x, -self.y)

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def abs2(self):
        return self.x * self.x + self.y * self.y

    def __abs__(self):
        return math.sqrt(float(self.abs2()))

    def __str__(self):
        return '({}, {})'.format(self.x, self.y)


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7028
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	string s, t, ans = "";
	int n = Read(), x = 0;
	cin >> s >> t;
	if (s + t > t + s)
		swap(s, t);
	for (int i = 1; i * s.length() <= n; i ++)
		if ((n - i * s.length()) % t.length() == 0)
			x = i;
	for (int i = 1; i <= x; i ++)
		ans += s;
	while (ans.length() ^ n)
		ans += t;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1544
n, k = map(int, input().split())
s = input()
ans = ""
if s[k-1] == "A":tmp="a"
if s[k-1] == "B":tmp="b"
if s[k-1] == "C":tmp="c"
for i in range(len(s)):
    if i == k-1:
        ans += tmp
    else:
        ans += s[i]
print(ans)

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

int main() {
  int N;
  vector<int> v;
  cin >> N;
  if (N == 0) {
    cout << '0';
    return 0;
  }
  for (int i = 0; N != 0; i++, N -= N & 1, N /= -2) {
    v.push_back(N & 1);
  }
  reverse(v.begin(), v.end());
  for (auto i : v) {
    cout << i;
  }
  return 0;
}

Measured memory_bytes: 3628
s = input()
n = len(s)
ans = 0

for c in s:
  ans += int(c)

for i in range(n):
  res =0 
  d = int(s[i])
  if d==0:
    continue
  else:
    d -= 1
  for c in s[:i]:
    res += int(c)
  res += d
  res += (n-i-1)*9
  ans = max(ans, res)
print(ans)



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W, A, B; cin >> H >> W >> A >> B;
    //行:0と1の個数はそれぞれ{A,W-A}か{W-A,A}
    //列:0と1の個数はそれぞれ{B,H-B}か{H-B,B}
    int ans[H][W]; rep(i, H) rep(j, W) ans[i][j] = -1;
    rep(i, B) rep(j, A) ans[i][j] = 0;
    for(int i = B; i < H; i++) for(int j = A; j < W; j++) ans[i][j] = 0;

    rep(i, H) rep(j, W) if(ans[i][j] == -1) ans[i][j] = 1;

    rep(i, H){
        rep(j, W){
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<cstdlib>
#include<stdio.h>
using namespace std;

int main()
{
	char A[20];
	int i;
	gets(A);
	for (i=0;i<10;i++)
	  {
	  	if (i==3) printf("8");
	  	   else printf("%c",A[i]);
	  }
	return 0;  
 } 

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] in = new int[n];
    int[] cal = new int[n];
    for(int i = 0; i < n; i++){
      in[i] = Integer.parseInt(sc.next());
      cal[in[i] - 1]++;
    }
    long sum = 0L;
    for(int i = 0; i < n; i++){
      if(cal[i] == 0){
        continue;
      }else{
       sum += ((long)cal[i] * (cal[i] - 1)) /  2;
      }
    }
    long[] out = new long[n];
    for(int i = 0; i < n; i++){
      if(cal[i] == 0){
        continue;
      }else{
        out[i] = sum - (cal[i] - 1);
      }
    }
    for(int i = 0; i < n; i++){
      System.out.println(out[in[i] - 1]);
    }
  }
}

Measured memory_bytes: 74892
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	n = int(input())
	a = sorted(list(map(int, re.split(" +", input()))), reverse=True)
	print(sum(a[::2]) - sum(a[1::2]))

if __name__ == '__main__':
	main()

Measured memory_bytes: 21316
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int h,w,m;
	cin>>h>>w>>m;
	vector<int> vh(h+1,0);
	vector<int> vw(w+1,0);
	unordered_map<string,int> u;
	for(int i=0;i<m;i++)
	{
		int l,r;
		cin>>l>>r;
		vh[l]++;
		vw[r]++;
		string temp=to_string(l)+" "+to_string(r);
		u[temp]++;
	}
	int m1=0;
	int m2=0;
	for(int i=0;i<=h;i++)
	{
		if(vh[i]>m1)
		{
			m1=vh[i];
		}
	}
	for(int i=0;i<=w;i++)
	{
		if(vw[i]>m2)
		{
			m2=vw[i];
		}
	}
  vector<int> l1;
  vector<int> r1;
  for(int i=0;i<=h;i++)
	{
		if(vh[i]==m1)
		{
			l1.push_back(i);
		}
	}
	for(int i=0;i<=w;i++)
	{
		if(vw[i]==m2)
		{
			r1.push_back(i);
		}
	}
  int ans=0;
  for(int i=0;i<l1.size();i++)
  {
    for(int j=0;j<r1.size();j++)
    {
      
    	string temp=to_string(l1[i])+" "+to_string(r1[j]);
    	if(u.find(temp)!=u.end())
    	{
    		ans=max(ans,m1+m2-1);
    	}
    	else
    	{
    		ans=max(ans,m1+m2);
          break;
    	}
    	
    }
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 32960
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
from bisect import bisect, bisect_left, bisect_right

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)


q = int(input())
for _ in range(q):
    s = input()
    t = input()

    info = deque(deque() for _ in range(100))
    check = []
    for i in range(len(s)):
        info[ord(s[i]) - 97].appendleft(i)
    ans = [INF] * (max(len(s), len(t)) + 10)
    link = [0] * (max(len(s), len(t)) + 10)
    for i in t:
        for l in info[ord(i) - 97]:
            ans[bisect_left(ans, l)] = l
    print(bisect_left(ans, INF))


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

const int NUM=1000005;
bool flag[NUM];
vector <LL> prime;
void sieve()
{
    flag[1]=true;
    for(int i=4; i<NUM; i+=2)
        flag[i]=true;
    for(int i=3; i*i<=NUM; i+=2)
    {
        if(!flag[i])
        {
            for(int j=i*i; j<NUM; j+=(i<<1))
                flag[j]=true;
        }
    }
    prime.pb(2);
    for(int i=3; i<NUM; i+=2)
        if(!flag[i])
            prime.pb(i);
    return;
}

LL NOD(LL n)
{
    LL div=1;
    for(int i=0; prime[i]*prime[i]<=n; i++)
    {
        if(n%prime[i]==0)
        {
            LL cnt=0;
            while(n%prime[i]==0)
            {
                n/=prime[i];
                cnt++;
            }
            div*=(cnt+1);
        }
    }
    if(n>1)
    {
        div*=2LL;
    }
    return div;
}

int main()
{
    sieve();
    LL n;
    cin >> n;
    LL ans=NOD(n-1);
    for(LL i=2;i*i<=n;i++){
        if(n%i==0){
            LL m=n;
            LL d=i;
            while(m%d==0) m/=d;
            if(m%d==1) ans++;
            if(n/i==i) continue;
            m=n;
            d=n/i;
            while(m%d==0) m/=d;
            if(m%d==1) ans++;
        }
    }
    cout << ans;
//    int n;
//    cin >> n;
//    FOR(i,2,n){
//        int m=n,val=-1;
//        while(m>=i){
//            if(m%i==0) {
//                m/=i;
//                val=m;
//            }
//            else m-=i;
//        }
//        if(m==1) cout << val << ' ' << i << '\n';
//    }
}


Measured memory_bytes: 2424
N=int(input())
A = [0] * N
B = [0] * N
for n in range(N):
  A[n] = [int(x) for x in input().split()]
for n in range(N):
  B[n] = [int(x) for x in input().split()]

B.sort(key=lambda x:x[1])
B.sort()
ans = 0
for b in B:
  A.sort(key=lambda x:x[1])
  A.sort()
  q = [a for a in A if a[0] < b[0] and a[1] < b[1]]
  q_ = [a for a in A if a[0] >= b[0] or a[1] >= b[1]]
  maxa = -1
  if q:
    for i, qq in enumerate(q):
      if qq[1] > maxa:
        maxi = i
        maxa = qq[1]
    q.pop(maxi)
    ans += 1
  A = q[:] + q_[:]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


int w,h;
vector<string> mp;

vector<vector<int> > bfs(char start){
  int dx[] = {1,-1,0,0};
  int dy[] = {0,0,1,-1};
  
  queue<P> Q;
  vector<vector<int> > D(h,vector<int> (w,INF));
 
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(mp[i][j] == start) Q.push(P(i,j)), D[i][j] = 0;

  while(!Q.empty()){
    P t = Q.front();Q.pop();
    int y, x; tie(y, x) = t;
    for(int i=0;i<4;i++){
      int ny = y + dy[i];
      int nx = x + dx[i];
      if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
      if(mp[ny][nx] == '#' || mp[ny][nx] == '*') continue;
      if(D[ny][nx] != INF) continue;
      D[ny][nx] = D[y][x] + 1;
      Q.push(P(ny, nx));
    }  
  }
  return D;
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  cin>>w>>h;
  mp.resize(h);
  cin>>mp;

  P S, T;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(mp[i][j] == 's') S = P(i,j), mp[i][j] = '.';
      if(mp[i][j] == 'g') T = P(i,j);
    }

  auto DB = bfs('*');
  auto DT = bfs('g');
  
  vector<P> A;
  double dot = 0;
  int sum = 0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(mp[i][j] != '.') continue;
      if(DB[i][j] == INF && DT[i][j] == INF) continue;
      if(DT[i][j] == INF) {sum += DB[i][j]; continue;}
      dot++;
      if(DB[i][j] == INF) {sum += DT[i][j]; continue;}
      A.push_back(P(DB[i][j], DT[i][j]));
    }
  
  for(auto p:A) sum += p.second;

  sort(A.begin(),A.end(),[&](auto a,auto b){return a.first - a.second < b.first - b.second;});
  
  
  int sy = S.first, sx = S.second;
  auto calc=[&](double x){return DB[sy][sx] + x;};
  
  double ans = calc(sum/dot);
  Min(ans, (double)DT[sy][sx]);
  for(int i=0;i<(int)A.size() - 1;i++){
    sum += A[i].first - A[i].second;
    double x = sum / (dot - i - 1);
    Min(ans, calc(x));
  }
  
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 11208
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

vector<ll> P(300001,0);

void era(){
    for (int i=6; i<300001; i++) {
        if(P[i]==0)continue;
        int j=i;
        while (j<300001) {
            j+=i;
            if(j>=300001)break;
            P[j]=0;
        }
    }
}

int main(){
    P[1]=1;
    int i=1;
    while(true){
        int p,q;
        p=i*7-1;
        q=i*7+1;
        i++;
        if(p<300001){
            P[p]=p;
        }else{
            break;
        }
        if(q<300001){
            P[q]=q;
        }else{
            break;
        }
    }
    era();
    for(;;){
        ll num;
        cin >> num;
        if(num==1) break;
        cout <<num<<":";
        for (int i=2; i<=num; i++) {
            if (P[i]!=0 and num%i==0) {
                cout <<" "<<i;
            }
        }
        cout <<endl;
    }
}

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

int main() {
  ll ans = 0;
  int N;
  cin >> N;
  map<string, int> counts;
  for (int n = 0; n < N; n++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ans += counts[s];
    counts[s]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
def Z_algorithm(s):
    n = len(s)
    A = [n] + [0] * (n-1)
    i, j = 1, 0
    while i < n:
        while i + j < n and s[j] == s[i+j]:
            j += 1
        A[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < n and k + A[k] < j:
            A[i+k] = A[k]
            k += 1
        i += k
        j -= k
    return A

N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
AA = [A[i] ^ A[i-1] for i in range(N)]
BB = [B[i] ^ B[i-1] for i in range(N)]

T = Z_algorithm(AA + [-1] + BB + BB)
for i in range(N, 0, -1):
    if T[N+i+1] >= N:
        print(N-i, A[-i%N] ^ B[0])

Measured memory_bytes: 128208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();

		for (int i=0; i<=N; i++) {
			for (int j=0; j<=N-i; j++) {
				int k = N - i - j;
				int sum = 10000 * i + 5000 * j + 1000 * k;
				if (sum == Y) {
					System.out.println(i + " " + j + " " +  k);
					return;
				}
			}
		}

		System.out.println("-1 -1 -1");

	}

}


Measured memory_bytes: 23252
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    string s;
    cin >> s;
    int a,b;
    a=(s[0]-'0')*10+s[1]-'0';
    b=(s[2]-'0')*10+s[3]-'0';
    if(0<a && a<=12 && 0<b && b<=12){
        cout << "AMBIGUOUS" << endl;
    }else if(0<a && a<=12){
        cout << "MMYY" << endl;
    }else if(0<b && b<=12){
        cout << "YYMM" << endl;
    }else {
        cout << "NA" << endl;
    }
    return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    ll x, y, ans = 0;
    cin >> x >> y;

    while (x <= y) {
        ans++;
        x *= 2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>

void solve() {
    int n, x, t;
    std::cin >> n >> x >> t;
    std::cout << (n + x - 1) / x * t << "\n";
}

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

    solve();

    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int mod(int a,int b){return a%b+b;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}


template<typename T>
void ppp(T n){cout << n << endl;}

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


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<string> vstr;



vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

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

    int N;
    cin >> N;
    string s = "";
    while(N != 0){
        if(N%2 != 0){
            N--;
            s = "1" + s;
        }
        else
            s = "0" + s;
        N /= -2;
    }
    if(s == "")
        s = "0";


    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 998244353;
const double pi = M_PI;


template <typename number>
pair<number, number> extended_euclid(number a, number b)
{
  number r0, r1, a0, a1, b0, b1;
  r0 = a; r1 = b;
  a0 = 1; a1 = 0;
  b0 = 0; b1 = 1;
  while (r1>0) {
    number q1 = r0 / r1;
    number r2 = r0 % r1;
    number a2 = a0 - q1 * a1;
    number b2 = b0 - q1 * b1;
    r0 = r1 ; r1 = r2;
    a0 = a1 ; a1 = a2;
    b0 = b1 ; b1 = b2;
  }
  number c = r0;
  a = a0; //x
  b = b0; //y
  return  {a, c};
}

template  <typename number>
number inverse_N(number a, number N)
{
  pair<number, number> result = extended_euclid(a, N);
  if(result.first < 0)
  {
    result.first = result.first + N;
  }
  return result.first;
}

ll n, m, k;

ll calc() {
  ll result = m;
  rep(i, n - 1) {
    result = (result * (m - 1)) % mod;
  }
  return result;
}

int main()
{
  cin >> n >> m >> k;
  if(m == 1) {
    if(k == n - 1){
      cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
    return 0;
  }
  ll base = calc();
  ll minv = inverse_N(m - 1, mod);
  ll numerator = n - 1;
  ll denominator = 1;
  ll cand = numerator;
  ll result = base;
  for(int i = 1; i <= k; i++) {
    ll temp = base * minv;
    temp %= mod;
    temp *= cand;
    temp %= mod;
    result += temp;
    result %= mod;
    //分母の更新
    numerator = (numerator * (n - 1 - i)) % mod;
    //分子の更新
    denominator = (denominator * (i + 1)) % mod;
    //組み合わせの更新
    cand = numerator * inverse_N(denominator, mod);
    cand %= mod;
    //減る候補を更新
    minv = minv * inverse_N(m - 1, mod);
    minv %= mod;
  }
  cout << result << endl;
}


Measured memory_bytes: 3636
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう
最後にout.flush()またはout.close()をするのを忘れずに！
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        int d = sc.nextInt();
        int[][] a = new int[h][w];
        int[] point = new int[90001];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                a[i][j] = sc.nextInt();
                point[a[i][j]] = i * w + j;
            }
        }
        long[] ds = new long[h * w + 1];
        for (int i = 1; i <= h * w; i++) {
            if (i > d) ds[i] = ds[i - d] + abs(point[i] / w - point[i - d] / w) + abs(point[i] % w - point[i - d] % w);
        }
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            out.println(ds[r] - ds[l]);
        }
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

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

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

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

Measured memory_bytes: 63816
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
//cout << std::fixed << std::setprecision(15) << y << endl;


// mod
#define MOD 1000000007

// 累乗mod
ll pmod(ll n, ll m){
    if(m == 0) return 1;
    if(m == 1) return n % MOD;
    if(m % 2 == 0){
        return pmod(n * n % MOD, m / 2) % MOD;
    }
    return n * pmod(n * n % MOD, (m - 1) / 2) % MOD;
}

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

    double ans = 0.0;
    ll throwsBefore;
    ll throws;
    ll minMaxPointsBefore;
    ll minMaxPoints;
    ll firstCheck = 1;
    for(ll i = N; i > 0; i--){
        throwsBefore = throws;
        minMaxPointsBefore = minMaxPoints;
        if(i >= K){
            minMaxPoints = i;
            throws = 0;
        }else{
            if(firstCheck == 1){
                minMaxPoints = i;
                throws = 0;
                while(minMaxPoints< K){
                    minMaxPoints *= 2;
                    throws++;
                }
                firstCheck = 0;
            }else{
                minMaxPoints = (minMaxPointsBefore / (i + 1)) * i;
                throws = throwsBefore;
                while(minMaxPoints < K){
                    minMaxPoints *= 2;
                    throws++;
                }
            }
        }
        ans += 1.0 / (double)(N * pmod((ll)2, throws));
    }

    cout << std::fixed << std::setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair	
#define SIZE 200005
ll f[SIZE];
ll arr[SIZE];
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<n;++i){
		cin>>arr[i];
		f[arr[i]]++;
	}
	for(ll i=1;i<=n;++i){
		ans+=(f[i]*(f[i]-1))/2;
	}
	for(ll i=0;i<n;++i){
		ll fans=ans-(f[arr[i]]-1);
		cout<<fans<<endl;
	}
}

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

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int A = s.nextInt();
		int B = s.nextInt();

		if (A == B) {
			System.out.println("Draw");
		}
		else if (A == 1) {
			System.out.println("Alice");
		}
		else if (B == 1) {
			System.out.println("Bob");
		}
		else if (A > B) {
			System.out.println("Alice");
		}
		else {
			System.out.println("Bob");
		}
	}

}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    ll res=0;
    for(int i=n-1;i>=0;i--){
        a[i]+=res;
        if(a[i]%b[i]==0) continue;
        else{
            res+=((a[i]/b[i]+1)*b[i]-a[i]);
        }
        
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
use proconio::input;

fn main() {
	input! {
		k: u32,
		a: u32,
		b: u32,
	}

	for i in a..b + 1 {
		if i % k == 0 {
			println!("OK");
			return;
		}
	}
	println!("NG");
}


Measured memory_bytes: 2096
#include <iostream>

int main()
{
  int L, R;
  std::cin >> L >> R;
  int min = 2018;
  
  if (R - L + 1 >= 673) min = 0;
  else{
    int r = L % 2019;
    for (int i = 0; i < R - L; i++){
      for (int j = i + 1; j < R - L + 1; j++){
        int buf = (r+i) * (r+j) % 2019;
        if ( buf < min) min = buf;
      }
    }
  }
  std::cout << min << std::endl;
  return 0;
}

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

int main(){
    int N, K; cin >> N >> K;
    set<int> s;

    for (int i = 0; i < K; i++)
    {
        int d; cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a; cin >> a;
            s.insert(a);
        }
    }
    cout << N - s.size() << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

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

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

string key(string &s,int &i);
string string_(string &s,int &i);
void indent(int &i,int n);

struct item{
    map<string,item*> ptr;
    string val;
    bool is_str;
    item(string val,bool is_str):val(val),is_str(is_str){}
    string find(string &qry,int i){
        if(i==qry.size()) return ptr.begin()->second->is_str?"string \""+ptr.begin()->first+"\"":"object";
        if(qry[i]=='.') ++i;
        string tmp=string_(qry,i);
        return ptr.count(tmp) and !ptr[tmp]->is_str?ptr[tmp]->find(qry,i):"no such property";
    }
};

bool isalphabet(char ch){
    return 'a'<=ch and ch<='z';
}

bool is_indent_n(string &s,int i,int n){
    if(n==0) return true;
    if(i==s.size() or s[i]!=' ') return false;
    return is_indent_n(s,i+1,n-1);
}

void yaml(string &s,int &i,item &itm);
void mapping(string &s,int &i,item &itm,int n);
void mapping_item(string &s,int &i,item &itm,int n);

void yaml(string &s,int &i,item &itm){
    mapping(s,i,itm,0);
}

void mapping(string &s,int &i,item &itm,int n){
    mapping_item(s,i,itm,n);
    if(i!=s.size() and is_indent_n(s,i,n)) mapping(s,i,itm,n);
}

void mapping_item(string &s,int &i,item &itm,int n){
    indent(i,n);
    item* itm_=new item(key(s,i),false);
    itm.ptr[itm_->val]=itm_;
    ++i;
    if(s[i]==' '){
        ++i;
        item* str=new item(string_(s,i),true);
        itm_->ptr[str->val]=str;
        ++i;
    }else{
        ++i;
        int j=i;
        while(j!=s.size() and s[j]==' ') ++j;
        mapping(s,i,*itm_,j-i);
    }
}

string key(string &s,int &i){
    string res;
    while(isalphabet(s[i]) or isdigit(s[i])){
        res+=s[i];
        ++i;
    }
    return res;
}

string string_(string &s,int &i){
    string res;
    while(isalphabet(s[i]) or isdigit(s[i]) or s[i]==' '){
        res+=s[i];
        ++i;
    }
    return res;
}

void indent(int &i,int n){
    if(n==0) return;
    ++i;
    indent(i,n-1);
}

void solve(){
    string qry,yaml_str;
    cin >> qry;
    cin.ignore();
    {
        string buf;
        while(getline(cin,buf)){
            yaml_str+=buf;
            yaml_str+='\n';
        }
    }

    item root("",false);
    {
        int idx=0;
        yaml(yaml_str,idx,root);
    }

    cout << root.find(qry,0) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 3468
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    string s;
    cin >> s;
    int n=s.size();
    rep(i,n){
        if(i%2==0){
            if(s[i]=='L'){
                co("No");
                return 0;
            }
        }else{
            if(s[i]=='R'){
                co("No");
                return 0;
            }
        }
    }
    co("Yes");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      int x = scanner.nextInt();
      int y = scanner.nextInt();
      
      if(x == 2 || y == 2){
        System.out.println("No");
      } else{
        if(x == 4 || x == 6 || x == 9 || x == 11){
          if(y == 4 || y == 6 || y == 9 || y == 11){
            System.out.println("Yes");
          }
          else{
            System.out.println("No");
          }
        }
        else{
          if(y == 4 || y == 6 || y == 9 || y == 11){
            System.out.println("No");
          }
          else{
            System.out.println("Yes");
          }
        }
      }
	}
}

Measured memory_bytes: 21716
N,Y = map(int,input().split())
# 10000a + 5000b + 1000c = Y
# 1000a + 1000b + 1000c = 1000N
# 9000a + 4000b = Y - 1000N
# 9a +4b = Y/1000 - N

tmp = Y // 1000 - N
b_max = tmp // 4

for i in range(b_max+1):
    uhe = tmp - 4 * i
    if uhe % 9 == 0:
        #答え存在
        b = i
        c = (tmp - 4 * b) // 9
        a = N - b - c

        if a >= 0:
            print(c,b,a)
            exit()

print("-1 -1 -1")

Measured memory_bytes: 3060