akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    // SS
    auto check = [&](string &ret) {
        if ((s[0] == 'o') ^ (ret[0] == 'W') ^ (ret[1] == 'W'))
            ret[n - 1] = 'S';
        else
            ret[n - 1] = 'W';

        for (int i = 1; i < n - 2; ++i) {
            if ((s[i] == 'o') ^ (ret[i] == 'W') ^ (ret[i - 1] == 'W'))
                ret[i + 1] = 'S';
            else
                ret[i + 1] = 'W';
        }
        if ((s[n - 2] == 'o') ^ (ret[n - 2] == 'W') ^ (ret[n - 3] == 'W') ^
            (ret[n - 1] == 'W')) {
            if ((s[n - 1] == 'o') ^ (ret[n - 1] == 'W') ^ (ret[n - 2] == 'W') ^
                (ret[0] == 'W')) {
                cout << ret << "\n";
                return true;
            }
        }
        return false;
    };
    string ret(n, 'S');
    if (check(ret))
        return 0;
    ret[0] = 'S';
    ret[1] = 'W';
    if (check(ret))
        return 0;
    ret[0] = 'W';
    ret[1] = 'S';
    if (check(ret))
        return 0;
    ret[0] = 'W';
    ret[1] = 'W';
    if (check(ret))
        return 0;

    cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define vint vector<int>

int main() {
    int N, M;
    cin >> N;
    vint D(N);
    rep(i, N) cin >> D[i];
    cin >> M;
    vint T(M);
    rep(i, M) cin >> T[i];
    map<int, int> mp;
    for (int i = 0; i < N; i++) {
        mp[D[i]]++;
    }
    bool ans = true;
    rep(k, M) {
        if (mp[T[k]] > 0) {
            mp[T[k]]--;
        } else {
            ans = false;
            break;
        }
    }
    if (ans) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/04  Problem: ABC 045 C / Link: http://abc045.contest.atcoder.jp/tasks/abc045_c  ----- */


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

	string s; cin >> s;
	int N = SZ(s);
	LL ans = 0;
	FOR(state, 0, 1 << (N - 1)) {
		LL sum = s.front() - '0';
		FOR(i, 0, N - 1) {
			if (state & 1 << i) {
				ans += sum;
				sum = 0;
			}
			sum *= 10;
			sum += s[i + 1] - '0';
		}
		ans += sum;
	}
	cout << ans << "\n";

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
typedef vector<string> vecst;

int main(){
    st S;
    cin >> S;
    vechar s(4);
    vecll count(26);
    for(ll i = 0; i < 4; i++) s.at(i) = S.at(i);
    for(ll i = 0; i < 4; i++) {
        count.at(s.at(i) - 'A')++;
    }
    ll count0 = 0, count2 = 0;
    for(ll i = 0; i < 26; i++){
        if(count.at(i) == 0) count0++;
        if(count.at(i) == 2) count2++;
        
    }
    if(count0 == 24 && count2 == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import heapq
N = int(input())
A = list(map(int,input().split()))

C = A[0:N]
S = sum(C)
prefix = [S]
heapq.heapify(C)
for i in range(N, 2*N):
  heapq.heappush(C,A[i])
  popped = heapq.heappop(C)
  S = S + A[i] - popped
  prefix.append(S)

C = [-e for e in A[2*N:]]
S = -sum(C)
suffix = [S]
heapq.heapify(C)
for i in range(2*N-1, N-1, -1):
  heapq.heappush(C,-A[i])
  popped = heapq.heappop(C)
  S = S + A[i] - (-popped)
  suffix.append(S)

res = -10**15 
j = len(suffix)-1
for i in range(len(prefix)):
  res = max(res, prefix[i] - suffix[j])
  j -= 1

print(res)

Measured memory_bytes: 122640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char str[428][73];
int length;

void copy(char* in, char* out, int length){
	int i;
	for(i=0;i<length;i++){
		out[i]=in[i];
	}
	return;
}

void reverse(char* in, char* out, int length){
	int i;
	for(i=0;i<length;i++){
		out[i]=in[length-1-i];
	}
	return;
}

int comp(const void *c1, const void *c2){
	int d=strcmp((void*)c1,(void*)c2);
	if(d>0){
		return 1;
	}else if(d<0){
		return -1;
	}else{
		return 0;
	}
}

void solve(){
	int i,j;
	for(i=0;i<428;i++){
		for(j=0;j<73;j++){
			str[i][j]=0;
		}
	}

	char line[74];
	scanf("%s",line);
	length=strlen(line);

	copy(line,str[0],length);
	reverse(line,str[1],length);
	int p=2;

	char *A=calloc(length,sizeof(char));
	char *B=calloc(length,sizeof(char));

	for(i=1;i<length;i++){
		copy(&line[0],A,i);
		copy(&line[i],B,length-i);

		//BA
		copy(B,&str[p][0],length-i);
		copy(A,&str[p][length-i],i);
		p++;

		//AB?????¢,AB
		reverse(&str[p-1][0],&str[p][0],length);
		p++;

		//A?????¢,AB
		reverse(A,&str[p][0],i);
		copy(B,&str[p][i],length-i);
		p++;

		//B?????¢,BA
		reverse(&str[p-1][0],&str[p][0],length);
		p++;

		//A?????¢,BA
		copy(B,&str[p][0],length-i);
		reverse(A,&str[p][length-i],i);
		p++;

		//B?????¢,AB
		reverse(&str[p-1][0],&str[p][0],length);
		p++;
	}
	qsort(str,p,sizeof(str[0]),comp);
	int c=0;
	for(i=0;i<p;i++){
		if(strcmp(str[i],str[i+1])) c++;
	}
	printf("%d\n",c);
	free(A);
	free(B);
}

int main(void){
	int m,i;
	scanf("%d",&m);
	for(i=0;i<m;i++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 688
#include<iostream>
#include<algorithm>
#include<map>
#include<math.h>
#include<set>
#include<string>
#include<vector>
using namespace std;

#define int long long

void fastio()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	fastio();
	string s, t;
	cin >> s >> t;
	string tt = t.substr(0, t.size() - 1);
	if (s == tt)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3120
solve :: [Int] -> Int -> Int
solve _ 0 = 0
solve hs level = count hs 0 level + solve hs (level - 1)

count :: [Int] -> Int -> Int -> Int
count [] _ _ = 0
count (h:hs) curr target = point + count hs next target
  where next = if h >= target then target else 0
        point = if next > curr then 1 else 0

main :: IO ()
main = do
  getLine
  hs <- map read . words <$> getLine
  print . solve hs $ maximum hs

Measured memory_bytes: 1020
n = gets.to_i
a = gets.chop.split.map(&:to_i)

l = [false]*8
over = 0

for x in a
    if x < 3200
        l[x/400] = true
    else
        over += 1
    end
end

mini =  [l.count(true),1].max

maxi =  l.count(true)+over

print("#{mini} #{maxi}")

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  ll x = a+b;
  cout << n/x*a+min(n%x, a) << endl;

  return 0;
}


Measured memory_bytes: 256
function Main(input) {
  var N = input[0];
  var Q = input[1];
  var S = input[2];
  var lr = input.slice(3);

  var queryL = [];
  var queryR = [];
  for (var i = 0; i < Q; i++) {
    queryL.push(lr[i * 2]);
    queryR.push(lr[i * 2 + 1]);
  }

  // 累積和（その地点のACの数）
  var s = [0];
  var sum = 0;
  for (var i = 0;i < N; i++) {
    if (i === 0) {
      s.push(0);
    } else {
      if (S.charAt(i - 1) === 'A' && S.charAt(i) === 'C') {
        sum++;
      }
      s.push(sum);
    }
  }
  // console.log(JSON.stringify(s));

  for (var i = 0; i < Q; i++) {
    console.log(s[queryR[i]] - s[queryL[i]]);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 60464
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x,l,r;
    string s;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> re;
    vector<ll> de;

    cin >> n;

    rep(i,n){
        double x1;
        string tm;
        cin >> x1 >> tm;
        if(tm=="JPY") dans += x1;
        else{
            dans += 380000.0 * x1;
        }
    }

    
    std::cout << dans << endl; 

    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
import sys

n = int(input())
raw_ss = [int(input()) for _ in range(n)]
ss = sorted(raw_ss)

if all([s % 10 == 0 for s in ss]):
	print(0)
	sys.exit()

res = sum(ss)
if res % 10 == 0:
	for s in ss:
		if s % 10 != 0:
			res = res - s
			break

print(res)


Measured memory_bytes: 3060
N  = int(input())

solve = 0
for i in range(9):
    A = i+1
    for j in range(9):
        B = j+1
        if A*B == N:        
            print('Yes')
            solve = 1
            break     
    if solve == 1:
      break
if solve == 0:
    print('No')

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

int main()
{
    int N;
    int d;
    map<int, int> mp;
    int count;
    
    cin >> N;
    for (int i=0;i<N;i++) {
        cin >> d;
        mp[d] += 1;
    }
    
    count = 0;
    for (auto itr=mp.begin();itr!=mp.end();++itr) {
        count += 1;
    }
    
    cout << count << endl;
    
    return 0;
}

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

bool check(char t[][32], int h, int w, int n)
{
    while (1){
        bool upd = false;
        bool done = true;
        
        bool del[32][32] = {0};
        
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (t[i][j] != '.'){
                    done = false;
                }
            }
        }
        if (done) return (true);
        
        for (int i = 0; i <= h - n; i++){
            for (int j = 0; j < w; j++){
                bool ch = true;
                for (int k = 1; k < n; k++){
                    if (t[i][j] == '.' || t[i][j] != t[i + k][j]) ch = false;
                }
                if (ch){
                    for (int k = 0; k < n; k++) del[i + k][j] = true;
                    upd = true;
                }
            }
        }
        
        for (int i = 0; i < h; i++){
            for (int j = 0; j <= w - n; j++){
                bool ch = true;
                for (int k = 1; k < n; k++){
                    if (t[i][j] == '.' || t[i][j] != t[i][j + k]) ch = false;
                }
                if (ch){
                    for (int k = 0; k < n; k++) del[i][j + k] = true;
                    upd = true;
                }
            }
        }
        
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (del[i][j]) t[i][j] = '.';
            }
        }
        
        if (!upd) break;
        
        char tmp[32][32];
        int d[32] = {0};
        memset(tmp, '.', sizeof(tmp));
        for (int i = h - 1; i >= 0; i--){
            tmp[i][w] = 0;
            for (int j = 0; j < w; j++){
                if (t[i][j] != '.'){
                    tmp[h - 1 - d[j]++][j] = t[i][j];
                }
            }
        }
        
        memcpy(t, tmp, sizeof(tmp));
        
    }
    
    return (false);
}

int main()
{
    int w, h, n;
    char s[32][32];
    
    scanf("%d %d %d", &h, &w, &n);
    
    for (int i = 0; i < h; i++) scanf("%s", s[i]);
    
    bool ok = false;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w - 1; j++){
            char t[32][32];
            memcpy(t, s, sizeof(s));
            
            char tmp_ = t[i][j];
            t[i][j] = t[i][j + 1];
            t[i][j + 1] = tmp_;
            
            char tmp[32][32];
            int d[32] = {0};
            memset(tmp, '.', sizeof(tmp));
            for (int i = h - 1; i >= 0; i--){
                tmp[i][w] = 0;
                for (int j = 0; j < w; j++){
                    if (t[i][j] != '.'){
                        tmp[h - 1 - d[j]++][j] = t[i][j];
                    }
                }
            }
            
            memcpy(t, tmp, sizeof(tmp));
            
            ok |= check(t, h, w, n);
        }
    }
    
    if (ok) printf("YES\n");
    else printf("NO\n");
    
    return (0);
}

Measured memory_bytes: 1172
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().Split(' ');
            int[] a = new int[n];
            for (int i=0; i<n; i++)
            {
                a[i] = int.Parse(s[i]);
            }

            int[] ans = new int[n];
            for (int i=n; i>0; i--)
            {
                int num = a[i - 1];
                for (int j=2; j * i <= n; j++)
                {
                    if (ans[j * i - 1] == 1) num = 1 - num;
                }
                ans[i - 1] = num;
            }
            Queue<int> m = new Queue<int>();
            for (int i=0; i<n; i++)
            {
                if (ans[i] == 1) m.Enqueue(i + 1);
            }
            Console.WriteLine(m.Count());
            if (m.Count() == 0) return;
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(m.Dequeue());
            while (m.Count() > 0)
            {
                sb.Append(" " + m.Dequeue());   
            }
            Console.WriteLine(sb.ToString());
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

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

using i64 = int64_t;

vector<int> z_algorithm(const string &s){
    vector<int> prefix(s.size());
    for(int i=1, j=0;i<(int)s.size();i++){
        if(i+prefix[i-j] < j+prefix[j]){
            prefix[i] = prefix[i-j];
        }else{
            int k = max(0, j+prefix[j]-i);
            while(i+k < (int)s.size() && s[k] == s[i+k])k++;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (int)s.size();
    return prefix;
}

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

    int ans = 0;
    for(int i=0;i<n;++i){
        string str = s.substr(i);
        auto res = z_algorithm(str);
        for(int j=1;j<res.size();++j){
            int tmp = min(res[j], j);
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

ll itoj(string N, ll i, ll j) {
	ll len = N.length();
	ll ans = 0;
	for (ll k = 1; k <= len; k++) {
		if (k == 1) {
			if (i <= stoi(N) && i == j) {
				ans++;
			}
			continue;
		}
		if (k == 2) {
			if (i*10+j <= stoi(N)) {
				ans++;
			}
			continue;
		}
		if (k >= 3 && k < len) {
			ans += pow(10, k - 2);
			continue;
		}
		if (k == len) {
			if (i < N[0] - '0') {
				ans += pow(10, k - 2);
			}
			else if (i > N[0] - '0') {
				continue;
			}
			else {
				ans += stoi(N.substr(1, len - 2));
				if (j <= N[len - 1] - '0') {
					ans++;
				}
			}
		}
	}
	return ans;
}

int main() {
	ll i, j;
	string N;
	cin >> N;
	ll len = N.length();

	ll ans = 0;
	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
			ans += itoj(N, i, j) * itoj(N, j, i);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
from collections import defaultdict
def main():
    N = int(input())
    S = input()
    D = defaultdict(bool)
    cnt = 0
    all1 = 0
    all2 = 0
    for i in range(N):
        if S[i] == "1":
            D[i] = True
            cnt += 1
        else:
            D[i] == False

    for i in range(N):
        if S[i] == "1":
            all1 += pow(2, N-1-i, cnt+1)
            if cnt != 1:
                all2 += pow(2, N-1-i, cnt-1)

    for i in range(N):
        P = 0
        if S[i] == "1":
            if cnt == 1:
                print(0)
                continue
            else:
                P += all2-pow(2, N-1-i, cnt-1)
            ans = 1
            P = P % (cnt-1)
            while P:
                c = P
                mod = 0
                while c:
                    mod += c & 1
                    c = c >> 1
                P = P % mod
                ans += 1
            print(ans)
            continue
        else:
            P += all1+pow(2, N-1-i, cnt+1)
            ans = 1
            P = P % (cnt+1)
            while P:
                c = P
                mod = 0
                while c:
                    mod += c & 1
                    c = c >> 1
                P = P % mod
                ans += 1
            print(ans)
if __name__=="__main__":
    main()


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

typedef long long ll;
typedef vector<long long> vecll;
typedef vector<string> vecstr;

#define rep0(i, n) for(ll i=0; i<(ll)(n); i++)
#define rep1(i, n) for(ll i=1; i<=(ll)(n); i++)
#define rep(i, a, b) for(ll i=(ll)a; i<=(ll)(b); i++)
#define rep0r(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rep1r(i, n) for(ll i=(ll)(n); i>0; i--)
#define repr(i, a, b) for(ll i=(ll)b; i>=(ll)(a); i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / __gcd(a, b)
#define len(x) x.size()
#define Sort(x) sort(x.begin(), x.end())
#define rSort(x) sort(x.begin(), x.end(), greater<ll>())

const ll mod_const = 1000000007;

ll modpow(ll a, ll n, ll m) {
    ll result = 1;
    while(n > 0) {
        if(n&1) {
            result = result * a % m;
        }

    a = a * a % m;
    n >>= 1;
    }

    return result;
}

ll modinv(ll a, ll n) {
    if(a <= 1) {
        return 1;
    } else {
        return  n - modinv(n%a, n) * (n/a) % n;
    }
}

ll comb(ll n, ll r, ll m = mod_const) {
    vecll fac = {1, 1};
    vecll inv ={1, 1};
    vecll facinv = {1 , 1};

    rep(i, 2, n) {
        fac.push_back(fac[i-1] * i % m);
        inv.push_back(modinv(i, m));
        facinv.push_back(facinv[i-1] * inv[i] % m);
    }

    if (n<r || n<0 || r<0) {
        return 0;
    } else {
        return fac[n] * (facinv[r] * facinv[n-r] % m) % m;
    }
}
void solve() {

    string s;
    cin >> s;

    if(s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }

}

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

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

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

typedef pair<ll, ll> P;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int n;
    cin >> n;
    vector <vector<int>> a(2);
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            int tmp;
            cin >> tmp;
            a[i].push_back(tmp);
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j <= i; j++) sum += a[0][j];
        for (int j = i; j < n; j++) sum += a[1][j];
        chmax(ans, sum);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N, Q = list(map(int, input().split()))
d = {i: set() for i in range(1, N + 1)}
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    d[a].add(b)
    d[b].add(a)
counter = [0] * (N + 1)
for _ in range(Q):
    p, x = list(map(int, input().split()))
    counter[p] += x

parents = {1}
while parents:
    children = set()
    for parent in parents:
        v = counter[parent]
        for child in d[parent]:
            d[child].remove(parent)
            children.add(child)
            counter[child] += v
    parents = children
print(*counter[1:])

Measured memory_bytes: 103524
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> vec(M,vector<int>(3));
  for(int i=0; i<M; i++){
    for(int j=0; j<3; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  pair<int,int> P;
  
  vector<bool> begin(N,true);
  
  vector<vector<pair<int,int>>> G(N,vector<pair<int,int>>(0));
  for(int i=0; i<M; i++){
    int a = vec.at(i).at(0);
    int b = vec.at(i).at(1);
    int c = vec.at(i).at(2);
    a--;
    b--;
    P = make_pair(b,c);
    G.at(a).push_back(P);
    begin.at(b) = false;
  }
  
  vector<int> dist(N,-1);
  for(int i=0; i<N; i++){
    if(begin.at(i)){
      dist.at(i) = 0;
    }
  }
  
  queue<int> Q;
  
  bool ans = true;
  
  for(int i=0; i<N; i++){
    if(begin.at(i) && ans){
      Q.push(i);
      while(Q.size() && ans){
        int x = Q.front();
        Q.pop();
        for(int j=0; j<G.at(x).size(); j++){
          P = G.at(x).at(j);
          if(dist.at(P.first) == -1){
            dist.at(P.first) = dist.at(x) + P.second;
            Q.push(P.first);
          }
          else if(dist.at(P.first) != dist.at(x) + P.second){
            ans = false;
            break;
          }
        }
      }
    }
  }
  
  for(int i=0; i<M; i++){
    if(begin.at(vec.at(i).at(0)-1)){
      break;
    }
    if(i == M-1){
      ans = false;
    }
  }
            
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 17408
/* https://www.youtube.com/watch?v=dQw4w9WgXcQ hello. -bedirhan */
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 2020000, mo = 1e9+7;
const ll M = 7LL*mo*mo;
inline int power(int a, int n){
	int res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;
		a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
namespace yzr{
	int x1,x2,x3,x4,x5,x6;
	int y1,y2,y3,y4,y5,y6;
	int fac[N],ifac[N];
	inline int C(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;}
	inline ll solve3(int x, int y, int n, int m){
		ll res=0;assert(x<=n&&y<=m&&x>=0&&y>=0);//printf("solve %d %d %d %d\n",x,y,n,m);
		rep(i,0,x){res+=1LL*C(i+y,i)*C(n-i+m-y-1,n-i)%mo*(y+i);res=res<M?res:res-M;}
		rep(i,0,y){res+=1LL*C(i+x,i)*C(m-i+n-x-1,m-i)%mo*(x+i);res=res<M?res:res-M;}
	//	rep(i,0,x)rep(j,0,y)res+=1LL*C(i+j,i)*C(n-i+m-j,n-i)%mo;
		return res%mo;
	}
	inline ll solve2(int sx, int sy, int tx, int ty){
		ll res=0;
		res+=solve3(x4-sx,y4-sy,tx-sx,ty-sy);
		res+=solve3(x3-1-sx,y3-1-sy,tx-sx,ty-sy);
		res-=solve3(x3-1-sx,y4-sy,tx-sx,ty-sy);
		res-=solve3(x4-sx,y3-1-sy,tx-sx,ty-sy);
	//	rep(i,x3,x4)rep(j,y3,y4)res+=1LL*C(i-sx+j-sy,i-sx)*C(tx-i+ty-j,tx-i)%mo;
		return res;
	}
	ll solve1(int x, int y){
		ll res=0;
		res+=solve2(x,y,x5,y5);
		res+=solve2(x,y,x6+1,y6+1);
		res-=solve2(x,y,x5,y6+1);
		res-=solve2(x,y,x6+1,y5);
		return res;
	}
	void solve(){
		read(x1);read(x2);read(x3);read(x4);read(x5);read(x6);
		read(y1);read(y2);read(y3);read(y4);read(y5);read(y6);
		int mx=N-1;
		fac[0]=1;rep(i,1,mx)fac[i]=1LL*fac[i-1]*i%mo;
		ifac[mx]=power(fac[mx],mo-2);per(i,mx-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
		ll res=0;
		res+=solve1(x1-1,y1-1);
		res+=solve1(x2,y2);
		res-=solve1(x1-1,y2);
		res-=solve1(x2,y1-1);
		printf("%lld",(res%mo+mo)%mo);
	}
}
int main() {
	yzr::solve();
	return 0;
}


Measured memory_bytes: 16000
#include<stdio.h>
int main(void)
{
int a,b;
scanf("%d",&a);
scanf("%d",&b);
if(a<b){
printf("a < b\n");
}else if(a>b){
printf("a > b\n");
}else{
printf("a == b\n");
}
return 0;
}



Measured memory_bytes: 2088
#include<iostream>
#include<cstdio>

const char clr[5]="RYGB";

int main()
{
	int i,j;
	int H,W,d;
	scanf("%d%d%d",&H,&W,&d);
	for(i=0;i<H;i++)
	{
		for(j=0;j<W;j++)
		{
			int x=((i+j)%(2*d)+(2*d))%(2*d)/d;
			int y=((i-j)%(2*d)+(2*d))%(2*d)/d;
		    putchar(clr[x+y*2]);
		}
		putchar('\n');
	}
	return 0;
}

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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

ll n;
ll a[100010];

bool ok(int k) {

  //cerr << k << ":" << endl;

  ll b[100010] = {};
  ll mi = 0;
  REP(i,n) {
    if (a[i] < k) {
      b[i+1] = -1;
    } else {
      b[i+1] = 1;
    }
    b[i+1] += b[i];
    mi = min(mi,b[i+1]);
  }
  REP(i,n+1) b[i] += -mi + 2;

//  REP(i,n+1) {cerr << b[i] << " ";}
//  cerr << endl;

  ll seg[100010] = {};
  ll ans = 0;
  REP(i,n+1) {
    //b[i]の左側にb[i]以下の数字の個数を求める
    ll tmp = b[i];
    while (tmp) {
      ans += seg[tmp];
      tmp -= tmp & (-tmp);
    }
    //b[i]をBITに挿入する
    tmp = b[i];
    while (tmp < 100010) {
      seg[tmp]++;
      tmp += tmp & (-tmp);
    }
//    cerr << ans << " ";
  }
//  cerr << endl;
  return ans >= (n * (n + 1) / 2 + 1) / 2;
}

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

  cin >> n;
  REP(i,n) cin >> a[i];
  int l = 0, r = 1e9;
  while (l < r) {
    int mid = (l + r + 1) / 2;
    if (ok(mid)) {
      l = mid;
    } else {
      r = mid - 1;
    }
//    cerr << l << " " << r << endl;
  }

  cout << l << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1),b(n);
    rep(i,n+1) cin >> a[i];
    ll sum = 0;
    rep(i,n) cin >> b[i];
    rep(i,n){
        if(a[i]>=b[i]){
            sum += b[i];
            a[i]-=b[i];
        }else{
            sum += a[i];
            b[i]-=a[i];
            if(a[i+1]>=b[i]){
                sum += b[i];
                a[i+1]-=b[i];
            }else{
                sum+=a[i+1];
                a[i+1]=0;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> uf(N), sz(N, 1);
    iota(begin(uf), end(uf), 0UL);
    const auto& find = [&uf](unsigned long i) -> unsigned long{while(i != uf[i])i = uf[i] = uf[uf[i]];return i;};
    const auto& unite = [&uf, &sz, &find](unsigned long i, unsigned long j) -> unsigned long {
        i = find(i);
        j = find(j);
        if(i == j)return 0;
        if(sz[i] < sz[j])swap(i, j);
        sz[i] += sz[j];
        uf[j] = i;
        return 1;
    };
    cout << [&N, &unite]{
        unsigned long M, ans{N - 1};
        cin >> M;
        for(unsigned long i{0}, A, B; i < M; ++i){
            cin >> A >> B;
            ans -= unite(A - 1, B - 1);
        }
        return ans;
    }() << endl;
    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    cout << (s < t ? "Yes" : "No") << 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)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int A, B;
vector<string> grid(100, string(100, '#'));
int main(){
  cin >> A >> B;
  A--, B--;
  REP(i, 50){
    REP(j, 100){
      grid[i][j] = '.';
    }
  }

  REP(i, A){
    int y = 51 +2 * (i / 50), x = i % 50 * 2;
    grid[y][x] = '.';
  }
  REP(i, B){
    int y = 2*(i / 50), x = i % 50 * 2;
    grid[y][x] ='#';
  }
  cout << 100 << " " << 100 << endl;
  REP(i, 100){
    cout << grid[i] << endl;
  }
  return 0;
}


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

int main() {
    int N,ans=0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N;
    cin >> N;
    VLL A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll ans=0;
    for(int i=1; i<N; i++){
        if(A[i]<A[i-1]){
            ans+=(A[i-1]-A[i]);
            A[i]+=(A[i-1]-A[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4740
# n = int(input())

# c = list(map(int, input().split()))
# s = [list(map(int, list(input()))) for i in range(10)]
L, R, d = map(int, input().split())

cnt = 0
for i in range(L, R + 1):
    if i % d == 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100
#define INF 800000000

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> a(M),b(M);
  vector<int> c(M,0);
  for(int i=0;i<M;i++){
    cin>>a.at(i)>>b.at(i);
    for(int j=0;j<b.at(i);j++){
      int x;
      cin>>x;
      c.at(i)+=(1<<(x-1));
    }
  }
  vector<vector<int>> dp(M+1,vector<int>(1<<N,INF));
  for(int i=0;i<M;i++){
    dp.at(i).at(0)=0;
    for(int j=0;j<(1<<N);j++){
      dp.at(i+1).at(j)=min(dp.at(i+1).at(j),dp.at(i).at(j));
      dp.at(i+1).at((j|c.at(i)))=min(min(dp.at(i+1).at(j|c.at(i)),dp.at(i).at((j|c.at(i)))),dp.at(i).at(j)+a.at(i));
    }
  }

  if(dp.at(M).at((1<<N)-1)==INF){
    cout<<-1<<endl;
  }else{
    cout<<dp.at(M).at((1<<N)-1)<<endl;
  }

}


Measured memory_bytes: 16384
n = int(input())
if 1 <= n <= 9:
    print(n)
if 10 <= n <= 99:
    print(9)
if 100 <= n <= 999:
    print(n-99+9)
if 1000 <= n <= 9999:
    print(900+9)
if 10000 <= n <= 99999:
    print(n-9999+900+9)
if 100000 <= n <= 999999:
    print(90000+900+9)

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


LL gcd(LL a, LL b) {
  LL r;
  while ((r = b % a) != 0) {
    b = a;
    a = r;
  }
  return a;
}

LL lcm(LL a, LL b) {
  return (a / gcd(a, b)) * b;
}

int main(){
  LL n, m;
  string s, t;
  cin >> n >> m;
  cin >> s;
  cin >> t;

  LL l = lcm(n, m);
  LL g = gcd(n, m);

  bool flag = true;
  REP (i, g) {
    if (s[(l / m) * i] != t[(l / n) * i]) {
      flag = false;
      break;
    }
  }

  if (flag) cout << l << endl;
  else cout << "-1" << endl;
}


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



typedef long long ll;

ll dp[81111][11][2];
string s;




int main(){
  while( cin >> s ){
    if( s == "0" ) break;
    int n = (int)s.size();
    for(int i=0;i<=n;i++){
      for(int j=0;j<11;j++){
	dp[i][j][1] = 0;
	dp[i][j][0] = 0;
      }
      dp[i][0][0] = 1;
    }

    ll res = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<11;j++){
	for(int k=0;k<2;k++){
	  if( dp[i][j][k] == 0 ) continue;
	  
	  int tm = (s[i]-'0') + j*10;
	  
	  //cout << i << " " << j << " " << dp[i][j] << " "<< tm << " " << tm % 11 << endl;
	  
	  if( tm % 11 == 0 && k != 0 ) {
	    res += dp[i][j][k];
	  }
	  if( !(k==0 && tm%11==0) )
	    dp[i+1][tm%11][1] += dp[i][j][k];
	}
      }
    }

    cout << res << endl;

  }
}

Measured memory_bytes: 15064
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

typedef struct
{
	int t, x, y;
} data_t;

int main()
{
	int n;
	vector<data_t> dataz;
	data_t temp, temp2;

	cin >> n;

	/*for (int i = 0; i < n; i++) {

	dataz.push_back(temp);
	}*/
	temp.x = temp.y = temp.t = 0;

	for (int i = 0; i < n; i++) {
		int mass;
		cin >> temp2.t >> temp2.x >> temp2.y;
		mass = abs(temp.x - temp2.x) + abs(temp.y - temp2.y);
		if (((temp2.t - temp.t - mass) % 2 != 0 || mass <= 0 || (temp2.t - temp.t) - mass < 0) ){
		cout << "No" << endl;
		return 0;
		}
		temp = temp2;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  int h[N];
  int max_cost[N];
  for(int i=0;i<N;i++){
    cin >> h[i];
    max_cost[i] = -1;
  }
  max_cost[0]=0;
  for(int frog=0;frog<N-1;frog++){
    for(int jump=1;jump<=K;jump++){
      if(frog<N-jump && (max_cost[frog+jump] >= max_cost[frog] + abs(h[frog+jump]-h[frog]) || max_cost[frog+jump] == -1))
        max_cost[frog+jump] = max_cost[frog] + abs(h[frog+jump]-h[frog]);
    }
  }
  cout << max_cost[N-1] << endl;
}

Measured memory_bytes: 1024
using System;

namespace abc107_b
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int ret = 0;
			for (int z = 1; z <= n; z += 2)
			{
				int count = 0;
				for (int i = 1; i <= z; i++) if (z % i == 0) count++;
				if (count == 8) ret++;
			}
			Console.WriteLine(ret);
		}
	}
}

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

set<string> S;

int main()
{
   ios::sync_with_stdio(false), cin.tie(0);
   int N;
   string com, str;
   cin >> N;
   while(N--){
      cin >> com >> str;
      if(com[0] == 'i')
         S.insert(str);
      else
         cout << (S.count(str) == 0 ? "no" : "yes") << '\n';
   }
}



Measured memory_bytes: 29764
import itertools

n, m, x = (int(each) for each in input().split())

books = []
for i in range(n):
    books.append([int(each) for each in input().split()])

# print(books)

scores = []
products = itertools.product([0,1], repeat=n)
for pro in products:
    score = [0]*(m+1)
    for index, j in enumerate(pro):
        if j == 1:
            score = [x+y for (x, y) in zip(score, books[index])]
    if min(score[1:]) >= x:
        scores.append(score)

if len(scores) == 0:
    print(-1)
else:
    print(min([each[0] for each in scores]))

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for(int i = 1; i <= N; ++i) {
    if(to_string(i).length() % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int x;
  cin >> x;
  int ans = 1;
  for(int i = 2;i * i <= x;i ++){
    int memo = i;
    while(memo * i <= x){
      memo *= i;
    }
    ans = max(ans, memo);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3640
#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 reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  cin >> n;
  string s = "";
  vector<char> vec = {'a'};
  rep(i, 25) {
    vec.push_back(char(vec[vec.size() - 1] + 1));
  }
  while(n) {
    n--;
    s += vec[n%26];
    n /= 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,d,i,j,k,l,m,n,x,y,z,ans,tmp,hoge,fuga,piyo;
ll xx[200100],yy[200100];
ll aa[13][13],cc[13],skill[13],ab[13],ac;
string s,str;
ll roop(ll num){
  yy[num]++;
  if(yy[num]==2){
    return num;
  }
  return roop(xx[num]);
}
ll roop2(ll num,ll first){
  if(num==first){
    ans++;
    if(ans==2){
      return 0;
    }
  }
  return roop2(xx[num],first)+1;
}
ll roop3(ll num,ll first){
  if(num==first){
    return 0;
  }
  return roop3(xx[num],first)+1;
}
ll roop4(ll num,ll count){
  if(count==0){
    return num;
  }
  return roop4(xx[num],count-1);
}
int main(){
  ans=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>xx[i];
    xx[i]--;
  }
  a=roop(0);
  b=roop2(a,a);
  c=roop3(0,a);
  if(k>c){
    d=(k-c)%b;
    cout<<roop4(a,d)+1;
  }else{
    cout<<roop4(0,k)+1;
  }
  return 0;
}

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

signed main(void)
{
	int n;
	cin >> n;
	int m = n / 1000; 
	if (n % 1000 != 0)
		m++;
	cout << m * 1000 - n << endl;
	return 0;
}


Measured memory_bytes: 3592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        KnapsackAizu solver = new KnapsackAizu();
        solver.solve(1, in, out);
        out.close();
    }

    static class KnapsackAizu {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            KnapsackAizu.Item[] a = new KnapsackAizu.Item[n];
            int w = in.nextInt();

            for (int i = 0; i < n; i++) {
                a[i] = new KnapsackAizu.Item(in.nextInt(), in.nextInt());
            }

            int[][] dp = new int[w + 1][n + 1];
            for (int i = 1; i < w + 1; i++) {
                for (int j = 1; j < n + 1; j++) {
                    dp[i][j] = dp[i][j - 1];
                    if (i >= a[j - 1].weight) {
                        dp[i][j] = Math.max(dp[i][j], a[j - 1].value + dp[i - a[j - 1].weight][j - 1]);
                    }
                }
            }

            out.printf("%d\n", dp[w][n]);
        }

        static class Item {
            int value;
            int weight;

            public Item(final int value, final int weight) {
                this.value = value;
                this.weight = weight;
            }

        }

    }
}




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

    signed main() {
       string s;
       cin>>s;
       int k=0;
       if(s.size()==26){
           while(s.size()>1&&s[s.size()-2]>s[s.size()-1])s.pop_back();
           s.pop_back();
           if(s.size()==0){
               cout<<-1;
               return 0;
           }
           k=s[s.size()-1]-'a'+1;
           s.pop_back();
       }
       
       bool x['z'-'a'+1]={};
       for(int i=0;i<s.size();i++)x[s[i]-'a']=true;
       for(int i=k;i<'z'-'a'+1;i++)if(!x[i]){
           cout<<s<<char('a'+i);
           return 0;
       }
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<' '<<x<<' '<<y<<endl;
}


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

using namespace std;

long long MOD = 998244353;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<vector<long long>> dp(n+1, vector<long long>(s+1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        int v = a[i-1];
        for (int j = 0; j <= s; j++) {
            auto cur = (dp[i-1][j] + (j == 0 ? 1 : 0)) % MOD;
            if (j >= v) {
                cur = (cur + dp[i-1][j-v]) % MOD;
            }
            dp[i][j] = cur;
        }
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = (ans + dp[i][s]) % MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 70784