akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    int n ,x,l;
    cin >> n >> x;
    vector<int> L(n);
    rep(i, n) {
        cin >> L[i];
    }
    vector<int> d;
    int cnt = 0;
    d.pb(0);
    for(int i=1; i<=L.size(); ++i) {
            d.pb(d.at(i-1) + L.at(i-1));
    }
    rep(i,d.size()) {
        if (d[i]<=x) {
            cnt++;
        }
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 256
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int n = in();
  vi a(n);
  rep(i, n) a[i] = in() - 1;
  bool vis[100000] = {};

  int next = 0;
  int cnt = 0;
  while (true) {
    if (vis[next]) {
      print(-1);
      break;
    }
    if (next == 1) {
      print(cnt);
      break;
    }
    vis[next] = true;
    next = a[next];
    cnt++;
  }
}


Measured memory_bytes: 768
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            a=n//i 
            if (a+1)*i<=n:
              a+=1
            n=a
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
N=int(input())
a=prime_factors(N)
current=0
index=0
anslist=[]
for i in a:
  if i!=current:
    current=i
    anslist.append(1)
  else:
    anslist[-1]+=1
ans=0
for i in anslist:
  k=1
  while (k*(k+1))<=2*i:
    k+=1
  k-=1
  ans+=k
print(ans)


Measured memory_bytes: 62992
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n,m;
  cin>>n>>m;
  if(n > m) swap(n,m);

  if(n == 1 && m == 1) {cout<<1<<endl;return 0;}
  if(n == 1) {cout<<m - 2<< endl;return 0;}

  int ans = (n-2) * (m-2);
  cout<<ans<<endl; 
  

  
  
  return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = T.length();
  for(int i = 0; i < int(S.length() - T.length() + 1); i++) {
    // i is start index of part string
    int count = 0;
    for(int j = i; j < int(i + T.length()); j++) {
      if(S[j] != T[j - i]) count++;
    }
    ans = min(ans, count);
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

int div(int a){
  if(a%2 != 0) return 0;
  return 1+div(a/2);
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 0;
  rep(i,n){
    int x;
    cin >> x;
    ans += div(x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vli vector<li>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pi pair<int,int>
#define FOR(i,s,n) for(auto i=s;i<n;++i)
#define FORN(i,s,n) for(auto i=s;i<=n;++i)
#define FORR(i,s,n) for(auto i=s;i>=n;--i)
#define FORE(i,a) for(auto i : a)
#define mp make_pair
const int MOD = 1e9+7;

void solve() {
    ll h;
    ll a;
    cin >> h >> a;
    ll cnt = 0;
    while(h>0) {
        h-=a;
        cnt++;
    }
    cout <<cnt << endl;
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 3516
def solve():
    N, A, B = map(int, input().split())
    h = []
    for _ in range(N):
        h.append(int(input()))
    ans_min = 0
    ans_max = 10 ** 9
    while ans_min + 1 < ans_max:
        ans = (ans_min + ans_max) // 2
        count = 0
        for i in h:
            count += (max(0, i - B * ans) + A - B - 1) // (A - B)
        if count > ans:
            ans_min = ans
        else:
            ans_max = ans
    print(ans_max)
    return
solve()

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

#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  ll long long
#define sc second
#define fr first
const int nax = 2e5+5;
// const int mod = 1e4+7;
using namespace std;
typedef pair<double,double> pi;
typedef tuple<int,int,int> tu;

signed main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt" , "w" , stderr);
    #endif
	int mod;
	cin >> mod;
	ll val = 7%mod;
	for(int i=1;i<1e6;i++)
	{
		if(val == 0)
		{
			cout << i << "\n";
			return 0;
		}
		val = (val*10+7)%mod;
	}
	cout << -1 << "\n";
	return 0;
}



Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll H1,M1,H2,M2,K;
  cin>>H1>>M1>>H2>>M2>>K;
  int tmp = (H2-H1)*60 + (M2-M1);
  if(tmp<K) cout<<0<<endl;
  else cout << tmp-K<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long n;
	long m;
	long i;
	cin >> n >> m;
	for(i=(m/n);i>=1;i--)
	{
		if(m%i==0)
		{
			cout << i;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

vi to[200005];
vi ans;

void dfs(int v, int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
  return;
}

int main () {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N, Q; cin >> N >> Q;
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].PB(b);
    to[b].PB(a);
  }

  ans.resize(N);
  REP(i,Q) {
    int p, x; cin >> p >> x;
    --p;
    ans[p] += x;
  }

  dfs(0);
  REP(i,N) {
    cout << ans[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 23552
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,n,ans=0;
    cin>>n;
    N=n;
    
    for(int i=0;i<8;i++){
        if(N==0){break;}
        else{    
        ans+=N%10;
        N=N/10;
        }
    }
    if(n%ans==0){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    return 0;
    
}


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

int main(){
  int S;
  cin >> S;
  int h = S/3600;
  S -= h*3600;
  int m = S/60;
  S -= m*60;
  int s = S;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}

Measured memory_bytes: 3104
<?php

function fget_array($dlmt = null) {
    $input = trim(fgets(STDIN));
    return $dlmt ? explode($dlmt, $input) : str_split($input);
}

list($n) = fget_array(' ');
$a = fget_array(' ');

asort($a);
$a = array_map(function($i) { return $i + 1; }, array_keys($a));
echo implode(' ', $a);
?>


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

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c;
	while (!(a <= b && b <= c)) {
		if (a > b) {
			x = a;
			y = b;
			a = y;
			b = x;
		}
		if (b > c) {
			x = b;
			y = c;
			b = y;
			c = x;
		}
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 3084
def m():
    A, B, C = map(int, input().split())
    K = int(input())
    while A >= B:
        B *= 2
        K -= 1

    while B >= C:
        C *= 2
        K -= 1

    if K < 0:
        return 'No'
    else:
        return 'Yes'

print(m())

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> p(N);
  for (int i = 0; i < N; i++) {
    string a;
    int b;
    cin >> a >> b;
    p.at(i) = make_tuple(a, b*(-1), i+1);  
  }
 
  sort(p.begin(), p.end());
 
  for (int i = 0; i < N; i++) {
    int id;
    tie(ignore, ignore, id) = p.at(i);  
    cout << id << endl;
  }
}

Measured memory_bytes: 256
while True:
    w, h = map(int, input().split())
    if w == 0 and h ==0:
        break
    goal = (w,h)
    vart = []
    hori = []
    for i in range(2*h-1):
        if i % 2 == 0:
            vart.append(list(map(int, input().split())))
        else:
            hori.append(list(map(int, input().split())))
    node = [[0 for i in range(h)] for i in range(w)]
    queue = [(0,0,1)]
    res = 0
    while queue:
        p = queue.pop(0)
        x, y, z = p[0], p[1], p[2]
        if x == w-1 and y == h-1:
            res = z
            break
        node[x][y] += 1
        if y-1 >= 0 and hori[y-1][x] == 0 and node[x][y-1] == 0:
            node[x][y-1] = node[x][y]
            queue.append((x,y-1,z+1))
        if y+1 < h and hori[y][x] == 0 and node[x][y+1] == 0:
            node[x][y+1] = node[x][y]
            queue.append((x,y+1,z+1))
        if x-1 >= 0 and vart[y][x-1] == 0 and node[x-1][y] == 0:
            node[x-1][y] = node[x][y]
            queue.append((x-1,y,z+1))
        if x+1 < w and vart[y][x] == 0 and node[x+1][y] == 0:
            node[x+1][y] = node[x][y]
            queue.append((x+1,y,z+1))
    print(res)

Measured memory_bytes: 7620
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
	string S;
	cin >> S;
	int co,cz;
	co = cz = 0;
	for (int i = 0; i < S.length(); ++i) {
		if (S[i] == '0') {
			++co;
		}
		else {
			++cz;
		}
	}
	cout << S.length()-(abs(co-cz)) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdint>
using namespace std;

const int N_MAX = 100000;

int c[N_MAX];

int main() {
    int n, k;

    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> c[i];
    }

    unsigned int ans = 0xFFFFFFFF;
    for(int i = 0; i < n - k + 1; i++) {
        ans = min(ans, static_cast<unsigned int>(abs(c[i]) + abs(c[i + k - 1] - c[i])));
        ans = min(ans, static_cast<unsigned int>(abs(c[i + k - 1]) + abs(c[i + k - 1] - c[i])));
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fore(i, init, n) for(long long i = init; i < n; i++)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
 
const int MAXN = 1e4+5;
int sn, tn, dp[MAXN][MAXN];
string s, t;
bool vis[MAXN], v[MAXN];
 
void debug() {
    cout << endl << endl;
    fore(i,0,sn) {
        fore(j,0,tn) {
            cout << dp[i][j] << " ";
        }
        cout << s[i];
        cout << endl;
    }
    fore(i,0,tn+1) cout << t[i] << " ";
 
}
 
int main() {
    FIN;
 
    cin >> s >> t;
    
    sn = s.size(); 
    tn = t.size();

    for(int i = sn-1; i >= 0; i--) {
        for(int j = tn-1; j >= 0; j--) {
            if (s[i] == t[j]) {
                dp[i][j] = 1 + dp[i+1][j+1];           
            }
            dp[i][j] = max({dp[i][j], dp[i+1][j], dp[i][j+1]});
        }
    }
 
    int i = 0, j = 0;
    string res = "";
    while(i < sn && j < tn) {
        if (s[i] == t[j]) {
            res += s[i];
            i++;j++;
        } else { 
            if (dp[i+1][j] > dp[i][j+1]) i++;
            else j++;
        }
    }
 
    cout << res << endl;

    // debug();
}

Measured memory_bytes: 117888
/**
*    created: 02.08.2020 21:00:06
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int 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 all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    if (n >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>


int time=0;
int f[101];
int d[101];
int dd[101];
int ff[101];
int Adj[101][101];
int color[101];

void dfs(int);
void visit(int,int);

int main(){
  int n,i,j,k,N,K;

  scanf("%d",&n);

  //初期化
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      Adj[i][j]=0;
      color[i]=0;
      dd[i]=0;
      ff[i]=0;
    }
  }

			
  for(i=1;i<=n;i++){
    scanf("%d",&N);
    scanf("%d",&k);

    for(j=1;j<=k;j++){
      scanf("%d",&K);
      Adj[N][K]=1;
    }
  }


  color[1]=1;
  dfs(n);

   for(i=1;i<=n;i++){
       printf("%d %d %d\n",i,d[i],f[i]);
   }




  return 0;
}


void dfs(int n){
  int i,j;
  for(i=1;i<=n;i++){

    for(j=1;j<=n;j++){
      if(Adj[i][j]==1){
	if(color[j]==0){
	  if(dd[i]!=1){
	    d[i]=++time;
	    dd[i]=1;
	  }
	  //	  printf("dfs %d %d\n",i,d[i]);
	  visit(j,n);
	}
      }
    }

    if(ff[i]!=1){
      f[i]=++time;
      ff[i]=1;
    }
      
  
  }

}

void visit(int u,int n){
  int i;
  // printf("%d\n",u);
  color[u]=1;
  d[u]=++time;
  // printf("visit d %d %d\n",u,d[u]);
  for(i=1;i<=n;i++){
    if(Adj[u][i]==1)
      if(color[i]==0)
	visit(i,n);
  }
  color[u]=2;

  if(ff[u]!=1){
    f[u]=++time;
    ff[u]=1;
  }


  //  printf("visit f %d %d\n",u,f[u]);

  }

Measured memory_bytes: 640
n,k = map(int,input().split())
a = list(map(int,input().split()))
cur = 0
reach = [False]*n
x = []
for i in range(k+1):
    x.append(cur)
    if reach[cur]:
        break
    reach[cur]=True
    cur = a[cur]-1
cnt = 0
for i in range(len(x)):
    if x[i]==x[-1]:
        break
    cnt += 1


y = x[cnt:-1]
if k>cnt:
    ind = (k-cnt)%len(y)
    print(y[ind]+1)
else:
    print(x[k]+1)



Measured memory_bytes: 32380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll count=0;
    for(ll i=1;i<n-1;i++)
    {
        ll greater=0;
        if(a[i+1]<a[i])
        {
            greater++;
        }
        if(a[i-1]<a[i])
        {
            greater++;
        }
        if(greater==1)
        {
            count++;
        }
        else
        {

        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

vector<vector<int>> graph;
vector<int> vis;

int dfs(int u){
	vis[u] = 1;
	int ans = 1;
	for(int v : graph[u]){
		if(!vis[v])
			ans += dfs(v);
	}
	return ans;
}

void solution(){
	int n,m; cin >> n >> m;
	graph = vector<vector<int>>(n);
	vis = vector<int>(n,0);
	for(int i = 0; i < m; i++){
		int u, v; cin >> u >> v;
		u--; v--;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	int ans = 1;
	for(int i = 0; i < n; i++){
		if(!vis[i]){
			ans = max(ans, dfs(i));
		}
	}
	cout << ans << endl;
}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 21020
#1は一意
#2は小さい番号の石の数が大きくなるように、大きい番号の石を除きたい

#個数が同順のものを、番号小以外が個数が時点になるまで除いてから、番号少を除く
n = int(input())
a = list(map(int, input().split( )))

cnt = {}#keyは個数、要素は最小番号

for i in range(n):
    if a[i] in cnt:
        cnt[a[i]][0] = min(cnt[a[i]][0],i)
        cnt[a[i]][1]+=1
    else:
        cnt[a[i]] = [i,1]

#個数、最小番号、番号の数    
mins = [[k,cnt[k][0],cnt[k][1]] for k in cnt]
mins.append([0,0,0])
#末端処理になっていない
mins.sort(reverse = True)
#print(mins)
ans = [0]*n

for i in range(len(mins)-1):
    k,cntk,l = mins[i][0],mins[i][1],mins[i][2]
    ans[cntk] += (k-mins[i+1][0])*l
    mins[i+1][2]+=l###=じゃおかしい
    if mins[i+1][1]>mins[i][1]:##追加
        mins[i+1][1] = mins[i][1]
#ans[mins[-1][1]]=n*mins[-1][0]

for ai in ans:
    print(ai)
    





Measured memory_bytes: 91340
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000007

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin>>n;

	vector<int> A(n);

	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	long long int sum=0;
	for(int i=1;i<n;i++){
		if(A[i]<A[i-1]){
			sum+=A[i-1]-A[i];
			A[i]=A[i-1];
		}

	}
	cout<<sum<<endl;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define rep(i, n)     for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n)    for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n)    for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n)   for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v)  for (auto &&V : v)
#define all(x)        (x).begin(), (x).end()
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = 1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;

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

  int n;
  cin >> n;
  vector<int> h(n);
  rep (i, n) cin >> h[i];
  int maxi = 0, cnt = 0;
  rep (i, n - 1) {
    if (h[i] >= h[i + 1]) ++cnt;
    else {
      maxi = max(maxi, cnt);
      cnt  = 0;
    }
  }
  maxi = max(maxi, cnt);
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a==1 && b==2)
	printf("3\n");
	else if (a==2 && b==1)
	printf("3\n");
	else if (a==1 && b==3)
	printf("2\n");
	else if (a==3 && b==1)
	printf("2\n");
	else if (a==2 && b==3)
	printf("1\n");
	else if (a==3 && b==2)
	printf("1\n");
	return 0;
}


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




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

	int l[5001] = {};
	int ans = 0;

	for (int i = n - 1; i >= 0; i--) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j]) {
				if ((j - i) < l[j + 1] + 1)
					l[j] = l[j + 1];
				else
					l[j] = l[j + 1] + 1;
			}
			else l[j] = 0;
			ans = max(ans, l[j]);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main(){
	char a[19];
	
	for(int i=0;i<19;i++){
		cin>>a[i];
		if(a[i] == ','){
			a[i]=' ';
			}
		cout<<a[i];
		}
	cout<<endl;	
	}

Measured memory_bytes: 256
#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>
using namespace boost::multiprecision;
using namespace std;
 
int main()
{
  int n;
  cpp_int d;
  cin >> n >> d;
 
 int c = 0;
 for (int i=0; i<n; ++i){
     cpp_int x,y;
     cin >> x >> y;

     if (x * x + y * y <= d * d) {
       ++c;
     }
 }
  
  cout << c << endl;
  
  return 0;
}

Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  string a,b;
  cin>>a>>b;
  if(a.size()>b.size()) cout<<"GREATER"<<endl;
  else if(a.size()==b.size()){
    if(a>b) cout<<"GREATER"<<endl;
    else if(a==b) cout<<"EQUAL"<<endl;
    else cout<<"LESS"<<endl;
  }
  else cout<<"LESS"<<endl;
  return 0;
}










Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int n, k;
  cin >> n >> k;
  vecint h(n);
  REP(i,n) cin >> h[i];
  sort(all(h));
  ll ans = 0;
  REP(i,n - k){
    ans += (ll)h[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF=float('inf')
MOD=10**9+7
input=sys.stdin.readline

x,y=map(int,input().split())



if (x+y)%3!=0:
    print(0)
    exit()

if x==0 and y==0:
    print(0)
    exit()


n=(2*y-x)//3
m=(2*x-y)//3


if m<0 or n<0:
    print(0)
    exit()

if n==0 and m==1:
    print(1)
    exit()
if n==1 and m==0:
    print(1)
    exit()
    

#n+mCm
#(n+m)!/m!


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)



print(cmb(n+m, m, 10**9+7))

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

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    int idx=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(arr[i]!=arr[j])
            {
                for(int k=j+1;k<n;k++)
                {
                    if(arr[k]!=arr[i]&&arr[k]!=arr[j]&&arr[k]<arr[i]+arr[j])
                    {
                       idx++;
                    }
                }
            }
        }
    }
    cout<<idx<<endl;
}


Measured memory_bytes: 3644
#include<stdio.h>

int main (void){
	
	int num=0,i,count=0,n;
	char number[1001]={0};

	while(1){
		scanf("%s",number);
		if(number[0] == '0')break;
		num = 0;
		
		for(i=0;number[i] != '\0';i++){
			num += number[i]-'0' ;
		}
	printf("%d\n",num);
	}
return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;
ll n,m;
ll a[100009],sum[100009];
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
    ll l=0,r=2e5+1,ans,cnt,res;
    while(l<=r){
        ll mid=(l+r)>>1;
        res=cnt=0;
        for(ll i=1;i<=n;i++){
            ll pos=lower_bound(a+1,a+n+1,mid-a[i])-a;
            cnt+=n-pos+1;
            res+=sum[n]-sum[pos-1]+a[i]*(n-pos+1);
        }
        if(cnt>=m){
            ans=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    printf("%lld\n",res-(cnt-m)*ans);
    return 0;
}


Measured memory_bytes: 1792
N = gets.to_i
reds = []
N.times{
  reds << gets.split.map(&:to_i)
}
reds.sort_by!{|r| -r[1]}
blues = []
N.times{
  blues << gets.split.map(&:to_i)
}
blues.sort_by!{|b| b[0]}
count = 0
blues.each{|b|
  pair =  reds.select{|r| r[0] < b[0] && r[1] < b[1] }[0]
  if pair != nil
    reds.delete(pair)
    count += 1
  end
}
puts count



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

A,B,C = inpl()
print(max(C-(A-B),0))


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

int main(){
  string s;
  cin>>s;
  char c='a';
  for(int i=0;i<26;i++){
    if(s.find(c+i)==string::npos){
      cout<<(char)(c+i);
      return 0;
    }
  }
  cout<<"None";
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int a, b;
  	cin >> a >> b;
  	int mod = (a + b) % 2;
  	if (mod <= 0.4) {
    	cout << (a + b)/2 << endl;
    } else if (mod >= 0.5) {
    	cout << (a + b)/2 + 1 << endl;
    }
  	
}

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


int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int i=1; i<=n; i++){
        if(i%3!=0 && i%5!=0){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  double a, b, x;
  cin >> a >> b >> x;
  double ans;
  if(x <= a*a*b/2) {
    double aa = 2*x/(a*b);
    double l = sqrt(b*b + aa*aa);
    ans = asin(b/l) * 360 / (2*M_PI);
  }
  else {
    double bb = 2*(a*a*b-x) / (a*a);
    double l = sqrt(a*a+bb*bb);
    ans = acos(a/l) * 360 / (2*M_PI);
  }
  printf("%0.12f\n", ans);
}


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

int main() {
  int n,a[n];
  cin >> n;
  for(int i=0;i<n;i++){
  	cin >> a[i];
  }
  
  int flg=0;
  int count=0;
  while(flg==0){
  	for(int j=0;j<n;j++){
    	if(a[j]%2==1){
        	flg++;
          break;
        }
    }
    if(flg==0){
      count++;
      for(int i=0;i<n;i++){
      	a[i]/=2;
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3612
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
using ll = long long;
const int INF = 100000;
const int MAX_N = 105;


int n=3;

int main(){

    int c[3][3];

    rep(i,n){
        rep(j,n){
            cin >> c[i][j];
        }
    }

    bool flag1 = false;
    bool flag2 = false;

    for(int i=1;i<=100;i++){
        int x1 = c[0][0] - i * c[1][0];
        int y1 = c[0][1] - i * c[1][1];
        int z1 = c[0][2] - i * c[1][2];

        int x2 = c[2][0] - i * c[1][0];
        int y2 = c[2][1] - i * c[1][1];
        int z2 = c[2][2] - i * c[1][2];

        if(x1==y1 && x1==z1) flag1 =true;
        if(x2==y2 && x2==z2) flag2 =true;
    }

    if(flag1 && flag2) cout << "Yes" <<endl;
    else cout << "No" << endl;


}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;
ll maximum = 0;
ll** dp;
ll* table;

int main(){

	scanf("%d",&N);

	table = new ll[N];
	dp = new ll*[N];
	for(int i = 0; i < N; i++){
		dp[i] = new ll[N];
		for(int k = 0; k < N; k++)dp[i][k] = 0;
	}

	for(int i = 0; i < N; i++)scanf("%lld",&table[i]);

	int end;

	for(int length = 0; length < N; length++){
		for(int start = 0; start < N; start++){

			end = (start+length)%N;

			if((N-length+1)%2 == 0){
				dp[start][end] = max(table[start] + dp[(start+1)%N][end],table[end] + dp[start][(end-1+N)%N]);
			}else{ //IOI??????
				if(table[start] > table[end]){
					dp[start][end] = dp[(start+1)%N][end];
				}else{
					dp[start][end] = dp[start][(end-1+N)%N];
				}
			}
		}
	}

	for(int i = 0; i < N; i++){
		maximum = max(maximum,dp[i][(i+N-1)%N]);
	}

	printf("%lld\n",maximum);

	return 0;
}

Measured memory_bytes: 34508
// inputに入力データ全体が入る
function Main(input) {
    input = input.split(/\r\n|\r|\n/);
    var peaples = input[0];
    const transportNum = 5;

    input = input.map(currentValue => parseInt(currentValue,10));

    //交通手段の最小値
    var bottleNeck = input.reduce((accumulator, currentValue, currentIndex) =>{
      if(currentIndex == 1){
        return currentValue;
      }
      if(accumulator > currentValue){
        return currentValue;
      }else{
        return accumulator;
      }
    });

    //出力
    if(peaples%bottleNeck == 0){
      console.log(Math.floor(peaples/bottleNeck) + transportNum -1);
    }else{
      console.log(Math.floor(peaples/bottleNeck) + transportNum);
    }
  }
  
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
n=int(input())
v=list(map(int,input().split()))
d1=[0]*(10**5+1)
d2=[0]*(10**5+1)

for i in range(n):
    if i%2==0:
        d1[v[i]]+=1
    else:
        d2[v[i]]+=1
if d1.index(max(d1))==d2.index(max(d2)):
    d1n=sorted(d1,reverse=True)
    d2n=sorted(d2,reverse=True)
    if d1n[1]>d2n[1]:
        print(n-d1n[1]-d2n[0])
    else:
        print(n-d1n[0]-d2n[1])
else:
    print(n-max(d1)-max(d2))

Measured memory_bytes: 20612
/*input
12
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;
int solve(int k){
	int ans=0;
	for(;k;k/=10) ans+=k%10;
	return ans;
}
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>k;
	if(k%solve(k)==0) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int N,X[105],Y[105],i;
double D;

double d(int p)
{
	int i;
	for(D=0.0,i=0;i<N;i++)
	{
		if(p==4)D=D>abs(X[i]-Y[i])?D:abs(X[i]-Y[i]);
		else D+=pow(1.0*abs(X[i]-Y[i]),p);
	}
	return p==4?D:pow(D,1.0/p);
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",X+i);
	for(i=0;i<N;i++)scanf("%d",Y+i);
	for(i=1;i<5;i++)printf("%lf\n",d(i));
	return 0;
}


Measured memory_bytes: 2108
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, c;
    cin >> n >> c;
    vector<vector<pair<int, int>>> range(c);
    vector<int> num_recording(200001);
    for (int i = 0; i < n; ++i) {
        int s, t, channel;
        cin >> s >> t >> channel;
        range[channel - 1].push_back(make_pair(s, t));
    }

    for (int i = 0; i < c; ++i) {
        sort(range[i].begin(), range[i].end());
        range[i].push_back(make_pair(inf, inf));
        auto cur = range[i].front();
        for (int j = 1; j < range[i].size(); ++j) {
            if (range[i][j].first == cur.second) {
                cur.second = range[i][j].second;
            } else {
                ++num_recording[2 * cur.first - 1];
                --num_recording[2 * cur.second];
                cur = range[i][j];
            }
        }
    }

    int ans = num_recording.front();
    for (int i = 1; i < num_recording.size(); ++i) {
        num_recording[i] += num_recording[i - 1];
        ans = max(num_recording[i], ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2304
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.random;
import std.range;
import std.functional;
import std.container;
class bt(T)
{
    t!T root;
    void insert(T key)
    {
        t!T y = null;
        auto x = root;
        auto z = new t!T(key);
        while (x)
        {
            y = x;
            if (z.key < y.key)
            {
                x = x.left;
            }
            else
            {
                 x = x.right;
            }
        }
        z.parent = y;
        if (!y)
        {
            root = z;
        }
        else
        {
            if (z.key < y.key)
            {
                y.left = z;
            }
            else
            {
                y.right = z;
            }
        }
    }
}
class t(T)
{
    T key;
    this(T k)
    {
        key = k;
    }
    t left, right, parent;
}
void in_(T)(t!T t)
{
    if (!t)
        return;
    in_(t.left);
    write(" ", t.key);
    in_(t.right);
}
void pre(T)(t!T t)
{
    if (!t)
        return;
    write(" ", t.key);
    pre(t.left);
    pre(t.right);
}
void main()
{
    auto c = readln.strip.to!int;
    bt!int b = new bt!int;
    foreach (_; 0..c)
    {
        auto instr = readln.strip.split(" ");
        if (instr.length == 1)
        {
            in_(b.root);
            writeln();
            pre(b.root);
            writeln();
        }
        else
        {
            auto key = instr[1].to!int;
            b.insert(key);
        }
    }
}


Measured memory_bytes: 56208
#include <iostream>

int N, K;
int dislike_numbers[10];

bool checkPayNumber(int pay_number, int *dislike_numbers) {
    int surplus;
    while (pay_number != 0) {
        surplus = pay_number % 10;

        for (int i = 0; i < K; i++) {
            if (surplus == dislike_numbers[i]) return false;
        }

        pay_number /=10;
    }
    return true;
}

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

    int num;
    for (int i = 0; i < K; i++) {
        std::cin >> dislike_numbers[i];
    }

    while(1) {
        if (checkPayNumber(N, dislike_numbers)) {
            std::cout << N << std::endl;
            return 0;
        }
        N++;
    }
}

Measured memory_bytes: 256
/**
*    author:  velengel
*    created: 12.06.2020 17:09:20
*    to run & test the code, type below command.
*    cptest abc000_a
**/

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n);++i)
#define each(i, mp) for(auto& i:mp)
typedef long long ll;
using namespace std;

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

  int n;
  cin >> n;
  ll ans = 1;
  bool f = false;
  ll ikichi = 1000000000000000000;

  ll a[1000001];

  rep(i,n){
    cin >> a[i];
    if(a[i]==0){
      ans = 0;
      cout << 0 << endl;
      return 0;
    }
  }

  rep(i, n)
  {
    if(a[i] > ikichi || (ikichi+1)/ans<a[i]){
      f = true;
      cout << -1 << endl;
      return 0;
    }

    if (!f){
      ans *= a[i];
    }
      
    if(ans>ikichi){
      f = true;
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4432
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
int N;
int M;
cin >> N;
vector<string> B(N);
for(int i = 0; i < N; i++){
    cin >> B[i];
}
cin >> M;
vector<string> R(M);
for(int i = 0; i < M; i++){
    cin >> R[i];
}

int coin = 0;

for(int i = 0; i < N; i++){
    int c = 0;
    for(int j = 0; j < N; j++){
        if(B[i] == B[j])c++;
    }
    for(int j = 0; j < M; j++){
        if(B[i] == R[j])c--;
    }
coin = max(coin , c);
}

cout << coin << endl;
}



Measured memory_bytes: 256
def ti():
    return int(input())

a = [None] * 5
e = [None] * 5
for _ in range(5):
    a[_] = ti()
    e[_] = 10 -(a[_] % 10)

for x in range(5):
    if e[x] == 10:
        e[x] = 0

print(sum(a) + sum(e) - max(e))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> A(4);
  string S;
  cin>>S;
  for(int i=0;i<4;i++) A[i]=S[i]-'0';
  for(int i=0;i<(1<<3);i++){
    int ans=A[0];
    bitset<3> X(i);
    for(int j=0;j<3;j++){
      if(X.test(j))
        ans+=A[j+1];
      else
        ans-=A[j+1];
    }
    if(ans==7){
      cout<<A[0];
      for(int j=0;j<3;j++){
        if(X.test(j))
          cout<<'+';
        else
          cout<<'-';
        cout<<A[j+1];
      }
      break;
    }
  }
  cout<<"=7";
}


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

const int IINF = INT_MAX;
#define REP(i, n) for (int i = 0; i < n; i++)
 
int n, m, d[1005], c[1005], dp[1005][1005];
 
int main() {
    cin >> n >> m;
    REP(i,n) cin >> d[i];
    REP(i,m) cin >> c[i];
    REP(i,n+1) fill(dp[i], dp[i]+m+1, IINF/2);
    dp[0][0] = 0;
    REP(i,n){
        REP(j,m){
            dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]+c[j]*d[i]);
            dp[i][j+1] = min(dp[i][j+1], dp[i][j]);
 
        }
    }
    int ans = IINF/2;
    REP(i,m+1) ans = min(ans, dp[n][i]);
    cout << (ans<IINF/2?ans:-1) << endl;
    return 0;
}


Measured memory_bytes: 6176
import sys
sys.setrecursionlimit(10**7)
 
n=int(input())
l=[list(input()) for i in range(n)]
connection=[[] for i in range(n)]
for i in range(n):
  for j in range(n):
    if l[i][j]=='1':
      connection[i].append(j)
 
colors = [0]*n
def dfs(v,color):
    colors[v] = color
    for to in connection[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and not dfs(to, -color):
            return False
    return True
 
def is_bipartite():
    return dfs(0,1)
if is_bipartite()==0:
  print(-1)
  sys.exit()

def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while len(next)!=0 and visitct!=n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        distance[next[i]]=ct
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return distance

ans=[]
for i in range(n):
  ans.append(max(bfs(i)))
print(max(ans)+1)

Measured memory_bytes: 44652
import java.util.Scanner;

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

		char[] c = sc.next().toCharArray();
		int n = c.length;
		int[] buffer = new int[n];
		int id = 0;
		for (int i = 0; i < n; i++) {
			if (c[i] == '0') {
				buffer[id++] = 0;
			} else if (c[i] == '1') {
				buffer[id++] = 1;
			} else {
				id = Math.max(0, id - 1);
			}
		}
		for (int i = 0; i < id; i++) {
			System.out.print(buffer[i]);
		}
		System.out.println();
	}

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


Measured memory_bytes: 8660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = NextInt();
            var list = IntList();
            list.Sort();

            var first = 0;
            var last = list.FindIndex(x => x != list[0]);
            last = last == -1 ? N : last;
            var result = last - first;

            for (int now = 0; now <= 100000 && last < N; now++) {
                while (first < N && list[first] < now - 1) first++;
                while (last < N && list[last] < now + 2) last++;

                result = Math.Max(result, last - first);
            }

            Console.WriteLine(result);

            //Console.WriteLine(Enumerable.Range(0, 100001).Max(x => list.Count(y => y - 1 <= x && x <= y + 1)));
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 17760