akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <climits>
#include <utility>
#include <map>
#include <set>
#include <complex>
#include <numeric>

#include <time.h>
#include <float.h>

#define loop(i, n) for(i = 0; i < n; i++)
#define loop1(i, n) for(i = 1; i <= n; i++)
#define loop2(i, n, start) for(i = start; i <= n; i++)
#define loopIterators(it, vec) for(it = (vec).begin(); it != (vec).end(); it++)
#define loopRev(i, n) for(i = (n - 1); i >= 0; i--)
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCases(t) cin >> t; while(t--)
#define PN(n) cout << (n)
#define PN1(n) cout << (n) << " "
#define PN2(a, b) cout << (a) << " " << (b) << " "
#define PNN1(n) cout << (n) << endl
#define PNN2(a, b) cout << (a) << " " << (b) << endl
#define PNN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define PrintArray(ar, n) for(i = 0; i < n; i++) cout << ar[i] << " "; cout << endl
#define PrintSet(ar, it) for(it = ar.begin(); it != ar.end(); it++) cout << *it << " "; cout << endl
#define PrintMap(map, it) for(it = map.begin(); it != map.end(); it++) PNN2(it -> first, it -> second)
#define sz(a) sizeof(a)
#define IN1(n) cin >> n
#define IN2(a, b) cin >> a >> b
#define IN3(a, b, c) cin >> a >> b >> c
#define ALL(s) s.begin(), s.end()
#define SWAP(a, b, c) c = a; a = b; b = c
#define STRSP(s) scanf("%[^\n]%*c", s)
#define ENTER PNN1("");
#define MOD7 1000000007
#define MOD9 10000009
#define MAX 100005
#define llPair std::pair<lli, lli>
#define iiPair std::pair<int , int>
#define ONLINE_JUDGE

typedef long long int lli;
typedef long int li;
typedef unsigned long long int ulli;
typedef long double ld;

using namespace std;

int main(void){
	FLASH

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

	lli n, a, b;
	IN3(n, a, b);
	lli pair = a + b;

	lli ans = n / pair * a;
	ans += std::min(n % pair, a);

	PNN1(ans);

	#ifndef ONLINE_JUDGE
		fclose(stdin);
    fclose(stdout);
	#endif

	return 0;
}


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

using namespace std;

int main() {

	long  n,k;

	cin >> n >> k;

	vector<long> h(n + 1);

	for (long i = 0; i < n; i++) {

		cin >> h[i];

	}

	sort(h.begin(), h.end());

	long long total = 0;
	for (long i = 0; i < n - k+1; i++) {
		total += h[i];
	}

	cout << total << endl;

	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    vector<bool> x;
    x.resize(n, false);

    rep(i, 0, k)
    {
        int d;
        cin >> d;
        rep(j, 0, d)
        {
            int a;
            cin >> a;
            --a;
            x[a] = true;
        }
    }

    int ans = 0;
    rep(i, 0, n)
    {
        if (x[i] == false)
            ++ans;
    }

    cout << ans << '\n';
}

Measured memory_bytes: 3648
// 解答不能(※正答／誤答のロジック差分が, 全く分からなかった, とりあえず, 解法暗記).
// outline氏.
// https://atcoder.jp/contests/abc144/submissions/8181484
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL INF = 1e12 + 1;

int n;
LL k;
vector<LL> a, f;

bool C(LL x){
    LL res = 0;
    for(int i = 0; i < n; ++i){
        LL tx = a[i], ty = f[i];
        if(tx * ty > x) res += (LL)ceil((double)(tx * ty - x) / ty);
    }
    return res <= k;
}

int main(){
    scanf("%d %lld", &n, &k);
    for(int i = 0; i < n; ++i){
        int tmp;
        scanf("%d", &tmp);
        a.push_back(tmp);
    }
    for(int i = 0; i < n; ++i){
        int tmp;
        scanf("%d", &tmp);
        f.push_back(tmp);
    }
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<LL>());
    
    LL lb = -1, ub = INF;
    while(ub - lb > 1){
        LL mid = (ub + lb) / 2;
        if(C(mid)) ub = mid;
        else       lb = mid;
    }
    printf("%lld\n", ub);
    return 0;
}

Measured memory_bytes: 4848
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;

int main(){
    while(true){
        
        stack<int> s;
        int n,r;
        cin >> n >> r;
        
        if(n==0 && r==0){break;}
        
        for(int i=0; i<n; i++){
            s.push(i+1);
        }

        for(int i=0; i<r; i++){
            int p,c;
            cin >> p >> c;
            
            
            stack<int> a;
            stack<int> b;
            
            for(int i=0; i<p-1; i++){
                a.push(s.top());
                s.pop();
            }
            for(int i=0; i<c; i++){
                b.push(s.top());
                s.pop();
            }
            
            while(!a.empty()){
                s.push(a.top());
                a.pop();
            }
            
            while(!b.empty()){
                s.push(b.top());
                b.pop();
            }
        }
        
        cout<<s.top()<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3000
fun main(arg: Array<String>) {
    val (sx, sy, tx, ty) = listOfInt()
    val sb = StringBuilder()

    sb.append("U".repeat(ty - sy))
    sb.append("R".repeat(tx - sx))

    sb.append("D".repeat(ty - sy))
    sb.append("L".repeat(tx - sx))

    sb.append("L".repeat(1))
    sb.append("U".repeat(ty - sy + 1))
    sb.append("R".repeat(tx - sx + 1))
    sb.append("D".repeat(1 ))

    sb.append("R".repeat(1))
    sb.append("D".repeat(ty - sy + 1))
    sb.append("L".repeat(tx - sx + 1))
    sb.append("U".repeat(1 ))

    val ans = sb.toString()
    println(ans)
}

fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map(String::toLong)
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }


Measured memory_bytes: 36040
program bulletin;
	var n,k,m,i : integer;
begin
	m := 1;
	readln(n);
	readln(k);
	for i:=1 to n do
	begin 
		if (m+m) <= (m+k) then
		m := m+m 
		else m := m+k;
	end;
	writeln(m);
end.

Measured memory_bytes: 128
use std::io::{stdin, BufRead};

fn main() {
    let ans = solve();
    println!("{}", ans.map(|n| n as i32).unwrap_or(-1));
}
fn solve() -> Option<u32> {
    let stdin = stdin();
    let mut stdinlock = stdin.lock();
    let mut nm = String::new();
    let _ = stdinlock.read_line(&mut nm).expect("read line!");
    let n: usize = nm
        .trim()
        .split_whitespace()
        .take(1)
        .map(|n| n.parse().expect("N"))
        .next()
        .expect("N");
    let mut digits: Vec<Option<u8>> = vec![None; n];
    for line in stdinlock.lines().map(|l| {
        (&l.expect("ln"))
            .trim()
            .split_whitespace()
            .map(|x| x.parse::<u8>().expect("parse"))
            .collect::<Vec<_>>()
    }) {
        let d = digits.get_mut(line[0] as usize - 1).expect("Get error");
        if let Some(dig) = d {
            if dig != &line[1] {
                return None;
            }
        } else {
            *d = Some(line[1]);
        }
    }
    if digits[0].is_none() {
        digits[0] = Some(if n == 1 { 0 } else { 1 });
    } else if digits[0] == Some(0) && n != 1 {
        return None;
    }
    let mut ans = 0;
    for &digit in &digits {
        ans *= 10;
        ans += digit.unwrap_or(0) as u32;
    }
    Some(ans)
}


Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int t1,t2,a1,a2,b1,b2,sa,res;
string str;
int main() {
	cout << fixed << setprecision(18);
	cin>>t1>>t2>>a1>>a2>>b1>>b2;
	if(t1*a1+t2*a2==t1*b1+t2*b2){
		cout<<"infinity";
		return 0;
	}
	if(t1*a1+t2*a2<t1*b1+t2*b2){
		swap(a1,b1);
		swap(a2,b2);
	}
	if((a1-b1)>0&&(a2-b2)>0){
		cout<<0;
		return 0;
	}
	
	if(a1>b1){
		cout<<0;
		return 0;
	}
	sa=t1*a1+t2*a2-(t1*b1+t2*b2);
	res=(t1*(b1-a1))/sa;
	if(sa*res==t1*(b1-a1)){
		res=2*res;
	}else{
		res=2*res+1;
	}
	
	//cout<<"sa"<<sa<<endl;
	//cout<<"t1(b1-a1)"<<t1*(b1-a1)<<endl;
	if(res<=0){res=0;}
	cout<<res;
} 


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

long long sut = 0;
const int typeNum = 26;
vector<vector<long long> > table;

long long last(long long d, long long i) {
    return table[i][d];
};

void solve(long long D, std::vector<long long> c, std::vector<std::vector<long long> > s){
    // make table
    for (int i=0;i<typeNum;++i) {
        table.push_back(vector<long long>(D));

        for (int j=0;j<D; ++j) {
            table[i][j] = -1;
        }
    }
 
    vector<long long> t = vector<long long>(D);
    int i=0;
    for (auto &tt : t) {
      tt = i + 1;
      i = (i + 1) % typeNum;
    }

    for (int i=0; i<D; ++i) {
        vector<long long> &target = table[t[i] - 1];
        for (int j=i; j<target.size() ;++j) {
            target[j] = i;
        }
    }

    // for (int i=0; i<table.size(); ++i) {
    //     cout << i << '\t';
    //     for (int j=0; j<table[i].size(); ++j) {
    //         cout << table[i][j] << ',';
    //     }
    //     cout << endl;
    // }

    for (int d = 0; d < D; ++d) {
        sut += s[d][t[d] - 1];

        // minus
        for (int i=0;i<typeNum;++i) {
            sut -= c[i] * (d - last(d, i));
        }

        // todays sutisfuction
        //cout << sut << endl;
    }

    // result sutisfuction
    //cout << sut << endl;

    for (auto &tt : t) {
      cout << tt << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long D;
    scanf("%lld",&D);
    std::vector<long long> c(26);
    for(int i = 0 ; i < 26 ; i++){
        scanf("%lld",&c[i]);
    }
    std::vector<std::vector<long long> > s(D, std::vector<long long>(26));
    for(int i = 0 ; i < D ; i++){
        for(int j = 0 ; j < 26 ; j++){
            scanf("%lld",&s[i][j]);
        }
    }
    solve(D, std::move(c), std::move(s));
    return 0;
}


Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B;
    cin >> N >> A >> B;
    A--; B--;
    vvec<int> g(N);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vec<int> dA(N,0),dB(N,0);
    auto dfs = [&](auto&& self,int cur,int par,vec<int>& d)->void{
        for(auto& to:g[cur]) if(to!=par){
            d[to] = d[cur]+1;
            self(self,to,cur,d);
        }
    };
    dfs(dfs,A,-1,dA);
    dfs(dfs,B,-1,dB);
    int ans = 0;
    for(int i=0;i<N;i++) if(dA[i]<=dB[i]){
        ans = max(ans,dB[i]-1);
    }
    cout << ans << "\n";
}

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

using namespace std;
#define N 100010
ll n,w,f[N];
int main(){
    cin>>n>>w;
    for(int i=0;i<=w;i++)f[i]=0;
    for(int u=0;u<n;u++){
     ll a,b;cin>>a>>b;
     for(int i=w;i-a>=0;i--){
      f[i]=max(f[i],f[i-a]+b);   
     }
    }
    cout<<f[w]<<endl;
 return 0;   
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

vector<int> G[105];
int d[105];

int main()
{
    int n; cin >> n;
    for(int i = 0; i< n; i++){
        int u,k;
        cin >> u >> k;
        u--;
        for(int j = 0; j < k; j++){
            int x; cin >> x;
            x--;
            G[u].push_back(x);
        }
    }
    for(int i = 0; i < 105; i++){
        d[i] = -1;
    }
    queue<int> q;
    d[0] = 0;
    q.push(0);
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int i = 0; i < G[u].size(); i++){
            int nv = G[u][i];
            if(d[nv] == -1){
                d[nv] = d[u] + 1;
                q.push(nv);
            }
        }
    }
    for(int i = 0; i < n; i++){
        cout << i+1 << ' ' << d[i] << endl;
    }
} 


Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end(), std::greater<int>());
    int ans = 0;
    for (int i = 0; i < k; i++)
    {
        ans += a[i];
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 3572
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

int main() {
  ll x, sum = 101, y = 1;
  cin >> x;
  while (sum < x) {
    sum += sum / 100;
    y++;
  }
  cout << y << endl;
}


Measured memory_bytes: 3584
// F - Enclosed Points
#include <bits/stdc++.h>

using namespace std;

#define	MOD	998244353

long long mpow(long long x, long long n)
{
	long long r = 1;
	for ( ; n > 0; x = x * x % MOD, n >>= 1) if (n & 1) r = r * x % MOD;
	return r;
}

void fen_update(vector<int> &tree, int i, int val)
{
	for ( ; i > 0 && i < tree.size(); i += i & -i) tree[i] += val;
}

int fen_get(vector<int> &tree, int i)
{
	int sum = 0;
	for ( ; i > 0; i &= i - 1) sum += tree[i];
	return sum;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	long long n;
	cin >> n;
	vector<int> b;
	vector<pair<int, int> > a(n);
	for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second, b.push_back(a[i].second);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	map<int, int> m;
	for (int i = 0; i < b.size(); i++) m[b[i]] = i;

	vector<long long> tp(n + 1, 1);
	for (int i = 1; i <= n; i++) tp[i] = tp[i - 1] * 2 % MOD;

	long long ans = n * tp[n - 1] % MOD;

	vector<int> l(n + 1), r(n + 1);
	for (int i = 0; i < n; i++)  fen_update(r, i + 1, 1);

	for (int i = 0; i < n; i++) {
		int y = m[a[i].second];
		fen_update(r, y + 1, -1);
		long long l1 = fen_get(l, y), l2 = i - l1;
		long long r1 = fen_get(r, y), r2 = n - 1 - i - r1;
		long long t1 = (tp[l1] - 1 + MOD) % MOD * (tp[r2] - 1 + MOD) % MOD * tp[l2 + r1] % MOD;
		long long t2 = (tp[l2] - 1 + MOD) % MOD * (tp[r1] - 1 + MOD) % MOD * tp[l1 + r2] % MOD;
		long long d = (tp[l1] - 1 + MOD) % MOD * (tp[r2] - 1 + MOD) % MOD * (tp[l2] - 1 + MOD) % MOD * (tp[r1] - 1 + MOD) % MOD;
		ans = (ans + t1 + t2 -d + MOD) % MOD;
		fen_update(l, y + 1, 1);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 15092
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)

ll X;

void solve() {
  ll ans = X / 11;
  X = X - 11 * ans;
  ans *= 2;
  ans += (X + 5) / 6;

  printf("%lld\n", ans);
}

int main() {
  scanf("%lld", &X);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll x = 1;
int main(){
	cin>>n;
	rep(i,n){
		ll a; cin >> a;
		ll y = __gcd(x,a);
		x/=y;
		x*=a;
	}
	cout << x << endl;
}

Measured memory_bytes: 256
import bisect

def calc_distance(frm, x, y):
	#frmからx, yのに地点を通るのに必要な距離を計算する
	return min(abs(frm - x), abs(frm - y) ) + abs(x - y)

def calc_both_end(frm, us):
	#地点frmに囲まれた2点を返す。
	#片側しか囲われていない場合は最寄の2点
	if len(us) == 1:
		return us[0], us[0]

	idx = bisect.bisect_left(us, frm)
	if idx == 0:
		return us[0], us[1]
	elif idx == len(us):
		return us[len(us) - 2], us[len(us) - 1]
	else:
		return us[idx - 1], us[idx]

def find(ss, ts, x):
	s1, s2 = calc_both_end(x, ss)
	t1, t2 = calc_both_end(x, ts)
	ans = min(calc_distance(x, s1, t1), calc_distance(x, s1, t2), calc_distance(x, s2, t1), calc_distance(x, s2, t2))
	return ans

a, b, q = list(map(int, input().split()))
ss = [int(input()) for _ in range(a)]
ts = [int(input()) for _ in range(b)]
xs = [int(input()) for _ in range(q)]

for x in xs:
	print(find(ss, ts, x))

Measured memory_bytes: 16168
import java.util.Scanner;
public class Main{
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String[] input;
	int[] hand = new int[15];
	int n, fourCard, threePair, twoPair;
	boolean straight;
	while (scan.hasNext()) {
	    input = scan.nextLine().split(",");
	    for (int i = 0; i < 15; i++) {
		hand[i] = 0;
	    }
	    fourCard = 0;
	    threePair = 0;
	    twoPair = 0;
	    straight = false;
	    for (int i = 0; i < 5; i++) {
		n = Integer.parseInt(input[i]);
		hand[n]++;
		if (n == 1) {
		    hand[14]++;
		}
	    }
	    for (int i = 0; i < 14; i++) {
		if (hand[i] == 4) {
		    fourCard++;
		} else if (hand[i] == 3) {
		    threePair++;
		} else if (hand[i] == 2) {
		    twoPair++;
		}
	    }
	    if (fourCard == 1) {
		System.out.println("four card");
	    } else if (threePair == 1 && twoPair == 1) {
		System.out.println("full house");
	    } else if (threePair == 1 && twoPair == 0) {
		System.out.println("three card");
	    } else if (twoPair == 2) {
		System.out.println("two pair");
	    } else if (twoPair == 1) {
		System.out.println("one pair");
	    } else {
		if (isStraight(hand)) {
		    System.out.println("straight");
		} else {
		    System.out.println("null");
		}
	    }
	}
    }
    static boolean isStraight (int[] hand) {
	int num = 15;
	int first = 1;
	for (int i = 10; i < 25; i++) {
	    int card1 = hand[i % num];
	    int card2 = hand[(i + 1) % num];
	    int card3 = hand[(i + 2) % num];
	    int card4 = hand[(i + 3) % num];
	    int card5 = hand[(i + 4) % num];
	    if (card1 == 1 && card1 == card2 && card2 == card3 && card3 == card4 && card4 == card5) {
		return true;
	    }
	}
	return false;
    }
}

Measured memory_bytes: 26132
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, a[N], ans;
map<ll,int>cnt;
main() {
  file("threesum");
  ios;
  cin >> n;
  fo(i, 1, n, 1) cin >> a[i];//, cerr << "CHH " << a[i] + i << " " << i - a[i] << "\n";
//  ordered_set<pii> st;
  fo(i, 1, n, 1) {
    int val = i - a[i];
    ans += cnt[val];
    ++cnt[a[i]+i];
    /*
    int f = st.order_of_key({val, 0});
    int cnt = 0;
    auto it = st.find_by_order(f+1);
    cerr << "CH " << i << " " << f << " " << it->F << " " << val << "\n";
    if (it->F == val) ans += it->S, cnt = it->S, st.erase(it);
    st.ins({a[i] + i, cnt + 1});*/
  }
  cout << ans;
  return 0;
}
/**
j - i == a[i] + a[j]
j - a[j] == a[i] + i

4 - 1 == 2 + 1

*/


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

int main() {
    int H,W,N; cin >> H >> W >> N;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int Canvas[H][W];
    int Color = 1;
    int temp = 0;
    for (int h = 0; h < H; h++)
    {
        for (int w = 0; w < W; w++)
        {
            int wx;
            if(h%2 == 0) wx = w;
            else wx = W-1-w;
            Canvas[h][wx] = Color;
            temp++;
            if(temp == A[Color-1]){
                Color++;
                temp = 0;
            }
        }
        
    }
    for (int h = 0; h < H; h++)
    {
        for (int w = 0; w < W-1; w++)
        {
            cout << Canvas[h][w] << " ";
        }
        cout << Canvas[h][W-1] << endl;
    }
    
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
 int A, B, C;
  
  scanf("%d %d %d", &A, &B, &C);
 
  if(A==B && B==C && C==A){
    printf("No\n");
  }
  else if(A==B || A==C || C==B){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  
 return 0;
}

Measured memory_bytes: 128
def make_devisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors +=[i]
            if i!=n//i:
                divisors +=[n//i]
    return divisors


n=int(input())
D=sorted(make_devisors(n))
ans=0
for i in D[1:]:
    if (n//(i-1))*i==n:
        ans +=i-1
print(ans)

Measured memory_bytes: 3296
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    uint64_t N;
    uint64_t Ai[200000];
    uint64_t difAN[200000];

    cin>> N;
    for(uint64_t i=0;i<N;i++){
        difAN[i] =0;
    }

    for(uint64_t i=0;i<N;i++){
        uint64_t temp;
        cin >> temp;
        Ai[i]=temp + i+1;
        if(i+1 > temp){
            difAN[i+1-temp]++;
        }
    }

    uint64_t countnum =0;
    for(int i=0;i<N;i++){
        if(Ai[i]<N){
            countnum += difAN[ Ai[i]];
        }
    }
    cout<< countnum <<endl;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, x;
  cin >> k >> x;
  cout << (k * 500 >= x ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),x;
		int[] a=new int[n];
		for(x=0;x<n;x++){
		a[x] = sc.nextInt();
		}
		for(x=n-1;x>=0;x--){
		System.out.print(a[x]);
		if(x!=0){System.out.print(" ");}
		}
		System.out.println(""); 
	}
}

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

int main(){
	ll a,b,k;
	cin>>a>>b>>k;
	if(a>=k){
		cout<<a-k<<" "<<b<<endl;
	}else if(a+b>=k){
		cout<<0<<" "<<(a+b)-k<<endl;
	}else{
		cout<<0<<" "<<0<<endl;
	}
}
		

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
int a[N];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int ans=1e9;
	for(int i=-100;i<=100;i++){
		int sum=0;
		for(int j=1;j<=n;j++){
			sum+=(i-a[j])*(i-a[j]);
		}
		ans=min(ans,sum);
	} 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3720
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

typedef long long ll;

const ll M = 1e9+7;

ll n, x[10], y[10], a[10];
long double ans;

int main()
{
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  
  for (ll i = 0; i < n; i++) {
    a[i] = i;
  }
  
  do {
    for (ll i = 0; i < n-1; i++) {
      ans += sqrt((x[a[i]] - x[a[i+1]])*(x[a[i]] - x[a[i+1]])
              +(y[a[i]] - y[a[i+1]])*(y[a[i]] - y[a[i+1]]));
    }
  } while(next_permutation(a, a+n));
  
  for (ll i = 1; i <= n; i++) {
    ans /= i;
  }
  
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;

int W, H;
int dh[] = {0, 0, 1, -1};
int dw[] = {1, -1, 0, 0};

inline bool in_field(int h, int w){
    return 0<=h && h<H && 0<=w && w<W;
}

int dfs(vector<vector<int>> &field, int h, int w, int d){
    if(d == 11)
        return d;
    
    int res = 11;
    for(int i=0; i<4; i++){
        int nh = h+dh[i];
        int nw = w+dw[i];
        if(in_field(nh, nw) && field[nh][nw] != 1){
            while(in_field(nh, nw) && field[nh][nw] == 0){
                nh += dh[i];
                nw += dw[i];
            }
            if(in_field(nh, nw)){
                if(field[nh][nw] == 3)
                    res = min(res, d+1);
                else{
                    field[nh][nw] = 0;
                    res = min(res, dfs(field, nh-dh[i], nw-dw[i], d+1));
                    field[nh][nw] = 1;
                }
            }
        }
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin>>W>>H, W|H){
        vector<vector<int>> field(H, vector<int>(W));
        int sh, sw;
        for(int i=0; i<H; i++)
            for(int j=0; j<W; j++){
                cin >> field[i][j];
                if(field[i][j] == 2){
                    sh = i; sw = j;
                    field[i][j] = 0;
                }
            }
        
        int ans = dfs(field, sh, sw, 0);
        cout << (ans == 11 ? -1 : ans) << endl;
    }
    
    return 0;
}

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

#define int long long

signed main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    if(s.size()!=(a+b+1) || s[a]!='-') {
        cout << "No" << endl;
        return 0;
    }
    for(int i=0; i<s.size(); ++i) {
        if(i==a) continue;
        if(!isdigit(s[i])) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);

void solve(long long X, long long Y, long long A, long long B, long long C,
           std::vector<long long> p, std::vector<long long> q,
           std::vector<long long> r)
{
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  vector<int> a;
  rep(i, X)
  {
    a.push_back(p[i]);
  }
  rep(i, Y)
  {
    a.push_back(q[i]);
  }
  rep(i, C) a.push_back(r[i]);
  sort(a.rbegin(), a.rend());
  lli ans = 0;
  rep(i, X + Y) ans += a[i];
  cout << ans << endl;
}

signed main()
{
  long long X;
  scanf("%lld", &X);
  long long Y;
  scanf("%lld", &Y);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  std::vector<long long> p(A);
  for (int i = 0; i < A; i++)
  {
    scanf("%lld", &p[i]);
  }
  std::vector<long long> q(B);
  for (int i = 0; i < B; i++)
  {
    scanf("%lld", &q[i]);
  }
  std::vector<long long> r(C);
  for (int i = 0; i < C; i++)
  {
    scanf("%lld", &r[i]);
  }
  solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


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

int main(){
	int a, b, c, d;
  
  	cin >> a >> b >> c >> d;
  	
  	if(a + b == c + d){
    	cout << "Balanced" << endl;
    }else if(a + b > c + d){
    	cout << "Left" << endl;
    }else if(a + b < c + d){
    	cout << "Right" << endl;
    }
  	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int a[102];
        int i,j,t,sum=0;
        for(i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
        }
        for(i=0; i<n-1; i++)
        {
            for(j=0; j<n-1-i; j++)
            {
                if(a[j]>a[j+1])
                {
                    t=a[j];
                    a[j]=a[j+1];
                    a[j+1]=t;
                    sum++;
                }
            }
        }
        for(i=0; i<n; i++)
        {
            if(i==n-1)
                printf("%d\n%d\n",a[i],sum);
            else
                printf("%d ",a[i]);
        }
    }
    return 0;
}



Measured memory_bytes: 2092
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] cnt = new int[M];
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                cnt[sc.nextInt()-1]++;
            }
        }
        for (int i = 0; i < M; i++) {
            if (cnt[i] == N)
                ans++;
        }
        System.out.println(ans);
    }
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void solve() {

}

int main() {
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int ans = 0;
  int two = 0, one = 0;
  rep(i,n) {
    char c = s[i];
    if( c == 'L' ) {
      if( i-1 >= 0 && s[i-1] == 'R' ) ++two;
    }
    if( c == 'L' && i-1 >= 0 && s[i-1] == 'L' ) ++ans;
    if( c == 'R' && i+1 <  n && s[i+1] == 'R' ) ++ans;
  }
  while( k > 0 && two > 0 ) {
    --k;
    --two;
    ans += 2;
  }
  if( k > 0 && ans != n-1 ) ans = n-1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
  int x, pt = 0;
  int stack[100];
  char s[100];

  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      stack[pt - 2] = stack[pt - 2] + stack[pt - 1];
      pt--;
    }else if(s[0] == '-'){
      stack[pt - 2] = stack[pt - 2] - stack[pt - 1];
      pt--;
    }else if(s[0] == '*'){
      stack[pt - 2] = stack[pt - 2] * stack[pt - 1];
      pt--;
    }else{
      x = atoi(s);
      stack[pt] = x;
      pt++;
    }
  }

  printf("%d\n", stack[pt - 1]);

  return 0;
}

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

int main() {
vector<vector<int>> grid(3, vector<int>(3));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
cin >> grid.at(i).at(j);}}
if(grid.at(0).at(0) - grid.at(1).at(0) == grid.at(0).at(1) - grid.at(1).at(1)
&& grid.at(0).at(0) - grid.at(1).at(0) == grid.at(0).at(2) - grid.at(1).at(2)
&& grid.at(1).at(0) - grid.at(2).at(0) == grid.at(1).at(1) - grid.at(2).at(1)
&& grid.at(1).at(0) - grid.at(2).at(0) == grid.at(1).at(2) - grid.at(2).at(2)
&& grid.at(0).at(0) - grid.at(2).at(0) == grid.at(0).at(1) - grid.at(2).at(1)
&& grid.at(0).at(0) - grid.at(2).at(0) == grid.at(0).at(2) - grid.at(2).at(2)){
cout << "Yes" << endl;}
else cout << "No" << endl;}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;


class A
{
   public static void Main() {
        int n = int.Parse(Console.ReadLine());
        int[,] G = new int[n+1, n+1];
        for(int i = 0; i < n; i++) {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            for(int j = 0; j < input[1]; j++) {
                if (G[input[0], input[j + 2]] == 0) {
                    G[input[0], input[j + 2]] = 1;
                }
            }
        }
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <=n; j++) {
                if (j > 1) {
                    Console.Write(" ");
                }
                Console.Write(G[i, j]);
            }
                Console.WriteLine();
        }
    }
}


Measured memory_bytes: 15948
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: usize = read();
    let a: usize = read();

    println!("{}", (h - 1) / a + 1);
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
N,K=map(int,input().split())
S=input()
Snumber=[]
count=0
 
for i in range(N):
    if i==0 or S[i-1]==S[i]:
        count=count+1
    else:
        Snumber.append(count)
        count=1
Snumber.append(count)
 
ans=0
C=0
 
if 1+2*K>len(Snumber):
    ans=len(S)
elif S[0]=="0":
    temporary=sum(Snumber[1:2+2*K])
    j=1
    while 1+2*K+j*2<=len(Snumber)-1:
        temporary=temporary-Snumber[2*j-1]-Snumber[2*j]+Snumber[2*K+2*j]+Snumber[1+2*K+2*j]
        if temporary>ans:
            ans=temporary
        j=j+1
    if len(Snumber)%2==1:
        C=sum(Snumber[len(Snumber)-2*K:])
    ans=max(ans,sum(Snumber[:2*K]),C)
elif S[0]=="1":
    temporary=sum(Snumber[0:1+2*K])
    j=1
    while 2*K+j*2<=len(Snumber)-1:
        temporary=temporary-Snumber[2*j-2]-Snumber[2*j-1]+Snumber[2*K+2*j-1]+Snumber[2*K+2*j]
        if temporary>ans:
            ans=temporary
        j=j+1
    if len(Snumber)%2==0:
        C=sum(Snumber[len(Snumber)-2*K:])
    ans=max(ans,C)
print(ans)

Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

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

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int n;
    cin >> n;
    map<int,int> d;
    rep(i,n){
        int x;
        cin >> x;
        d[x]++;
    }
    int m;
    cin >> m;
    rep(i,m){
        int y;
        cin >>y;
        if(d[y]>0) d[y]--;
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
 int N;
 cin >> N;
 vector<ll> A(N);
 bool h = 1;

 rep(i, N) {
   cin >> A[i];
   if(A[i] == 0) h = 0;
 }
 ll ans = 1;

 if(h){
   rep(i,N){
     ll next = ans * A[i];
     if(ans > next || next > 1000000000000000000){
       ans = -1;
       break;
     }
     ans = next;
   }
 }
 else ans = 0;

 cout << ans << endl;

}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    double b;
    cin>>a;
    for(double i=1.0;i<=50000;i++)
    {
        if((int)(i*1.08)>a)
        {
        cout<<":("<<endl;
        break;
        }
        if((int)(i*1.08)==a)
          {
              cout<<i<<endl;
              break;
          }
    }
    return 0;
}


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

int main(void){
    int N, K;

    cin >> N >> K;

    if(K > (N-1)*(N-2)/2){
        cout << -1 << endl;
        return 0;
    }

    int M = N-1 + (N-1)*(N-2)/2-K;
    cout << M << endl;
    for(int i=1; i<N; i++){
        cout << 1 << " " << i+1 << endl;
    }
    int u = 1;
    int v = 1;
    for(int i=N-1; i<M; i++){
        v++;
        if(v >= N){
            u++;
            v=u+1;
        }
        cout << u+1 << " " << v+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#import math
#import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal
#import itertools
import collections

N=int(input())
#N,K = map(int,input().split())
#B,W = map(int,input().split())
#T=int(input())
A = list(map(int,input().split()))
#S=str(input())
#A=[p for p in range(2*10**5)]
Q=int(input())
c=collections.Counter(A)
s=sum(A)
for i in range(Q):
    #print(A)
    B,C = map(int,input().split())
    if c[B]:
        s += (C-B)*c[B]
        c[C] += c[B]
        c[B] = 0

    print(s)


Measured memory_bytes: 21368
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';
ll num=1, ans=0, cnt=0, sum=0;

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

  ll money=100, year=0, x;
  cin >> x;
  
  while(money<x) {
    money += money/100;
    year++;
  }
  cout << year << newl;
  return 0;
}

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

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll x,a,b;
    cin>>x>>a>>b;
    if(a-b>=0){
        cout<<"delicious"<<endl;
    }else{
        if(abs(a-b)>x){
            cout<<"dangerous"<<endl;
        }else{
            cout<<"safe"<<endl;
        }
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define f(i, k, j) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = (1 << 26);
const int MAX_WH = 1010;

int h, w, n;
int dp[MAX_WH][MAX_WH], field[MAX_WH][MAX_WH];

int main(){
    while(cin >>h >>w >>n && h && w && n){
        memset(dp, 0, sizeof(dp));
        dp[0][0] = n - 1;
        rep(i, h) rep(j, w) cin >>field[i][j];

        rep(i, h){
            rep(j, w){
                dp[i + 1][j] += dp[i][j] / 2;
                dp[i][j + 1] += dp[i][j] / 2;
                if(dp[i][j] % 2 == 1){
                    if(field[i][j] == 0) dp[i + 1][j]++;
                    else dp[i][j + 1]++;
                }
                if(dp[i][j] % 2 == 1) field[i][j] = (field[i][j] + 1) % 2;
            }
        }
        int nx = 0, ny = 0;
        while(nx < w && ny < h){
            if(field[ny][nx] == 0) ny++;
            else nx++;
        }
        cout <<ny + 1 <<" " <<nx + 1 <<endl;
    }
    return 0;
}

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

using namespace std;

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

	string s, t;
	cin >> s >> t;
	int ans=0;

	int n=s.size();
	for(int i=0; i<n; i++)
        if(s[i]!=t[i])
            ans++;

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3768
#pragma region
#include <assert.h>
#include <math.h>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;

template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &v) {
  return os << v.first << ' ' << v.second << '\n';
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  for (T t : v) os << t << ' ';
  return os << '\n';
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &t : v) is >> t;
  return is;
}
#pragma endregion

#define int long long

void solvetestcase() {
  int n, x, mod, idx = -1;
  cin >> n >> x >> mod;
  vector<int> v, v1, v2;
  map<int, int> m;
  v.push_back(x);
  m[x] = 1;

  for (int i = 2;; i++) {
    x = (x * x) % mod;
    if (!x) break;
    if (m[x]) {
      idx = m[x];
      break;
    }
    m[x] = i;
    v.push_back(x);
  }
  if (idx == -1) {
    v1 = v;
  } else {
    for (int i = 0; i < idx - 1; i++) {
      v1.push_back(v[i]);
    }
    for (int i = idx - 1; i < v.size(); i++) {
      v2.push_back(v[i]);
    }
  }

  // cout << v1 << v2;
  int ans = 0;
  if (n <= v1.size()) {
    for (int i = 0; i < n; i++) {
      ans += v1[i];
    }
    n = 0;
  } else {
    for (int i = 0; i < v1.size(); i++) {
      ans += v1[i];
    }
    n -= v1.size();
  }
  if (n && v2.size()) {
    int q = n / v2.size();
    int sum = 0;
    for (auto &&num : v2) {
      sum += num;
    }
    ans += sum * q;
    n %= v2.size();

    for (int i = 0; i < n; i++) {
      ans += v2[i];
    }
  }
  cout << ans << endl;
}

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

  int t = 1;
  // cin >> t;

  for (int T = 1; T <= t; T++) {
    // cout << "Case #" << T << ": ";
    solvetestcase();
    cout.flush();
  }

  return 0;
};

/*
    AUTHOR:     KUNAL TAWATIA
    EDUCATION:  INDIAN INSTITUTE OF TECHNOLOGY, JODHPUR
*/


Measured memory_bytes: 7436
float a,b,c,d,e,f;main(){for(;~scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",(c-b*d)/a,d))d=(a*f-c*d)/(a*e-b*d);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int check(int a,int b)
{
	if(a==b)return 1;
	else
	return 0;	
}
int main()
{
	int n;
	cin>>n;
	int a,b,c=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		if(check(a,b)){
		c++;
		if(c==3){
			cout<<"Yes";
			return 0;
		}
		}
		else
		c=0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3636