akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
#define CEIL(A,B) ((A)+(B)-1)/(B)
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N;
set<ll> res;

inline void count_div(ll n) {
    ll f = 2;
    res.insert(n);
    while(f * f <= n) {
        if(n % f == 0) {
            res.insert(f);
            res.insert(n / f);
        }
        f++;
    }
}

inline bool judge(ll n, ll k) {
    ll tmp;
    while(true) {
        tmp = n % k;
        if(tmp == 0) n /= k;
        else return tmp == 1;
    }
}

inline void count_k(ll n) {
    ll f = 2;
    res.insert(n);
    while(f * f <= n) {
        if(n % f == 0) {
            if(judge(n, f)) res.insert(f);
            if(judge(n, n / f)) res.insert(n / f);
        }
        f++;
    }
}

int main() {
    fastio();
    cin >> N;
    if(N == 2) cout << 1 << "\n";
    else {
        count_div(N - 1);
        count_k(N);
        cout << res.size() << "\n";
    }
    // for(auto e : res) cerr << e << endl;
	return 0;
}

Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

int fac[N] , invfac[N];
void pre(){
    fac[0] = 1;
    for(int i = 1 ; i < N ; ++i)
        fac[i] = (i * fac[i - 1]) % mod;
    invfac[N - 1] = po(fac[N-1] , mod - 2);
    for(int i = N - 2 ; i >= 0 ; --i)
        invfac[i] = (invfac[i + 1] * (i + 1)) % mod ;
}

int ncr(int n , int r){
    if(r > n) return 0;
    ll res = (fac[n] * invfac[r]) % mod ;
    res = (res * invfac[n - r]) % mod ;
    return res;
}

void solve()
{
    int l1 = -1 , l2 = -1;
    int n ;
    cin >> n ;
    pre();
    int vis[n + 1] = {} , a[n + 1];
    for(int i = 1 ; i <= n + 1 ; ++i){
        cin >> a[i];
        if(vis[a[i]]){
            // cout << i << ' ' << vis[a[i]] << ' ' ;
            l1 = vis[a[i]] - 1;
            l2 = (n + 1 - i);
            break;
        }else vis[a[i]] = i;
    }

    ll ans[n + 1] = {}; 
    for(int k = 1 ; k <= n + 1 ; ++k) ans[k] = ncr(n + 1 , k);
    for(int k = 1 ; k <= n + 1 ; ++k){
        ll res = ncr(l1 + l2, k - 1);
        ans[k] = (ans[k] + mod - res) % mod;
        cout << ans[k] << '\n';
    }
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 10544
#include <iostream>

using namespace std;

int main() {
	
	int m, f, r;

	while (true) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) break;
		if (m == -1 || f == -1) {
			cout << "F\n";
		}
		else {
			int sum = m + f;
			if (sum >= 80) cout << "A\n";
			else if (sum >= 65) cout << "B\n";
			else if (sum >= 50) cout << "C\n";
			else if (sum >= 30) {
				if (r >= 50) cout << "C\n";
				else cout << "D\n";
			}
			else cout << "F\n";
		}
	}

	return 0;
}





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

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

  int hh;
  cin >> hh;
  rep(i, n-1){
    int h;
    cin >> h;
    if(hh>h){
      cout << "No" << endl;
      return 0;
    }
    if(hh<h) h--;
    hh = h;
  }

  cout << "Yes" << endl;

}



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

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

  map<int,int> sp;
  multiset<int> diff;
  rep(i,w) sp[i]=i,diff.insert(0);

  vector<int> ans;
  rep(i,h) {
    int a, b; cin >> a >> b; a--, b--;
    int m = -1;
    auto itr = sp.lower_bound(a);
    while (itr != sp.end() && itr->first <= b+1) {
      m = max(m,itr->second);
      diff.erase(diff.find(itr->first-itr->second));
      itr = sp.erase(itr);
    }
    if (m != -1 && b < w-1) {
      sp[b+1] = m;
      diff.insert(b+1-sp[b+1]);
    }
    ans.push_back(diff.empty()?-1:*diff.begin()+i+1);
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}

Measured memory_bytes: 23068
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < a.second;
    }
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> val(N, 0);
    vector<int> cost(N, 0);
    for (int i = 0; i < N; i++)
        cin >> val[i];
    for (int i = 0; i < N; i++)
        cin >> cost[i];

    vector<int> gap(N, 0);
    for (int i = 0; i < N; i++)
        gap[i] = val[i] - cost[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (gap[i] > 0) {
            ans += gap[i];
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int EOorder(int i);
int main(){
	int n;
	cin>>n;
	float a=n;
	n=EOorder(n);
	cout<<n/a<<endl;
	
}
int EOorder(int i){
	if(i%2==1){
		i++;
	}
	i=i/2;
	return i;
}


Measured memory_bytes: 256
s = gets.chomp.split("")
sum = 0
(2 ** (s.length - 1)).times do |i|
  bit = i
  array = []
  s.each_with_index do |ss, i|
    # p "#{ss} #{bit[i]}"
    if bit[i] == 1
      ss = ss + "+"
    end
    array << ss
  end
  sum += eval(array.join)
end
puts sum

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define ll long long

const ll MOD = 1e9+7;

ll q_pow(ll a, ll b){
        ll ans = 1;
        while(b>0) {
                if(b&1) {
                        (ans*=a)%=MOD;
                }
                (a*=a)%=MOD;
                b/=2;
        }
        return ans;
}

ll com(ll n, ll k){
        using namespace std;
        ll x = 1, y = 1;
        for(int i = 1; i <= k; i++) {
                x=x*(n-i+1)%MOD;
                y=y*i%MOD;
                //cout << x << ", " << y << endl;
        }
        return x*q_pow(y,MOD-2)%MOD;
}

int main(){
        using namespace std;
        ll n, a, b, ans;
        cin >> n >> a >> b;
        ans = q_pow(2,n);
        ans--;
        (ans-=com(n,a))%=MOD;
        (ans-=com(n,b))%=MOD;
        ans=(ans+MOD)%MOD;
        //cout << com(n,a) << ", " << com(n,b) << endl;
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,t[2000001];
void maxHeapify(int i){
  int l = i*2,r = i*2+1,largest;
  if (l<=h&&t[l]>t[i])
    largest=l;
  else 
    largest = i;
  if(r<=h&&t[r]>t[largest])
    largest=r;
  if(largest!=i)
    swap(t[i],t[largest]),maxHeapify(largest);
}

int main(){
  string s;
  int a;
  t[0]=2100000000;
  while(cin>>s&&s[2]!='d'){
    if(s[0]=='i'){
      cin>>a;
      h++;
      int i=h;
      t[h]=a;
      while(t[i/2]<t[i])swap(t[i/2],t[i]),i/=2;
      }
    else {
      cout<<t[1]<<endl;
      t[1]=t[h];
      h--;
      maxHeapify(1);
    }
  }
  return 0;
}

Measured memory_bytes: 5292
#include <stdio.h>

int main(void){
	int N,ans=0;
	scanf("%d",&N);
	int A[2][N];
	int i;
	for(i=0;i<N;i++){scanf("%d",&A[0][i]);}
	for(i=0;i<N;i++){scanf("%d",&A[1][i]);}
	
	for(i=0;i<N;i++){ans += A[0][i];}
	ans += A[1][N-1];
	int x,y=ans;
	for(i=N-1;i>0;i--){
		x = y - A[0][i];
		x += A[1][i-1];
		y = x;
		if(x > ans) ans = x;
	}
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    string s;
    cin>>s;
    int n=s.size();
    int first=0;
    int last=0;
    for(int i=0;i<n;i++){
        if(s[i]=='A'){
            first=i;
            break;
        }
    }
    for(int k=n-1;k>=0;k--){
        if(s[k]=='Z'){
            last=k;
            break;
        }
    }
    cout<<last-first+1<<endl;
}

Measured memory_bytes: 640
N,M=map(int,input().split())
gate=[1]*N
start=0
end=N
for i in range(M):
  L,R=map(int,input().split())
  if start<L:
    start=L
  if end>R:
    end=R
if end<start:
  print(0)
else:
  print(end-start+1)

Measured memory_bytes: 3828
def solve():
    N, M, X = map(int, input().split())
    A = map(int, input().split())
    squares = [0 for _ in range(0, N+1)]
    for a in A:
        squares[a] = 1
    print(min(squares[:X].count(1), squares[X+1:].count(1)))


if __name__ == "__main__":
    solve()

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a > b && c < a && c > b){
    cout << "Yes" << endl;
  }
  else if(a < b && c < b && c > a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" <<endl;
  }
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a>b){
            cout << 2*a - 1;
    }
    else if(a==b){
        cout << a + b;
    }
    else {
        cout << 2 * b - 1;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int a,b;
const int k = 50;
bool grid[k][k*2];
signed main(){
  cin>>a>>b;
  a--;
  int r = 0, c = 0;
  rep(i, a){
    grid[r][c] = true;
    c += 2;
    if(c >= k*2){
      c = 0;r += 2;
    }
  }
  cout << 2*k << " " << 2*k << endl;
  rep(i,k)rep(j,k*2)cout << (grid[i][j] ? '.' : '#') << (j == k*2-1 ? "\n" : "");
  
  rep(i,k)rep(j,k*2)grid[i][j] = false;
  b--;r = 1, c = 0;
  rep(i, b){
    grid[r][c] = true;
    c += 2;
    if(c >= k*2){
      c = 0;r += 2;
    }
  }
  rep(i,k)rep(j,k*2)cout << (grid[i][j] ? '#' : '.') << (j == k*2-1 ? "\n" : "");
}




Measured memory_bytes: 256
N,T = map(int,input().split())
ct = [list(map(int,input().split())) for _ in range(N)]

ct.sort(key=lambda x: x[1])
ans = 10**18

for c,t in ct:
  if t > T:
    break
  ans = min(ans,c)
if ans == 10**18:
  ans = 'TLE'
print(ans)

Measured memory_bytes: 3064
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()

if ord(s)<=90:
    ans="A"
else:
    ans="a"
print(ans)

Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;

struct dsu {
    int n;
    vector<int> p, sz;
    int serie;

    dsu(int m) : n(m), serie(m) {
        p.resize(m);
        iota(begin(p), end(p), 0);
        sz.assign(m, 1);
    }

    int get(int u) {
        return p[u] == u ? u : p[u] = get(p[u]);
    }

    int inc() {
        return (n * n - serie) / 2ll;
    }

    void unite(int u, int v) {
        u = get(u), v = get(v);
        if(u == v) return ;
        serie -= sz[u] * sz[u] + sz[v] * sz[v];
        p[u] = v;
        sz[v] += sz[u];
        serie += sz[v] * sz[v];
    }
};

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> ans(m);
    vector<pair<int, int>> e(m);
    for(auto& x : e) cin >> x.fi >> x.se, --x.fi, --x.se;

    dsu u(n);
    for(int i = m - 1; i >= 0; --i) {
        ans[i] = u.inc();
        u.unite(e[i].fi, e[i].se);
    }
    for(int i = 0; i < m; ++i)
        cout << ans[i] << '\n';
}

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

using namespace std;

int main(void)
{
    int N, M, C;
    int sum;
    int ans = 0;
    int j;
    cin >> N >> M >> C;
    vector <int> B(M);
    vector <vector<int>> A(N, vector<int>(M));
    for (auto &i: B) cin >> i;
    for (auto &i: A) for(auto &j: i) cin >> j;
    for (auto i: A)
    {
        sum = 0;
        for (j = 0; j < M; j++) sum += i[j] * B[j];
        sum += C;
        if (sum > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define Yes(i) if(i) cout << "Yes" << endl; else cout << "No" << endl

int main(){
    vector<int> nums;
    int A, B, K;
    cin >> A >> B >> K;
    for(int i = A; i < A + K && i <= B; i++){
        nums.push_back(i);
    }
    for(int i = B; i > B - K && i >= A + K; i--){
        nums.push_back(i);
    }
    sort(nums.begin(), nums.end());
    for(int i = 0; i < nums.size(); i++){
        cout << nums[i] << endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

int n;
string s;
bool b[100010];
bool a[] = { 0,0,1,1 };
int main() {
	cin >> n >> s;
	do {
		b[0] = a[0];
		b[1] = a[1];
		for (int i = 1; i < n - 1; i++) {
			if (s[i] == 'o') {
				if (!b[i])b[i + 1] = b[i - 1];
				else {
					if (b[i - 1])b[i + 1] = 0;
					else b[i + 1] = 1;
				}
			}
			else {
				if (!b[i]) {
					if (b[i - 1])b[i + 1] = 0;
					else b[i + 1] = 1;
				}
				else b[i + 1] = b[i - 1];
			}
		}
		if (!b[n - 1] && s[n - 1] == 'o'&&b[n - 2] != b[0])continue;
		if (!b[n - 1] && s[n - 1] == 'x'&&b[n - 2] == b[0])continue;
		if (b[n - 1] && s[n - 1] == 'o'&&b[n - 2] == b[0])continue;
		if (b[n - 1] && s[n - 1] == 'x'&&b[n - 2] != b[0])continue;
		if (!b[0] && s[0] == 'o'&&b[n - 1] != b[1])continue;
		if (!b[0] && s[0] == 'x'&&b[n - 1] == b[1])continue;
		if (b[0] && s[0] == 'o'&&b[n - 1] == b[1])continue;
		if (b[0] && s[0] == 'x'&&b[n - 1] != b[1])continue;
		for (int i = 0; i < n; i++){
			if (!b[i])cout << 'S';
			else cout << 'W';
		}
		cout << endl;
		return 0;
	} while (next_permutation(a, a + 4));
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;

 

ll int power(ll int x, ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

void computeLPSArray(string pat, int M, int* lps) 
{ 
    // length of the previous longest prefix suffix 
    int len = 0; 
  
    lps[0] = 0; // lps[0] is always 0 
  
    // the loop calculates lps[i] for i = 1 to M-1 
    int i = 1; 
    while (i < M) { 
        if (pat[i] == pat[len]) { 
            len++; 
            lps[i] = len; 
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            // This is tricky. Consider the example. 
            // AAACAAAA and i = 7. The idea is similar 
            // to search step. 
            if (len != 0) { 
                len = lps[len - 1]; 
  
                // Also, note that we do not increment 
                // i here 
            } 
            else // if (len == 0) 
            { 
                lps[i] = 0; 
                i++; 
            } 
        } 
    } 
}
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
  

int main()
{
  fastio();

 
ll int T;
T=1;

while(T--)
{ 
ll int n,k,i,flag=1;
cin>>n>>k;
ll int a[n];
for(i=0;i<n;i++)
  cin>>a[i];

while(k--)
{
  int f=0;
  ll int b[n]={0};
  
  for(i=0;i<n;i++)
  {
    if(a[i]==0)continue;
    b[max(i-a[i],0ll)]++;
    b[max(i,0ll)]--;
    if(i+1<n){
      b[i+1]++;
        if(a[i]+i+1<n)
        b[a[i]+i+1]--;}


  }
  for(i=1;i<n;i++)
    b[i]+=b[i-1];
 
  

        for(i=0;i<n;i++)
    {a[i]=b[i]+1;if(a[i]<n)f=1;}
    if(!f)break;


}
for(i=0;i<n;i++)
  cout<<a[i]<<" ";
}





    
  



    return 0;
}


Measured memory_bytes: 6712
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    l,r,d = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    print(r//d-(l-1)//d)




if __name__ == "__main__":
    main()

Measured memory_bytes: 77420
use proconio::input;

fn main(){
    input! {
        n : usize,
        s : String
    };
    let c = s.chars().collect::<Vec<char>>();
    let r = c.iter().filter(|x| x == &&'R').count();
    let g = c.iter().filter(|x| x == &&'G').count();
    let b = c.iter().filter(|x| x == &&'B').count();
    let mut res = r * g * b;
    for i in 0..n {
        for j in 1..n {
            if i + 2 * j >= n { break }
            if c[i] != c[i+j] && c[i+j] != c[i+2*j] && c[i+2*j] != c[i] {
                res -= 1;
            }
        }
    }
    println!("{}", res);
}

Measured memory_bytes: 2156
#include <stdio.h>
	
	int main(void)
	{
		int a,b,c,d,ks,n,k;
		while(scanf("%d",&n)!=EOF){
		ks=0;
			for(a=0;a<10;a++){
				for(b=0;b<10;b++){
					for(c=0;c<10;c++){
						for(d=0;d<10;d++){
							if(a+b+c+d==n)
								ks++;
						}
					}
				}
			}
			printf("%d\n",ks);
		}
		return 0;
	}

Measured memory_bytes: 596
# 入力の取得
s = input()

even = ""
odd  = ""

#1文字ずつループ
for idx,s in enumerate(s):
    if idx == 0 or idx % 2 == 0:
        even += s
    else:
        odd += s

#判定
even = even.replace('R', '').replace('U', '').replace('D', '')
odd  = odd.replace('L', '').replace('U', '').replace('D', '')


if even == "" and odd == "":
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1024;
int d[maxn][maxn], g[maxn][maxn];
int tot[3][maxn];
int val[3][maxn];
int main(){
  int n, c; cin >> n >> c;
  for(int i = 0; i < c; i++) for(int j = 0; j < c; j++) cin >> d[i][j];
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> g[i][j];
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) g[i][j]--;
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) tot[(i+j)%3][g[i][j]]++;
  int ans = 1<<30;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < c; j++){
      int sum = 0;
      for(int k = 0; k < c; k++){
      	sum += tot[i][k] * d[k][j];
      }
      val[i][j] = sum;
    }
  }
  for(int i = 0; i < c; i++) for(int j = 0; j < c; j++) for(int k = 0; k < c; k++){
    if(i != j && i != k && j != k) ans = min(ans, val[0][i] + val[1][j] + val[2][k]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int i, j, n, a[100000], x[100000];
	unsigned int p = 1;
	scanf("%d", &n);
	for (i = 0; i < 100000; i++)
		x[i] = 0;

	for (i = 0; i < n - 1; i++)
		scanf("%d ", &a[i]);
	scanf("%d", &a[n - 1]);
	
	for (i = 0; i < n; i++) {
		x[a[i]]++;
		if (n % 2 == a[i] % 2 || x[a[i]] > 2 || x[0] > 1) {
			printf("0\n");
			return 0;
		}
	}
	
	for (i = 0; i < n / 2; i++) {
	//	if (p > 1000000007)
	//		p -= 1000000007;
		p = (p * 2) % 1000000007;
	}
	printf("%u\n", p);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forn(i,a,n) for(int i =a;i < n; i++)
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){__
	int n,k;
	cin >> n >> k;
	vi a(n);
	forn(i,0,n) cin >> a[i];
	vi dp(k+1);
	for(int i =1; i <= k;i++){
		int mini = 1e9;
		for(int x : a){
			if(i-x < 0) continue;
			mini = min(mini,dp[i - x]);
		}
		if(mini == 0){
			dp[i] = 1;
		}
	}
	if(dp[k] == 1) cout << "First\n";
	else cout << "Second\n";
}


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

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl



int32_t main()
{
    fast;
    string s,t;cin>>s>>t;
    int a,b;cin>>a>>b;
    string tmp;cin>>tmp;
    if(s==tmp)
        cout<<a-1<<' '<<b;
    else    
        cout<<a<<' '<<b-1;
}   

Measured memory_bytes: 256
/*......................*/
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double   ld;
 
//#include <ext/pb_ds/assoc_container.hpp>   
//#include <ext/pb_ds/tree_policy.hpp>  
//#include <functional> 
//using namespace __gnu_pbds;  
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> OST;           //unique elements  
 
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                       cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int t; cin >> t; while(t--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ook(x)                   order_of_key(x)
#define    fbo(x)                   find_by_order(x)
 
int main(){                                       //constraints , long long
     speed upp
     int n  , m , k; cin >> k >> n;
     int arr[n+5];
     vector <int> v;
     f(i,1,n){
         cin >> arr[i];
     }
     sort(arr+1 , arr+n+1);
     multiset <int> ms;
     f(i,2,n){
         v.pb(arr[i]- arr[i-1]);
     }
     ll total = 0;
     sort(all(v));
     int j = 0;
     if(k > n){
         cout << "0\n"; return 0;
     }
     while(n){
         if(n==k){
             break;
         }
         n--;
         total+=(v[j]);
         j++;
     }
     cout << total << '\n';
}
 

Measured memory_bytes: 1276
def main():
    abc = sorted(list(map(int, input().split())))

    cnt = 0
    while True:
        if abs(abc[2] - abc[0]) <= 1 and abs(abc[2] - abc[0]) <= 1:
            break
        abc[0] += 2
        abc = sorted(abc)
        cnt += 1
    ans = cnt
    if abc[0] == abc[1] and abc[1] == abc[2]:
        ans = cnt
    elif abc[2] == abc[1]:
        ans += 2
    elif abc[0] == abc[1]:
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9148
N, x=map(int, input().split())
a=[]
a=list(map(int, input().split()))
a.sort()
A=0
B=0
for i in range(N):
    A=A+a[i]
    if A<=x:
        B+=1
if A<x:
    B=B-1
print(B)
        

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)


int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif // LOCAL
	int max_val = INT_MIN;
	int min_val = INT_MAX;

	int n;
	scanf("%d", &n);

	int t;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &t);
		if (t > max_val) {
			max_val = t;
		}
		if (t < min_val) {
			min_val = t;
		}
	}
	cout << abs(max_val - min_val) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
long long a[100];
long long ans;
long long n;
void findls(long long &ls){
	while(ls>1&&a[n]-a[ls-1]<=n+1) ls--;
}
void qdown(long long ls)
{
	long long x=n-ls+1;
	long long k=(a[n]-a[ls-1])/(long long)((long long)n-(x-1)+x);
	for(long long i=ls;i<=n;i++)
		a[i]=a[i]-k*((long long)n-(x-1));
	for(long long i=1;i<ls;i++)
		a[i]=a[i]+k*(long long)x;
	ans=ans+k*x;
}
void work()
{
	a[n]=a[n]-n;
	for(long long i=1;i<n;i++)
		a[i]++;
	sort(a+1,a+n+1);
	ans++;
}
void play(long long ls){
	while(a[n]-a[ls-1]>n+1)
		work();
}
void solve(){
	long long k=a[n]-(n+n+n+n);
	if(k<0) return;
	ans=ans+k*n;
	for(long long i=1;i<=n;i++)
		a[i]-=k;
}
int main()
{
//	freopen("C.in","r",stdin);
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	long long ls=n;
	while(ls>1)
	{
		findls(ls);
		if(ls==1)
		{
			solve();
			break;
		}
		qdown(ls);
		play(ls);
	}
	while(a[n]>=n)
		work();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b,c,k;
   cin >> a >> b >> c >> k;
   int r = 0;
   while(b <= a){
      b *= 2;
      r++;
   }
   while(c <= b){
      c *= 2;
      r++;
   }
   if(r <= k){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 

Measured memory_bytes: 3624
N = int(input())
def dfs(s):
  if int(s) > N:
    return 0
  else:
    if all(s.count(c) > 0 for c in "753"):
      cnt = 1
    else:
      cnt = 0
    for c in "753":
      cnt += dfs(s+c)
    return cnt
print(dfs("0"))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll k;

vl f(vl a,vl b){
	vl c;
	for(auto i:a) for(auto j:b) c.push_back(i+j);
	sort(c.rbegin(),c.rend());
	c.resize(min((ll)c.size(),k));
	return c;
}

ll x,y,z;
vl a,b,c;

int main(){
	cin>>x>>y>>z>>k;
	a=vl(x);
	b=vl(y);
	c=vl(z);
	for(auto &i:a) cin>>i;
	for(auto &i:b) cin>>i;
	for(auto &i:c) cin>>i;
	vl d=f(f(a,b),c);
	for(auto i:d) cout<<i<<endl;
}

Measured memory_bytes: 42984
while True:
    n = int(raw_input())
    if n == 0:
        break
    f = [[0 for i in range(21)] for i in range(21)]
    for i in range(n):
        x, y = map(int, raw_input().split())
        f[y][x] = 1

    n = int(raw_input())
    x,y = 10, 10
    for i in range(n):
        c, d = map(str, raw_input().split())
        d = int(d)
        if c == "N":
            for j in range(1,d+1):
                f[y+j][x] = 0
            y += d
        elif c == "E":
            for j in range(1,d+1):
                f[y][x+j] = 0
            x += d
        elif c == "S":
            for j in range(1,d+1):
                f[y-j][x] = 0
            y -= d
        else:
            for j in range(1,d+1):
                f[y][x-j] = 0
            x -= d
    for i in range(20):
        if 1 in f[i][:]:
            print "No"
            break
        if i == 19:
            print "Yes"

Measured memory_bytes: 4284
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

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

	int N; int a; cin >> N >> a;
	if (N == 0) {
		if (a != 1) {
			cout << -1 << endl;
		}
		else {
			cout << 1 << endl;
		}
		return 0;
	}
	else if (a != 0) {
		cout << -1 << endl;
		return 0;
	}

	vector<ll> A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = 0;
	}

	for (int i = 0; i < N; i++) {
		if (i == 0) {
			B[i] = 2;
		}
		else {
			B[i] = B[i - 1] * 2;
		}
		if (A[i] > B[i]) {
			cout << -1 << endl;
			return 0;
		}
		B[i] -= A[i];

		if (B[i] > (1LL << 50)) {
			B[i] = 1LL << 50;
		}
	}

	ll ans = 0;
	ll temp = 0;
	for (int i = N - 1; i >= -1; i--) {
		if (i == -1) {
			ans++;
			break;
		}
		temp += A[i];
		ans += temp;
		if (i > 0) {
			chmin(temp, B[i - 1]);
		}
		else {
			chmin(temp, 1LL);
		}
	}

	cout << ans << endl;

	return 0;
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

int main(){
    ll Q;
    cin >> Q;

    multiset<ll> se;

    while(Q--){
        ll a, x;
        cin >> a >> x;

        if(a==0){
            // insert
            se.insert(x);
            p(se.size());
        }
        else if(a==1){
            // find
            p(se.count(x));
        }
        else if(a==2){
            // delete
            se.erase(x);
        }
        else{
            // dump
            ll L = x;
            ll R; cin >> R;

            auto it = se.lower_bound(L);
            auto it2 = se.upper_bound(R);
            for(; it!=it2; it++){
                p(*it);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 12264
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

/* see https://github.com/pllk/cphb/ */
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;

typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int h, w;
    cin>>h>>w;
    vector<string> s(h);    // one string per row
    vector<int> obsRow[h];  // one list of obstacles per row
    vector<int> obsCol[w];  // one list of obstacles per col

    fori(w)
        obsCol[i].push_back(0);

    fori(h) {
        cin>>s[i];
        obsRow[i].push_back(0);
        for(int j=0; j<w; j++) {
            if(s[i][j]=='#') {
                obsRow[i].push_back(j+1);
                obsCol[j].push_back(i+1);
            }
        }
        obsRow[i].push_back(w+1);
    }

    fori(w)
        obsCol[i].push_back(h+1);

    int ans=0;
    for(int col=1; col<=w; col++) {
        for(int row=1; row<=h; row++) {
            if(s[row-1][col-1]=='#')
                continue;
                
            /* binsearch both directions */
            auto it=upper_bound(obsRow[row-1].begin(), obsRow[row-1].end(), col);
            int horz=*it-*(it-1)-1;
            it=upper_bound(obsCol[col-1].begin(), obsCol[col-1].end(), row);
            int vert=*it-*(it-1)-1;
            ans=max(ans, horz+vert-1);
        }
    }

    cout<<ans<<endl;
    

}



Measured memory_bytes: 38144
def set_info(a, i, p, d):
    a[i][1], a[i][2] = p, d
    for b in a[i][0]:
        set_info(a, b, i, d + 1)

n = int(input())
tree = [[None] for i in range(n)]
root = set(range(n))

for i in range(n):
    l = list(map(int, input().split()))
    tree[l[0]] = [l[2:], None, None]
    root -= set(l[2:])

set_info(tree, root.pop(), -1, 0)

for i in range(n):
    c, p, d = tree[i]
    if p == -1:
        t = "root"
    elif len(c) == 0:
        t = "leaf"
    else:
        t = "internal node"
    print("node ", i, ": parent = ", p, ", depth = ", d, ", ", t, ", ", c, sep="")

Measured memory_bytes: 38188
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

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

    int A;
    double sum = 0;
    for (int i = 0; i < N; ++i) {
        std::cin >> A;
        sum += 1.0 / A;
    }

    std::printf("%lf\n", 1.0 / sum);

    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n < 2) {
    cout << n + 1 << '\n';
  } else if (n == 2) {
    cout << "1\n";
  } else {
    cout << "0\n";
  }
}



Measured memory_bytes: 3212
import java.util.*;

public class Main {
    public static int gcd(int num1,int num2) {
        if(num2==0) return num1;
        else return gcd(num2,num1%num2);
    }

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int H1 = sc.nextInt();
        int M1 = sc.nextInt();
        int H2 = sc.nextInt();
        int M2 = sc.nextInt();
        int K = sc.nextInt();
        int T1 = H1 * 60 + M1;
        int T2 = H2 * 60 + M2;
        int result = T2 - T1 - K;
        System.out.println(result);
    }
}


Measured memory_bytes: 35900
def main():
    N = int(input())
    A = [int(n) for n in input().split()]
    A = sorted(A, key = lambda x: abs(x), reverse=True)
    minus = 0
    for a in A:
        if a < 0:
            minus += 1
    if minus % 2 == 1:
        minus -= 1
    res = 0
    for i in range(N):
        a = A[i]
        if a < 0 and minus > 0:
            A[i] = -a
            minus -= 1
    for i in range(N):
        a = A[i]
        if a < 0:
            A[i] = -a
            A[-1] = -A[-1]
    
    print(sum(A))
main()

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

const long long int mod = 1000000007;
const long long int big = 2999999999999999999;
const long long int small = -2999999999999999999;
#define ll long long int 
#define pb(a) push_back(a)
#define vll vector<long long int>
#define loop(i, n) for(long long int i=1;i<=n;i++)
#define loop0(i, n) for(long long int i=0;i<n;i++)
#define in(i) scanf("%lld", &i);
#define out(i) printf("%lld", i)

ll n, m, k;

void in2(ll& a, ll& b)
{
  in(a);
  in(b);
}
void in3(ll& a, ll& b, ll& c)
{
  in(a);
  in(b);
  in(c);
}

class matrix
{
  public:
    vector<vll> mat;
    matrix(ll n)
    {
      mat.resize(n+1);
      loop(i, n)
        mat[i].resize(n+1, 0);
    }

    matrix operator * (matrix x)
    {
      matrix c(n);
      loop(i, n)
      {
        loop(j, n)
        {
          loop(k, n)
          {
            c.mat[i][j]=(c.mat[i][j] + (mat[i][k]%mod * x.mat[k][j]%mod)%mod)%mod;
          }
        }
      }
      return c;
    }
};

matrix power(matrix a, ll p)
{
  if(p==0)
  {
    matrix iden(n);
    loop(i, n)
      iden.mat[i][i]=1;
    return iden;
  }
  matrix res=power(a, p/2);
  if(p%2)
    return res*res*a;
  else
    return res*res;
}
int main()
{
  in2(n, k);
  ll a, b;
  matrix adjacencyMatrix(n+1);
  loop(i, n)
  {
    loop(j, n)
      in(adjacencyMatrix.mat[i][j]);
  }
  matrix finalMat=power(adjacencyMatrix, k);
  ll ans=0;
  loop(i, n)
  {
    loop(j, n)
    {
      ans=(ans+(finalMat.mat[i][j]%mod))%mod;
    }
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 5208
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
char a[5];
int b[5];
int c[5];
int ji = 0;
bool ok = false;
int main()
{
    cin >> a;
    int len = strlen(a);
    int sum = 0;
    FOR(i,1,4)
    {
        c[i] = a[i-1]-'0';
        sum += c[i];
    }
    memset(b, 0, sizeof(b));
    if(c[1]-c[2]-c[3]-c[4] == 7)cout << c[1] << '-' << c[2] << '-' << c[3] << '-' << c[4] << '=' << 7 << endl;
    else if(c[1]-c[2]+c[3]-c[4] == 7)cout << c[1] << '-' << c[2] << '+' << c[3] << '-' << c[4] << '=' << 7 << endl;
    else if(c[1]-c[2]+c[3]+c[4] == 7)cout << c[1] << '-' << c[2] << '+' << c[3] << '+' << c[4] << '=' << 7 << endl;
    else if(c[1]+c[2]+c[3]+c[4] == 7)cout << c[1] << '+' << c[2] << '+' << c[3] << '+' << c[4] << '=' << 7 << endl;
    else if(c[1]+c[2]-c[3]-c[4] == 7)cout << c[1] << '+' << c[2] << '-' << c[3] << '-' << c[4] << '=' << 7 << endl;
    else if(c[1]-c[2]-c[3]+c[4] == 7)cout << c[1] << '-' << c[2] << '-' << c[3] << '+' << c[4] << '=' << 7 << endl;
    else if(c[1]+c[2]+c[3]-c[4] == 7)cout << c[1] << '+' << c[2] << '+' << c[3] << '-' << c[4] << '=' << 7 << endl;
    else if(c[1]+c[2]-c[3]+c[4] == 7)cout << c[1] << '+' << c[2] << '-' << c[3] << '+' << c[4] << '=' << 7 << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
l=defaultdict(int)
r=defaultdict(int)
for i in range(n):
    l[i+a[i]] += 1
    r[i-a[i]] += 1
ans=0
for i in l:
    ans += l[i]*r[i]
print(ans)

Measured memory_bytes: 163780
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int k;
  cin >> k;
  int val = k/50;
  int dis = k%50;
  vint ans(50,49+val);
  rep(i,0,dis){
    ans[i] += (51 - dis);
  }
  rep(i,dis,50){
    ans[i] -= dis;
  }
  cout << 50 << endl;
  rep(i,0,50){
    cout << ans[i] << " ";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
  string s;
  char city;

  for( ; ; ){
    cin >> s;
    if(s == "#") break;
    
    city = 'A';
    for(int i = 0;i < s.size(); i++){
      s[i] = s[i] - '0';
      switch(city){
      case 'A':
	city = s[i]? 'Y' : 'X';
	break;
      case 'X':
	city = s[i]? 'Z' : 'D';
	break;
      case 'Y':
	city = s[i]? 'D' : 'X';
	break;
      case 'Z':
	city = s[i]? 'B' : 'W';
	break;
      case 'W':
	city = s[i]? 'Y' : 'B';
	break;
      case 'B':
	city = s[i]? 'X' : 'Y';
	break;
      }
      if(city == 'D') break;
    }
    cout << (city == 'B'? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 1184
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int n = sc.nextInt();
			
			int s=0;
			for(int i=0; i<n; ++i){
				a *= 10;
				s += (a/b)%10;
				a = a%b;
			}
			
			System.out.println(s);
		}
		
		sc.close();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000