akhauriyash/Code-Regression huggingface dataset:
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
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...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> a >> b;
  if (b >= a)
    Cout("unsafe");
  else
    Cout("safe");
  return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

inline bool is_in(const int x, const int a, const int b) {
    return a <= x && x <= b;
}

int main() {
    ll l, r, ans;
    cin >> l >> r;
    int m = INT_MAX;
    if(r - l >= 2019) {
        m = 0;
    }
    else {
        l %= 2019;
        r %= 2019;
        if(l >= r) {
            m = 0;
        }
        else {
            FOR(i, l, r + 1) {
                FOR(j, i + 1, r + 1) {
                    m = min(m, (int)((i * j) % 2019));
                }
            }
        }
    }
    cout << m << endl;

    return 0;
}


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

int main() {
	int x, a;
	cin >> x >> a;
	if (x < a) cout << 0 << endl;
	else cout << 10 << endl;
	return 0;
}

Measured memory_bytes: 256
main=interact$maybe"No\n"(unlines.("Yes":).map show).f.map read.words
f[n,x]
  | x == 1 || x == 2*n-1 = Nothing
  | otherwise = let (xs, ys) = splitAt (n-1) $ [1..x-1] ++ [x+1..2*n-1]
                in Just $ reverse xs ++ x:reverse ys

Measured memory_bytes: 20092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main() {
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    cout << (s < t ? "Yes" : "No") << endl;
}


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

int main() {
    std::string S;
    std::cin >> S;

    int64_t sum = 0; 
    for (int i = 0; i < (1 << (S.size() - 1)); ++i) {
        int64_t v = 0;
        std::deque<char> deq;
        for (size_t j = 0; j < S.size() - 1; ++j) {
            deq.push_back(S[j]);
            if ((i >> j) & 1) {
                const std::string str = std::string(deq.begin(), deq.end());     
                v += std::stoll(str);
                deq.clear();
            } 
        }
        deq.push_back(S[S.size()-1]);
        const std::string str = std::string(deq.begin(), deq.end());     
        v += std::stoll(str);

        sum += v;
    }

    std::printf("%ld\n", sum);

    return 0;
}


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

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

    vector<long long> Vals(100001, 0);
    rep(i,N){
        long long val = A[i];
        Vals[val] += 1;
        if(val>1)Vals[val-1]+=1;
        if(val<100000)Vals[val+1]+=1;
    }

    long long ans = *max_element(Vals.begin(), Vals.end());
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 4836
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

using LL = long long;
LL n, s;

int main(void)
{
	cin >> n >> s;
	LL b;
	for (b = 2; b * b <= n; ++b)
	{
		LL nn = n, ss = 0;
		while (nn)
		{
			ss += nn % b;
			nn /= b;
		}
		if (s == ss)
		{
			cout << b << endl;
			return 0;
		}
	}
	for (LL ten = n / b; ten > 0; --ten)
	{
		LL one = s - ten;
		if ((n - one) % ten == 0)
		{
			LL bb = (n - one) / ten;
			if (bb > one && bb > ten && one >= 0 && ten >= 0)
			{
				if (bb >= 2)
				{
					cout << bb << endl;
					return 0;
				}
			}
		}
	}
	if (n == s)
	{
		cout << n + 1 << endl;
	}
	else
	{
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main(){
    int N;
    cin >> N;
    vector<int> x(N);
    REP(i,N) cin >> x[i];
    sort(x.begin(),x.end());
    int ans = 1000000;
    int mi = x.at(0);
    int ma = x.at(N-1);
    for(int i = mi;i<=ma;++i){
        int s = 0;
        REP(j,N){
            int d = x[j]-i;
            d*=d;
            s+=d;
        }
        ans = min(ans,s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3548
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.20 04:22:18
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int keta(int x) {
    int ret = 0;
    while(x) {
        ret++;
        x >>= 1;
    }
    return ret;
}
int bitpopcount(ll n) {
    int res = 0;
    while (n) {
        if (n & 1) res++;
        n >>= 1;
    }
    return res;
}
int main() {
    int l;cin >> l;
    int n = keta(l);
    int m = (n - 1) * 2 + bitpopcount(l) - 1;
    cout << n << " " << m << endl;
    int two = 1, r = l;
    for (int i = n-2; i >= 0; i--) {
        cout << i + 1 << " " << i + 2 << " " << 0 << endl;
        cout << i + 1 << " " << i + 2 << " " << two << endl;
        if (l & (1 << (n-2-i))) {
            cout << 1 << " " << i + 2 << " " << r - two << endl;
            r -= two;
        }
        two <<= 1;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    vec ord(N);
    rep(i,N) ord[i] = i;
    sort(ord.begin(), ord.end(), [&](ll x, ll y){
        return a[x] < a[y];
    });
    rep(i,N){
        cout<<(a[ord[N/2]] <= a[i] ? a[ord[N/2 - 1]] : a[ord[N/2]])<<endl;
    }
}

Measured memory_bytes: 5376
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {

	int a, b; string p;
	cin >> a >> b >> p;
	bool f = 1;
	for (int i = 0; i < p.size(); i++) {
		if (i < a)if (p[i] == '-')f = 0;
		if (i == a)if (p[i] != '-')f = 0;
		if (i > a)if (p[i] == '-')f = 0;
	}
	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	int MAX = 0;
	int Second = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (MAX < A[i]) {
			Second = MAX;
			MAX = A[i];
		}
		else if (Second < A[i]) {
			Second = A[i];
		}
	}
	for (int a : A) cout << (a == MAX ? Second : MAX) << endl;
}


Measured memory_bytes: 2432
n = int(input())
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
l = tuple(x+1 for x in range(n))
#print(a,b,l)
c,d = 0,0
cnt = 0
from itertools import permutations
for k in permutations(l):
    #print(k)
    cnt += 1
    if a ==k:
        c = cnt
    if b ==k:
        d = cnt
print(abs(c-d))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=5002;
int n,A,B,a[N],i,j;
long long f[N],tot;
int main(){
	scanf("%d%d%d",&n,&A,&B);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	a[n+1]=n+1,n++;
	memset(f,63,sizeof(f));
	f[0]=0;
	for (i=1;i<=n;i++){
		tot=0;
		for (j=i-1;~j;j--)
			if (a[j]<a[i]) f[i]=min(f[i],f[j]+tot),tot+=B;
			else tot+=A;
	}
	printf("%lld",f[n]);
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    string s;
    cin >> n >> s;
    lli ans = 0;
    lli now = 0;
    rep(i,n){
        if(s[i]=='I'){
            now++;
        }
        else{
            now--;
        }
        ans = max(ans, now);
    }
    out(ans);
}

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

int main()
{
    ll n;
    cin>>n;
    map<string,int>mp;
    map<string,int>:: iterator it;
    string s;
    for(ll i=1;i<=n;i++)
    {
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans=0,m=0;
    for(it=mp.begin();it!=mp.end();it++)
    {
        m=it->second;
        m--;
        ans+=((m*(m+1))/2);
        m=0;
    }
    cout<<ans<<endl;
    mp.clear();
    return 0;
}


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

int main() {
	ll n, s;
	cin >> n >> s;
	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (0<=s-i-j&&s - i - j <= n)ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi 3.1415926535
using namespace std;

int main() 
{
    string s,t;
    cin>>s>>t;
    ll n=s.size();
    string ch=t.substr(0,n);
    if(ch==s) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
    int n;
    char s[1010];
    scanf("%s",s);
    n = strlen(s);
    if(s[n-1]!='s')
    {
        s[n]='s';
        s[n+1]='\0';
    }
    else if(s[n-1]=='s')
    {
        s[n]='e';
        s[n+1]='s';
        s[n+2]='\0';
    }
    //scanf("%d %d %d",&a,&b,&c);
    printf("%s",s);
}

Measured memory_bytes: 1712
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647


int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);


ll n, m, x, k;

void solve()
{
   string s;
   cin >>k >>  s;
   ll n = s.size();
   if(n <= k) cout << s << endl;
   else{ cout << s.substr(0,k);
   for(int i = k ; i < k+3 ; i ++)
   cout <<'.';
   cout << endl;
   }
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 3612
n = int(input())
a,b = list(map(int, input().split()))
x = list(map(int, input().split()))
#print(x)
x1 = []
x2 = []
x3 = []
for i in range(n):
  if x[i] <=a:
    x1.append(x[i])
  elif a+1 <= x[i] <= b:
    x2.append(x[i])
  else:
    x3.append(x[i])
print(min(len(x1), len(x2), len(x3)))

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

int s(int64_t x) {
    int result = 0;
    for (; x != 0; x /= 10)
        result += x % 10;
    return result;
}

double f(int64_t x) {
    return 1.0 * x / s(x);
}

int main() {
    int n;
    scanf("%d", &n);
    int64_t last = 1, high_bit = 1;
    for (int i = 0; i < n; i++) {
        printf("%lld\n", last);
        if (f(last + high_bit * 10) < f(last + high_bit))
            high_bit *= 10;
        last += high_bit;
    }
    return 0;
}


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

sort_x = sorted(x)

b1 = sort_x[n//2]
b2 = sort_x[n//2-1]

for i in range(n):
    if x[i]>=b1:
        print(b2)
    else:
        print(b1)

Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a<b) swap(a,b); 
	if(a<c) swap(a,c); 
	if(b<c) swap(b,c); 
	cout<<a*10+b+c;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int a[] = new int[n];
    int b[] = new int[n];
    int c[] = new int[m];
    int d[] = new int[m];
    for(int i = 0 ; i < n ; ++i){
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    for(int i = 0 ; i < m ; ++i){
      c[i] = sc.nextInt();
      d[i] = sc.nextInt();
    }
    
    
    for(int i = 0 ; i < n ; ++i){
      int kyori = 0;
      int min = 1000000000;
      int num = 0;
      for(int j = 0 ; j < m ; ++j){
        kyori = Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]);
        if(kyori<min){
          min = Math.min(min,kyori);
          num = j+1;
        }
        
      }
      System.out.println(num);
    }
    
    
  }
}

Measured memory_bytes: 36216
#include<bits/stdc++.h>
using namespace std;
int n,m,k,tot;
char s[10][10];
bool vis[10][10];
int find()
{
	int sum=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
		{
			if(s[i][j]=='#'&&!vis[i][j] ) sum++;
		}
	return sum;
}
int main()
{
	cin>>n>>m>>k;
	for(int i=0;i<n;i++) cin>>s[i];
	for(int i=0;i<(1<<n);i++)
		for(int j=0;j<(1<<m);j++)
		{
			memset(vis,false,sizeof vis);
			int sum=0;
			for(int k=0;k<n;k++)
			{
				if((i>>k&1))
				{
					for(int p=0;p<m;p++)
					{
						
						vis[k][p]=true;
					}
				}
			}
			for(int k=0;k<m;k++)
			{
				if((j>>k&1))
				{
					for(int p=0;p<n;p++)
					{
					
						vis[p][k]=true;
					}
				}
			}
			sum=find();
			if(sum==k) tot++;
		}
	cout<<tot<<endl;
}

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

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

    char c;
    cin >> c;

    if(c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u') cout << "vowel" << endl;
    else cout << "consonant" << endl;

}

Measured memory_bytes: 256
# Complete Binary Tree

n = int(input())
a = list(map(int, input().split())) # heap
# 接点の添字iが与えられた時、その親、左の子、右の子の添え字はそれぞれi//2, 2i, 2i+1
# ヒープの添字は1-indexed
for i in range(1, n+1):
    print("node {0:}: key = {1:}, ".format(i, a[i-1]), end = "")
    if 0 < i // 2:
        print("parent key = {0:}, ".format(a[i//2 - 1]), end = "")
    if 2 * i <= n:
        print("left key = {0:}, ".format(a[2*i - 1]), end = "")
    if 2 * i + 1 <= n:
        print("right key = {0:}, ".format(a[2*i]), end = "")
    print("")


Measured memory_bytes: 5688
import sys
input = sys.stdin.readline
from collections import *

def bfs(s, g):
    q = deque([s])
    dist = [-1]*N
    dist[s] = 0
    
    while q:
        v = q.popleft()
        
        for nv in g[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+1
                q.append(nv)
    
    return dist

def bellman_ford():
    dist = [10**18]*N
    dist[0] = 0
    
    for i in range(N):
        for s, t, w in edges:
            if d1[s]==-1 or d2[t]==-1:
                continue
            
            if dist[t]>dist[s]+w:
                dist[t] = dist[s]+w
                
                if i==N-1:
                    print(-1)
                    exit()
        
    return -dist[N-1]
    
N, M, P = map(int, input().split())
G = [[] for _ in range(N)]
rG = [[] for _ in range(N)]
edges = []

for _ in range(M):
    A, B, C = map(int, input().split())
    G[A-1].append(B-1)
    rG[B-1].append(A-1)
    edges.append((A-1, B-1, -(C-P)))

d1 = bfs(0, G)
d2 = bfs(N-1, rG)
print(max(0, bellman_ford()))

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

using namespace std;
#define rep0(i,j) for(int i=0; i<j; i++)
#define rep1(i,j) for(int i=1; i<=j; i++)
#define lli long long
#define MOD 998244353

int main(){
    lli n, ans = 1;
    cin >> n;
    map<lli,lli> num{};
    lli temp;
    cin >> temp;
    num[temp]++;
    if(temp!=0){
        cout << 0;
        return 0;
    }
    rep1(i, n-1){
        cin >> temp;
        num[temp]++;
    }
    if(num[0]!=1){
        cout << 0;
        return 0;
    }
    rep1(i,num.size()-1){
        rep0(j,num[i]){
            ans *= num[i-1];
            ans %= MOD;
        }
    }
         
    cout << ans;
    

}

Measured memory_bytes: 6528
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input! {
        n: usize,
        k: usize,
        _arr: [i32; n],
    }
    println!("{}", (n + k - 3) / (k - 1));
}


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

int main() {
	// your code goes here
	int n, a , b;
	cin >> n >> a >> b;
	int total = 0;
	for(int i = 1; i <= n; ++i){
		int next = i, sum = 0;
		for(int j = 0; j < 5; ++j){
			sum += next % 10;
			next /= 10;
		}
		if(a <= sum && sum <= b){
			total += i;
		}
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    a, b, t = map(int, input().split())

    ans = 0

    time = 0
    while(t+0.5 > time):
        time += 1
        if time % a == 0 and time < t+0.5:
            ans += b

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];
  sort(A.begin(), A.end(), greater<ll>());
  ll l1 = 0, l2 = 0;
  ll tmp1 = 0, tmp2 = 0;
  for(int i=0; i<N; i++){
    if(l1 == 0)
      if(tmp1 != A[i])
	tmp1 = A[i];
      else
	l1 = A[i];
    else
      if(tmp2 != A[i])
	tmp2 = A[i];
      else
	l2 = A[i];
    if(l1 != 0 && l2 != 0)
      break;
  }
  cout << l1 * l2 << endl;
  return 0;
}


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

//数列Aを読み込み、バブルソートで昇順に並び変え出力するプログラム
int main(){
    int N, i, flag, prev, count, array[100] = {};
    cin >> N;

    //N個の整数を配列に格納
    i = 0;
    while(i < N){
        cin >> array[i];
        i++;
    }

    //バブルソート
    count = 0;
    flag = 1;
    while(flag){
        flag = 0;
        i = N - 1;
        while(i > 0){
            if (array[i] < array[i-1]){
                prev = array[i];
                array[i] = array[i-1];
                array[i-1] = prev;
                count++;
                flag = 1;
            }
            i--;
        }
    }
    
    i = 0;
    while(i < N){
        cout << array[i];
        if (i < N-1) cout << ' ';
        else cout << endl;
        i++;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3088
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;//ここを変えるとよい 
const llint big=1e17+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=0.0000000001;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<lldo>&ar,lldo in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<lldo>&ar,lldo in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int i,n;cin>>n;
	if(n==1){cout<<"Second"<<endl;return 0;}//A[0]=1なので
	vector<llint>a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	
	int flip=0;
	while(-1){
		int ki=0;
		llint sum=0;
		for(i=0;i<n;i++){
			sum+=a[i]-1;
			if(a[i]%2==1){ki++;}
			if(a[i]==1){ki++;}
		}
		if(ki>=2||sum%2==1){cout<<((flip+sum+1)%2==0?"First":"Second")<<endl;break;}
		flip++;
		for(i=0;i<n;i++){if(a[i]%2==1){a[i]--;}}
		llint koya=a[0];
		for(i=1;i<n;i++){koya=gcd(koya,a[i]);}
		//cerr<<koya<<endl;
		for(i=0;i<n;i++){a[i]/=koya;}
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int i = 1;
  while (i * i <= N) i++;
  i--;
  cout << i * i << endl;
  return 0;
}


Measured memory_bytes: 256
// Problem: C - Ubiquity
// Contest: AtCoder - AtCoder Beginner Contest 178
// URL: https://atcoder.jp/contests/abc178/tasks/abc178_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long int
#define ii int
#define du double
#define jmp "\n"
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define printv(v)     \
  for (auto x : v)    \
    cout << x << " "; \
  cout << jmp;
#define vi vector<int>
#define vb vector<bool>
#define ump unordered_map
#define SORT(v) sort(v.begin(), v.end())
#define REV(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()
#define SET(x, a) memset(x, a, sizeof(x))
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
#define deb(x) cout << "test " << #x << "=" << x << jmp
#define deb2(x, y) cout << "test " << #x << "=" << x << "," << #y << "=" << y << jmp
using namespace std;
const ll M = 1e9 + 7;
long long mod(long long x)
{
  return ((x % M + M) % M);
}
long long add(long long a, long long b)
{
  return mod(mod(a) + mod(b));
}
long long mul(long long a, long long b)
{
  return mod(mod(a) * mod(b));
}
ll n;
ll rr(ll a)
{
  ll ans = 1;
  for (ll i = 0; i < n; i++)
    ans = mul(a, ans);
  return (ans);
}

void solve()
{
  ll ans = 0;
  cin >> n;
  ll a = add(rr(10) , rr(8));
  ll b = mul(2 , rr(9));
  cout << mod(mod(a) - mod(b));
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 3628
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N, M = readint()
  
  if M==0
    println(1)
    return
  end
  G = Vector{Vector{int}}(undef,N)
  for i in 1:N 
    G[i] = Vector{int}(undef,0)
  end
  for i in 1:M
    A,B = readint()
    append!(G[A],[B])
    append!(G[B],[A])
  end
  
  
  checked = Vector{Bool}(undef,N)
  checked .= false

  Q = Queue{int}()
  smax = 1
  for i in 1:N
    if checked[i]
      continue
    end
    enqueue!(Q,i)
    checked[i] = true
    s = 0

    while true
      if isempty(Q)
        break
      end
      a = dequeue!(Q)
      s += 1

      for b in G[a]
        if ! checked[b]
          enqueue!(Q,b)
          checked[b]=true
        end
      end
    end
    if smax < s
      smax = s
    end
    #println(G)

  end
  println(smax)
  
  

end

main()


Measured memory_bytes: 248660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,q;
int main(){
  cin >> n >> k >> q;
  vector<ll> a(q);
  vector<ll> b(n,0);
  for(int i=0 ; i<q ; i++){
    cin >> a[i];
    a[i]--;
    b[a[i]]++;
  }
  vector<ll> left(n+1, 0);
  vector<ll> right(n+1, 0);
  for(int i=0 ; i<n ; i++)  left[i+1] = left[i] + b[i];
  for(int i=n-1 ; i>=0 ; i--) right[i] = right[i+1] + b[i];
  for(int i=0 ; i<n ; i++){
    ll K = k - left[i] - right[i+1];
    if(K<=0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

typedef struct _NODE{
    llong key;
    _NODE *right;
    _NODE *left;
}NODE;

NODE *root=NULL;

NODE *MakeNode(llong key){
    NODE *node = (NODE*)malloc(sizeof(NODE));
    node->key = key;
    node->right = NULL;
    node->left = NULL;
    return node;
}

void Insert(llong key){
    if(root==NULL){
        root = (NODE*)malloc(sizeof(NODE));
        root->left = NULL;
        root->right = NULL;
        root->key = key;
        return;
    }
    NODE *now = root;
    NODE *prev;
    NODE *new_node = MakeNode(key);
    while(now!=NULL){
        if(now->key >= key){
            prev = now;
            now  = now->left;
        }else{
            prev = now;
            now  = now->right;
        }
    }
    if(prev->key >= key){
        prev->left = new_node;
    }else{
        prev->right = new_node;
    }
}

void InorderTreeWalk(NODE *node){
    if(node==NULL){
        return;
    }
    InorderTreeWalk(node->left);
    cout << " " << node->key;
    InorderTreeWalk(node->right);
    return;
}

void PreorderTreeWalk(NODE *node){
    if(node==NULL){
        return;
    }
    cout << " " << node->key;
    PreorderTreeWalk(node->left);
    PreorderTreeWalk(node->right);
    return;
}

void PrintTree(NODE *node){
    InorderTreeWalk(node);
    cout << endl;
    PreorderTreeWalk(node);
    cout << endl;
}

int main(){
    llong n;
    cin >> n;
    char command[100];
    llong key;
    for(int i=0; i<n; i++){
        scanf("%s", command);
        if(command[0]=='i'){
            scanf("%lld", &key);
            Insert(key);
        }else{
            PrintTree(root);
        }
    }
    return 0;
}


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

string T, P;

int main(void) {
  cin >> T >> P;

  vector<ll> first;
  {
    ll j = 0;
    REP(i, 0, P.length()) {
      while(j < T.length() && T[j] != P[i]) j++;
      if(j == T.length()) {
        cout << "no" << endl;
        return 0;
      }
      first.push_back(j);
      j++;
    }
    // REP(i, 0, first.size()) cout << first[i] << " ";
    // cout << endl;
  }

  vector<ll> last;
  {
    ll j = T.length() - 1;
    for(ll i = P.length() - 1; i >= 0; i--) {
      while(j >= 0 && T[j] != P[i]) j--;
      if(j == -1) {
        cout << "no" << endl;
        return 0;
      }
      last.push_back(j);
      j--;
    }
    reverse(last.begin(), last.end());
    // REP(i, 0, last.size()) cout << last[i] << " ";
    // cout << endl;
  }

  ll ans = 1;
  REP(i, 0, first.size()) ans = ans && first[i] == last[i];
  cout << (ans ? "yes" : "no") << endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N;
vector<int> s;

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

  ll kaiN=1, kaiM=1, mod=1e9+7;
  REP(i, N){
    kaiN*=i+1;
    kaiN%=mod;
  }
  REP(i, M){
    kaiM*=i+1;
    kaiM%=mod;
  }


  if(M == N){
    cout << (2* kaiM * kaiN) % mod << endl;
  }
  else if(abs(N-M) == 1){
    cout << (kaiM*kaiN) % mod << endl;
  }
  else{
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
t = N - 2
res = a[0]
for x in a[1: ]:
  if t == 0: break
  if t >= 2:
    res += x * 2
    t -= 2
  else:
    res += x
    t -= 1
print(res)

Measured memory_bytes: 92096
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i =0; i<N ;i++){
    cin >> a.at(i);
  }
  vector<int> b(N);
  for(int i =0; i<N ;i++){
    b.at(i) =a.at(i);
  }
  sort(b.begin(), b.end());

  long long max1=b[N-1],max2=0 ,index=0;
  for(int i=0;i<N-1;i++){
    if(b[N-1-i] !=b[N-2-i] ){
      max2 = b[N-2-i];
      break;
    }
    index++;
  }
  for(int i=0; i <N; i++){
    if(a[i] == max1 && max2 !=0 &&index ==0){
      cout << max2<<endl;
    }
    else if(a[i] ==max1 && max2==0){
      cout <<max1<<endl;
    }
    else{
      cout <<max1<<endl;
    }
  }
}

Measured memory_bytes: 3200
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long MOD = 1000000007;
        sc.close();
        long ans = modpow(10, n) - modpow(9, n) - modpow(9, n) + modpow(8, n);
        ans %= MOD;
        ans = (ans + MOD) % MOD;
        System.out.println(ans);
    }

    public static long modpow(long a, long n) {
        long res = 1;
        long MOD = 1000000007;
        while (n > 0) {
            if ((n & 1) != 0) res = res * a % MOD;
            a = a * a % MOD;
            n >>= 1;
        }
        return res;
    }
}


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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    unordered_map<int, vector<int>> dic;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        dic[a].push_back(b);
    }

    ll ans = 0;
    priority_queue<int> queue;
    for (int i = 1; i <= M; ++i) {
        if (dic[i].size() != 0) {
            for (int j = 0; j < dic[i].size(); ++j) {
                int tar = dic[i][j];
                queue.push(tar);
            }
        }
        if (queue.size() >= 1) {
            int tmp = queue.top();
            ans += tmp;
            queue.pop();
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 8868
import networkx as nx
N, M = list(map(int, input().strip().split()))
labels = list(map(int, input().strip().split()))
G = nx.empty_graph(N)
for _ in range(M):
	edge = tuple(map(int, input().strip().split()))
	G.add_edge(edge[0]-1,edge[1]-1)
for nidx, label in enumerate(labels):
	G.nodes[nidx]['high'] = label

good_list = []
for nidx in G.nodes:
	neighbors_high = [0]
	for neighbor in G.neighbors(nidx):
		neighbors_high.append(G.nodes[neighbor]['high'])
	if G.nodes[nidx]['high'] > max(neighbors_high):
		good_list.append(nidx)

print(len(good_list))

Measured memory_bytes: 150704
package main

import (
        "fmt"
)

func solution(a, b, c, k int) string {

        for i := 0; i < k; i++ {
                if a >= b {
                        b *= 2
                } else {
                        c *= 2
                }
        }
        if b > a && c > b {
                return "Yes"
        }
        return "No"
}

func main() {
        var a, b, c, k int
        fmt.Scan(&a, &b, &c, &k)
        fmt.Println(solution(a, b, c, k))
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
  
// Function to return dynamic allocated 
// array consisting integers individually 
int* GetBigInteger(string str) 
{ 
    int x = str.size(), a = 0; 
  
    // Create an array to store the big 
    // integer into it. 
  
    // Make the array size same as the 
    // size of string str 
    int* arr = new int[str.size()]; 
  
    // Loop to extract string elements 
    // into the array one by one 
    while (a != x) { 
  
        // Subtracting '0' to convert 
        // each character into digit 
  
        // str[a] - '0' 
        // = ASCII(str[a]) - ASCII('0') 
        // = ASCII(str[a] - 48 
        arr[a] = str[a] - '0'; 
        a++; 
    } 
  
    // Return the reference of the array 
    return arr; 
} 
  
// Driver Code 
int main() 
{ 
    // Big Integer in form of string str 
     string str;
    cin>>str;
    long long int sum=0;
    // Function Call 
    int* arr = GetBigInteger(str); 
  
    // Print the digits in the arr[] 
    for (long long int i = 0; i < str.size(); i++) { 
       sum+=arr[i];
    } 
    if(sum%9==0)
       cout<<"Yes";
    else
      cout<<"No"; 
    return 0; 
} 


Measured memory_bytes: 4524
#include <algorithm>
#include <functional>
#include <iostream>
#include <unordered_map>

using namespace std;

int main()
{
    while (true) {
        int a;
        int l;
        cin >> a >> l;
        if (a == 0 && l == 0) {
            break;
        }

        auto compute_next = [l](int n) {
            auto s = to_string(n);
            auto a0 = string(l - s.size(), '0') + s;
            auto min_ = a0;
            sort(begin(min_), end(min_));
            auto& max_ = a0;
            sort(begin(max_), end(max_), greater<>{});
            return stoi(max_) - stoi(min_);
        };
        unordered_map<int, int> m;
        m[a] = 0;
        for (int i = 1;; ++i) {
            auto n = compute_next(a);
            auto it = m.find(n);
            if (it != end(m)) {
                cout << it->second << ' ' << n << ' ' << (i - it->second)
                     << endl;
                break;
            }
            m[n] = i;
            a = n;
        }
    }
}

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

#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define fill(a, z) memset(a, z, sizeof(a))
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << z << ' '
#define cnl(z) cout << z << '\n'
#define M 1000000007
#define M2 998244353
#define INF 10000000000000000000
#define MAXN 300005
#define endl "\n"
#define iip(t) \
	int t;     \
	cin >> t;
#define iip2(a, b) \
	int a, b;      \
	cin >> a >> b;
#define dip(a) \
	double a;  \
	cin >> a;
#define dip2(a, b) \
	double a, b;   \
	cin >> a >> b;
#define garr(ip)       \
	for (auto &x : ip) \
		cin >> x;
#define parr(ip)          \
	for (auto &x : ip)    \
		cout << x << " "; \
	cout << endl;
#define test   \
	int _t;    \
	cin >> _t; \
	while (_t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vp;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	rep(a, 1, n)
	rep(b, 1, n)
	rep(c, 1, n)
	{
		ans += __gcd(__gcd(a,b),c);
	}
	cnl(ans);
}

Measured memory_bytes: 3640
n = int(input())
alist = list(map(int, input().split()))

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

ans = alist[0]
for a in alist[1:]:
  if a <= ans:
    ans = gcd(ans, a)
  else:
    ans = gcd(a, ans)
print(ans)


Measured memory_bytes: 14252
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    a,b,n = [int(i) for i in N[l].split()]
    a = a % b
    a = a * (10**n)
    a = a // b
    ans = 0
    while a > 0:
        ans += a % 10
        a = a // 10
    print(ans)


Measured memory_bytes: 5600
n = int(input())
l = []
for i in range(n):
  a,b = input().split()
  b = -int(b)
  l.append([a,b,i+1])
l = sorted(l, key=lambda x:(x[0],x[1]), reverse=False)
for i in range(n):
  print(l[i][2])

Measured memory_bytes: 3060
package main

import "fmt"

var ns []int
var ps []int

func main() {
	var n, x int
	fmt.Scan(&n, &x)

	ns = make([]int, n+1)
	ps = make([]int, n+1)
	ns[0], ps[0] = 1, 1
	for i := 1; i < len(ns); i++ {
		ns[i] = ns[i-1]*2 + 3
		ps[i] = ps[i-1]*2 + 1
	}

	fmt.Println(rec(n, x))
}

func rec(n, x int) int {
	if n == 0 {
		if x <= 0 {
			return 0
		}
		return 1
	}

	mid := (ns[n] + 1) / 2
	if x == mid {
		return ps[n-1] + 1
	}
	if x < mid {
		return rec(n-1, x-1)
	}

	return rec(n-1, x-mid) + ps[n-1] + 1
}


Measured memory_bytes: 512
import math

def prime(x):
    if x==2:
        return 'true'
    elif x%2==0:
        return 'false'
    else:
        i=3
        while i<=math.sqrt(x):
            if x%i==0:
                return 'false'
            i+=2
        return 'true'

n=int(input())
s=0
for j in range(n):
    x=int(input())
    r=prime(x)
    if r=='true':
        s+=1
print(s)


Measured memory_bytes: 5676
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
dp[0] = abc[0]
for i in range(n - 1):
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + abc[i + 1][0]
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + abc[i + 1][1]
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + abc[i + 1][2]
print(max(dp[-1]))

Measured memory_bytes: 47364
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
ans = 0
for i in range(1, n+1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)
        












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

int main() {
	int n;
	vector<long long> a;
	bool loop = true;
	int cnt = 0;

	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	while (loop) {
		for (int j = 0; j < n; j++) {
			if (a[j] % 2 == 0 && a[j] > 0) {
				a[j] /= 2;
			}
			else {
				cnt--;
				loop = false;
				break;
			}
		}
		cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 100000, MAXI = 3, D = 1000;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 10000, flag = 1;
//     cout << tc << "\n";
//     int n = 1;
//     while (tc--)
//     {
//     	n = rand()%N + 1;

//     	cout << n << "\n~\n";

//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 

//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long
#define mod (int)(1e9+7)
#define MAXI (int)(3e17+10)
#define N 105
#define M 100005

int dp[M];

int n, k, a[N];

int MEM(int left)
{
	if(left<0)
		return 1;

	if(left==0)
		return 0;

	if(dp[left]!=-1)
		return dp[left];

	dp[left] = 0;
	for(int i=0;i<n;i++)
	{
		if(!MEM(left-a[i]))
		{
			dp[left] = 1;
			break;
		}
	}

	return dp[left];
}

// Driver code to test above functions
int32_t main()
{
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    
    cin >> n >> k;
    for(int i=0;i<n;i++)
    	cin >> a[i];

    memset(dp, -1, sizeof dp);

    if(MEM(k))
    	cout << "First";
    else
    	cout << "Second";

    

    return 0;
 
} 

Measured memory_bytes: 4224
n=int(input())
num=26
data=[]
while num<=n:
    if n%num==0:
        data.append("z")
        n=int(n/num-1)
    else:
        data.append(chr(n%26+96))
        n=int(n/num)
if n!=0:
    data.append(chr(n+96))
data="".join(data)
print(data[::-1])

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int h,w,k;
char chk[10][1000];

bool ok(int bit, int&cnt){
  int ppp = 0;
  map<int,int>mp;
  mp[0] = 0;
  vector<int> v(cnt+1);
  for(int i = 1; i < h; ++i){
    if(bit&(1<<(i-1)))mp[i] = mp[i-1]+1;
    else mp[i] = mp[i-1];
  }  
  for(int i = 0; i < w; ++i){
    vector<int> w(cnt+1);
    for(int j = 0; j < h; ++j){
      if(chk[j][i] == '1'){
	w[mp[j]]++;
      }
    }
    bool ko = false;
    for(int j = 0; j < cnt+1; ++j){
      if(w[j] > k)return false;
      if(v[j]+w[j] > k){
	ko = true;
	break;
      }
    }
    if(ko){
      ppp++;
      v = move(w);//vector<int>(cnt+1,0);
    } else {
      for(int j = 0; j < cnt+1; ++j)v[j] += w[j];
    }
  }
  cnt += ppp;
  return true;
}

int main(){
  cin >> h >> w >> k;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      cin >> chk[i][j];
    }
  }
  int ans = 1001001001;
  for(int i = 0; i < (1<<(h-1)); ++i){
    // debug(i);
    // debug(ans);
    int cnt = bitset<10>(i).count();
    if(ok(i,cnt)){
      // dline;
      ChangeMin(ans,cnt);
    }
    // debug(cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string O, E;
    cin >> O >> E;
    for(int i = 0; i < E.size(); i++) {
        cout << O[i] << E[i];
    }
    if(O.size() > E.size()) cout << O.back();
    cout << endl;
    return 0;
}


Measured memory_bytes: 256