akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

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

    ll n,a,b;
    cin >> n >> a >> b;
    ll ans=0;
    ll cn=0,cr=0;
    if((a>b)||(a!=b)&&(n==1)){
        cout << ans;
        return 0;
    }else{
        ans=b*(n-2)-a*(n-2)+1;
    }
    cout << ans;
}				

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
#define mii = map<int, int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
lint A, B, C, D, E, F, G, H, I, J, K, L, M, N;
lint O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
double ans;
vector<pii> c;
vector<vector<double>> d;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N;
    c.resize(N);
    rep(i, N) cin >> c[i].first >> c[i].second;

    d.resize(N, vector<double>(N));
    rep(i, N) {
        rep(j, N) {
            d[i][j] = (double)sqrt(
                (c[i].first - c[j].first) * (c[i].first - c[j].first) +
                (c[i].second - c[j].second) * (c[i].second - c[j].second));
        }
    }

    vi p(N);
    iota(all(p), 0);
    int cnt = 0;
    do {
        cnt++;
        rep(i, N - 1) ans += d[p[i]][p[i+1]];
    } while (next_permutation(all(p)));

    cout << fixed << setprecision(20);
    cout << ans / (double)cnt << endl;
    return 0;
}

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

using namespace std;

typedef pair <int, int> ii;
typedef long long int ll;
vector <int> primes;

void ESieve(int n) {
	vector <bool> sieve(n+1, true);

	sieve[0] = sieve[1] = false;

	for (int i = 2; i <= n; i++) {
		if (!sieve[i])
			continue;

		primes.push_back(i);

		for (int j = i*i; j <= n; j += i) {
			sieve[j] = false;
		}
	}
}

bool is_prime(int n) {

	for (int p: primes) {
		if (p == n)
			return true;

		if (n % p == 0)
			return false;
	}

	return true;
}

vector <ii> prime_factors(int n) {
	vector <ii> f;

	for (int p: primes) {
		if (p > n)
			break;

		int e = 0;

		while (n % p == 0) {
			e++;
			n = n / p;
		}

		if (e)
			f.emplace_back(p, e);
	}

	if (n != 1) {
		f.emplace_back(n, 1);
	}

	return f;
}

int main() {
	// ESieve(1000);

	int n;

	cin >> n;

	vector <ll> a(n);
	unordered_map <ll, int> counts;
	unordered_map <ll, bool> can;
	ll mx = 0;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		counts[a[i]]++;
		can[a[i]] = true;
		mx = max(mx, a[i]);
	}

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

	if (n == 1) {
		cout << 1 << "\n";
		return 0;
	}

	int ans = 0;

	for (int i = 0; i < n; i++) {
		if (!can[a[i]])
			continue;
		
		ll x = a[i];

		for (ll j = 2; j*x <= mx; j++) {
			ll y = j*x;
			if (counts.find(y) != counts.end()) {
				can[y] = false;
			}
		}

		if (counts[x] > 1)
			can[x] = false;

		if (can[x]) {
			// cout << x << "\n";
			ans++;
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 21252
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];
    int b[] = new int[N];
    int c[] = new int[N];
    int dp[][] = new int[N][3];
    int ans[] = new int[N];
    for(int i=0;i<N;i++){
      a[i]=sc.nextInt();
      b[i]=sc.nextInt();
      c[i]=sc.nextInt();
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
 //   ans[0]=Math.max(a[0],b[0],c[0]);
    for(int i=1;i<N;i++){
      dp[i][0]=Math.max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
      dp[i][1]=Math.max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);      
      dp[i][2]=Math.max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);      
    }
    
    System.out.println(Math.max(Math.max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]));
    
  }
  

  
}

Measured memory_bytes: 97136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double n = in.nextDouble();
        double d = in.nextDouble();
        int ans = 0;
        while(n-->0){
            double x = in.nextDouble();
            double y = in.nextDouble();
            if (Math.sqrt(x * x + y * y) <= d)
                ans++;
        }
        System.out.println(ans);
        in.close();
    }
}

Measured memory_bytes: 63404
import string


def get_input():

    N = int(input())
    S = input()

    return N, S


def convert(S, N):

    count = string.ascii_uppercase.index(S) + N
    count = count % 26

    return string.ascii_uppercase[count]


def main():

    N, S = get_input()

    res = []
    for s in S:
        res.append(convert(s, N))

    print(''.join(res))


main()


Measured memory_bytes: 3772
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n f >>= print
  where
    f = (\[x, l] -> (x+l, x-l)) <$> map read <$> words <$> getLine

solve :: [(Int, Int)] -> Int
solve = fst . foldl' f (0, -1000000000) . sort
  where
    f (ct, p) (r, l)
      | p <= l = (ct+1, r)
      | otherwise = (ct, p)


Measured memory_bytes: 126204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

ll n, p, q;
ll sum;
ll x[500001]; 

void solve() {
    cin >> n >> p >> q;
    rep(i,n) {
        ll c; cin >> c;
        sum += c;
        x[i] = p*i+c;
    }
    sort(x, x+n);
    ll ans = -linf;
    ll acc = 0;
    rep(i,n+1) {
        ll cnt = sum + i * p * q + (ll)i*(ll)(i-1)*p - acc;
        ans = max(ans, cnt);
        acc += x[i];
    }
    cout << ans << endl;
}

int main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
    cout.precision(20);
    cerr << fixed;
    cerr.precision(6);
#ifdef LOCAL
    //freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif  
    solve();
    //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}



Measured memory_bytes: 7088
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pii> place(n - 1);
  vvi root(n);
  rep(i, n - 1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    root[a].push_back(b);
    root[b].push_back(a);
    place[i] = make_pair(a, b);
  }
  int k = 0;
  rep(i, n) k = max(k, int(root[i].size()));
  queue<int> que;
  map<pii, int> ans;
  vi checked(n);
  checked[0] = 1;
  que.push(0);
  while(!que.empty()){
    int pos = que.front();
    que.pop();
    for(int x : root[pos]){
      if(!checked[x]){
        checked[x] = checked[pos] % k + 1;
        checked[pos] = checked[x];
        ans[make_pair(min(pos, x), max(pos, x))] = checked[x];
        que.push(x);
      }
    }
  }
  cout << k << endl;
  rep(i, n - 1) cout << ans[place[i]] << endl;
}

Measured memory_bytes: 13568
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

D = [pow(i, 2) for i in range(1, N + 2)]

ok = N
ng = 1
List = [-1 for i in range(N + 1)]
while abs(ok - ng) > 2:
  LR = [(ok - ng) // 3 + ng, 2 * (ok - ng) // 3 + ng]
  Ans = [0, 0]
  for j in range(2):
    if List[LR[j]] != -1:
      Ans[j] = List[LR[j]]
      continue
    least = 0
    Ans[j] = X * (N + LR[j])
    cnt = -1
    t = 0
    flag = False
    for i in x[::-1]:
      if flag:
        Ans[j] += (D[least + 1] - D[least]) * x[cnt]    
      else:
        Ans[j] += (D[0] + D[1]) * x[cnt]
      cnt -= 1
      t += 1
      if t == LR[j]:
        t = 0
        least += 1
        flag = True
    List[LR[j]] = Ans[j]
  if Ans[0] < Ans[1]:
    ok = LR[1]
  else:
    ng = LR[0]
 
FA = 1e20
for j in range(ng, ok + 1):
  if List[j] != -1:
    FA = min(FA, List[j])
    continue
  least = 0
  Ans = X * (N + j)
  cnt = -1
  t = 0
  flag = False
  for i in x[::-1]:
    if flag:
      Ans += (D[least + 1] - D[least]) * x[cnt]    
    else:
      Ans += (D[0] + D[1]) * x[cnt]
    cnt -= 1
    t += 1
    if t == j:
      t = 0
      least += 1
      flag = True
  FA = min(FA, Ans)
print(FA)

Measured memory_bytes: 119384
#include<bits/stdc++.h>
#define clr(a,b) memset(a,b,sizeof(a))
using namespace std;

typedef long long ll;

const int maxn=2010;
int n, h;

int main(){
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    cin >> n;
    int la = 0, flag = 0;
    for (int i = 1; i <= n; i++) {
        cin >> h;
        if (h > la) la = h - 1;
        else if (h < la) {
            flag = 1;
            break;
        }
    }
    if (flag) cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# input
import sys
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a, b, h, m = map(int, input().split())
theta = abs(h * 30 + m * 0.5 - (6 * m))
# セイゲンテイリ
ans = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(theta))
print(ans ** (0.5))


Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;

vector<ll> v;
ll l;

bool num753(ll i){
    bool n7=false;
    bool n5=false;
    bool n3=false;
    while(i!=0){
        ll j;
        j = i%10;
        if(j==7) n7=true;
        if(j==5) n5=true;
        if(j==3) n3=true;
        i /= 10;
    }
    return n7&&n5&&n3;
}

void dfs(ll t){
    ll x = t*10+3;
    //cout << t << endl;
    if(x<=l){
        if(num753(x)) {v.emplace_back(x);}
        dfs(x);
    }
    if(x+2<=l){
        if(num753(x+2)) {v.emplace_back(x+2);}
        dfs(x+2);
    }
    if(x+4<=l){
        if(num753(x+4)) {v.emplace_back(x+4);}
        dfs(x+4);
    }
}

void solve(){
    ll n;
    cin >> n;
    //753数を列挙。
    l = n;
    dfs(0);
    ll count = 0;
    for(auto x:v){
        if(num753(x)){
            count++;
        }
    }
    cout << count << endl;

}

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


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

using namespace std;

int main()
{
  int l[26], r[26];
  string s;
  int tmp;
  int sum[100];
  int ans = 0;

  for ( int i = 0; i < 26; ++i ) l[i] = r[i] = -1;
  for ( int i = 0; i < 100; ++i ) sum[i] = 0;

  cin >> tmp;
  cin >> s;
  for ( int i = 0; i < s.size(); ++i ) {
    if ( l[s[i]-'a'] != -1 ) continue;

    l[s[i]-'a'] = i;
    for ( int j = i+1; j < s.size(); ++j ) {
      if ( s[i] == s[j] ) r[s[i]-'a'] = j;
    }
  }

  for ( int i = 0; i < 26; ++i ) {
    if ( r[i] != -1 ) {
      ++sum[l[i]];
      --sum[r[i]];
    }
  }

  for ( int i = 1; i < tmp; ++i ) sum[i] = sum[i-1]+sum[i];
  for ( int i = 0; i < tmp; ++i ) if ( ans < sum[i] ) ans = sum[i];

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define X 3000
#define Y 100010
typedef unordered_map<ll,ll> mp;

vector<ll> prime;
unordered_map<ll,mp>mas;

bool issquare(ll x){
  ll l=0,r=Y,m;
  while(l<r-1){
    m=(l+r)/2;
    if(m*m==x)return 1;
    if(m*m<x)l=m;
    else r=m;
  }
  return 0;
}

class setmas{
  public:
  mp mem;
  ll divi(ll x){
    mem.clear();
    for(auto y:prime){
      while(x%y==0){
	mem[y]++;
	x/=y;
      }
    }
    return x;
  }
  ll comp(){
    ll res=1;
    for(auto t:mem){
      ll val=t.first;
      ll cnt=t.second;
      for(int i=0;i<cnt%3;i++){
	res*=val;
      }
    }
    return res;
  }
  bool isone(ll x){
    ll p=divi(x);
    ll q=comp();
    if(p==1&&q==1)return 1;
    return 0;
  }
  void insert(ll x){
    ll p=divi(x);
    ll res=comp();
    //cout<<x<<" "<<res<<" "<<p<<endl;
    mas[res][p]++;
  }
  bool erase(ll x){
    ll p=divi(x);
    ll res=comp();
    
    if(mas[res][p]<1)return 0;
    mas[res][p]--;
    
    ll rev=1;
    for(auto t:mem){
      ll val=t.first;
      ll cnt=t.second;
      cnt%=3;
      for(int i=0;i<(3-cnt)%3;i++){
	rev*=val;
      }
    }
    if(p==1){
      if(mas[rev][p]>=1){
	mas[rev][p]--;
	return 1;
      }
      return 0;
    }
    if(p>Y){
      if(issquare(x))mas[res][p]++;
      return 0;
    }
    if(mas[rev][p*p]>=1){
      mas[rev][p*p]--;
      return 1;
    }
    return 0;
  }
};setmas setmass;
int main(){
  for(ll i=2;i<X;i++){
    bool ok=1;
    for(auto x:prime)if(i%x==0)ok=0;
    if(ok)prime.push_back(i);
  }
  ll n,a[100010];
  cin>>n;
  lol(i,n)cin>>a[i];
  lol(i,n)setmass.insert(a[i]);
  ll ans=n,ones=0;
  lol(i,n){
    if(setmass.isone(a[i]))ones++;
    else ans-=setmass.erase(a[i]);
  }
  if(ones)ans=ans+1-ones;
  cout<<ans<<endl;
  return 0;
}


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

int n;

int main()
{
    while(cin >> n) 
        if(n % 39)
            cout << "3C" << setw(2) << setfill('0') << (n % 39) << endl;
        else 
            cout << "3C39" << endl;
    
}

Measured memory_bytes: 0
(defun main ()
  (let* ((str (read-line))
        (buff)
        (n (length str))
        (ans 0))
    (dotimes (i (floor n 2))
      (setf buff (aref str i))
      (if (not (equal buff (aref str (- n 1 i))))
          (incf ans)))
    ans))

(format t "~A~%" (main))

Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> rsum,xsum;
int main(){
  ll n;
  cin>>n;
  rsum.push_back(0);
  xsum.push_back(0);
  for(int i=1;i<=n;i++){
    ll a;
    cin>>a;
    rsum.push_back(rsum[i-1]+a);
    xsum.push_back(xsum[i-1]^a);
  }
  ll ans=0;
  for(ll i=1;i<=n;i++){
    ll lb=i,rb=n+1;
    while(rb-lb>1){
      ll mid=(lb+rb)/2;
      if((rsum[mid]-rsum[i-1])==(xsum[mid]^xsum[i-1])) lb=mid;
      else rb=mid;
    }
    ans+=lb-i+1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3564
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
//#include <atcoder/all>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
//using namespace atcoder;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    cin>>n;
    string str[n];
    rep(i,n)cin>>str[i];
    vector<ll> v(5);
    ll r,h;
    rep(i,n){
        if(str[i][0]=='M') v[0]++;
        if(str[i][0]=='A') v[1]++;
        if(str[i][0]=='R') v[2]++;
        if(str[i][0]=='C') v[3]++;
        if(str[i][0]=='H') v[4]++;
    }
    rep(i,5)rep(j,i)rep(k,j){
        sum+=v[i]*v[j]*v[k];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 6712
#include <iostream>

using namespace std;
typedef long long int lint;

void answer()
{
	int a, b;
	cin >> a >> b;
	if (a < b) cout << "a < b";
	else if (a > b) cout << "a > b";
	else cout << "a == b";
	cout << endl;
}

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

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

class dice{
    public:
    int num[6], new_num[6];
    void refresh();
    void turnN();
    void turnS();
    void turnE();
    void turnW();
};
void dice::refresh(){
    for(int i=0;i<6;i++){
        num[i] = new_num[i];
    }
}

void dice::turnN(){
    new_num[0] = num[1];
    new_num[1] = num[5];
    new_num[2] = num[2];
    new_num[3] = num[3];
    new_num[4] = num[0];
    new_num[5] = num[4];
    
}

void dice::turnS(){
    new_num[0] = num[4];
    new_num[1] = num[0];
    new_num[2] = num[2];
    new_num[3] = num[3];
    new_num[4] = num[5];
    new_num[5] = num[1];
}

void dice::turnE(){
    new_num[0] = num[3];
    new_num[1] = num[1];
    new_num[2] = num[0];
    new_num[3] = num[5];
    new_num[4] = num[4];
    new_num[5] = num[2];
}

void dice::turnW(){
    new_num[0] = num[2];
    new_num[1] = num[1];
    new_num[2] = num[5];
    new_num[3] = num[0];
    new_num[4] = num[4];
    new_num[5] = num[3];
}


int main(){
    
    dice a, b;
    bool flag = false;
    
    for(int i=0;i<6;i++){
        cin >> a.num[i];
    }
    for(int i=0;i<6;i++){
        cin >> b.num[i];
    }
    for(int k=0;k<4;k++){
        for(int j=0;j<4;j++){
            for(int i=0;i<4;i++){
                if(a.num[1]==b.num[1] && a.num[2]==b.num[2] && a.num[3]==b.num[3] && a.num[4]==b.num[4] && a.num[5]==b.num[5] && a.num[0]==b.num[0]){
                    flag = true;
                }
                a.turnW();
                a.refresh();
            }
            a.turnS();
            a.refresh();
        }
        a.turnW();
        a.refresh();
    }
    for(int j=0;j<4;j++){
        for(int i=0;i<4;i++){
            if(a.num[1]==b.num[1] && a.num[2]==b.num[2] && a.num[3]==b.num[3] && a.num[4]==b.num[4] && a.num[5]==b.num[5] && a.num[6]==b.num[6]){
                flag = true;
            }
            a.turnW();
            a.refresh();
        }
        a.turnS();
        a.refresh();
    }
    
    if(flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
    
    return 0;
    
}


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

using namespace std;

const int max_n = 200222, inf = 1000111222;
const int max_lev = 64;

int n, a[max_n], first[max_n], cnt[max_n];
bool vis[max_n];
int nxt[max_lev][max_n];
long long k, h[max_lev][max_n];
vector<int> v;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k;
    memset(first, -1, sizeof(first));
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if (first[a[i]] == -1) {
            first[a[i]] = i;
        }
    }
    for (int i = n - 1; i >= 0; --i) {
        nxt[0][i] = first[a[i]];
        if (!vis[a[i]]) {
            vis[a[i]] = 1;
            h[0][i] = 1;
        }
        ++nxt[0][i];
        if (nxt[0][i] == n) {
            nxt[0][i] = 0;
            ++h[0][i];
        }
        //cout << i << ": " << nxt[0][i] << " " << h[0][i] << endl;
        first[a[i]] = i;
    }
    for (int lev = 1; lev < max_lev; ++lev) {
        for (int i = 0; i < n; ++i) {
            nxt[lev][i] = nxt[lev - 1][nxt[lev - 1][i]];
            h[lev][i] = h[lev - 1][i] + h[lev - 1][nxt[lev - 1][i]];
            if (h[lev][i] >= k) {
                h[lev][i] = k;
                nxt[lev][i] = 0;
            }
        }
    }
    long long curh = 0;
    int pos = 0;
    for (int lev = max_lev - 1; lev >= 0; --lev) {
        if (curh + h[lev][pos] < k) {
            curh += h[lev][pos];
            pos = nxt[lev][pos];
            //cout << curh << " " << pos << endl;
        }
    }
    while (curh < k) {
        if (cnt[a[pos]] == 0) {
            ++cnt[a[pos]];
            v.push_back(a[pos]);
        } else {
            while (cnt[a[pos]]) {
                --cnt[v.back()];
                v.pop_back();
            }
        }
        ++pos;
        if (pos == n) {
            pos = 0;
            ++curh;
        }
    }
    for (int x : v) {
        printf("%d ", x);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 155124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vi(x,m);
    rep(i,m){
        cin >> x[i];
    }
    srt(x);
    long long ans = x[m-1] - x[0];
    //cout << "ans:" << ans << endl;
    vi(def,m-1);
    rep(i,m-1){
        def[i] = x[i+1] - x[i];
            //cout << i << ":" << def[i] << endl;
    }
    srt(def);
    rev(def);
    if(n >= m) ans = 0;
    else{
        for(int i = 0; i < n - 1; i++){
            ans -= def[i];
            //cout << def[i] << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

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

string N,K;

void Input(){
	cin>>N;
}

void Solve(){
	if(N[N.length()-1]=='s'){
		cout<<N+"es"<<'\n';
	}else{
		cout<<N+"s"<<'\n';
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	Input();
	Solve();
}

Measured memory_bytes: 3660
import sys

n= int(sys.stdin.readline())
a= [ int(x) for x in sys.stdin.readline().split() ]
b= [ int(x) for x in sys.stdin.readline().split() ]

c= 0
r= a[0]
for i in range(n):
    m = r + a[i+1]
    bi= b[i]
    c+= min(m,bi)
    #
    if bi<r: r= a[i+1]
    elif bi<m: r= m - bi
    else: r=0
#
print( c )

Measured memory_bytes: 18624
#include <iostream>
using namespace std;
int main(){
  int N, A;
  cin >> N >> A;
  if(N <= A) cout << 1;
  if(N > A) {
    if(N/A * A == N) cout << N/A;
    if(N/A * A != N) cout << N/A + 1;
  }
}


Measured memory_bytes: 256
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val n = Scanner.nextInt
	val c = Scanner.next

	val rcount = c.count(_ == 'R')

	pw.println(rcount - c.take(rcount).count(_ == 'R'))
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54600
A, B = map(int,input().split())
r = B - A +1
ans = 0
for i in range(r):
  n = str(A + i)
  l = len(n)//2
  count = 0
  for j in range(l):
    if n[j] == n[-(j+1)]:
      count +=1
  if count == l:
    ans += 1
    
print(ans)

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - HonestOrDishonest
            var s = Console.ReadLine();
            var a = s.Substring(0, 1);
            var b = s.Substring(2, 1);
            var topCoDeer = "";

            if (a == "H")
            {
                Console.WriteLine(b);
            }
            else
            {
                if (b == "H")
                {
                    Console.WriteLine("D");
                }
                else
                {
                    Console.WriteLine("H");
                }
            }
        }
    }
}

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

const int MAX_N = 100000;

int main() {
	int N, ans = 0;
	vector<int> a(MAX_N);
	cin >> N;
	for(int i=0;i<N;i++) {
		cin >> a[i]; a[i]--;
	}
	for(int i=0;i<N;i++) {
		if(i < a[i] && a[a[i]] == i) ans++;
	}
	cout << ans << endl;
	return 0;
}


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


int main(){
    int n,f=0,s=0;
    for(int i=0; i<3;i++){
        scanf("%d", &n);
        if(n==5)
            f++;
        else if(n==7)
            s++;
    }
    if(f==2 && s==1)
        printf("YES");
    else
        printf("NO");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll n,k; cin >> n >> k;
    ll sum[n];
    queue<ll> q;
    vector<int> cnt(50,0);
    rep(i,n){
        ll a; cin >> a;
        if(i==0) sum[0]=a;
        else sum[i]=sum[i-1]+a;
        q.push(sum[i]);
        rep(j,50){
            if(sum[i]&(1ull<<j)) cnt[j]++;
        }
    }
    rep(i,n){
        for(int j=i+1;j<n;j++){
            ll d=sum[j]-sum[i];
            q.push(d);
            rep(l,50){
                if(d&(1ull<<l)) cnt[l]++;
            }
        }
    }
    
    //bit 50
    ll ans=0;
    for(int i=49;i>=0;i--){
        if(cnt[i]<k) continue;
        ans+=(1ull<<i);
        ll sz=q.size();
        rep(j,sz){
            ll f=q.front(); q.pop();
            if(f&(1ull<<i)) q.push(f);
            else{
                rep(l,50){
                    if(f&(1ull<<l)) cnt[l]--;
                }
            }
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 4352
# define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }
int main()
{
	const lint MAXS = 1000000000;
	int n, q;
	multiset<lint> ms;
	vector<lint> a, b;


	cin >> n >> q;
	FOR(i, n)
	{
		lint x; cin >> x;
		a.push_back(x);
		b.push_back(x);
	}
	sort(ALL(a));

	FOR(c, q)
	{
		string s; lint x;
		cin >> s >> x;
		if (s == "ADD")
		{
			x--;
			ms.insert(b[x]);
		}
		if (s == "REMOVE")
		{
			x--;
			auto it = ms.lower_bound(b[x]);
			ms.erase(it);
		}
		if (s == "CHECK")
		{
			lint l = 0, r = MAXS + 1, m;
			while (l != r)
			{
				m = (l + r) / 2;
				int prev = 0, st = 0;
				for (auto it : ms)
				{
					int d = lower_bound(ALL(a), it - m) - a.begin();
					st += max(d - prev, 0);
					prev = upper_bound(ALL(a), it) - a.begin();
				}
				st += max(n - prev, 0);
				if (st <= x)r = m;
				else l = m + 1;
			}
			if (l == MAXS + 1)cout << "NA" << endl;
			else cout << l << endl;
		}
	}
}

Measured memory_bytes: 18744
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll n;
ll a[100010];
ll b[100010];
ll bc[100010];
ll c[100010];
ll ans;
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n)scanf("%lld",b+i);
	rep(i,0,n)scanf("%lld",c+i);
	sortup(a,n);
	sortup(b,n);
	sortup(c,n);
	ll cc=0;
	rep(bb,0,n){
		while(cc<n&&c[cc]<=b[bb])cc++;
		if(cc==n)break;
		bc[bb]=n-cc;
	}
	//bc[i]には、b[i]とセットにできるcの個数
	for(ll i=n-1;i>0;i--)bc[i-1]+=bc[i];
	//bc[i]にはb[i]以上のbを使ってできる(b,c)の組の数
	
	ll bb=0;
	rep(aa,0,n){
		while(bb<n&&b[bb]<=a[aa])bb++;
		if(bb==n)break;
		ans+=bc[bb];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 4080
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
using namespace std;



int main(void) {
	int n,m,l[100000],r[100000],lmax=0,rmin=100000;
	cin>>n>>m;
	for (int i = 0; i < m; i++) {
		cin>>l[i]>>r[i];
		lmax=max(lmax,l[i]);
		rmin=min(rmin,r[i]);
	}

	//cout<<lmax<<"\n";
	//cout<<rmin<<"\n";

	int ans=max(0,rmin-lmax+1);

	cout<<ans<<"\n";



	return 0;
}


Measured memory_bytes: 1024
import java.io.PrintWriter
import java.util.ArrayDeque

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

/** edge info */
data class Edge<T>(val to: Int, var cost: T)


fun solve(out: PrintWriter) {
    val (n, x, y) = readIntegerList()

    /** incidenceList[fromNodeIndex]: edges to other node */
    val incidenceList = Array(n) { mutableListOf<Edge<Int>>() }
    for (i in 0 until n - 1) {
        incidenceList[i].add(Edge(i + 1, 1))
        incidenceList[i + 1].add(Edge(i, 1))
    }
    incidenceList[x - 1].add(Edge(y - 1, 1))
    incidenceList[y - 1].add(Edge(x - 1, 1))

    val ans = IntArray(n - 1)
    for (i in 0 until n) {
        val costArray = bfs(i, incidenceList)
        for (j in (i + 1) until n) {
            ans[costArray[j] - 1]++
        }
    }

    println(ans.joinToString("\n"))
}

fun <T> bfs(startNode: Int, edges: Array<MutableList<Edge<T>>>): IntArray {
    val costArray = IntArray(edges.size)
    val isUnchecked = BooleanArray(edges.size) { true }
    val nodeQueue = ArrayDeque<Int>()
    nodeQueue.addLast(startNode)
    isUnchecked[startNode] = false
    while (nodeQueue.isNotEmpty()) {
        val node = nodeQueue.removeFirst()
        for (edge in edges[node]) {
            if (isUnchecked[edge.to]) {
                costArray[edge.to] = costArray[node] + 1
                isUnchecked[edge.to] = false
                nodeQueue.addLast(edge.to)
            }
        }
    }

    return costArray
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 106312
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;

int main() {
	cin >> N;
	cout << ((N - 1) / 111 + 1) * 111 << endl;
	return 0;
}

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


void solve(long long N, std::vector<long long> a){
    ll sum=0;
    for(ll i=0; i< N; i++) sum+= a[i];
    ll diff = sum, ans = 1LL << 60;
    for(ll i=0; i<N-1; i++){
        diff -= a[i]*2;
        ans = min(ans, abs(diff));
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define all(s) s.begin(), s.end()
#define fuck_you_scanf ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define si size()
 
const int N = 1e6 + 5;
double arr[N];
double DP[3005][3005][2];


double f(int idx, int reqd, int n)
{
	if(reqd <= 0) return 1;
    if(idx == n)
    {
        return 0;
    }
    int type = 0;
    if(reqd < 0) type = 1;
    if(DP[idx][abs(reqd)][type] >= 0) return DP[idx][abs(reqd)][type];
    double ans1 = (arr[idx]) * f(idx + 1, reqd - 1, n) * 1.0;
    double ans2 = (1.0 - arr[idx]) * f(idx + 1, reqd, n) * 1.0;
    return DP[idx][abs(reqd)][type] = ans1 + ans2;
}

int32_t main()
{
   int n;
   cin >> n;
   memset(DP, -1,sizeof(DP));
   for(int i = 0; i < n; i++)
   {
       cin >> arr[i];
   }
   int reqd = (n + 1)/2;
   if(n % 2 == 0) reqd++;
   cout << setprecision(10) << fixed;
   cout << f(0, reqd, n);
}

Measured memory_bytes: 141824
#include <bits/stdc++.h>
using namespace std;
int n, l;

struct PP {
	char s[107];
} a[107];

bool cmp(PP x, PP y) {
	return strcmp(x.s, y.s) < 0;
}

int main() {
	scanf("%d %d", &n, &l);
	for(int i = 1; i <= n; i++) scanf("%s", a[i].s);
	sort(a + 1, a + n + 1, cmp);
	for(int i = 1; i <= n; i++) printf("%s", a[i].s);
	printf("\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 10010
#define ll long long
#define P 998244353
using namespace std;
int n,m;
ll q[N],ni[N],nq[N];
int f[N][N];
char a[N],b[N];
ll C(int n,int m)
{
	return q[n]*nq[m]%P*nq[n-m]%P;
}
int main()
{
	q[0]=ni[1]=nq[0]=1;
	for(int i=1;i<N;i++) q[i]=q[i-1]*i%P;
	for(int i=2;i<N;i++) ni[i]=(P-P/i)*ni[P%i]%P;
	for(int i=1;i<N;i++) nq[i]=nq[i-1]*ni[i]%P;
	scanf("%s%s",a,b);
	for(int i=0;a[i];i++)
	if(a[i]=='1')
	{
		if(b[i]=='1') n++;
		else m++;
	}
	f[0][0]=1;
	for(int i=0;i<=n;i++)
	for(int j=0;j<=m;j++)
	if(i||j)
	{
		ll o=0;
		if(j) o+=(ll)j*j*f[i][j-1];
		if(i) o+=(ll)i*j*f[i-1][j];
		f[i][j]=o%P;
	}
	ll ans=0;
	for(int i=0;i<=n;i++) ans+=f[i][m]*C(n,i)%P*C(n+m,i+m)%P*q[n-i]%P*q[n-i]%P;
	ans%=P;
	cout<<ans;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int a[3]; cin >> a[0] >> a[1] >> a[2];

	sort(a,a+3);

	cout << a[2]-a[0] << endl;

	return 0;

}


Measured memory_bytes: 256
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, l[500010], r[500010], dp[500010];
string s;
signed main() {
    cin >> N >> s;

    rep(i,0,N)    l[i+1] = (s[i] == '0' ? 0 : l[i] + 1);
    repr(i,N-1,0) r[i+1] = (s[i] == '0' ? 0 : r[i+2] + 1);

    repq(i,1,N) {
        chmax(dp[i], dp[i-1]);
        if(s[i-1] == '1') continue;
        int L = l[i-1], R = r[i+1];
        if(!L || !R) continue;
        repq(k,1,L) chmax(dp[i+1], dp[i-k-1] + k);
        repq(k,1,R) chmax(dp[i+k], dp[i-2] + k);
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 12548
/*
Please Chant The Holy Name Of Lord Krisna(The Supreme Personality Of Godhead)

      "Hare Krisna Hare Krisna Krisna Krisna Hare Hare
       Hare Rama Hare Rama Rama Rama Hare Hare ......."

Surrender yourself to the Lotus Feet of Krisna, serve devotees and Srila Prabhupada
*/
//26-9-20
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(NULL); cin.tie(nullptr);
#define endl "\n"
#define int long long
#define pb emplace_back
#define sz(s) (int)s.size()
#define all(v)                            v.begin(),v.end()
#define fr(i,n)                           for(int i=0;i<n;i++)
#define fr1(i,n)                          for(int i=1;i<=n;i++)
#define fro(i,a,b)                        for(int i=a;i<=b;i++)
#define d(a)                              cout << #a << " : " << a << " ";
#define dl(a)                             cout<< #a <<" : " << a << endl;
#define print(v)  for(auto x : v)         {cout<<x<<" ";   }  cout<<endl;
#define PRINT(v)  for(auto x : v)         {cout<<x.first<<" "<<x.second<<endl;}
#define TEST                              int tc;cin>>tc; while(tc--)

using namespace std;

const int N   = 2e5 + 7;
const int MOD = 1e9 + 7;
int arr[N];
int n,m,k,x,y,i,j;
int kase = 1;

void solve()
{
    // Can you solve it by brute force?
    // kkp
    // Are you sure you want to code so soon?? -_-
    // Simplify your code a little more. :)

    int k;
    cin>>k;

    string s;

    while(k--)
    {
        s += "ACL";
    }

    cout<<s<<endl;
}

int32_t main()
{
    //IOS;

    //TEST
    solve();

    return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <math.h>
#include <stdio.h>

#define MAX_N 200'000
#define INF 1'000'000'000'000'000'000

typedef long long ll;

using namespace std;

int A[MAX_N];

int main() {
  int N;
  cin >> N;
  ll t = 0;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    t += A[i];
  }
  ll res = INF;
  ll s = 0;
  for (int i = 0; i < N - 1; ++i) {
    s += A[i];
    res = min(res, abs(t - s - s));
  }
  printf("%lld\n", res);
}

Measured memory_bytes: 4024
import numpy as np
A,B = [ int(it) for it in input().split() ]
x = np.zeros([100,100]).astype(np.int32)
x[:,99]=1
for i in range(20):
    x[99-i*2,1:]=1
    
p=97
q=98
for i in range(A-1):
    x[q,p]=1
    p-=2
    if (p==3):
        p=97
        q-=2

p=1
q=1
for j in range(B-1):
    x[q,p]=1
    p+=2
    if (p==95):
        p=1
        q+=2

print ( 100,100)
for line in x:
    print ( "".join([ "#" if v==1 else "." for v in line]))

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

using namespace std;
int n,a[102],s[102];
int main()
{
    //freopen("B.INP","r",stdin);
    ios_base::sync_with_stdio(false);
    cin >> n;
    s[0]=0;
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        s[i]=s[i-1]+a[i];
    }
    sort(s+1,s+1+n);
    int pos=lower_bound(s+1,s+1+n,s[n]/2)-s;
    //cout << "pos: " << pos << "\n";
    cout << min(abs(s[pos]-(s[n]-s[pos])),abs(s[pos-1]-(s[n]-s[pos-1])));
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int N;
int S,D;
int bit(int I){
	if (I == 0)return 0;
	if (I & 1)return bit(I >> 1) + 1;
	return bit(I >> 1);
}
int main()
{
	scanf("%d", &N);
	
	for (int i = 0; i < N; i++){
		scanf("%d%d", &S, &D);
		int ans = 0;
		if (S <= 0 && 0 <= D){
			ans = (bit(-S) + bit(D));
		}
		else{
			if (D <= 0){
				S = -S;
				D = -D;
				swap(D, S);
			}
			while (true){
				if (S + (S&-S) <= D){
					ans++;
					S += (S&-S);
				}
				else break;
			}
			ans += bit(D - S);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1188
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    Scanner   sc   = new Scanner(System.in);

    void run() {
        int n = sc.nextInt();
        Pair[] p = new Pair[n + 1];
        for (int i = 0; i < n; i++) p[i] = new Pair(i + 1, sc.nextLong());
        p[n] = new Pair(0, 0);
        Arrays.sort(p);
        long[] res = new long[n + 1];
        long cnt = 0;
        int idmin = n + 1;
        for (int i = 0; i < n; i++) {
            Pair nowP = p[i];
            idmin = Math.min(idmin, nowP.id);
            cnt++;
            while (nowP.cnt == p[i + 1].cnt) {
                i++;
                cnt++;
            }
            res[idmin] += cnt * (nowP.cnt - p[i + 1].cnt);
        }
        
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < n + 1; i++) sb.append(res[i]+"\n");
        System.out.print(sb);
    }

    class Pair implements Comparable<Pair> {

        int  id;
        long cnt;

        public Pair(int id, long cnt) {
            super();
            this.id = id;
            this.cnt = cnt;
        }

        @Override
        public int compareTo(Pair arg0) {
            if (this.cnt == arg0.cnt) {
                return this.id - arg0.id;
            }
            return -Long.compare(this.cnt, arg0.cnt);
        }
    }

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

Measured memory_bytes: 65888
// ref. https://img.atcoder.jp/ddcc2020-qual/editorial.pdf

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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 < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll m;
  cin >> m;
  ll n = 0; // sum of digit
  ll s = 0; // sum of number
  rep(i, m) {
    ll d, c;
    cin >> d >> c;
    s += d * c;
    n += c;
  }

  // Here, we calculate the difference of 9*n+s.
  ll initial = 9*n + s;
  ll last = 9 + ((s-1)%9) + 1;
  cout << (initial-last)/9 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  bool ans = true;
  rep(i, N) {
    if(A[i]%2==0) {
      if(A[i]%3==0 || A[i]%5==0) {
        continue;
      } else {
        ans = false;
        break;
      }
    }
  }

  if(ans) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string.h>
using namespace std;
#define maxn 1e6;
int main()
{
	long long a, b, c, d;
	long long area1, area2;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	area1 = a * b;
	area2 = c * d;
	printf("%lld\n", area1 >= area2 ? area1 : area2);

}

Measured memory_bytes: 256
a[2][21];main(t,n,m,f,i,j,x){for(;scanf("%d%d",&n,&m),n;printf("Case %d: %d\n",t++,i)){
	memset(a,f=0,sizeof(a));
	a[f][0]=n;
	for(i=0;!a[f][m];f^=1,i++)for(j=0;j<m;j++){
		x=a[f][j];
		a[f][j]=0;
		a[f^1][j+1]+=x/2;
		a[f^1][0]+=x/2;
		a[f^1][j]+=x%2;
	}
}exit(0);}

Measured memory_bytes: 600
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int x;
    cin >> x;
    for ( int i = 1; i * 100 <= x; ++i ) {
        int y = x - i * 100;
        if ( y <= 5 * i ) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256