akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

vector<int> operator+(const vi& v1, const vi& v2) {
    return { v1[0] + v2[0],v1[1] + v2[1] };
}

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

bool isWithin(const vector<int>& coordinate, int& H, int& W) {
    int y = coordinate[0];
    int x = coordinate[1];
    if (-1 < y && y < H) {
        if (-1 < x && x < W) {
            return true;
        }
    }
    return false;
}

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

vector<vector<int>> bfs(vector<vector<char>> table) {
    int H = table.size(); int W = table[0].size();
    vector<vector<int>> dp(table.size(), vi(table[0].size(), pint_INF));
    queue<vi> search_ij;
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table[0].size(); j++) {
            if (table[i][j] == '#') {
                dp[i][j] = 0;
                search_ij.push({ i,j });
            }
        }
    }
    while (!search_ij.empty()) {
        vi coor = search_ij.front(); search_ij.pop();
        for (auto move : moves) {
            vi next = coor + move;
            if (isWithin(next, H, W)) {
                if (chmin(dp[next[0]][next[1]], dp[coor[0]][coor[1]] + 1)) {
                    search_ij.push(next);
                }
            }
        }
    }
    return dp;
}

int main() {
    int H, W; cin >> H >> W;
    vector<vector<char>> vec(H, vector<char>(W));
    rep(i, H) rep(j, W) cin >> vec[i][j];
    vvi dist_table = bfs(vec);

    int M = -1;
    for (auto row : dist_table) {
        for (auto elem : row) {
            M = max(M, elem);
        }
    }
    cout << M << endl;
    sysp;
}

Measured memory_bytes: 64580
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, K;
const int MAX_N = 2000;
int A[MAX_N], B[MAX_N];
vi G[MAX_N];

int check_v(int v, int d) {
  bool used[N];
  REP(i, N) used[i] = false;
  queue<pi> q;
  q.push(pi(0, v));
  used[v] = true;

  int res = 0;
  while(!q.empty()) {
    pi u = q.front();
    q.pop();
    used[u.S] = true;
    if(u.F > d / 2) res++;
    REP(i, G[u.S].size()) {
      if(!used[G[u.S][i]]) q.push(pi(u.F + 1, G[u.S][i]));
    }
  }
  return res;
}

int check_e(int e, int d) {
  bool used[N];
  REP(i, N) used[i] = false;
  queue<pi> q;
  q.push(pi(0, A[e] - 1));
  used[A[e] - 1] = true;
  q.push(pi(0, B[e] - 1));
  used[B[e] - 1] = true;

  int res = 0;
  while(!q.empty()) {
    pi u = q.front();
    q.pop();
    used[u.S] = true;
    if(u.F > d / 2) res++;
    REP(i, G[u.S].size()) {
      if(!used[G[u.S][i]]) q.push(pi(u.F + 1, G[u.S][i]));
    }
  }
  return res;
}

int main(){
  cin >> N >> K;
  REP(i, N - 1) cin >> A[i] >> B[i];
  REP(i, N - 1) {
    G[A[i] - 1].pb(B[i] - 1);
    G[B[i] - 1].pb(A[i] - 1);
  }

  int ans = INFi;
  if(K % 2 == 0) {
    REP(i, N) {
      ans = min(ans, check_v(i, K));
    }
  } else {
    REP(i, N - 1) {
      ans = min(ans, check_e(i, K));
    }
  }

  cout << ans << endl;

  return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;

  int ans = 0;
  for(int a = 1; a < n; a++){
    for(int b = 1; a * b < n; b++){
      ans++;
    }
  }
  cout << ans << endl;
}



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

int main(){
    int N;  cin >> N;
    vector<int> A(N,0);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end()); // A はソートしておく

    vector<int> S(N,0); // A の累積和
    S[0] = A[0];
    for(int i=1; i<N; i++){
        S[i] = S[i-1] + A[i];
    }
    
    int M = -1e9;
    int K = 0;
    for(int k=1; k<=N-1; k++){
        // k 個の A の符合を反転させる場合は
        // S[N-1]-S[k-1]*2 となる。 
        if(M < S[N-1]-S[k-1]*2){
            M = S[N-1]-S[k-1]*2;
            K = k;
        }
    }

    cout << M << endl;
    // 操作の 1.
    for(int i=1; i<K; i++){
        cout << A[N-1] << " " << A[i] << endl;
        A[N-1] = A[N-1] - A[i];
    }
    // 操作の 2.
    for(int i=K; i<N-1; i++){
        cout << A[0] << " " << A[i] << endl;
        A[0] = A[0] - A[i];
    }
    // 操作の 3.
    cout << A[N-1] << " " << A[0] << endl;
}

Measured memory_bytes: 2688
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X = lr()
burger = [0] * 51 # 1-indexed
burger[0] = 1
patty = [0] * 51
patty[0] = 1
for i in range(1, N+1):
    burger[i] = 2 * burger[i-1] + 3
    patty[i] = 2 * patty[i-1] + 1

#print(burger)
answer = 0
while X:
    if N == 0:
        answer += 1
        break
    if X <= 1:
        break
    elif X == burger[N]:
        answer += patty[N]
        break
    if X > burger[N] // 2:
        answer += patty[N-1] + 1  # +1は中央部
        X -= burger[N-1] + 2
        N -= 1
        continue
    else:
        X -= 1
        N -= 1

print(answer)


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

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;++i) cin >> v[i];
  for(int i=n-1;i>=0;--i){
    if(i!=n-1) cout << " ";
    cout << v[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3092
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

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

	int a, b, c;
	cin >> a >> b >> c;

	swap(a, b);
	swap(a, c);

	cout << a << ' ' << b << ' ' << c << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <cassert>
#define SIZE 505
#define MX 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll A[SIZE][SIZE];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
bool pr[MX];
vector <int> all;

void make()
{
	for(int i=2;i<MX;i++)
	{
		if(!pr[i])
		{
			all.push_back(i);
			for(int j=2*i;j<MX;j+=i)
			{
				pr[j]=true;
			}
		}
	}
}
int main()
{
	make();
	int n;
	scanf("%d",&n);
	if(n==2)
	{
		puts("4 7");
		puts("23 10");
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			A[i][j]=1;
		}
	}
	int sz=0;
	for(int t=0;t<n;t++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(abs(i+j-2*t)<=1)
				{
					A[i][j]*=all[sz];
				}
			}
		}
		sz++;
	}
	int L=0,R=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)%2==0)
			{
				L=min(L,(i-j)/2);
				R=max(R,(i-j)/2);
			}
		}
	}
	for(int t=L;t<=R;t++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(abs((i-j)-2*t)<=1)
				{
					A[i][j]*=all[sz];
				}
			}
		}
		sz++;
	}
	/*
	for(int i=0;i<n;i++)
	{
		for(int j=0;j+1<n;j++)
		{
			ll a=A[i][j],b=A[i][j+1];
			if(a>b) swap(a,b);
			assert(b%a==0);
		}
	}
	for(int i=0;i+1<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ll a=A[i][j],b=A[i+1][j];
			if(a>b) swap(a,b);
			assert(b%a==0);
		}
	}*/
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(j!=0) printf(" ");
			printf("%lld",A[i][j]+(i+j)%2);
			assert(A[i][j]<=1000000000000000LL);
		}puts("");
	}
	return 0;
}


Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int num = 0;
		for(int i = a; i <= b; i++) {
			if(c % i == 0) {
				num++;
			}
		}
		System.out.println(num);
	}
}


Measured memory_bytes: 26344
n = int(input())
a = list(map(int,input().split()))
m = 1000
s = 0
for i in range(n-1):
    if s == 0:
        if a[i+1]>a[i]:
            s += m//a[i]
            m = m%a[i]
    if s != 0:
        if a[i+1]<a[i]:
            m += s*a[i]
            s = 0
    #print(i,m)
if s != 0:
    m += s*a[n-1]
    s = 0
print(m)



Measured memory_bytes: 8952
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define debug cout << "Ok" << endl;

using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	double aux;

	cin >> n;

	aux = n/3;

	if(n%3==2) aux+=0.6666666666666;
	if(n%3==1) aux+=0.3333333333333;

	cout << setprecision(10) << aux*aux*aux << endl;


	return 0;
}

Measured memory_bytes: 3784
// Aizu Vol0 0062: What is the Bottommost?
// 2017.7.29

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

char *gets(char *);
char buf[100], *p;

int main()
{
	int i, j, n[10];

	while (gets(p = buf) != NULL) {
		while (isspace(*p)) p++;
		for (i = 0; i < 10; i++) n[i] = *p++ - '0';
		for (i = 9; i >= 1; i--) {
			for (j = 1; j <= i; j++) n[j-1] = (n[j-1] + n[j]) % 10;
		}
		putchar(n[0] + '0');
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 998244353;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  vector<lint> a(N);
  REP(i, N) cin >> a[i];
  lint asum = 0;
  REP(i, N) asum += a[i];
  vector<lint> dp(asum+1);
  dp[0] = 1;
  REP(i, N) IREP(j, asum+1) {
    if(j-a[i] >= 0) dp[j] = (2*dp[j] + dp[j-a[i]]) % MOD;
    else dp[j] = 2*dp[j] % MOD;
  }
  lint tmp = 0;
  REP(i, asum+1) if(i >= (asum+1) / 2) tmp = (tmp + dp[i]) % MOD;
  lint ans = (power(3, N, MOD) - 3 * tmp % MOD + MOD) % MOD;
  if(asum%2 == 0) {
    vector<lint> dp2(asum+1);
    dp2[0] = 1;
    REP(i, N) IREP(j, asum+1) if(j-a[i] >= 0) dp2[j] = (dp2[j] + dp2[j-a[i]]) % MOD;
    ans = (ans + dp2[asum/2] * 3) % MOD;
  }
  cout << ans << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int func(int x)
{
    if (x % 2 == 0)
    {
        return x / 2;
    }
    else
    {
        return 3 * x + 1;
    }
}

int main()
{
    int a = 0;
    cin >> a;
    set<int> sets;
    int buf = a;
    sets.insert(a);
    while (1)
    {
        buf = func(buf);
        if (sets.count(buf) == 1)
        {
            COUT(sets.size() + 1);
            return 0;
        }
        sets.insert(buf);
    }

    return 0;
}

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

int main() {
  string a;
  cin >> a;
  if((a[0] == a[1] &&a[1]== a[2]) ||( a[1] == a[2]&&a[2] == a[3]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#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>;

int main()
{
    int a, b;
    cin >> a >> b;

    if (a < 9 && b < 9) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }


    return 0;
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();

		if (500 * k >= x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}

}


Measured memory_bytes: 23892
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long A, B;
    scan(A, B);
    foreach (x; 0 .. 10000)
    {
        if (A == (x * 8 / 100) && B == (x * 10 / 100))
        {
            writeln(x);
            return;
        }
    }
    writeln(-1);
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int a, b, c; cin >> a >> b >> c;
    int K; cin >> K;
    bool ans = false;
    REP(i, K + 1) REP(j, K + 1) REP(k, K + 1) if(i + j + k <= K){
        int a0 = a, b0 = b, c0 = c;
        REP(_, i) a0 *= 2;
        REP(_, j) b0 *= 2;
        REP(_, k) c0 *= 2;
        if(a0 < b0 && b0 < c0) ans = true;
    }
    chOut(ans, "Yes", "No");

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)


int main(){
  int  a,b;
  cin >> a >>b ;
  int ans=0;
  int c=b-a;
  ans++;
  if(b==1) ans=0;
  else if(a>=b);
  else if(c%(a-1)==0) {
    ans+=c/(a-1);
  }
  else {
    ans+=c/(a-1)+1;
  }
  cout << ans << endl;
    
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
 
    void solve (){
        int n;
        cin>>n;
        int odd=0;
        for(int i=1;i<=n;i++){
            if(i%2==1)
                odd++;
        }
        double ans=(double)odd/n;
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

int main() {
	
	int N;
	cin>>N;
	vector<int> h(N);
	vector<int> dp(N);
	for (auto &x : h) {
		cin>>x;
	}
	
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2;i < N;++i) {
		dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
	}

	cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1024
// 
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;


#define MAX_N 1000000005


int main() {
	string s;
	cin >> s;
	if(s=="ABC")outl("ARC");
	else outl("ABC");
    return 0;
}



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

int main(){
  string s;
  cin >> s;
  if ((s.at(0) == s.at(1) && s.at(1) == s.at(2)) || (s.at(1) == s.at(2) && s.at(2) == s.at(3))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){
    string str;
    getline(cin, str);
    for(int i=0; i<str.size(); i++){
        if('a'<=str[i] && str[i]<='z'){
            str[i] = toupper(str[i]);
        }else if('A'<=str[i] && str[i]<='Z'){
            str[i] = tolower(str[i]);
        }
    }

    cout << str << endl;

    return 0;
}



Measured memory_bytes: 3156
// https://atcoder.jp/contests/abc177/tasks/abc177_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
const int MOD = 1e9 + 7;

// 参考
// https://atcoder.jp/contests/s8pc-1/submissions/15772604
template <int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using modint = ModInt<MOD>;

// BIT(Binary-Indexed-Tree) 別名：Fenwick Tree
template <typename T> struct BIT {
    int n;
    vector<T> d;
    BIT(int n = 0) : n(n), d(n + 1) {}
    // 要素iにxを加算
    void add(int i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }
    // 区間[0, i]の合計を求める（閉区間）
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }
};

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    BIT<modint> bt(N);
    REP(i, N) {
        cin >> A[i];
        bt.add(i, A[i]);
    }
    modint a = 0;
    for (int i = N - 1; i > 0; i--) {
        int t = A[i];
        modint u = bt.sum(i - 1);
        a += u * t;
    }
    cout << a << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 6340
def main():
    N = int(input())
    count = N-1
    for i in range(2, N):
        count += int((N-1)/i)
        #print(count)

    return count

"""
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
"""

if __name__ == '__main__':
    print(main())
    #print(make_divisors(100))

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

using namespace std;
using ll = long long;



int main()
{
    ll h, w;
    cin >> h >> w;
    ll ans = 0;

    if(h == 1 || w == 1){
        cout << 1 <<  endl;
        return 0;
    }

    if(h & 1){
        ans = h * (w / 2) + (w % 2) * ((h + 1) / 2);
    }else{
        ans = h * (w / 2) + (w % 2) * (h / 2);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
long long int a,b,c;
  b=1;
scanf("%lld",&a);
 while(a!=1)
 {
 a=a/2;
 b++;
 }
 c=pow(2,b)-1;

  printf("%lld",c);
  
return 0;
}

Measured memory_bytes: 128
/// meowa 

#pragma GCC optimize("O3")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;

void stndrtn() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

int lcm(int a, int b) {
    return (a * 1ll * b) / __gcd(a, b);
}

void ma1n() {
    int x;
    cin >> x;
    cout << lcm(360, x) / x;
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			final int m = sc.nextInt();
			
			final int size = 2 * n + 1;
			
			char[] input = sc.next().toCharArray();
			
			int count = 0;
			for(int i = 0; i < m; i++){
				if(input[i] == 'I'){
					boolean next_i = false;
					int pos = i + 1;
					
					while(pos < m){
						if(input[pos] == (next_i ? 'I' : 'O')){
							next_i = !next_i;
							pos++;
						}else{
							break;
						}
					}
					
					int len = (pos - i) + (next_i ? -1 : 0);
					if(len >= size){
						count += 1 + (len - size) / 2;
					}
					
					i = pos - 1;
				}
			}
			
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 32728
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
ll haha[312345],lol[312345],a[312345];
multiset<ll> seti,setr;
multiset<ll>::iterator it;
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int i;
    ll sumi=0,maxi;
    maxi=inf;
    maxi*=-1;
    maxi*=inf;
    rep(i,3*n){
    	cin>>a[i];
    }
    rep(i,n){
    seti.insert(a[i]);
    	sumi+=a[i];
    }
    haha[n-1]=sumi;
    f(i,n,2*n){
    	it=seti.begin();
    	if(*it<a[i]){
    		sumi-=*it;
    		sumi+=a[i];
    		seti.erase(it);
    		seti.insert(a[i]);
    		
    	}
    	haha[i]=sumi;
    }
    sumi=0;
    fd(i,3*n-1,2*n){
    	setr.insert(a[i]);
    	sumi+=a[i];
    }
    lol[2*n]=sumi;
    fd(i,2*n-1,n){
    	it=setr.end();
    	it--;
    	if(*it>a[i]){
    		sumi-=*it;
    		sumi+=a[i];
    		setr.erase(it);
    		setr.insert(a[i]);
    		
    	}
    	lol[i]=sumi;
    }
    f(i,n-1,2*n){
    	maxi=max(maxi,haha[i]-lol[i+1]);
    	//cout<<haha[i]-lol[i+1]<<endl;
    }
    cout<<maxi<<endl;


}



Measured memory_bytes: 16128
import fractions
def n_div(k):
  return B // k - (A-1) // k
A, B, C, D = map(int, input().split())
CD = C * D // fractions.gcd(C,D)
ans = B - A + 1 - n_div(C) - n_div(D) + n_div(CD)
print(ans)

Measured memory_bytes: 5052
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint n,m,s,t,i,sai=0;cin>>n>>m>>s>>t;s--;t--;
	vector<vector<pair<int,llint>>>goen(n);
	vector<vector<pair<int,llint>>>gosn(n);
	for(i=0;i<m;i++){
		int u,v;llint a,b;cin>>u>>v>>a>>b;u--;v--;
		goen[u].pub(mp(v,a));
		goen[v].pub(mp(u,a));
		gosn[u].pub(mp(v,b));
		gosn[v].pub(mp(u,b));
	}
	vector<llint>en(n,big);
	vector<llint>sn(n,big);
	priority_queue<pair<llint,int>,vector<pair<llint,int>>,greater<pair<llint,int>>>que;
	que.push(mp(0LL,s));
	en[s]=0;
	while(que.size()>0){
		int ter=que.top().sec;
		llint co=que.top().fir;
		que.pop();
		if(en[ter]<co){continue;}
		for(auto it:goen[ter]){
			if(en[it.fir]<=co+it.sec){continue;}
			en[it.fir]=co+it.sec;
			que.push(mp(co+it.sec,it.fir));
		}
	}
	que.push(mp(0LL,t));
	sn[t]=0;
	while(que.size()>0){
		int ter=que.top().sec;
		llint co=que.top().fir;
		que.pop();
		if(sn[ter]<co){continue;}
		for(auto it:gosn[ter]){
			if(sn[it.fir]<=co+it.sec){continue;}
			sn[it.fir]=co+it.sec;
			que.push(mp(co+it.sec,it.fir));
		}
	}
	vector<llint>ans(n);
	llint ken=1000000000000000LL;
	for(i=n-1;i>=0;i--){
		maxeq(sai,ken-en[i]-sn[i]);
		ans[i]=sai;
	}
	for(i=0;i<n;i++){cout<<ans[i]<<endl;}
	return 0;
}

Measured memory_bytes: 19576
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bOutput(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp)
	sc.Split(bufio.ScanWords)
	n, q := iScan(), iScan()
	uf := newUF(n)
	for i := 0; i < q; i++ {
		t, u, v := iScan(), iScan(), iScan()
		if t == 0 {
			uf.unite(u, v)
		} else {
			bOutput(uf.same(u, v), "1", "0")
		}
	}
}

type UnionFind struct {
	par []int
}

func newUF(n int) *UnionFind {
	uf := new(UnionFind)
	uf.par = make([]int, n)
	for i, _ := range uf.par {
		uf.par[i] = -1
	}
	return uf
}
func (uf UnionFind) root(x int) int {
	if uf.par[x] < 0 {
		return x
	}
	uf.par[x] = uf.root(uf.par[x])
	return uf.par[x]
}
func (uf UnionFind) unite(x, y int) {
	rx, ry := uf.root(x), uf.root(y)
	if rx != ry {
		if uf.size(rx) > uf.size(ry) {
			rx, ry = ry, rx
		}
		uf.par[ry] += uf.par[rx]
		uf.par[rx] = ry
	}
}
func (uf UnionFind) same(x, y int) bool {
	return uf.root(x) == uf.root(y)
}
func (uf UnionFind) size(x int) int {
	return -uf.par[uf.root(x)]
}


Measured memory_bytes: 6188
//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

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


int32_t main() {
	boost; IO();

	int a,b,c,d; cin>>a>>b>>c>>d;
	cout << max(max(a*c,b*d),max(b*c,a*d)) << endl;



	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/


Measured memory_bytes: 3576
while True:
    T,D,L = map(int,input().split())
    if T==0 and D ==0 and L == 0:
        break
    x = [int(input()) for i in range(T)]
    beforeflag=0
    flag=0
    total=0
    for i in range(T):
        if x[i]>=L:
            flag=1
            if beforeflag!=D+1 and beforeflag!=0:
                total+=1
        elif x[i]<L and flag>0 and flag<=D:
            flag+=1
            total+=1
        else:
            flag=0
        beforeflag=flag
    print(total)


Measured memory_bytes: 14180
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA(My_College_Sucks)
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli, lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
    opt;
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.sz()-1]==b[0] and b[b.sz()-1]==c[0])
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b;cin>>a>>b;
  if(a>b)swap(a,b);

  int c = (b-a);
  if(c%2==0){
    cout<<b-(c/2)<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define INF (1e9+1)

typedef struct state{
  int pos,cost;
} state;

state A[2000001];
int N=0;
 
int parent(int i){return i/2;}
int left(int i){return i*2;}
int right(int i){return i*2+1;}
 
void exchange(state* a,state* b){
  state tmp=*a;
  *a=*b;
  *b=tmp;
}
 
void minHeapify(int i){
  int l=left(i);
  int r=right(i);
  int small;
  
  if( l<=N && A[l].cost<A[i].cost )small=l;
  else small=i;
  
  if( r<=N && A[r].cost<A[small].cost)small=r;
  
  if(small!=i){
    exchange(&A[i],&A[small]);
    minHeapify(small);
  }
  
}
 
state heapExtractMin(){
  if(N<1)return (state){0,0};
  state min=A[1];
  A[1]=A[N];
  N--;
  minHeapify(1);
  return min;
}

 
void heapIncreaseKey(int i,state key){
  if(key.cost>A[i].cost)return;
 
  A[i]=key;
  while(i>1&&A[parent(i)].cost>A[i].cost){
    exchange(&A[i],&A[parent(i)]);
    i=parent(i);
  }
}
 
void minHeapInsert(state key){
  N++;
  A[N]=(state){INF,INF};
  heapIncreaseKey(N,key);
}


typedef struct edge{
  int to,cost;
} edge;

edge* G[10000];
int size[10000];
int n;
int d[10000];
edge e;
state s;
int main(){
  int i,j,a,b;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    G[a] = malloc( sizeof( edge ) *b );
    size[a]=b;
    for(j=0;j<b;j++){
      scanf("%d %d",&G[a][j].to,&G[a][j].cost);
    }
    d[i]=INF;
  }
  d[0]=0;
  minHeapInsert( (state){0,0} );
  while(N!=0){
    s = heapExtractMin();
    if(s.cost>d[s.pos])continue;
    for(i=0;i<size[s.pos];i++){
      e=G[s.pos][i];
      if(d[e.to]<=d[s.pos]+e.cost)continue;
      d[e.to]=d[s.pos]+e.cost;
      minHeapInsert((state){e.to,d[e.to]});
    }
  }
   for(i=0;i<n;i++)
    printf("%d %d\n",i,d[i]);
  
  return 0;
}



Measured memory_bytes: 5728
# -*- coding: utf-8 -*-
import math
from functools import reduce

K = int(input())

ans = 0

for a in range(1, K + 1):
    for b in range(a, K + 1):
        for c in range(b, K + 1):
            abc = [a, b, c]
            #print(abc)

            abc_gcd = reduce(math.gcd, abc)
            set_abc = set(abc)
            #print(set_abc)
            # a, b, cが全て同じならこの組み合わせは1回だけ
            if len(set_abc) == 1:
                ans += abc_gcd
            # a, b, cに数字が2つ存在するならこの組み合わせは3回
            elif len(set_abc) == 2:
                ans += (abc_gcd * 3)
            # a, b, cの数字がすべて違えばこの組み合わせは6回
            elif len(set_abc) == 3:
                ans += (abc_gcd * 6)

print(ans)

Measured memory_bytes: 9640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int X,A;scan(X>>A);
	if(X<A) prin(0);
	else prin(10);
	return 0;
}


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

int main()
{
    int n;
    scanf("%d", &n);

    int a[n] = {};
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a, a + n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == a[i + 1]) {
            ++i;
        } else {
            ans++;
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 640
N, M = map(int,input().split())
H = list(map(int,input().split()))

result = [1]*N
for i in range(M):
    A, B = map(int,input().split())
    if H[A-1] < H[B-1]:
        result[A-1] = 0
    elif H[A-1] == H[B-1]:
        result[A-1] = 0
        result[B-1] = 0
    elif H[A-1] > H[B-1]:
        result[B-1] = 0
print(sum(result))


Measured memory_bytes: 20116
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pbb pair<bool,bool>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod (ll)(1e9+7) 
#define hmod 1286031825167LL
using namespace std;

int h,w,a,b,s[1005][1005];
int main(){	
    ios::sync_with_stdio(false);
    cin >> h >> w >> a >> b;
    for (int i=1;i<=h;i++){
    	for (int j=1;j<=w;j++){
    		s[i][j]=0;
		}
	}
    for (int i=1;i<=b;i++){
    	for (int j=1;j<=a;j++){
    		s[i][j]=1;
		}
	}
	a=w-a; b=h-b;
	for (int i=h;i>=h-b+1;i--){
		for (int j=w;j>=w-a+1;j--){
			s[i][j]=1;
		}
	}
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++){
			cout << s[i][j];
		}
		cout << "\n";
	}
    return 0;
}	

Measured memory_bytes: 7584
#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<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	int n;cin>>n;
	vector<int> A(n);
	vector<int> cho(n,0);
	ll sum=1000;
	ll kabu=0;
	rep(i,n){
	    cin>>A[i];
	}
	rep(i,n-1){
	   
	        if(A[i]<A[i+1]){
	            cho[i+1]=1;
	            cho[i]=-1;
	        }
	  
	}
	rep(i,n){
	    if(cho[i]==1){
	        sum+=kabu*A[i];
	        kabu=0;
	    }else if(cho[i]==-1){
	        kabu+=(sum-sum%A[i])/A[i];
	        sum=sum%A[i];
	    }
	}
	cout<<sum<<endl;
	return 0;
}


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

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
double p[3005][3005];
double prob[3005];
void solve() {	
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> prob[i];
	p[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int now = 0; now <= i; ++now) {
			p[i][now] = p[i - 1][now] * (1 - prob[i]);
			if (now >= 1)
				p[i][now] += p[i - 1][now - 1] * prob[i];
		}
	}
	double ans = 0;
	for (int i = 0; i <= n; ++i) {
		if (i > n - i)
			ans += p[n][i];
	}
	cout << ans;
}     


Measured memory_bytes: 69120