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

using namespace std;
struct node {
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};

typedef struct node *Node;
#define NIL NULL
Node root;

void insert(int k) {
    Node y = NIL;
    Node x = root;
    Node z;

    z = static_cast<Node>(malloc(sizeof(struct node)));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;

    if (y == NIL) {
        root = z;
    } else if (z->key < y->key) {
        y->left = z;
    } else {
        y->right = z;
    }
}

int Inorder(node *x) {
    if (x->left != NIL) {
        Inorder(x->left);
    }
    cout << " " << x->key;
    if (x->right != NIL) {
        Inorder(x->right);
    }
    return 0;
}

int Preorder(node *x) {
    cout << " " << x->key;
    if (x->left != NIL) {
        Preorder(x->left);
    }
    if (x->right != NIL) {
        Preorder(x->right);
    }
    return 0;
}

bool find(node *x, int k) {
    while (x != NIL) {
        if(k == x->key){
            return true;
        }
        else if (k < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }
    return false;
}

int main() {
    int n, tmp;
    string com;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> com;
        if (com == "insert") {
            cin >> tmp;
            insert(tmp);
        } else if (com == "print") {
            Inorder(root);
            cout << endl;
            Preorder(root);
            cout << endl;
        } else if (com == "find") {
            cin >> tmp;
            find(root, tmp);
            if (find(root, tmp)) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }


    return 0;
}



Measured memory_bytes: 21900
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

struct segtree {
public:
	const int SIZE = 1 << 18;
	VI seg, lazy;
	//seg:区間の合計値 lazy:区間に対して、加える値でまだ遅延しているもの

	segtree() :seg(SIZE * 2), lazy(SIZE * 2) {}
	void lazy_evaluate(int k, int l, int r) {
		if (lazy[k] != 0) {
			seg[k] += lazy[k];
			//区間[l,r)にすべて同じ値を追加することになっていて、
			//segには合計値が入っているので、加える値を足す
			if (r - l > 1) {
				lazy[k * 2 + 1] += lazy[k];
				lazy[k * 2 + 2] += lazy[k];
			}
			lazy[k] = 0;
		}
	}

	void update(int a, int b, int k, int l, int r, int x) {
		lazy_evaluate(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			lazy[k] += x;
			lazy_evaluate(k, l, r);
		}
		else {
			update(a, b, k * 2 + 1, l, (l + r) / 2, x);
			update(a, b, k * 2 + 2, (l + r) / 2, r, x);
			seg[k] = seg[k * 2 + 1] + seg[k * 2 + 2];
		}
	}
	int query(int a, int b, int k, int l, int r) {
		lazy_evaluate(k, l, r);
		if (r <= a || b <= l)return 0;
		if (a <= l && r <= b)return seg[k];
		int x = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int y = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return x + y;
	}

	void update(int a, int b, int x) { update(a, b, 0, 0, SIZE, x); }
	//update(a,b,x) := [a,b)を全てxを加える
	int query(int a, int b) { return query(a, b, 0, 0, SIZE); }
	//query(a,b) := [a,b)に対する合計値を求める

};


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

	int N, K; cin >> N >> K;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
		A[i] -= K;
	}
	int sum = 0;
	VP S;
	S.push_back(pii(sum, 0));
	REP(i, N) {
		sum += A[i];
		S.push_back(pii(sum, i + 1));
	}
	SORT(S);

	int ans = 0;
	segtree seg;
	//seg.update(0, 1, 1);
	REP(i, S.size()) {
		
		seg.update(S[i].second, S[i].second + 1, 1);
		ans += seg.query(0, S[i].second);
		//cout << S[i].second<<" "<<ans << endl;
	}
	cout << ans << endl;

	

	return 0;
}



Measured memory_bytes: 14188
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	string s;
	cin >> s;
	int ans = 0;

	for (int x : s) {
		ans += x - '0';
	}

	if (ans % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 3648
N = int(input())
H = list(map(int, input().split()))

ans = 'Yes'

if N > 1:
  H_rev = list(reversed(H))

  for i in range(N-1):
    if H_rev[i] < H_rev[i+1]:
      H_rev[i+1] -= 1

    if H_rev[i] < H_rev[i+1]:
      ans = 'No'
      break

print(ans)

Measured memory_bytes: 14396
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_5_A&lang=jp
# Sorting Pairs

import sys
input = sys.stdin.readline

def main():
    l = []
    for i in range(int(input())):
        (a,b) = map(int,input().split())
        l.append((a,b))
    for a,b in sorted(l):
        print (a,b)
if __name__ == '__main__':
    main()


Measured memory_bytes: 20212
def brick_break(n, a_list):
    c = 1
    for a in a_list:
        if a==c:
            c += 1
    if c == 1:
        return -1
    else:
        return n-c+1

n = int(input())
a_list = [int(i) for i in input().split()]

print(brick_break(n, a_list))

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

template<typename ...> inline int gc(void) { return getchar(); }
inline void read(long long int &x){
    int k=gc();x=0;
    for(;k<48||k>57;k=gc());
    for(;k>47&&k<58;k=gc())x=x*10+k-48;
}

typedef priority_queue<long long> P;
long long d[300001], m, i, M, N, O, a[300000];
P q, l;

int main(){
    read(N);
    M = N << 1;
    O = N * 3;
    for(; i < O; ++i){
        read(a[i]);
    }
    for(i = 0; i < M; ++i){
        q.push(-a[i]);
        m += a[i];
        if(N <= i){
            m += q.top();
            q.pop();
        }
        d[i + 1] = m;
    }
    m = 0;
    for(i = O; --i >= N;){
        l.push(a[i]);
        m += a[i];
        if(i < M){
            m -= l.top();
            l.pop();
        }
        d[i] -= m;
    }
    cout << *max_element(d + N, d + M + 1) << endl;
}


Measured memory_bytes: 7156
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int flag = 0;
  for (int i = 0; i < 3; i ++){
    if (S.at(i) == S.at(i+1)){
      cout << "Bad" <<endl;
      flag = 1;
      break;
    }
  }
  if (flag == 0){
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
import re
while True:
    n, k = map(int, raw_input().split())

    if n == 0 and k == 0: break

    cards = set(int(raw_input()) for x in xrange(k))

    a = ''.join('o' if x in cards else 'x' for x in xrange(1, n + 1))

    if not(0 in cards):
        v = re.findall('o+', a)
        print len(max(v, key= lambda s: len(s)))
    else:
        pattern = re.compile('(o*xo*)')
        ans = 0
        for m in re.finditer('x', a):
            matched = pattern.search(a, pos=m.end())
            if matched is not None:
                ans = max(ans, len(matched.group(1)))

        print ans

Measured memory_bytes: 9328
#include <stdio.h>

int main()
{
    long long n,a,b,c;
    long long i,j;

    scanf("%lld",&n);

    for (i = 1; i <= 3500; i++)
    {
        for (j = 1; j <= 3500; j++)
        {
            if((4 * i * j - i * n - j * n) == 0 || (4 * i * j - i * n - j * n) < 0)continue;
            if((n * i * j) % (4 * i * j - i * n - j * n) == 0)
            {
                a = i;
                b = j;
                c = (n * i * j) / (4 * i * j - i * n - j * n);
                break;
            }
        }
        if(j != 3501)break;
    }
    printf("%lld %lld %lld",a,b,c);
    
}


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

int main(){
    string S, T;
	cin >> S >> T;

    int mincnt=T.size();
    for(int i=0; i<S.size(); i++){
        int cnt=0;

        for(int k=0; k<T.size(); k++){
            if( i+k >= S.size() ){
                cout << mincnt << endl; 
                return 0;
            }

            if( S.at(i+k)==T.at(k) ){
            }
            else{
                cnt++; 
            }
        }

        if( mincnt > cnt ){
            mincnt = cnt;
        }
    }

    cout << mincnt << endl;


}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.next();
		if(N.length() < 8){
			long A = new Long(N);
			if(A % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
		else{
			int sum = 0;
			int a = 0;
			for(int i = 0; i < N.length(); i++){
				a = N.charAt(i);
				a = a - 48;
				sum = sum + a;
			}
			if(sum % 9 == 0){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}


		}
		stdIn.close();
	}
}


Measured memory_bytes: 40000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 100000

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, A[MAX_N], res;
int main(int argc, char **argv) {
    cin >> N;
    for(int i = 0; i < N; ++i)
        cin >> A[i];
    
    int res = 0;
    for(int i = 0; i < N - 2; ++i)
        if(A[i] < A[i + 1] && A[i + 1] < A[i + 2] || A[i + 2] < A[i + 1] && A[i + 1] < A[i])
            ++res;

    cout << res << endl;
}

Measured memory_bytes: 256
n,m = map(int, input().split())

if n % 2 == 1:
    a = 1
    b = n - 1
    for i in range(m):
        print(a,b)
        a += 1
        b -= 1
else:
    a = n // 2
    b = a + 1
    nn = (n//2) // 2
    for i in range(m):
        print(a, b)
        if i == nn - 1:
            a -= 1
            b += 2
        else:
            a -= 1
            b += 1

Measured memory_bytes: 69548
#include<stdio.h>
#include<string.h>
int main(){
int a,b,c,k;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&k);
int i,r=0;

for(i=1; i<=k; i++){
    if(i<=a) r++;
　　else if(i<=(a+b)) r+=0;
    else r--;
     }

printf("%d",r );   
      
return 0;
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  kyun;
  in6 a,b,c,d;
  cin >> a >> b >> c >> d;
  in6 e = c*d/euclidean_gcd(c,d);
  in6 ans1 = b/c+b/d-b/e;
  a--;
  in6 ans2 = a/c+a/d-a/e;
  in6 ans = ans1-ans2;
  cout << (b-a) - ans;
  hinata;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	int n; scanf("%d", &n);
	set<int> a;
	for (int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		a.insert(x);
	}
	puts(sz(a) == n? "YES" : "NO");
}


Measured memory_bytes: 9600
import sys
input = lambda: sys.stdin.buffer.readline()
from bisect import bisect_left, bisect_right
INF = float("inf")

class LazySegmentTree:
    INF = float("inf")

    def __init__(self, n):
        self.n = 1 << (n-1).bit_length()
        self.data = [self.INF] * (self.n*2)
        self.lazy = [None] * (self.n*2)
    
    def build(self, data):
        for i, x in enumerate(data):
            self.data[self.n+i] = x
        for i in range(self.n-1, 0, -1):
            self.data[i] = min(self.data[i*2], self.data[i*2+1])
        
    def query(self, l, r):
        if not l < r: return self.INF
        self.__propagate(self.__getidx(l, r))

        l += self.n; r += self.n 
        res = self.INF
        while l < r:
            if l & 1:
                res = min(res, self.data[l])
                l += 1
            if r & 1:
                res = min(res, self.data[r-1])
            l >>= 1; r >>= 1
        return res
    
    def update(self, l, r, x):
        if not l < r: return
        idx = self.__getidx(l, r)
        self.__propagate(idx)

        l += self.n; r += self.n 
        while l < r:
            if l & 1:
                self.data[l], self.lazy[l] = x, x
                l += 1
            if r & 1:
                self.data[r-1], self.lazy[r-1] = x, x
            l >>= 1; r >>= 1
    
        for i in idx:
            self.data[i] = min(self.data[i*2], self.data[i*2+1])

    def __getidx(self, l, r):
        l += self.n; r += self.n 
        lm = l // ((l & -l) << 1)
        rm = r // ((r & -r) << 1)
        res = []
        while l < r:
            if l <= lm: res.append(l)
            if r <= rm: res.append(r)
            l >>= 1; r >>= 1
        while l:
            res.append(l)
            l >>= 1
        return res
    
    def __propagate(self, idx):
        for i in reversed(idx):
            val = self.lazy[i]
            if val is None: continue
            self.lazy[i*2] = val; self.lazy[i*2+1] = val
            self.data[i*2] = val; self.data[i*2+1] = val
            self.lazy[i] = None

def main():
    n, q = map(int, input().split())
    query = [None] * n
    for i in range(n):
        s, t, x = map(int, input().split())
        query[i] = s-x, t-x, x
    d = [int(input()) for _ in range(q)]
    lst = LazySegmentTree(q)

    query.sort(key=lambda x: x[2], reverse=True)

    for l, r, x in query:
        lst.update(bisect_left(d, l), bisect_left(d, r), x)

    for i in range(q):
        ans = lst.query(i, i+1)
        print(-1 if ans == INF else ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 125212
#include <cstdio>
#include <array>

using namespace std;

long long get_two_digits(int n, int* s){
    array<bool, 10> flag_first;
    flag_first.fill(false);
    long long cnt = 0;
    for(int i=0; i < n - 1; i++){
        if(flag_first[s[i]]){
            continue;
        }
        flag_first[s[i]] = true;
        array<bool, 10> flag_second;
        flag_second.fill(false);
        for(int j=i+1; j < n; j++){
            if(flag_second[s[j]]){
                continue;
            }
            flag_second[s[j]] = true;
            cnt++;
        }
    }
    

    return cnt;
}

long long get_three_digits(int n, int* s){
    array<bool, 10> flag_first;
    flag_first.fill(false);
    long long cnt = 0;
    for(int i=0; i < n - 1; i++){
        if(flag_first[s[i]]){
            continue;
        }
        flag_first[s[i]] = true;
        cnt += get_two_digits(n - i - 1, s + i + 1);
    }
    return cnt;
}

int main(){
    int n;
    int s[31234];
    scanf("%d\n", &n);
    for(int i=0; i < n; i++){
        char c;
        scanf("%c", &c);
        s[i] = c - '0';
        // printf("%d", s[i]);
    }
    printf("%lld\n", get_three_digits(n, s));
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;

void all_bit_search(int n, int m, vector<int> p, vector<int> s, int *ans)
{
    int flag;

    for (int bit = 0; bit < (1 << n); ++bit)
    { //スイッチのON・OFFで全探索

        flag = 1;
        REP(i, m)
        {
            //cout << bit << "and" << s[i] <<" = " << __builtin_popcount(bit & s[i])<<" p="<< p[i]<<endl;
            if (__builtin_popcount(bit & s[i]) % 2 != p[i])
                flag = 0;
        }
        if (flag)
            *ans += 1;
    }
}

int main(void)
{
    int n, m, k, tmp, ans = 0;
    cin >> n >> m;
    vector<int> p(m);
    vector<int> s(m, 0);

    REP(i, m)
    {
        cin >> k;
        REP(j, k)
        {
            cin >> tmp;
            s[i] |= (1 << (tmp - 1));
        }
    }

    REP(i, m)
    {
        cin >> tmp;
        p[i] = tmp;
    }

    all_bit_search(n, m, p, s, &ans);

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


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  int N, D;
  cin >> N >> D;
  D = 2 * D + 1;
  cout << (N + D - 1) / D << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
inline __int128 read()
{
    __int128 x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}

inline void write(__int128 x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
}

int main()
{
	ll t1,t2,a1,a2,b1,b2;//cin>>t1>>t2>>a1>>a2>>b1>>b2;
	t1=read();t2=read();a1=read();a2=read();b1=read();b2=read();
	ll v1=a1-b1;ll v2=a2-b2;
	if(v1*v2>0)
	{
		cout<<0<<endl;
		return 0;
	}
	else
	{
		ll x1=v1*t1,x2=v2*t2;
		if(x1>0&&(x1+x2)>0)
		{
			cout<<0<<endl;
			return 0;
		}
		else if(x1>0&&(x1+x2)==0)
		{
			cout<<"infinity"<<endl;
			return 0;
		}
		else if(x1>0&&(x1+x2)<0)
		{
			ll res=(-x1-x2);
			ll ans=x1/res;
			if(x1%res!=0) write(2ll*(ans)+1ll); 
			else write(2ll*(ans)); 
			return 0;
		}
		else if(x1<0&&(x1+x2)<0)
		{
			cout<<0<<endl;
			return 0;
		}
		else if(x1<0&&(x1+x2)==0)
		{
			cout<<"infinity"<<endl;
			return 0;
		}
		else if(x1<0&&(x1+x2)>0)
		{
			ll xx=-x1;
			if(xx%(x1+x2)!=0)write(2ll*(xx/(x1+x2))+1ll); 
			else write(2ll*(xx/(x1+x2))); 
			return 0;
		} 
		else while(1);
	}
	return 0;
 } 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int d;
  cin >> d;
  if (d == 22)
    cout << "Christmas Eve Eve Eve" << endl;
  else if (d == 23)
    cout << "Christmas Eve Eve" << endl;
  else if (d == 24)
    cout << "Christmas Eve" << endl;
  else
    cout << "Christmas" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long int solve(int wt[],int val[],int n,int W)
{
    long int dp[n+1][W+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(wt[i-1]<=j)
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
             

            }
            else dp[i][j]=dp[i-1][j];
			
        }
    }
   return dp[n][W];

}


int main()
{
    int n,W;
    cin>>n>>W;
    int wt[n];
    int val[n];
    for(int i=0;i<n;i++) 
    {
      cin>>wt[i]>>val[i];
      
    }
  

    cout<<solve(wt,val,n,W);

    return 0;
}


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

int main(void){
  int x, m, t;
  cin >> x;
  
  m=0;
  for (int b=2; b*b<=x; b++){
    t = b;
    do{
      t *= b;
      if (t <= x) m = max(m,t);
    } while (t <= x);
  }
  cout << (m?m:1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string S;
    cin >> S;
    int ans = 700;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'o') {
            ans += 100;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1e9+7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;

int main(){
    int N, R;
    cin >> N >> R;
    if (N > 9) cout << R << endl;
    else cout << R+100*(10-N)<< endl;
}

Measured memory_bytes: 256
def ret_num(num, val):
  for i in num:
    if i > val:
      return i

def check(num, val):
  while val > 0:
    if val % 10 not in num:
      return False
    val//=10
  return True
    
all_num=[0,1,2,3,4,5,6,7,8,9]
(val, dis)=[int(x) for x in input().split()]
dis_num=[int(x) for x in input().split()]
num=[]
for i in all_num:
  if i not in dis_num:
    num.append(i)
while True:
  if check(num, val):
    print(val)
    break
  else:
    val+=1

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){

    char W[10];

    scanf("%s",W);

    if(W[0] == 'S'){
        printf("Cloudy\n");
    }else if(W[0] == 'C'){
        printf("Rainy\n");
    }else{
        printf("Sunny\n");
    }

    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

										`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	s := next()
	t := next()

	ans := 0

	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			ans++
		}
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)

}

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func printArray(a []int) {
	for i := 0; i < len(a); i++ {
		if i >= 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, a[i])
	}
	fmt.Fprintln(out)
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}

// 挿入ソート配列
type slist struct {
	l []int
}

func makeSlist() slist {
	return slist{[]int{}}
}

func (s *slist) add(a int) {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	if pos < len(s.l) {
		s.l = append(s.l[:pos+1], s.l[pos:]...)
		s.l[pos] = a
	} else {
		s.l = append(s.l, a)
	}
}
func (s slist) contains(a int) bool {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	return pos < len(s.l) && s.l[pos] == a
}


Measured memory_bytes: 2604
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	cout << (a - 1) * (b - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    string s;
    cin >> s;

    if(s.size() == 1){
        cout << 1 << endl;
        return 0;
    }

    int ans = 0;

    string t,u,v;
    u = s.at(s.size()-1);

    while(s.size() > 0){
        v = t;
        t = u;
        for(int i = 0;i < t.size();i ++){
            s.pop_back();
        }

        if(s.size() > 0){
            u = s.at(s.size()-1);

            if(t == u && s.size() > 1){
                u += s.at(s.size()-2);
            }
        }
        ans ++;
    }

    if(v == t){
        ans --;
    }
        
    cout << ans << endl;
}

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

int main() {

    int N, M, best, far;

    cin >> N >> M;

    int students[N][2];
    int checks[M][2];

    for (int i = 0; i < N; i++) {
        cin >> students[i][0] >> students[i][1];
    }

    for (int i = 0; i < M; i++) {
        cin >> checks[i][0] >> checks[i][1];
    }

    int ans;

    for (int i = 0; i < N; i++) {
        best = INT32_MAX;
        for (int j = 0; j < M; j++) {
            far = abs(students[i][0] - checks[j][0]) + abs(students[i][1] - checks[j][1]);
            if (far < best) {
                ans = j + 1;
                best = far;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST_IO   ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Relocate freopen("./in.txt","r",stdin);freopen("./out.txt","w",stdout)
#define up(mi,a,b) for(mi=a;mi<=b;++mi)
#define down(mi,b,a) for(mi=b;mi>=a;--mi)
#define mfill(a,v) memset(a,v,sizeof(a))
#define INF 0x3f3f3f3f
#define MAX 1005
#define v_n 5005
#define LL long long
#define e_n 5000005
#define MOD 1000000007
#define eps 0.000000001
#define Blen 32
using namespace std;
vector<LL> hh;
int st[MAX];
int main(void)
{
	int i, j, k;
	FAST_IO;
	//Relocate;
	int N, K;
	cin >> N >> K;
	hh.push_back(0);
	up(i, 1, N)
	{
		cin >> j;
		hh.push_back(j);
	}
	vector<LL> tt;
	LL mx = -INF;
	up(i, 0,min(N, K))
	{
		for (int j = 0; j + i <= min(N,K); j++)
		{
			for (int k = 0; i + j + k <= K; k++)
			{
				if (k > (i + j))
					break;
				tt.clear();
				for (int f = 1; f <= i; f++)
					tt.push_back(hh[f]);
				for (int f = N-j+1; f <= N; f++)
					tt.push_back(hh[f]);
				sort(tt.begin(), tt.end());
				LL sum = 0;
				for (int f = k ; f < tt.size(); f++)
					sum += tt[f];
				mx = max(mx, sum);
			}
		}
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
class DisjointSets:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.siz = [1]*n

    def root(self,x):
        if x != self.parent[x]: 
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def same(self,x,y): 
        return self.root(x) == self.root(y)

    def unite(self,x,y): 
        x = self.root(x)
        y = self.root(y)
        if x == y: 
            return
        if self.siz[x] < self.siz[y]: 
            x,y = y,x
        self.parent[y] = x
        self.siz[x] += self.siz[y]

    def size(self,x):
        return self.siz[self.root(x)]

n,m = map(int,input().split())
p = [int(i)-1 for i in input().split()]
ds = DisjointSets(n)
for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    ds.unite(x,y)
ans = 0
for i,p in enumerate(p):
    if ds.same(i,p): ans += 1
print(ans)

Measured memory_bytes: 13812
r,c=map(int,input().split())
w=[0]*c
q=[]
for i in range(r):
    b=input().split()
    e=[int(s) for s in b]
    q.append(e)
for i in range(r):
    for j in range(c):
        w[j]+=q[i][j]
        print(q[i][j],end=' ')
    print(sum(q[i]))
for j in range(c):
    print(w[j],end=' ')
print(sum(w))


Measured memory_bytes: 6240
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){
int N ; cin >> N ;
   string S;cin >> S;
  int pointer = 0; int need_left = 0;
  for(int i = 0; i < N; i++){
    
    if(S[i] == '('){pointer++;}
    else{
      if(pointer > 0){ pointer--;}
      else{
        need_left++;}}}
    
    for(int i = 0; i < need_left; i++){ cout<< '(';}
    cout << S;
    for(int i = 0; i < pointer ; i++){ cout << ')'; }
    cout << endl; return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const int MAX = 300000;
const int mod = 998244353;

    vector<ll> fac(MAX), finv(MAX), inv(MAX);
 void cominit() {
    fac[0] = 1 ; fac[1] = 1; 
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i %mod;
        inv[i] = mod - inv[mod%i] * (mod/i) %mod;
        finv[i] = finv[i-1] * inv[i] %mod;
  		 }
	 }

 ll com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] %mod) %mod;
	}
   
int main(){
   cominit();
  int n, m, k;
  cin >> n >> m >> k;
  
  vector<ll> p(n);
   p[0] = 1;
  rep(i, n){
    if(i==0) continue;
    p[i] = p[i-1] *(m-1) %mod;
  }
  
  ll ans = 0;
  rep(i, k+1){
    ll hc = ((m * p[n-1-i] )%mod)*(com(n-1, i)) %mod;
    ans = (ans + hc) %mod;                      
  }  
    cout << ans << endl; 
  
  return 0;
}

Measured memory_bytes: 11976
#include<stdio.h>


int main(void){

 char str[1010];

int i,sum;


scanf("%s",str);

 while(str[0]!='0'){

 i=0; sum=0;

while(str[i]){

 sum+=str[i]-'0';i++;

}

printf("%d\n",sum);

scanf("%s",str);

}

return 0;

}

Measured memory_bytes: 536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*

*/
map<pair<ll,ll>,ll> MP;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll H,W,M; cin>>H>>W>>M;
  vector<ll> Y(M,0), X(M,0) ,YM(H,0), XM(W,0);
  rep(i, M){
    ll h,w; cin>>h>>w;
    YM[h-1]++;
    XM[w-1]++;
    Y[i] = h;
    X[i] = w;
    MP[{h,w}]++;
  }
  ll ans = 0, tmp=0;
  vector<ll> YK(0,0), XK(0,0);
  rep(i, H)
    tmp = max(tmp, YM[i]);
  ans += tmp;
//cout<<"1tmp:"<<tmp<<endl;
  rep(i, H)
    if (YM[i] == tmp)
      YK.push_back(i);
  tmp = 0;
  rep(i, W)
    tmp = max(tmp, XM[i]);
//cout<<"2tmp:"<<tmp<<endl;
  ans += tmp;
  rep(i, W)
    if (XM[i] == tmp)
      XK.push_back(i);
  ll xs = XK.size(), ys=YK.size();
  bool dup = true;
  rep(i, ys) rep(j, xs){
    if (MP[{YK[i]+1, XK[j]+1}] == 0){
      dup = false;
      break;
    }
  }
  if (dup) ans--;
  cout<<ans<<endl;
}

Measured memory_bytes: 54724
N, Z, W = map(int, input().split())
a = list(map(int, input().split()))
ans = abs(W-a[-1])
for i in range(N-1):
    hoge = abs(a[i]-a[-1])
    for j in range(i+1,N-1):
        hoge = min(hoge,abs(a[-1]-a[j]))
    ans = max(ans,hoge)
print(ans)



Measured memory_bytes: 42588
S = input()
if int(S[:4]) < 2019:
  print('Heisei')
else:
  if int(S[5:7]) < 4:
    print('Heisei')
  elif int(S[8:]) <= 30 and int(S[5:7]) == 4:
    print('Heisei')
  else:
    print('TBD')

Measured memory_bytes: 3060
module Main where

import qualified Data.Vector as V
import           Data.List
import           Control.Applicative
import           Control.Monad

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  ns <- fmap (sortBy (\(a:_) (b:_) -> compare a b)) . replicateM n
    $ map read . words <$> getLine
  print $ f1 ns 0 0 m

f1 [] _ mny _ = mny
f1 (n:ns) cnt mny m
  | cnt + last n < m = f1 ns (cnt + last n) (mny + last n * head n) m
  | otherwise = mny + (m - cnt) * head n


Measured memory_bytes: 156028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll limit;
  cin >> limit;
  limit--;
  string res;
  while(limit >= 0) {
    res += (char)(limit % 26 + 'a');
    limit /= 26;
    limit--;
  }
  reverse(res.begin(), res.end());
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3652
n = int(input())

def dfs(s):
    if int(s) <= n:
        ans = 1 if all(s.count(x) > 0 for x in "357") else 0
        for x in "357":
            ans += dfs(s+x)
    else:
        return 0
    return ans

print(dfs("0"))

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

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        Console.WriteLine(solve(n,s));
    }
    static int solve(int n, string s) {
        int[] ans = new int[n];
        for(int i = 1; i < n; i ++) {
            HashSet<char> x = new HashSet<char>(s.Substring(0,i));
            HashSet<char> y = new HashSet<char>(s.Substring(i));
            foreach(char c in x) {
                if(y.Contains(c)) ans[i] ++;
            }
        }
        return ans.Max();
    }
}

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

int main()
{
   string s;
   cin>>s;
   if(s=="Sunny")
      cout<<"Cloudy";
   else if(s=="Cloudy")
      cout<<"Rainy";
   else
      cout<<"Sunny";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);  
    public static void main(String[] args) throws Exception {
        long x = sc.nextLong();
        long ret = x/11*2;
        long d = x%11;
        if (0<d&&d<=6) {
            ret++;
        } else if (d>6) {
            ret  += 2;
        }
        System.out.println(ret);
    }
}


Measured memory_bytes: 9800
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

int main ()
{
	int D ;
	scanf("%d",&D);
	if ( D==25 ) puts("Christmas");
	if ( D==24 ) puts("Christmas Eve");
	if ( D==23 ) puts("Christmas Eve Eve");
	if ( D==22 ) puts("Christmas Eve Eve Eve");
	return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=a*b%mod

ll h,w;
char ch[200][200];
int rui[200][200];
short f[200][200][200],g[200][200][200];
int main(){
    cin>>h>>w;
    for(int i=0;i<200;i++)rui[i][0]=rui[0][i]=0;
    for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	    cin>>ch[i][j];  
	    rui[i+1][j+1]=rui[i+1][j]+rui[i][j+1]-rui[i][j]+(ch[i][j]=='.'); 
	}
    }
    for(int a=0;a<w;a++)for(int b=a;b<w;b++){
	for(int c=0;c<h;c++){
	    int l=c-1,r=h,d;
	    while(l<r-1){
		d=(l+r)>>1;
		int res=rui[d+1][b+1]-rui[d+1][a]-rui[c][b+1]+rui[c][a];
		if(res==0||res==(b-a+1)*(d-c+1))l=d;
		else r=d;
	    }
	    f[a][b][c]=l;
	}
    }
    for(int s=0;;s++){
	if(f[0][w-1][0]>=h-1){
	    cout<<s<<endl;
	    break;   
	}
	for(int a=0;a<w;a++)for(int b=a;b<w;b++)for(int c=0;c<h;c++){
	    int d=f[a][b][c];
	    d++;
	    if(d<h)g[a][b][c]=f[a][b][d];
	    else g[a][b][c]=h-1;
	    if(a<b){
		int l=a,r=b-1,k;
		while(l<r-1){
		    k=(l+r)>>1;
		    if(f[a][k][c]>f[k+1][b][c])l=k;
		    else r=k;
		}
		chmax(g[a][b][c],min(f[a][l][c],f[l+1][b][c]));
		chmax(g[a][b][c],min(f[a][r][c],f[r+1][b][c]));
	    }
	}
	for(int a=0;a<w;a++)for(int b=a;b<w;b++)for(int c=0;c<h;c++){
	    f[a][b][c]=g[a][b][c];
	}
    }
}



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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	
	sort(v.begin(), v.end());
	cout << v[n -1] - v[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(register int i=a;i<=b;i++)
#define Maxn 1000

using namespace std;

inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int n,m;
struct NODE{
	int tot;
	int swh[1000];
}bulb[1000];
int mode[Maxn+10];

int stat[Maxn+10];

void print(){
	cout<<"now ";
	FOR(i,1,n)
		cout<<stat[i]<<" ";
	puts("");
}

bool check(){
	//print();
	FOR(now,1,n){
		//cout<<" "<<now<<" : \n";
		int sum=0;
		FOR(i,1,bulb[now].tot)
			sum+=stat[bulb[now].swh[i]];
			//cout<<" "<<bulb[now].swh[i]<<endl;
		//cout<<" "<<now<<" : "<<sum<<endl;
		if(sum%2!=mode[now])
			return false;
	}
	return true;
}
int Ans=0;
void Find(int now){
	if(now>m){
		if(check())
			Ans++;
		return;
	}
	stat[now]=0;
	Find(now+1);
	stat[now]=1;
	Find(now+1);
	stat[now]=0;
}

int main(){
	
	m=read(); n=read();
	FOR(i,1,n){
		bulb[i].tot=read();
		FOR(j,1,bulb[i].tot){
			bulb[i].swh[j]=read();
		}
	}
	
	FOR(i,1,n) mode[i]=read();
	
	Find(1);
	cout<<Ans;
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]

# dp(直前の値を取っている)(最大個数取っている)
dp00 = 0
dp01 = -10**15
dp10 = -10**15
dp11 = a[0]

for i in range(1, n):
    if i % 2 != 0:
        dp01 = dp11
        dp11 = dp00 + a[i]
        dp00 = max(dp00, dp10)
        if i == 3:
            dp10 = a[i]
    else:
        dp10 = dp00 + a[i]
        dp00 = max(dp01, dp11)
        dp11 = dp01 + a[i]

if n % 2 == 0:
    print(max(dp01, dp11))
else:
    print(max(dp00, dp10))


Measured memory_bytes: 105112
#include<cstdio>
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        int d=gcd(a,b);
        int lc=a/d*b;
        printf("%d %d\n",d,lc);
    }
}

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

#define pb push_back
#define mp make_pair

bool comp(pair<int,int> a,pair<int,int> b){

    return a.second<b.second;

}

int main (){

    int n;
    cin >>n;
    vector<pair<int,int> > a;
    for (int i=0;i<n;i++){
        int b;
        cin >>b;
        a.pb(mp(i,b));
    }

    sort(a.begin(),a.end(),comp);

    for (int i=0;i<n;i++){
        cout <<a[i].first+1<<' ';
    }

    return 0;
}


Measured memory_bytes: 1780
from bisect import bisect_left, bisect_right

class Set(): #BinaryIndexedTree
    def __init__(self, valuelist, INF=10**18+1):
        self.n = len(valuelist) + 1
        self.value = sorted(valuelist) + [INF]
        self.comp = {v : k for k, v in enumerate(self.value, 1)}
        self.bit = BinaryIndexedTree(self.n)

    def insert(self, x, k=1):
        self.bit.add(self.comp[x], k)

    def delete(self, x, k=1):
        self.bit.add(self.comp[x], -k)

    def count(self, x):
        return self.bit.get(self.comp[x])

    def sum(self, x):
        return self.bit.sum(self.comp[x])

    def get(self, k): #k個以下のときはINFを返す
        return self.value[self.bit.bisect_left(k) - 1]

class BinaryIndexedTree(): #1-indexed
    def __init__(self, n):
        self.n = n
        self.tree = [0 for _ in range(n + 1)]

    def sum(self, index):
        res = 0
        while index:
            res += self.tree[index]
            index -= index & -index
        return res

    def get(self, index):
        return self.sum(index) - self.sum(index - 1)

    def add(self, index, x):
        while index <= self.n:
            self.tree[index] += x
            index += index & -index

    def bisect_left(self, x):
        if x <= 0: return 0
        res, tmp = 0, 2**((self.n).bit_length() - 1)
        while tmp:
            if res + tmp <= self.n and self.tree[res + tmp] < x:
                x -= self.tree[res + tmp]
                res += tmp
            tmp >>= 1
        if res >= self.n:
            return self.n
        return res + 1

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]

cum = [0]

for i in range(N):
    cum.append(cum[-1] + A[i])

V = [cum[i] - K * i for i in range(N + 1)]

S = Set(V)

res = 0

for i in range(N + 1):
    res += S.sum(V[i])
    S.insert(V[i])

print(res)

Measured memory_bytes: 57004
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll s;
    cin >> hex >> s;
    
    if((s>>31)&1) cout << "-";
    
    ll Kassa1 = (s & 0x7FFFFFFF) >> 7; // 整数部分
    ll Kassa2 = (s & 0x0000007F); // 小数部分
    
    double ans = Kassa1;
    
    int saisyouno_keta = 0;
    for(int i = 0; i < 7;i++){
        if((Kassa2 >> (6-i))&1){
            ans += pow(0.5,i+1);
            saisyouno_keta = i;
        }
    }
    
    cout << fixed << setprecision(saisyouno_keta+1) << ans << endl;
    return ans;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    
    int Q; cin >> Q;
    while(Q--){
        solve(0);
        // cout << fixed << setprecision(15) << solve<double>() << endl;
    }
    return 0;
}



Measured memory_bytes: 3416
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] H = new int[N];
        int ans = 0;

        for(int i=0; i<N; i++){
            H[i] = sc.nextInt();
        }
        
        int x = 0;
        for(int i=0; i<N-1; i++){
            if(H[i]>=H[i+1]){
                x += 1;
                if(x>ans){
                    ans = x;
                }
            }
            else if(H[i]<H[i+1]){
                if(x>ans){
                    ans = x;
                }
                    x = 0;
            }
           
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 48964
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
//#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
/////////////////////////

int main() {
	//code
	int tc=1;
	//cin>>tc;
	while(tc--)
	{
	    int n;
        cin>>n;
        string s;cin>>s;
        int i=0;
        int j=n-1;
        int ans=0;
        while( i<j )
        {
            while( s[i]=='R')i++;
            while( s[j]=='W')j--;
            if( i<j )
            {
                // swap;
                ans++;
                i++;
                j--;
            }
        }
        cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3672
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func() uint64 {
		sc.Scan()
		i, _ := strconv.ParseUint(sc.Text(), 10, 64)
		return i
	}

	n := in()
	a := make([]uint64, n)
	v := make([]uint64, n)

	for i := range a {
		a[i] = in()
	}

	val := a[0] ^ a[1]

	var i uint64
	for i = 2; i < n; i++ {
		val ^= (a[0] ^ a[i])
	}

	v[0] = a[0] ^ (val)

	s := a[0] ^ v[0]

	for i = 1; i < n; i++ {
		v[i] = s ^ a[i]
	}

	for i := range v {
		fmt.Print(v[i], " ")
	}
	fmt.Println()
}


Measured memory_bytes: 11544
fn main() {
    proconio::input! {
        s: String,
    }
    let mut c = [0i64;2019];
    c[0] = 1;
    let mut t = 0;
    let mut p = 1;
    for v in s.bytes().map(|c| (c-b'0')as usize).rev() {
        t = (v*p+t)%2019;
        c[t] += 1;
        p = p*10%2019;
    }
    println!("{}",c.iter().map(|v|v*(v-1)/2).sum::<i64>());
}

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

int main() {
    int N, A[200002];
    int num_sup[200002] = {0};
    cin >> N;
    for (int i = 2; i <= N; i++){
        cin >> A[i];
        num_sup[A[i]]++;
    }
    for(int i = 1; i <= N; i++) {
        // cout << num_sup[i] << endl;
        printf("%d\n",num_sup[i]);
    }
}

Measured memory_bytes: 5196
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k - 1] = tolower(s[k - 1]);

    cout << s << endl;
}

Measured memory_bytes: 3612