akhauriyash/Code-Regression huggingface dataset:
//
// author  : Abhishek
//
#include <bits/stdc++.h>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}


ll power(ll x, ll n, ll m) {
    if (x == 0) {
        return 0;
    }
    if (n == 0) {
        return 1;
    }
    ll ans;
    if (isEven(n)) {
        ll smallAns = power(x, n / 2, m);
        ans = (smallAns * smallAns) % m;
    } else {
        ll smallAns = power(x, n - 1, m);
        ans = x;
        ans = (ans * smallAns) % m;
    }
    // for negative values also
    return (ans + m) % m;

}

class Act {
public:
    ll a;
    ll b;
    ll c;
};

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

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

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;

    cin >> n;

    vector<Act> arr(n);

    fo(i, n) {
        Act temp;
        cin >> a >> b >> x;
        temp.a = a;
        temp.b = b;
        temp.c = x;
        arr[i] = temp;
    }

//    fo(i, n) {
//        cout << arr[i].a << " " << arr[i].b << " "<<arr[i].c << "\n";
//    }

    ll dp[3][n];

    dp[0][0] = arr[0].a;
    dp[1][0] = arr[0].b;
    dp[2][0] = arr[0].c;

    Fo(i, 1, n) {
//        deb(i);
        dp[0][i] = arr[i].a + max(dp[1][i - 1], dp[2][i - 1]);
        dp[1][i] = arr[i].b + max(dp[0][i - 1], dp[2][i - 1]);
        dp[2][i] = arr[i].c + max(dp[1][i - 1], dp[0][i - 1]);
    }


    cout << max(dp[0][n - 1], max(dp[1][n - 1], dp[2][n - 1]));

    return 0;
}




Measured memory_bytes: 7932
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

int main() {
  int w, h;
  while (true) {
    cin >> w >> h;
    if (w == 0 && h == 0) {
      break;
    }

    bool field[w][h];
    memset(field, false, sizeof(field));
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
	int t;
	cin >> t;
	if (t == 0) {
	  field[j][i] = false;
	}else {
	  field[j][i] = true;
	}
      }
    }

    int cnt = 0;
    int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
    int dy[] = {1, -1, 0, 0, 1, -1, -1, 1};
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
	if (field[j][i]) {
	  stack<int> st;
	  st.push(j);
	  st.push(i);
	  field[j][i] = false;
	  while (!st.empty()) {
	    int y = st.top(); st.pop();
	    int x = st.top(); st.pop();

	    for (int p = 0; p < 8; p++) {
	      int nx = x+dx[p];
	      int ny = y+dy[p];

	      if (nx < 0 || ny < 0 ||
		  nx >= w || ny >= h ||
		  !field[nx][ny]) {
		continue;
	      }
	      st.push(nx);
	      st.push(ny);
	      field[nx][ny] = false;
	    }
	  }
	  cnt++;
	}
      }
    }

    std::cout << cnt << std::endl;
  }
}

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

	int a, b = 1, c = 0, d = 2, n = 3, m;
	string str;

	cin >> str;

	str.insert(str.begin() + 6, ' ');
	str.insert(str.begin() + 15, ' ');

	str.erase(str.begin() + 5);
	str.erase(str.begin() + 13);

	cout << str << endl;




	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * 4 8
 * 5 6
 * 1 8
 * 3 4
 * 1 5
 * 2 3
 * 0 4
 * 1 2
 * 
 */
int main() {
	ll a, b;
	cin >> a >> b;
	if (a <= 1 && b <= 1) {
		cout << "Brown";
		return 0;
	}
	if (a == b || a == b + 1 || a + 1 == b) {
		cout << "Brown";
	}
	else {
		cout << "Alice";
	} 
}


Measured memory_bytes: 256
(n,m),*z=$<.map{|s|s.split.map &:to_i}
P=*0..n
Q=[0]*-~n
F=->x{x==(p=P[x])?x:(P[x]=F[p];Q[x]+=Q[p];P[x])}
puts z.any?{|l,r,d|x=F[l];y=F[r];x==y&&Q[l]+d!=Q[r]||!(P[y]=x;Q[y]=Q[l]+d-Q[r])}?:No: :Yes

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

int gcd(int a, int b, int c)
{
  return __gcd(__gcd(a, b), c);
}

int main()
{
  int K;
  cin >> K;
  long long ans = 0;
  for (int a = 1; a <= K; a++)
  {
    for (int b = 1; b <= K; b++)
    {
      for (int c = 1; c <= K; c++)
      {
        ans += gcd(a, b, c);
      }
    }
  }
  cout << ans << endl;
}

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

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

  if (10%p == 0) {
    ll ans = 0;
    rep(i, n) {
      if ((s[i]-'0')%p == 0) ans += i+1;
    }
    cout << ans << endl;
    return 0;
  }

  ll ten = 1;
  vector<ll> c(n+1, 0);
  for (int i=n-1; i>=0; i--) {
    ll t = s[i]-'0';
    ll u = t * ten % p;
    c[i] = (c[i+1]+u) % p;
    ten = (ten*10) % p;
  }
  map<ll, ll> mp;
  mp[0]++;
  ll ans = 0;
  for (int i=n-1; i>=0; i--) {
    ans += mp[c[i]];
    mp[c[i]]++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2564
#include <iostream>
#include <string>
#include <vector>
#include <utility>

using namespace std;

int main()
{
    int n;
    int sumtime = 0;
    cin >> n;
    vector<pair<string, int>> songlist(n);
    for (auto &&i : songlist)
    {
        cin >> i.first >> i.second;
        sumtime += i.second;
    }
    string x;
    cin >> x;
    int ans = sumtime;
    for (auto &&i : songlist)
    {
        ans -= i.second;
        if (i.first == x)
        {
            cout << ans << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;

int main(){

  ll n,m;
  cin>>n>>m;
    priority_queue<int> pq;
    for(ll i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        pq.push(x);
    }
    for(ll i=1;i<=m;i++)
    {
      ll x=pq.top();
      pq.pop();
      pq.push(x/2);
    }
    ll res=0;
    while(!pq.empty())
    {
        res+=pq.top();
        pq.pop();
    }
      cout<<res;
   return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N,M;

set<int> o,n;

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

  rep(i,0,M - 1){
    int a,b;
    cin >> a >> b;
    if(a == 1){
      o.insert(b);
    }
    if(b == N){
      n.insert(a);
    }
  }

  rep(i,1,N){
    if(o.count(i) && n.count(i)){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}



Measured memory_bytes: 9600
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<string> board(H);
	for (int i = 0; i < H; ++i) {
		cin >> board[i];
	}
	vector<int> vl, hl;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (board[i][j] == '#') {
				vl.push_back(i);
				break;
			}
		}
	}
	for (int i = 0; i < W; ++i) {
		for (int j = 0; j < H; ++j) {
			if (board[j][i] == '#') {
				hl.push_back(i);
				break;
			}
		}
	}
	for (int i : vl) {
		for (int j : hl) {
			cout << board[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,i,j,h1=0,h2=0,h3=0;
    for(i=0;i<10;i++){
        scanf("%d",&a);
        if(a>h1){
                h3=h2;
                h2=h1;
                h1=a;
        }
        else if(a>h2){
                h3=h2;
                h2=a;
        }
        else if(a>h3){
                h3=a;
        }
    }
    printf("%d\n%d\n%d\n",h1,h2,h3);
    return 0;
}


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

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(float, input().split()))
dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(N+1):
        dp[i+1][j] += dp[i][j]*(1-P[i])
        if j > 0:
            dp[i+1][j] += dp[i][j-1]*P[i]
print(sum(dp[N][N//2+1:]))


Measured memory_bytes: 252168
#include<bits/stdc++.h>
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

const ll MOD = 1e9 + 7;
const ll maxN = 5e5 + 5;


ll powerM(ll x, ll y, ll M = MOD) // default argument
{ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;}

ll power(ll x, ll y)
{ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;}


ll fact[maxN], invfact[maxN];

ll modinv(ll a) { return powerM(a, MOD - 2, MOD); }

ll nCr(ll n, ll r) {
	if (r > n) return 0;
	return ((fact[n] * invfact[r]) % MOD * invfact[n - r]) % MOD;
}

void precomputenCr() {
	fact[0] = fact[1] = 1;
	for (ll i = 2; i < maxN; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	/*
	n! = n * (n-1) !
	==> 1/(n-1!) = n/(n!)
	==> (1/(n-1!)) % M = (n/(n!)) % M
	==> (1/(n-1!)) % M = ((n % M) * ((1/(n!)) % M)) % M
	*/
	invfact[maxN - 1] = modinv(fact[maxN - 1]);
	for (ll i = maxN - 2; i >= 0; i--) {
		invfact[i] = invfact[i + 1] * (i + 1);
		invfact[i] %= MOD;
	}

}

int main()
{
	// WHILE(!(SUCCEED == TRY()));
	// BEFORE WRITING MAKE SURE YOU HAVE ANALYSED THE CONSTRAINTS
	// AND THINK THROUGH THE LOGIC ONCE MORE
	FIO
	precomputenCr();
    // USING PRINCIPLE OF INCLUSION AND EXCLUSION
	ll n, m; cin >> n >> m;
	ll ans = nCr(m, n) * fact[n];
	ans %= MOD;
	for (ll i = 1; i <= n; i++) {
		ll cur = nCr(n, i);

		cur *= nCr(m - i, n - i);
		cur %= MOD;

		cur *= fact[n - i];
		cur %= MOD;

		if (i % 2 == 1) cur = MOD - cur;

		ans += cur;
		ans %= MOD;
	}
	ans = ans * ((nCr(m, n) * fact[n]) % MOD);
	ans = ans % MOD;
	cout << ans << "\n";
	return 0;
}
// “Well, probably you won’t understand anything, because you
// didn’t try to understand anything in your life, you expect
// all hard work to be done for you by someone else” - um_nik
/*
https://codeforces.com/blog/entry/79438
...

https://codeforces.com/blog/entry/79438?#comment-651722

That's not assumed. Do you understand what we're doing PiE over? I can phrase in a different way:

Take WLOG Ai=i
for 1≤i≤n as in the editorial above. Then, let Si be the set of sequences for B satisfying the
second condition (Bi≠Bj when i≠j) and with Bi=i

. Then clearly we want to work out
(MN)N!−|S1∪S2∪⋯∪SN|

as this is the number of valid B
sequences (assuming Ai=i for all i). We can work this out via PiE (since the sizes intersections
of various Si sets are easy to work out), and then we just multiply by (MN)N! as that's the number
of possibly A sequences.

*/

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

int main() {
	int a, b;
	cin >> a >> b;
	if (b < a) cout << a - 1 << endl;
	else cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
import bisect


def soin(n):
    re = []
    while n > 1:
        for i in range(2, int(n ** 0.5) + 1):
            if n % i == 0:
                re += [i]
                n //= i
                break
        else:
            re += [n]
            n = 0
    return re


n = int(input())
sol = []
for i in range(2, n + 1):
    sol += soin(i)

sisu = []
for sk in set(sol):
    sisu += [sol.count(sk)]

sisu.sort()
lsi = len(sisu)
c74 = lsi - bisect.bisect_left(sisu, 74)
c24 = lsi - bisect.bisect_left(sisu, 24)
c14 = lsi - bisect.bisect_left(sisu, 14)
c4 = lsi - bisect.bisect_left(sisu, 4)
c2 = lsi - bisect.bisect_left(sisu, 2)

c24_2 = c24 * (c2 - 1)
c14_4 = c14 * (c4 - 1)
c4_4_2 = c4 * (c4 - 1) * (c2 - 2) // 2

print(c74 + c24_2 + c14_4 + c4_4_2)

Measured memory_bytes: 3188
S = list(map(int,input().rstrip().split('/')))
if S[0]>2019:
    print('TBD')
elif S[0]==2019:
    if S[1]>4:
        print('TBD')
    elif S[1]==4:
        if S[2]>30:
            print('TBD')
        else:
            print('Heisei')
    else:
        print('Heisei')
else:
    print('Heisei')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



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

  ll n = s.length();
  vector<char> v;
  s = s + 'Z';

  ll ref = 0;
  while(ref<=n-1){
    if(s[ref]=='B' && s[ref+1]=='C'){
      v.PB('D');
      ref += 2;
    }
    else{
      v.PB(s[ref]);
      ++ref;
    }
  }

  ll acnt = 0;
  ll ans = 0;
  FOR(i,0,SZ(v)-1){
    if(v[i]=='A') ++acnt;
    else if(v[i]=='D'){
      ans += acnt;
    }
    else{
      acnt = 0;
    }
  }

  cout << ans << endl;
}



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

int main(){
  string S;
  cin >> S;
  int ans = 1;
  if(S=="RRR") ans = 3;
  if(S=="RRS"||S=="SRR") ans = 2;
  if(S=="SSS") ans = 0;
  cout << ans;
  return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = 0;
        for (int i = 2; i < Math.sqrt(n) + 1; i++) {
            int e = 0;
            while(n % i == 0){
                e++;
                n /= i;
            }
            for (int j = 1; j <= e; j++) {
                ans++;
                e -= j;
            }
        }
        if(1 < n) ans += 1;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 35812
x = input().split()

N = int(x[0])
A = int(x[1])
B = int(x[2])

C = A + B

m = N % C
n = N // C

if m == 0:
    print(A*n)
else:
    if m >= A:
        print(A*(n+1))
    else:
        print(A*n + m)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

namespace P0027_What_day_is_today
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = new List<string[]>();

            while (true)
            {

                var line = Console.ReadLine();
                if (line == "0 0") break;

                inputs.Add(line.Split(' '));

            }

            foreach (var input in inputs)
            {
                var d = new DateTime(2004, int.Parse(input[0]), int.Parse(input[1]));
                Console.WriteLine(d.DayOfWeek.ToString());                
            }

        }
    }
}

Measured memory_bytes: 20396
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;
 
 
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
#endif
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
 
using namespace std;
 
const long long p=998244353ll;
long long b[201],ans;
int n,x[201],y[201];
 
int main(){
    scanf("%d",&n);for(int i=1;i<=n;++i)scanf("%d%d",x+i,y+i);
    for(int i=b[0]=1;i<=n;++i)b[i]=b[i-1]*2ll%p;
    ans=b[n]-(n*(n+1ll)>>1)%p-1ll;
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=n;++j){
            int cnt=0ll;
            for(int k=j+1;k<=n;++k)cnt+=(x[j]-x[i])*(y[k]-y[j])==(x[k]-x[j])*(y[j]-y[i]);
            (ans-=b[cnt]-1ll)%=p;
        }
    }
    printf("%lld",ans<0ll?ans+p:ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    int N;
    cin >> N;
    cout << N/3 << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

const ll M=1e9+7;
typedef vector<ll> vec;
typedef vector<vec> mat;
struct Matrix{
  ll N;
  mat a;
  Matrix(ll n){
    N=n;
    a=mat(N,vec(N));
    for(int i=0;i<N;i++)a[i][i]=1;
  }
  Matrix pow(ll b) const {
    Matrix res(N);
    Matrix d(N);
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)d[i][j]=a[i][j];
    for(;b>0;b>>=1,d=d*d)if(b&1)res=d*res;
    return res;
  }
  Matrix operator+(const Matrix& r) const {
    Matrix s(N);
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        s[i][j]=(a[i][j]+r.a[i][j])%M;
      }
    }
    return s;
  }
  Matrix operator*(const Matrix& r) const {
    Matrix s(N);
    for(int i=0;i<N;i++)s[i][i]=0;
    const long long modl=8*M*M;
    for(int i=0;i<N;i++){
      for(int k=0;k<N;k++){
        for(int j=0;j<N;j++){
          s[i][j]+=a[i][k]*r.a[k][j];
          if(s[i][j]>=modl)s[i][j]-=modl;
        }
      }
      for(int j=0;j<N;j++)s[i][j]%=M;
    }
    return s;
  }

  vector<ll>& operator[](ll i){
    return a[i];
  }
};

ll fib(ll n){
  Matrix A(2);
  A[0][0]=1; A[0][1]=1;
  A[1][0]=1; A[1][1]=0;
  Matrix res=A.pow(n+1);
  return res[1][0];
}

ll K;

int main(){
  cin>>K;
  ll lb=0,ub=1e9;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    if(mid*(mid+1)<K)lb=mid;
    else ub=mid;
  }
  K-=lb*(lb+1);
  ll N=ub;
  ll si=1,sj=(N-1)*2+1;
  if(K>N){
    K-=N;
    sj++;
  }
  ll num1,num2;
  if(N%2==0){
    num1=N/2+1;
  }else{
    num1=(N+1)/2;
  }
  num2=N-num1;
  if(N%2==0){
    if(K<=num1){
      if(K==num1){
        si+=N-1; sj-=N-1;
      }else{
        si+=2*(K-1); sj-=2*(K-1);
      }
    }else{
      si+=N-1; sj-=N-1;
      K-=num1;
      si-=2*K; sj+=2*K;
    }
  }else{
    if(K<=num1){
      si+=2*(K-1); sj-=2*(K-1);
    }else{
      K-=num1;
      si+=N-1; sj-=N-1;
      si-=1; sj+=1;
      si-=2*(K-1); sj+=2*(K-1);
    }
  }
  cout<<fib(si)*fib(sj)%mod<<endl;
  return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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 / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll a,b;
cin>>a>>b;
if(a<=8&&b<=8){
    cout<<"Yay!"<<endl;
}else{
    cout<<":("<<endl;
}
}









Measured memory_bytes: 256
#include<iostream>
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 1000000007
#define DEB(x) cout<<"##"<<x<<"##"<<endl;
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void solve1()
{
	int r;
	cin>>r;
	cout<<2*((double)(r))*(3.141592653589793238);
}
void solve()
{
	ll n,m;
	cin>>n>>m;
	int ar[m];
	ll sum=0;
	rep(i,m)
	{


		cin>>ar[i];
		sum+=ar[i];
	}
	ll x=-1;
	cout<<max(n-sum,x);
}
int main()
{
	fastio();
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	solve();


	return 0;

	
}

Measured memory_bytes: 3624
object Main {
  def main(args:Array[String]) {
    val S = readLine()
    var ansarr = Array.fill(S.length)(1)

    for(i <- 0 until S.length) {
      if(S(i) == 'R') {
        if(S(i + 1) == 'R') {
          ansarr(i + 2) += ansarr(i)
          ansarr(i) = 0
        }
      }
    }
    for(i <- S.length - 1 to 0 by -1) {
      if(S(i) == 'L') {
        if(S(i - 1) == 'L') {
          ansarr(i - 2) += ansarr(i)
          ansarr(i) = 0
        }
      }
    }
    ansarr.map(a => print(a + " "))
  }
}

Measured memory_bytes: 46320
N, M, X = map(int, input().split())
sankousyo = [list(map(int, input().split())) for _ in range(N)]

f = False
res = 10**7
for i in range(2**N):
    kane = 0
    rikaido = [0]*M
    for j in range(N):
        if (i>>j)&1:
            kane += sankousyo[j][0]
            for k in range(M):
                rikaido[k] += sankousyo[j][k+1]
    if min(rikaido) >= X:
        f = True
        res = min(kane, res)

if f:
    print(res)
else:
    print(-1)

Measured memory_bytes: 9052
n, m, x = (int(i) for i in input().split())
list_a = [int(i) for i in input().split()]
list_toll = []
for i in range(0, n + 1):
    if i in list_a: list_toll.append(1)
    else: list_toll.append(0)
print(min(sum(list_toll[:x]), sum(list_toll[x:])))

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
ll x[10], y[10];

double dist(ll i, ll j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx * dx + dy * dy, 0.5);
}

int main() {
  ll n,cnt=0;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];
  for (int i = 0; i < n; ++i) v[i] = i;
  double ans = 0.0;
  do {
    rep(i, n - 1) ans += dist(v[i], v[i + 1]);
    cnt++;
  } while (next_permutation(v.begin(), v.end()));

  cout << setprecision(16) << ans / cnt << endl;
  return 0;
}


Measured memory_bytes: 384
// Problem : B - ... (Triple Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define ll long long
#define F first
#define S second
#define mod 1000000007
#define maxn 200005
#define INF 1000000000
#define ld long double
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
	FAST
	ll n;
	cin >> n;
	string s;
	cin >> s;
	if(s.size()<=n){
		cout << s << endl;
	}
	else {
		for(ll i = 0;i<n;i++){
			cout << s[i];
		}
		cout << "..." << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> data(N, vector<int>(2));
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data.at(i).at(j);
    }
  }
  
  int sum = 0;
   for (int i = 0; i < N; i++) {
    for (int j = 0; j < 1; j++) {
      int num = data.at(i).at(1) - data.at(i).at(0) +1;
      sum += num;
    }
  }
 cout << sum << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

int main()
{
    int sum = 0;
    rep(i, 10){
        int a;
        cin >> a;
        sum += a;
    }
    cout << sum << endl;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1e3 + 5;
const int MAXD = 1e6 + 5;
const int MOD = 1e9 + 7;
set<int> vis;
ll solve(ll n) {
    ll ret = 1e18;
    ll pw = 1;
    while (n % 2 == 0) {
          if(!vis.count((ll)pow(2,pw)))
             ret = min(ret , (ll)pow(2,pw));
            n /= 2;
            ++pw;
    }
    for (ll d = 3; d * d <= n; d += 2) {
         pw = 1;
        while (n % d == 0) {
            if(!vis.count((ll)pow(d,pw)))
             ret = min(ret , (ll)pow(d,pw));
            n /= d;
            ++pw;
        }
    }
    if (n > 1 and !vis.count((ll)n))
        ret = min(ret ,n);
    return ret;
}

int main() {

ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

ll n;
cin >> n;
int Ans = 0;
while(1)
{
    ll z = solve(n);
    if(z == 1e18)
          break;
    vis.insert(z);
    n/=z;
    ++Ans;
    
}
cout << Ans;



}

Measured memory_bytes: 4136
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}
template <class T> T gcd(T a, T b) {if (b) return gcd(b, a % b); else return a;}
template <class T> T lcm(T a, T b) {return (a * b) / gcd(a,b);}

const ll maxn = 1001, mod = 1e9 + 7;

char g[maxn][maxn];
ll dp[maxn][maxn];

signed main()
{
//	freopen("test.inp", "r", stdin); //freopen("TEXT.out", "w", stdout);
	fastio();

    ll m, n; cin >> m >> n;
    for (ll i = 0; i < m; i++) {
        for (ll j = 0; j < n; j++) {
            cin >> g[i][j];
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    for (ll i = 0; i < m; i++) {
        for (ll j = 0; j < n; j++) {
            if (g[i][j] == '#') {
                dp[i][j] = 0;
                continue;
            } else {
                dp[i][j] = max(dp[i][j], (i > 0 ? dp[i - 1][j] : 0) + (j > 0 ? dp[i][j - 1] : 0)) % mod;
            }
        }
    }
    cout << dp[m - 1][n - 1];
}


Measured memory_bytes: 12348
#include <iostream>//cout
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>//swap
using namespace std;
static const int MAX = 200000;
#define rep(i,n) for(int i=0;i<n;i++)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 
int main() {
  long long int x, a, b;
  cin >> x >> a >> b;
  cout << x-a-((x-a)/b)*b << endl;
  return 0;
}


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

lis.sort(key=lambda x:x[1])

flag = 1
total = 0

for i in lis:
    total += i[0]
    if total > i[1]:
        flag = 0
        break

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 46868
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#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(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

ll memo[11][110][1010];
ll sub(int n, int k, int s){
	if(n == 0) return (s == 0);
	if(memo[n][k][s] != -1) return memo[n][k][s];

	ll sum = 0;
	rep(i, k){
		if(i > s)break;
		//printf("call sub(%d,%d,%d)/ret=%d\n", n-1, i, s-i, sub(n-1, i, s-i));
		sum += sub(n-1, i, s-i);
	}
	return memo[n][k][s] = sum;
}

int main(){
	memset(memo, -1, sizeof(memo));
	int n, s;
	while(cin >> n >> s, n+s){
		cout << sub(n, 101, s) << endl;
	}

	return 0;
}

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

using namespace std;

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

	int cR = 0, cW = 0;
	for (int j = 0; j < N; j++) {
		if (c[j] == 'R') {
			cR++;
		} else {
			cW++;
		}
	}

	string target = string(cR, 'R') + string(cW, 'W');

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (c[i] != target[i]) {
			ans++;
		}
	}

	cout << ans / 2 << endl;

	return 0;
}


Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string s,t; cin>>s>>t;
    int n=s.size();
    int ans=0;
    rep(i,n){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define DIM (long long)3007
#define INF (long long)100000007

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pairll;

ll n,m,i,j,sum,f1,f2,v1,v2,k,x,y,l;
ll a[DIM];
ll dp[DIM][DIM];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(i=1; i<=n; i++) cin >> a[i];

    for(l=1; l<=n; l++){
        for(i=1; i<=n-l+1; i++){
            dp[l][i]=max(a[l+i-1]-dp[l-1][i],a[i]-dp[l-1][i+1]);

        }
    }

    cout << dp[n][1] << endl;










    return 0;
}


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

int main() {
	int N;
	int num;
	int tmp = 0;
	int result = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> num;
		while (num % 2 == 0) {
			num /= 2;
			tmp++;
		}
	
		if (i == 0) {
			result = tmp;
		}
		else if (result > tmp) {
			result = tmp;
		}
		tmp = 0;
	}
	cout << result << endl;
	return 0;

}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define len(list) sizeof(list)/sizeof(list[0])
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int maxdif(int R[], int n){
    int minv, maxv, j;
    maxv = -2000000000;
    minv = R[0];
    REP(j,1,n){
        maxv = max(maxv, (R[j]-minv));
        minv = min(minv, R[j]);
    }
    return maxv;
}


int main(){
    int i, n;
    scanf("%d", &n);
    int R[n];
    rep(i,n){
        scanf("%d", &R[i]);
    }
    n = len(R);
    printf("%d\n", maxdif(R, n));
    return 0;
}


Measured memory_bytes: 4004
import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()])
mod = 10**9+7
ans = 0

for i in range(60):
    c = np.count_nonzero((A>>i)&1)
    ans += (2 ** i) * c * (N - c)

print(ans%mod)

Measured memory_bytes: 48852
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n,m;
    cin>>n>>m;
    puts( n == m ? "Yes" : "No" );

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000 * 1000 * 1000 + 7;

struct Matrix {
	int n, m; vector<vector<ll>> v; Matrix() {}
	Matrix(vector<vector<ll>> &_v) : n(_v.size()), m(_v.front().size()), v(_v) {}
	Matrix(int _n, int _m, ll _x) : n(_n), m(_m), v(_n, vector<ll>(_m, _x)) {}
	Matrix(int _n) : n(_n), m(_n), v(_n, vector<ll>(_n, 0)) {
		for (int i = 0; i < _n; i++) { v[i][i] = 1; }
	}
	vector<ll>& operator[](int idx) { return v[idx]; }

	Matrix operator *(Matrix &rhs) {
		Matrix res(n, rhs.m, 0);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < rhs.m; j++)
				for (int k = 0; k < m; k++)
					res[i][j] = (res[i][j] + v[i][k] * rhs[k][j]) % mod;
		return move(res);
	}
	Matrix operator ^(ll x) {
		Matrix res(n), a(v); //Change if (*) changes
		for (; x; x >>= 1, a = a * a)
			if (x & 1) { res = res * a; }
		return move(res);
	}
};

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

	int n; ll k; cin >> n >> k; Matrix M(n);
	for (auto &x : M.v) for (auto &y : x) cin >> y;
	
	ll res = 0; M = M ^ k;
	for (auto &x : M.v) for (auto &y : x) res = (res + y) % mod;
	cout << res << '\n'; cin.ignore(2); return 0;
}

Measured memory_bytes: 3664
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(it, 2);
    let MAX = std::usize::MAX / 3;
    let mut dp = vec![MAX; 1 << n];
    dp[0] = 0;
    for _ in 0..m {
        let (a, b): (usize, usize) = parse!(it, 2);
        let c: Vec<usize> = parse!(it, b);
        let c: usize = c.iter().map(|x| 1 << (x - 1)).sum();
        dp[c] = std::cmp::min(dp[c], a);
        for i in 0..(1 << n) {
            dp[i & c] = std::cmp::min(dp[i & c], dp[c]);
        }
        for i in 0..(1 << n) {
            dp[i | c] = std::cmp::min(dp[i | c], dp[i] + dp[c]);
        }
    }
    let v = dp[(1 << n) - 1];
    println!("{}", if v == MAX { -1 } else { v as isize });
}


Measured memory_bytes: 4476
using System;

class Class5
{
    static void Main(string[] args)
    {
        string[] _strinput = Console.ReadLine().Split();
        ulong ul0 = ulong.Parse(_strinput[0]), ul1 = ulong.Parse(_strinput[1]), ul2 = ulong.Parse(_strinput[2]);
        if ((ul0 + ul1) > ul2)
        {
            Console.WriteLine("No");
            return;
        }
        if ((4 * ul0 * ul1 + 2 * ul0 * ul2 + 2 * ul1 * ul2) < (ul0 * ul0 + ul1 * ul1 + ul2 * ul2 + 2 * ul0 * ul1 ))
        {
            Console.WriteLine("Yes");
            return;
        }
        Console.WriteLine("No");
    }
}



Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		scan.close();

		if (-100 <= x && x <= 100 && -100 <= y && y <= 100) {
			if (0 < W && W <= 100 && 0 < H && H <= 100 && 0 < r && r <= 100) {
				if ((x - r) < 0 || (x + r) > W) {
					System.out.println("No");
				} else if ((y - r) < 0 || (y + r) > H) {
					System.out.println("No");
				} else {
					System.out.println("Yes");
				}
			}
		}
	}

}

Measured memory_bytes: 26280
#include<bits/stdc++.h>
#define L long long
using namespace std;
int n,m,x[100010],f[100010],u,v,w,p;
vector<int> a[100010];
inline void dfs(int i)
{
    int j;
    for(j=0;j<a[i].size();j++)
      if(!f[a[i][j]])
        {
         f[a[i][j]]=f[i]^1;
         dfs(a[i][j]);
        }
      else if(f[a[i][j]]==f[i])
        p=1;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	  {
       scanf("%d%d",&j,&k);
       a[j].push_back(k);
       a[k].push_back(j);
      }
    for(i=1;i<=n;i++)
      if(!f[i])
        if(!a[i].size())
          w++;
        else
          {
           f[i]=2;
           p=0;
           dfs(i);
           if(p)
             v++;
           else
             u++;
          }
    printf("%lld\n",(L)n*n-(L)(n-w)*(n-w)+(L)(u+v)*(u+v)+(L)u*u);
	return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,p,r,t;
cin>>n>>m;
p=2*n;
r=4*n;
if((m>=p&&m<=r)&&m%2==0)
cout<<"Yes"<<endl;
else
cout<<"No";
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define fi first
#define se second
#define mod 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
int main()
{
	ios;
	ll x,i,j,d;
	cin>>x;
	for(i=-120;i<=120;i++)
	{
		for(j=-120;j<=120;j++)
		{
			d=pow(i,5)-pow(j,5);
			if(d==x)
			{
				cout<<i<<" "<<j<<endl;
				exit(0);
			}
		}
	}
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
string S;

void solve(){
	if(S[6] <= '4' and S[5] == '0')
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> S;
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> A >> B >> C >> D;
  if (abs(A-C) <= D) cout << "Yes" << endl;
  else if (abs(A-B) <= D && abs(B-C) <=D) cout << "Yes" << endl;
  else cout<<"No" << endl;
}


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

using namespace std;

#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
#define ll long long

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

	int n;
	cin >> n;
	cout << 24 - n + 24;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int N,M;
vector<int> S,T;

Int dp[3000][3000];

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

    for(int i = 0;i < N;i++) {
        int s;
        cin>>s;
        S.push_back(s);
        dp[i+1][0] = 1;
    }

    for(int j = 0;j < M;j++) {
        int t;
        cin>>t;
        T.push_back(t);
        dp[0][j+1] = 1;
    }

    dp[0][0] = 1;
    
    for(int i = 1;i <= N;i++) {
        for(int j = 1;j <= M;j++) {
            dp[i][j] = (dp[i-1][j]+dp[i][j-1] + MOD -dp[i-1][j-1])%MOD;
            if(S[i-1] == T[j-1]) {
                dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % MOD;
            }
        }
    }

    cout<<dp[N][M]<<endl;

    return 0;
}


Measured memory_bytes: 46976
S = list(input())

even_0 = 0
even_1 = 0
odd_0 = 0
odd_1 = 0

for i, value in enumerate(S):
    # 偶数のとき
    if i % 2 == 0:
        if value == "0":
            even_0 += 1
        else:
            even_1 += 1

    # 奇数のとき
    else:
        if value == "0":
            odd_0 += 1
        else:
            odd_1 += 1

print(min(even_0 + odd_1, even_1 + odd_0))

Measured memory_bytes: 3956