akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.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;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

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

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}

//-------------------------------------------

int main() {
  int N, R;
  cin >> N >> R;
  
  if(N >= 10) cout << R << endl;
  else cout << R+100*(10-N) << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
d = {}
m = 0
s = set()
for _ in range(N):
  str = input()
  if str in s:
    d[str] += 1
  else :
    s.add(str)
    d[str] = 1
  m = max(m,d[str])
l = []
for _ in d.keys():
  if d[_] == m:
    l.append(_)
l.sort()
print(*l,sep="\n")

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

const int INF=1001001001;
vector<int> to[100005];

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    --a,--b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> q;
  vector<int> dist(n,INF);
  vector<int> pre(n,-1);
  dist[0]=0;
  q.push(0);
  while(!q.empty()){
    int v=q.front();q.pop();
    for(int u:to[v]){
      if(dist[u]!=INF)continue;
      dist[u]=dist[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }

  cout<<"Yes"<<endl;
  rep(i,n){
    if(i==0)continue;
    int ans=pre[i];
    ++ans;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 10588
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
int n,k;
cin>>n>>k;
V<ll> a(n),d,sum(n+1,0);
for(int i=0;i<n;i++){
    cin>>a[i];
    sum[i+1]=a[i]+sum[i];
}
for(int i=0;i<n;i++){
    for(int j=i+1;j<=n;j++)d.push_back(sum[j]-sum[i]);
}
ll ans=0;
for(int i=60;i>=0;i--){
  //Aimax=10e9だが累積和の最大値が10e12であるため32では足りないことに気を付ける
    int cnt=0;
      for(int j=0;j<d.size();j++){
            if(d[j]&(1ll<<i))cnt++;
      }
    if(cnt>=k){
          V<ll> tmp;
    for(int j=0;j<d.size();j++){
         if(d[j]&(1ll<<i))tmp.push_back(d[j]);
      }
      d.clear();
      ans+=(1ll<<i);
      d=tmp;
      }
}
cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;


int main()
{
    string s, t; cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++) {
        if(i != n - 1 && s[i] == 'B' && s[i + 1] == 'C') {
            t.push_back('D');i++;
        } else {
            t.push_back(s[i]);
        }
    }
    n = t.size();
    vector<string> str;

    for(int i = 0; i < n; i++) {
        int j = i;
        while((t[j] == 'A' || t[j] == 'D') && j < n) {
            j++;
        } 
        if(i == j)continue;
        str.push_back(t.substr(i, j - i));
        i = j;
    }

    ll cnt = 0;

    for(auto s : str) {
        int cur = 0;
        for(auto j : s) {
            if(j == 'D')cnt += cur;
            else cur++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int a,b,task[3],max,i;
    scanf("%d %d",&a,&b);
    if(a<=100&&a>=-100&&b<=100&&b>=-100)
    {
        task[0]=a+b;
    task[1]=a-b;
    task[2]=a*b;
    max=task[0];
    for(i=0;i<3;i++)
    {
        if(max<task[i])
        {
            max=task[i];
        }
    }
    printf("%d",max);
    }

}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class DLuckyPIN {
public:
  void solve(std::istream &cin, std::ostream &cout) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<char> v = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    int ans = 0;
    for (auto i: v)
      for (auto j: v)
        for (auto k: v) {
          int correct = 0;
          for (int l = 0; l < n; ++l) {
            if (correct == 0 && s[l] == i) {
              correct++;
              continue;
            }
            if (correct == 1 && s[l] == j) {
              correct++;
              continue;
            }
            if (correct == 2 && s[l] == k) {
              ans += 1;
              break;
            }
          }
        }
    cout << ans << endl;
  }

};


int main() {
  DLuckyPIN solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
sa=list(input())
sb=list(input())
sc=list(input())
sa.append("A")
sb.append("B")
sc.append("C")
turn=sa
while True:
    nex=turn.pop(0)
    if len(turn)==0:
        print(nex)
        break
    if nex=="a":
        turn=sa
    elif nex=="b":
        turn=sb
    else:
        turn=sc


Measured memory_bytes: 3060
S=input()
res=[0]*len(S)
cnt_r=0
cnt_l=0
lr="R"
last_id=0
for i,c in enumerate(S):
    if lr=="R":
        if c=="R":
            cnt_r+=1
            continue
        else:
            res[i]+=cnt_r//2
            res[i-1]+=(cnt_r-cnt_r//2)
            last_id=i
            lr = "L"
            cnt_r=0
            cnt_l=1
            continue
    else:
        if c=="L":
            cnt_l+=1
            continue
        else:
            res[last_id-1]+=cnt_l//2
            res[last_id]+=cnt_l-(cnt_l//2)
            lr="R"
            cnt_l=0
            cnt_r=1
res[last_id-1]+=cnt_l//2
res[last_id]+=cnt_l-(cnt_l//2)
print(*res)

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;

ll dsu[SIZE], sz[SIZE];

ll find(int v) {
    if (dsu[v] == v) return v;
    else return dsu[v] = find(dsu[v]);
}

void uni(int v, int u) {
    v = find(v);
    u = find(u);
    if (u != v) {
        sz[v] += sz[u];
        dsu[u] = v;
    }
}

int main()
{
    fastInp;
    
    ll d, t, s;
    cin >> d >> t >> s;

    if (d <= t * s) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main() {
  int i,n,j,k,b,f,r,v;
  int house[4][3][10]={0};
  scanf("%d",&n);
  
  for(i =0; i <n; i++) {
    scanf("%d %d %d %d",&b,&f,&r,&v);
    house[b-1][f-1][r-1] += v;
  }

  for(k=0; k<4; k++) {
    for(j=0; j<3; j++) {
      for(i=0; i<10;i++) {
	printf(" %d",house[k][j][i]);
      }
      printf("\n");
    }
    if(k == 3){
      break;
    }
    printf("####################\n");
  }
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    if (s == "ABC"){
    	cout << "ARC" << endl;
    }else{
    	cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3552
fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map(String::toInt)
    val S = Array(H) { readLine()!!.toCharArray() }

    val result = Array(S.size) { "" }
    for (i in S.indices) {
        for (j in 0 until W) {
            if (S[i][j] == '#') {
                continue
            }
            var sum = 0

            val right = j + 1
            val left = j - 1
            val top = i - 1
            val down = i + 1

            if (0 <= top) {
                if (right < W) {
                    if (S[top][right] == '#') {
                        sum++
                    }
                }
                if (S[top][j] == '#') {
                    sum++
                }
                if (0 <= left) {
                    if (S[top][left] == '#') {
                        sum++
                    }
                }
            }
            if (down < H) {
                if (right < W) {
                    if (S[down][right] == '#') {
                        sum++
                    }
                }
                if (S[down][j] == '#') {
                    sum++
                }
                if (0 <= left) {
                    if (S[down][left] == '#') {
                        sum++
                    }
                }
            }
            if (right < W) {
                if (S[i][right] == '#') {
                    sum++
                }
            }
            if (0 <= left) {
                if (S[i][left] == '#') {
                    sum++
                }
            }
            S[i][j] = sum.toString()[0]
        }
    }

    for (i in S.indices) {
        for (j in 0 until W) {
            print(S[i][j].toString())
        }
        println()
    }
}



Measured memory_bytes: 37956
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		int price = 700;
		String line = readLine();
		String[] strArray = line.split("");
		for (int i = 0; i < strArray.length; i++){
			if(strArray[i].equals("o")){
				price += 100;
			}
		}
		System.out.println(price);
	}

	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		return br.readLine();
	}
}

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

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll ab = a + b;
  cout << n / ab * a + min(a, n % ab) << endl;;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include <string.h>
#include <algorithm>

using namespace std;

int main(){
  int N;cin>>N;
  int W;cin>>W;
  int v_l[N], w_l[N];
  for (int i  = 0; i < N; i++) cin >> v_l[i] >> w_l[i];
  int dp[N+1][W+1];
  memset(dp,0,sizeof(dp));
  for (int n=0;n < N; n++) {
    for (int w=0; w <= W; w++) {
      //cout<<w_l[n]<<w<<endl;
      if(w<w_l[n]){
       dp[n+1][w]=dp[n][w];
      }
      else{
        dp[n+1][w]=max(dp[n][w],dp[n+1][w-w_l[n]]+v_l[n]);
      }
    }
  }
  cout<< dp[N][W]  << "\n";
}


Measured memory_bytes: 7040
function Main(input) {
    input = input.split("\n");
    for (i=0; i < input.length-1; i++) {
        var S = parseInt(input[i], 10)
        var h = Math.floor(S / 60 /60)
        var m = Math.floor(S / 60 % 60)
        var s = Math.floor(S % 60)
        var hh = String(h)
        var mm = String(m)
        var ss = String(s)
        var c = ":"
        console.log('%s', hh + ":" + mm + ":" + ss);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15100
#include<bits/stdc++.h>
using namespace std;
int main(){int n;cin>>n;
  if(n<10) cout<<n;
  if(n<=99&&n>=10) cout<<"9";
  if(n>=100&&n<=999) cout<<n-90;
   if(n>=1000&&n<=9999) cout<<"909";
    if(n>=10000&&n<=99999)   cout<<n-9090;
     if(n==100000) cout<<"90909";
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]){

  int X, Y, Z;
  cin >> X >> Y >> Z;

  int res = (X-Z)/(Y+Z);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
#input = sys.stdin.readline
#sys.setrecursionlimit(10**6)

def main():
    x,y,a,b,c = map(int, input().split())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    r = list(map(int, input().split()))
    p.sort(reverse = True)
    q.sort(reverse=True)
    r.sort(reverse=True)

    p = p[:x]
    q = q[:y]

    all = []
    all.extend(p)
    all.extend(q)
    all.extend(r)
    all.sort(reverse=True)
    all = all[:x+y]



    print(sum(all))


if __name__ == '__main__':
    main()


Measured memory_bytes: 23328
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/


void proc() {
	LOAD(int, N);
	LOADVEC(int, p, N);
	std::vector<int>a(N);
	std::vector<int>b(N);
	std::vector<int>c(N);
	for (int i = 0; i < N; ++i) {
		c[p[i] - 1] = i;
	}
	a[0] = 1;
	b[0] = 2 * N*N;
	for (int i = 1; i < N; ++i) {
		int sign = c[i] - c[i - 1];
		if (0 < sign) {
			a[i] = 1 + sign + a[i - 1];
			b[i] = -1 + b[i - 1];
		}
		else {
			a[i] = 1 + a[i - 1];
			b[i] = -1 + sign + b[i - 1];
		}
	}
	for (int i = 0; i < N; ++i) {
		cout << a[i];
		if (i == N - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	for (int i = 0; i < N; ++i) {
		cout << b[i];
		if (i == N - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
}

#endif


Measured memory_bytes: 1280
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>
int A[20]={};
int B[20]={};
int C[20]={};
int main()
{
    int n;
    scanf("%d",&n);
    int i;
    int sum = 0;
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&B[i]);
    }
    for(i=0;i<n;i++){
        if(A[i]>B[i])
            sum +=(A[i]-B[i]);
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
// atcoder/abc157/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;

template<typename T>
struct SegTree {
  int n;
  vector<T> dat;
  using F = function<T(T, T)>;
  F fn;
  T e;
  SegTree(int n_, T e_, F fn_) {
    e = e_;
    fn = fn_;
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, e);
  }

  void update(size_t k, T a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = fn(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
    return ;
  }

  T operator [] (size_t idx) const {
    return dat[idx + n - 1];
  }

  T query(size_t a, size_t b) {
    return query(a, b, 0, 0, n);
  }

  T query(size_t a, size_t b, size_t k, size_t l, size_t r) {
    if (r <= a || b <= l) return e;
    if (a <= l && r <= b) return dat.at(k);

    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

    return fn(vl,vr);
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, q;
  str s;
  while (cin >> n >> s >> q) {
    const int N = 500000 + 5;
    SegTree<int> freq(N, 0, [] (int a, int b) { return a | b; });

    for (int i = 0; i < s.size(); ++i) {
      freq.update(i, 1 << (s[i] - 'a'));
    }

    while (q--) {
      int t;
      cin >> t;
      if (t == 1) {
        int i;
        char c;
        cin >> i >> c;
        --i;
        freq.update(i, 1 << (c - 'a'));
      }
      if (t == 2) {
        int begin, end;
        cin >> begin >> end;
        --begin;
        cout << __builtin_popcount(freq.query(begin, end)) << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int ok=0,x=0;
  map<Int, Int> m;
  for(Int i=0;i<n;i++){
    if(m[a[i]]++==0) ok++;
    if(m[a[i]]==0) ok--;
    if(m[a[n-(i+1)]]--==0) ok++;
    if(m[a[n-(i+1)]]==0) ok--;
    
    if(!ok){
      if(x) cout<<" ";
      x=1;
      cout<<i+1;
    }
  }
  cout<<endl;
  return 0;
}



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

namespace new_0501
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputData = GetInputData();

			var conversionData = ConvertData(inputData);

			OutputData(conversionData);

		}

		private static List<string> GetInputData()
		{
			var DataSet = "";
			var DataSets = new List<string>();
			var LoopCount = 0;
			var LoopTimes = 0;
			while (true)
			{
				LoopCount = 0;
				DataSet = Console.ReadLine();
				LoopTimes = int.Parse(DataSet);
				DataSets.Add(DataSet);

				while (LoopCount != LoopTimes)
				{
					DataSet = Console.ReadLine();
					DataSets.Add(DataSet);
					LoopCount++;
				}

				if (DataSet == "0")
				{
					break;
				}
			}
			return DataSets;
		}

		private static StringBuilder ConvertData(List<string> inputData)
		{
			var index = 0;
			StringBuilder convertedData = new StringBuilder("");
			var convertDictionary = new Dictionary<string, string>();

			while (true)
			{
				//createDictionary
				if (inputData[index] == "0")
				{
					break;
				}

				for (int dicIndex = 1; dicIndex <= int.Parse(inputData[index]); dicIndex++)
				{
					convertDictionary.Add(inputData[dicIndex + index].Split()[0], inputData[dicIndex + index].Split()[1]);
				}

				index = index + int.Parse(inputData[index]) + 1;

				for (int convertIndex = 1; convertIndex <= int.Parse(inputData[index]); convertIndex++)
				{
					if (convertDictionary.ContainsKey(inputData[convertIndex + index]))
					{
						inputData[convertIndex + index] = convertDictionary[inputData[convertIndex + index]];
					}

					convertedData.Append(inputData[convertIndex + index]);
				}

				index = index + int.Parse(inputData[index]) + 1;
				convertDictionary.Clear();
				convertedData.Append("\n");
			}

			return convertedData;
		}

		private static void OutputData(StringBuilder conversionData)
		{
			
			Console.Write(conversionData);
			
		}
	}
}



Measured memory_bytes: 22044
#include<cstdio>
char str[10005];
bool used[1005];
int main(){
  scanf("%s",str+1);
  for(int i=1;str[i];++i){
    used[str[i]]=true;
  }
  if(used['W']^used['E']){
    printf("No\n");
  }else if(used['N']^used['S']){
    printf("No\n");
  }else printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct UnionFind {
    vector<int> par;
    int cnt;
    UnionFind(int size_) : par(size_, -1), cnt(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (par[y] < par[x]) swap(x, y);
            par[x] += par[y]; par[y] = x; cnt--;
        }
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
    int size(int x) { return -par[find(x)]; }
    int size() { return cnt; }
};

struct Edge {
    int src, dst, weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

int n, m;
Graph g;

bool check(int l, int r) {
    UnionFind uf(g.size());
    for (auto &es : g) {
        for (auto &e : es) {
            if (l <= e.weight && e.weight <= r) {
                uf.unite(e.src, e.dst);
            }
        }
    }
    return uf.size() == 1;
}

int solve() {
    int ans = 1e9;
    vector<int> ws;
    for (auto &es : g) for (auto &e : es) ws.emplace_back(e.weight);
    sort(ws.begin(), ws.end());
    ws.erase(unique(ws.begin(), ws.end()), ws.end());
    for (int i : ws) {
        int lb = i - 1;
        int ub = ws.back() + 1;
        while (lb + 1 < ub) {
            int mid = (ub + lb) / 2;
            if (check(i, mid)) {
                ub = mid;
            } else {
                lb = mid;
            }
        }
        if (ub != ws.back() + 1) {
            ans = min(ans, ub - i);
        }
    }
    return ans == 1e9 ? -1 : ans;
}

signed main() {
    while (cin >> n >> m && n) {
        g.assign(n, {});
        for (int i = 0; i < m; i++) {
            int a, b, w;
            cin >> a >> b >> w;
            --a, --b;
            g[a].emplace_back(a, b, w);
            g[b].emplace_back(b, a, w);
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;



void _main() {
    vector<int> A(3);
    cin >> A;
    SORT(A);
    cout << A[2] - A[0] << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

const int L = 2e5 + 5;
long long dp[L][5];

long long mdp(int i, int j) {
	if(i == 0) return 0;
	long long dr = dp[i][0];
	for(int ii = 1; ii <= j; ++ii)
		dr = min(dr, dp[i][ii]);
	return dr;
}

int l, a[L];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> l;
	for(int i = 1; i <= l; ++i) {
		cin >> a[i];
	}
	for(int i = 1; i <= l; ++i) {
		dp[i][0] = mdp(i - 1, 0) + a[i];
		dp[i][1] = mdp(i - 1, 1) + (a[i] == 0 ? 2 : (a[i] & 1));
		dp[i][2] = mdp(i - 1, 2) + (a[i] & 1 ^ 1);
		dp[i][3] = mdp(i - 1, 3) + (a[i] == 0 ? 2 : (a[i] & 1));
		dp[i][4] = mdp(i - 1, 4) + a[i];
	}
	cout << mdp(l, 4) << endl;
	return 0;
}


Measured memory_bytes: 8960
#include<stdio.h>
int main(){
  char s[101];
  scanf("%s",s);
  long long k,i;
  scanf("%lld",&k);
  for(i=0;i<k-1;i++){
    if(s[i]!='1'){
      printf("%c\n",s[i]);
      return 0;
    }
  }
  printf("%c\n",s[k-1]);
  return 0;
}


Measured memory_bytes: 128
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int c = 0, d = 0;
  rep(i, n){
    bool f = true;
    if (s[i] == 'a' && c + d < a + b) c++;
    else if (s[i] == 'b' && c + d < a + b && d < b) d++;
    else f = false;
    cout << (f ? "Yes\n" : "No\n");
  }
}


Measured memory_bytes: 848
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int pow100(int n) { return (n ? (n - 1 ? ((n - 2) ? 1000000 : 10000) : 100) : 1); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int D, N;
	cin >> D >> N;

	int M = 0;
	for (int i = D; i < 3; i++) {
		M += pow100(D) * N / pow100(i + 1);
	}

	cout << pow100(D) * (N + M) << "\n";

	return 0;
}

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

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  double d;
  cin >> d;
  cout << 2 * d * 3.1415 <<endl;
} 


Measured memory_bytes: 3772
from collections import deque

h, w = map(int, input().split())
ch, cw = map(lambda x: int(x) - 1, input().split())
dh, dw = map(lambda x: int(x) - 1, input().split())
maze = [list(input()) for _ in range(h)]

inf = 10 ** 10
cost = [[inf] * w for _ in range(h)]

walk = [[0, 1], [0, -1], [1, 0], [-1, 0]]
warp = [[i, j] for i in range(-2, 3) for j in range(-2, 3) if [i, j] not in [[0, 0]] + walk]

q = deque()
cost[ch][cw] = 0
q.append([ch, cw, 0])

while q:
    x, y, c = q.popleft()
    for dx, dy in walk:
        nx = x + dx
        ny = y + dy

        if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] == '.' and cost[nx][ny] > c:
            cost[nx][ny] = c
            q.appendleft([nx, ny, c])

    for dx, dy in warp:
        nx = x + dx
        ny = y + dy

        if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] == '.' and cost[nx][ny] > c + 1:
            cost[nx][ny] = c + 1
            q.append([nx, ny, c + 1])

ans = cost[dh][dw] if cost[dh][dw] != inf else -1
print(ans)


Measured memory_bytes: 162068
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1)
#define N 100005
#define mod 1000000007 
#define bitscount 32

using namespace std;

struct stuc{
int x;
int y;
};

bool cmp(stuc a, stuc b)
{
return a.x < b.x;
}

int  main()
{

int n;

cin >> n;

stuc s[n+5];

for(int v,i=0;i<n;i++)
{
cin >> v;
s[i].x = v;
s[i].y = i+1;
}

sort(s,s+n,cmp);

for(int i=0;i<n;i++) cout << s[i].y << ' ';

return 0;
}

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

int main() {
    int a, b, c, ans = 0;
    cin >> a >> b >> c;
    a -= b;
    ans = max(0, c - a);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    long K = sc.nextLong();
    int[] a = new int[N];
    int[] b = new int[N];

    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }

    sc.close();

    long[] count = new long[100001];

    for (int i = 0; i < N; i++) {
      count[a[i]] += b[i];
    }

    for (int i = 1; i <= 100000; i++) {
      if (K <= count[i]) {
        System.out.println(i);
        break;
      }
      K -= count[i];
    }
    
  }

}

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

const long long INF = 1LL << 60;
const int N_MAX = 100;
const int V_MAX = 1e3;
vector <long long int> dp((N_MAX * V_MAX) + 1, INF);

int main(){
  int N, W; cin >> N >> W;
  vector<int> v(N), w(N);
  dp[0] = 0;
  
  int v_sum = 0;
  for(int i = 0; i < N; i++){
    int v, w;
    cin >> w >> v;
    v_sum += v;
    for(int j = v_sum; j >= v; j--){
      dp[j] = min(dp[j], dp[j - v] + w);
    }
  }
  int ans;
  for(int i = v_sum; i >= 0; i--){
    if(dp[i] <= W) {ans = i; break;}
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

class FIO
{
public:
    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }
    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }
private:
    char f,c,a[25],i;
    template<typename T>inline void _R(T& x)
    {
        for(f=0;(c=getchar())<48;c==45&&(f=1));
        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));
        if(f)x=-x;
    }
    template<typename T>inline void _W(T x)
    {
        if(sizeof(x)==1){ putchar(x);return; }
        if(x<0)putchar(45),x=-x;
        if(x>99) {
            for(i=0;x;x/=10)a[i++]=x%10;
            while(i--)putchar(a[i]+48);
        } else if(x>9) putchar(x/10+48),putchar(x%10+48);
        else putchar(x+48);
    }
}io;

int main()
{
    int n,a,b;
    io>>n>>a>>b;
    if(n*a<b)io<<n*a;
    else io<<b;
    return 0;
}

Measured memory_bytes: 3008
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        if(a < b && b < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
 
}



Measured memory_bytes: 26100
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+10;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


vector<vector<char>> data(2010, vector<char>(2010,'#'));
vector<vector<P>> used(2010, vector<P>(2010));
int h,w,ans=0;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  int h,w; 
  cin >> h >> w;
  for(int i=1; i<=h; i++){ 
    int cnt=0;
    for(int j=1; j<=w; j++){    
      cin >> data[i][j]; 
      if(data[i][j]=='.' ){cnt++;} 
      if(data[i][j]=='#'){ 
        for(int k=j-cnt; k<=j; k++){ used[i][k].F=cnt; }
        used[i][j].F=0;
        cnt=0;
        continue;
      }
      if(j==w){ 
        for(int k=j-cnt+1; k<=j; k++){ used[i][k].F=cnt; }
        cnt=0;
      }   
    } 
  }

  for(int j=1; j<=w; j++){ 
    int cnt=0;
    for(int i=1; i<=h; i++){ 
      if(data[i][j]=='.' ){cnt++;} 
      if(data[i][j]=='#'){ 
        for(int k=i-cnt; k<=i; k++){ used[k][j].S=cnt; }
        used[i][j].S=0;
        cnt=0;
        continue;
      }
      if(i==h){ 
        for(int k=i-cnt+1; k<=i; k++){ used[k][j].S=cnt; }
        cnt=0;
      }   
    } 
  }
  

  for(int i=1; i<=h; i++){ 
    for(int j=1; j<=w; j++){
      ans = max(ans,used[i][j].F+used[i][j].S-1);
    }
    if(ans==h+w-1){break;}
  }
  
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 35968
N,M=map(int,input().split())
A_B=[list(map(int,input().split())) for _ in range(N)]
A_B.sort(key=lambda x:x[0])
ans=0
sum=0
for a_b in A_B:
    M-=a_b[1]
    if M<=0:
        ans+=(a_b[0]*a_b[1]+M*a_b[0])
        break
    else:
        ans+=a_b[0]*a_b[1]
print(ans)


Measured memory_bytes: 29024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sumvec(vector<S>&a){return accumulate(all(a),S());}
template<class S>S maxvec(vector<S>&a){return *max_element(all(a));}
template<class S>S minvec(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}


int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
  	
  	string s;
  	cin>>s;
  	
  	rep(i,(int)s.length()){
  	    cout<<'x';
  	}
  	
    cout<<endl;

}


Measured memory_bytes: 256
MOD = 998244353
N,S= map(int,input().split())
A = list(map(int,input().split()))

def dpinit(ps, val=0):
    res = [val for i in [0]*ps[-1]]
    for i in ps[:-1][::-1]:
        res = [res[:] for k in [0]*i]
    return res

dp = dpinit((N+1,S+1))

dp[0][0] = 1
for i in range(N):
    a = A[i]
    for j in range(S+1):
        dp[i+1][j] += dp[i][j]*2
        dp[i+1][j] %= MOD
        if j+a <= S:
            dp[i+1][j+a] += dp[i][j]
            dp[i+1][j+a] %= MOD
        
print(dp[N][S]%MOD)



Measured memory_bytes: 139460
#include<cstdio>
#include<iostream>
using namespace std;
int gcd(int x,int y){
    if(!y)return x;
    gcd(y,x%y);
}
int main(){
    int x,y;
    scanf("%d %d",&x,&y);
    if(y>x)swap(x,y);
    printf("%d\n",gcd(x,y));
    return 0;
}


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

int main() {
  int n, x;
  cin>>n>>x;
  int m[n];
  for (int i=0; i<n; i++) cin>>m[i];
  sort(m, m + n);
  for (int i=0; i<n; i++) x-= m[i];
  cout<<n + x / m[0]<<endl;
}

Measured memory_bytes: 256
# include <stdio.h>
int main(){
long n,c,g=0,k=0;
int z;
scanf("%ld",&n);
long a[n];
for(c=0;c<n;c++){
scanf("%ld ",&a[c]);
if(a[c]%2==1)k++;
}
if(k%2==1)printf("NO");
else if(k%2==0)printf("YES");
return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define TEST cout << "ococo" << endl;
using namespace std;

int main(void){
	int n;
	cin >> n;
	if(n % 2 == 0)cout << (n / 2) - 1 << endl;
	else cout <<(n - 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]

count=0
be=0
if a[0]==0:
    for i in a[1:]:
        #print(i,count)
        if i<=be+1:
            if i>be: count+=1
            else: count +=i
            be=i
        else:
            print('-1')
            break
    else:print(count)
else: print('-1')

Measured memory_bytes: 12584
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

#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 (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define vll vector<long long>

using namespace std;

typedef long long ll;

#define MAX 100000
ll N, C, K;
ll T[MAX];

ll bin(ll min, ll max, ll tim)
{
    while (true) {
        if (min == max) {
            return max - 1;
        }
        ll mid = (min + max) / 2;
        if (T[mid] <= tim) {
            if (min == mid) {
                return min;
            }
            min = mid;
        } else {
            max = mid;
        }
    }
}

int main()
{
    cin >> N >> C >> K;
    rep(i, N)
    {
        cin >> T[i];
    }
    std::sort(T, T + N);
    ll start = T[0];
    ll next = 0;
    ll c = 0;
    while (true) {
        if (next == N) {
            break;
        }
        int tmp = (next + C - 1 < N) ? (next + C - 1) : N - 1;
        if (T[tmp] <= start + K) {
            if (tmp != N - 1) {
                start = T[next + C];
                next += C;
            } else {
                next = N;
            }
            c++;
        } else {
            next = bin(next, N, start + K) + 1;
            start = T[next];
            c++;
        }
    }
    cout << c << endl;

    return 0;
}


Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;


long P = 10^^9+7;
long[10^^6*2+10] F, RF;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

long inv(long x)
{
    return pow(x, P-2);
}

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

void main()
{
    init();
    auto rc = readln.split.to!(long[]);
    auto r1 = rc[0];
    auto c1 = rc[1];
    auto r2 = rc[2];
    auto c2 = rc[3];

    long g(long r, long c) {
        long x;
        foreach (i; 1..r+2) {
            x = (x + F[i+c] * RF[i] % P * RF[c] % P) % P;
        }
        return x;
    }
    writeln( (((g(r2, c2) - g(r1-1, c2) + P) % P - g(r2, c1-1) + P) % P + g(r1-1, c1-1)) % P );
}

Measured memory_bytes: 31488
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
ll solve (ll);
 
int main() {
    ll h;
    cin >> h;
    cout << (ll)solve(h) << endl;;
}

ll solve (ll h) {
    if (h == 1) {
        return 1;
    } else {
        return solve(h/2) * 2 +1;
    }
}

Measured memory_bytes: 3176
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let xy: Vec<(i32, i32)> = (0..n).map(|_| (read(), read())).collect();

    let mut ans = 0;
    for i in 0..n {
        for j in 0..n {
            if i == j {
                continue;
            }
            let dx = xy[i].0 - xy[j].0;
            let dy = xy[i].1 - xy[j].1;

            let mut count = 0;
            for k in 0..n {
                for l in 0..n {
                    if xy[k].0 - xy[l].0 == dx && xy[k].1 - xy[l].1 == dy && i != j {
                        count += 1;
                    }
                }
            }
            ans = std::cmp::max(ans, count);
        }
    }

    println!("{}", n - ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>


int main() 
{
	int a,b,c,d;
	int i,j,k;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	while(1)
	{
		c = c-b;
		if(c<=0)
		{
			printf("Yes");
			break;
		}
		a=a-d;
		if(a<=0)
		{
			printf("No");
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1732
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=4e5+5;
typedef long long ll;
int n,k;
char s[N];
int num[N];
int st;
int main()
{
    scanf("%d%d",&n,&k);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
        num[i]=s[i]-'A';
    st=num[1];
    int p=1;
    int cnt=0;
    while(k--){
        if(st==0){
            st^=1;
            num[p]^=1;
        }
        else{
            p++;
            cnt++;
            st=num[p];
            st^=(cnt&1);
        }
        if(p>n)
            break;
    }
    if(p<=n){
        for(int i=p;i<=n;i++)
            putchar('A'+(num[i]^(cnt&1)));
        int t=p-1,c=(cnt-1)&1;
        while(t--){
            putchar('A'+c);
            c^=1;
        }
    }
    else{
        if((cnt-1)&1)
            for(int i=1;i<=n;i++)
                putchar('A'+(i&1));
        else{
            putchar('A'+(k&1));
            for(int i=1;i<n;i++)
                putchar('A'+(i&1));
        }
    }
}


Measured memory_bytes: 1280