akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

typedef long long ll;
const ll mod = 1e9+7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

ll ncm(ll n, ll a){
    ll ret = 1;
    for(int i = 0; i < a; i++){
        (ret *= n-i) %= mod;
        (ret *= modpow(i+1, mod-2, mod)) %= mod;
    }
    return ret;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = modpow(2, n, mod);
    ans += (mod-ncm(n, a));
    ans %= mod;
    ans += (mod-ncm(n, b));
    ans %= mod;
    cout << (ans-1+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
 
chash = {}
for i in range( ord( 'a' ), ord( 'z' )+1 ):
    chash[ chr( i ) ] = 0

lines = sys.stdin.readlines()
for i in range( len( lines ) ):
	for j in range( len( lines[i] ) ):
	    if lines[i][j].isalpha():
	        chash[ lines[i][j].lower() ] += 1
 
for i in range( ord( 'a' ), ord( 'z' )+1 ):
    print( "{:s} : {:d}".format( chr( i ), chash[ chr( i ) ] ) )	

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

int A;
int B;
int C;
int X;

int main() {
  cin >> A >> B >> C >> X;
  int count = 0;

  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        int sum = 500 * i + 100 * j + 50 * k;
        if (sum == X)
          count++;
      }
    }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  int h,w;
  scanf("%d %d", &h, &w);
  char s[h][w+1];
  for (int i = 0; i < h; i++) {
    scanf("%s", s[i]);
  }
  int dp[h][w];
  dp[0][0] = 0;
  if (s[0][0] == '#') {
    dp[0][0] = 1;
  }
  for (int i = 1; i < w; i++) {
    dp[0][i] = dp[0][i-1];
    if (s[0][i-1] == '.' && s[0][i] == '#') {
      dp[0][i]++;
    }
  }
  int case1,case2;
  for (int i = 1; i < h; i++) {
    dp[i][0] = dp[i-1][0];
    if (s[i-1][0] == '.' && s[i][0] == '#') {
      dp[i][0]++;
    }
    for (int j = 1; j < w; j++) {
      case1 = dp[i-1][j];
      if (s[i-1][j] == '.' && s[i][j] == '#') {
        case1++;
      }
      case2 = dp[i][j-1];
      if (s[i][j-1] == '.' && s[i][j] == '#') {
        case2++;
      }
      dp[i][j] = case1;
      if (case2 < case1) {
        dp[i][j] = case2;
      }
    }
  }
  printf("%d\n", dp[h-1][w-1]);

  return 0;
}

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

typedef long long ll;
const ll MAX = 1000000000000000000;

int main () {
	int N;
	ll res = 1;
	cin >> N;
	bool of = false;
	for (int i=0; i<N; i++) {
		ll tmp;
		cin >> tmp;
		if (tmp == 0) {
			cout << 0 << endl;
			return 0;
		}
		ll pv = res;
		res *= tmp;
		if (res > MAX || res<pv) {
			of = true;
		}
	}
	if (of)
		cout << -1 << endl;
	else 
		cout << res << endl;
	return 0;
}

Measured memory_bytes: 3632
r=(a=(b=[-1,0,1])+[-2,2]*3+b).zip(a.sort)
while(s=gets.split.map &:to_i)[0]>0
gets
q=[s]
gets.split.map(&:to_i).each_slice(2){|i,j|q=q.flat_map{|x,y|r.map{|t,u|t+=x;u+=y
t|u>=0&&t<=9&&u<=9&&t>i-2&&t<i+2&&u>j-2&&u<j+2?[t,u]:0}}.uniq-[0]}
puts q[0]?:OK:"NA"end

Measured memory_bytes: 6116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
#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 _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vin w(n),d(n-1);
    rep(i,n)cin>>w[i];
    rep(i,n-1){
        int sum1=0;
        int sum2=0;
        rep(j,i+1)sum1+=w[j];
        rep2(k,i+1,n)sum2+=w[k];
        d[i]=abs(sum1-sum2);
    }
    sort(d.begin(),d.end());
    cout<<d[0]<<endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
if H == 1 or W == 1:
  print(1)
elif H % 2 == 0 or W % 2 == 0:
  print(W * H // 2)
else:
  total = H * (W//2) + H//2 + 1
  print(total)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define mn 3005
#define inf 4444444444444444444
#define mod (ll) 1000000007
#define base 31
#define fu(i, a, b) for (int i=a; i<=b; i++)
#define fd(i, a, b) for (int i=a; i>=b; i--)
#define fi first
#define se second
#define pii pair <int, int>
#define pb push_back
#define mp make_pair

//int t, ntest;
int n, m, t;
int a[mn][mn], dp[mn][mn][4];

void input(){
	cin>>n>>m>>t;
	fu(i, 1, t){
		int x, y, c;
		cin>>x>>y>>c;
		a[x][y]=c;
	}
}

void solve(){
	fu(i, 1, n){
		fu(j, 1, m){
			int tmp=0;
			fu(k, 0, 3) tmp=max(tmp, dp[i-1][j][k]);
			if (a[i][j]>0){
				dp[i][j][0]=tmp;
				dp[i][j][1]=max(max(tmp, dp[i][j-1][0])+a[i][j], dp[i][j-1][1]);
				fu(k, 2, 3) dp[i][j][k]=max(dp[i][j-1][k-1]+a[i][j], dp[i][j-1][k]);
			}
			else {
				dp[i][j][0]=tmp;
				fu(k, 0, 3) dp[i][j][k]=max(dp[i][j][k], dp[i][j-1][k]);
			}
		}
	}
	int ans=0;
	fu(j, 0, 3) {
//		cout<<n<<" "<<m<<" "<<j<<" "<<dp[n][m][j]<<endl;
		ans=max(ans, dp[n][m][j]); 
	}
	cout<<ans;
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//	freopen("test.inp", "r", stdin);
//	freopen("test.out", "w", stdout);
//	cin>>t;
//	for (ntest=1; ntest<=t; ntest++){
		input();
		solve();
//	}
}

//By: 646487264





Measured memory_bytes: 355752
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 0) {
		if (b == 100) 
		   b++;
		cout << b;
	}else if (a == 1) {
		int x = b * 100;
		if (b == 100) // 10100
			x += 100;
		cout << x;
	}else {
		int x = b * 10000;
		if (b == 100) 
		    x += 10000;
		cout << x;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll n,k;
	cin>>k>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	ll ans=0;
	for(ll i=1;i<n;i++){
		ll c=a[i]-a[i-1];
		ans=max(ans,c);
	}
	ans=max(ans,k-a[n-1]+a[0]);
	cout<<k-ans<<endl;
}


Measured memory_bytes: 1792
import scala.io.StdIn

object Main extends App {
  def f(x:Int,t:Int):Int = {
    if(x == 0) t
    else f(x/10, t + (x % 10))
  }

  val n = StdIn.readLine.toInt

  val ans = if(n % f(n,0) == 0) "Yes" else "No"
  println(ans)
}

Measured memory_bytes: 25416
a,b,k=io.read("*n","*n","*n")

for i=1, k do
    if a+i-1<=b then
        print(a+i-1)
    end
end

for i=k, 1, -1 do
    if b-i>=a+k-1 then
        print(b-i+1)
    end
end

Measured memory_bytes: 760
#!/usr/bin/env python3
import sys


def solve(n: int, p: "List[int]"):

    count = 0
    for i in range(n - 2):
        partial = p[i : i + 2 + 1]
        if partial[0] < partial[1] and partial[1] < partial[2]:
            count += 1
        elif partial[0] > partial[1] and partial[1] > partial[2]:
            count += 1
        else:
            pass

    print(count)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, p)


if __name__ == "__main__":
    main()


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

int main() {
    int n;
    cin >> n;
    if (n > 9 * 9) {
        cout << "No" << endl;
        return 0;
    } else {
        for (int i = 1; i <= 9; i++) {
            if (n % i == 0 && n / i < 10) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll fac[2000010], finv[2000010], inv[2000010];

void init(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(ll i=2;i<2000010;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll C(ll n, ll k){
  return fac[n] %mod * finv[k] %mod * finv[n-k] %mod;
}

int main(){FIN
    
    ll n;cin>>n;
    vll l(n); REP(i,n) cin>>l[i];
    ll ans=0;
    REP(i,n-2){
        FOR(j, i+1, n-2){
            FOR(k, j+1, n-1){
                if (l[i] ==l[j] || l[j]==l[k] || l[k]==l[i]) continue;
                if(l[i]+l[j] <= l[k]) continue;
                if(l[i]+l[k] <= l[j]) continue;
                if(l[k]+l[j] <= l[i]) continue;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3648
import collections

def per4_2(x):
	if x % 4 == 0:
		return 4
	elif x % 2 == 0 and x % 4 != 0:
		return 2
	else:
		return 1


N = int(input())
a = list(map(int, input().split( )))

a = list(map(per4_2,a))


a_c=collections.Counter(a)

ans = 'No'

if a_c[2] == 0:
	if a_c[4]>=a_c[1]-1:
		ans = 'Yes'
else:
	if a_c[4] >=a_c[1]:
		ans = 'Yes'
print(ans)
	


Measured memory_bytes: 14628
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	// 入力
	int N;
	cin >> N;
	
	map<int, int> mp;

	ll ans = 0;
	REP(i, N) {
		int a;
		cin >> a;

		if (mp.find(a) == mp.end()) {
			mp[a] = 1;
		} else {
			mp.erase(a);
		}
	}

	cout << mp.size() << endl;
	return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    vector<bool>b(8,0);
    int oc=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i]<400){
            b[0]=1;
        }else if(a[i]<800){
            b[1]=1;
        }else if(a[i]<1200){
            b[2]=1;
        }else if(a[i]<1600){
            b[3]=1;
        }else if(a[i]<2000){
            b[4]=1;
        }else if(a[i]<2400){
            b[5]=1;
        }else if(a[i]<2800){
            b[6]=1;
        }else if(a[i]<3200){
            b[7]=1;
        }else{
            oc++;
        }
    }
    int cnt=0;
    for(int i=0; i<8; i++){
        if(b[i]) cnt++;
    }
    if(cnt==0) cout << 1 << " ";
    else cout << cnt << " ";
    cout << cnt + oc << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;
	cin>>n;
	if(n==1){
		cout<<"Hello World";
	}else{
		int a,b;
		cin>>a>>b;
		cout<<a+b;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * POW(n, m - 1)) % MOD;
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  vl D(26, 0);
  if (S == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
  } else if (S.size() < 26) {
    REP(i, S.size()) D[S[i] - (int)'a'] = 1;
    REP(i, 26) {
      if (D[i] == 0) {
        cout << S << (char)(i + 'a') << endl;
        break;
      }
    }
  } else {
    ll cut = -1;
    ll replace = -1;
    RREP(i, 26) {
      REP(j, 26) {
        if (D[j] == 1 && j > (S[i] - (int)'a')) {
          replace = j;
          break;
        }
      }
      if (replace != -1) {
        cut = i;
        break;
      }
      D[S[i] - (int)'a'] = 1;
    }

    REP(i, cut) cout << S[i];
    cout << (char)(replace + 'a') << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n;
 	cin >> n;
 	for (int i = 0; i < n; i++){
 		int x;
 		cin >> x;
 		if(x%2){
 			cout << "first" << endl;
 			return 0;
 		}
 	}
 	cout << "second" << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/***template***/
#define ll                   long long
#define ___                  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dd                   double
#define scl(n)               scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define pi                   pair<ll,ll>
#define pb                   push_back
#define mp                   make_pair
#define uu                   first
#define vv                   second
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define FOOR(i,a,b)          for(ll i=a;i<=b;i++)
#define LOP(i,a,b)           for(ll i=a;i<b;i++)
#define sorted(s)            sort(s.begin(),s.end())
#define sortedd(s)           sort(s.begin(),s.end(),cmp)
#define reversed(s)          reverse(s.begin(),s.end())
#define contains(a,b)        (find((a).begin(), (a).end(), (b)) != (a).end())
#define MAXN                 100005
#define pii                  3.1415926536
#define mod                  1000000007
#define eps                  0.0000000001
#define inf                  1e18
#define INF                  (1LL<<62)
#define mstt(a,b)            memset((a),(b),sizeof (a))
#define sz(x)                (ll)x.size()
#define uniquee(x)            x.erase(unique(x.begin(), x.end()),x.end())
#define print_vector(v)       for(ll i=0;i<(v.size());i++)cout<<v[i]<<" ";
/****only for priority queue******/
/**struct node
{
    ll nod,d;
    node(ll a,ll b)
    {
        nod=a;
        d=b;
    }
    bool operator<(const node &p)const
    {
        return p.d<d;
    }
};**/

ll Set(ll n,ll pos)
{
    return n=n|(1LL<<pos);
}
ll reset(ll n,ll pos)
{
    return n=n&~(1LL<<pos);
}
bool check(ll n,ll pos)
{
    return (bool)(n&(1LL<<pos));
}
ll mul(ll a,ll b)
{
    ll c;
    c = (a%mod * b%mod)%mod;
    return c;
}
ll add(ll a,ll b)
{
    ll c;
    c = (a%mod + b%mod)%mod;
    return c;
}
ll sub(ll a,ll b)
{
    ll c;
    c = ((a%mod - b%mod)%mod + mod)%mod;
    return c;
}
ll power(ll x,ll y)
{
    ll res = 1;
    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}
long long exgcd(long long x, long long y, long long &a, long long &b)
{
    // ax + by = gcd(x,y)
    int flag = 0;
    long long t, la = 1, lb = 0, ra = 0, rb = 1;
    while(x%y)
    {
        if(flag == 0)
            la -= x/y*ra, lb -= x/y*rb;
        else
            ra -= x/y*la, rb -= x/y*lb;
        t = x, x = y, y = t%y;
        flag = 1 - flag;
    }
    if(flag == 0)
        a = ra, b = rb;
    else
        a = la, b = lb;
    return y;
}
/***template***/
ll a,b;
int main()
{
    scl(a);
    scl(b);
    
    if(!(a%3) || !(b%3) || !((a+b)%3))
    {
        printf("Possible\n");
    }
    else
    {
        printf("Impossible\n");
    }
    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong(),b=sc.nextLong(),c=sc.nextLong(),d=sc.nextLong();
		long range=b-a+1, min=lcm(c,d);
		long c_div=b/c-(a-1)/c, d_div=b/d-(a-1)/d, common_div=b/min-(a-1)/min;
		System.out.println(range-(c_div+d_div-common_div));
	}

	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}
}


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

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }
};


int main() {
    int N, M; cin >> N >> M;
    UnionFind uf = UnionFind(M+1);
    vector<bool> langs(M+1, false);
    for (int i = 0; i < N; i++) {
        int K; cin >> K;
        int l; cin >> l;
        langs[l] = true;
        for (int j = 1; j < K; j++) {
            int l2; cin >> l2;
            langs[l2] = true;
            uf.unite(l, l2);
        }
    }
    int hoge = 0;
    for (int i = 1; i <= M; i++) {
        if (langs[i]) {
            hoge = uf.find(i);
            break;
        }
    }
    for (int i = 1; i <= M; i++) {
        if (langs[i] && uf.find(i) != hoge) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 640
def solve():
    N = int(input())
    H = list(map(int, input().split()))
    h_max = H[0]
    ret = True
    for h in H:
        if h_max-1 > h:
            ret = False
            break
        if h_max < h:
            h_max = h
    print('Yes' if ret else 'No')
    
solve()

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n >> k;
  	
  for (ll i = k; i <= n+1; ++i){

  	c=(c +  n*i%mod -  i*(i-1+mod)%mod + 1+ mod)%mod ;
  	
  }
  c(c);
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
	int S=0,h=0,m=0,s=0;

	scanf("%d",&S);

	h = S / 3600;
	m = ( S % 3600 ) / 60;
	s = ( S % 3600 ) % 60;

	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

Measured memory_bytes: 1024
n = int(input())

R = []
for i in range(n):
    R.append(int(input()))

maxv = R[1]-R[0]
minv = R[0]

for j in range(1,n):
    if maxv < R[j] - minv:
        maxv = R[j] - minv
    if minv > R[j]:
        minv = R[j]

print(maxv)


Measured memory_bytes: 13592
#include <stdio.h>
#define MAX 100

int main(void){
	int hist[MAX], t, max=0; for(t=0; t<MAX; t++) hist[t]=0;
	
	while(scanf("%d",&t)==1){
		hist[t]++;
	}
	
	for(t=0; t<MAX; t++) if(hist[t]>max) max=hist[t];
	for(t=0; t<MAX; t++) if(hist[t]==max) printf("%d\n",t);

	return 0;
}
	

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



int c[100][100];
int a[10001];

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

	int h,w,n;
	cin>>h>>w;
	cin>>n;
	rep(i,n){
		cin >> a[i];
	}
	int idx=0,r = a[0];
	int y=0,x=0;
	while (idx < n){
		c[y][x] = idx+1;
		r--;
		if (r==0){
			idx++;
			r = a[idx];
		}

		if (x%2){
			y--;
			if (y < 0){
				y=0;
				x++;
			}
		}
		else{
			y++;
			if (y == h){
				y=h-1;
				x++;
			}
		}
	}


	rep(i,h){
		cout << c[i][0];
		rep(j,w-1){
			cout << ' ' << c[i][j+1];
		}
		cout<<endl;
	}

	return 0;
}

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

flag = [[True] * N for _ in range(N)]

for i in range(N):
    for j in range(i+1, N):
        for k in range(N):
            if k == i or k == j:
                continue
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()
            elif A[i][j] == A[i][k] + A[k][j]:
                flag[i][j] = False

ans = 0

for i in range(N):
    for j in range(i+1, N):
        if flag[i][j]:
            ans += A[i][j]

print(ans)

Measured memory_bytes: 44764
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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


	cin >> N;
	int A, B, C;
	cin >> A >> B >> C;
	if (B & 1) {
		cout << 0 << endl;
		return 0;
	}
	B /= 2;
	vector<long long int>by(N + 1, 1);
	vector<long long int>rev(N + 1, 1);
	for (int i = 1; i <= N; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	long long int ans = by[A + B] * rev[A];
	ans %= MOD;
	ans *= rev[B];
	ans %= MOD;
	//cout << ans << endl;
	long long int ansby = 0;
	for (int i = 0; i <= C; i += 3) {
		for (int j = 0; j <= A; j++) {
			int box = C - i - j;
			if (box < 0)continue;
			if (!B&&box)continue;
			long long int add = 0;
			add = by[A] * rev[j];
			add %= MOD;
			add *= rev[A - j];
			add %= MOD;
			add *= by[A + B + i / 3];
			add %= MOD;
			add *= rev[A + B];
			add %= MOD;
			add *= rev[i / 3];
			add %= MOD;
			if (box) {
				add *= by[B - 1 + box];
				add %= MOD;
				add *= rev[B - 1];
				add %= MOD;
				add *= rev[box];
				add %= MOD;
			}
			ansby += add;
			ansby %= MOD;
		}
	}
	ans *= ansby;
	ans %= MOD;
	cout << ans << endl;
}


Measured memory_bytes: 384
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<algorithm>
#include<vector>
#include<string>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<assert.h>
using namespace std;
typedef long long LL;
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
typedef pair<LL, string> P;
typedef vector<int> V;
typedef vector<V> VV;
//input
int n, m, l;
int c[32][32];
string label[1123];
int bg_pos[1123];
int ed_pos[1123];
LL bg_time[1123];


LL d[32][32];
int nxt[32][32];

const LL INF = 1e15;

int exist[32];
vector<VV> post(32,VV(32));
LL min_time[32][32];
typedef pair<LL, int> pli;
template<typename T>
bool chmin(T &a, T b) { bool f = a > b; if (f)a = b; return f; }
map<LL, vector<pair<int,int>>> sc;
void sync(LL now_time,vector<P>& answer) {
	REP(from, n)if(exist[from]) {
		pli res(INF,-1);
		REP(j, n)chmin(res, { min_time[from][j],j });
		int to = res.second;
		if (to != -1) {
			exist[from] = 0;
			LL next_time = now_time + c[from][to];
			V &now_post = post[from][to];
			while (now_post.size()) {
				int now_item = now_post.back();
				if (ed_pos[now_item] == to)
					answer.push_back({ next_time,label[now_item] });
				else {
					sc[next_time].push_back({ to,now_item });
					//cout << label[now_item] << " " << from << "->" << to << endl;
				}
				now_post.pop_back();
			}
			min_time[from][to] = INF;
			next_time += c[to][from];
			sc[next_time].push_back({ from,-1 });
		}
	}
}
LL clean(LL now_time) {
	auto it = sc.upper_bound(now_time);
	if (it == sc.end())return -1;
	now_time = it->first;
	while (it->second.size()) {
		int id = it->second.back().second;
		int pos = it->second.back().first;
		if (id == -1)exist[pos] = 1;
		else {
			int to = nxt[pos][ed_pos[id]];
			chmin(min_time[pos][to], now_time);
			post[pos][to].push_back(id);
		}
		it->second.pop_back();
	}
	return now_time;
}

void init() {
	sc.clear();
	REP(i, 32)REP(j, 32)c[i][j] = -1;
	REP(i, 32)REP(j, 32) {
		d[i][j] = INF;
		nxt[i][j] = -1;
	}
	REP(i, 32) {
		exist[i] = 1;
		REP(j,32)post[i][j].clear();
		REP(j,32)min_time[i][j] = INF;
	}
}

void set_nxt(){
	REP(t, n) {
		bool update = true;
		d[t][t] = 0;
		while (update) {
			update = false;
			REP(i, n)REP(j, n) if(c[i][j]!=-1){
				LL nxt_cost = d[i][t] + c[i][j];
				if (d[j][t] > nxt_cost) {
					update = true;
					d[j][t] = nxt_cost;
					nxt[j][t] = i;
				}
				if (d[j][t] == nxt_cost) {
					nxt[j][t] = min(nxt[j][t], i);
				}
			}
		}
	}
}

int main() {
	int xxx = 0;
	while (cin >> n >> m, n + m) {
		if (xxx)cout << endl;
		xxx = 1;
		init();
		REP(i, m) {
			int a, b, x;
			cin >> a >> b >> x;
			a--, b--;
			c[a][b] = c[b][a] = x;
		}
		vector<P> res;
		set_nxt();
		cin >> l;
		REP(i, l) {
			cin >> bg_pos[i] >> ed_pos[i] >> bg_time[i] >> label[i];
			bg_pos[i]--;
			ed_pos[i]--;
			sc[bg_time[i]].push_back({ bg_pos[i],i });
		}
		LL nt = -1;
		while (true) {
			nt = clean(nt);
			if (nt == -1)break;
			sync(nt, res);
		}
		assert(res.size() == l);
		sort(ALL(res));
		for (auto &it : res)cout << it.second << " " << it.first << endl;
	}
}

Measured memory_bytes: 3576
N = int(input())

a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

m = 0
ame = 0
for i in range(N):
    ame = sum(a1[:i+1]) + sum(a2[i:])
    if ame > m:
        m = ame

print(m)


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 N;
	while(cin >> N && N){
		int32 cnt = 0;
		bool ok = 1;
		REP(i, N){
			string s;
			cin >> s;
			if(s == "A"){
				cnt++;
			}else{
				cnt--;
				if(cnt < 0) ok = 0;
			}
		}
		if(cnt != 0 || !ok) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
}


Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

ll _gcd(ll a, ll b)
{
    return (b) ? _gcd(b, b%a) : a;
}

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

    ll k;
    cin >> k;

    ll ans = 0;
    for (ll a=1; a<=k; ++a)
        for (ll b=1; b<=k; ++b)
            for (ll c=1; c<=k; ++c)
                ans += gcd(c, gcd(a,b));

    cout << ans << endl;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 500000
struct Node {
  int key;
  struct Node *pa,*l,*r;/*parents left child right child*/
};
struct Node *root,*NIL;
/*int findr[MAX],in = 0;*/
void insert(int k){/*挿入　挿入するキー*/
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;
  z=(struct Node *)malloc(sizeof(struct Node));/*zノードのメモリを動的に確保*/
  z->key=k;/*zのキーをkとする*/
  z->l=NIL;
  z->r=NIL;
  while(x!=NIL){/*x　rootから*/
    y=x;/*yののーどをxとおなじものにする（最初はroot）*/
    if(z->key < y->key){/*zのキーがyのキーより小さい時*/
      x=x->l;/*xをxのleft child とする*/
    }
    else x=x->r;/*zのキーがyのキー以上の時　xをxのright child とする*/

  }
  z->pa=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->l = z;
    }else{
      y->r = z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(struct Node *u){
  if(u ==NIL)return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

void find(int k){
  struct Node *r = root;
  while (r != NIL && k!= r->key) {
    if(k < r->key){
      r = r->l;
    }else{
      r = r->r;
    }
  }
  if(r == NIL)printf("no\n");
  else printf("yes\n");
}
int main(){
  int str1 = 0, str2 = 0,str3 = 0;
  int i,n,v;
  char C1[10], C2[10]="insert", C3[10]="print",C4[10]="find";

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%s",C1);

    if(strcmp(C1,C2) == 0) str1 = 1;
    if(strcmp(C1,C3) == 0) str2 = 1;
    if(strcmp(C1,C4) == 0) str3 = 1;
    if(str1 == 1){
      scanf("%d",&v);
      insert(v);
      str1 = 0;
    }
    else if(str2 == 1){
      str2 = 0;
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(str3 ==1){
      scanf("%d",&v);
      find(v);
    }
  }

  return 0;
}



Measured memory_bytes: 20484
#include <stdio.h>

int main(void){
  int i=0, j=0, count=0;
  int n;

  scanf("%d", &n); //たこ焼きの数を取得
  int items[n]; //たこ焼きの回復量を格納する配列を宣言
    
  while(i<n){
    scanf("%d", &items[i]); //たこ焼きの回復量を格納
    i++;
  }
  
  i=0;
  while(i<n){
    j=i+1;
    while(j<n){ //かけ合わせの相手を一つずつずらしながら加算
        count += items[i]*items[j];
        j++;
    }
    i++;
  }
  
  printf("%d", count);

  return 0;
}

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

using namespace std;

int main()
{
    int g[3][3];
    for (int i = 0; i < 3; i++)
        cin >> g[i][0] >> g[i][1] >> g[i][2];

    int n;
    cin >> n;
    set<int> cj;
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        cj.insert(b);
    }

    bool can = (cj.count(g[0][0]) > 0 && cj.count(g[1][1]) > 0 && cj.count(g[2][2]) > 0) ||
                (cj.count(g[0][2]) > 0 && cj.count(g[1][1]) > 0 && cj.count(g[2][0]) > 0);

    for (int i = 0; i < 3; i++) {
        if (cj.count(g[i][0]) > 0 && cj.count(g[i][1]) > 0 && cj.count(g[i][2]) > 0)
            can = true;
        else if (cj.count(g[0][i]) > 0 && cj.count(g[1][i]) > 0 && cj.count(g[2][i]) > 0)
            can = true;
    }
    if (can)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();

		System.out.println(p + q + r - Math.max(p, Math.max(q, r)));
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <cstdio>
#include <map>
using namespace std;

int main(){
	string s;
	int n;
	map<int,int> mp;

	while(getline(cin, s) && !s.empty()){
		if(sscanf(s.c_str(), "%d", &n) == 1){
			mp[n] += 4;
			mp[n] |= 1;
		}
	}
	while(getline(cin, s) && !s.empty()){
		if(sscanf(s.c_str(), "%d", &n) == 1){
			mp[n] += 4;
			mp[n] |= 2;
		}
	}
	
	for(map<int,int>::iterator it = mp.begin(); it != mp.end(); ++it){
		if((it->second & 3) == 3){
			printf("%d %d\n", it->first, it->second >> 2);
		}
	}
}

Measured memory_bytes: 1244
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int N;
    
    cin >> N;

    vector<int> A;
    for( int ni = 0 ; ni < N ; ni++ ){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    sort(A.begin(),A.end());
    cout << A[N-1] - A[0];
    
    

}

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

int N,M,p[100010] = {},c[100010] = {},cnt[100010] = {};
vector<vector<int>> v(100010);
int main(){
	cin >> N >> M;
	int a,b;
	for(int i=0;i<N+M-1;i++){
		cin >> a >> b;
		v[a].push_back(b);
		c[b]++;
	}
	int id = 0;
	for(int i=1;i<=N;i++){
		if(c[i]==0){
			p[i] = 0;
			id = i;
			break;
		}
	}
	queue<int> Q;
	Q.push(id);
	while(!Q.empty()){
		int s = Q.front(); Q.pop();
		for(int i=0;i<v[s].size();i++){
			int t = v[s][i];
			cnt[t]++;
			if(cnt[t]==c[t]){
				p[t] = s;
				Q.push(t);
			}
		}
	}
	for(int i=1;i<=N;i++) cout << p[i] << endl;
}

Measured memory_bytes: 7424
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long A = sc.nextInt();
    long B = sc.nextInt();
    long minCost = 0;
    long[] x = new long[N];
    for(int i = 0; i < N; i++) {
      x[i] = sc.nextLong();
    }
    for(int i = 0; i < N - 1; i++) {
      minCost += Math.min((x[i + 1] - x[i]) * A, B);
    }
    System.out.println(minCost);
  }
}

Measured memory_bytes: 34652
/*input
90081 33447 90629 6391049189
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=998244353;
long long fac[300005]={1},n;
long long power(long long a,long long p,long long m=md,long long k=0){
	return p?k=power(a,p/2,m),(k*k%m)*(p&1?a:1)%m:1;
}
long long ncr(int n, int r){
	if(r<0 || r>n) return 0;
	return fac[n]*power(fac[r]*fac[n-r]%md,md-2)%md;
}
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>>n>>x>>y>>k;
	for(int i=1;i<300005;++i) 
		fac[i]=fac[i-1]*i%md;
	for(int i=0;i<=min(k,n);++i) if((k-i*x)%y==0)
		(ans += ncr(n,i)*ncr(n,(k-i*x)/y)%md)%=md;
	cout<<ans;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    cin >>n;
    int c[100][100];
    rep(i,n)rep(j,n) scanf(" %d", &c[i][j]);

    long ans=0;
    rep(i,n)rep(j,i) ans+=min(c[i][j],c[j][i]);

    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 3268
#coding: utf-8
from decimal import Decimal
n = int(input())
n = n-1
answer = 0

if n % 2 == 0:
	answer = (Decimal(n)+Decimal(1))*(Decimal(n)/2)
else:
	answer = Decimal(n)*((Decimal(n)-Decimal(1))/2) + Decimal(n)

print(int(round(answer,0))) 


Measured memory_bytes: 5332
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;

signed main(){
	string s;cin>>s;int cnt=s[0]+s[1]+s[2]-3*'0';cout<<cnt<<endl;
	}


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
		if (!a[i]) b[0] = 1;
		else if (b[a[i] - 1]) b[a[i]] = 1;
	}
	for (int i = 0; i < n; i++) {
		if (!b[i]) {
			cout << (i ? (n - i) : -1);
			return;
		}
	}
	cout << 0;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main()
{

    int A,B,C,D;
cin>>A>>B>>C>>D;
if(A+B>C+D){
    cout<<"Left";
}
else if (A+B<C+D){
    cout<<"Right";
}
else if(A+B==C+D){
    cout<<"Balanced";
}


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
	int x, h;
	while(cin >> x){
		cin >> h;
		if(x == 0 && h == 0) break;
		double s = x * x + 4 * (x * sqrt((x*0.5)*(x*0.5) + h*h) * 0.5);
		cout << fixed << setprecision(6) << s << endl;
	}
}

Measured memory_bytes: 1232
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,k,a;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a;
	cout<<(n-k)/(k-1)+((n-k)%(k-1)==0?0:1)+1; 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
  
int main(void)
{
	int a, b, c;
	int tmp;

	scanf("%d%d%d", &a, &b, &c);
	if (a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if (b > c){
		tmp = b;
		b = c;
		c = tmp;
		if (a > b){
			tmp = a;
			a = b;
			b = tmp;
		}
	}

	printf("%d %d %d\n", a, b, c);
	return 0;

}


Measured memory_bytes: 2056
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(a-b)<=d && abs(b-c)<=d || abs(a-c)<=d){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
    n: usize,
    }
    let L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    println!("{}", L[n-1])
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;
const int MAX_PRIME = 10000000;


int prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
int p;

void erats(){
	// primeツδ環スツトツづーツ渉可甘コツ可サ
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i]){
			prime[p++] = i;
		}
		else
			continue;

		// ツづ督づゥツつ「ツづ可つゥツつッツづゥ
		for(int j = 2*i; j <= MAX_PRIME; j+=i){
			isPrime[j] = false;
		}
		cout << flush;
	}
}

int main(){

	erats();
	int n;
	while(cin>>n&&n!=0){
		for(int i = n; i >= 0; i--){
			if(isPrime[i]&&isPrime[i-2]&&isPrime[i-6]&&isPrime[i-8]){
				cout<<i<<endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

/* Trie */

struct ACNode{
  int val;
  ACNode *next[26], *failure;
  
  ACNode():val(0) { memset(next,0,sizeof(next)); }
  
  void insert(char *s){
    if(!*s){ val++; return; }
    int al = *s-'a';
    if(next[al]==NULL) next[al] = new ACNode;
    next[al]->insert(s+1);
  }

  ACNode *nextNode(char c){
    int al = c - 'a';
    if (next[al]) return next[al];
    return failure == this ? this : failure->nextNode(c);
  }
};

struct AhoCorasick{
  ACNode *node;

  AhoCorasick(){node = new ACNode;}
  
  void insert(char *s) {
    node->insert(s);
  }
  
  void build() {
    queue<ACNode*> que;

    node->failure = node;
    que.push(node);
    
    while(que.size()){
      ACNode *p = que.front();
      que.pop();
      
      for(int i=0;i<26;i++){
        if(p->next[i]){
          ACNode *failure = p->failure;
          while(!failure->next[i] && failure != node){
            failure = failure->failure;
          }
          if (failure->next[i] && !(failure == p && p == node)){
            p->next[i]->failure = failure->next[i];
            p->next[i]->val += failure->next[i]->val;
          }else{
            p->next[i]->failure = node;
          }
          que.push(p->next[i]);
        }
      }
    }
  }
};



int main(){
  char s[SIZE], p[SIZE];
  int n;
  AhoCorasick ac;
  
  scanf("%s%d", s, &n);
  
  for(int i=0;i<n;i++){
    scanf("%s", p);
    ac.insert(p);
  }

  ac.build();

  ACNode *now = ac.node;
  int ans = 0;
  for(int i=0;s[i] != '\0';i++){
    now = now->nextNode(s[i]);
    if(now->val){
      ans++;
      now = ac.node;
    }
  }

  printf("%d\n", ans);
  
  return 0;
}




Measured memory_bytes: 22852
#!/usr/bin/python3
# abc061_c
"""
Big Array
"""

def answer():
    """
    答えを出力する関数
    """
    l = []
    N, K = map(int, input().split())
    counter = 0

    for _ in range(N):
        l.append(list(map(int, input().split())))

    l.sort()
    for v in l:
        counter += v[1]
        if counter >= K:
            print(v[0])
            break

def main():
    """
    処理を実行する関数
    """
    answer()


if __name__ == '__main__':
    main()


Measured memory_bytes: 27872
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		
		BigDecimal bd1 = BigDecimal.valueOf(L*L*L);
		BigDecimal bd2 = new BigDecimal(27);
		
		BigDecimal bd3 = bd1.divide(bd2,10, RoundingMode.HALF_UP);

		
		System.out.println(bd3);
	}
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int sum = 0;
	for (int i = 0; i < 3; i++) sum += ri();
	std::cout << (sum <= 21 ? "win" : "bust") << std::endl;
	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    long long n, m, k, answ = 0;
    cin >> n >> m >> k;
    long long a[n+1] = {0}, b[m+1] = {0};
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    for(int i = 1; i <= m; i++) {
        cin >> b[i];
        b[i] += b[i-1];
    }

    long long l = 0, r = n+m;
    while(r >= l) {
        long long mid = (l+r)/2, ctime = 1e18;
        for(int i = 0; i <= mid; i++) {
            int p1 = i, p2 = mid-i;
            if(p1 <= n && p2 <= m)
                ctime = min(ctime, a[p1] + b[p2]);
        }
        if(ctime <= k) {
            answ = max(answ, mid);
            l = mid+1;
        }
        else
            r = mid-1;
    }
    cout << answ;

    return 0;
}


Measured memory_bytes: 6760