akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
    long long N = 0;
    long long blue = 0;
    long long red = 0;

    cin >> N >> blue >> red;

    long long count = blue * (N / (red + blue));
    long long rem = N % (red + blue);

    if(rem <= blue){
        count += rem;
    }else{
        count += blue;
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);

		int ans = 0;

		str = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			int h = Integer.parseInt(str[i]);

			if (h >= k) {
				ans++;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 43076
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

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

    string S_copy = S;

    size_t c;
    while ((c = S_copy.find_first_of("A")) != string::npos) {
        S_copy.erase(c, 1);
    }

    if (S_copy != "KIHBR") {
        cout << "NO" << endl;
        return 0;
    }

    vector<ll> A_cnt(6, 0);
    ll idx = 0;
    rep(i, S.length()) {
        if (S[i] == 'A') {
            A_cnt[idx]++;
        } else {
            idx++;
        }
    }

    vector<ll> A_ans = {1, 0, 0, 1, 1, 1};

    rep(i, 6) {
        if (A_cnt[i] > A_ans[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    cout << ((S.substr(0,4) == "YAKI")?"Yes": "No") << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n;
    vector<int> cnt;
    Problem(LL n):n(n),cnt(26,INF){};

    void solve(){
        for(int i=0; i<n; ++i){
            vector<int> tmp(26);
            string s;
            cin >> s;
            for(char c : s){
                tmp[c-'a']++;
            }
            for(int i=0; i<26; ++i){
                cnt[i]=min(cnt[i],tmp[i]);
            }
        }
        string ans;
        for(int i=0; i<26; ++i){
            for(int j=0; j<cnt[i]; ++j){
                ans+='a'+i;
            }
        }
        cout << ans <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}
//cout << fixed << setprecision(10);

int main(){
  ll n,m; cin>>n>>m;
  ll t=m/n;
  while(1){
    if((m-n*t)%t==0){
    cout<<t<<endl; return 0;
    }
    t--;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std ; 
int main()
{
	
	int A,B ;
	cin>>A>>B;
	if((A>B&&B!=1)||(A==1&&B!=1))
	cout<<"Alice "<<endl;
	else if (B>A||(B==1&&A!=1)&&A!=1)
	cout<<"Bob"<<endl;
	else if (A==B)
	cout<<"Draw"<<endl;
	
}

Measured memory_bytes: 256
/***

   Author : Md. Jashim Uddin
   From   : RMSTU

 ***/
#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     pob             pop_back()
#define     ll              long  long int
#define     fast            ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)
#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     mx              320

int main()
{
   string s,ss,str; cin>>s>>ss;
   for(int i=0;i<ss.size()-1;++i)
   {
      str.pb(ss[i]);
   }
   if(str==s)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3580
a, b, m = map(int, input().split())
a_lst = list(map(int, input().split()))
b_lst = list(map(int, input().split()))
waribiki = []
for i in range(m):
    waribiki.append(list(map(int, input().split())))

no_waribiki = min(a_lst) + min(b_lst)

yes_waribiki = 100000000
for i in range(m):
    yes_waribiki = min(yes_waribiki, a_lst[waribiki[i][0]-1] + b_lst[waribiki[i][1]-1] - waribiki[i][2])

print(min(no_waribiki, yes_waribiki))

Measured memory_bytes: 38564
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
from operator import itemgetter

N,M=map(int,input().split())

l=[[-1]*3 for i in range(M)]

for i in range(M):
    p,y=map(int,input().split())
    l[i]=[i,10**10*p+y]
#10**9なのわすれてた
l.sort(key=itemgetter(1))

pre_n=l[0][1]//10**10
count=0
for i in range(M):
    n=int(l[i][1]//(10**10))
    if n==pre_n:
        count+=1
        l[i][1]=n*10**6+count
        
    else:
        pre_n=n
        count=1
        l[i][1]=n*10**6+count
l.sort()

for i in range(M):
    s=str(l[i][1])
    print("0"*(12-len(s))+s)
    
    



Measured memory_bytes: 25028
#include<bits/stdc++.h>
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=1,f=0;
  string s;
  cin >>a;
  for(int n=0;n<a;n++){
    cin >>i[n];
  }
  sort(i,i+a,greater<int>());
  e=i[0];
  for(int n=1;n<a;n++){
    if(i[n]<e) d++,e=i[n];
  }
  cout <<d+1<<'\n';
  return (0);
}


Measured memory_bytes: 256
n=int(input())
klist=[input() for i in range(n)]
ans=1
kset=set(klist)
if len(kset)!=len(klist):
  print("No")
  ans=2
else:
  for i in range(n-1):
    if klist[i][-1]!=klist[i+1][0]:
      print("No")
      ans=2
      break
      
if ans==1:
  print("Yes")




Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll x;
	ll start=100;
	cin >> x;
	int count = 0 ;
	while(start<x)
	{
		start+=start/100;
		count ++;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3624
from collections import Counter
from collections import deque

if __name__ == '__main__':
    n = int(input())
    vs0 = []
    vs1 = []
    for i,v in enumerate(map(int, input().split())):
        if i % 2 == 0:
            vs0.append(v)
        else:
            vs1.append(v)
    vs0 = deque(sorted(Counter(vs0).items(), key=lambda t: t[1]))
    vs1 = deque(sorted(Counter(vs1).items(), key=lambda t: t[1]))
    t0 = vs0.pop()
    t1 = vs1.pop()
    if t0[0] != t1[0]:
        vs0 = (t[1] for t in vs0)
        vs1 = (t[1] for t in vs1)
        print(sum(vs0) + sum(vs1))
    else:
        if len(vs1) == 0:
            if len(vs0) == 0:
                print(t1[1])
            else:
                vs0 = (t[1] for t in vs0)
                print(sum(vs0))
        elif len(vs0) == 0:
            vs1 = (t[1] for t in vs1)
            print(sum(vs1))
        else:
            t00 = vs0.pop()
            t11 = vs1.pop()
            a = t00[1] + t1[1]
            b = t11[1] + t0[1]
            vs0 = (t[1] for t in vs0)
            vs1 = (t[1] for t in vs1)
            print(sum(vs0) + sum(vs1) + (a if a < b else b))




Measured memory_bytes: 20144
n,w = list(map(int,input().split()))
mat = [[0 for i in range(w+1)]for j in range(n+1)]
arr = []
for i in range(n):
	arr.append(list(map(int,input().split())))
for i in range(1,n+1):
	wt,val = arr[i-1][0],arr[i-1][1]
	for j in range(1,w+1):
		if j<wt:
			mat[i][j] = mat[i-1][j]
		else:
			mat[i][j] = max(mat[i-1][j-wt]+val,mat[i-1][j])
print(mat[n][w])

Measured memory_bytes: 171400
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int ans,n,i,s=0,t[100000],x[100000],y[100000],xs=0,ys=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&t[i],&x[i],&y[i]);
	}
	for(i=0;i<n;i++){
		ans=abs(x[i]-xs)+abs(y[i]-ys);
		if(t[i]-s<ans||(t[i]-s)%2!=ans%2){
			printf("No\n");
			return 0;
		}
		xs=x[i];
		ys=y[i];
		s=t[i];
	}
	printf("Yes\n");
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  for (int i=0 ; i<n ; i++)
    cin >> w.at(i);
  
  vector<int> s1(n-1);
  vector<int> s2(n-1);
  for (int i=0 ; i<n-1 ; i++){
    s1.at(i) = 0;
    s2.at(i) = 0;
    for (int j=0 ; j<=i ; j++)
      s1.at(i) += w.at(j);
    for (int j=i+1 ; j<n ; j++)
      s2.at(i) += w.at(j);
  }
  
  vector<int> s(n-1);
  for (int i=0 ; i<n-1 ; i++){
    s.at(i) = abs(s1.at(i) - s2.at(i));
  }
  
  sort(s.begin(), s.end());
  
  cout << s.at(0) << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sidha(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int> 
#define pb push_back
#define st string
#define pairi pair<int,int>

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
	int b,g,n;cin>>b>>g>>n;
	if(g*n>=b){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3636
n, w = [int(i) for i in input().split()]

sv = {}
for i in range(n):
    ww, vv = map(int, input().split())
    if ww > w:
        continue
    added = {}
    for k, v in sv.items():
        if (ww+k) <= w:
            added[ww+k] = vv+v
    for k, v in added.items():
        sv[k] = max(v, sv.get(k, 0))

    sv[ww] = max(vv, sv.get(ww, 0))

print(max(sv.values()))

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

int main() {
	int N, ans, input, A, A2, sum = 0;
	cin >> N;
	vector<int> B;
	for (int i = 0; i < N - 1; i++) {
		cin >> input;
		B.emplace_back(input);
	}
	sum += B[0];
	for (int i = 1; i < B.size(); i++) {
		A = B[i - 1];
		A2 = B[i];
		sum += min(A, A2);
	}
	sum += B[N - 2];
	ans = sum;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int N, M;
vector<P> ab;

int main(void){
    
    scanf("%d %d", &N, &M);
    for(int i = 0; i < M; ++i){
        int a, b; scanf("%d %d", &a, &b);
        ab.push_back(make_pair(b, a));
    }
    sort(ab.begin(), ab.end());
    
    int ans = 0, t = 0;
    for(int i = 0; i < ab.size(); ++i){
        if(t <= ab[i].second){
            t = ab[i].first;
            ++ans;
        }
    }
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    REP(i, N) cin >> x[i] >> y[i] >> h[i];

    ll X, Y, H;
    int zeroh = 0;
    REP(i, N) {
        if (0 < h[i]) {
            zeroh = i;
            break;
        }
    }

    REP(xi, 101) {
        REP(yi, 101) {
            H      = (ll)abs(xi - x[zeroh]) + abs(yi - y[zeroh]) + h[zeroh];
            bool f = true;
            REP(i, N) {
                ll aa = H - (ll)abs(xi - x[i]) - abs(yi - y[i]);
                ll bb = max(aa, 0LL);
                if (h[i] != bb) {
                    f = false;
                    break;
                }
            }
            if (f) {
                std::cout << xi << " " << yi << " " << H << '\n';
                return 0;
            }
        }
    }

    return 0;
}

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

using namespace std;

using ull = unsigned long long;

ull solve(map<ull, ull> &memo, ull n, array<ull, 4> &costs) {
  if (n == 0) {
    return 0;
  } else if (n == 1) {
    return costs.back();
  }

  if (memo.count(n) > 0) {
    return memo[n];
  }

  array<ull, 3> d{2, 3, 5};

  ull ans = costs[3] * n;
  for (int i = 0; i <= 2; ++i) {
    ull k = 0;
    while ((n + k) % d[i] != 0) {
      k++;
    }

    ans = min(ans,
              solve(memo, (n + k) / d[i], costs) + costs[i] + k * costs.back());
    k = 0;
    while ((n - k) % d[i] != 0) {
      k++;
    }

    ans = min(ans,
              solve(memo, (n - k) / d[i], costs) + costs[i] + k * costs.back());
  }

  return memo[n] = ans;
}

int main(int argc, const char *argv[]) {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    ull n;
    array<ull, 4> costs;

    cin >> n;
    for (int i = 0; i < costs.size(); ++i) {
      cin >> costs[i];
    }

    map<ull, ull> memo;
    ull ans = solve(memo, n, costs);
    cout << ans << '\n';
  }

  return 0;
}

Measured memory_bytes: 4488
import bisect

A,B,Q = map(int,input().split())
shrine = [-float('inf')]+[int(input()) for _ in range(A)]+[float('inf')]
temple = [-float('inf')]+[int(input()) for _ in range(B)]+[float('inf')]
query = [int(input()) for _ in range(Q)]

for q in query:
  s = bisect.bisect(shrine,q)
  t = bisect.bisect(temple,q)
  print(
      min(
        max(shrine[s],temple[t])-q, 
        q - min(shrine[s-1],temple[t-1]),
        (shrine[s]-q)*2+(q-temple[t-1]),
        (temple[t]-q)*2+(q-shrine[s-1]),
        (shrine[s]-q)+(q-temple[t-1])*2,
        (temple[t]-q)+(q-shrine[s-1])*2,
        )
        )

Measured memory_bytes: 125144
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
#define pai 3.141592653589793238462643383279





int main(){
  string S; cin >> S;
  rep(i, 3){
    cout << S[i];
  }
  cout << endl;
}

Measured memory_bytes: 3596
from collections import deque
h,w = map(int,input().split())
grid = []
white = 0
grid.append(["#"]*(w+2))
for i in range(h):
    a = list(input())
    white += a.count(".")
    a.insert(0,"#")
    a.append("#")
    grid.append(a)
grid.append(["#"]*(w+2))

grid[1][1] = "1"

def bfs():
    q = deque([(1,1)])
    used = set()
    while q:
        here = q.popleft()
        num = int(grid[here[0]][here[1]])
        x = here[0]
        y = here[1]
        if grid[x-1][y] == "." and (x-1,y) not in used:
            grid[x-1][y] = str(num + 1)
            used.add((x-1,y))
            q.append((x-1,y))
        if grid[x+1][y] == "." and (x+1,y) not in used:
            grid[x+1][y] = str(num + 1)
            used.add((x+1,y))
            q.append((x+1,y))
        if grid[x][y-1] == "." and (x,y-1) not in used:
            grid[x][y-1] = str(num + 1)
            used.add((x,y-1))
            q.append((x,y-1))
        if grid[x][y+1] == "." and (x,y+1) not in used:
            grid[x][y+1] = str(num + 1)
            used.add((x,y+1))
            q.append((x,y+1))

bfs()
if grid[h][w] == ".":
    print(-1)
else:
    print(white-int(grid[h][w]))

Measured memory_bytes: 39920
#include<stdio.h>
int main() 
{
	int a,b,c,n;
	n = 0;
	scanf("%d %d %d", &a, &b, &c);
	while (1)
	{
		if (c % a == 0)
		{
			n = n + 1;
		}
		if (b - a == 0) break;
		a = a + 1;
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n; ++i) if (s[i] == '?') s[i] = 'D';
  cout << s << '\n';
  /*for (int i = 0; i < n; ++i) if (s[i] == 'D') ++ans;
  for (int i = 0; i + 1 < n; ++i) if (s[i] == 'P' && s[i + 1] == 'D') ++ans;
  cout << ans << '\n';*/
}



Measured memory_bytes: 3732
#include <bits/stdc++.h>
 
using namespace std;
 
struct State{
    int tx, ty, kx, ky;
    State(int tx, int ty, int kx, int ky) : tx(tx), ty(ty), kx(kx), ky(ky) {} 
};
 
#define MAX 51
#define INF 1e9
 
int H, W, tx, ty, kx, ky;
int field[MAX][MAX];
const int ttx[] = {-1, 0, 0, 1};
const int tty[] = {0, -1, 1, 0};
const int kkx[] = {1, 0, 0, -1};
const int kky[] = {0, 1, -1, 0};
 
bool inField(int y, int x)
{
    return (0 <= y && y < H && 0 <= x && x < W);
}
 
int bfs()
{
    bool vis[MAX][MAX][MAX][MAX];
    memset(vis, false, sizeof(vis));
    vis[ty][tx][ky][kx] = true;
    queue<State> Q;
    Q.push(State(tx,ty,kx,ky));
    queue<int> cnt;
    cnt.push(0);
 
    int res = INF;
    while (!Q.empty()) {
	State s = Q.front(); Q.pop();
	int _cnt = cnt.front(); cnt.pop();
 
	if (_cnt == 100) break;
	if (s.tx == s.kx && s.ty == s.ky) {
	    res = min(res, _cnt);
	    break;
	}
 
	for (int i = 0; i < 4; i++) {
	    int ntx = s.tx + ttx[i], nty = s.ty + tty[i];
	    int nkx = s.kx + kkx[i], nky = s.ky + kky[i];
 
	    if (!inField(nty, ntx) || field[nty][ntx] == 1) {
		ntx = s.tx, nty = s.ty;
	    }
	    if (!inField(nky, nkx) || field[nky][nkx] == 1) {
		nkx = s.kx, nky = s.ky;
	    }
 
	    if (vis[nty][ntx][nky][nkx]) continue;
	    vis[nty][ntx][nky][nkx] = true;
	    Q.push(State(ntx, nty, nkx, nky));
	    cnt.push(_cnt+1);
	}
    }
    return res;
}
 
int main()
{
    while (cin >> W >> H, (W | H)) {
	cin >> tx >> ty >> kx >> ky;
	tx--, ty--, kx--, ky--;
	for (int i = 0; i < H; i++) {
	    for (int j = 0; j < W; j++) {
		cin >> field[i][j];
	    }
	}
	int res = bfs();
	if (res == INF) {
	    cout << "NA" << endl;
	} else {
	    cout << res << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 9868
use std::cmp;
use std::collections::*;
use std::io::{self, Read};

const MOD: usize = 1000000007;

fn usqrt(u: u32) -> u32 {
    (u as f64).sqrt() as u32
}

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

    let n: u32 = sc.read().unwrap();

    let mut ans = 0;
    for ii in 0..(n + 1) / 2 {
        let i = ii * 2 + 1;

        let mut c = 0;
        for j in 1..i + 1 {
            if i % j == 0 {
                c = c + 1;
            }
        }

        if c == 8 {
            ans = ans + 1;
        }
    }
    println!("{}", ans);
}

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

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll x;
    cin >> x;
    for (ll a = -1000; a <= 1000; ++a)
    {
        for (ll b = -1000; b <= 1000; ++b)
        {
            if (a * a * a * a * a - b * b * b * b * b == x)
            {
                cout << a << " " << b;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
using namespace std;

const int N=500010;
struct edge{int s,t,n;}e[2*N];
int n,k,tot,p[N],q[N],h[N],d[N];
set <int> S;
set <int> ::iterator It;

void work()
{
	scanf("%d %d",&n,&k);
	for (int i=1; i<=n; i++)  scanf("%d",&p[i]),q[p[i]]=i;
	for (int i=1; i<=n; i++)
		{
			if (i>k)  S.erase(p[i-k]);
			It=S.insert(p[i]).first;
			if ((++It)!=S.end())
				e[++tot]=(edge){i,q[*It],h[i]},h[i]=tot,d[q[*It]]++;
		}
	S.clear();
	for (int i=n; i; i--)
		{
			if (i+k<=n)  S.erase(p[i+k]);
			It=S.insert(p[i]).first;
			if ((++It)!=S.end())
				e[++tot]=(edge){i,q[*It],h[i]},h[i]=tot,d[q[*It]]++;
		}
	S.clear();
	for (int i=1; i<=n; i++)  if (!d[i])  S.insert(i);
	for (int i=1; i<=n; i++)
		{
			It=S.begin(),S.erase(It),p[*It]=i;
			for (int j=h[*It]; j; j=e[j].n)
				if (!(--d[e[j].t]))
					S.insert(e[j].t);
		}
	for (int i=1; i<=n; i++)  printf("%d\n",p[i]);
}

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


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

int palindrome(string s)
{
    int l=s.length();
    int flag=1;
    for(int i=0;i<l;i++)
    {
        if(s[i]!=s[l-1-i])
        {
            flag=0;
            break;
        }
    }
    return flag;
}

int main()
{
    string s,s1,s2;
    cin>>s;
    int n=s.length();
    int n1,n2,n3;
    s1=s.substr(0,(n-1)/2);
    s2=s.substr((n+1)/2);
    n1=palindrome(s);
    n2=palindrome(s1);
    n3=palindrome(s2);
    if(n1==1&&n2==1&&n3==1)
    {
        cout<<"Yes";
    }
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N; 
  string S;

  int i; 
  int tmp = 0;
  int max = 0;

  
  cin >> N;
  cin >> S;
  
  for(i=0;i<N;i++){
    if(S[i]=='I'){
      tmp++;
    }else{
      tmp--;
    }
    
    if(tmp > max) max = tmp; 
  }
  cout << max << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cout << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N);
  vector<double> v(N);
  in(v);

  sort(all(v) , greater<>());

  for(int i = N - 2;i >= 0; i--){
    v[i] = (v[i] + v[i + 1]) / 2.0;
  }
  out(v[0]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t r, g, b, n;
    cin >> r >> g >> b >> n;

    int64_t ans = 0;
    for (int64_t i = 0; i * r <= n; ++i) {
        int64_t m = n - i * r;
        for (int64_t j = 0; j * g <= m; ++j) {
            if ((n - i * r - j * g) % b == 0) {
                ++ans;
            }
        }
    }
      

    cout << ans << endl;
}

Measured memory_bytes: 256
from heapq import heapify, _heapify_max, heappushpop, _heappushpop_max

N = int(input())

numbers = [int(x) for x in input().split()]

left = numbers[:N]
left_sum = sum(left)
left_memo = [0] * N
heapify(left)

right = numbers[2 * N:]
right_sum = sum(right)
right_memo = [0] * N
_heapify_max(right)

middle = numbers[N:2 * N]

for i in range(0, N):
  left_sum += (middle[i] - heappushpop(left, middle[i]))
  left_memo[i] = left_sum

for i in range(N - 1, -1, -1):
  right_sum += (middle[i] - _heappushpop_max(right, middle[i]))
  right_memo[i] = right_sum

left_memo.insert(0, sum(numbers[:N]))
right_memo.insert(0, None)
right_memo.append(sum(numbers[2 * N:]))
    
print(
  max([left_memo[i] - right_memo[i + 1] for i in range(N + 1)])
)

Measured memory_bytes: 37212
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int m = sc.nextInt();
    if((n*m)%2==1){
    System.out.println("Yes");
    }else{

    System.out.println("No");
    }
   
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

template<typename T>
vector<T> sieve(T n){//n以下の整数が素数か判定 エラトステネスの篩
    int p=0;
    vector<int>is_prime(n+1,true);
    //vector<int>prime(n);
    is_prime[0]=false;is_prime[1]=false;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            //prime[p++]=i;//p番目の素数 
            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
        }
    }
    return is_prime;
}

int main(){
    int q;
    cin>>q;
    auto prime=sieve<int>(100000);
    vector<int>cnt(100005,0);
    for(int i=1;i<=100000;++i){
            if(prime[i]&&prime[(i+1)/2])cnt[i]=cnt[i-1]+1;
            else cnt[i]=cnt[i-1];
        }
    while(q--){
        int l,r;
        cin>>l>>r;
        l--;
        cout<<cnt[r]-cnt[l]<<endl;
    }
    return 0;
    }


Measured memory_bytes: 1408
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A = readline().strip()
    B = readline().strip()

    if len(A) > len(B):
        ans = 'GREATER'
    elif len(A) < len(B):
        ans = 'LESS'
    else:
        ans = 'EQUAL'
        for a, b in zip(A, B):
            if int(a) > int(b):
                ans = 'GREATER'
                break
            elif int(a) < int(b):
                ans = 'LESS'
                break

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9140
import sys
input = sys.stdin.readline


def main():
    X, Y = list(map(int, input().split()))
    # X = list(map(int, input().split()))
    ans = 0

    if X == 3:
        ans += 100000
    elif X == 2:
        ans += 200000
    elif X == 1:
        ans += 300000

    if Y == 3:
        ans += 100000
    elif Y == 2:
        ans += 200000
    elif Y == 1:
        ans += 300000

    if X == 1 and Y == 1:
        ans += 400000

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {

  int N, X;
  cin >> N >> X;

  vector<int> D(N+1);

  D[0] = 0;

  for (int i = 0; i < N; i++) {
    int L;
    cin >> L;
    D[i+1] = D[i] + L;
  }

  int answer = 0;

  for (int i = 0; i <= N; i++) {
    if (D[i] <= X) {
      answer++;
    } else {
      break;
    }
  }

  cout << answer << endl;

}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
program friendly_rabbits
  implicit none
  integer :: n, a(0:100000), m, i
  a = 0
  read(*,*) n
  read(*,*) a(1:n)
  m = 0
  do i = 1, n
    if (i.eq.a(a(i))) then
      a(i) = 0
      a(a(i)) = 0
      m = m + 1
    end if
  end do
  write(*,'(i0)') m
  stop
end program friendly_rabbits

Measured memory_bytes: 1152
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n = input()
    if n[0]==n[-1]:
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38636
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
struct Graph {
  int V;
  vector<vector<int>> g;
  vector<int> dist;
  Graph(int V) : V(V), g(V), dist(V, -1) {}
  void add_edge(int s, int t) {
    g[s].push_back(t);
    g[t].push_back(s);
  }
};

struct Tree { // rooted tree
  vector<vector<int>> g, parent;
  int root, V, log2_n;
  vector<int> depth;
  int get_depth(int x) { return depth[x]; }
  void dfs(int v, int p, int d) {
    parent[0][v] = p;
    depth[v] = d;
    rep(i, 0, g[v].size()) {
      if (g[v][i] != p)
        dfs(g[v][i], v, d + 1);
    }
  }
  Tree(Graph G, int root)
      : root(root), V(G.V), g(G.g), depth(V), log2_n(1 + (int)log2(V)) {
    parent.resize(log2_n, vector<int>(V));
    dfs(root, -1, 0);
    for (int k = 0; k + 1 < log2_n; k++) {
      for (int v = 0; v < V; v++) {
        if (parent[k][v] < 0)
          parent[k + 1][v] = -1;
        else
          parent[k + 1][v] = parent[k][parent[k][v]];
      }
    }
  }
  int lca(int u, int v) {
    if (depth[u] > depth[v])
      swap(u, v);
    for (int k = 0; k < log2_n; k++) {
      if ((depth[v] - depth[u]) >> k & 1) {
        v = parent[k][v];
      }
    }
    if (u == v)
      return u;
    for (int k = log2_n - 1; k >= 0; k--) {
      if (parent[k][u] != parent[k][v]) {
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  Graph g(N);
  rep(i, 0, N) {
    int k;
    cin >> k;
    rep(j, 0, k) {
      int c;
      cin >> c;
      g.add_edge(i, c);
    }
  }
  Tree t(g, 0);
  int Q;
  cin >> Q;
  loop(Q) {
    int u, v;
    cin >> u >> v;
    cout << t.lca(u, v) << endl;
  }

  return 0;
}



Measured memory_bytes: 30244
// D - Prediction and Restriction
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int N,K,R,S,P; string T;

int winc(char c){ return c=='r'?'p':c=='s'?'r':'s'; }
int winp(char c){ return c=='r'?P:c=='s'?R:S; }

int main(){
	cin>>N>>K>>R>>S>>P>>T;
	vector<string> G(K); rp(i, 0, N) G[i%K] += T[i];
	int ans = 0;
	for(auto s:G){
		int n = s.size();
		pair<char,int> dp[n+1];
		dp[0].first = '-';
		dp[0].second = 0;
		rp(i, 0, n){
			if(dp[i].first == winc(s[i])){
				dp[i+1].first = winc(winc(s[i+1]));//draw or lose
				dp[i+1].second = dp[i].second;
			}
			else{
				dp[i+1].first = winc(s[i]);//win
				dp[i+1].second += dp[i].second + winp(s[i]);
			}
		}
		ans += dp[n].second;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char a[233];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    int t=0;
    cin>>n;
    while(n)
    {
    	a[++t]='a'+(n-1)%26;
    	n--;
    	n/=26;
	}
	for(int i=t;i>=1;i--)
	cout<<a[i];
    return 0;
}


Measured memory_bytes: 3596
import math
#def main(S, b):
if __name__ == '__main__':
    #a, b, c, d = map(int, input().split())

    # x = int(input())
    #a, b = map(int, input().split())

    # a = list(map(int, input().split()))

    s = input()
    t = input()

    if (s == t[:(len(s))] and len(t) == len(s) + 1):

        print("Yes")
    else:
        print("No")
    # s = sum(a)


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

double lw, lh, w, h, x, y;

double solve();

int main() {
  cout << fixed << setprecision(8);
  cin >> lw >> lh >> w >> h >> x >> y;
  cout << solve() << endl;
  return 0;
}

double solve() {
  double ny = 1.0, nx = 1.0;
  lw /= 2;
  lh /= 2;
  w /= 2;
  h /= 2;
  nx = (double)(max(-lw, x - w) + min(lw, x + w)) / 2.0;
  ny = (double)(max(-lh, y - h) + min(lh, y + h)) / 2.0;
  return ny / nx;
}


Measured memory_bytes: 3280
/*
 * AOJDataConversation.cxx
 * 
 * Copyright 2016 Tom Tanaka <torumu@Tom-no-MacBook-Pro.local>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 * 
 * 
 */


#include <iostream>
#include <vector>

int main(int argc, char **argv)
{
	while(true){
	std::vector<int> bef;
	std::vector<int> aft;
	int n;
	std::cin >> n;
	if(n==0){
		break;
	}
	for(int i = 0; i < n; i++){
		char input;
		std::cin >> input;
		bef.push_back(input);
		std::cin >> input;
		aft.push_back(input);
	}
	std::cin >> n;
	for(int i = 0; i < n; i++){
		char input;
		std::cin >> input;
		for(int j = 0; j < bef.size(); j++){
			if(input == bef[j]){
				input = aft[j];
				break;
			}
		}
		std::cout << input;
	}
	std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3096
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int A, B;
	cin >> A >> B;
	if (A == B)cout << "Draw\n";
	else if (A == 1)cout << "Alice\n";
	else if (B == 1)cout << "Bob\n";
	else cout << (A > B ? "Alice\n" : "Bob\n");
	return 0;
}

Measured memory_bytes: 3024
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
s = gets.chomp.to_i

dp = [0,0,0,1,1,1,2,3,4,6,9]
if s <= 10
  puts dp[s]
else
  11.upto(s) do |i|
    dp.push (dp[i-1] + dp[i-3]) % MOD
  end
  puts dp.last
end

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

int main()
{
    string stra, strb;
    cin >> stra >> strb;
    int ans=9999, currentans;
    for(int i=0;i<=stra.length()-strb.length();i++){
        currentans = 0;
        for(int j=0;j<strb.length();j++){
            if(stra[i+j]!=strb[j]){
                currentans ++;
            }
        }
        ans = min(ans, currentans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define out(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define out2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define min(v) *min_element(all(v))
#define max(v) *max_element(all(v))
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint h,w;
    cin>>h>>w;
    lint ans=LINF;
    if(w%3==0||h%3==0){
        cout<<0;
        return 0;
    }
    else ans=min<lint>({ans,w,h});
    rep(i,w%3+1){
        vec a={(w/3+i)*h,(w-w/3-i)*(h/2),(w-w/3-i)*(h-h/2)};
        ans=min<lint>(ans,max(a)-min(a));
    }
    rep(i,h%3+1){
        vec a={(h/3+i)*w,(h-h/3-i)*(w/2),(h-h/3-i)*(w-w/2)};
        ans=min<lint>(ans,max(a)-min(a));
    }
    cout<<ans;
}

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

using namespace std;

int N,M,K,L,R,H,W;
//long long int N,M,K,L,R,H,W;

//constexpr long long int MOD=1000000007;
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double  EPS=1e-8;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N;
	vector<vector<int>>edge(N,vector<int>(N));
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cin>>edge[i][j];
		}
	}
	long long int ans=0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			ans+=min(edge[i][j],edge[j][i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3236