akhauriyash/Code-Regression huggingface dataset:
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-07 23:18:09
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

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

  // x -> a : x * 108 / 100
  // x -> b : x * 110 / 100

  for (int i = 1; i <= 20000; ++i) {
    if (i * 8 / 100 == a && i * 10 / 100 == b) {
      cout << i << endl; return 0;
    }
  }
  
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> x(3);
  for (int i = 0; i < 3; i++) {
    cin >> x[i];
  }
  int &a = x[0];
  int &b = x[1];
  int &c = x[2];
  sort(x.begin(), x.end());
  int count = 0;
  if (c > b) {
    for (int i = 0; i < 50; i++) {
      a++;
      b++;
      count++;
      if(c==b) {
        break;
      }
    }
  }
  
  //ここからA
  if ((b-a)%2==0) {
    count+=(b-a)/2;
  }
  else {
    count+=(b-a)/2+1+1;
  }
  cout << count << endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  // A, B, C, Dを全探索する
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  int ans_sw = 0;
  int ans_s  = 0;
  double ans_per = -1.0;

  for(int na = 0; na * 100 * A <= 3000; na++){
    for(int nb = 0; 100 * A * na + 100 * B * nb <= F; nb++){
      
      // 水の量
      int water = 100 * A * na + 100 * B * nb;
      int max_suger = (A * na + B * nb) * E;

      for(int nc = 0; nc * C <= max_suger; nc++){
        for(int nd = 0; nc * C + nd * D <= max_suger && ((nc * C + nd * D) + water <= F); nd++){

          int suger = nc * C + nd * D;

          double per = 100.0 * suger / (water + suger);
          if(chmax(ans_per, per)){
            ans_sw = water + suger;
            ans_s  = suger;
          }
        }
      }
    }
  }

  cout << ans_sw << " " << ans_s << endl;

  return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> l(n);
    vector<int> r(n);
    for (int i = 0; i < n; i++)
    {
        cin >> l[i] >> r[i];
    }
    
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += r[i]-l[i]+1;
    }
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 384
import math

N = int(input())

mod = 10 ** 9 + 7
count_dict = {}
ans = 1

def primes(x):
    if x < 2: 
        return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, x, prime):
            primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

def cal(n):
    global count_dict
    for i in count_dict.keys():
        if n % i == 0:
            count_dict[i] += 1
            n //= i
            return n

    

for i in primes(1000):
    count_dict[i] = count_dict.get(i-1, 0)

if N > 1:
    for i in range(2, N+1):
        while True:
            i = cal(i)
            if i == 1:
                break


for i in count_dict.values():
    if i != 0:
        ans *= (i+1)

print(ans % mod)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int h,n,sum=0;
    scanf("%d %d",&h ,&n);
        int arr[n];
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    for(int i=0;i<n;i++){
        h=h-arr[i];
    }
    if(h<=0){
        printf("Yes");
    }
    else{
        printf("No");
    }

}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll n,k,size;
vector<ll>a,f;
ll check(ll x){
    ll count=0;
    for(ll i=0;i<size;i++){
        if(x>=a[i]*f[i])continue;
        ll num=x/f[i];
        num=a[i]-num;
        count+=num;
    }
    return (count<=k);
}

int main(void){
    cin>>n>>k;
    ll x;
    for(ll i=0;i<n;i++){
        cin>>x;
        a.push_back(x);
    }
    for(ll i=0;i<n;i++){
        cin>>x;
        f.push_back(x);
    }
    sort(a.begin(),a.end());
    sort(f.begin(),f.end(),greater<ll>());
    size=n;
    ll ok=1000000000000;
    ll ng=-1;
    while(ok-ng>1){
        //cout<<ok<<" "<<ng<<endl;
        ll mid=(ok+ng)/2;
        if(check(mid))ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
    return 0;
}

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

int main(){
  	int x;
    int y;
    int ans=0;
    cin>>x>>y;
    if(y<2*x || 4*x<y || (y%2)==1) ans=1;
    if(ans==1){
    	cout<<"No";
    }else{
      	cout<<"Yes";
    }
}

Measured memory_bytes: 3596
n = int(input())
a = sorted([int(input()) for _ in range(n)])
tmp = a[0]
cnt = [0]*n
ptr = 0
for i in range(n) :
  if(a[i-1] != a[i]) :
    ptr += 1
  cnt[ptr] += 1
print(sum([cnt[i]%2 for i in range(len(cnt))]))

Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	long double prod = 1;
	long long arr[n];
	for(int i=0; i<n; ++i){
		cin >> arr[i];
	}
	sort(arr, arr+n);
	for(int i=0; i<n; ++i){
		prod*=arr[i];
		if(prod-1000000000000000000 > 0){
			cout << "-1";
			return 0;
		}
	}
	cout << (long long)prod;
}


Measured memory_bytes: 4312
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define I_L_T_S ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
const int N = 1e5 + 2;
const int mod = 1e9 + 7;

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

int32_t main(){
   I_L_T_S;
   int n;
   cin >> n;
   int a[n] , b[n] , c[n];
   for(int i = 0 ; i < n ; i++){
   		cin >> a[i] >> b[i] >> c[i];
   }
   int dp[n][3];
   	dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
   for(int i = 1 ; i < n ; i++){
   		dp[i][0] = a[i] + max(dp[i - 1][1] , dp[i - 1][2] ); 
   		dp[i][1] = b[i] + max(dp[i - 1][0] , dp[i - 1][2] );
   		dp[i][2] = c[i] + max(dp[i - 1][0] , dp[i - 1][1] );
   }
   cout << max({dp[n - 1][0] , dp[n - 1][1] , dp[n - 1][2]}  );
	return 0;
}

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

#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

// data
int n, q;
vector<int> A;

bool solve(int i, int M);
int main(){
    // input 
    cin >> n;
    rep(i, n){
        int Ai; cin >> Ai;
        A.push_back(Ai);
    }

    cin >> q;
    rep(i, q){
        int M; cin >> M;

        cout << (solve(0, M) ? "yes": "no") << endl;
    }
}

bool solve(int i, int M){
    // pre end
    if(M == 0 || M == A[i]) return true;
    if(M < 0) return false;
    // end
    if(i == n-1) return false; // recursive to A_n-1 but need to make M !=

    // recursive
    return solve(i+1, M) || solve(i+1, M-A[i]);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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 ll MOD = 1e9+7;

int main(){
    int A[3][3];
    REP(i,3){
        REP(j,3){
            cin >> A[i][j];
        }
    }

    int N;
    cin >> N;
    set<int> X;
    REP(i,N){
        int b;
        cin >> b;
        X.insert(b);
    }

    bool Y[3][3];
    REP(i,3){
        REP(j,3){
            Y[i][j] = false;
            int a = A[i][j];
            if(X.find(a) != X.end())
                Y[i][j] = true;
        }
    }

    bool ans = false;
    REP(i,3){
        int tmp = 0;
        REP(j,3){
            tmp += Y[i][j];
        }
        if(tmp == 3) ans = true;
    }

    REP(j,3){
        int tmp = 0;
        REP(i,3){
            tmp += Y[i][j];
        }
        if(tmp == 3) ans = true;
    }

    int tmp = 0;
    REP(i,3){
        tmp += Y[i][i];
    }
    if(tmp == 3) ans = true;

    tmp = 0;
    REP(i,3){
        tmp += Y[i][2-i];
    }
    if(tmp == 3) ans = true;

    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int heaps[251],H,i;
    scanf("%d",&H);
    for(i=1;i<=H;i++) scanf("%d" ,&heaps[i]);
    for(i=1;i<=H;i++){
        printf("node %d: key = %d, ",i,heaps[i]);
        if(i!=1) printf("parent key = %d, ",heaps[i/2]);
        if(i*2<=H) printf("left key = %d, ",heaps[i*2]);
        if(i*2+1<=H) printf("right key = %d, ",heaps[i*2+1]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <math.h>

int main(void) {

  long n,a,b;
  scanf("%ld %ld %ld", &n, &a, &b);
  long h[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &h[i]);
  }
  long start,end,center,b_sum,life,count;
  a -= b;
  start = 0;
  end = pow(10,9);
  while (1) {
    if (start+1 == end) {
      break;
    }
    center = (start+end)/2;
    b_sum = b*center;
    count = 0;
    for (long i = 0; i < n; i++) {
      life = h[i]-b_sum;
      if (life <= 0) {
        continue;
      }
      count += (life+a-1)/a;
      if (count > center) {
        break;
      }
    }
    if (count > center) {
      start = center;
    } else {
      end = center;
    }
  }
  printf("%ld\n", end);

  return 0;
}

Measured memory_bytes: 896
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] v = new int[n];

        for (int i = 0; i < n; i++) {
            v[i] = Integer.parseInt(sc.next());
        }

        Map<Integer, Integer> oddMap = new HashMap<>();
        Map<Integer, Integer> evenMap = new HashMap<>();

        for (int i = 0; i < n; i++) {
            if ((i + 1) % 2 == 0) {
                evenMap.put(v[i], evenMap.getOrDefault(v[i], 0) + 1);
            } else {
                oddMap.put(v[i], oddMap.getOrDefault(v[i], 0) + 1);
            }
        }

        int[][] odd = oneTwo(oddMap);
        int[][] even = oneTwo(evenMap);

        int res = Integer.MAX_VALUE;
        if (odd[0][0] != even[0][0]) {
            res = Math.min(res, (n / 2) - odd[0][1] + (n / 2) - even[0][1]);
        } else {
            res = Math.min(res, (n / 2) - odd[0][1] + (n / 2) - even[1][1]);
            res = Math.min(res, (n / 2) - odd[1][1] + (n / 2) - even[0][1]);
        }

        System.out.println(res);

    }

    private static int[][] oneTwo(Map<Integer, Integer> map) {
        int max[] = new int[2];
        int two[] = new int[2];

        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            int v = entry.getValue();
            int k = entry.getKey();
            if (max[1] < v) {
                two[0] = max[0];
                two[1] = max[1];
                max[0] = k;
                max[1] = v;
            } else if (two[1] < v) {
                two[0] = k;
                two[1] = v;
            }
        }
        int[][] res = new int[2][2];
        res[0] = max;
        res[1] = two;
        return res;
    }
}


Measured memory_bytes: 50216
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    ll n = 0;
    cin >> n;
    double a = log2(n);
    ll x = (ll)(a);
    ll res = 1;
    while(res <= n){
        res *= 2LL;
    }
    res--;
    cout << res << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

s = len(S)
t = len(T)

ans = 10**10
for i in range(s-t+1):
    mm = 0
    for j in range(t):
        if S[i+j]!=T[j]:
            mm += 1
    else:
        ans = min(ans,mm)
print(ans)

Measured memory_bytes: 67336
N,M,K=map(int,input().split())
A=[];B=[]
for i in range(M):
    a,b=map(int,input().split())
    A.append(a);B.append(b)
C=[];D=[]
for i in range(K):
    c,d=map(int,input().split())
    C.append(c);D.append(d)
f=[set() for i in range(N)]
b=[set() for i in range(N)]
for i in range(M):
    f[A[i]-1].add(B[i]-1)
    f[B[i]-1].add(A[i]-1)
for i in range(K):
    b[C[i]-1].add(D[i]-1)
    b[D[i]-1].add(C[i]-1)
checked=[False for i in range(N)]
class UnionFind:
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
    def root(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.root(self.parents[x])
            return self.parents[x]
    def union(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return
        if self.parents[x]>self.parents[y]:
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x
    def same(self,x,y):
        return self.root(x)==self.root(y)
    def size(self,x):
        return -self.parents[self.root(x)]
    def roots(self):
        return [i for i,x in enumerate(self.parents) if x<0]
    def group_count(self):
        return len(self.roots())
uf=UnionFind(N)
for i in range(N):
    for people in f[i]:
        uf.union(i,people)
ans=[]
for i in range(N):
    c=uf.size(i)
    bl=0
    for x in b[i]:
        if uf.same(i,x):
            bl+=1
    ans.append(c-bl-1-len(f[i]))
print(*ans)

Measured memory_bytes: 129368
#include <iostream>
#include <vector>
using namespace std;
#define KMAX 30
#define VMAX 1000000
int main( void )
{
	vector <bool> prime(VMAX+1, false);
	for ( int i = 3; i <= VMAX; i += 2 )
	{
		prime[i] = true;
	}
	prime[2] = true;
	for ( int i = 3; i * i <= VMAX; i += 2 )
	{
		if ( prime[i] )
		{
			for ( int j = i + i; j <= VMAX; j += i )
				prime[j] = false;
		}
	}

	while ( 1 )
	{
		int n, x;
		cin >> n >> x;
		if ( n == 0 && x == 0 )
			break;

		vector <int> K( KMAX );
		for ( int i = 0; i < n; i++ )
			cin >> K[i];

		vector < vector <bool> > T( KMAX, vector <bool>(VMAX, false) );

		for ( int i = 0; i < n; i++ )
			T[i][0] = true;
		for ( int i = K[0]; i <= x; i += K[0] )
			T[0][i] = true;

		for ( int i = 1; i < n; i++ )
		{
			for ( int j = 1; j < K[i]; j++ )
			{
				T[i][j] = T[i-1][j];
			}

			for ( int j = K[i]; j <= x; j++ )
			{
				T[i][j] = ( T[i-1][j] || T[i][j-K[i]] );
			}
		}

		int kotae = -1;
		for ( int i = x; i >= 2; i-- )
		{
			if ( prime[i] && T[n-1][i] )
			{
				kotae = i;
				break;
			}
		}

		if ( kotae == -1 )
			cout << "NA" << endl;
		else
			cout << kotae << endl;

	}

	return 0;
}

Measured memory_bytes: 4812
#include<iostream>
using namespace std;
#define MAX 100

int mat[MAX][MAX] = {};
int n, tt = 0, d[MAX] = {}, f[MAX] = {};
bool c[MAX];

void dfs_visit(int u){
    c[u] = true;
    d[u] = ++tt;
    for(int i = 0; i < n; i++){
        if(mat[u][i] == 0)  continue;
        if(!c[i])   dfs_visit(i);
    }
    f[u] = ++tt;
}

void dfs(){
    for(int i = 0; i < n; i++){
        if(!c[i])   dfs_visit(i);
    }

    for(int i = 0; i < n; i++){
        cout << (i+1) << " " << d[i] << " " << f[i] << endl;
    }
}

int main(){
    cin >> n;
    
    for(int i = 0; i < n; i++){
        int x, k, y;
        cin >> x >> k;
        while(k-- > 0){
            cin >> y;
            mat[x-1][y-1] = 1;
        }
    }

    dfs();
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int main(void)
{
	int a1,a2,a3,a4,b1,b2,b3,b4,gou1,gou2;
	scanf("%d %d %d %d",&a1,&a2,&a3,&a4);
	scanf("%d %d %d %d",&b1,&b2,&b3,&b4);
	gou1=a1+a2+a3+a4;
	gou2=b1+b2+b3+b4;
	if(gou1>=gou2) {
		printf("%d\n",gou1);
	}
	else {
		printf("%d\n",gou2);
	}
	return 0;
}

Measured memory_bytes: 592
def main():
    N = int(input())
    A = []
    for i in range(N):
        a = int(input())
        h, d = 0, 0
        for _ in range(a):
            x, y = [int(i) for i in input().split()]
            if y == 1:
                h |= 1 << (x - 1)
            else:
                d |= 1 << (x - 1)
        A.append((i, h, d))
    
    m = 0
    for n in range(2 ** N):
        ch, cd = 0, 0
        mm = 0
        for i, h, d in A:
            if n & (1 << i):
                ch |= h | (1 << i)
                cd |= d
                if ch & cd:
                    break
                if cd & n:
                    break
                mm += 1
            elif ch & (1 << i):
                break
        else:
            if n == ch:
                m = max(m, mm)
    print(m)


main()


Measured memory_bytes: 3064
str = input()
for q in range(int(input())):
    com, *num = input().strip().split()
    a, b = int(num[0]), int(num[1])
    if com == 'print':
        print(str[a:b+1])
    elif com == 'replace':
        if b == len(str)-1:
            str = str[:a] + num[2]
        else:
            str = str[:a] + num[2] + (str[b+1:])
    else: # com == 'reverse'
        if a == 0:
            str = str[b::-1] + str[b+1:]
        elif b == len(str)-1:
            str = str[:a] + str[:a-1:-1]
        else:
            str = str[:a] + str[b:a-1:-1] + str[b+1:]

Measured memory_bytes: 7692
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	defer writer.Flush()
	var N int
	fmt.Scan(&N)
	for N > 0 {
		sum := 0
		for i := 1; ; i++ {
			sum += i
			if sum >= N {
				Println(i)
				N -= i
				break
			}
		}
	}
}

var writer = bufio.NewWriter(os.Stdout)

func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }


Measured memory_bytes: 1868
#include<stdio.h>
int main (void){
    long long int s,c;
    scanf("%lld%lld",&s,&c);
    //cを2つでsにできる
    //scc
    unsigned long long int ans=0;
    
    if(s*2<=c){
        c-=s*2;
        ans+=s;
        s=0;
    }
    if(s*2>c){
        s-=c/2;
        ans+=c/2;
        c=0;
    }
    
    
    while(s>=1 && c>=2){
        s--;
        c-=2;
        ans++;
    }
    
    
    /*while(c>=4){
        c-=4;
        ans++;
    }*/
    ans+=(c/4);
    printf("%lld\n",ans);
    
    return 0;
    
}

Measured memory_bytes: 128
// @DateTime:    2020-04-26 20:04:23
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int main()
{
    int a , b;
    cin >> a >> b;
    puts(a > b?"safe":"unsafe");
    
}

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

int main()
{
    int n;
    cin >> n;
    int house[4][3][10] = {0};

    for (int i = 0; i < n; i++)
    {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        b--;
        f--;
        r--;
        house[b][f][r] += v;
    }

    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int s = 0; s < 10; s++)
            {
                cout << " " << house[i][j][s];
            }
            cout << endl;
        }
        if (i != 3)
            cout << "####################" << endl;
    }
}


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

int main() {
  ll N, T;
  cin >> N >> T;

  int t[N];
  ll ans = 0;
  rep(i,0,N-1) {
    cin >> t[i];
    if (i == 0) continue;
    if (T < t[i] - t[i-1]) ans += T;
    else ans += t[i] - t[i-1];
  }

  cout << ans + T << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  int a;
  int b;
  cin >> a >> b;
  if((100*a + 99)/8 < 10*b || 10*b + 9 < (100*a + 7)/8){
      cout << -1;
  } else{
      cout << max((100*a + 7)/8, 10*b);
  }
}

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

using namespace std;

vector<vector<int>> initializeVector(int row, int col)
{
    vector<vector<int>> outerVector;
    for(int i = 0 ; i <= row ; i++)
    {
        vector<int> innerVector;
        for(int j = 0 ; j <= col ; j++)
        {
            innerVector.push_back(0);
        }
        outerVector.push_back(innerVector);
    }
    return outerVector;
}

string traversePath(vector<vector<int>> lcsVector, int row, int col, string str1, string str2)
{
    string result = "";
    while (row && col)
    {
        if(str1[row-1] == str2[col-1])
        {
            result = str1[row-1] + result;
            row--;
            col--;
        }
        else
        {
            if(lcsVector[row][col-1] > lcsVector[row-1][col])
            {
                col--;
            }
            else
            {
                row--;
            }
        }
    }
    return result;
}

string getLongestCommonSubsequence(string str1, string str2)
{
    int                 row       = (int)(str1.length());
    int                 col       = (int)(str2.length());
    vector<vector<int>> lcsVector = initializeVector(row, col);
    for(int i = 1 ; i <= row ; i++)
    {
        for(int j = 1 ; j <= col ; j++)
        {
            if(str1[i-1] == str2[j-1])
            {
                lcsVector[i][j] = max(lcsVector[i-1][j-1]+1, max(lcsVector[i-1][j], lcsVector[i][j-1]));
            }
            else
            {
                lcsVector[i][j] = max(lcsVector[i-1][j], lcsVector[i][j-1]);
            }
        }
    }
    return lcsVector[row][col] > 0 ? traversePath(lcsVector, row, col, str1, str2) : "";
}

int main(int argc, const char * argv[])
{
    string str1, str2;
    cin>>str1>>str2;
    cout<<getLongestCommonSubsequence(str1, str2)<<endl;
    return 0;
}


Measured memory_bytes: 70912
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void) {
    
    int n;
    cin>>n;
    bool ch=false;
    int ans=0;
    vs s(n);
    vi t(n);
    string x;
    rep(i,n)cin>>s[i]>>t[i];
    cin>>x;
    rep(i,n){
        if(x==s[i]){
            ch=1;
            continue;
        }
        if(ch){
            ans+=t[i];
        }
    }
    fin(ans);

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a[] = new int[n+1];
		int b[] = new int[n];
		for(int i=0; i<n+1; i++) {
			a[i]=sc.nextInt();
		}
		for(int i=0; i<n; i++) {
			b[i]=sc.nextInt();
		}
		long ans = 0;
		for(int i=0; i<n; i++) {
			int left = Math.min(a[i], b[i]);
			a[i] -= left;
			b[i] -= left;
			ans += left;
			int right = Math.min(a[i+1], b[i]);
			a[i+1] -= right;
			b[i] -= right;
			ans += right;
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 60452
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = 1e13;

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

	int N,M;
	cin >> N >> M;

	ll a[M],b[M],c[M];
	rep(i,M){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;
		b[i]--;
		c[i] = -c[i];
	}

	vector<ll> dist(N,INF);
	dist[0] = 0;

	// bellman-ford
	rep(l,N-1){
		rep(i,M){
			if(dist[a[i]] == INF) continue;
			if(dist[b[i]] > dist[a[i]] + c[i]){
				dist[b[i]] = dist[a[i]] + c[i];
			}
		}
	}

	ll ans = dist[N-1];

	// find negative acyclic path 
	bool negative[N] = {};
	rep(l,N){
		rep(i,M){
			if(dist[a[i]] == INF) continue;
			if(dist[b[i]] > dist[a[i]] + c[i]){
				dist[b[i]] = dist[a[i]] + c[i];
				negative[b[i]] = true;
			}
			if(negative[a[i]]) negative[b[i]] = true;
		}
	}

	if(negative[N-1]) cout << "inf" << endl;
	else cout << -ans << endl;
}

Measured memory_bytes: 384
import math
def combinations_count(n, r):
    if r == 0:
        return 1
    if n<r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k = map(int,input().split())
for i in range(k):
    ans = combinations_count(n-k+1,i+1) * combinations_count(k-1,i) % 1000000007
    print(ans)


Measured memory_bytes: 3316
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N, M = map(int, input().split())
    N_list = [1 for x in range(N)]
    H_i = list(map(int, input().split()))

    for i in range(M):
        A, B = map(int, input().split())
        if H_i[A - 1] < H_i[B - 1]:
            N_list[A - 1] = 0
        elif H_i[A - 1] > H_i[B - 1]:
            N_list[B - 1] = 0
        else:
            N_list[A - 1] = 0
            N_list[B - 1] = 0
            
    print(N_list.count(1))

    logging.info("Hello!")

    
if __name__ == "__main__":
    main()


Measured memory_bytes: 22684
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll X,A,B; cin >> X >> A >> B;
    if(A>=B){
        cout << "delicious" << endl;
    }else if(B-A<=X){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


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

	ll res = 1000000000000;
	for (ll a=1; a*a<=n; a++) {
		if (n%a==0) {
			ll b = n/a;
			res = min(res, a+b);
		}
	}
	cout << res - 2 << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){

    int a,b,c;
    int i,n_yakusu=0;

    //input
    scanf("%d %d %d",&a, &b, &c);


    for(i=a; i<=b; i++){
        if(c%i==0){
            n_yakusu++;
        }
    }

    //output
    printf("%d\n", n_yakusu);

    return 0;

}

Measured memory_bytes: 596
#include <stdio.h>

int main(void){
    int n,a;
    scanf("%d",&n);
    while (n >= 1000)n -= 1000;

    if (n == 0){
        printf("%d",n);
        return 0;
    }
    else{
        a = 1000 - n;
        printf("%d",a);
    }


    return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
#define N 1000

int main(void){
    // Your code here!
    
    int n;//int l,r,d=0;
    int ans=0;
    int a[N]={0};
    
    scanf("%d",&n);
    
    
    for(int i=0; i<n; i++) scanf("%d",&a[i]);
    
    for(int i=0; i<n; i++) if(  (i+1) % 2 && a[i]%2 ) ans++;
   
    printf("%d\n",ans);
    
    
    return 0;
    
}


Measured memory_bytes: 2076
<?php
list($n, $m) = explode(" ", trim(fgets(STDIN)));
$L = 1;
$R = $n;
for($i = 0; $i < $m; $i++){
    list($l, $r) = explode(" ", trim(fgets(STDIN)));
    $L = max($L, $l);
    $R = min($R, $r);
}
echo max($R-$L+1, 0);


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#include<string.h>
#define v vector<int>
#define vpp vector<pair<int,int>>
#define ll long long int
#define ull unsigned long long
#define ld long double
#define f(a,b) for(ll i =a;i<b;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define pb push_back
#define MOD 1000000007
#define ub upper_bound
#define lb lower_bound
ll fast_pow(ll k, ll p)
{
if (p == 0)
        return 1;
 
    ll P = fast_pow(k, p/2);
    P = (P * P) % MOD;
 
    if (p % 2 == 1)
        P = (P * k) % MOD;
 
    return P;
}
ll invmod(ll a,ll m)
{
    return fast_pow(a,m-2);
}

bool isPrime(ll n) 
{ 
   
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
       if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
ll nextPowerOf2(ll n)
{
    n>>=1;
    ll count = 0;

    if (n && !(n & (n - 1)))
        return n;

    while( n != 0)
    {
        n >>= 1;
        count += 1;
    }

    return 1 << count;
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
    C[0] = 1;
  
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 


//////////////////////*********CODE***********/////////////////////
int main() {
    ll n,x;
    cin>>n>>x;
    if(n<=x){
     cout<<min(abs(n-x),n)<<endl;
    }
    else{
        ll y=n%x;
        cout<<min(y,abs(y-x))<<endl;
    }
}

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

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.next();
    let s: String = sc.next();
    let t: String = s[0..(n / 2)].to_string();
    let t = t.clone() + &t;
    println!("{}", if s == t { "Yes" } else { "No" });
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}


Measured memory_bytes: 4352
def calRate(m, r):
    return int(1.0 * m * (100.0 + r) / 100.0)

while True:
    x, y, s = map(int, raw_input().split())
    if x == 0 and y == 0 and s == 0: break
    ans = 0
    for i in range(1, s):
        ix = calRate(i, x)
        j = int((s - ix) * 100.0 / (100.0 + x))
        if j < 1 or j > s-1:
            continue
        while True:
            if calRate(i, x) + calRate(j, x) < s:
                j += 1
            else:
                break
        if calRate(i, x) + calRate(j, x) != s:
            continue
        ans = max(ans, calRate(i, y) + calRate(j, y))
    print ans

Measured memory_bytes: 4276
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
#include<utility>
#include<list>
using namespace std;
using ll = long long;

int main(){
  ll k,n;
  cin >> k >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  ll num = 0;
  for(ll i=1;i<n;i++){
    num = max(num,a[i]-a[i-1]);
  }
  num = max(k-a[n-1]+a[0],num);
  cout << k-num;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define Rep(i,j,n) for(int i=j; i<n; i++)
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<int,P>
#define T tuple<int,int,int> 
using namespace std;
 

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};



int main(){
  int n,m; cin >> n >> m;
  UnionFind u(n);
  rep(i,m){
    int a,b; cin >> a >> b;
    a--; b--;
    u.unite(a,b);
  }
  vector<int> ans(n+1,0);
  rep(i,n){
    ans[u.find(i)]++;
  }

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

  cout << Ans-1 << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ans = 0;
  if (N < 10){
    ans += N;
  } else{
    ans += 9;
    if (N < 100){
      ans += 0;
    } else if (N < 1000){
      ans += N - 99;
    } else{
      ans += 900;
      if (N < 10000){
        ans += 0;
      } else if (N < 100000){
        ans += N - 9999;
      } else{
        ans += 90000;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 5e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	ld w, h, x, y;
	cin >> w >> h >> x >> y;
	cout << setprecision(10) << fixed << (w * h) / 2 << " " << ((int)w % 2 == 0 && (int)h % 2 == 0 && x == w / 2 && y == h / 2) << "\n";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
    a,b=input().split()
    b=100-int(b)
    if b<10:
        A.append(a+'00'+str(b))
    elif b==100:
        A.append(a+str(b))
    else:
        A.append(a+'0'+str(b))
B=sorted(A)
for b in B:
    print(A.index(b)+1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long N = in.nextLong();
		long d = divisor(N);
		if (d == 1) {
			System.out.println(N - 1);
		} else {
			long i = d - 1;
			long j = N / d - 1;
			System.out.println(i + j);
		}
		in.close();
	}

	public static long divisor(long n) {
		long max = 0;
		for (long i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				max = Math.max(max, i);
				//n=PQ+0→ PもQも約数. ただし、Q=Pは↑で登録済みなので登録しない
				if (i != n / i)
					max = Math.max(max, i);
			}
		}
		return max;
	}
}

Measured memory_bytes: 22608
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    map<int, int> cnt;
    int now = 0;
    int base = 1;
    int ans = 0;
    cnt[0] = 1;
    for(int i=s.size()-1;i>=0;i--){
        now = (now + int(s[i] - '0') * base) % 2019;
        base *= 10;
        base %= 2019;
        ans += cnt[now];
        cnt[now] += 1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3408
#include <iostream>

int main() {
  int A, B, C, D;
  std::cin >> A >> B >> C >> D;

  int area1 = A * B;
  int area2 = C * D;
  if ( area1 > area2 ) {
    std::cout << area1 << std::endl;
  } else {
    std::cout << area2 << std::endl;
  }

  return 0;
}


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

//#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef vector<vint>vvint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

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

int p[5][5]={{-1,-1,0,-1,-1},{-1,1,2,3,-1},{4,5,6,7,8},{-1,9,10,11,-1},{-1,-1,0,-1,-1}};
void bfs(vvint &a,map<vvint,int>&s){
    queue<vvint>que[2];
    que[0].push(a);
    s[a]=0;
    rep(i,10){
        while(que[i&1].size()){
            vvint a=que[i&1].front();
            que[i&1].pop();
            rep(y,5)rep(x,5){
                if(a[y][x]!=0)continue;
                rep(d,4){
                    int ny=y+dy[d],nx=x+dx[d];
                    if(ny<0||ny>=5||nx<0||nx>=5||a[ny][nx]<=0)continue;
                    swap(a[ny][nx],a[y][x]);
                    if(s.find(a)==s.end()){
                        s[a]=i+1;
                        que[(i+1)&1].push(a);
                    }
                    swap(a[ny][nx],a[y][x]);
                }
            }
        }
    }
}

signed main(){
    vvint a(5,vint(5,-1));
    while(cin>>a[0][2],a[0][2]!=-1){
        rep(i,3)cin>>a[1][i+1];
        rep(i,5)cin>>a[2][i];
        rep(i,3)cin>>a[3][i+1];
        cin>>a[4][2];

        vvint b(5,vint(5));
        rep(i,5)rep(j,5)b[i][j]=p[i][j];

        map<vvint,int>m1,m2;
        bfs(a,m1);
        bfs(b,m2);

        int ans=21;
        each(it,m1){
            if(m2.find(it->fi)==m2.end())continue;
            chmin(ans,it->se+m2[it->fi]);
        }
        if(ans<=20)cout<<ans<<endl;
        else cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 15832
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> dist(n,vector<int>(n,INF));
    rep(i,n) dist[i][i] = 0;
    rep(i,m){
        int a,b,c,d;
        scanf("%d,%d,%d,%d",&a,&b,&c,&d);
        --a;--b;
        dist[a][b] = c;
        dist[b][a] = d;
    }
    
    rep(k,n)rep(i,n)rep(j,n) dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
    
    int s,g,v,p;
    scanf("%d,%d,%d,%d",&s,&g,&v,&p);
    --s;--g;
    cout << (v - dist[s][g] - dist[g][s] - p) << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1),b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll cnt=0;
  for (int i = 0; i < n; i++) {
    //b[i]がa[i]のモンスターを全力で倒す  
    cnt += min(a[i],b[i]);
    //a[i] = max(a[i]-b[i], 0);
    b[i] = max(b[i]-a[i], 0);
    if(a[i+1]<=b[i]) {
      cnt += a[i+1];
      b[i] -= a[i+1]; 
      a[i+1] = 0;
    }
    else if(a[i+1]>b[i]) {
      cnt += b[i];
    //  b[i] = 0;
      a[i+1] -= b[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024