akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[100010];

int main() {

    int n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> y(n);

    map<pair<int, int>, int> diff;

    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    ll sax, say;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {

            if (i == j) continue;
            
            sax = x[i] - x[j];
            say = y[i] - y[j];
            diff[{sax, say}] ++;

        }
    }

    int tmp = n;

    // tmp = min(*max_element(diffx.begin(), diffx.end()), *max_element(diffy.begin(), diffy.end()));

    for(auto out : diff) {
        tmp = min(tmp, n - out.second);
    }

    cout << tmp << endl;

    return 0;
    
    


/*  
    int n;
    cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }

    vector<pair<ll, ll>> xy(n);

    ll x, y;
    ll conx, cony;
    ll sax, say;

    ll count = 1;
    int ans = 100;

    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        xy[i] = make_pair(x, y);
    }

    sort(xy.rbegin(), xy.rend());
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {

            int count = 1;

            if(i == j) break;

            sax = xy[i].first - xy[j].first;
            say = xy[j].second - xy[j].second;

            for (int k = 0; k < n-1; k++) {
                if (xy[k].first - xy[k+1].first != sax || xy[k].second - xy[k+1].second != say) {

                    count ++;
                }
            }

            if (ans > count) {
                ans = count;
            }
            

        }
    }

    cout << count << endl;

    return 0;
    */

    /*

    for (ll i = 0; i < 1000000001; i++) {
        xin[i] = 0;
        yin[i] = 0;
    }


    for (int i = 1; i < n; i++) {
        sax = conx - xy[i].first;
        say = cony - xy[i].second;
        xin[sax] ++;
        yin[say] ++;
    }

    int maxx = 0;
    int maxy = 0;

    for (ll i = 0; i < 1000000001; i++) {
        maxx = max(maxx, xin[i]);
        maxy = max(maxy, yin[i]);
    }

    cout << min(maxx, maxy) << endl;

    return 0;
    
    */
    /*
    ll>> xy(n);

    ll x, y;
    ll conx, cony;
    ll sax, say;

    ll ans = 1;

    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        xy[i] = make_pair(x, y);
    }

    sort(xy.rbegin(), xy.rend());

    conx = xy[0].first;
    cony = xy[0].second;

    sax = conx - xy[1].first;
    say = cony - xy[1].second;

    for (int i = 2; i < n; i++) {
        if (xy[i-1].first - xy[i].first != sax || xy[i-1].second - xy[i].second != say) {
            ans ++;
        }
    }
    
    cout << ans << endl;

    return 0;
*/

}

Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


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


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

// @@ !! LIM()

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

  ll N, M, X; cin >> N >> M >> X;
  vector<ll> C(N);
  vector A(N, vector<ll>(M));
  for (ll i = 0; i < N; i++) {
    cin >> C.at(i);
    for (ll j = 0; j < M; j++) cin >> A.at(i).at(j);
  }
  ll ans = LLONG_MAX;
  vector<ll> skill(M);
  auto dfs = [&](const auto& cmpF, ll n, ll cost) -> void {
    if (n == N) {
      ll ok = true;
      for (ll j = 0; j < M; j++) {
	if (skill.at(j) < X) {
	  ok = false;
	  break;
	}
      }
      if (ok && cost < ans) ans = cost;
    }else {
      cmpF(cmpF, n+1, cost);
      for (ll j = 0; j < M; j++) {
	skill.at(j) += A.at(n).at(j);
      }
      cmpF(cmpF, n+1, cost + C.at(n));
      for (ll j = 0; j < M; j++) {
	skill.at(j) -= A.at(n).at(j);
      }
    }
  };
  dfs(dfs, 0, 0);

  if (ans == LLONG_MAX) {
    cout << -1 << endl;
  }else {
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long Y = sc.nextLong();
        int count = 0;
        while (Y >= X) {
            Y /= 2;
            count++;
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 22868
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    if(c >=a&&c<=b ){
    	System.out.println("Yes");
    }else{
    	System.out.println("No");
    }
	}

}

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

const int LEN = 20000000;
const int MAX = 10000;
int A[LEN], B[LEN], C[MAX+1];

void CountingSort(int n, int A[], int B[], int k) {
	for (int i = 0; i <= k; i++)
		C[i] = 0;
	for (int i = 0; i < n; i++)
		C[A[i]]++;
	for (int i = 1; i <= k; i++)
		C[i] += C[i-1];
	for (int i = n-1; i >= 0; i--) {
		B[C[A[i]]-1] = A[i];
		C[A[i]]--;
	}
}

int main() {
	int n, k = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		k = max(k, A[i]);
		B[i] = 0;
	}
	CountingSort(n, A, B, k);
	
	cout << B[0];
	for (int i = 1; i < n; i++) cout << ' ' << B[i];
	cout << endl;
}



Measured memory_bytes: 18756
import std.stdio, std.string, std.conv;

void main() {
    int n = readln.chomp.to!int;
    int[] p = readln.split.to!(int[]);
    int cnt;
    foreach (i; 1 .. n-1) {
        if (p[i-1] < p[i] && p[i] < p[i+1]) ++cnt;
        if (p[i-1] > p[i] && p[i] > p[i+1]) ++cnt;
    }
    cnt.writeln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){

long long int h,w;
cin >> h>>w;
 
 
 
long long int z;
 
if(h%2==0 && w%2==0){
z= (h*w)/2;
}else if(h%2==0 && w%2!=0){
if(w==1){
z=1;
}else if(w>1)
z= (h*(w-1))/2 + ((h)/2);
else
z=h/2;
}else if(h%2!=0 && w%2==0){
if(h==1){
z=1;
}else if(h>1)
z= ((h-1)*(w))/2 + ((w)/2);
else
z=w/2;
}else if(h%2!=0 && w%2!=0){
if(h>1 && w>1)
z= ((h-1)*(w-1))/2 + ((h-1)/2)+((w-1)/2)+1;
else if(h>1 && w==1)
z= 1;
else if (w>1 && h==1)
z= 1;
else
z=1;
}
 

cout << z<< endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	if(max(a,max(b,max(c,max(d,e))))-min(a,min(b,min(c,min(d,e))))<=k){
		cout<<"Yay!";
	}
	else{
		cout<<":(";
	}
}

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

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

	long long sum = 0;

	for(int i = 0; i < n; i++){
		scanf("%d",&tmp);
		sum += tmp;
	}

	printf("%lld\n",sum/n);

	return 0;
}

Measured memory_bytes: 2612
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define forit(it, st) for(auto it : st)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
set<int> s[N];
void solve(){
	int n;
	cin >> n;
	int a[n];
	rep(i, n) {
		cin >> a[i];
		s[a[i]].insert(i);
	}
	int cnt = 1;
	int l = 0;
	while(1){
		auto it = s[cnt].lower_bound(l);
		if(it == s[cnt].end()) break;
		else{
			++cnt;
			l = *it;
		}
	}
	int res = n - cnt + 1;
	cout << (res == n ? -1 : res);
}
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}


Measured memory_bytes: 57344
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int sum = a[2] * 10 + a[1] + a[0];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mx=1e9+7;

#define int long long
void solve(){
    int n;
    cin>>n;
    vector<int>v(n);
    vector<int>pre;
    for(int &i:v)
        cin>>i;
    pre.push_back(v[0]);
    for(int i=1;i<n;i++)
        pre.push_back(pre[pre.size()-1]+v[i]);
    int ans=0;
    for(int i=0;i<n-1;i++){
        int p=((v[i]%mx*(pre[n-1]%mx-pre[i]%mx+mx)%mx)%mx)%mx;
        ans=(ans%mx+p%mx)%mx;
    }
    cout<<ans<<endl;
}


signed main()
{
    int t;
    solve();
}

Measured memory_bytes: 6928
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		// Scanner scanner = new Scanner("3 5 4 2 0 0 8 8");
		Scanner scanner = new Scanner(System.in);
		int a;
		int b;
		while (true) {
			a = scanner.nextInt();
			b = scanner.nextInt();
			if (a == 0 && b == 0) {
				break;
			}
			for (int i = 0; i < a; i++) {
				lineMaker(b);
				System.out.println("");
			}
			System.out.println("");
		}
	}

	static void lineMaker(int b) {
		for (int i = 0; i < b; i++) {
			System.out.print("#");
		}
	}
}

Measured memory_bytes: 32592
from fractions import gcd
n,x=map(int, input().split())
town=list(map(int, input().split()))+[x]
town.sort()
if n == 1:
    town.remove(x)
    print(abs(town[0]-x))
    exit()

d1 = abs(town[0]-town[1])
d2 = abs(town[1]-town[2])
ans = gcd(d1,d2)

for i in range(2,n):
    d = abs(town[i]-town[i+1])
    ans = gcd(d,ans)
print(ans)






Measured memory_bytes: 16280
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main
{ 
  public static void main(String[] args) throws Exception{
  	FastReader sc = new FastReader();
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(a*b);
  
  }
  
  static class FastReader 
     {  
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}

Measured memory_bytes: 25352
#!/usr/bin/env python3
import sys


def solve(H: int, A: int):
    count = 0
    while True:
        H -= A
        count += 1
        if H <= 0:
            break
    print(count)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(H, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


w,h = li()
stack = []
for _ in range(w):
    stack.append((ni(),0))
    
for _ in range(h):
    stack.append((ni(),1))
    
    
stack.sort(reverse=True)

res_w = 0
res_h = 0

ans = 0

while res_w <= w and res_h <= h and stack:
    cost, wh = stack.pop()

    if wh == 0:
        ans += (cost * ((h+1)-res_h))
        res_w += 1
        
    else:
        ans += (cost * ((w+1)-res_w))
        res_h += 1

        
print(ans)

Measured memory_bytes: 24768
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

#define INF 0x3fffffff

long long n,ans;
int a[20],cnt;

int main()
{
    scanf("%lld",&n);
    if(n<10)
    {
        printf("%lld",n);
        return 0;
    }
    while(n)
    {
        a[++cnt]=n%10LL;
        n/=10LL;
    }
    long long now=0;
    for(int i=cnt;i>0;i--)
    {
        //printf("**%d\n",a[i]);
        now+=a[i];
        if(a[i])
            ans=max(ans,now-1LL+(i-1)*9LL);
        //printf("%d %d\n",ans,now);
    }
    ans=max(ans,now);
    printf("%lld",ans);
}


Measured memory_bytes: 128
func readArrayInt() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

// input
var line = readArrayInt()
let (N, M, X) = (line[0], line[1], line[2])
var C: [Int] = []
var A: [[Int]] = []
(1...N).forEach({ _ in
    line = readArrayInt()
    C.append(line[0])
    A.append(Array(line[1...M]))
})

// main
func allAchived(_ bits: Int) -> Bool {
    var achieved = Array(repeating: 0, count: M)
    for place in 0..<N where ((1 << place & bits) > 0) {
        for (i, value) in A[place].enumerated() {
            achieved[i] += value
        }
    }
    return !achieved.contains(where: {$0 < X})
}

func cost(_ bits: Int) -> Int {
    var cost = 0
    for i in 0..<N where ((1 << i & bits) > 0) {
        cost += C[i]
    }
    return cost
}

var ans = -1
(1..<(1 << N)).forEach { bits in
    if (allAchived(bits)) {
        ans = ans < 0 ? cost(bits) : min(cost(bits), ans)
    }
}

print(ans)


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

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int MX = 307;

ld b[MX+5][MX+5][MX+5];

int main(){
  int n; scanf("%d", &n);
  int c[3] = {0, 0, 0};
  for(int i=0;i<n;i++){
    int l; cin >> l;
    if(l>0) c[l-1] += 1;
  }
  b[0][0][0] = 0.0;
  for(int k=0;k<MX;k++){
    for(int j=0;k+j<MX;j++){
      for(int i=0;i+j+k<MX;i++){
        if(i == 0 && j == 0 && k == 0) continue;
        b[i][j][k] += 1.0 * n/(i+j+k);
        b[i+1][j][k] += b[i][j][k] * 1.0 *(i+1)/(i+1+j+k);
        if(i) b[i-1][j+1][k] += b[i][j][k] * 1.0 * (j+1)/(i+j+k);
        if(j) b[i][j-1][k+1] += b[i][j][k] * 1.0 * (k+1)/(i+j+k);
      }
    }
  }
  cout << fixed << setprecision(10) <<  b[c[0]][c[1]][c[2]] ;
  return 0;
}


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


int main() {
  string s;
  cin >> s;
  string t(s.rbegin(),s.rend());
  int count = 0;
  rep(i,s.size()){
    if(s[i] != t[i]) ++count;
  }
  cout << count/2 << endl;
  return 0;
}

Measured memory_bytes: 256
x, y = map(int,input().split())

"""
n = min(x,y)
for d in range(n, 0, -1):
    if x % d == 0 and y % d == 0:
        print(d)
        break
"""

if x < y:
    x, y = y, x

while y > 0:
    r = x % y
    x = y
    y = r
print(x)




Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a); i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define pconent(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
//#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const ll MOD =  1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " "<<"\n";
#define endln cerr << "\n";
const ll MN = 100 ;
void output()
{
	ll n ;
	cin>>n ;
	ll a[n],b[n] ;
	FOR(i,0,n)
	{
		cin>>a[i] ;
	}
	FOR(i,0,n)
	{
		cin>>b[i] ;
	}
	ll p[n],s[n] ;
	p[0] = a[0] ; 
	FOR(i,1,n)
	{
		p[i] = p[i-1]+a[i] ;
	}
	s[n-1] = b[n-1] ;
	FORd(i,n-2,0)
	{
		s[i] = s[i+1]+b[i] ;
	}
	ll ans = -LINF ;
	FOR(i,0,n)
	{
		ans = max(ans,s[i]+p[i]) ;
	}
	cout<<ans<<endl ;
}
int main()
{
	 #ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t  =1;
    FOR(i,0,t)
    {
        output() ;
    }
    return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,M,K;
  cin>>N>>M>>K;
  int ans=0;
  rep(i,N+1) rep(j,M+1){
    if((N-i)*j+(M-j)*i==K) ans=1;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  int idx;
  rep(i,n){
    int a;
    cin >> a;
    if(a==1) idx = i+1;
  }
  
  --k;
  int ans = (idx-1+k-1)/k;
  idx = ans*k+1;
  ans += (n-idx+k-1)/k;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define plll pair<ll,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
//#define endl "\n"
const int MAX = 1e3+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll INF = 1e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

int n,ans,ls;
pii x[MAX];

int main(){
//	cout<<fixed<<setprecision(15);
//    freopen("output.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    rep(i,1,n)cin>>x[i].se>>x[i].fi;
    sort(x+1,x+1+n);
    rep(i,1,n)ans+=min(x[i].fi-x[i].se+1,x[i].fi-ls), ls = x[i].fi;
    cout<<ans<<endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  if(s.at(k-1)=='A') s.at(k-1)='a';
  if(s.at(k-1)=='B') s.at(k-1)='b';
  if(s.at(k-1)=='C') s.at(k-1)='c';
  
  cout << s << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int w[310][310], C[310], v[310];
int n, m, res = 1e9;
int main(){
    int i, j, k;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            scanf("%d",&w[i][j]);
        }
    }
    for(i=1;i<=m;i++){
        for(j=1;j<=m;j++)C[j]=0;
        for(j=1;j<=n;j++){
            for(k=1;k<=m;k++){
                if(!v[w[j][k]])break;
            }
            C[w[j][k]]++;
        }
        int M = -1, x = 0;
        for(j=1;j<=m;j++){
            if(M < C[j]) M = C[j], x = j;
        }
        res = min(res, M);
        v[x] = 1;
    }
    printf("%d\n",res);
}

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    vector<char> x(n);
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        x.at(i) = s[i];
        if (x.at(i) == '1')
        {
            count++;
        }
    }
    int ccc = min(count, n - count);
    cout << ccc*2 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,K,Q;
  cin>>N>>K>>Q;
  int A[Q],P[N],bd=Q;
  for(int i=0;i<Q;i++) cin>>A[i];
  for(int i=0;i<N;i++) P[i]=K;
  for(int i=0;i<Q;i++) P[A[i]-1]++;
  for(int i=0;i<N;i++){
    if(P[i]>bd) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 1408
#include<iostream>
#include<map>
#include<string>
using namespace std;

int main(void) {
	int num,  a, b, value;
	long long order,index = 0;
	cin >> num >> order;

	map<int, long long> array;
	for (int i = 0; i < num; i++) {
		cin >> a >> b;
		if (array.count(a)) {
			array.at(a) += b;
		}
		else {
			array[a] = b;
		}
	}
//	for (auto it = array.begin(); it != array.end(); ++it) {
	for(auto it : array){
		index += it.second;
		if (index >= order) { value = it.first; break; }
	}

	cout << value << endl;

}


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

ll n;
vector<pair<ll,int> > fac;

set<int> ans;
int pw[50];

ll mpow (ll bs, ll ep) {
    if (ep == 0) {
        return 1;
    } else {
        ll hf = mpow(bs, ep>>1);
        return (ep&1) ? hf*hf*bs : hf*hf;
    }
}
void dfs (int id) {
    if (id == int(fac.size())) {
        int gcd = pw[0];

        for (int i=0; i<int(fac.size()); i++) {
            gcd = __gcd(gcd, pw[i]);
        }

        for (int i=1; i<=gcd; i++) {
            if (gcd % i == 0) {
                ll k = 1;
                ll ky = 1;
                for (int j=0; j<int(fac.size()); j++) {
                    k *= mpow(fac[j].first, pw[j] / i);
                    ky *= mpow(fac[j].first, pw[j]);
                }

                if (n/ky % k == 1) {
                    ans.insert(k);
                }
            }
        }
    } else {
        for (int i=0; i<=fac[id].second; i++) {
            pw[id] = i;
            dfs(id+1);
        }
    }
}
int main () {
    cin >> n;

    ll tmp = n;
    for (ll i=2; i*i<=n; i++) {
        if (tmp % i == 0) {
            int cnt = 0;
            while (tmp % i == 0) {
                cnt++;
                tmp /= i;
            }
            fac.emplace_back(i, cnt);
        }
    }
    if (tmp != 1) {
        fac.emplace_back(tmp, 1);
    }

    dfs(0);

    n--;
    for (ll i=1; i*i<=n; i++) {
        if (n % i == 0) {
            ans.insert(i);
            ans.insert(n/i);
        }
    }
    ans.erase(1);

    cout << ans.size() << endl;
}


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

using namespace std;

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

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    int n;
    cin>>n;
    vi p(n),q(n);
    REP(i,n)cin>>p[i];
    REP(i,n)cin>>q[i];
    int a=0,b=0;
    vi v(n);
    REP(i,n)v[i] = i+1;
    int it = 0;
    do{
        if(v==p)a=it;
        if(v==q)b=it;
        it++;
    }while(next_permutation(ALL(v)));
    cout<<abs(a-b)<<endl;
    return 0;
}


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

using namespace std;

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  int l[100010], r[100010];
  for(int i = 0; i < Q; i++) {
    cin >> l[i] >> r[i];
  }

  int ac[100010];
  
  int start = 0;
  while(true) {
    auto found = S.find("AC", start);
    if(found != string::npos) {
      start = found + 1;
      ac[found] = 1;
    }else{
      break;
    }
  }

  int ruiwa[100011];
  for(int i = 0; i <= N; i++) {
    if(i == 0) {
      ruiwa[0] = 0;
      continue;
    }
    ruiwa[i] = ac[i-1] + ruiwa[i-1];
  }

  for(int i = 0; i < Q; i++) {
    cout << ruiwa[r[i] - 1] - ruiwa[l[i] - 1] << endl;
  }

  return 0;
}




Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
main()
{
	long long int d;
	cin >> d;
	long long int i, c[26];
	for(i=0;i<26;i++)
	cin >> c[i];
	long long int s[d][29], maxi[d] = { 0 };
	for(i=0;i<d;i++)
	{
		long long int idx = 0, maxii = -1e17;
	for(long long int j=0;j<26;j++)
	{
	cin >> s[i][j];
      if(maxii < s[i][j])
      {
      	maxii = s[i][j];
      	idx = j;
	  }
	  }
	 maxi[i] = idx+1;
	}
	for(i=0;i<d;i++)
	{
		cout << maxi[i] << endl;
	}
	return 0;
}

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

int main()
{
  int N;
  int a[110];
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> a[i];
  
  sort(a, a + N, greater<int>());
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 ==0)
      Alice += a[i];
    else
      Bob += a[i];
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long mod=1e9+7;
#define ll long long
using namespace std;
int lim=0;

/*ll power(ll n)
{
    if(n==0) return 0%mod;
    if(n==1) return 1%mod;
    return ((power(n-1)%mod) + (power(n-2)%mod ))%mod;
}
int main()
{
    ll n;cin>>n;
    cout<<power(n%mod)%mod;
}*/
ll pw(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=res*x*1ll%mod;
        x=x*x*1ll%mod;
        n/=2;
    }return res;
}
int main()
{
    int n,i,m;
    cin>>n;int a[n+10];
    for(i=0;i<n;i++) {cin>>m;a[m]=i+1; }
    for(i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }

}

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

int main(void){
    int a, b, k, n, i, j, ans=0;
    scanf("%d %d", &n, &k);
    char s[n+1];
    scanf("%s", s);
    s[k-1] += 32;
    printf("%s", s);
    
}

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


int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i != N; ++i)
	{
		cin >> A.at(i);
	}

	int counter = 0;
	while (1)
	{
		bool odd_flg = false;
		for (auto it = A.begin(); it != A.end(); ++it)
		{

			if ((*it % 2) == 0)
			{
				continue;
			}
			else
			{
				odd_flg = true;
			}
		}

		if (!odd_flg)
		{
			for (auto it = A.begin(); it != A.end(); ++it)
			{
				*it = *it / 2;
			}
			counter++;
		}
		else
		{
			break;
		}
	}

	cout << counter;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <list>
#include <set>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

bool is_exist(map<long long int,set<long long int>> vs ){
    for(auto &x:vs){
        if(x.second.size()){
            return true;
        }
    }
    return false;
}

int main(){

    long long int n,m;
    cin>>n>>m;
    map<long long int,set<long long int>> vs;
    long long int tmpa, tmpb;
    REP(i,m){
        scanf("%lld %lld", &tmpa, &tmpb);
        vs[tmpa ].insert(tmpb);
    }
    long long int min_end, result = 0;

    while(vs.size()){
        set<long long int> killer;
        min_end = linf;
        for(auto &x:vs){
            min_end = min(min_end, *(x.second.begin()));

        }
        
        for(auto &x:vs){
            if(x.first<min_end){
                killer.insert(x.first);
            }else{
                break;
            }
        }
        for(auto &x:killer){
            vs.erase(x);
        }
        //cout << min_end<<" "<<result << endl;

        result++;
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 12800
#include<stdio.h>
#include<stdlib.h>

int main(){
  int N,i,j,key;
  int *A;

  scanf("%d",&N);
  A=(int *)malloc(sizeof(int)*N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(j=0;j<N;j++){
    key=A[j];
    i=j-1;
    while(i>=0 && A[i]>key){
      A[i+1]=A[i];
      i--;
    }
    A[i+1]=key;


    for(i=0;i<N-1;i++){
      printf("%d ",A[i]);
    }
    printf("%d\n",A[N-1]);
  }
  free(A);

  return 0;
}

Measured memory_bytes: 600
import heapq
N = int(input())
Nlist = list(map(int, input().split()))
heapq.heapify(Nlist)
for _ in range(N-1):
    x = heapq.heappop(Nlist)
    y = heapq.heappop(Nlist)
    z = (x+y)/2
    heapq.heappush(Nlist, z)

print(Nlist[0])


Measured memory_bytes: 9188
e_1,e_2,e_3,e_4=map(int,input().split())
if e_1==e_2 and e_3==e_4 :
    print("yes")
elif e_1==e_3 and e_2==e_4 :
    print("yes")
elif e_1==e_4 and e_2==e_3 :
    print("yes")
else:
    print("no")


Measured memory_bytes: 5596
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb1=new StringBuilder();
		StringBuilder sb2=new StringBuilder();
		String b=" ",n="\n";
        String[] rc=br.readLine().split(b);
        int r=Integer.parseInt(rc[0]);
        int c=Integer.parseInt(rc[1]);
        int[][] h=new int[r+1][c+1];
        
        for(int i=0;i<r;i++){
        	String[] row=br.readLine().split(b);
        	int j=0;
        	for(String num:row){
        		h[i][j]=Integer.parseInt(num);
        		h[i][c]+=h[i][j];
        		h[r][j]+=h[i][j];
        		h[r][c]+=h[i][j];
        		sb1.append(h[i][j]+b);
        		if(i==r-1) sb2.append(h[r][j]+b);
        		j++;
        	}
        	sb1.append(h[i][c]+n);
        }
        sb2.append(h[r][c]);
        System.out.print(sb1);
        System.out.println(sb2);
	}
}

Measured memory_bytes: 25472
n = int(input())
lists = list(map(int,input().split()))
flg = True
for check in lists:
    if(check % 2 == 0):
        if(check % 3 != 0):
            if(check % 5 != 0):
                print('DENIED')
                flg = False
                break
        if(check % 5 != 0):
            if(check % 3 != 0):
                print('DENIED')
                flg = False
                break
if(flg == True):
  print('APPROVED')

Measured memory_bytes: 3060
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


signed main() {
	int x,y;
	std::cin >> x >> y;
	int a,b;
	a = 2*x-y;
	b = 2*y-x;
	if(a<0 || b<0 || a%3!=0 || b%3!=0) {
		print(0);
		return 0;
	}
	int nx, ny;
	nx = b/3;
	ny = a/3;
	print(mint::comb(nx+ny,nx));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
	int A,B;
	cin >> A >> B;
	if (B % A == 0) {
		cout << A+B << endl;
	} else {
		cout << B - A << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

#define N 200

int main(void)
{
        int num,i,cnt,tmp;
        int data[N];

        scanf("%d",&num);

        for(i=0;i<num;i++)      scanf("%d",&data[i]);

        i=0;    tmp=0;
        while(1)
        {
                for(i=0;i<num;i++)
                {
                        if((data[i]%2)!=0)
                        {
                                tmp=1;
                                break;
                        }
                        data[i]=data[i]/2;
                }
                if(tmp==1)      break;
                cnt++;
        }
        printf("%d",cnt);

        return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define inf (1ll<<60)
#define mod 1000000007
#define eps 1e-18
inline ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0';
    return tmp*f;
}
using namespace std;
int main()
{
	int n=read();
	printf("%d\n",n/3);
	return 0;
}

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

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

b = a[:]
acc = 0

for i in range(n):
    if i%2==0:
        if acc+b[i]<=0:
            b[i] += 1-(acc+b[i])
    else:
        if acc+b[i]>=0:
            b[i] -= acc+b[i]+1
    
    acc += b[i]

c = a[:]
acc = 0

for i in range(n):
    if i%2==0:
        if acc+c[i]>=0:
            c[i] -= acc+c[i]+1
    else:
        if acc+c[i]<=0:
            c[i] += 1-(acc+c[i])
    
    acc += c[i]

ans = min(sum(abs(ai-bi) for ai, bi in zip(a, b)), sum(abs(ai-ci) for ai, ci in zip(a, c)))

print(ans)

Measured memory_bytes: 59120
/*
  Reference:-
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1000000007;

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ar[n][3];
    forn(i,n)cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    int dp[n][3];
    memset(dp,0,sizeof(dp));
    dp[0][0]=ar[0][0];dp[0][1]=ar[0][1];dp[0][2]=ar[0][2];
    forn1(i,n){
        forn(j,3)dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+ar[i][j];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

    return 0;
}


Measured memory_bytes: 2560
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int w,h;
  int x,y;
  cin>>h>>w>>y>>x;

  double p, q;
  if (h%2==0 and y==h/2 and w%2==0 and x==w/2){
    p = (double)h*w/2.0;
    q = 1;
  }
  else{
    p = (double)h*w/2.0;
    q = 0;
  }
  cout << p << " " << q << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;

int main(){

  queue<pair<string,int> > Q;

  
  int n,q;
  cin>>n>>q;

  string name;
  int time;
  for(int i=0;i<n;i++){
    cin>>name>>time;
    Q.push(make_pair(name,time));
      }

  pair<string,int> u;
  int elaps=0,a;
  while(!Q.empty()){
    u=Q.front();Q.pop();
    a=min(q,u.second);
    u.second-=q;
    elaps+=a;
    if(u.second>0) Q.push(u);

    else cout<<u.first<<" "<<elaps<<endl;
  }

    return 0;
  }

Measured memory_bytes: 6228
#include <bits/stdc++.h>
static const int MAX = 100;
static const int INFTY = (1 << 30);
class edge {
public:
    int target, cap, rev;
    edge (int target = 0, int cap = 0, int rev = 0) : target(target), cap(cap), rev(rev) {}
};
int V;
std::vector<edge> G[MAX];
int level[MAX]; //dist from source
int iter[MAX]; //ended search num

void bfs(int s) {
    std::memset(level, -1, sizeof(level));
    std::queue<int> q;
    q.push(s);
    level[s] = 0;
    while(!q.empty()) {
        int current = q.front(); q.pop();
        for (int i  = 0; i < G[current].size(); i++) {
            edge &e = G[current][i];
            if (e.cap > 0 && level[e.target] < 0) {
                level[e.target] = level[current] + 1;
                q.push(e.target);
            }
        }
    }
}

int dfs(int current, int sink, int f) {
    if (current == sink) return f;
    for (int &i = iter[current]; iter[current] < G[current].size(); i++) {
        edge &e = G[current][i];
        if (e.cap > 0 && level[current] < level[e.target]) {
            int d = dfs(e.target, sink, std::min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.target][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for (; ;) {
        bfs(s);
        if (level[t] < 0) return flow;
        std::memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, INFTY)) > 0) {
            flow += f;
        }
    }
}

int main()
{
    int E, source, target, capacity;
    std::scanf("%d %d", &V, &E);
    for (int i = 0; i < E; i++) {
        std::scanf("%d %d %d", &source, &target, &capacity);
        G[source].push_back(edge(target, capacity, G[target].size()));
        G[target].push_back(edge(source, 0, G[source].size()-1));
    }
    std::cout << max_flow(0, V-1) << std::endl;
    return 0;
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
long long n,k;
vector<long long> arr;

bool ok(int target){
	long long count = 0;
	for(auto each:arr){
		count += (each/target);
		if(each%target==0)count--;
	}
	//cout<<target<<" "<<count<<endl;
	return count>k ? false:true;
}

int main(){
    cin>>n>>k;
	arr = vector<long long>(n);
	for(int i=0;i<n;++i)cin>>arr[i];
	sort(arr.begin(),arr.end());
	int l = 1;
	int r = 1e9;

	while(l<r){
		int mid = l + (r-l)/2;
		//cout<<mid<<" "<<ok(mid)<<endl;
		if( ok(mid) ){
			r = mid;
		} else {
			l = mid+1;
		}
	}

	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 4752
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            int x = Integer.parseInt(sl[0]);
            int a = Integer.parseInt(sl[1]);
            int b = Integer.parseInt(sl[2]);

            System.out.println(Math.abs(x - a) < Math.abs(x - b) ? 'A' : 'B');
        }
    }
}


Measured memory_bytes: 23124
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define MAX 2000000

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}
int H;
int heap[MAX+1];

void heapIncreaseKey(int ii,int key){

  if(key < heap[ii]){
    return ;
  }

  heap[ii] = key;
  
  int tmp;

  while(ii > 1 && heap[(ii)/2] < heap[ii]){

    tmp = heap[ii];
    heap[ii] = heap[(ii)/2];
    heap[(ii)/2] = tmp;
    ii = (ii)/2;

  }

}

void insert(int key){
  H++;
  heap[H] = -INF;
  heapIncreaseKey(H,key);
  //cout << H << endl;
  int ii;

}

void maxHeapify(int ii){

  int l,r;
  l = ii*2;
  r = ii*2+1;

  int largest;

  if(l <= H && heap[l] > heap[ii]){
    largest = l;
  }
  else{
    largest = ii;
  }

  if(r <= H && heap[r] > heap[largest]){
    largest = r;
  }
  
  if(largest != ii){
    int sw;
    sw = heap[ii];
    heap[ii] = heap[largest];
    heap[largest] = sw;
    maxHeapify(largest);
  }
  
}


int heapExtractMax(){

  if(H < 0){
    return 0;
  }

  int max;
  max = heap[1];
  heap[1] = heap[H];
  H--;
  maxHeapify(1);
  return max;

}


int main(){
  long ii,jj,kk;
  H = 0;
  string cmd;
  int n;

  while(true){
    cin >> cmd;
    if(cmd == "end"){
      break;
    }
    else if(cmd == "insert"){
      cin >> n;
      insert(n);
    }
    else{
      // extract;
      cout << heapExtractMax() << endl;
      //cout << "=================" << endl;
      //for(ii=1;ii<=H;ii++){
      //  cout << heap[ii] << endl;
      //}
      //cout << "=================" << endl;      
      //cout << "***" << heapExtractMax() << "***" << endl;
      //cout << "=================" << endl;
      //for(ii=1;ii<=H;ii++){
      //  cout << heap[ii] << endl;
      //}
      //cout << "=================" << endl;      
    }
  }

  //for(ii=0;ii<H;ii++){
  //  cout << heap[ii] << endl;
  //}

  //insert(7);
  //insert(2);
  //
  //insert(8);
  //
  //for(ii=0;ii<H;ii++){
  //  cout << heap[ii] << endl;
  //}
  //heapExtractMax();
  //
  //for(ii=0;ii<H;ii++){
  //  cout << heap[ii] << endl;
  //}  
  return 0;
}



Measured memory_bytes: 7096
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second

const int N = 1e6 + 10;
const int M = 1e9 + 7;

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

int main()
{
	ll mx = (ll)1e16;
	ll k;
	while(scanf("%lld", &k) != EOF){
	//	printf("%lld\n", k);
		for(int i = 3; i <= 50; i++){
			ll t = k / i;
			ll l = k % i;
			if(t > mx) continue;
			printf("%d\n", i);
			for(int j = 0; j <= i-l-1; j++)
				printf("%lld ", t+j);
			for(int j = i-l; j < i; j++)
				printf("%lld ", t+j+1);
			puts("");
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b, c;

    scanf("%d %d", &a, &b);

    if(a==1&&b==2)
    {
        printf("3\n");
    }
    else if(a==2&&b==1)
    {
        printf("3\n");
    }
    else if(a==3&&b==1)
    {
        printf("2\n");
    }
    else if(a==1&&b==3)
    {
        printf("2\n");
    }
    else if(a==3&&b==2)
    {
        printf("1\n");
    }
    else if(a==2&&b==3)
    {
        printf("1\n");
    }

    return 0;
}

Measured memory_bytes: 128