akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main (void) {
    int s[100000], t[100000];
    int n, q, i, right, left, mid, count = 0;
    
    scanf ( "%d", &n );
    for ( i = 0; i < n; i++ ) {
        scanf ( " %d", &s[i] );
    }
    
    scanf ( "%d", &q);
    for ( i = 0; i<q; i++ ) {
        scanf ( " %d", &t[i] );
    }
    
    for ( i = 0; i < q; i++ ) {
        left = 0;
        right = n;
        while ( left < right ) {
            mid = ( right + left ) / 2;
            if ( s[mid] == t[i] || s[mid + 1] == t[i] ) {
                count++;
                break;
            }
            else if ( t[i] < s[mid] ) {
                right = mid;
            }
            else {
                    left = mid + 1;
            }
        }
    }
    
    printf ( "%d\n", count);
    return 0;
}


Measured memory_bytes: 2276
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

a = Counter(A).most_common(1)
ok = a[0][1] == 1
if ok:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 42980
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int u1 = n/ 500;
		int u2 = (n % 500) /5;
		sc.close();
		System.out.println(u1 *1000 + u2 *5);
	}
}


Measured memory_bytes: 23252
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	int N,M;
	int[] A,B;
	ArrayList<Integer>[] graph;
	@SuppressWarnings("unchecked")
	public void solve(){
		N = nextInt();
		M = nextInt();

		graph = new ArrayList[N];
		for(int i = 0;i < N;i++){
			graph[i] = new ArrayList<Integer>();
		}
		A = new int[M];
		B = new int[M];

		for(int i = 0;i < M;i++){
			int a = nextInt()-1;
			int b = nextInt()-1;
			A[i] = a;
			B[i] = b;

			graph[a].add(b);
			graph[b].add(a);
		}

		ArrayDeque<Long> q = new ArrayDeque<Long>();
		boolean[] used = new boolean[N];
		used[A[0]] = true;
		used[B[0]] = true;
		q.add(1000000L*A[0]);
		q.add(1000000L*B[0] + 1);

		int[][] pre = new int[2][N+1];
		int a = 0;
		int b = 0;
		while(q.size() > 0){

			long p = q.poll();
			int v = (int)(p / 1000000);
			int m = (int)(p % 1000000);

			if(m == 0){
				pre[m][a++] = v;
			}else{
				pre[m][b++] = v;
			}

			for(int n : graph[v]){
				if(used[n])continue;
				used[n] = true;
				q.add(n * 1000000L + m);
				break;
			}

		}
		out.println(a+b);
		for(int i = a-1;i >= 0;i--){
			if(i != a-1)out.print(" ");
			out.print(pre[0][i]+1);
		}
		for(int i = 0;i < b;i++){

			out.print(" "+ (pre[1][i]+1));
		}
		out.println();
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 58460
#include<stdio.h>
#include <stdlib.h>
#include<math.h>

long long int parent(long long int i)
{
  return (i-1)/2;
}
long long int left(long long int i)
{
  return 2*i+1;
}
long long int right(long long int i)
{
  return 2*i+2;
}

void maxheapify(long long int arr[], int n, int i)
{
  int l, r,largest,temp;
  l = left(i);
  r = right(i);

  	if(l<n && arr[l] > arr[i]) largest = l;
  	else largest = i;

  	if(r<n && arr[r] > arr[largest]) largest = r;

  	if(largest != i)
  	{
    	temp = arr[i];
    	arr[i] = arr[largest];
    	arr[largest] = temp;
    	maxheapify(arr,n,largest);
  	}
}

int main()
{
  int n;
  long long int arr[500000];
  scanf("%d", &n);

  for(int i=0; i<n; i++)
    scanf("%lld", &arr[i]);

  for(int i=(n-1)/2; i>=0; i--)
    maxheapify(arr,n,i);

  for(int i=0;i<n;i++)
    printf(" %lld",arr[i]);
	puts("");
 }


Measured memory_bytes: 5580
H, W = map(int, input().split())

s = [list(input()) for _ in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for i in range(H):
    for j in range(W):
        can = False
        if s[i][j] == "#":
            for k in range(4):
                x = i + dx[k]
                y = j + dy[k]
                if 0 <= x <= H - 1 and 0 <= y <= W - 1:
                    if s[x][y] == "#":
                        can = True
            if can is False:
                print("No")
                exit()

print("Yes")


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vi arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr.begin(), arr.end());
    arr.erase(unique(arr.begin(), arr.end()), arr.end());
    int res = (int)arr.size();
    if (res % 2 == 0) res--;
    cout << res << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
const int MAXN = 10100;
const int mod = 998244353;
typedef long long LL;
typedef pair<int, int> PII;
int n, k, a[MAXN], dp[MAXN], fp[MAXN];
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		if (a[i] >= k) {
			n--;
			i--;
		}
	}
	dp[0] = 1;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = MAXN - 1; j >= a[i]; --j) {
			dp[j] += dp[j - a[i]];
			if (dp[j] >= mod) dp[j] -= mod;
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = a[i]; j < MAXN; ++j) {
			dp[j] -= dp[j - a[i]];
			if (dp[j] < 0) dp[j] += mod;
		}
		bool flag = 0;
		for (int j = k - a[i]; j < k; ++j) {
			flag |= dp[j];
		}

		ans += !flag;
		for (int j = MAXN - 1; j >= a[i]; --j) {
			dp[j] += dp[j - a[i]];
			if (dp[j] >= mod) dp[j] -= mod;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,k,a,b,c,x,cnt=0;
	scanf("%d %d %d %d",&a,&b,&c,&x);
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			for(k=0;k<=c;k++){
				if(x==500*i+100*j+50*k){
					cnt++;
				}
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
import statistics
N = int(input())
A = list(map(int, input().split()))
A_med = []
for i in range(N):
    a = A[i] - (i +1)
    A_med.append(a)
b = statistics.median(A_med)
count = 0
for i in range(N):
    count += abs(A[i]-(b+i+1))
print(int(count))

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

const ll mod = 1e9 + 7;
ll dp[2020];

int main() {
	ll s;
    cin >> s;
    dp[0] = 1;
    for (int i = 0; i < 2020; ++i) {
        for (int k = 3; k < 2020; ++k) {
            if(i + k < 2020) {
                dp[i + k] += dp[i];
                dp[i + k] %= mod;
            }
        }
    }
    cout << dp[s] << endl;
}


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

int main(int argc, const char *argv[]) {
    int x, y;
    
    cin >> x >> y;
    
    if(x<y) cout << "a" << " < " << "b" << endl;
    else if (x==y) cout << "a" << " == " << "b" << endl;
    else cout << "a" << " > " << "b" << endl;
    

    return 0;
}

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

vector<pair<int64_t, int64_t>> primeFactorization(int64_t n) {
    vector<pair<int64_t, int64_t>> result;
    for (int64_t i = 2; i * i <= n; i++) {
        int64_t num = 0;
        while (n % i == 0) {
            n /= i;
            num++;
        }
        if (num != 0) {
            result.push_back({ i, num });
        }
    }

    if (n != 1) {
        result.push_back({ n, 1 });
    }

    return result;
}

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

    int64_t ans = 0;
    vector<pair<int64_t, int64_t>> prime = primeFactorization(N);
    for (const pair<int64_t, int64_t>& p : prime) {
        int64_t num = p.second;
        for (int64_t i = 1; ; i++) {
            ans++;
            int64_t next_value = num - i;
            if (next_value <= i) {
                //ここで終わり
                break;
            }
            num = next_value;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  double sum=0;
  cin>>N;
  for(int i=0;i<N;i++){
    double x;
    string u;
    cin>>x>>u;
    if(u=="BTC")
      sum+=x*380000.0;
    else
      sum+=x;
    }
  cout<<sum<<endl;
  }

Measured memory_bytes: 256
n,y = map(int,input().split())
for i in range(n+1):
 for j in range(n-i+1):
  if i*10000 + j*5000 + (n-i-j)*1000 == y:
   print(i,j,n-i-j)
   exit()
print("-1 -1 -1")







Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; i++)

ll solve(string num_str, ll mod)
{
    ll L = num_str.size();
    ll dp[L + 1][2][mod];
    fill((long long *)dp, (long long *)dp + sizeof(dp) / sizeof(long long), 0);

    dp[0][0][0] = 1;
    REP(i, L)
    {
        ll D = num_str[i] - '0';
        REP(j, 2)
        {
            REP(k, mod)
            {
                REP(d, (j ? 10 : D + 1))
                {
                    dp[i + 1][j || (d < D)][k] += dp[i][j][((mod * 10) + k - d) % mod];
                    dp[i + 1][j || (d < D)][k] %= MOD;
                }
            }
        }
    }
    return (MOD - 1 + dp[L][0][0] + dp[L][1][0]) % MOD;
}

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

    ll d;
    string n;
    cin >> n >> d;
    cout << solve(n, d) << endl;
}


Measured memory_bytes: 15872
#include<iostream>
#include<vector>

using namespace std;


int binary(int s[], int t, int n){

	int mid=n/2;
	int left=0;
	int right=n;

	while(right>=left){
		if(s[mid]==t) return 0;
		else if(s[mid]<t) left=mid+1;
		else right=mid-1;
		mid=(right+left)/2;
	}


	return 1;
}


int main(){
	
	int n,q;
	
	int cnt=0;
	cin>>n;
	int s[n];
	int nin,t;
	for(int i=0;i<n;i++){
		cin>>nin;
		s[i]=nin;
	}

	cin>>q;
	for(int j=0;j<q;j++){
		cin>>t;
		if((binary(s,t,n))==0) cnt++;
	}
	cout<<cnt<<endl;


	return 0;
}



Measured memory_bytes: 3464
#include <iostream>
#include <sstream>
#include"string.h"
#include"stdio.h"

#define DEBUG_MODE

/* define */
#define STR_LENGTH_MAX (1000)
#define ORDER_LENGTH_MAX (100)

#define	STR_PRINT		"print"
#define	STR_REVERSE	"reverse"
#define	STR_REPLACE	"replace"

using std::cout;
using std::endl;
using std::cin;
using std::string;
using std::getline;

class StrOrder {
private:
	string str;
	void swap(int a, int b);
	void PrintOrder(int a, int b);
	void ReverseOrder(int a, int b);
	void ReplaceOrder(int a, int b, string p);
public:
	void DoOrder(void);

	StrOrder();
};

int main() {
	int q = 0;
	StrOrder strOrder;
	cin >> q;
	for (int i = 0; i < q; i++) {
		strOrder.DoOrder();
	}
}



StrOrder::StrOrder() {
	cin >> str;
}
void StrOrder::DoOrder(void){
	char q[STR_LENGTH_MAX]={0};
	char p[ORDER_LENGTH_MAX+1]={0};
	scanf("\n%s",q);
	if(strcmp(q,STR_PRINT)==0){
		int a=0,b=0;
		scanf("%d",&a);
		scanf("%d",&b);
		PrintOrder(a,b);

	}
	else if(strcmp(q,STR_REVERSE)==0){
		int a=0,b=0;
		scanf("%d",&a);
		scanf("%d",&b);
		ReverseOrder(a,b);
	}
	else if(strcmp(q,STR_REPLACE)==0){
		int a=0,b=0;
		memset(p,0,sizeof(p));
		scanf("%d",&a);
		scanf("%d",&b);
		scanf("\n%s",p);
		ReplaceOrder(a,b,p);
	}
}
void StrOrder::swap(int a, int b) {
	char temp = str[a];
	str[a] = str[b];
	str[b] = temp;
}
void StrOrder::PrintOrder(int a, int b) {
	for (int i = a; i <= b; i++) {
		cout << str[i];
	}
	cout << endl;
}
void StrOrder::ReverseOrder(int a, int b) {
	for (int i = 0; a + i < b - i; i++) {
		swap(a + i, b - i);
	}
}
void StrOrder::ReplaceOrder(int a, int b, string p) {
	for(int i=0;i<=b-a;i++){
		str[a+i]=p[i];
	}
}



Measured memory_bytes: 3304
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())

sn = 0
for n in str(N):
    n = int(n)
    sn += n
if N%sn:
    print('No')
else:
    print('Yes')







Measured memory_bytes: 3316
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] hl = new long[n];
        for(int i = 0; i < n; i++){
            hl[i] = sc.nextLong();
        }
        long[] dp = new long[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for(int i = 0; i < n; i++){
            for(int k = i+1; k < n && k <= i+2; k++){
                dp[k] = Math.min(dp[k], dp[i] + Math.abs(hl[k] - hl[i]));
            }
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 48844
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<cstdlib>
#include<map>
using namespace std;




const int nil=0;
int func(int a,int b){
	return max(a,b);
}



class SparseRMQ{
	map<int,int> mp;
public:
	void insert(int x,int v){
		map<int,int>::iterator it,s,e;
		it=mp.lower_bound(x);
		if(it!=mp.end()&&it->first==x){
			if(v<=it->second)return;
			it->second=v;
			s=it;
			++s;
		}else if(it!=mp.begin()){
			s=it;
			if((--it)->second>=v)return;
			mp.insert(it,make_pair(x,v));
		}else{
			s=it;
			mp.insert(it,make_pair(x,v));
		}
		e=s;
		while(e!=mp.end()&&e->second<=v)++e;
		mp.erase(s,e);
	}
	int max(int xe)const{//(-inf,xe)
		map<int,int>::const_iterator it;
		it=mp.lower_bound(xe);
		if(it==mp.begin())return nil;
		return (--it)->second;
	}
};


class Dynamic2DRMQ_BIT{
	std::vector<SparseRMQ*> bit;
public:
	Dynamic2DRMQ_BIT(int xsize):bit(xsize+1,(SparseRMQ*)NULL){}
	~Dynamic2DRMQ_BIT(){
		for(int i=0;i<(int)bit.size();i++)
			if(bit[i])delete bit[i];
	}
	void insert(int x,int y,int v){
		x++;
		while(x<(int)bit.size()){
			if(!bit[x])bit[x]=new SparseRMQ();
			bit[x]->insert(y,v);
			x+= x&-x;
		}
	}
	int query(int xe,int ye)const{//[0,xe)*[0,ye)
		int res=nil;
		while(0<xe){
			if(bit[xe])res=func(res,bit[xe]->max(ye));
			xe-= xe&-xe;
		}
		return res;
	}
};




int m,n,A,B;

int r() {
	static const int C = ~(1<<31), M = (1<<16)-1;
	A = 36969 * (A & M) + (A >> 16);
	B = 18000 * (B & M) + (B >> 16);
	return (C & ((A << 16) + B)) % 1000000;
}
 

int main(){
	while(cin>>m>>n>>A>>B,m|n){
		vector<pair<int,pair<int,int> > > v(n+m),w;
		for(int i=0;i<m;i++){
			cin>>v[i].first>>v[i].second.first>>v[i].second.second;
		}
		for(int i=m;i<m+n;i++){
			v[i].first=r();
			v[i].second.first=r();
			v[i].second.second=r();
		}
		sort(v.begin(),v.end());
		int ans=0;
		Dynamic2DRMQ_BIT rmq2d(2000000);
		int prevx=-1;
		for(int i=0;i<m+n;i++){
			if(prevx<v[i].first){
				for(int j=0;j<w.size();j++)
					rmq2d.insert(w[j].second.first,w[j].second.second, w[j].first);
				w.clear();
				prevx=v[i].first;
			}
			int t=rmq2d.query(v[i].second.first,v[i].second.second)+1;
			ans=max(ans,t);
			w.push_back(make_pair(t,make_pair(v[i].second.first,v[i].second.second) ) );
		}

		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 92160
#include <iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
typedef long long int ll;
using namespace std;

int main(){
    int a,b,h;
    cin >> a >>b >> h;
    cout << (a+b)*h/2;
    
    return 0;
}

Measured memory_bytes: 256
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define LEFT(x) (x<<1)
#define RIGHT(x) (x<<1|1)

#define INF 1e18
#define MOD 1000000007

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

map<int,int> comp;
vi adj[200010];
ll a[200010];
ll tree[200010*4];
int ans[200010];
int n;

ll val_ant;

void update(int i, int l, int r, ll val, bool volta) {
    if(l == r) {
        if(volta) tree[i] = val_ant;
        else {
            val_ant = tree[i];
            tree[i] = val;
        }
    }else {
        int mid = (l+r)>>1;
        if(tree[LEFT(i)] < val)
            update(RIGHT(i), mid+1, r, val, volta);
        else
            update(LEFT(i), l, mid, val, volta);
        tree[i] = max(tree[LEFT(i)], tree[RIGHT(i)]);
    }
}

ll query(int i, int l, int r) {
    if(l == r) return (tree[i] < INF ? l : l-1);
    else {
        int mid = (l+r)>>1;
        if(tree[LEFT(i)] < INF)
            return query(RIGHT(i), mid+1, r);
        else
            return query(LEFT(i), l, mid);
    }
}

int cnt = 0;

void dfs(int u, int p, int cntp) {
    int me = ++cnt;
    update(1, 1, n, a[u], false);
    ll va = val_ant;
    ans[u] = query(1, 1, n);
    for(int v : adj[u]) {
        if(v == p) continue;
        dfs(v, u, me);
    }
    val_ant = va;
    update(1, 1, n, a[u], true);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 0; i < 200010 * 4; i++) tree[i] = INF;
    for(int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        adj[a].PB(b);
        adj[b].PB(a);
    }

    dfs(1, 1, 1);
    for(int i = 1; i <= n; i++) cout << ans[i] << "\n";
}


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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define DMAX 
#define NMAX 
#define MMAX 
#define MOD 1000000007

using namespace std;

long long n, k, x, v[103000100];
string s;


template<class T>
ostream& operator<<(ostream& out, vector<T> v)
{
	out << v.size() << '\n';
	for(auto e : v)
		out << e << ' ';
	return out;
}

long long pw(long long base, long long exp) {
	if(exp == 1) return base;
	if(exp == 0) return 1LL;

	long long g = pw(base, exp / 2);
	g = g * g;
	g %= MOD;
	if(exp % 2) return (g * base) % MOD;
	else return g;
}

inline long long nrc(long long k) {
	long long ans = 0;
	while(k) ans++, k/=10;
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	// for(long long i = 1; i < 100000000; i++)

	cin >> n;
	long long ans = 0;
	long long j = 1, sum = 0, p10 = 9;
	// 
	// ans = n / 8;
	for(int t = 1; t <= n / 8; t++) {
		if(n % t == 0) {
			long long nr = n / t;
			long long g = (long long)((pw(10, nr) - pw(10, nr - 1) + MOD) % MOD + MOD - t + 1) % MOD;
			// if(g < 0) g += MOD;
			ans += g;
			ans %= MOD;
		} 
		else ans++;
	}
	ans %= MOD;
	// dbg(ans);
	// dbg(ans);
	for(int i = 0; i < 10; i++) 
		v[i] = 1;
	
	for(long long i = 10; i < 23000000; i++)
		v[i] = v[i / 10] + 1;

	for(long long l = 1, r = 2, sum = v[1]; l < 10000000;sum -= v[l], l++) {
		while(sum < n) sum += v[r], r++;
		if(sum == n) {
			// dbg(l);
			// dbg(r);
			ans ++;
		}
	}

	cout << ans % MOD << '\n';
} 

Measured memory_bytes: 180480
import java.util.Scanner;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26072
#pragma gcc optimize(2)
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[2333333],vis[2333333],tot=1,cnt;
vector<int>p;
inline int gcd(int x,int y){
	if(x<y)swap(x,y);
	return !y?x:gcd(y,x%y);
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	int g=a[1];
	for(int i=2;i<=n&&g>1;i++)g=gcd(g,a[i]);
	if(g>1){cout<<"not coprime\n";return 0;}
	for(int i=1;i<=n;i++){
		int x=a[i];
		for(int j=2;j*j<=x;j++)
		    if(x%j==0){
		    	if(vis[j]){
		    		cout<<"setwise coprime\n";
		    		return 0;
				}
		    	vis[j]=1;
		    	while(x%j==0)x/=j;
		    }
		if(vis[x]){cout<<"setwise coprime\n";return 0;}
		if(x>1)vis[x]=1;
	}
	cout<<"pairwise coprime\n";
}

Measured memory_bytes: 12032
#include<stdio.h>
int main(void){
   int d, w, h, n, r, i, key = 1;
   scanf("%d %d %d", &d, &w, &h);
   while ( key ) {
      scanf("%d", &n);
      d /= 2;
      d *= d;
      w /= 2;
      w *= w;
      h /= 2;
      h *= h;
      for ( i = 0; i < n; i++ ) {
         scanf("%d", &r);
         r *= r;
         if ( r > d + w || r > w + h || r > h + d ) printf("OK\n");
         else printf("NA\n");
      }
      scanf("%d %d %d", &d, &w, &h);
      if ( d == 0 && w == 0 && h == 0 ) key = 0;
   }
   return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) (a).begin(),(a).end()

template <typename T>
class SegmentTree{
  public:
    int n;
    T element;
    vector<T> dat;
    function<T(T,T)> operate;

    SegmentTree(){}
    SegmentTree(int n_,T element_,function<T(T,T)> operate_){
        element = element_;
        operate = operate_;
        n = 1;
        while(n < n_) n *= 2;
        dat = vector<T>(n*2,element);
    }

    void update(int k,T a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = operate(dat[k*2+1],dat[k*2+2]);
        }
    }

    T query(int a,int b,int k,int l,int r){
        if(r<=a || b<=l) return element;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a,b,k*2+1,l,(l+r)/2);
        T vr = query(a,b,k*2+2,(l+r)/2,r);
        return operate(vl,vr);
    }

    T query(int a,int b) { return query(a,b,0,0,n);}

    T get(int k){
        return query(k,k+1);
    }
};

struct P{
    int l,r,id;
    bool q;
};

bool operator<(const P a, const P b) {
    if(a.r != b.r) return a.r < b.r;
    if(a.q != b.q) {
        return b.q;
    }
    return a.l < b.l;
}

int add(int a,int b){
    return a+b;
}


int main(void){
    int n,m,q;
    cin>>n>>m>>q;
    vector<P> segs;
    rep(i,m){
        int l,r;
        cin>>l>>r;
        segs.push_back({l,r+1,0,false});
    }
    rep(i,q){
        int l,r;
        cin>>l>>r;
        segs.push_back({l,r+1,i,true});
    }
    vector<int> res(q);
    sort(all(segs));
    SegmentTree<int> stree(n+1, 0, add);

    for(P seg : segs){
        if(seg.q){
            res[seg.id] = stree.query(seg.l, seg.r);
        }else{
            stree.update(seg.l, stree.get(seg.l)+1);
        }
    }
    for(int x : res){
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
int ask(int x){
	printf("%d\n",x);
	fflush(stdout);
	char s[20];
	scanf("%s",s);
	if(s[0]=='V'){
		exit(0);
	}
	return s[0]=='M';
}
int main(){
	int n;
	scanf("%d",&n);
	int lo=0,h=n;
	int l=ask(0);
	int r=l;
	while(lo<h)
	{
		int mid=(lo+h)/2;
		int m=ask(mid);
		if((mid-lo)%2!=(m^l)){
			h=mid;
			r=m;
		}else{
			lo=mid;
			l=m;
		}
	}
	return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <algorithm>
#include <numeric>

#define FOR(i,l,n) for(int i=(l);i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX_JUDGE 100
using namespace std;

int main(){
  int n,score[MAX_JUDGE];
  while(cin>>n,n){
    REP(i,n)cin>>score[i];
    sort(score,score+n);
    int sum = accumulate(score+1,score+n-1,0);
    cout << sum/(n-2) <<endl;
  }
  return 0;
}



Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
int main(void){
  const int inf = 100000000;
  int n,m;
  cin >> n >> m;
  int a[1000],b[1000],c[1000],dist[100][100];
  for(int i = 0; i < m; ++i){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(i==j)
        dist[i][j]=0;
      else
        dist[i][j]=inf;
    }
  }
  for(int i = 0; i < m; ++i){
    dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
    dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
  }
  for(int k = 0; k < n; ++k){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  int ans=m;
  for(int i = 0; i < m; ++i){
    bool shortest=false;
    for(int j = 0; j < n; ++j)
      if(dist[j][a[i]]+c[i]==dist[j][b[i]])
        shortest=true;
    if(shortest){
      ans--;
    }
  }
  cout << ans << endl;
}


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

int n;
const int maxn = 4005;
char s[maxn];
int a[maxn];
int r[3][maxn];
long long ans = 0;
int main() 
{
	scanf("%d", &n);
	scanf("%s", s);
	for (int i = 1; i <= n; i++)
	{
		if (s[i-1] == 'R')	
			a[i] = 0;
		if (s[i-1] == 'G')	
			a[i] = 1;
		if (s[i-1] == 'B')	
			a[i] = 2;
	}
	for (int i = n; i >= 1; i--)
	{
		for (int j = 0; j < 3; j++)
			r[j][i] = r[j][i + 1];
		r[a[i]][i] = r[a[i]][i] + 1;
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			if (a[i] == a[j])
				continue;
			int x;
			for (int k = 0; k < 3; k++)
			{
				if (a[i] != k && a[j] != k)
				{
					x = k;
					break;
				}
			}
			ans += r[x][j + 1];
			if (j - i + j <= n && a[j - i + j] == x)
				ans--;
		}
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 3868
#include<stdio.h>
int main(void)
{
	int e,f,x,y[4],z,i,j;
	scanf("%d %d %d %d %d %d",&y[0],&y[1],&y[2],&y[3],&e,&f);
	for(i=0;i<3;i++){
		for(j=i+1;j<4;j++){
			if(y[i]<y[j]){
				z=y[i];
				y[i]=y[j];
				y[j]=z;
			}
		}
	}
		x=y[0]+y[1]+y[2];
	if(e>=f){
		x=x+e;
		printf("%d\n",x);
	}
	else{
		x=x+f;
		printf("%d\n",x);
	}
	return 0;
}


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

int main(){
  int K, A ,B, C;
  C = 0;
  cin >> K >> A >> B;
  while(A <= B){
    if(A % K == 0){
      C = 1;
      break;
    }else{
      A = A + 1;
    }
  }
  if(C == 0){
    cout << "NG" << endl;
  }else{
    cout << "OK" << endl;
  }
}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
#include<map>
#define int long long int
int32_t main()
{
    int n;
    cin>>n;
    int f=0,t=0;
    int j;
    for(j=0;j<n;j++)
    {
		int x;
		cin>>x;
		if(x%4==0)
		    f++;
		else if(x%2==0)
		   t++;
	}
	int val=f+t/2;
	if(val>=n/2)
	  cout<<"Yes"<<endl;
	else
	  cout<<"No"<<endl;
}


Measured memory_bytes: 256
A = list(input())
k = False
p = False
if A[0] == 'A' and A[1].islower() == True and  A[-1].islower() == True and "C" in A[2:-1]:
  A.pop(0)
  A=str(A)
  A = A.replace('C', '', 1)
  k = A.islower()
if k:
  print('AC')
else:
  print('WA')

Measured memory_bytes: 3060
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solveA(args);
//		solveB(args);
//		solveC(args);
//		solveD(args);
//		solveE(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		String a = nextString();
		if('a'<= a.charAt(0) && a.charAt(0) <='z') {
			pw.println("a");

		}else {
			pw.println("A");
		}
	}
	public static void solveB(String[] args) throws Exception{

	}
	public static void solveC(String[] args) throws Exception{

	}
	public static void solveD(String[] args) throws Exception{

	}
	public static void solveE(String[] args) throws Exception{

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25420
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  long long a, b;
  cin >> n >> a >> b;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  auto f = [&](long long K) {
    long long x = 0;
    for (long long e : h) {
      long long rem = e - b * K;
      if (rem > 0) x += (rem + a - b - 1) / (a - b);
    }
    return x <= K;
  };
  long long ok = 1000000000;
  long long ng = 0;
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    if (f(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok << endl;
  return 0;
}


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

const int MAXN = 110;
int n, a[MAXN], c[MAXN], r;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		c[a[i]]++;
		r = max(r, a[i]);
	}
	int i;
	for(i = r; i > ((r+1)>>1); i--) {
		if(c[i] < 2) {
			printf("Impossible\n");
			return 0;
		}
		c[i] -= 2;
	}
	if(r & 1) {
		if(c[i] < 2) {
			printf("Impossible\n");
			return 0;
		}
		c[i] -= 2;
	}
	else {
		if(c[i] < 1) {
			printf("Impossible\n");
			return 0;
		}
		c[i]--;
	}
	for(i = ((r+1)>>1); i >= 0; i--) {
		if(c[i]) {
			printf("Impossible\n");
			return 0;
		}
	}

	printf("Possible\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int main(){
	char a[10];
	int ans=0;
	cin>>a;
	for(int i=0;i<6;i++){
		if(a[i]=='1')ans++;
	}
	cout<<ans;
	return 0;
}

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

signed main(){
    int K;
    cin >> K;
    
    int cnt = 0;
    
    vector<int> a;
    string S;
    int s = 0;
    for(int i=1;i<=9;i++){
        a.push_back(i);
    }
    
    
    int i=0;
    while(a[i] <= 323456667){
        S = to_string(a[i]);
        S = S[S.size()-1];
        s = stoi(S);
        for(int k=0;k<=9;k++){
            if( abs(s-k) <= 1) a.push_back((a[i]*10)+k);
        }
        i++;
    }
    
    sort(a.begin(),a.end());
    
    cout << a[K-1] << endl;
    return 0;
    
}


Measured memory_bytes: 1400
# coding: utf-8
# Your code here!
n=str(input())
a=int(n[:2])
b=int(n[2:])
ans="NA"
flag=0
if(a<=12 and a>=1):
    ans="MMYY"
    flag+=1
if(b<=12 and b>=1):
    ans="YYMM"
    flag+=1
if(flag==2):
    ans="AMBIGUOUS"
print(ans)
    


Measured memory_bytes: 3060
n = int(input())
S = [sorted(list(input())) for _ in range(n)]
ans = []

for i in range(len(S[0])):
    count = 0
    for j in range(n):
        if S[0][i] in S[j]:
            count += 1
    if n == count:
        for k in range(n):
            if k != 0:
                S[k].remove(S[0][i])
        ans.append(S[0][i])

print(''.join(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

void enum_divisor(ll n, vector<ll> &v) {
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i * i != n) v.push_back(n / i);
        }
    }
    sort(v.begin(), v.end());
}

int main() {
    ll N, ans = 0;
    cin >> N;
    vector<ll> v0, v1;
    enum_divisor(N, v0);
    enum_divisor(N - 1, v1);
    for (ll i = 1; i < v0.size(); i++) {
        ll n = N;
        ll k = v0[i];
        while (n % k == 0) n /= k;
        if (n % k == 1) ans++;
    }
    ans += v1.size() - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

#define pow nyapow
inline ll nyapow(ll b,ll n){
  ll ret = 1;
  while(n){
    if(n & 1) ret *= b;
    b *= b;
    n >>= 1;
  }
  return ret;
}

int main(){
  inl(N , P);
  map<ll,int> m;
  ll X = P;
  for(ll i = 2; i * i <= X; i++){
    while(X % i == 0){
      m[i]++;
      X /= i;
    }
  }
  if(X != 1){
    m[X]++;
    X = 1;
  }
  ll ans = 1;
  each(x , m){
    trc(x);
    ans *= pow(x.fi , (x.se / N));
  }
  out(ans);
}

Measured memory_bytes: 256
x = gets.chomp
n = x.length

s_cnt = 0

st_cnt = 0

n.times do |i|
  if x[i] == 'S'
    s_cnt += 1
    next
  end

  if s_cnt > 0
    st_cnt += 1
    s_cnt -= 1
  end
end

puts n - st_cnt * 2

Measured memory_bytes: 2172
def maxsum(A):
    smax = A[0]
    ssum = max(A[0], 0)
    for a in A[1:]:
        ssum += a
        smax = max(ssum, smax)
        ssum = max(ssum, 0)
    return smax

while True:
    n = int(input())
    if not n:
        break

    A = []
    for i in range(n):
        a = int(input())
        A.append(a)

    print(maxsum(A))

Measured memory_bytes: 7632
from collections import deque
k=int(input())
li=deque([i for i in range(1,10)])
cnt=9
if k<=cnt:print(k)
else:
    while cnt<k:
        v=li.popleft()
        if v%10==0:
            li.append(v*10)
            li.append(v*10+1)
            cnt+=2
        elif v%10==9:
            li.append(v*10+8)
            li.append(v*10+9)
            cnt+=2
        else:
            r=v%10
            li.append(v*10+r-1)
            li.append(v*10+r)
            li.append(v*10+r+1)
            cnt+=3
    print(li[k-cnt-1])

Measured memory_bytes: 6120
#include<stdio.h>
int main(void)
{
	int i,a,b,wa[7+1];
	for(i=1;i<=7;i++){
		scanf("%d %d",&a,&b);
		wa[i]=a-b;
	}
	for(i=1;i<=7;i++){
		printf("%d\n",wa[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
struct BIT{
    typedef long long ll;
    int size;
    vector<ll> bit;
    function<ll(ll, ll)> f = [](ll a, ll b){ return a+b; };
    BIT(int n){
        size = n;
        bit.assign(size+1, 0);
    }
    BIT(int n, ll ide, function<ll(ll, ll)> g){
        size = n;
        bit.assign(size+1, ide);
        f = g;
    }

    ll sum(int x){
        ll res = bit[0];
        while(x > 0){
            res = f(res, bit[x]);
            x -= (x & -x);
        }
        return res;
    }

    void add(int x, ll y){
        while(x <= size){
            bit[x] = f(bit[x], y);
            x += (x & -x);
        }
    }
};
int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> a(n+1, 0);
    for(int i=1;i<=n;i++) cin >> a[i];

    for(int j=0;j<k;j++){
        BIT bit(n+3);
        for(int i=1;i<=n;i++){
            bit.add(max(1, i-a[i]), 1);
            bit.add(min(n+1, i+a[i]+1), -1);
        }
        bool cont = false;
        for(int i=1;i<=n;i++){
            a[i] = bit.sum(i);
            if(a[i] < n) cont = true;
        }
        if(!cont) break;
    }
    for(int i=1;i<=n;i++){
        cout << a[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 5196
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
def getInputListF():
    outputData = []
    inputData = input().split()
    outputData = [float(n) for n in inputData]

    return outputData

def calcDis(a, b, num):
    ans = 0
    for i in range(len(a)):
        ans += abs(a[i]-b[i])**num
    ans = ans**(1/num)
    return ans

def calcChebi(a, b):
    ans = 0
    for i in range(len(a)):
        ans = max(ans, abs(a[i]-b[i]))
    return ans

n = int(input())
d1 = getInputListF()
d2 = getInputListF()

print(calcDis(d1, d2, 1))
print(calcDis(d1, d2, 2))
print(calcDis(d1, d2, 3))
print(calcChebi(d1, d2))









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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::string s;
  std::cin >> s;

  std::vector<int64_t> r, g, b;

  for (int64_t i = 0; i < n; i++) {
    if (s[i] == 'R') {
      r.push_back(i);
    } else if (s[i] == 'G') {
      g.push_back(i);
    } else {
      b.push_back(i);
    }
  }

  int64_t sum = 0;

  for (int64_t i = 0; i < n; i++) {
    for (int64_t j = i + 1; j < n; j++) {
      if (s[i] == s[j]) {
        continue;
      }
      if ((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')) {
        auto count = std::distance(
            std::lower_bound(b.cbegin(), b.cend(), j + 1), b.cend());
        const auto diff = j - i;
        if (j + diff < n && s[j + diff] == 'B') {
          count--;
        }
        sum += count;
      } else if ((s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G')) {
        auto count = std::distance(
            std::lower_bound(r.cbegin(), r.cend(), j + 1), r.cend());
        const auto diff = j - i;
        if (j + diff < n && s[j + diff] == 'R') {
          count--;
        }
        sum += count;
      } else if ((s[i] == 'B' && s[j] == 'R') || (s[i] == 'R' && s[j] == 'B')) {
        auto count = std::distance(
            std::lower_bound(g.cbegin(), g.cend(), j + 1), g.cend());
        const auto diff = j - i;
        if (j + diff < n && s[j + diff] == 'G') {
          count--;
        }
        sum += count;
      }
    }
  }

  std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

/*--------switch header--------*/
#define ALGORITHM   1
#define CASSERT     0
#define CMATH       0
#define DEQUE       0
#define FUNCTIONAL  1
#define IOMANIP     1
#define IOSTREAM    1
#define LIST        0
#define MAP         0
#define QUEUE       0
#define SET         0
#define STRING      1
#define UTILITY     1
#define VECTOR      1
#define VEC_DEBUG   1

using namespace std;

#pragma region headers
#if VEC_DEBUG
#define _GLIBCXX_DEBUG
#endif
#if ALGORITHM
#include <algorithm>
#endif
#if CASSERT
#include <cassert>
#endif
#if CMATH
#include <cmath>
#endif
#if DEQUE
#include <deque>
#endif
#if FUNCTIONAL
#include <functional>
#endif
#if IOMANIP
#include <iomanip>
#endif
#if IOSTREAM
#include <iostream>
#endif
#if LIST
#include <list>
#endif
#if MAP
#include <map>
#endif
#if QUEUE
#include <queue>
#endif
#if SET
#include <set>
#endif
#if STRING
#include <string>
#endif
#if UTILITY
#include <utility>
#endif
#if VECTOR
#include <vector>
#endif
#pragma endregion


/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    if(n/100 == 7 || n%100/10 == 7 || n%10 == 7)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3652
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static private final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static private final int upper(long v) {return (int)(v >> 32);}
	static private final int lower(long v) {return (int)(v & 0xFFFFFFFF);}

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

	static private final long load(int end, int length) {
		return pair(end, length);
	}
	static private final int end(long load) {
		return upper(load);
	}
	static private final int length(long load) {
		return lower(load);
	}
	static private final long score(int count, int last) {
		return pair(count, last);
	}
	static private final int count(long score) {
		return upper(score);
	}
	static private final int last(long score) {
		return lower(score);
	}

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

	public void exec() throws Exception{
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		if(A < 10 && B < 10) {
			out.println(A*B);
		}else {
			out.println(-1);
		}
	}
}


Measured memory_bytes: 23124
// glory be to the sky
#include<bits/stdc++.h> 
#define pb push_back
using namespace std;
	
typedef long long ll; 


ll W;
ll w[105], v[105];
int n;
map<pair<int, ll>, ll > mep;

ll f(int curr, ll rem) {
	if (curr == 0) return 0;
	pair<int, ll> param = make_pair(curr, rem);
	if (mep.count(param)) return mep[param];
	ll ans = 0, t1, t2;
	if (rem >= w[curr]) {
		t1 = f(curr - 1, rem - w[curr]) + v[curr];
		ans = max(ans, t1);
	}
	t2 = f(curr - 1, rem);
	ans = max(ans, t2);
	return mep[param] = ans;
}
int main(){

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

	cin >> n >> W;
	for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
	ll ans = f(n, W);
	cout << ans;
	return 0;	
}


Measured memory_bytes: 6272
let () = Scanf.scanf "%d\n" @@ fun n ->
  let ans = ref 1 in
  Scanf.scanf "%s" @@ fun s -> 
  for i=1 to n-1 do
    if s.[i] <> s.[i-1] then ans := !ans + 1
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 4168