akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		//		new Main().solveC();
		new Main().solveC2();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String[] stringS = new String[4];

		try {
			scanner = new Scanner(System.in);
			stringS = scanner.next().split("");

			int res = 0;
			for (int i = 0; i < stringS.length; i++) {
				if (stringS[i].equals("+")) {
					res++;
				} else if (stringS[i].equals("-")) {
					res--;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int wkN = 0;
			int tmp = numN;
			while (tmp != 0) {
				wkN += tmp % 10;
				tmp /= 10;
			}

			System.out.println(numN % wkN == 0 ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int[] wk;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numK = scanner.nextInt();
			wk = new int[numN];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}

			Arrays.sort(wk);

			int res = 0;
			int wkN = numN;
			while (wkN > 0) {
				if (res == 0) {
					wkN = wkN - numK;
					res++;
				} else {
					wkN = wkN - (numK - 1);
					res++;
				}
			}
			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC2() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int[] wk;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numK = scanner.nextInt();
			wk = new int[numN];

			int wkN = numN - numK;
			int wkK = numK - 1;
			int res = 1 + (wkN % wkK == 0 ? (wkN / wkK) : (wkN / wkK) + 1);
			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
int main() {
    int n;
    scanf("%d", &n);
    int a[n];
    int b[n];
    int c[n - 1];

    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for(int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }
    for(int i = 0; i < n - 1; i++) {
        scanf("%d", &c[i]);
    }
    
    int ans = 0;

    for(int i = 0; i < n; i++) {
        ans += b[a[i] - 1];
        if(i != 0 && a[i] - a[i-1] == 1) {
            ans += c[a[i-1] - 1];
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 128
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // 入力
        MyScanner sc = new MyScanner(System.in);
        String S = sc.nextString();

        // 初期化
        String ans = "";

        // 主処理
        if ("Sunny".equals(S)) {
            ans = "Cloudy";
        } else if ("Cloudy".equals(S)) {
            ans = "Rainy";
        } else if ("Rainy".equals(S)) {
            ans = "Sunny";
        }

        // 出力
        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader br;
        // 標準入力から入力値を取得
        MyScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }
        // 標準入力を文字列で取得
        public String nextString() throws IOException {
            return br.readLine();
        }
        // 標準入力を文字列の配列で取得
        public String[] nextStringArray() throws IOException {
            return nextString().split(" ");
        }
        // 標準入力を数値で取得
        public int nextInt() throws IOException {
            return Integer.parseInt(nextString());
        }
        // 標準入力を数値の配列で取得
        public int[] nextIntArray() throws IOException {
            String[] strArr = nextStringArray();
            int[] intArr = new int[strArr.length];
            for(int i = 0; i < strArr.length; i++) {
                intArr[i] = Integer.parseInt(strArr[i]);
            }
            return intArr;
        }
    }

}


Measured memory_bytes: 21332
def main(str)
  n, m = str.split(' ').map(&:to_i)
  n * (n - 1) / 2 + m * (m - 1) / 2
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal(1, main("2 1"))
    assert_equal(9, main("4 3"))
    assert_equal(0, main("1 1"))
    assert_equal(81, main("13 3"))
  end
end




Measured memory_bytes: 14308
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print1(a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	if(a>=10||b>=10) print1(-1);
	else print1(a*b);
	return 0;
}

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

  ll H, W;
  cin >> H >> W;

  ll ans = INF;
  if(H % 3 == 0 || W % 3 == 0){
    ans = 0;
  }else{
    // 横に3分割
    if(W > 3){
      chmin(ans,H * (W - W / 3 * 3));
      ll w = (W + 3 - 1) / 3;
      chmin(ans, H * (3 * w - W));
    }

    // 縦に3分割
    if(H > 3){
      chmin(ans, W * (H - H / 3 * 3));
      ll h = (H + 3 - 1)/ 3;
      chmin(ans, W * (3 * h - H));
    }

    for(int i = 1; i < W;i++){
      ll A = H * i;
      ll h = H / 2;
      ll B = (W - i) * h;
      ll C = (W - i) * (H - h);
      chmin(ans, max(max(A, B), C) - min(min(A, B), C));
    }

    for(int i = 1; i < H;i++){
      ll A = W * i;
      ll w = W / 2;
      ll B = (H - i) * w;
      ll C = (H - i) * (W - w);
      chmin(ans, max(max(A, B), C) - min(min(A, B), C));
    }
  }

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
flag1 = False
flag2 = False
flag3 = False
if a == 5 or b == 5 or c == 5:
    flag1 = True
if a == 7 or b == 7 or c == 7:
    flag2 = True
if a + b + c == 17:
    flag3 = True

if flag1 and flag2 and flag3:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
import java.util.*;

// ABC 62-D
// http://abc062.contest.atcoder.jp/tasks/arc074_b

public class Main {
	
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		
		for (int i = 0; i < n; i++) {
			int num = in.nextInt();
			
			int count = 0;
			if (map.containsKey(num)) {
				count = map.get(num);
			}
			
			map.put(num, count + 1);
		}
		
		int answer = 0;
		for (int num : map.keySet()) {
			if (map.get(num) % 2 == 1) {
				answer++;
			}
		}
		System.out.println(answer);
	}
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = max(max(a+b, a-b), a*b);
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    ll ans = 0;
    vector<ll> P(A), Q(B), R(C);
    rep(i, A) cin >> P[i];
    rep(i, B) cin >> Q[i];
    rep(i, C) cin >> R[i];
    sort(P.rbegin(), P.rend());
    sort(Q.rbegin(), Q.rend());
    sort(R.rbegin(), R.rend());
    priority_queue<ll> pque;
    rep(i, X) {
        pque.push(P[i]);
    }
    rep(i, Y) {
        pque.push(Q[i]);
    }
    rep(i, C) {
        pque.push(R[i]);
    }
    ll cnt = 0;
    while (cnt < X + Y) {
        cnt++;
        ans += pque.top();
        pque.pop();
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 8816
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50

def run():
    N = int(input())
    S = input()
    n_white = [0] * (N+1)
    black_position = []
    for i in range(N-1, -1, -1):
        n_white[i] = n_white[i+1]
        if S[i] == '#':
            black_position.append(i)
        else:
            n_white[i] += 1
    #print(black_position)
    #print(n_white)
    ans = min(len(black_position), N - len(black_position))
    for p, k in enumerate(black_position[::-1]):
        ans = min(ans, p + n_white[k])

    print(ans)

if __name__ == "__main__":
    run()

Measured memory_bytes: 20036
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

from collections import deque
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


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


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():

    a, b, c, k = wi()
    ans = 0
    d = k - a
    e = d - b
    f = e - c
    if d >= 0:
        ans += a
        if e >= 0 and f >= 0:
            ans -= c
            print(ans)
        elif e >= 0 and f < 0:
            ans -= e
            print(ans)
        else:
            print(ans)
    else:
        ans += k
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65308
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int P, Q, R;
    cin >> P >> Q >> R;
    cout << P + Q + R - max({P, Q, R}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std ;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;

int main(){
    ll n ;
    cin >> n ;
    if(n % 2 == 0 )cout << n << endl;
    else cout << n*2 << endl;
}

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

using namespace std;

int main(){
	for(int i = 1; i <= 9; i ++ ){
		for(int j = 1; j <= 9; j ++ ){
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3088
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,ans=0,i;
  cin >> n >> m;
  for(i=1; i*i<=m; i++) {
    if(m%i==0) {
      if(i*n<=m) {
        ans=max(ans,i);
      }
      if(m%(m/i)==0&&m/i*n<=m) {
        ans=max(ans,m/i);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
a = int(input())
if a == 1: print('Yes')
else:
    if a <= 81:
        b = round(math.sqrt(a))
        while a % b != 0: b -= 1
        c = int(a / b)
        if b < 10 and c < 10: print('Yes')
        else: print('No')
    else: print('No')

Measured memory_bytes: 3060
A, B, K = map(int, str(input()).split(" "))
disp = []
for i in [j for j in range(A, A + K) if j <= B]:
    disp.append(i)
for i in [j for j in range(B - K + 1, B + 1) if A <= j]:
    disp.append(i)
for i in sorted(set(disp)):
    print(i)

Measured memory_bytes: 3064
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


s = S()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
    print("Bad")
else:
    print("Good")

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i=0; i< (int)(n); i++)
typedef long long ll;

// solution 2
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> ss(M), cc(M);
    rep(i, M) {
        cin >> ss[i] >> cc[i];
    }
    rep(i, pow(10, N)){
        string t = to_string(i);
        if (t.size() == N) {
            bool found = true;
            rep(j, M) {
                if (t[ss[j] - 1] != cc[j] + '0') {
                    found = false;
                    break;
                }
            }
            if (found) {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1;
    return 0;

}

Measured memory_bytes: 4040
var
  a: array [1..50] of real;
  n, i, x, num: longint;
procedure swap(var x, y: real); inline;
var
  t: real;
begin
  t := x;
  x := y;
  y := t;
end;
procedure push(x: real); inline;
var
  i: longint;
begin
  inc(num);
  a[num] := x;
  i := num;
  while (i > 1) and (a[i] < a[i shr 1]) do
  begin
    swap(a[i], a[i shr 1]);
    i := i shr 1;
  end;
end;
function pop: real; inline;
var
  i, x: longint;
begin
  pop := a[1];
  a[1] := a[num];
  dec(num);
  i := 1;
  x := 2;
  if (x < num) and (a[x + 1] < a[x]) then
    inc(x);
  while (x <= num) and (a[x] < a[i]) do
  begin
    swap(a[x], a[i]);
    i := x;
    x := i shl 1;
    if (x < n) and (a[x + 1] < a[x]) then
      inc(x);
  end;
end;
begin
  read(n);
  num := 0;
  for i := 1 to n do
  begin
    read(x);
    push(x);
  end;
  for i := 1 to n - 1 do
    push((pop + pop) / 2);
  writeln(pop : 0 : 6);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

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

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define REP(n) for(int i = 0; i < n; i++)
#define all(p) p.begin(), p.end()
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
template<class X=int>inline X min(X a,X b,X c){return min(min(a,b),c);}
template<class X=int>inline X min(X a,X b,X c,X d){return min(min(a,b,c),d);}
template<class X=int> inline X max(X a,X b,X c){return max(max(a,b),c);}
template<class X=int> inline X max(X a,X b,X c,X d){return max(max(a,b,c),d);}
template<class X=int> inline X mid(X s,X e){return (s+(e-s)/2);}
template<class X=int> inline X len(X s,X e){return (e-s+1);}
const int MOD = 1e9 + 7;
const int INF = 987654321;
const bool TESTCASES = 0;
const bool CODEJAM = 0;

void solve()
{
	int n;
	cin >> n;
	int ct = 0;
	for(int i = 1, x; i <= n; i++)
	{
		cin >> x;
		if((x&1) and (i&1)) ct++;
	}
	cout << ct;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int T = 1;
	if(TESTCASES) cin >> T;
	for(int t = 1; t <= T; t++)
	{
		if(CODEJAM) cout << "Case #" << t << ": ";
		solve();
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>a[i];
  ll sum = 0;
  ll ret = 0;
  for(int i=0;i<n;i++){
    sum += (a[i] + 1);
    if(i-m>=0)sum-=(a[i-m]+1);
    ret=max(ret, sum);
  }
  printf("%.10f\n",ret/2.0);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

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

    vector <int> v[n + 1];

    for (int i = 1; i <= n; i++) {
        int x, no;
        cin >> x >> no;
        for(int j = 0; j < no; j++) {
            int temp;
            cin >> temp;
            v[x].push_back(temp);
        }
    }

	queue <int> q;
	q.push(1);
	
	int dis[n + 1];
	for (int i = 0; i <= n; i++)
		dis[i] = -1;
	dis[1] = 0;
		
	bool vis[n + 1] = {0};
    vis[1] = 1;
	while (!q.empty()) {
		for (int i = 0; i < v[q.front()].size(); i++) {
			int temp = v[q.front()][i];
			if (!vis[temp]) {
				q.push(temp);
				vis[temp] = 1;
				dis[temp] = dis[q.front()] + 1;
			}	
		}
		q.pop();
	}
	
	for (int i = 1; i <= n; i++)
		cout << i << ' ' << dis[i] << '\n';
}
	


Measured memory_bytes: 3168
/*
    It’s Always Darkest Before the Dawn
                This Time is that Darkness in you Life
                                                            */
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define pb push_back  
#define F first
#define S second
#define pii pair<int,int>
#define all(a) a.begin(),a.end()
 
const ll mod=1e9+7,di=998244353,N=3e5+1;
 
bool IsQuery=false; 
ll q=1,a[N];
 
map<int,vector<int>> edge;
map<int,bool> occ;
 
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
 
void solve(){
		
  	ll n;
  	cin>>n;
  
  	for(int i=1;i<=n;i++)
      cin>>a[i];
  	 
  	ll dp[n+2]={0};
  	
  	for(int i=1;i<=n;i++)
      dp[i]=INT_MAX;
  	
  	dp[1]=0;
  
  	for(int i=1;i<n;i++){
      
      dp[i+1]=min(dp[i]+abs(a[i+1]-a[i]),dp[i+1]);
      dp[i+2]=min(dp[i]+abs(a[i+2]-a[i]),dp[i+2]);
    }
    
    cout<<dp[n];
    return;   
} 
int main(){
    
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    if(IsQuery)
    cin>>q;
 
    for(int i=0;i<q;i++){
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 5180
n=int(input())
c=[0for i in range(n)]
s=[0for i in range(n)]
f=[0for i in range(n)]
for i in range(n-1):
  c[i],s[i],f[i]=map(int,input().split())
for i in range(n):
  time=0
  for j in range(i,n-1):
    if(time<=s[j]):
      time=s[j]+c[j]
    else:
      x=(time-s[j])//f[j]
      if(time%f[j]!=0):
        x+=1
      time=s[j]+f[j]*x+c[j]
  print(time)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
using pint = pair<int, int>;

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

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

int main()
{
  int n;
  cin >> n;
  map<string, int> mp;

  rep(i, n)
  {
    string s;
    cin >> s;
    mp[s]++;
  }

  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct P
{
	int pos,nxt,num;
}p[20100];
bool operator<(const P &a,const P &b)
{
	return a.pos<b.pos;
}
int np;
int t[20100];
int n;
namespace G
{
	struct E
	{
		int to,nxt;
	}e[1000100];
	int f1[200100],ne,pnum;
	int dfn[200100],low[200100],dfsc;
	int sccnum[200100],sccc;
	int s[200100],top;
	void me(int a,int b)
	{
		e[++ne].to=b;e[ne].nxt=f1[a];f1[a]=ne;
	}
	void tarjan(int u)
	{
		dfn[u]=low[u]=++dfsc;
		s[++top]=u;
		int v;
		for(int k=f1[u];k;k=e[k].nxt)
		{
			v=e[k].to;
			if(!dfn[v])
			{
				tarjan(v);
				low[u]=min(low[u],low[v]);
			}
			else if(!sccnum[v])
				low[u]=min(low[u],dfn[v]);
		}
		if(low[u]==dfn[u])
		{
			sccc++;
			while(top&&s[top]!=u)	sccnum[s[top--]]=sccc;
			sccnum[s[top--]]=sccc;
		}
	}
}
namespace SegT
{
#define lc (num<<1)
#define rc (num<<1|1)
#define mid ((l+r)>>1)
	int dat[200100];
	int L,R,x;
	void build(int l,int r,int num)
	{
		if(l==r)
		{
			dat[num]=p[l].nxt;
			return;
		}
		build(l,mid,lc);build(mid+1,r,rc);
		dat[num]=++G::pnum;
		G::me(dat[num],dat[lc]);G::me(dat[num],dat[rc]);
	}
	void addx(int l,int r,int num)
	{
		if(L<=l&&r<=R)
		{
			G::me(x,dat[num]);
			return;
		}
		if(L<=mid)	addx(l,mid,lc);
		if(mid<R)	addx(mid+1,r,rc);
	}
#undef lc
#undef rc
#undef mid
}
bool ok(int x)
{
	G::ne=0;
	memset(G::f1,0,sizeof(G::f1));
	memset(G::sccnum,0,sizeof(G::sccnum));
	memset(G::dfn,0,sizeof(G::dfn));
	memset(G::low,0,sizeof(G::low));
	G::dfsc=G::sccc=G::top=0;
	G::pnum=np;
	SegT::build(1,np,1);
	int l=1,r=0,i;
	for(i=1;i<=np;i++)
	{
		while(r<np&&p[r+1].pos-p[i].pos<x)	r++;
		while(l<=np&&p[i].pos-p[l].pos>=x)	l++;
		SegT::x=i;
		if(l<i)	{SegT::L=l;SegT::R=i-1;SegT::addx(1,np,1);}
		if(i<r)	{SegT::L=i+1;SegT::R=r;SegT::addx(1,np,1);}
	}
	for(i=1;i<=np;i++)
		if(!G::dfn[i])
			G::tarjan(i);
	for(i=1;i<=np;i++)
		if(G::sccnum[i]==G::sccnum[p[i].nxt])
			return 0;
	return 1;
}
int main()
{
	int i,a,b,l,r,mid;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&a,&b);
		p[++np].pos=a;p[np].num=i;
		p[++np].pos=b;p[np].num=i;
	}
	sort(p+1,p+np+1);
	for(i=1;i<=np;i++)
	{
		if(!t[p[i].num])	t[p[i].num]=i;
		else
		{
			p[i].nxt=t[p[i].num];
			p[t[p[i].num]].nxt=i;
		}
	}
	l=0;r=1e9+1;
	while(r-l>1)
	{
		mid=l+(r-l)/2;
		if(ok(mid))	l=mid;
		else	r=mid;
	}
	printf("%d",l);
	return 0;
}


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

int debug = 1;

const int N = 2e6 + 10;
int mod = 998244353;

int n, m;
int fac[N], fre[N], c[3][N];

int add(int a, int b) {
    a += b;
    while (a >= mod) a -= mod;
    return a;
}

int sub(int a, int b) {
    a -= b;
    while (a < 0) a += mod;
    return a;
}

int mul(int a, int b) {
    return a * b % mod;
}

int pw(int x, int p) {
    if (p == 0) return 1;
    if (p % 2) return pw(x, p - 1) * x % mod;
    int pp = pw(x, p / 2);
    return pp * pp % mod;
}

int rev(int a) {
    return pw(a, mod - 2);
}

void precalc() {
    fac[0] = 1;
    fre[0] = rev(fac[0]);
    rep(i, 1, N) {
        fac[i] = mul(fac[i - 1], i);
        fre[i] = rev(fac[i]);
    }
}

int C(int nn, int k) {
    if (nn - k < 0) return 0;
    return mul(fac[nn], mul(fre[k], fre[nn - k]));
}

int f(int s, int param) {
    return C(n-param+s, n-param);
}

int g(int s, int param) {
    int res = 0;
    rep(a, 0, m + 1) {
        if ((s - a) % 2 == 0 && (s - a) >= 0) {
            res = add(res, mul(f((s - a) / 2, param), C(n+1-param, a)));
        }
    }
    return res;
}

main() {
    cin >> n >> m;
    precalc();
    int ans = sub(g(3 * m, 1), mul(n, sub(g(m, 1), g(m, 2))));
    cout << ans << '\n';
}

Measured memory_bytes: 33280
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える
int n;
vector<int> d;

int main(){
    cin >> n;
    d.resize(n);
    rep(i, n) cin >> d[i];
    
    //dが小→大にソートされる
    sort(all(d));

    cout << d[n/2] - d[n/2 -1]  << endl;
}

Measured memory_bytes: 640
a=int(input())
S=[1,2,3,4,5,6,7,8,9,10,11,12,13]
H=[1,2,3,4,5,6,7,8,9,10,11,12,13]
C=[1,2,3,4,5,6,7,8,9,10,11,12,13]
D=[1,2,3,4,5,6,7,8,9,10,11,12,13]
for j in range(a):
    x,n = input().split()
    n = int(n)
    if x == 'S':
        S.remove(n)
    elif x == 'H':
        H.remove(n)
    elif x == 'C':
        C.remove(n)
    else:
        D.remove(n)
if len(S)!=0:
    for i in S:
        print('S',str(i))
if len(H)!=0:
    for i in H:
        print('H',str(i))
if len(C)!=0:
    for i in C:
        print('C',str(i))
if len(D)!=0:
    for i in D:
        print('D',str(i))


Measured memory_bytes: 5620
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

int main()
{
	map<string, int> m;
	queue<pair<string, int>> Q;
	int n, q;
	int consumed_time = 0;
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; i++)
	{
		string s;
		int t;
		cin >> s >> t;
		m.insert(make_pair(s,t));
		Q.push(make_pair(s, t));
	}
	/*for (auto i = m.begin(); i != m.end() ; i++)
	{
		cout << i->first << " " << i->second << endl;
	}*/

	while (!Q.empty())
	{
		auto t = Q.front(); Q.pop();
		if (t.second <= q)
		{
			consumed_time += t.second;
			cout << t.first << " " << consumed_time << endl;
		}
		else
		{
			consumed_time += q;
			Q.push(make_pair(t.first, t.second - q));
		}
	}

	return 0;
}

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

vector<int> Z_algorithm(string S){
  int c = 0, n = S.length();
  vector<int> Z(n,0);
  for(int i = 1; i < n; ++i){
    int l = i - c;
    if(i + Z[l] < c + Z[c]){
      Z[i] = Z[l];
    }else{
      int j = max(0, c + Z[c] - i);
      while(i + j < n && S[j] == S[i+j]) ++j;
      Z[i] = j;
      c = i;
    }
  }
  return Z;
}

int main(){
  int N;
  string s;
  cin >> N >> s;
  int ans = 0;
  for(int i = 0; i < N; ++i){
    vector<int> P = Z_algorithm(s.substr(i));
    int M = P.size();
    for(int j = 0; j < M; ++j){
      //  cerr << i << " " << P[i] << endl;
      ans = max(ans,min({P[j],j,M-j}));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#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> v(n);
  rep(i ,n) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = (double)v[0];
  rep(i,n) {
    if(i > 0){
      ans = (double)(ans + v[i]) / 2;
    }
  }
  cout << fixed << ans << setprecision(5) << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> suffix(n);
  
  rep(i, n) {
    cin >> x[i] >> y[i];
    suffix[i] = i;
  }

  //階乗計算
  int fac = 1;
  for(int i = 1; i <= n; ++i) {
    fac *= i;
  }
  
  double sum = 0.0;
  do{
    for(int i = 1; i < n; ++i) {
      double tmp = 0.0;
      int xt = x[suffix[i-1]] - x[suffix[i]];
      int yt = y[suffix[i-1]] - y[suffix[i]];
      tmp = sqrt(double(xt)*xt + double(yt)*yt);
      sum += tmp;
    }
  }while(next_permutation(suffix.begin(), suffix.end()));
  
  double ans = sum / fac;
  cout << ans << endl;
  return 0;
}
    

Measured memory_bytes: 3848
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    while(true){
      int midterm = sc.nextInt();
      int fin = sc.nextInt();
      int makeup = sc.nextInt();

      int totalScore = midterm + fin;
      if (midterm == -1 && fin == -1 && makeup == -1){
        break;
      } else if (midterm == -1 || fin == -1) {
        System.out.println("F");
      } else {
        if (totalScore >= 80) {
          System.out.println("A");
        } else if (totalScore >= 65 && totalScore < 80) {
          System.out.println("B");
        } else if (totalScore >= 50 && totalScore < 65) {
          System.out.println("C");
        } else if (totalScore >= 30 && totalScore < 50) {
          if (makeup >= 50) {
            System.out.println("C");
          } else {
            System.out.println("D");
          }
        } else {
          System.out.println("F");
        }
      }
    }
  }
}



Measured memory_bytes: 26288
#include<stdio.h>

int main() {
  int n, Rt;
  int maxv = -2e9;
  int minv = 2e9;

  scanf("%d", &n);

  for ( int i = 0; i < n; i++ ) {
    scanf("%d", &Rt);
    maxv = maxv > Rt-minv ? maxv : Rt-minv;
    minv = minv < Rt ? minv : Rt;
  }

  printf("%d\n", maxv);

  return 0;
}


Measured memory_bytes: 2732
import sys
s = sys.stdin.readline().strip()
ac = True
if s[0] == "A" and s[1].islower():
    n = len(s)
    c = 0
    for i in range(2, n):
        if s[i].isupper():
            if s[i] == "C" and i < n-1: c += 1
            else:
                ac = False
                break
        if c > 1:
            ac = False
            break
    if c != 1: ac = False
else:
    ac = False
print("AC" if ac else "WA")


Measured memory_bytes: 3060
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 8223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	vector<pii> P(N);
	VI A(N), B(N);
	REP(i, N) {
		cin >> A[i] >> B[i];
		P[i] = pii(A[i] + B[i], i);
	}
	SORT(P);
	int dp[5050][5050];
	REP(i, 5050) REP(j, 5050)dp[i][j] = LLINF;
	dp[0][0] = 0;
	REP(i, N) {
		REP(j, N) {
			if (dp[i][j] != LLINF) {
				int id = P[i].second;
				chmin(dp[i + 1][j], dp[i][j]);
				if (dp[i][j] <= A[id])chmin(dp[i + 1][j + 1], dp[i][j] + B[id]);
			}
		}
	}
	int res = -1;
	REP(i, N + 1)if (dp[N][i] != LLINF)res = i;
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 199680
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	int n;
	int a[50000], b[50000];
	int amax1 = 0, amax2 = 0, bmax1 = 0, bmax2 = 0;
	int ama1 = 0, bma1 = 0;
	int co = 0, co1 = 0;
	cin >> n;
	for (int i = 0; i < n / 2; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n / 2);
	sort(b, b + n / 2);
	for (int j = 0; j < n / 2; j++) {
		co++;
		co1++;
		if (a[j] != a[j + 1] || j == n / 2 - 1) {
			if (co > amax1) {
				amax2 = amax1;
				amax1 = co;
				ama1 = a[j];
			}
			else if (co > amax2) {
				amax2 = co;
			}
			co = 0;
		}
		if (b[j] != b[j + 1] || j == n / 2 - 1) {
			if (co1 > bmax1) {
				bmax2 = bmax1;
				bmax1 = co1;
				bma1 = b[j];
			}
			else if (co1 > bmax2) {
				bmax2 = co1;
			}
			co1 = 0;
		}
	}
	if (ama1 == bma1) {
		if (amax2 > bmax2) {
			amax1 = amax2;
		}
		else {
			bmax1 = bmax2;
		}
	}
	cout << n - amax1 - bmax1 << endl;
}
	

Measured memory_bytes: 640
import sys

a, b, c = map(int,input().split())
k = int(input())

for i in reversed(range(1,k+1)):
    ck = c * (2 ** i)
    bk = b * (2 ** (k-i))
    ak = a * ((2 ** (k - i - (k - i))))
    if ck > bk > ak:
        print('Yes')
        sys.exit()
print('No')

Measured memory_bytes: 9188
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

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

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump(int *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	
	long double n,m,d;
	cin >> n >> m >> d;

	printf("%.8Lf\n",(d==0?1:2)*(n-d)*(m-1)/(n*n)); 

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 1e5 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//


int n , m , q, a[60] , b[60] , c[60], d[60];
ll ans;
vector < int > v;

void backTrack(int idx , int lst){
	if(idx == n){
		ll curSum = 0;
		for(int i = 0 ; i < q ; ++i){
			if(v[b[i]] - v[a[i]] == c[i])
				curSum += d[i];
		}
		ans = max(ans , curSum);
		return ;
	}
	for(int i = lst ; i < m ; ++i){
		v.push_back(i);
		backTrack(idx+1 , i);
		v.pop_back();
	}
}


int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	
	scanf("%d %d %d", &n , &m, &q);
	for(int i = 0 ; i < q ; ++i){
		scanf("%d %d %d %d", a+i, b+i, c+i, d+i);
		--a[i];
		--b[i];
	}
	//vector < int > v;
	backTrack(0 , 0);
	printf("%lld\n" , ans);
	
    return 0;
}




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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 2e5 + 5;

int N, son[MAXN][2], cnt = 1, root = 1;
ll ans = 0, L;

char s[MAXN];

void extend(){
	int cur = root, len = strlen(s + 1);
	up (i, 1, len) {
		int nxt = s[i] - '0';
		if (!son[cur][nxt]) son[cur][nxt] = ++cnt;
		cur = son[cur][nxt];
	}
}

ll calc(ll n){
	if (!n) return 0LL;
	ll sum = 1;
	while (n % 2 == 0) {
		n >>= 1;
		sum <<= 1;
	}
	return sum;
}

void DFS(int k, int dep){
	if (!k) {
		ans ^= calc(L - dep + 1);	
		return;
	}
	DFS(son[k][0], dep + 1);
	DFS(son[k][1], dep + 1);
}

int main(){
	scanf("%d%lld", &N, &L);
	up (i, 1, N) {
		scanf("%s", s + 1);
		extend();
	}
	DFS(root, 0);
	puts(ans ? "Alice" : "Bob");
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int count = 0;
  for (int i = a; i <= b; i++) {
    if(i/10000 == i%10 && (i%10000)/1000 == (i%100)/10)
      count++;
  }
  cout << count << endl;
}

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

using namespace std;

int numDivByTwo(int a) {
  int c = 0;
  while(a % 2 == 0) {
    a /= 2;
    ++c;
  }
  return c;
}

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

  int N;
  cin >> N;
  
  int count = 0;
  int a;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    count += numDivByTwo(a);
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
class UnionFind {
  vector<ll> par, rank; // par > 0: number, par < 0: -par
public:
  void init(ll n) {
    par.resize(n); rank.resize(n);
    fill(par.begin(), par.end(), 1); fill(rank.begin(), rank.end(), 0);
  }
  ll getSize(ll x) {
    return par[find(x)];
  }
  ll find(ll x) {
    if (par[x] > 0) return x;
    return -(par[x] = -find(-par[x]));
  }
  void merge(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      par[y] += par[x];
      par[x] = -y;
    } else {
      par[x] += par[y];
      par[y] = -x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
  bool isSame(ll x, ll y) {
    return find(x) == find(y);
  }
};
int main(void){
    int n,m;
    cin>>n>>m;
    int a[10000],b[10000];
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--,b[i]--;
    }
    int ans=0;
    for(int i=0;i<m;i++){
        UnionFind uf;
        uf.init(n);
        for(int j=0;j<m;j++){
            if(i==j) continue;
            uf.merge(a[j],b[j]);
        }
        if(uf.getSize(0)!=n) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from functools import reduce

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def gcd_list(numbers):
    return reduce(gcd, numbers)


n = int(input())
a = list(map(int, input().split()))
print(gcd_list(a))

Measured memory_bytes: 14596
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include <iomanip>
using namespace std;

int main() {
  int N;
  double ans = 0;
  string s;

  cin >> N;

  vector<double> x(N);
  vector<string> u(N);
  for(int i = 0; i < N; i++){
    cin >> x[i] >> u[i];
  }

  for(int i = 0; i < N; i++){
    s = u[i];
    if(s == "JPY"){
      ans += x[i];
    }else if(s == "BTC"){
      ans += x[i]*380000.0;
    }
  }

  cout << fixed;
  cout << setprecision(5) << ans << endl;

}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	int res[n];
	for (int i = n - 1; i >= 0; i--) {
		int step = i + 1;
		int cnt = 0;
		for (int j = i; j < n; j += step) if (j > i) cnt += res[j];
		res[i] = (cnt & 1) ^ a[i];
	}
	std::set<int> st;
	for (int i = 0; i < n; i++) if (res[i]) st.insert(i);
	std::cout << st.size() << std::endl;
	for (auto i : st) std::cout << i + 1 << std::endl;
	return 0;
}


Measured memory_bytes: 8448
#include <stdio.h>
int main(){

 int a, b, op;
 while(1) {
 scanf("%d %c %d", &a, &op, &b);
 if(op == '+') {
 printf("%d\n", a+b);
 } else if(op == '-') {
 printf("%d\n", a-b);
 } else if(op == '*') {
 printf("%d\n", a*b);
 } else if(op == '/') {
 printf("%d\n", a/b);
 } else {
 break;
 }
 }

 return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
signed main() {
	int a, b; cin >> a >> b; cout << (a * 3 + b)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  int i;
  for ( i=0; i<N ; i++ ){
    char S;
    cin >> S;
    
    if ( S == 'Y' ){
      cout << "Four" << endl;
      break;
    }
    if ( i == N-1 ){
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256