akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  string s;
  in(s);
  while(true){
    s.pop_back();
    if(s.size() % 2 == 1)
      continue;
    b = s.size() / 2;
    a = 0;
    rep(i, b){
      if(s[i] != s[i + b])
        a++;
    }
    if(a == 0)
      break;
  }
  out(s.size());
  memi;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n , k ;
int memo[1001][1001];
ll doo (int last , int i )
{
    if( i == n ) return 1 ;
    ll ans =  0 ;
    if(memo[i][last] != -1 ) return memo[i][last] ;
    for(int j= 1 ; j <= k ; j++)
    {
        if(last != j)
           ans+= doo(j , i+1);
    }
    return memo[i] [last] = ans ;
}
int main()
{
 cin >> n >> k ;
 memset(memo , -1 , sizeof(memo) ) ;
 cout << doo(0 , 0) <<endl;





}


Measured memory_bytes: 4224
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    ans = 1
    mod = 1000*1000*1000 + 7
    for i in range(1, n+1):
        ans *= (i%mod)
        ans %= mod
    print(ans)

solve()


Measured memory_bytes: 3060
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=3e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;
int cnt(int x){
    int ret=0;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            ret+=2;
            if(i==x/i)
                ret--;
        }
    }
    return ret;
}
void solve(){
    int n;
    cin>>n;
    int res=0;
    loop(n+1,i,1){
        if(cnt(i)==8)
            res++;
        i++;
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3588
N = int(input())
A = sorted(list(map(int, input().split())) + [0, 0, 0, 0], reverse=True)

res = []
tmp = -1
for a in A:
    if a == tmp:
        res.append(a)
        tmp = -1
    else:
        tmp = a
    if len(res) >= 2:
        break

res = sorted(res, reverse=True)

result = 1
for i in range(2):
    result *= res[i]

print(result)


Measured memory_bytes: 14252
#include <stdio.h>

#define LL long long

/**
 * Return the number of multiples of x in the interval [0, n].
 */
LL num_divisors(LL n, LL x)
{
    return (n >= 0) ? (n/x + 1) : 0;
}

int main(int argc, char **argv)
{
    LL a, b, x;
    scanf("%lld %lld %lld", &a, &b, &x);
    printf("%lld\n", num_divisors(b, x) - num_divisors(a-1, x));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


Vbo rs, rt;
VV to, ot;

void dfs_s(int u) {
  if (rs[u]) return;
  rs[u] = true;
  for (int v : to[u]) dfs_s(v);
}
void dfs_t(int u) {
  if (rt[u]) return;
  rt[u] = true;
  for (int v : ot[u]) dfs_t(v);
}


template<typename T>
struct edge {
  int u, v; T cost;
  edge(int u, int v, T cost) : u(u), v(v), cost(cost) {}
};

template<typename T>
using Edges = vector<edge<T>>;

template<typename T>
vector<T> bellman_ford(Edges<T> &E, int n, int s) {
  const auto INF_T = numeric_limits<T>::max() / 2;
  vector<T> dist(n, INF_T);
  dist[s] = 0;
  for (int i = 0; i < n-1; ++i) {
    for (auto &e : E) chmin(dist[e.v], dist[e.u] + e.cost);
  }
  for (auto &e : E) if (dist[e.u] + e.cost < dist[e.v]) return vector<T>();
  return dist;
}


int main() {
  int n, m; cin >> n >> m;
  ll p; cin >> p;
  to.assign(n, V());
  ot.assign(n, V());
  rs.assign(n, false);
  rt.assign(n, false);

  Vll u(m), v(m), c(m);
  for (int i = 0; i < m; ++i) {
    cin >> u[i] >> v[i] >> c[i];
    --u[i], --v[i];
    to[u[i]].push_back(v[i]);
    ot[v[i]].push_back(u[i]);

  }
  dfs_s(0);
  dfs_t(n-1);

  Edges<ll> E;
  for (int i = 0; i < m; ++i) {
    if (rs[u[i]] && rs[v[i]] && rt[u[i]] && rt[v[i]])
      E.emplace_back(u[i], v[i], p-c[i]);
  }

  auto dist = bellman_ford(E, n, 0);
  if (dist.size() == 0) cout << -1 << "\n";
  else cout << max(-dist[n-1], 0ll) << "\n";
  return 0;
}


Measured memory_bytes: 896
import sys


def main():
    n = int(sys.stdin.readline().strip())
    a = [int(s) for s in sys.stdin.readline().strip().split()]
    # a = [1000] * 100

    multi_all = 1
    for ai in a:
        multi_all *= ai

    divider = 0
    for ai in a:
        divider += multi_all / ai

    print(multi_all / divider)


main()


Measured memory_bytes: 38492
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
tc = 0
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        tc += c[a[i] - 1]
print(sum(b) + tc)


Measured memory_bytes: 3060
import sys

input = sys.stdin.readline


def main():
    S = int(input())

    # X2*Y3-X3*Y2 = S
    #   (X2,Y2) = (10**9,1)
    # 10**9*Y3 - X3 = S
    # S = 10**9*q + r
    #   = 10**9*(q+1) - (10**9-r)
    # (X3,Y3) = (10**9-r, q+1)
    q, r, = divmod(S, 10**9)
    if r == 0:
        X = 0
        Y = q
    else:
        X = 10**9 - r
        Y = q + 1
    ans = [0, 0, 10**9, 1, X, Y]
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


void print_vec(vll a)
{
	cout << "start printing the vector\n";
	for (ll i = 0; i < a.size(); i++)
		cout << a[i] << " ";
	cout << "\n";
}
void print_mat(vector<vll> a)
{
	cout << "start printing the matrix\n";
	for (ll i = 0; i < a.size(); i++)
	{
		for (ll j = 0; j < a[i].size(); j++)
		{
			cout << a[i][j] << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	ll n;
	cin >> n;
	vll arr(n);
	for (ll i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr.begin(), arr.end());
	ll lim = n;
	ll out = arr[n - 1];
	lim--;
	for (ll i = n - 2; i >= 0 and lim > 1; i--)
	{
		out += arr[i];
		lim--;
		if (lim > 1)
		{
			lim--;
			out += arr[i];
		}
	}
	cout << out << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 4780
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD  998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
#define int long long
vector<pair<int,int>> constraints[301];
int dp[301][301][301] = {};
#undef int
int main() {
#define int long long 
	int n, m;
	cin >> n >> m;
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		if (b == 1) {
			if (c != 1) {
				cout << 0 << endl;
				return 0;
			}
		}
		constraints[b].push_back(make_pair(a, c));
	}
	dp[1][0][0] = 1;
	dp[0][1][0] = 1;
	dp[0][0][1] = 1;
	for (int i = 1; i < n; ++i) {
		for (int q = 0; q < i; ++q) {
			for (int j = 0; j < i; ++j) {
				//dp[i][q][j]
				if (dp[i][q][j] != 0) {
					dp[i + 1][q][j] += dp[i][q][j];
					dp[i + 1][q][j] %= MAX_MOD;
					dp[i][i + 1][j] += dp[i][q][j];
					dp[i][i + 1][j] %= MAX_MOD;
					dp[i][q][i + 1] += dp[i][q][j];
					dp[i][q][i + 1] %= MAX_MOD;
				}
				if (dp[q][i][j] != 0) {
					dp[i + 1][i][j] += dp[q][i][j];
					dp[q][i + 1][j] += dp[q][i][j];
					dp[q][i][i + 1] += dp[q][i][j];
					dp[i + 1][i][j] %= MAX_MOD;
					dp[q][i + 1][j] %= MAX_MOD;
					dp[q][i][i + 1] %= MAX_MOD;
				}
				if (dp[q][j][i] != 0) {
					dp[i + 1][j][i] += dp[q][j][i];
					dp[q][i + 1][i] += dp[q][j][i];
					dp[q][j][i + 1] += dp[q][j][i];
					dp[i + 1][q][i] %= MAX_MOD;
					dp[q][i + 1][i] %= MAX_MOD;
					dp[q][j][i + 1] %= MAX_MOD;
				}
			}
		}
		for (int te = 0; te < constraints[i + 1].size(); ++te) {
			for (int q = 0; q <= i; ++q) {
				for (int j = 0; j <= i; ++j) {
					int cnt = 1;
					if (q >= constraints[i + 1][te].first) {
						cnt++;
					}
					if (j >= constraints[i + 1][te].first) {
						cnt++;
					}
					if (cnt != constraints[i + 1][te].second) {
						dp[i + 1][q][j] = 0;
						dp[q][i + 1][j] = 0;
						dp[q][j][i + 1] = 0;
					}
				}
			}
		}
	}
	long long ans = 0;
	for (int q = 0; q < n; ++q) {
		for (int j = 0; j < n; ++j) {
			ans += dp[n][q][j];
			ans += dp[q][n][j];
			ans += dp[q][j][n];
			ans %= MAX_MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

vi a,f,p;
int n;
ll k;

bool solve(ll v){
    ll kk=k;
    for(int i:p){
        ll x=(ll)a[i]*f[i];
        if (x<=v) return true;
        ll j = (x-v)/f[i] + ((x-v)%f[i]!=0);
        if (j>kk) return false;
        kk -= j;
    }
    return true;
}

int main() {
    READ(0);
    cin>>n>>k;
    a.resize(n),f.resize(n),p.resize(n);
    FOR(i,n) cin>>a[i];
    FOR(i,n) cin>>f[i];
    FOR(i,n) p[i]=i;
    sort(a.begin(),a.end());
    sort(f.begin(),f.end(),greater<int>());
    sort(p.begin(),p.end(),[](int x,int y){return (ll)a[x]*f[x]>(ll)a[y]*f[y];});
    ll lo=0,hi=(ll)a[p[0]]*f[p[0]],mid;
    while(lo<hi) {
        mid = lo + (hi - lo) / 2;
        if (solve(mid)) hi=mid;
        else lo = mid + 1;
    }
    cout << lo;
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);

void solve()
{
	double n;
	cin >> n;
	// cout << n / 2 << endl;
	cout << fixed << setprecision(7) << double(int(n / 2 + (int)n % 2)) / double(n);
}
  
int main()
{
    Red;
    solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
A.sort()
B.sort()
C.sort()
C.reverse()
 
ans = 0
ai = 0
ci = N-1
for b in B:
    while ai < N and A[ai] < b:
        ai += 1
    while ci >= 0 and C[ci] <= b:
        ci -= 1
    ans += ai * (ci+1)
 
print(ans)

Measured memory_bytes: 23328
gets

$suits = {}

cards = gets.split.map do |card|
  suit = card[0]
  num = card[1..-1]
  $suits[num] = [] unless $suits.include? num
  $suits[num] << suit
  [suit, num]
end

def bubble_sort(cards)
  (0).upto(cards.length-1) do |i|
    (cards.length-1).downto(i+1) do |j|
      cards[j], cards[j-1] = cards[j-1], cards[j] if cards[j][1] < cards[j-1][1]
    end
  end
  return cards
end

def selection_sort(cards)
  (0).upto(cards.length-1) do |i|
    mini = i
    (i).upto(cards.length-1) do |j|
      mini = j if cards[j][1] < cards[mini][1]
    end
    cards[i], cards[mini] = cards[mini], cards[i]
  end
  return cards
end

def check(cards)
  (1).upto(cards.length-1) do |i|
    return 'Not stable' if cards[i-1][1] == cards[i][1] && $suits[cards[i][1].to_s].index(cards[i][0]) < $suits[cards[i][1].to_s].index(cards[i-1][0])
  end
  return 'Stable'
end

bubble = bubble_sort(cards.clone)
puts bubble.map {|card| card * ''} * ' '
puts check(bubble)

selection = selection_sort(cards.clone)
puts selection.map {|card| card * ''} * ' '
puts check(selection)

Measured memory_bytes: 6128
/*input
6
1 -1000000000 1000000000
1 -1000000000 1000000000
1 -1000000000 1000000000
1 -1000000000 1000000000
1 -1000000000 1000000000
2
*/
#include <bits/stdc++.h>
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }
#endif

void print(multiset<ll> setas) {
	for (auto u : setas)
		printf("%lld\n", u);
	printf("\n");
}

void print(multiset<ll>::iterator &it, multiset<ll> &setas) {
	while (it != setas.end()) {
		printf("%lld ", *it);
		it++;
	}
	printf("\n");
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int Q;
	cin >> Q;
	ll bkai = 0;
	multiset<ll> akai;
	multiset<ll>::iterator it;
	ll pliusas = 0;
	ll minusas = 0;
	for (int i = 0; i < Q; ++i)
	{
		int t; cin >> t;
		if (t == 1) {
			ll a, b;
			cin >> a >> b;
			bkai += b;
			if (akai.empty()) {
				akai.insert(a);
				it = akai.begin();
			} else {
				if (a == *it) {
					it = akai.insert(it, a);
					if ((int)akai.size() & 1) it++;
				} else if (a >= *it) {
					akai.insert(a);
					if ((int)akai.size() & 1) {
						it++;
						pliusas -= *it;
						pliusas += a;
					} else {
						minusas += *it;
						pliusas += a;
					}
				} else {
					akai.insert(a);
					if ((int)akai.size() % 2 == 0) {
						minusas += a;
						pliusas += *it;
						it--;
					} else {
						minusas -= *it;
						minusas += a;
					}
				}
			}
		} else {
			if (akai.empty()) {
				printf("0 0\n");
				continue;
			}
			printf("%lld %lld\n", *it, pliusas - minusas + bkai);
		}
	}
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


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

  if(s.size()%2^(s[0] == s[s.size()-1])) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
    int n;
    cin >> n;
    ll march[5]={};
    int A[10]={0,0,0,0,0,0,1,1,1,2};
    int B[10]={1,1,1,2,2,3,2,2,3,3};
    int C[10]={2,3,4,3,4,4,3,4,4,4};
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        if(s[0]=='M') march[0]++;
        if(s[0]=='A') march[1]++;
        if(s[0]=='R') march[2]++;
        if(s[0]=='C') march[3]++;
        if(s[0]=='H') march[4]++;
    }
    ll res=0;
    for(int i=0; i<10; i++){
        res+=march[A[i]]*march[B[i]]*march[C[i]];
    }
    cout << res << endl;
}
/*
//素因数分解した結果をres[]に入れる
for(int i=2; i<=num; i++){
	while(c%i==0){
		res[i]++;
		c/=i;
	}
}
*/

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define S ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std; 
signed main()
{
    S;
    int n,k,sum=0;
    int a[5];;
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<5;i++)
    {
        if(a[i]==0)
        {
            cout<<i+1;
            break;
        }
    }
    
   
    
}
    

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

int main() {
	int n;
	bool a[4][13];
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 13; j++)
			a[i][j] = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		char c;
		int r;
		cin >> c >> r;
		switch (c) {
		case 'S':
			a[0][r - 1] = false;
			break;
		case 'H':
			a[1][r - 1] = false;
			break;
		case 'C':
			a[2][r - 1] = false;
			break;
		case 'D':
			a[3][r - 1] = false;
			break;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (a[i][j]) {
				switch (i) {
				case 0:
					cout << "S " << j + 1 << endl;
					break;
				case 1:
					cout << "H " << j + 1 << endl;
					break;
				case 2:
					cout << "C " << j + 1 << endl;
					break;
				case 3:
					cout << "D " << j + 1 << endl;
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 3124
#include <cstdio>
int N, M, A, B, ans;
int father[200005], cnt[200005];
int find(int x)
{
	if(father[x]!=x)
	    father[x] = find(father[x]);
	return father[x];
}
int main()
{
	scanf("%d%d", &N, &M);
	for(int i=1;i<=N;i++)
	    father[i] = i;
	for(int i=1;i<=M;i++)
	{
		scanf("%d%d", &A, &B);
		int r1 = find(A), r2 = find(B);
		if(r1!=r2)
		    father[r2] = r1;
	}
	for(int i=1;i<=N;i++)
	{
		int fa = find(i);
		cnt[fa]++;
		if(cnt[fa]>ans)
		    ans = cnt[fa];
	}
	printf("%d\n", ans);
	return 0;
}

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


int main()
{
	int n;
	scanf("%d", &n);
		 
	long long int *a = NULL;
	a = (long long int *)malloc(sizeof(long long int)*n);
	long long int *b = NULL;
	b = (long long int *)malloc(sizeof(long long int)*n);
	int i;
	long long int s = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
		s += a[i];
	 }
	long long int t = 0,m;
		 
	for (i = 0; i<n;i++)
	{
		t += a[i];
		if (s - 2 * t >= 0) b[i] = s - 2 * t;
		else b[i]=2*t-s;
	}
	m = b[0];
	for (i = 0; i < n-1; i++)
		if (b[i] < m)m = b[i];

	
	printf("%lld\n", m);
	free(a);
	free(b);
	return 0;
}

Measured memory_bytes: 3328
import sys


def input():
    return sys.stdin.readline().strip()


def bellman_ford(edges, N, start):
    dist = [float("inf") for _ in range(N)]
    dist[start] = 0
    # 辺の情報を見ることを1ループとすると
    # 1回のループで,最低でも1つの頂点について，スタートからの最短距離が求まる
    # つまり,スタートからの全ての頂点への距離は，
    # スタートを除いた頂点の数である,(N-1)回のループで求まる．
    for i in range(2 * N):
        for fro, to, cost in edges:
            if dist[to] > dist[fro] - cost:
                dist[to] = dist[fro] - cost
                # N回目に頂点の更新があると，負の経路がある
                if i == N - 1:
                    dist[to] = -float("inf")

    return dist


def main():
    N, M, P = map(int, input().split())
    edge = []
    for _ in range(M):
        A, B, C = map(int, input().split())
        edge.append((A - 1, B - 1, C - P))
    dist = bellman_ford(edge, N, 0)

    if dist[-1] == -float("inf"):
        print(-1)
    else:
        if dist[-1] > 0:
            print(0)
        else:
            print(-1 * dist[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 45040
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=500010;
struct water{
	double t;
	int v;
	inline friend water operator + (const water &a,const water &b){
		int sum=a.v+b.v;
		if(sum==0)return (water){0,0};
		return (water){a.t*((double)a.v/sum)+b.t*((double)b.v/sum),sum};
	}
	inline void operator += (const water &b){
		*this=*this+b;
	}
	inline void operator -= (const water &b){
		*this+=(water){b.t,-b.v};
	}
}que[N],cur;
int main(){
	int n=ni,v=ni;
	int qh=0,qt=0;
	for(int i=1;i<=n;i++){
		water a=(water){(double)ni,ni};
		for(;cur.v+a.v>v&&cur.v+a.v-que[qh].v>=v;cur-=que[qh++]);
		if(cur.v+a.v>v){
			que[qh].v-=cur.v+a.v-v;
			cur-=(water){que[qh].t,cur.v+a.v-v};
		}
		cur+=a;
		printf("%.10lf\n",cur.t);
		for(;qh<qt&&que[qt-1].t>a.t;a+=que[--qt]);
		que[qt++]=a;
	}
	return 0;
}

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

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

  int R; cin >> R;

  printf("%lf\n", 2 * M_PI * R);

  return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;

int main()
{
    int ans = 0, tap = 1, a, b;
    cin >> a >> b;
    while (tap < b)
    {
        tap += a - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a), end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

int main()
{   _
    string s; cin >> s;
    lli cnt = 0;
    for(char c : s) cnt += c - '0';
    cout << (cnt % 9 ? "No" : "Yes") << ENDL;
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define FASTBOI ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pll pair<long long, long long>
#define ll long long
#define f first
#define s second
#define mod 1000000007
const int inf = 1e9;

using namespace std;

int main()
{
	FASTBOI;
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 1000;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//ll P[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//int A[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//int B[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//double Perf[NM];

ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program


struct Info
{
    int A;
    int B;
    double Perf;

    bool operator<(const Info& another) const
    {
        return Perf == another.Perf ? A < another.A : Perf < another.Perf;//年齢を比較
    };
    //2つのconstを付けないとコンパイルエラーになるので注意!!
};


void solve() {
    ll  A,B,C;
    cin >> A >> B >> C;

    bool flag = false;
    if (A == B && A != C) {
        flag = true;
    }
    else if (A == C && A != B) {
        flag = true;
    }
    else if (B == C && A != B) {
        flag = true;
    }

    if (flag) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return;

}



int main() {
    solve();
    return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll n;
   cin>>n;
   
   ll ans = ((n+999)/1000)*1000 - n;
   cout<<ans;
   
   return 0;        
}  
  
          
   

Measured memory_bytes: 3648
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;

ll ans[101][101];
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll h,w,n;
  std::cin>>h>>w>>n;
  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];
  ll sum=-1;
  rep(i,0,n){
    rep(j,0,a[i]){
      sum++;
      ll x=sum/w;
      ll y = (x % 2) ? w - 1 - (sum % w) : sum % w;
      ans[x][y]=i+1;
    }
  }

  rep(i,0,h){
    rep(j,0,w){
      std::cout<<ans[i][j];
      if(j!=w-1)std::cout<<" ";
    }
    if(i!=h-1)std::cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

typedef long long ll;
#define IMF 1000000007

int main(void){
  ll n;
  scanf("%lld",&n);
  
  ll ans = 0;
  ll dai = 1 , syou = 1 , tyu = 1;
  int count = 0;
  if(n == 1){
    ans = 0;
  }

  else{
    int count = 0;
    while(count < n){
      dai *= 10;
      dai %= IMF;
      syou *= 8;
      syou %= IMF;
      tyu *= 9;
      tyu %= IMF;
      count ++;
    }
     ll tyu2 = tyu*2;
     tyu2 %= IMF;
     ll hiku = tyu2 - syou;
     if(hiku < 0){
       hiku += IMF;
     }
    ans = dai - hiku;
    if(ans < 0){
      ans += IMF;
    }
  }
  
  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 1720
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int x = Integer.parseInt(sc.next());
    int ans = 0;
    for (int i = 0; i < a+1; i++){
      for (int j = 0; j < b+1; j++){
        for (int k = 0; k < c+1; k++){
          int temp = 500*i + 100*j + 50*k;
          if (temp == x){ans += 1;}
        }
      }
    }
    System.out.println(ans);
    
  }
}


Measured memory_bytes: 35688
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<unordered_map>
#include<queue>
#define rep(i,n) for(i=0;i<n;++i)

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};


int main(){

  string s;
  int a,b,c,i,j,k,n,ans,m,d,d1,d10;
  vector<string> vs;
  vector<int> vi;
  pair<int,int> pr;

  //unordered_map<string,int> mp;

  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst pq;

  cin >> m >> d;
  ans = 0;
  for(i=1;i<=m;++i){
    for(j=10;j<=d;++j){
      
      d1 = j % 10;
      d10 = j/10;
      if(d1*d10 == i && d1 > 1 && d10 > 1){
        ++ans;
     //   cout << i << " " << j << " " << d1 << " "<< d10 << endl;
      }
    }
  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
int cmpfunc (const void * a, const void * b) {
  return ( *(int*)a - *(int*)b );
}
int main(){
  int N, A[200001];
  scanf("%d", &N);
  for(int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  
  qsort(A, N, sizeof(int), cmpfunc);
  for(int i=0; i<N-1; i++){
    if(A[i]==A[i+1]){
      printf("NO");
      return 0;
    }
  }
  
  printf("YES");
  return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
vector<long long> ans(50,-1);
long long fib(int n){
    if(ans[n]!=-1) return ans[n];
    if(n==0 || n==1) return ans[n] = 1;
    return ans[n] = fib(n-1)+fib(n-2);
}
int main(void){
    int n;cin >> n;
    cout << fib(n) << endl;
    return 0;
}



Measured memory_bytes: 3100
#include<iostream>
using namespace std;
char a[1000][1000];
int main()
{
	int h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=h;i++)
	{
		int check=1;
		for(int j=1;j<=w;j++)
		{
			if(a[i][j]=='#')
			{
				check=0;
				break;
			}
		}
		if(check==1)
		{
			for(int j=1;j<=w;j++)
		  {
			   a[i][j]='0';
		  }
		}
	}
	for(int i=1;i<=w;i++)
	{
		int check=1;
		for(int j=1;j<=h;j++)
		{
			if(a[j][i]=='#')
			{
				check=0;
				break;
			}
		}
		if(check==1)
		{
			for(int j=1;j<=h;j++)
		  {
			   a[j][i]='0';
		  }
		}
	}
	for(int i=1;i<=h;i++)
	{
		int check=0;
		for(int j=1;j<=w;j++)
		{
			if(a[i][j]=='0')
			continue;
			else
			{
			   cout<<a[i][j];	
			   check=1;
			}
		}
		if(check==1)
		cout<<endl;
	}
}

Measured memory_bytes: 384
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

string S;
int cnt = 0;
int flag = 0;

int sizeOfString;

int main()
{
	cin >> S;
	sizeOfString = S.size();
	int i = 0;
	int j = S.size() - 1;

	while(i != j)
	{
		if(S[i] == S[j])
		{
			i++;
			j--;
			if(i > j)
			{
				break;
			}
		}
		else if(S[i] == 'x' && S[i] != S[j])
		{
			// if(flag == 0 && S[0] != 'x' && S[sizeOfString - 1] != 'x')
			// {
			// 	cnt += 2;
			// 	flag = 2;
			// }
			i++;
			cnt++;
		}
		else if(S[j] == 'x' && S[i] != S[j])
		{
			// if(flag == 0 && S[0] != 'x' && S[sizeOfString - 1] != 'x')
			// {
			// 	cnt += 2;
			// 	flag = 2;
			// }
			j--;
			cnt++;
		}
		else if(S[j] != S[i] && S[i] != 'x' && S[j] != 'x')
		{
			flag = 1;
			break;
		}
	}
	if(flag == 1)
	{
		printf("-1\n");
	}
	else
	{
		printf("%d\n", cnt);
	}
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 512
#include <stdio.h>
int main(){
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	bool sw;
	if(y<2019) sw=1;
	else if(y>2019) sw=0;
	else{
		if(m<4) sw=1;
		else if(m>4) sw=0;
		else{
			if(d<=30) sw=1;
			else sw=0;
		}
	}
	printf("%s",sw?"Heisei":"TBD");
}

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

using namespace std;
#define  ll  long long
#define f first
#define s second
#define matrix vector<vector<ll>>
#define zero(n,m) matrix(n , vector<ll>(m,0))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<ll,ll>
const int N = 1e6+5;

int n , a[N] , tmp , cnt[N];
vector<int> v[N];

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

    for(int i=1; i<N; i++)
    {
        tmp = i;
        if (tmp%2==0)
        {
            v[i].push_back(2);
            while(tmp%2==0) tmp /= 2;
        }
        for(int j=3; j*j<=tmp; j++)
        {
            if (tmp%j==0)
            {
                v[i].push_back(j);
                while(tmp%j==0) tmp /= j;
            }
        }
        if (tmp > 2) v[i].push_back(tmp);
    }

    cin >> n;
    int co=1 , gc=0 , setwist=1;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        gc = __gcd(gc , a[i]);

        for(auto j : v[a[i]])
        {
            cnt[j]++;
            if (cnt[j] > 1) co=0;
        }
    }

    if (co) cout << "pairwise coprime\n";
    else if (gc==1) cout << "setwise coprime\n";
    else cout << "not coprime\n";

    return 0;
}



Measured memory_bytes: 66752
#include<iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
  int a,b,h,m;
  cin >> a >> b >> h >> m;

  long double rad = (m*6.0 - (h*30.0 + m*0.5)) * M_PI / 180.0;
  long double ans;
  ans = sqrt(a*a + b*b - 2*a*b*cos(rad));
  cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 3516
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 22 21:03:45 2020

@author: NEC-PCuser
"""

N = input()

sum_c = 0
for c in N:
	sum_c += int(c)

if (sum_c % 9 == 0):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9212
N, K = map(int,input().split())
t = list(map(int,input().split()))
#t.insert(0,0)
#tmp=1
h={1}
g=[1]
for i in range(N):
    x=t[g[i]-1]
    g.append(x)
    #print(x)
    #print(h)
    if x in h:
        break
    h.add(x)
#print(h,g,x)
if K>len(g):
    a=g.index(g[-1])
    #print(a)
    b=len(g)-a-1
    #print(b)
    K=(K-a)%b+a
print(g[K])

Measured memory_bytes: 32316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;cin>>S;
    for(int i = 0; i < S.size(); i++)
    {
    if (S.at(i)=='1') {
        S.at(i)='9';
    }
    else if(S.at(i)=='9')
    S.at(i)='1';
    }
    
   cout<<S<<endl;
    
    
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{

	public static void main(String[]arg) throws IOException{
		new Main().read();
	}

	public void read() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int N,A;
		N = Integer.parseInt(in.readLine());
		A = Integer.parseInt(in.readLine());
		System.out.println(N*N - A);
	}
}

Measured memory_bytes: 21076
#include<bits/stdc++.h> 
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define ull unsigned long long
#define ll long long
void codeforces()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.in", "w", stdout);
    #endif
}

int32_t main()
{
    //codeforces();
    // int t;cin>>t;
    // while(t--){
       
    // }

    int n;cin>>n;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        mp[s]++;
    }
    cout<<mp.size()<<endl;
    return 0;
}

Measured memory_bytes: 19120
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,int> P;
typedef vector<pair<ll,ll>> vep;
const ll mod=998244353;
const ll INF=1e15;
const int BIG=1e7;
struct edge{int to;ll cost;};


ll ans[100001];
bool used[100001];
vector<P> d[100001];


int main(){
    int N,M; cin>>N>>M;
    
    for(int i=2;i<=N;i++) d[i].push_back(make_pair(0,i-1));
    for(int i=0;i<M;i++){
        int L,R; ll C; cin>>L>>R>>C;
        d[L].push_back(make_pair(C,R));
    }
    //cout<<"inputend"<<endl;

    priority_queue<P, vector<P>, greater<P> > Q;
    for(int i=2;i<=N;i++) ans[i]=INF;
    used[1]=true;
    Q.push(make_pair(0,1));

    while(!Q.empty()){
        P p=Q.top(); Q.pop();
        int v=p.second;
        if(ans[v]<p.first) continue;
        for(int i=0;i<d[v].size();i++){
            ll c=d[v].at(i).first;
            int t=d[v].at(i).second;
            if(ans[t]>ans[v]+c){
                ans[t]=ans[v]+c;
                Q.push(make_pair(ans[t],t));
            }
        }
    }

    if(ans[N]<INF) cout<<ans[N]<<endl;
    else cout<<-1<<endl;
    

    
}



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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, a, b, c, d;
char s[max_n];

bool ok(int a, int b) {
    for (int i = a; i < b; ++i) {
        if (s[i] == '#' && s[i + 1] == '#') {
            return false;
        }
    }
    return true;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d%d%d%d%s", &n, &a, &b, &c, &d, s);
    --a;
    --b;
    --c;
    --d;
    if (c < d) {
        if (ok(a, c) && ok(b, d)) {
            puts("Yes");
        } else {
            puts("No");
        }
        return 0;
    }
    if (!ok(b, d) || !ok(a, c)) {
        puts("No");
        return 0;
    }
    for (int i = b; i <= d; ++i) {
        if (s[i] == '.') {
            if (s[i - 1] == '.' && s[i + 1] == '.') {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import math

N, P = list(map(int, input().split()))
a_list = list(map(int, input().split()))

odd_n = 0
even_n = 0

for a in a_list:
    if a % 2 == 0:
        even_n += 1
    else:
        odd_n += 1


def C(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


if P == 0:
    odd_p = 1
    if odd_n > 0:
        # 偶数個選ぶ組み合わせ
        for i in range(2, odd_n + 1, 2):
            odd_p += C(odd_n, i)
    even_p = 2 ** even_n
    p = odd_p * even_p
else:
    odd_p = 0
    if odd_n > 0:
        # 奇数個選ぶ組み合わせ数
        for i in range(1, odd_n + 1, 2):
            odd_p += C(odd_n, i)

    even_p = 2 ** even_n
    p = odd_p * even_p

ans = p

print(ans)


Measured memory_bytes: 3064
w,h,n = map(int,input().split())
b,c,d,e = 0,w,0,h
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        b = max(b,x)
    elif a == 2:
        c = min(c,x)
    elif a == 3:
        d = max(d,y)
    else:
        e = min(e,y)
print(max(c-b,0)*max(e-d,0))

Measured memory_bytes: 9236
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
inline LL read(){
	LL x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const LL MAXN = 100010;
const LL INF = 2147483600;

LL N;
LL opr[MAXN+1];
LL a[MAXN+1],f[MAXN+1][201];

inline LL fan(LL x,LL c){
	if(c&1) return -x; return x;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); 
	for(LL i=1;i<=N;i++){
		a[i]=read(); char c;
		if(i<N){
			c=getchar();
			getchar();
			opr[i+1]=(c=='+'?1:-1);
		}
	} memset(f,-127,sizeof(f));
	opr[1]=1; f[0][0]=0;
	for(LL i=1;i<=N;i++){
		for(LL j=0;j<=min(N,200LL);j++){
			if(j>0&&opr[i]==-1) f[i][j]=f[i-1][j-1]+fan(opr[i],j-1)*a[i];
			if(j<200&&j<N) f[i][j]=max(f[i][j],f[i-1][j+1]+fan(opr[i],j+1)*a[i]);
			f[i][j]=max(f[i][j],f[i-1][j]+fan(opr[i],j)*a[i]);
		}
	}
	for(LL i=0;i<=200LL;i++) f[N][0]=max(f[N][0],f[N][i]);
	printf("%lld\n",f[N][0]);
	return 0;
}


Measured memory_bytes: 158848