akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define forna(i,a,n) for(int i=a;i<n;i++)
typedef long long int lli;
using namespace std;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli n,begin,i;lli k,len,d;

// cin>>t;
// while(t--){
cin>>n>>k;
int a[n];
forna(i,0,n) cin>>a[i];
vector<int>v,v2;unordered_set<int>s;auto it=v.begin();
for(i=0;i<n;){
  if(s.find(a[i])==s.end()){
    s.insert(a[i]);
    v.push_back(a[i]);
    i=a[i]-1;
    continue;
  }
  else{
    i=v[v.size()-1]-1;
    it=find(v.begin(),v.end(),a[i]);
    break;
  }
}
// for(auto x:v) cout<<x<<" ";cout<<"frefgerf";
begin=it-v.begin();
// cout<<begin<<"jhhj";
if(k<=begin){cout<<v[k-1];}
else{
  k-=begin;
  len=v.size()-begin;
  forna(j,begin,begin+len) v2.push_back(v[j]);
//   for(auto x:v2) cout<<x<<" ";cout<<"frefgerf";
   d=(k%len);
//   cout<<d<<"kbjbj";
  if(d==0) cout<<v2[len-1];
  else{cout<<v2[d-1];}
}
}


Measured memory_bytes: 13296
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
string s;
int res=0;
void cal(string t){
    //cout<<t<<endl;
    int a=0;
    int b=0;
    for(int i=0;i<t.size();i++){
        if(t[i]!='+'){
            b=b*10+(t[i]-'0');
        }else{
            a+=b;
            b=0;
        }
    }
    a+=b;
    res+=a;
}

void dfs(int i,string sum){
    if(i==s.size()){
        cal(sum);
    }else{
        dfs(i+1,sum+s[i]);
        dfs(i+1,sum+'+'+s[i]);
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    string x="";
    x+=s[0];
    dfs(1,x);
    cout<<res<<endl;

}

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

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

  vector<int> a(N);
  rep(i, N) cin >> a[i];

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

  cout << a[N - 1] - a[0] << endl;
}

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

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
int main()
{
    fast();
    int n =D(),r=D();
    if(n<10){
        cout<<r*1ll+(100ll*(10-n))<<endl;
    }else
      cout<<r<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<ll> dp(n + 1, -1);
    dp[0] = 1;
    for(int i = 0; i < m; i++)
    {
        cin >> a[i];
        dp[a[i]] = 0;
    }
    if(dp[1] == -1)
    {
        dp[1] = 1;
    }
    for(int i = 2; i < n + 1; i++)
    {
        if(dp[i] == -1)
        {
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
        }
    }
    cout << dp[n];

    return 0;
}


Measured memory_bytes: 1408
// 難さんすう すーぱーさんすうと呼ぼう
// Mを素因数分解しといて例えばM=12としてM=(2^2) * (3^1)なるが、それぞれの因数をそれぞれの乗数ぶん振り分ける感じにした組み合わせが答え
// N = 3なら [1, 1, 1]の3つのどれかに振り分ける つまり以下
// 因数2を2つ,因数3を1つ を振り分けて、
//			[2^1, 2^1, 2^0], [3^1, 3^0, 3^0]
// 				-> [1*(2^1 * 3^1)] * [1*(2^1 * 3^0)] * [1*(2^0 * 3^0)] = 6*2*1 = 12
// あるいは
//			[2^2, 2^0, 2^0], [3^0, 3^0, 3^1] ならば
//				-> [1*(2^2 * 3^0)] * [1*(2^0 * 3^0)] * [1*(2^0 * 3^1)] = 4*1*3 = 12
// あるいは
//			[2^1, 2^1, 2^0], [3^0, 3^0, 3^1] ならば
//				-> [1*(2^1 * 3^0)] * [1*(2^1 * 3^0)] * [1*(2^0 * 3^1)] = 2*2*3 = 12
//
// 解説の""計算量はNに依らない""が意味不明だけど、説明してくれないので無視
// すーぱーさんすうの世界ではこれを重複組合せと呼ばうらしい 漢字だね 画数が多い
// n種類のものから重複を許してr個選ぶ場合の数 = nHr = (n+r-1)Cr に帰着できるらしい

// nCr mod Pなので気をつける
package main

import (
	"fmt"
	"math"
)

var MOD int

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	arr := primeFactorization(M)
	ans := 1
	MOD = int(math.Pow10(9)) + 7
	for _, v := range arr {
		ans = ans * ncrMod(v+N-1, v, MOD) % MOD
	}
	fmt.Println(ans)
}

func primeFactorization(x int) map[int]int {
	ret := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			x /= i
			ret[i] += 1
		}
	}
	if x > 1 {
		ret[x] += 1
	}
	return ret
}

func ncrMod(n, r, mod int) int {
	// 呼び出すたびにテーブルを作るのは愚
	_n := 1000000
	g1 := make([]int, _n+1)
	g1[0], g1[1] = 1, 1
	g2 := make([]int, _n+1)
	g2[0], g2[1] = 1, 1
	inverse := make([]int, _n+1)
	inverse[0], inverse[1] = 0, 1
	for i := 2; i <= _n; i++ {
		g1[i] = (g1[i-1] * i) % mod
		inverse[i] = mod - inverse[mod%i]*(mod/i)%mod
		g2[i] = (g2[i-1] * inverse[i]) % mod
	}

	return g1[n] * (g2[r] * g2[n-r] % mod) % mod
}


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

int main(){
 int X;
 cin >> X;
 int n, ans = 0;
 n = X%500;
 ans += (X / 500) * 1000;
 int m;
 m = n%5;
 ans += (n / 5) * 5;
 cout << ans;
  return 0;
}




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

int main(){
  int N;
  cin >> N;
  int a,b;
  a = N / 4;
  b = N / 7;
  bool judge = false;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      if(N == 4 * i + 7 * j) judge = true;
    }
  }
  if(judge){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;


int keta5(int64_t x){
  int count=0;
  while(x%5==0){
    x/=5;
    count++;
  }
  return count;
}
int keta2(int64_t x){
  int count=0;
  while(x%2==0){
    x/=2;
    count++;
  }
  return count;
}

int64_t SYO(string s){
  string u,v; 
  bool p=true;
  int t=s.size();
  rep(j,t){
    auto w=s.at(j);
    if(w=='.') {
      p=false;
      continue;
    }
    if(p) u.push_back(w);
    else v.push_back(w);
  }
  while(v.size()<9) v.push_back('0');
  reverse(u.begin(),u.end());
  reverse(v.begin(),v.end());
    
  int64_t k=0, x=1;
  rep(j,v.size()){
    k+=x*(v.at(j)-'0');
    x*=10;
  }
  rep(j,u.size()){
    k+=x*(u.at(j)-'0');
    x*=10;
  }
  return k;
}
  
int main() {
  int64_t N,ans=0; cin>>N;
  vector<vector<int64_t>> A(50,vector<int64_t>(50,0));
  
  rep(i,N){
    string S; cin>>S;
    int64_t k=SYO(S);
    int a=keta2(k),b=keta5(k);
    A.at(a).at(b)++;
  }
  
  rep(i,50){
    rep(j,50){
      rep(k,50){
        rep(l,50){
          auto t=A.at(i).at(j), m=A.at(k).at(l);
          if(i+k>17&&j+l>17){
            if(i==k&&j==l) ans+=t*(t-1);
            else ans+=t*m;
          }
        }
      }
    }
  }

  cout<<ans/2;
}


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

int main(){
    int h, w;
    std::cin >> h >> w;

    std::vector<std::string> line(h);
    for(int i = 0; i < h; ++i){
        std::cin >> line.at(i);
    }

    std::string boundary(w + 2, '#');

    std::cout << boundary << std::endl;
    for(int i = 0; i < h; ++i){
        std::cout << '#' << line.at(i) << '#' << std::endl;
    }
    std::cout << boundary << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) {return b?gcd(b, a%b):a;}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
inline constexpr int modpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
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;}
const ll LINF=0x1fffffffffffffff;

int main(){
    ll n,d,cnt=0;
    cin>>n>>d;
    vector<vector<ll>> x(n,vector<ll>(d));
    rep(i,0,n) rep(j,0,d) cin>>x[i][j];
    rep(i,0,n-1) rep(j,i+1,n){
        double s=0;
        rep(k,0,d) s+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        if(sqrt(s)==round(sqrt(s))) cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();

        boolean[] hskip = new boolean[H];
        boolean[] wskip = new boolean[W];
        char[][] a = new char[H][];
        for (int i = 0; i < H; i++) {
            a[i] = sc.next().toCharArray();
        }

        for (int i = 0; i < H; i++) {
            boolean skip = true;
            for (int j = 0; j < W; j++) {
                if (a[i][j] == '#') {
                    skip = false;
                    break;
                }
            }
            if (skip) hskip[i] = true;
        }

        for (int i = 0; i < W; i++) {
            boolean skip = true;
            for (int j = 0; j < H; j++) {
                if (a[j][i] == '#') {
                    skip = false;
                    break;
                }
            }
            if (skip) wskip[i] = true;
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (!wskip[j] && !hskip[i]) {
                    System.out.print(a[i][j]);
                }
            }
            if (!hskip[i]) {
                System.out.println();
            }
        }
        return;
    }

}

Measured memory_bytes: 25428
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    long long int n,a,b,c=0,m =1e18;
    cin >> n;
    while(n > 1)
    {
        n = n/2;
        c++;
    }
    b=pow(2,c+1)-1;
    cout << b << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL a[101010], aCum[101010];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%lld", &a[i]);
    
    // 2. sort.
    sort(a, a + N);
    
    // 3. 一次元累積和.
    rep(i, N) aCum[i + 1] = a[i] + aCum[i];
    
    // 4. 最終的に残ることが出来るか？
    int ans = 0;
    rep(i, N){
        // i番目の生き物について調査.
        LL ua = aCum[i + 1];
        int cur = i, bef = i;
        bool ok = true;
        
        while(cur < N && ua < 1010101010){
            // 自身の二倍となる箇所のインデックスを検索.
            cur = upper_bound(a, a + N, ua + ua) - a;
            
            // 前回と等しい場合は, 合体出来ないケースに引っ掛かったと見る.
            // if(cur < N && a[bef + 1] >= aCum[cur]){
            // in13.txt で, WA版 のため, ロジック修正.
            if(cur < N && a[bef] > aCum[cur]){
                ok = false;
                break;
            }
            
            // 合体.
            ua = aCum[cur];
            
            // 前回分更新.
            bef = cur;
        }
        // カウント.
        if(ok) ans++;
    }
    
    // 5. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 5388
from collections import Counter
n = int(input())
V = list(map(int,input().split()))
Vodd = list()
Veven = list()
for x in range(0,n//2):
    Vodd.append(V[2*x])
    Veven.append(V[2*x+1]) 

oddcounts = Counter(Vodd).most_common(2)
evencounts = Counter(Veven).most_common(2)

number = n - oddcounts[0][1] - evencounts[0][1]

if oddcounts[0][0] == evencounts[0][0]:
    if len(oddcounts) == 1:
        a = 0
    else:
        a = oddcounts[1][1]
    if len(evencounts) == 1:
        b = 0
    else:
        b = evencounts[1][1]
    number = min(n - a - evencounts[0][1],n - oddcounts[0][1] - b)

print(number)

Measured memory_bytes: 16100
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long
#define MAX 200010

bool same(string s) {
    for(int i = 1; i < s.size(); i++) {
        if(s[i] != s[i - 1]) {
            return false;
        }
    }
    return true;
}

signed main() {
    string s; cin >> s;

    int n = s.size();
    int ans = INF;
    for(int i = 0; i < n; i++) {
        string t = s;
        int temp = 0;
        while(!same(t)) {
            for(int j = 0; j < n - 1; j++) {
                if(t[j + 1] == s[i]) t[j] = s[i];
            }
            t.pop_back();
            temp++;
        }
        ans = min(ans, temp);
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N,K;
  in(N,K);
  long T=(N-2)*(N-1)/2;
  if(K>T){
    out(-1);
    return;
  }
  out(N-1+T-K);
  up(i,2,N)out(1,i);
  long cnt=0;
  up(i,2,N-1){
    up(j,i+1,N){
      if(T-K==cnt)return;
      out(i,j);
      cnt++;
    }
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int a, b, c;
int main(){
	scanf("%d%d%d", &a, &b, &c);
	if(b - a == c - b) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(a));i>=((int)(b));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	int n, l; cin >> n >> l;
	int a[n+2];
	bool b[n-1];
	reg(i, 1, n) cin >> a[i];
	a[0] = a[n+1] = 0;
	rep(i, n) b[i] = false;
	
	reg(i, 1, n) if(a[i] >= l || a[i] + a[i+1] >= l){
		cout << "Possible" << endl;
		reg(j, 1, i-1) cout << j << endl;
		ireg(j, n-1, i) cout << j << endl;
		return 0;
	}
	
	cout << "Impossible" << endl;
	
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  int n,m;
  cin>>n>>m;
  vector<P> d(n);
  VI dd(n);
  vector <vector<P> > E(n);
  VI c(n,0);
  VI h(m,-1);
  int x;
  for(i=0;i<n;i++) {
    cin>>x;
    d[i]=P(x,i);
    dd[i]=x;
  }
  sort(d.begin(),d.end());

  int u,v;
  for(i=0;i<m;i++){
    cin>>u>>v;
    u--; v--;
    E[u].pb(P(v,i));
    E[v].pb(P(u,i));
  }
  int te=1;

  for(i=0;i<n;i++){
    int s=d[i].se;
    bool ng=1;
    for(P t:E[s]){
      if(dd[t.fi]<=dd[s]){
        if(c[s]==0&&c[t.fi]==0) {
          c[t.fi]=-1;
          c[s]=-c[t.fi];
        }
        else if(c[s]==0&&c[t.fi]!=0) c[s]=-c[t.fi];
        h[t.se]=dd[s];
        ng=0;
      }
    }
    if(ng){
      cout<<-1<<endl;
      return 0;
    }
    
    //cout<<i<<" "<<c[i]<<endl;
  }

  for(i=0;i<n;i++){
    if(c[i]==-1) cout<<"B";
    else cout<<"W";
  }
  cout<<endl;
  for(i=0;i<m;i++){
    assert(h[i]!=-1);
    cout<<(int)h[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 18944
#include <cstdio>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 3505;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;

int n,m;

int main()
{
    scanf("%d",&n);
    for(int h=1;h<maxn;h++)
    for(int i=1;i<maxn;i++)
    {
        ll ans1=(ll)n*h*i;
        ll ans2=(ll)h*i*4-n*(h+i);
        if(ans2<=0) continue;
        if(ans1%ans2==0)
        {
            printf("%d %d %lld\n",h,i,ans1/ans2);
            return 0;
        }
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
constexpr long long mod=1e9+7;
template <typename T,typename E> //SegmentTree((要素数) int n_,(演算) F f,(更新) G g,(初期値) T d1)
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  int n;
  F f;
  G g;
  T d1;
  E d0;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T d1,
	      vector<T> v=vector<T>()):
    f(f),g(g),d1(d1){
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=d1,vr=d1;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }
  
};
signed main(){
    int N;
    long long K;
    cin>>N>>K;
    vector<pair<int,int>> A(N);
    REP(i,N){
        int a;cin>>a;
        A[i]=make_pair(a,i);
    }
    sort(A.begin(),A.end());
    long long ans=0;
    vector<long long> left(N,0),right(N,0);
    SegmentTree<int,int> seg(N,[](int x,int y){return x+y;},[](int x,int y){return y;},0);
    vector<int> V;
    int j=0;
    REP(i,N){
        int now=A[i].second;
        left[now]=seg.query(0,now);
        right[now]=seg.query(now+1,N);
        if(i<N-1&&A[i].first==A[i+1].first) V.push_back(now);
        else{ 
            while(j<V.size()){
                seg.update(V[j],1);
                j++;
            }
            seg.update(now,1);
        }
    }
    REP(i,N){
        ans+=K*(K+1)/2%mod*right[i]+K*(K-1)/2%mod*left[i];
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
li = sorted(na())
print(li[-1] - li[0])

Measured memory_bytes: 3572
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from functools import reduce

def f(s):
    _res = s[1]
    a = [s[0],s[3],s[4]]
    if reduce(lambda x,y: x + y, list(map(lambda x: x%2,a))) > 1 and a[0] > 0 and a[1] > 0 and a[2] > 0 :
        _res = _res + 3
        a = list(map(lambda x: x - 1,a))
    a = list(map(lambda x: x - x % 2,a))
    _res = _res + a[0] + a[1] + a[2]
    return _res


s = input().split(' ')
print(f(list(map(lambda x:int(x),s))))


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

int main() {
	int A, B;
	cin >> A >> B;
	int ans;
	if (B%A == 0){
		ans = A + B;
	}
	else{
		ans = B - A;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
int n,m;
long long ans;
int main(){
	scanf("%d%d",&n,&m);
	while(m--){
		int a;scanf("%d",&a);ans+=a;
	}
	printf("%lld\n",ans>n?-1:n-ans);
}

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

map<int,int> mp;
int n,t;

int main(){

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

    cin>>n;
    while(n--){
        cin>>t;mp[t]++;
    }
    t=0;
    for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
        t^=(it->second%2==0);
    }
    cout<<mp.size()-t<<endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, a, b;
    cin >> n >> a >> b;
    if (abs(a-b) % 2 == 0){
        cout << "Alice" << endl;
    }
    else cout << "Borys" << endl;
    return 0;
}





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

int main() {
int N;
  cin >> N;
  vector<int> A(N + 1);
  vector<int> B(N);
  long long result = 0;
  for(int a = 0;a < N + 1;a++)cin >> A[a];
  for(int a = 0;a < N;a++)cin >> B[a];
  for(int a = 0;a < N;a++){
   if(A[a] >= B[a]){
    result += B[a]; 
   }else if(A[a] + A[a + 1] >= B[a]){
     result += B[a];
     A[a + 1] -= B[a] - A[a];
   }else{
    result += A[a] + A[a + 1];
     A[a + 1] = 0;
   }
  }
  cout << result << endl;
}

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

using namespace std;

int main(){
    string S;
    string T;

    cin >> S >> T;

    bool s = (S.size() + 1) == T.size();
    T.pop_back();
    bool n = S == T;

    string ans = (s && n) ? "Yes" : "No";

    cout << ans << endl;
}


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

int main () {
  /*
  vector<int> data(3);
  for (int i = 0; i < 3; i++) {
    cin >> data.at(i);
  }

  int count = 0;
  for (int x : data) {
    if (data.at(0) == x) {
      count ++;
    }
    if (data.at(1) == x) {
      count ++;
    }
    if (data.at(2) == x) {
      count ++;
    }
  }
  if (count == 3) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  */
  int A, B, C;
  cin >> A >> B >> C;

  if (A == B) {
    if (A != C) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else if (B == C) {
    if (B != A) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else if (C == A) {
    if (C != B) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1100;
int n,m,a,b,cnt;
char s[N][N];
int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) s[i][j]='.';
	}
	cnt=(n/2)*(m/2);
	if (m&1)
	{
		int tmp=min(b,n/2);
		b-=tmp;
		for (int i=1,x=1;i<=tmp;i++,x+=2) s[x][m]='^',s[x+1][m]='v';
	}
	if (n&1)
	{
		int tmp=min(a,m/2);
		a-=tmp;
		for (int i=1,x=1;i<=tmp;i++,x+=2) s[n][x]='<',s[n][x+1]='>';
	}
	if (n&1 && m&1 && a&1 && b&1 && (a+1)/2+(b+1)/2==cnt+1 && n!=1 && m!=1)
	{
		printf("YES\n");
		int x=1,y=1;
		while (a>1)
		{
			s[x][y]='<',s[x][y+1]='>';
			s[x+1][y]='<',s[x+1][y+1]='>';
			a-=2;y+=2;
			if (y>m-(m&1)) y=1,x+=2;
		}
		while (b>1)
		{
			s[x][y]='^',s[x+1][y]='v';
			s[x][y+1]='^',s[x+1][y+1]='v';
			b-=2;y+=2;
			if (y>m-(m&1)) y=1,x+=2;
		}
		s[n][m]='>';s[n][m-1]='<';
		s[n][m-2]='v';s[n-1][m-2]='^';
		s[n-2][m-2]='<';s[n-2][m-1]='>';
		for (int i=1;i<=n;i++)
		{
			for (int j=1;j<=m;j++) printf("%c",s[i][j]);
			printf("\n");
		}
		return 0;
	}
	if ((a+1)/2+(b+1)/2>cnt)
	{
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	int x=1,y=1;
	while (a>0)
	{
		s[x][y]='<',s[x][y+1]='>';
		if (a!=1) s[x+1][y]='<',s[x+1][y+1]='>';
		a-=2;y+=2;
		if (y>m-(m&1)) y=1,x+=2;
	}
	while (b>0)
	{
		s[x][y]='^',s[x+1][y]='v';
		if (b!=1) s[x][y+1]='^',s[x+1][y+1]='v';
		b-=2;y+=2;
		if (y>m-(m&1)) y=1,x+=2;
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) printf("%c",s[i][j]);
		printf("\n");
	}
}

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

int main(){
	string s;
	vector<string> ans;
	while(true) {
		cin >> s;
		if(s == "-") break;
		int len = s.size();
		int n, h;
		scanf("%d", &n);
		for(int i = 0; i < n; i++) {
			scanf("%d", &h);
			s += s.substr(s.size()-len, h);
		}
		ans.push_back(s.substr(s.size()-len, len));
	}
	for(auto str: ans)
		cout << str << endl;
}



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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= int(b); i++)
#define TRAV(a, e) for(auto x : e)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void solve(__attribute__((unused)) int tc = 0) {
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 256
N,M,X = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(N)]
res = float('inf') #無限で初期化
for i in range(2**N):
    tca = [0]*(M+1) #index(0)=totalcost
    for j in range(N):
        if (i >> j) & 1:#その本を使うかどうかの判定
            for k in range(M+1):
                tca[k] += ca[j][k]
    if min(tca[1:]) >= X:
        res = min(res, tca[0])

if res != float('inf'):
    print(res)
else:
    print(-1)

Measured memory_bytes: 68384
#include<bits/stdc++.h>
#include<iomanip>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
int n,m,ans=0;
cin>>n>>m;
int x[m]={};
int y[m]={};
for(int i=0;i<m;i++){
  cin>>x[i]>>y[i];
}
sort(x,x+m);reverse(x,x+m);
sort(y,y+m);
ans=y[0]-x[0]+1;
if(ans<0)
cout<<0<<endl;
else
cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
llong r,g;

int main(){ _;
  cin>>r>>g;
  cout<<g*2-r<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
using namespace std;
int main()
{
    ios;
    int n;
    cin >> n;
    int h;
    unordered_map<int,int> L;
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> h;
        if(L.count(i - h))
            ans += L[i - h];
        L[i + h]++;
    }
    cout << ans << '\n';
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int x;
	cin>>x;
	int i=1;
	while(x>0) {
		x-=i++;
	}
	cout<<i-1;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ll long long int
#define pi pair<ll,ll>
#define ordered_set tree<pi, null_type,less<pi >, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ordered_set os;
ll sm[M];

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

	ll n,k,ans = 0,i,t;

	cin >> n >> k;
	for(i=1;i<=n;++i)
	{
		cin >> t;
		sm[i] = sm[i-1]+t;
	}

	os.insert(pi(0,0));

	for(i=1;i<=n;++i)
	{
		ans += os.order_of_key(pi(sm[i]-k*i,i));
		os.insert(pi(sm[i]-k*i,i));
	}

	cout << ans << "\n";
}

	

Measured memory_bytes: 17708
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;


int main()
{
	int k, s, a, b;
	cin >> k >> s;
	ll ans=0;
	for(int i=max(s-k, 0); i<=s; i++)
	{
		a=max(0, i-k);
		b=min(k, i);
		if(a<=b) ans+=b-a+1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  int a, b, g;
  long long l;
  while (cin >> a >> b) {
    g = gcd(a, b);
    l = a / g * b / g * g;
    cout << g << " " << l << endl;
  }
}

Measured memory_bytes: 1160
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll a, b, k;
	cin >> k >> a >> b;
	REPN(i, a, b){
		if(i % k == 0){
			puts("OK");
			return 0;
		}
	}

	puts("NG");
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(ll i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fitr(it,it1,itr2) for(auto it=itr1;it!=itr2;++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define PI 3.1415926535897932384626433832795
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll,ll>> vpll;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
const ll MOD=1000000007;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
ll nod (ll num) {
  ll cnt=0;
  while (num) {
    num/=10; 
    ++cnt;
  }
  return cnt;
}

int main()
{
  ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
  ll n;
  cin>>n;
  ll ans=1e10;
  F (i,1,(ll)(sqrt(n)+0.5)+1,1) {
    if (n%i==0) {
      ll a= max (nod(i) ,nod(n/i));
      ans=min(a,ans);
    }
  }
  cout<<ans;

return 0;
}




Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
void input() { cin >> S; }
void solve() {
    x = S[0] - 'A';
    if(x > -1 && x < 26)
        cout << "A" << endl;
    else
        cout << "a" << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}


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

ac = 0
wa = 0
check = [0 for i in range(n)]
fail  = [0 for i in range(n)]
for i in range(m):
  p, s = map(str, input().split())
  if check[int(p)-1] == 1:
    continue
  if s == 'AC':
    check[int(p)-1] = True
    ac+=1
    wa+= fail[int(p)-1]
  else:
    fail[int(p)-1]+=1
      
print(str(ac) + " " + str(wa))
  

Measured memory_bytes: 4760
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = (int) 4e5 + 10;
int edges[maxn][3];

int n, q;

int read() {
  if (scanf("%d%d", &n, &q) < 2) {
    return 0;
  }
  for (int i = 0; i < q; ++i) {
    int s, t, c;
    scanf("%d%d%d", &s, &t, &c);
    edges[2 * i][0] = s, edges[2 * i][1] = t, edges[2 * i][2] = c;
    edges[2 * i + 1][0] = s + 1, edges[2 * i + 1][1] = t, edges[2 * i + 1][2] = c + 1;
  }
  q *= 2;
  return 1;
}


int pr[maxn], w[maxn];

int get(int v) {
  return pr[v] == v ? v : pr[v] = get(pr[v]);
}

void myUnion(int s, int t) {
  s = get(s), t = get(t);
  if (s == t) {
    return;
  }

  if (w[s] == w[t]) {
    ++w[s];
  }

  if (w[s] < w[t]) {
    swap(s, t);
  }

  pr[t] = s;
}

void solve() {
  for (int i = 0; i < n; ++i) {
    pr[i] = i;
    w[i] = 0;
  }

  set<pair<int, int> > evs;
  for (int i = 0; i < q; ++i) {
    evs.insert(mp(edges[i][2], i));
  }

  long long res = 0;
  while (sz(evs)) {
    int id = evs.begin()->second;
    evs.erase(evs.begin());
    int &s = edges[id][0], &t = edges[id][1];
    if (get(s) == get(t)) {
      continue;
    }
    myUnion(s, t);
    res += edges[id][2];
    s = (s + 1) % n;
    t = (t + 1) % n;
    edges[id][2] += 2;
    evs.insert(mp(edges[id][2], id));
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 25216
import java.util.Scanner;

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

    int[][] card = new int[4][13];
    int n = in.nextInt();

    for (int i = 0; i < n ; i++) {
      String s = in.next();
      int r = in.nextInt();
      if (s.equals("S")) {
        card[0][r - 1] = 1;
      }
      else if (s.equals("H")) {
        card[1][r - 1] = 1;
      }
      else if (s.equals("C")) {
        card[2][r - 1] = 1;
      }
      else if (s.equals("D")) {
        card[3][r - 1] = 1;
      }
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 13; j++) {
        if (card[i][j] == 0) {
          if (i == 0) {
            System.out.println("S " + (j + 1));
          }
          else if (i == 1) {
            System.out.println("H " + (j + 1));
          }
          else if (i == 2) {
            System.out.println("C " + (j + 1));
          }
          else if (i == 3) {
            System.out.println("D " + (j + 1));
          }
        }
      }
    }
  }
}

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

int count_leaf(int start, int depth){

    if(depth == 1){
        return 1;
    }else{
        int ans = 0;
        if( start - 1 >= 0){
            ans += count_leaf(start - 1, depth - 1);
        }
        ans += count_leaf(start , depth - 1);
        if( start + 1 <= 9){
            ans += count_leaf(start + 1, depth  - 1);
        }
        return ans;
    }
}

unsigned long func_test(int K){
    unsigned long ans = 0;
    int head = 1;
    int temp_k = K;
    bool found_depth = false;
    int depth = 1;
    while(! found_depth ){
        head = 1;
        for(;head <= 9 ; head++){
            int leaf = count_leaf(head, depth);
            temp_k -= leaf;
            if( temp_k <= 0 ){
                found_depth = true;
                temp_k += leaf;
                break;
            }
        }
        depth++;
    }
    ans = head;
    depth -= 1;
    if(depth == 1){
        return K;
    }
    //std::cout<< "found depth " << depth << " head " << head << " temp k " << temp_k << std::endl;
    while( depth > 1){
        // choose head
        if( head - 1 >= 0){
            int leaf = count_leaf(head - 1 , depth - 1);
            if(leaf < temp_k){
                temp_k -= leaf;
            }else{
                head = head - 1;
                ans = ans * 10 + head;
                depth--;
                continue;
            }
        }
        int leaf = count_leaf(head, depth - 1);
        if(leaf < temp_k){
                temp_k -= leaf;
            }else{
                ans = ans * 10 + head;
                depth--;
                continue;
            }
        
        if(head + 1 <= 9){
            int leaf = count_leaf(head + 1, depth - 1);
            if(leaf < temp_k){
                temp_k -= leaf;
            }else{
                head = head + 1;
                ans = ans * 10 + head;
                depth--;
                continue;
            }
        }
    }
    //std::cout << "ans now " << ans << "temp_k " << temp_k << std::endl;
    ans = ans + temp_k - 1 ;
    //std::cout << ans << std::endl;
    return ans;
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    unsigned int K;
    std::cin >> K;
    std::cout << func_test(K) << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const ll mod = 1e9+7;

int numLen(int K) 
{ 
    if (K % 2 == 0 || K % 5 == 0) 
        return -1; 
  
    int number = 0; 
  
    int len = 1; 
  
    for (len = 1; len <= K; len++) { 
        number = (number * 10 + 1) % K; 
        if (number == 0) 
            return len; 
    } 
  
    return -1; 
} 
main(){
    int k;cin>>k;
    if(k%7 == 0) cout<<numLen(k/7);
    else cout<<numLen(k);
}

Measured memory_bytes: 3620
using System;
class aoj
{
    static void Main()
    {
        const double t = 3.305785;
        string[] u = Console.ReadLine().Split(' ');
        int a = int.Parse(u[0]), b = int.Parse(u[1]);
        int c = a * b;
        double s = (double)c / t;
        Console.WriteLine(s);
    }
}

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

using namespace std;

template<class T>
void copy(vector<T> from, vector<T> to) {
  copy(from.begin(), from.end(), back_inserter(to));
}

template<class T>
void sort(vector<T> a) {
  sort(a.begin(), a.end());
}

template<class T>
void input_to(vector<T> a) {
  T a_i;
  cin >> a_i;
  a.push_back(a_i);
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (a <= c && c <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
var h,n;

function maxHeapify(i){
    var l = i * 2;
    var r = i * 2 + 1;

    var largest;
    if(l <= n && h[l] > h[i]){
        largest = l;
    }
    else
        largest = i;
    if(r <= n  && h[r] > h[largest])
        largest = r;

    if(largest != i){
        var ex;
        ex = h[i];
        h[i] = h[largest];
        h[largest] = ex;
        maxHeapify(largest);
    }
}

function buildMaxHeap(){
    for(var i = n/*Math.floor((n + 1) / 2)*/;i >= 1;i--)
        maxHeapify(i);
}

function Main(input){
    input = input.split("\n");
    n = parseInt(input[0],10);
    input[1] = input[1].split(" ");
    h = new Array(n + 1);
    for(var i = 1;i <= n;i++)
        h[i] = parseInt(input[1][i - 1],10);

    buildMaxHeap();

    for(var i = 1;i <= n;i++){
        String(h[i]);
    }

    var ans = "";

    for(var i = 1;i <= n;i++){
        ans += " " + h[i];
    }
    console.log(ans);
    
}
 
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 117556