akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {

        var line = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        long N = line[0];
        long X = line[1];

        var line2 = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        long d_ = 0;
        int maxi = 0;

        for(int i = 0; i <= N - 1; i++)
        {
            d_ = d_ + line2[i];

            if (d_ > X)
            {
                maxi = i;
                break;
            }

            maxi = i + 1;
            
        }



        Console.WriteLine(maxi + 1);

    }

}


//public static int EuclideanAlgorithm(int A, int B)
//{
//    //ユークリッドの互除法　AとBの最大公約数を求める
//    bool p = true;
//    int k = 0; //最大公約数k
//    int Q = Math.Max(A, B); //割られる数
//    int R = Math.Min(A, B); //割る数

//    while (p)
//    {
//        //「割られる数」/「割る数」が割り切れたら、「割られる数」と「割る数」の最大公約数は「割る数」
//        int n = Q % R; //余り
//        if (n == 0)
//        {
//            k = R;
//            p = false;
//        }
//        else
//        {
//            //「割られる数」に「割る数」をセット
//            Q = R;
//            //「割る数」に「余り」をセット
//            R = n;
//        }
//    }

//    return k;
//}

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

int dfs(vector<vector<int>> vec, int n, int max_n, bitset<9> ck, int r = 0) {
  if(ck.count() == max_n ) return ++r;
  
  for(int x: vec.at(n)) {

    if(!ck.test(x)) {
      ck.set(x);
      r = dfs( vec, x, max_n, ck, r);
      if( x != n ) ck.reset(x);
    }
  }
  return r;

};
 
int main() {
  int N,M;
  cin >> N >> M;
  
  vector<vector<int>> A(N+1);
  
  for (int i=1; i<=M; i++) {
    int a1,a2;
    cin >> a1 >> a2;
    A.at(a1).push_back(a2);
    A.at(a2).push_back(a1);
  }
  
  bitset<9> b;
  b.set(1);
  int res =  dfs( A, 1, N, b);
  
  cout << res << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include <stdio.h>
#include <string>
using namespace std;
int main()
{
	int n,q;
	cin>>n>>q;
	queue<int> Q;      //int???????´????????????\???
    queue<string> N;   //string???????´????????????\???
    for(int i = 0; i < n; i++){
        string name;
        int time;
        cin >> name >> time;
        N.push(name);  //????°??????????
        Q.push(time);  //????°??????????
    }
    int timesum = 0;
    while(!N.empty())  //????´?????????????
	{ 
        if(Q.front() - q > 0)
		{
            timesum += q;
            N.push(N.front());
            N.pop();
            Q.push(Q.front() - q);
            Q.pop();
        }
		else
		{
            timesum += Q.front();
            printf("%s %d\n", N.front().c_str(), timesum);
            N.pop();
            Q.pop();
        }
    }
}

Measured memory_bytes: 5860
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)
map<int,vector<int>> g;
void remove(int u,int v) {
  rep(i,g[u].size()) {
    if(g[u][i]==v) {
      g[u].erase(g[u].begin()+i);
      return;
    }
  }
}

int treeSize(int s) {
  set<int> visited;
  visited.insert(s);
  queue<int> q;
  q.push(s);
  while(!q.empty()) {
    int v=q.front();
    q.pop();
    visited.insert(v);
    for(auto& u : g[v]) {
      if(visited.find(u)==visited.end()) {
        q.push(u);
      }
    }
  }
  return visited.size();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  rep(i,n-1) {
    int a,b;
    cin>>a>>b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> prev(n+1);
  queue<int> q;
  q.push(1);
  prev[1]=-1;
  while(!q.empty()) {
    int v=q.front();
    q.pop();
    for(auto& u : g[v]) {
      if(prev[u]==0) {
        prev[u]=v;
        q.push(u);
      }
    }
  }
  vector<int> path;
  {
    int v=n;
    while(v!=-1) {
      path.push_back(v);
      v=prev[v];
    }
  }
  reverse(path.begin(),path.end());
  // for(auto& u : path) {
  //   cout << u << " " ;
  // }
  int u=path[(path.size()-1)/2],v=path[(path.size()-1)/2+1];
  remove(u,v);
  remove(v,u);
  if(treeSize(1)>treeSize(n)) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
  return 0;
}


Measured memory_bytes: 15360
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int h, n;
    cin >> h >> n;
    vi a(n);
    REP(i, n) cin >> a[i];

    REP(i, n) h -= a[i];

    if(h <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
};


Measured memory_bytes: 640
//use proconio::{input, fastout};
use proconio::input;

//#[fastout]
fn main() {
    input! {
        s: String,
    }
    let mut t = String::new();
    for c in s.chars() {
        if c == '?' {
            t.push('D')
        } else {
            t.push(c)
        }
    }
    println!("{}", t);
}


Measured memory_bytes: 2776
#include <iostream>
#include <queue>

using namespace std;



int main(){
	
	
	while(1){
		queue<int> Q;
		int n,m,a[10000][2],b,i,j,k;
		bool c[500]={};
		cin >> n >> m;
		if(n==0&&m==0){
			return 0;
		}
		for(j=0, i=0;i<m;i++){
			cin >> a[i][0] >> a[i][1];
			if(a[i][0]==1){
				c[a[i][1]-1]=true;
				Q.push(a[i][1]);
			}else if(a[i][1]==1){
				c[a[i][0]-1]=true;
				Q.push(a[i][0]);
			}
		}
		for(;Q.size()!=0;){
			b=Q.front();
			Q.pop();
			for(j=0;j<m;j++){
				if(b==a[j][0]){
					c[a[j][1]-1]=true;
				}
				if(b==a[j][1]){
					c[a[j][0]-1]=true;
				}
			}
		}
		int count=0;
		for(i=0;i<500;i++){
			if(c[i]==true){
				count++;
			}
		}
		cout << count-1 << "\n";
	}
}
	

Measured memory_bytes: 1276
A = list(map(int, input().split()))
m = max(A)
if A[0]%2==A[1]%2==A[2]%2:
  print((m-A[0])//2 + (m-A[1])//2 + (m-A[2])//2)
else:
  A.sort()
  ans = 0
  if (A[2]-A[0])%2 == (A[2]-A[1])%2:
    ans += (A[1]-A[0])//2 + A[2]-A[1]
  else:
    ans += (A[1]-A[0])//2 + A[2]-A[1] + 2
  print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i = 0; i < n; i++) d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty()){
    u = q.front();
    q.pop();
    for(int v = 0; v < n; v++){
      if(M[u][v] == 0) continue;
      if(d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for(int i = 0; i < n; i++) cout << i+1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
}

int main(){
  int u, k, v;

  cin >> n;
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) M[i][j] = 0;
  for(int i = 0; i < n; i++){
    cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
ll mod = LLONG_MAX;
ll power(ll a, ll b)
{
	if(b == 0) return 1;
	ll ans = power(a, b/2);
	ans = (ans*ans)%mod;
	if(b%2) ans*=a;
	return ans%mod;
}
ll mul(ll a,ll n, ll mod)
{
	ll ret;
	if(n==0) return 0;
	ret = mul(a,n/2, mod);
	ret = (ret+ret)%mod;
	if(n%2)	ret=(ret+a)%mod;
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	int ans = 0;
	string a, b;
	cin >> a >> b;
	fr(i, a.size())
	{
		if(a[i - 1] != b[i - 1]) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 3804
s = input()
n = len(s)
A = {"A", "T", "G", "C"}
res = 0
for i in range(n):
    for j in range(i+1, n+1):
        ck = True
        for k in range(i, j):
            if not s[k] in A:
                ck = False
                break
        if ck:
            res = max(res, j-i)

print(res)

Measured memory_bytes: 3060
def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

if __name__ == '__main__':
    n = int(input())
    while not is_prime(n):
        n += 1
    print(n)

Measured memory_bytes: 3060
fun main(arg: Array<String>) {
    val N = nextInt()
    val S = next()
    val A = S.map { it == 'o' }.toBooleanArray()
    val B = BooleanArray(N)
    val C = BooleanArray(N)
    for (b in 0 .. 3) { // 00 01 10 11
        B[0] = (b and 1) != 0
        B[1] = (b and 2) != 0
        for (n in C.indices) {
            C[n] = A[n] xor B[n]
            if (n in 1 until N - 1) B[n + 1] = B[n - 1] xor C[n]
        }
        if (B[0] == (B[N - 2] xor C[N - 1]) && B[N - 1] == (B[1] xor C[0])) {
            val ans = B.joinToString("") {if (it) "S" else "W"}
            return println(ans)
        }
    }
    println(-1)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong() = listOfString().map(String::toLong)



Measured memory_bytes: 41256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	rep(i,n){
		cin >> a[i];
		sum += __builtin_ctz(a[i]);
	}
	cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

constexpr ll mod = 1000000007;
 
int main() {
    int n = 0;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    
    int cnt0 = 0;
    for (int x : a) {
        if (x == 0) {
            cnt0++;
        }
    }
 
    if (cnt0 > 3) {
        cout << 0 << endl;
        return 0;
    }
 
    ll color = (cnt0 == 1) ? 3 : 6;
 
    ll ans = 1;
    vector<ll> cur(1e5, 0);
    for (int i=0; i<n; i++) {
        if (a.at(i) == 0) {
            cur.at(0)++;
        } else {
            ans *= cur.at(a.at(i)-1);
            ans %= mod;
            cur.at(a.at(i))++;
            cur.at(a.at(i)-1)--;
        }
    }
    
    cout << ans * color % mod << endl;
 
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;

int main(){
    ll n; cin >> n;
    vl t(n),v(n);
    ll time = 0;
    rep(i,n){
        cin >> t[i];
        time += t[i];
    }
    rep(i,n) cin >> v[i];
    vl tab(40005);
    ll index = 0;
    rep(i,n){
        rep(j,t[i]){
            tab[index] = v[i];
            if(j==t[i]-1) tab[index+1] = min(v[i],v[i+1]);
            else tab[index+1] = v[i];
            index+=2;
        }
    }
    vector<vector<double>> dp(2*(time+1),vector<double>(205,-1));
    dp[0][0] = 0.0;
    //rep(i,60) cout << tab[i] << " ";
    rep(i,2*time){
        rep(j,201){
            if(dp[i][j] != -1){
                if(j+1 <= tab[i]*2) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + j*0.5*0.5 + 0.125);
                if(j <= tab[i]*2) dp[i+1][j] = max(dp[i+1][j], dp[i][j] + j*0.5*0.5);
                if(j >= 1 && j-1 <= tab[i]*2) dp[i+1][j-1] = max(dp[i+1][j-1], dp[i][j] - 0.125 + j*0.5*0.5);
            }
        }
    }
    printf("%.5f\n",dp[2*time][0]);
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, K) ans += p[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

int N,K;
vector<vector<int>> adj_list;//隣接リスト
 
LL ans = 1;
 
void solve(){
	//BFS

	//点iにおける、点0から見た深さ、iにおいて使用不可な色の数を
	//pair<現在の深さ,使用不可な色の数>
	//の形にしておく
	vector<pair<int,int>> point_state(N,make_pair(-1,-1));
	queue<int> q;
	q.push(0);
	point_state[0] = make_pair(0,0);
	while(!q.empty()){
		int now = q.front();
		q.pop();
		int counter = 0;
		for(auto u : adj_list[now]){
			if(point_state[u].first>=0) continue;
			q.push(u);
			point_state[u].first = point_state[now].first + 1;
			if(point_state[u].first<=2){
				point_state[u].second = point_state[u].first + counter;
			}else{
				point_state[u].second = 2 + counter;
			}
			counter++;
		}
	}
	for(int i=0;i<N;i++){
		ans *= (K-point_state[i].second)%mod;
		ans %= mod;
	}
}
 
int main(){
	cin >> N >> K;
	adj_list = vector<vector<int>>(N,vector<int>(0));
	for(int i=0;i<N-1;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		adj_list[a].push_back(b);
		adj_list[b].push_back(a);
	}
 
	solve();
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7288
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

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

int main(){
    int n;
    cin >> n;
    int p[n];
    REP(i,n) cin >> p[i];
    int num=0;
    for(int i=1;i<n-1;++i){
        if(p[i-1]>p[i] && p[i]>p[i+1]) ++num;
        else if(p[i-1]<p[i] && p[i]<p[i+1]) ++num;
    }
    cout << num;
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

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

  int now = a[0];
  int count = 1;
  while (true) {
    if (now == 0) {cout << -1 << endl; break;}
    if (now == 1) {cout << count << endl; break;}

    int tmp = now;
    now = a[now];
    a[tmp] = 0;
    count++;
  }

  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

#define INF 1e+9
#define mp make_pair
#define pb push_back
#define fi first
#define fs first
#define se second
#define i64 long long
#define li long long
#define lint long long
#define pii pair<int, int>
#define vi vector<int>

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

int main() {
#ifdef LOCAL
    freopen("inp", "r", stdin);
    //freopen("outp", "w", stdout);
#else
    // freopen(TASKNAME ".in", "r", stdin);
    // freopen(TASKNAME ".out", "w", stdout);
#endif
    string s;
    cin >> s;
    cout << s.substr(0, (int)s.length() - 8);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    sort(all(s));
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#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;

vector<ll> solve(ll N, vector<ll> A) {
  stack<ll> stk;
  vector<ll> ret(N);
  ll cnt = 0;

  for (ll i = N - 1; i >= 0; i--) {
    ret[i] = cnt;
    if (i == 0) break;

    ll x = A[i - 1], y = A[i];

    while (x > y) {
      ll k = N;
      if (!stk.empty()) {
        k = stk.top();
        stk.pop();
      }
      cnt += (k - i) * 2;
      y *= 4;
    }

    while (x * 4 <= y) {
      stk.push(i);
      x *= 4;
    }
  }

  return ret;
}

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, 0, N) cin >> A[i];

  vector<ll> r = solve(N, A);

  reverse(A.begin(), A.end());
  REP(i, 0, N) A[i] *= 2;
  vector<ll> l = solve(N, A);
  reverse(l.begin(), l.end());
  REP(i, 0, N) l[i] += i + 1;

  REP(i, 0, N) cerr << l[i] << " " << r[i] << endl;

  ll ans = min(l[N - 1], r[0]);
  REP(i, 0, N - 1) ans = min(ans, l[i] + r[i + 1]);
  cout << ans << endl;
}

Measured memory_bytes: 6500
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i,x[nmax],y[nmax],t[nmax],tmp;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)cin>>t[i]>>x[i]>>y[i];
	for(i=1;i<=n;i++)
	{
		tmp=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if(t[i-1]+tmp>t[i] || (t[i-1]+tmp<=t[i] && (t[i]-t[i-1]-tmp)&1))rc("No");
	}
	rc("Yes");
	return 0;
}

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

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

struct task{
    ll a;
    ll b;
};

int main(void){
    vector <task> tasks;
    ll n; cin >> n;
    REP(i, n){
        ll _a; cin >> _a;
        ll _b; cin >> _b;
        tasks.push_back({_a, _b});
    }
    sort(tasks.begin(), tasks.end(), [](task x, task y){return (x.b < y.b);});
    string ans = "Yes";
    ll sum_time = 0;
    REP(i, n){
        sum_time += tasks[i].a;
        if (sum_time > tasks[i].b){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,A,B,C = inpl()
ll = [int(input()) for i in range(N)]

def saiki(cnt,a,b,c,MP):
    if cnt == N:
        if a==0 or b==0 or c==0:
            return INF
        MP += abs(a-A) + abs(b-B) + abs(c-C)
        return MP
    else:
        l = ll[cnt]
        if a == 0:
            tmpa = saiki(cnt+1,a+l,b,c,MP)
        else:
            tmpa = saiki(cnt+1,a+l,b,c,MP+10)
        if b == 0:
            tmpb = saiki(cnt+1,a,b+l,c,MP)
        else:
            tmpb = saiki(cnt+1,a,b+l,c,MP+10)
        if c == 0:
            tmpc = saiki(cnt+1,a,b,c+l,MP)
        else:
            tmpc = saiki(cnt+1,a,b,c+l,MP+10)
        tmpd = saiki(cnt+1,a,b,c,MP)
        return min(tmpa,tmpb,tmpc,tmpd)

print(saiki(0,0,0,0,0))


Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

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







int main() {
    long long K, A, B; cin >> K >> A >> B;
    if (B-A <= 2 || K < A-1) cout << K+1 << endl;
    else {
        long long res = A;
        K -= A-1;
        if (K % 2 == 1) ++res, --K;
        res += (B-A) * (K/2);
        cout << res << endl;
    }
}

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

int main(){
    int N, K;
    long ans = 0;
    cin >> N >> K;
    vector<int> H(N);

    for(int i = 0; i < N; i++){
        cin >> H.at(i);
    }
    sort(H.begin(), H.end());
    reverse(H.begin(), H.end());
    for(int i = K; i < N; i++){
        ans += H.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;

int K;

int main(){
  cin >> K;
  vector<int> A(K);
  REP (i, K) cin >> A[i];
  reverse(ALL(A));
  ll min = A[0];
  ll max = A[0]*2 - 1;
  if (min != 2){
    cout << "-1" << endl;
    return 0;
  }
  ////////////////////////////

  for (int a_i : A) {
    min = (min + a_i -1)/a_i*a_i;
    if(max<min){
      min = -1;
      break;
    }
    max = (max + a_i -1)/a_i*a_i;
  }

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

  if(min == -1) cout << min << endl;
  else{
    cout << min << ' ' << max-1 << endl;
  }
  return 0;
}


Measured memory_bytes: 640
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


a, b, c, d = map(int, input().split())

s = b - a + 1
x = b // c - (a - 1) // c
y = b // d - (a - 1) // d
z = b // lcm(c, d) - (a - 1) // lcm(c, d)

print(s - (x + y) + z)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  dump(abs(x-a) > abs(x-b) ? "B" : "A");
  return 0;
}


Measured memory_bytes: 256
def main():
    #n = int(input())
    a,b,c,d = map( int, input().split())
    if c>=b or a>=d:
        print(0)
    elif a<=c and b>=d:
        print(d-c)
    elif c<=a and d>=b:
        print(b-a)
    elif a >= c:
        print(d-a)
    elif c >= a:
        print(b-c)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();
        string s = sc.NextString();
        int res = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'o') res++;
        }
        Console.WriteLine(res + (15 - s.Length) >= 8 ? "YES" : "NO");
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int x;
	int y;
	int z;
};
node t[6];
bool cmp(node q,node p)
{
	return q.y < p.y;
}
int main()
{
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	t[0].x=a;
	t[1].x=b;
	t[2].x=c;
	t[3].x=d;
	t[4].x=e;
	for(int i=0;i<5;i++)
	{
		for(int j=0;j<=130;j+=10)
		{
			if(j>=t[i].x)
			{
				t[i].y=j-t[i].x;
				t[i].z=j;
				break;
			}
		}
	}
	sort(t,t+5,cmp);
	int ans=0;
	for(int i=0;i<=3;i++)
	{
		ans+=t[i].z;
	}
	ans+=t[4].x;
	cout << ans <<endl;
	return 0;
 } 



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int comp(const char &a,const char &b)
{
  return a>b;
}
int main()
{
	string s;
  	string t;
  	cin>>s>>t;
  	sort(s.begin(),s.end());
  	sort(t.begin(),t.end(),comp);
    if(s<t)cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, collections
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

ans=collections.deque()
n=int(input())
A=list(map(int,input().split()))
for i in range(n):
    if i%2==0:
        ans.appendleft(A[i])
    else:
        ans.append(A[i])
if n%2==0:
    ans=reversed(ans)
print(*ans)


Measured memory_bytes: 89616
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
u = [[] for i in range(k)]
R=0
S=0
P=0

for i in range(n):
  u[i%k]+=t[i]

for i in range(k):
  l=len(u[i])
  for j in range(1,l):
    if u[i][j]==u[i][j-1]:
      u[i][j]='o'
  
  R+=u[i].count('s')
  S+=u[i].count('p')
  P+=u[i].count('r')

print(r*R+s*S+p*P)

Measured memory_bytes: 13428
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int h,w;cin>> h>>w;
  vector<pair<int,int>> vh,vw;
  set<pair<int,int>> sth,stw;
  string field[w][h];
  for(int j=0;j<h;++j){
    string s;cin >>s;
    for(int i=0;i<w;++i){
      string sub = s.substr(i,1);
      field[i][j] = sub;
    }
  }
  for(int j=0;j<h;++j){
    for(int i=0;i<w;++i){
      if(field[i][j] == "#"){
        if(i+1<w) if(field[i+1][j] == "#"){
          vw.push_back(make_pair(i,i+1));
          stw.insert(make_pair(i,i+1));
        }
        if(j+1<h) if(field[i][j+1] == "#"){
          vh.push_back(make_pair(j,j+1));
          sth.insert(make_pair(j,j+1));
        }
      }
    }
  }
  int vec_w_size = vw.size();
  int vec_h_size = vh.size();
  int set_w_size = stw.size();
  int set_h_size = sth.size();
  if(vec_w_size != set_w_size || vec_h_size != set_h_size){
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
  }
  return 0;
}


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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> L(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    ll ng = 0;
    for ( int i = 2; i < N; i++ ) {
        ll a = L[i];
        int ci = -1;
        for ( int j = i-1; j >= 1; j-- ) {
            ll b = L[j];
            if ( ci >= j ) ci = j-1;
            while ( ci < j-1 && L[ci+1]+b <= a ) ci++;
            if ( ci >= 0 ) ng += ci+1;
        }
    }
    ll ans = N*(N-1)*(N-2)/6 - ng;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()


int n, k;
int a[200000];

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

	cin >> n >> k;
	rep(i, n)cin >> a[i];

	for (int i = k; i < n; i++) {
		if (a[i - k] < a[i]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}


	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(W + 2, "#");
 
  for(int l = 0; l < W + 2; l++){
    cout << "#";
  }
  cout << endl;
  
  for(int k = 0; k < H; k++){
    cin >> vec.at(1);
    for(int j = 0; j < 3; j++){
      cout << vec.at(j) ;
    }
    cout << endl;
  }
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

map<ll,ll> factorize(ll x){
  map<ll,ll> ret;
  ll d, q;
  while(x>=4 && x%2==0){ret[2]++; x/=2;}
  d = 3; q = x/d;
  while(q>=d){
    if(x%d==0){ ret[d]++; x=q; }else{ d+=2; }
    q=x/d;
  }
  ret[x]++;
  return ret;
}

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

  if(N == 1){
    cout << 0 << endl;
    return 0;
  }
  
  map<ll,ll> ret = factorize(N);

  ll ans = 0;
  FOR(it,ret){
    ll a = it->second;
    //cout << it->first << " " << a << endl;

    ll cnt = 0;
    ll sum = 0;
    ll tmp = 1;
    while(true){
      if(sum+tmp<=a){
        sum += tmp;
        cnt++;
      }else{
        break;
      }
      tmp++;
    }
    ans += cnt;
  }
  
  cout << ans << endl;
  
  return 0;
}




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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	a %= m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
	map<int, int> mp;
	ll ans = 0;
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}

	rep(i, n) {
		ans += mp[i - a[i]];
		mp[i + a[i]]++;
	}
	cout << ans << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//experi();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}

int main() {
   ll i,j,k;
     ll n,m,s[10],c[10],num[5];
    cin >>n>>m ;
    for(i=0; i<3; i++)
    {
      num[i]=-1;
    }
    for(i=0; i<m; i++)
    {
      ll a,b;
      cin>> a;
      a=n-a;

      cin>>b;
            if(a<0)
      {
        cout <<-1  << endl;
        return 0;
      }
      if(num[a]!=-1 && num[a]!=b)
      {
        cout <<-1  << endl;
        return 0;
      }
      if(a==n-1 && b==0)
      {
        if(n!=1)
        {
          cout <<-1  << endl;
          return 0;
        }
      }
      num[a]=b;
    }


if(num[n-1]==-1 && n != 1)
{
  cout<<1;
}else if(num[n-1]==-1 && n== 1){
  cout<<0;
}else 
{
  cout<<num[n-1];
}

for(i=n-2; i>=0; i--)
{
  if(num[i]==-1)
  {
    cout<<0;
  }else 
  {
    cout<<num[i];
  }

}
   
  cout << endl;
}


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

int main(void) {
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
}

Measured memory_bytes: 3620
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

S = list(readline().rstrip().decode('utf-8'))

import collections
c = collections.Counter(S)
max_c = max(c["a"], c["b"], c["c"])
min_c = min(c["a"], c["b"], c["c"])
diff = abs(max_c - min_c)
if diff <= 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 4052
from collections import deque
sa = deque(input())
sb = deque(input())
sc = deque(input())
d = {"a":sa,"b":sb,"c":sc}
turn = "a"
winner = " "
while (winner == " "):
    turn = d[turn].popleft()
    if len(d[turn]) == 0:
        winner = turn
        break
print(winner.upper())


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 30; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline void maxch(int& a, int b) { if (a < b) a = b; }

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

	//cout << static_cast<int>(_s[0]) - '0' << endl;

	vector<int> s(n);
	rep(i,n) s[i] = static_cast<int>(_s[i]) - '0';

	vector<vector<vector<vector<int>>>> dp(n+1, vector<vector<vector<int>>>(11, vector<vector<int>>(11, vector<int>(11,0))));
	dp[0][10][10][10] = 1;
	rep(i, n) {
		rep(a, 11) {
			rep(b, 11) {
				rep(c, 11) {
				  if(a == 10 && b == 10 && c == 10)  dp[i + 1][s[i]][10][10] += dp[i][10][10][10];
					else if (b == 10 && c == 10) dp[i + 1][a][s[i]][10] += dp[i][a][10][10];
					else if (c == 10) dp[i+1][a][b][s[i]] += dp[i][a][b][c];
					
					dp[i + 1][a][b][c] += dp[i][a][b][c];
				}
			}
		}
	}

	int ans = 0;
	rep(a,10) rep(b,10) rep(c,10) if(dp[n][a][b][c]) {ans++; //cout << a << b << c << " " << dp[n][a][b][c] << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 323584
import sys

N=int(input())
C=[int(input()) for i in range(N)]
mod=10**9+7

if N==1:
    print(1)
    sys.exit()

S=[C[0]]

for i in range(1,N):
    if C[i]!=C[i-1]:
        S.append(C[i])

L=len(S)

if L==1:
    print(1)
    sys.exit()

AL=[[] for i in range(2*10**5+1)]

for i in range(L):
    AL[S[i]].append(i)

PLUS=[0]*(2*10**5+1)

NOW=1

for i in range(L):
    NOW,PLUS[S[i]]=(NOW+PLUS[S[i]])%mod,(PLUS[S[i]]+NOW)%mod
    #PLUS[S[i]]+=NOW
    

    #print(NOW,PLUS)

#print(PLUS)
print(NOW)
    
    


Measured memory_bytes: 44588
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n,cou=0,res=1;
  	cin >> n;
  	for(int i=1;i<=n;i++){
    	int a =i,counter=0;
      	if(i%2==0){
        	while(a>=0){
            	a /= 2;
              	counter++;
              	if(a%2==1) break;
             }
        }
      	if(counter>cou){
        	cou=counter;
          	res=i;
        }
    }
	cout<<res<<endl;
}

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int x,ans=0;
    cin>>x;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                int tmp=500*i+100*j+50*k;
                if(tmp==x){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();
        int s = a1+a2+a3;
        if(s >= 22){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }

    }
}

Measured memory_bytes: 21716
import numpy as np
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N,M,Q = map(int,readline().split())
lines = readlines()
L,R = np.array([line.split() for line in lines[:M]],np.int32).T
P,Q = np.array([line.split() for line in lines[M:]],np.int32).T

cnt = np.zeros((N+1,N+1),dtype=np.int32)
np.add.at(cnt,(L,R),1)

np.cumsum(cnt,axis=0,out=cnt)
np.cumsum(cnt,axis=1,out=cnt)
P -= 1
x = cnt[Q,Q] - cnt[Q,P] - cnt[P,Q] + cnt[P,P]
print(*x,sep="\n")

Measured memory_bytes: 98244
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 1000005
//<<fixed << setprecision(9)
ll fac[space];
void pre()
{
    int i;
    fac[0]=1;
    rep(i,1,space)fac[i]=(fac[i-1]*i)%mod;
}



ll EE(ll a, ll b, ll *x, ll *y)
{
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1;
    ll gcd = EE(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}

ll inverse(ll a, ll m)
{
    ll x,y;
    EE(a,m,&x,&y);
    if(x<0) x += m;
    return x;
}

ll choose(ll n,ll k)
{
	ll i;
	ll num=1,den=1;
	for(i=2;i<=k;i++)
	{
		den*=i;
		den%=mod;
	}
	for(i=n-k+1;i<=n;i++)
	{
		num*=i;
		num%=mod;
	}
	
	i=num*inverse(den,mod);
	i%=mod;
	return i;
}

int main()
{
    pre();
    int n,i,j,t;
    boost;
    int x,y;
    cin>>x>>y;
    int a,b;
    bool ok=1;
    t=2*y-x;
    if(t%3!=0)ok=0;
    a=t/3;
    b=y-2*a;

    if(a<0 || b<0)ok=0;

    
    if(ok)
    {
        cout<<choose((a+b),a);
    }
    else cout<<0;
    return 0;
}



Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int arr[1000010];
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int k;
  cin>>k;
  set<int> s;
  int y=0,i=1;
  while(true)
  {
    y=(y*10+7);
    y=(y%k);
    if(arr[y]==1)
    {
      break;
    }
    if(y==0)
    {
      cout<<i<<endl;
      return 0;
    }
    arr[y]=1;
    i++;
  }
  cout<<"-1"<<endl;
  return 0;
}


Measured memory_bytes: 7504