akhauriyash/Code-Regression huggingface dataset:
def gcd_(a, b):
    if a < b:  a, b = b, a
    if b == 0:  return a
    return gcd_(b, a % b)

def gcd(l):
    ans = l[0]
    for i in l:  ans = gcd_(ans, i)
    return ans

def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

def solve():   
    if N == 1:  return A == K    
    g = gcd(A)
    m = max(A)
    return K <= m and K % g == 0

N, K = cin()
A = cin()
ret = solve()
if ret:  print("POSSIBLE")
else:  print("IMPOSSIBLE")

Measured memory_bytes: 84984
import java.io.*;
import java.util.*;
public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	static long mod=1000000007;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		int n=cin();
		int[] arr=split();
		ArrayList<Integer>ar=new ArrayList<>();
		int x=1;
		for(int i=0;i<n;i++)
		{
			if(arr[i]==x)
			{
				ar.add(x);
				x++;
			}
		}
		if(ar.size()==0)
			System.out.println(-1);
		else
			System.out.println(n-ar.size());
	}
}


Measured memory_bytes: 61252
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 s;
    constexpr i64 k = 1000000000;
    scanf("%lld", &s);
    i64 a = s / k;
    if (s == k * k) {
        printf("0 0 0 %lld %lld 0\n", k, k);
    } else {
        printf("0 0 1 %lld %lld %lld\n", k, a + 1, (a + 1) * k - s);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

vector<int> dist(200010,0);//ノード間距離

int main(){
 int a,b,x;
 cin >> a >> b >> x;
 if(a+b >= x && a <=x) cout << "YES" << endl; 
 else cout << "NO" << endl;
}

Measured memory_bytes: 1024
//Sliding Minimum Element問題をDequeで解く(O(N))
//長さNの数列が与えられ、すべての長さLの連続した部分列の最小値を求める
//reference Programming Contest ChaTenge Book Second Edition
// verify https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/3/DSL_3_D

#include<iostream>
#include<vector>
#include<deque>

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

using namespace std;

template<typename T>
vector<T> Sliding_Minimum_Element (const T *a,const T n,const T L) {
  vector<T> ret(n - L + 1);
  deque<T> deq;//デックに入っている値を先頭から順にxiとしたとき、xi<xi+1かつa_{xi} < a_{xi+1} が成り立つ

  rep(i,n) {
    while(!deq.empty() && a[deq.back()] >= a[i]) deq.pop_back();

    deq.push_back(i);

    if (i - L + 1 >= 0) {
      ret[i - L + 1] = a[deq[0]];

      if (deq[0] == i - L + 1){
        deq.pop_front();
      }
    }
  }

  return ret;
}

template<typename T>
vector<T> Sliding_Minimum_Element(const vector<T> a,const T L) {
  return Sliding_Minimum_Element(a.data(),(T)a.size(),L);
}

using ll = long long;

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

  vector<ll> a(N);
  rep(i,N)cin >> a[i];

  vector<ll> ans = Sliding_Minimum_Element(a,L);

  rep(i,ans.size()) {
    cout << ans[i] << ((i + 1 == ans.size()) ? "" : " ");
  }
  cout << endl;
}



Measured memory_bytes: 26396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 200000, MAX_A = 1000001;

int N, A[MAX_N];

int tbl[MAX_A];

int main() {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    
    sort(A, A + N);

    REP(i, MAX_A) tbl[i] = 0;
    
    int cnt = 0;
    REP(i, N) {
        if (tbl[A[i]] == 1) continue;
        cnt++;
        if (i+1 < N) {
            if (A[i] == A[i+1]) cnt--;
        }
        int a = A[i];
        while(a < MAX_A) {
            tbl[a] = 1;
            a += A[i];
        }
    }
    PRINT(cnt);
    return 0;
}

Measured memory_bytes: 8312
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public string s { get; set; }
    public char mx { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        getAns(n);
    }
    static void getAns(int n)
    {
        var sb = new StringBuilder();
        var q = new Queue<P>();
        q.Enqueue(new P { s = "a", mx = 'a' });
        while (q.Count() > 0)
        {
            var w = q.Dequeue();
            if (w.s.Length == n) { sb.Append(w.s); sb.Append("\n"); }
            else
            {
                for (int i = 'a'; i <= w.mx; i++)
                    q.Enqueue(new P { s = w.s + (char)i, mx = w.mx });
                q.Enqueue(new P { s = w.s + (char)(w.mx + 1), mx = (char)(w.mx + 1) });
            }
        }
        Console.Write(sb);
    }
}

Measured memory_bytes: 31904
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <utility>
#include <string>
#include <vector>

using namespace std;

int main() {
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
    } else if (r < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 256
import math

A,B,H,M = (int(x) for x in input().split())

time_angle = float((H*60+M)/2)
minu_angle = float(6*M)

angle = abs(time_angle - minu_angle)

if angle > 180:
  angle = 360-angle

if angle == 180:
  length = A+B
elif angle == 90:
  length = math.sqrt(A*A+B*B)
else:
  angle = angle*math.pi/180
  length = math.sqrt((A*A)+(B*B)-(2*A*B*math.cos(angle)))

print(length)

Measured memory_bytes: 9440
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const int MAX = 1e5+5;



int main() {
	int n;
	cin >> n;
	vector<int> t(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}

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

	vector<int> p(n);
	p[0] = 1;
	
	for (int i = 1; i < n; i++) {
		if (t[i] == t[i - 1]) {
			p[i] =t[i];
		}
		else {
			p[i] = 1;
			
		}

		
	}

	
	p[n - 1] = 1;
	
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] == a[i + 1]) {
			p[i] = min(p[i], a[i]);
		}
		else {
			p[i] = 1;
			
		}
	}

	int m = 0;
	for (int i = 0; i < n; i++) {
		m = max(m, t[i]);
	}

	bool isConsist = false;
	for (int i = 0; i < n; i++) {
		if (t[i] == m && a[i] == m) {
			isConsist = true;
		}
	}
	
	if (!isConsist) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;
	for (int i = 0; i < n; i++) {
		ans = (ans * p[i]) % MOD;
		//cout << p[i] << " ";
	}
	//cout << endl;

	cout << ans << endl;
}

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

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")


#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,m,DP[100005];
set<int> S;

int fun(int c)
{
	if (S.find(c)!=S.end())return 0;
	if (c==n)return 1;
	if (DP[c]!=-1)return DP[c];
	return DP[c]=(fun(c+1)+fun(c+2))%MOD;
}
void solve()
{
	cin>>n>>m;
	int a;
	rep(i,0,m)cin>>a,S.insert(a);
	fill(DP,DP+n+1,-1);cout<<fun(0)<<"\n";

}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///    cout<<"Case #"<<a+1<<": ";
        solve();
    }
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
}


Measured memory_bytes: 5760
# reference: https://www.onakasuitacity.com/abc144-f/

import numpy as np

n, m = map(int, input().split())
outgoing = [[] for _ in range(n)]
incoming = [[] for _ in range(n)]
for _ in range(m):
    si, ti = map(int, input().split())
    outgoing[si-1].append(ti-1)
    incoming[ti-1].append(si-1)


ex_dp = np.zeros(n)
for v in reversed(range(n-1)):   # O(m)
    outgoing_degree = len(outgoing[v])
    ex_dp[v] = 1 + sum(ex_dp[post] for post in outgoing[v])/outgoing_degree if outgoing_degree!=0 else np.inf

p_dp = np.ones(n)
for v in range(1,n):      # O(m)
    p_dp[v] = sum(p_dp[prev]/len(outgoing[prev]) for prev in incoming[v])

min_ex = ex_dp[0]
for v, posts in enumerate(outgoing):      # O(m)
    outgoing_degree = len(outgoing[v])
    if outgoing_degree <= 1:
        continue

    max_post = max(posts, key= lambda pos: ex_dp[pos])
    diff_v_ex = 0
    for w in posts:
        if w == max_post:
            diff_v_ex -= 1/outgoing_degree * ex_dp[w]
        else:
            diff_v_ex += 1/(outgoing_degree*(outgoing_degree-1)) * ex_dp[w]
    min_ex = min(ex_dp[0] + p_dp[v] * diff_v_ex, min_ex)

print(min_ex)

Measured memory_bytes: 21868
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn counter(a: &mut Vec<i64>, judge: &Fn(usize) -> bool) -> i64 {
    let mut sum = 0;
    let mut counter = 0;
    for i in 0..a.len() {
        if judge(i) {
            if sum + a[i] == 0 {
                a[i] += 1;
                counter += 1;
            } else if sum + a[i] < 0 {
                counter += (sum + a[i]).abs() + 1;
                a[i] += (sum + a[i]).abs() + 1;
            }
        } else {
            if sum + a[i] == 0 {
                a[i] -= 1;
                counter += 1;
            } else if sum + a[i] > 0 {
                counter += (sum + a[i] + 1).abs();
                a[i] -= sum + a[i] + 1;
            }
        }
        sum += a[i];
    }
    counter
}

fn main() {
    let _n = input!(usize);
    let a = input!(i64; n);

    let answer1 = counter(&mut a.clone(), &|x| x % 2 == 0);
    let answer2 = counter(&mut a.clone(), &|x| x % 2 != 0);
    println!("{}", if answer1 < answer2 { answer1 } else { answer2 });
}


Measured memory_bytes: 6396
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  int i;
  for(i = 0;i < N;i++){
    cin >> a[i];
  }
  int count = 0;
  for(i = 0;i < N;i++){
    while(1){
      if(a[i]%2 == 0){
        a[i]/=2;
        count++;
      }
      else break;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MAX(x, y) (((x)>(y))?(x):(y))
#define min(x, y) (((x)<(y))?(x):(y))

int c[20][20];
int d[20][20];

int main(){
	int i, j, k, h, w;

	scanf("%d%d", &h, &w);

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

	for (k = 0; k < 10; k++) {
		for (i = 0; i < 10; i++) {
			for (j = 0; j < 10; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	
	//for (i = 0; i < 10; i++) {for (j = 0; j < 10; j++) {printf("%d ", d[i][j]);} printf("\n");}

	int x;
	int ans = 0;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			scanf("%d", &x);
			
			if (x != -1) {
				ans += d[x][1];
			}
		}
	}

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

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

int main()
{
  int N;
  set<int> d;
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
  {
    int w;
    scanf("%d", &w);
    d.insert(w);
  }
  printf("%d\n", (int)d.size());
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s;
	else cout << "red";
}

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

int main() {
    long long n, m ,l;
    std::cin >> n >> m >> l;

    std::vector<std::vector<long long> > matrix_a(n, std::vector<long long>(m));
    std::vector<std::vector<long long> > matrix_b(m, std::vector<long long>(l));
    std::vector<std::vector<long long> > matrix_r(n, std::vector<long long>(l, 0));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            std::cin >> matrix_a.at(i).at(j);
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            std::cin >> matrix_b.at(i).at(j);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            for (int k = 0; k < m; k++) {
                matrix_r.at(i).at(j) += matrix_a.at(i).at(k) * matrix_b.at(k).at(j);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l - 1; j++) {
            std::cout << matrix_r.at(i).at(j) << " ";
        }
        std::cout << matrix_r.at(i).at(l-1) << std::endl;
    }

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto&& i : a) {
        cin >> i;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    vector<int> ab(2, 0);
    for (int i = 0; i < n; i++) {
        ab.at(i & 1) += a.at(i);
    }
    cout << ab.at(0) - ab.at(1) << endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
plus = a.map{|e| e+1}
minus = a.map{|e| e-1}
arr = a + plus + minus
list = Hash.new(0)
arr.each do |e|
    list[e] += 1
end
x = list.max{|x, y| x[1] <=> y[1]}
ans = 0
a.each do |e|
    tmp = nil
    if e < x[0]
        tmp = e + 1
    elsif e > x[0]
        tmp = e - 1
    else
        tmp = e
    end
    ans += 1 if tmp == x[0]
end
puts ans

Measured memory_bytes: 22924
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;


int main()
{
	int n;cin >> n;
	
	vector<ll> v(n);
	ll sum = 0;
	
	REP(i,n)
	{
		cin >> v[i];
		sum += v[i];
	}
	
	bitset<4000000> dp;
	dp[0] = 1;
	
	REP(i,n)dp |= dp << v[i];
	
	REP(i,4000000)
	{
		if(dp[i]&&i>=sum-(sum/2))
		{
			cout << i << endl;
			return 0;
		}
	}	
	
	return 0;
}

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

const int N = 200005;

int n, x[N], y[N], perm[N], par[N], ans[N], cnt = 0;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &x[i], &y[i]);
		perm[x[i]] = y[i];
	}
	int mn = n + 1;
	par[0] = 0;
	for (int i = 1; i <= n; i++) {
		mn = min(mn, perm[i]);
		if (mn == n - i + 1) par[++cnt] = i;
	}
	for (int i = 1; i <= cnt; i++) {
		for (int j = par[i]; j > par[i - 1]; j--) ans[j] = par[i] - par[i - 1];
	}
	for (int i = 1; i <= n; i++) printf("%d\n", ans[x[i]]);
	return 0;
}

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

using namespace std;

const int N = 1e5 + 9;

int n, h[N], dp[N][2];

int sol(int i, int prev){
    if(i >= n)  return 1e9;
    if(i == n - 1)  return abs(h[i] - h[i - 1 - (prev == 1)]);

    int &ret = dp[i][prev];
    if(~ret)    return ret;

    return ret = abs(h[i] - h[i - 1 - (prev == 1)]) + min(sol(i + 1, 0), sol(i + 2, 1));
}

int main(){
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> h[i];

    memset(dp, -1, sizeof dp);

    cout << min(sol(1, 0), sol(2, 1));

    return 0;
}

Measured memory_bytes: 3712
import numpy as np
# Aliceの点数
point_A = 0
# Bobの点数
point_B = 0
N = int(input())
A = np.array([int(i) for i in input().split()])
A = np.sort(A)
for j in range(N):
    if j % 2 == 0:
        point_A += A[N - 1 - j]
    else:
        point_B += A[N - 1 - j]
print("{}".format(point_A - point_B))


Measured memory_bytes: 12404
a = [list(map(int, input().split())) for _ in range(3)]

if a[0][1] - a[0][0] == a[1][1] - a[1][0] == a[2][1] - a[2][0] and a[0][2] - a[0][0] == a[1][2] - a[1][0] == a[2][2] - a[2][0]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61952
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define range(i, a, b, s) for (int i = (a), __##i = (b); i < __##i; i += (s))
#define down(i, a, b, s) for (int i = (a), __##i = (b); __##i < i; i += (s))

const double eps = 1e-9;

double w, h, x, y;

int main(int argc, char const *argv[]) {
  // freopen("C.txt", "r", stdin);
  while (cin >> w >> h >> x >> y) {
    bool flag = true;
    if (fabs(x - w / 2.0) > eps) flag = false;
    if (fabs(y - h / 2.0) > eps) flag = false;
    cout << w * h / 2.0 << " " << (flag ? 1 : 0) << endl;
  }
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

    lli n;
    cin>>n;
    set<lli> s;
    REP(i,0,n){
        lli a;
        cin>>a;
        s.insert(a);
    }

    cout<<((n==(s.size())) ? "YES":"NO")<<endl;

	return 0;
}

Measured memory_bytes: 9600
package main

import "fmt"

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_D&lang=jp>
 */

func init() {
}

func main() {
	var n, m, l int
	fmt.Scanf("%d %d %d", &n, &m, &l)

	a := make([][]int, n)
	b := make([][]int, m)
	c := make([][]int, n)

	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &a[i][j])
		}
	}
	for j := 0; j < m; j++ {
		b[j] = make([]int, l)
		for k := 0; k < l; k++ {
			fmt.Scanf("%d", &b[j][k])
		}
	}
	for i := 0; i < n; i++ {
		c[i] = make([]int, l)
		for k := 0; k < l; k++ {
			for j := 0; j < m; j++ {
				c[i][k] += a[i][j] * b[j][k]
			}
		}
	}
	for i := 0; i < n; i++ {
		for k:=0;k < l;k++ {
			fmt.Print(c[i][k])
			if k != l-1{
				fmt.Print(" ")
			}
		}
		fmt.Println("")
	}
}

Measured memory_bytes: 2604
package main

import (
	"fmt"
	"sort"
)

func main() {
	ss := ScanNums(5)
	os := make([]int, 0, 5)

	var t int

	for _, v := range ss {
		if v%10 == 0 {
			t += v
		} else {
			os = append(os, 10-v%10)
			t += v + (10 - v%10)
		}
	}

	if len(os) == 0 {
		fmt.Println(t)
		return
	} else {
		sort.Sort(sort.IntSlice(os))
		t -= os[len(os)-1]
	}

	fmt.Println(t)
}

func SingleInt() int {
	var n int
	fmt.Scan(&n)
	return n
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
//Average Length
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector <pair<int, int>> v;
	for (int i = 0; i < n; i++) {
		int x, y;	cin >> x >> y;
		v.push_back({x, y});
	}
	double sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			double temp = ((v[i].first - v[j].first) * (v[i].first - v[j].first)) + ((v[i].second - v[j].second) * (v[i].second - v[j].second));
			sum += sqrt(temp);
		}
	}
	double z = 2 * sum / n;
	cout << fixed << setprecision(14) << z << endl;
	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
  int n,i,a[10],b[10],aa,bb,c,x;
  scanf("%d",&n);
  for(;n--;)
    {
      a[0]=b[0]=aa=bb=0;
      for(i=x=0;i<10;i++)
	{
	  scanf("%d",&c);
	  if(x!=0)continue;
	  if(a[aa]>=c && b[bb]>=c)
	    x=-1;
	  else
	    {
	      if(a[aa]<c && (a[aa]>b[bb] || b[bb]>=c))
		aa++,a[aa]=c;
	      else if(b[bb]<c)
		bb++,b[bb]=c;

	    }
	}
      puts(x?"NO":"YES");
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
class BIT{
private:
    vector<int> bit;
    int size_;
public:
    BIT() {
        size_ = 0;
        bit = vector<int>(0);
    }
    BIT(int size__) {
        size_ = size__;
        bit.resize(size_ + 1);
    }
    int sum(int i) {
        int ret = 0;
        while(i > 0) {
            ret += bit[i];
            i -= i & (-i);
        }
        return ret;
    }
 
    void add(int i, int x) {
        while(i <= size_) {
            bit[i] += x;
            i += i & (-i);
        }
    }
};
int sum[200010];
int tmp[200010];
map<int, int> mp;


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int a[200010];
    rep(i, N) cin >> a[i];
    rep(i, N) a[i] -= K;
    rep(i, N) sum[i + 1] = sum[i] + a[i];
    rep(i, N + 1) tmp[i] = sum[i];
    sort(tmp, tmp + N + 1);
    int order = 1;
    rep(i, N + 1) {
        mp[tmp[i]] = order;
        if(i + 1 < N + 1 && tmp[i] < tmp[i + 1]) order++;
    }
    // rep(i, N + 1) cout << mp[sum[i]] << " ";
    // cout << endl;
    BIT B(N + 1);
    int ans = 0;
    rep(i, N + 1) {
        ans += i - B.sum(mp[sum[i]]);
        B.add(mp[sum[i]], 1);
        //cout << i << " " << ans << endl;
    }
    cout << N * (N + 1) / 2 - ans<< endl;


    return 0;
}
//0 -16 -22 -18 -4 0 -6 -22  
//6  3   1   2   5 6  4  1


Measured memory_bytes: 21912
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    int a,p; cin>>a>>p;
    cout<<(a*3+p)/2<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var nab = Reads();
            var n = nab[0];
            var a = nab[1];
            var b = nab[2];
            var x = Math.Min(Math.Min(b - 1, a - 1), Math.Min(n - b, n - a));

            Console.WriteLine((b - a) % 2 == 0 ? (b - a) / 2 : x+1+(b-a-1)/2);

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
int main(){
    int N; cin>>N;
    int P[N];
    forin(P, N);
    int ans=0;
    int tmp[3];
    for(int i=1; i<N-1; i++){
        tmp[0]=P[i-1];
        tmp[1]=P[i];
        tmp[2]=P[i+1];
        sort(tmp, tmp+3);
        if(tmp[1]==P[i]) ans++;
    }
    cout<<ans<<endl;
}


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

using namespace std;

typedef unsigned long long uint64;
typedef vector<uint64> VI;
typedef vector<VI> Matrix;

void readMatrix(Matrix &mat, const int &row, const int &column)
{
    for(int r = 0; r < row; r++)
    {
        for(int c = 0; c < column; c++)
        {
            cin >> mat[r][c];
        }
    }
}

void multipleMatrix(const Matrix &matA, const Matrix &matB, Matrix &matC)
{
    size_t l = matA.size();
    size_t m = matB.size();
    size_t n = matB[0].size();

    for(size_t r = 0; r < l; r++)
    {
        for(size_t c = 0; c < n; c++)
        {
            uint64 tmp = 0;
            for(size_t i = 0; i < m; i++)
            {
                tmp += matA[r][i] * matB[i][c];
            }
            matC[r][c] = tmp;
        }
    }
}

void outputMatrix(const Matrix &mat)
{
    size_t r = mat.size();
    size_t c = mat[0].size();

    for(size_t i = 0; i < r; i++)
    {
        for(size_t j = 0; j < c; j++)
        {
            cout << mat[i][j];
            if(j != c - 1){ cout << " "; }
        }
        cout << "\n";
    }

}

int main()
{
    int l = 0, m = 0, n =0;
    cin >> n >> m >> l;

    Matrix matA(n, VI(m, 0));
    Matrix matB(m, VI(l, 0));
    Matrix matC(n, VI(l, 0));

    //Read matA, matB
    readMatrix(matA, n, m);
    readMatrix(matB, m, l);

    multipleMatrix(matA, matB, matC);

    outputMatrix(matC);

    return 0;
}

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

int main() {
  int a,b,c,d,e,k;
  cin >> a >>b >>c >>d >>e >>k;

  if (e-a <= k ) {
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" <<endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int n;
int a[3];
int l[10];

int dfs(int pos, int dist){
  if(dist == 3) return 0;
  if(pos == n) return 1 << 30;

  int ans = 1 << 30;
  int sum = 0;
  int mp = 0;
  for(int i = pos; i < n; i++){
    sum += l[i];
    if(i != pos) mp += 10;

    ans = min(ans, mp + std::abs(sum - a[dist]) + dfs(i + 1, dist + 1));
  }

  return ans;
}

int main(){
  n = getInt();
  REP(i,3) a[i] = getInt();
  REP(i,n) l[i] = getInt();

  sort(l, l + n);

  int ans = 1 << 30;
  do {
    ans = min(ans, dfs(0, 0));
  }while(next_permutation(l, l + n));

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

pp red[101], blue[101];
int n;

int cnt[400];

int main()
{
	read(n);
	for(int i=1; i<=n; ++i) read(red[i].x, red[i].y);
	for(int i=1; i<=n; ++i) read(blue[i].x, blue[i].y);
	sort(red+1, red+n+1); sort(blue+1, blue+n+1);
	int rp = 0;
	int ans = 0;
	for(int i=1; i<=n; ++i){
		while(rp+1<=n && red[rp+1].x < blue[i].x){
			++cnt[red[++rp].y];
		}
		for(int j=blue[i].y-1; 0<=j; --j) if(cnt[j]){
			--cnt[j]; ++ans; break;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
s = int(input())

front = s//100
back = s%100

if 1<= front <=12:
    if 1<=back <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=back<=12:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 38256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    if W >= V:
        print('NO')
    elif abs((A - B) / (W - V)) <= T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

int main()
{
  ll n,m,q;
  cin>>n>>m>>q;
  UnionFind uf(n);
  vector<tuple<ll,ll>> vt;
  for(ll i:irange(0l,q)) {
    ll a,b,c;
    cin>>a>>b>>c;
    if(c==0) {
      uf.merge(a,b);
    } else {
      vt.emplace_back(a,b);
    }
  }
  set<ll> roots;
  for(ll i:irange(0l,n)) {
    roots.insert(uf.root(i));
  }
  ll rts = roots.size();
  ll mxcnt = rts * (rts-1) / 2 + (n - rts);
  bool ok = m <= mxcnt;
  set<ll> loopnodes;
  for(auto t:vt) {
    ll a,b;
    tie(a,b) = t;
    if(uf.root(a) == uf.root(b)) {
      ok = false;
      break;
    } else {
      loopnodes.insert(uf.root(a));
      loopnodes.insert(uf.root(b));
    }
  }
  if (!ok) {
    cout<<"No"<<endl;
    return 0;
  }
  int lps = loopnodes.size();
  if (lps == 0) {
    cout<<"Yes"<<endl;
  } else if (lps == 2) {
    if (roots.size() >= 3 && m >= n) {
      cout<<"Yes"<<endl;
    } else {
      cout<<"No"<<endl;
    }
  } else {
    if (m >= n) {
      cout<<"Yes"<<endl;
    } else {
      cout<<"No"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 11632
#include <stdio.h>

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

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
#define FOR(i,n) for(int i=0;i<n;i++)
//map<key,value>

int main(){
  int n;
  int c=0;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++)cin >> p[i];
  for(int i=0;i<n;i++){
    if(p[i] != i+1)c++;
  }
  if(c>2)cout << "NO";
  else cout << "YES";
  return 0;
}


Measured memory_bytes: 256
n = int(input())
lst = list(map(int, input().split()))

limit = max(lst)

num = [[] for _ in range(limit)]
for _ in range(n):
    if lst[_] <= limit:
        num[lst[_] - 1].append(_)

from collections import deque
def comp():
    queue = deque(num)
    try:
        now = min(queue.popleft())
        c = 1
    except:
        return -1
    while queue:
        try:
            nxt = min([_ for _ in queue.popleft() if _ > now])
            if nxt > now:
                c += 1
                now = nxt
            else:
                return n - c
        except:
            return n - c
    return n - c

print(comp())

Measured memory_bytes: 42948
#include <stdio.h>

int main(void) {
	int N, M;
	int A[100];
	
	float limen;
	int sumVote = 0;
	int ok = 0;
	
	scanf("%d %d", &N, &M);
	
	for( int i = 0; i < N; i++ ) {
		scanf("%d", &A[i]);
		sumVote += A[i];
	}
	
	limen = sumVote / (4.0 * M);
	
	for( int i = 0; i < N; i++ ) {
		if( A[i] >= limen ) ok++;
		
		if( ok >= M ) break;
	}
	
	if( ok >= M )	printf("Yes\n");
	else			printf("No\n");
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ll n, k;
    cin >> n >> k;
    cout << min(n % k, k - (n % k)) << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
L = list(map(int, input().split()))
n = [1, 0, -1]
maxres = 0

for i in range(3):
    if L[3] == 0:
        break
    maxres += L[i] * n[i]
    L[3] -= L[i]
    #print(L[3])
    if L[3] < 0:
        maxres -= abs(L[3]) * n[i]
        break
print(maxres)

Measured memory_bytes: 9076
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(10010);
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];

		while (a[i] % 2 == 0) {
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			int[] l=new int[n*2];
			for(int i=0;i<2*n;i++) l[i]=sc.nextInt();
			Arrays.sort(l);
			int ans=0;
			for(int i=0;i<2*n;i+=2) ans+=l[i];
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 10068
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

void dfs(const vector<vector<int>>& graph, vector<bool>& visited, int node) {
    visited[node] = true;
    for (auto& next_node : graph[node]) {
        if (!visited[next_node]) {
            dfs(graph, visited, next_node);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    rep(i, 0, M) {
        cin >> X[i] >> Y[i] >> Z[i];
        --X[i], --Y[i];
    }
    vector<vector<int>> graph(N);
    rep(i, 0, M) {
        graph[X[i]].push_back(Y[i]);
        graph[Y[i]].push_back(X[i]);
    }
    int ans = 0;
    vector<bool> visited(N, false);
    rep(i, 0, N) {
        if (!visited[i]) {
            dfs(graph, visited, i);
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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;
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int X,t;

void input() {
	cin>>X>>t;
}

void solve() {
	cout<<max(0,X-t)<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int N;
  while(scanf("%d", &N) && N){
    char mes[128];
    scanf("%s", mes);
    int a[128], b[128];
    for(int i = N - 1; i >= 0; i--) scanf("%d%d", &a[i], &b[i]);

    rep(i, N){
      int c = a[i]-1, d = b[i]-1;
      char t = mes[c]; mes[c] = mes[d]; mes[d] = t;
      int dis = d - c;
      dis %= 26;
      if(mes[c] + dis > 'z') mes[c] -= 26;
      mes[c] += dis;
      if(mes[d] + dis > 'z') mes[d] -= 26;
      mes[d] += dis;
    }

    puts(mes);
  }
  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {
	
	int a,b; cin >> a >> b;
	int c,d; cin >> c >> d;

	int cnt = 0;
	for (int i = 0; i <= 100; i++) {
		if (a <= i and i <= b and c <= i and i <= d) {
			cnt++;
		}
	}
	if (cnt != 0 ) {
		cnt--;
	}
	cout << cnt << endl;

	return 0;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 200'000 + 5;

i64 n, k;
i64 a[MAXN];
i64 u[MAXN];
i64 z[MAXN];


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);
    cin >> n >> k;

    for (i64 i = 1; i <= n; i++) {
        cin >> a[i];
    }


    i64 c = 1;
    i64 t = 0;
    for (i64 i = 1; true; i++) {
        if (u[c]) {
            t = i - u[c];
            break;
        }
        z[i] = c;
        u[c] = i;
        c = a[c];
    }

    k += 1;
    if (k < u[c]) {
        cout << z[k] << endl;
        return 0;
    }

    i64 i = u[c] + (k - u[c]) % t;
    cout << z[i] << endl;


    return 0;
}

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

using namespace std;

const int N = 2e6 + 5 , MOD = 1e9 + 7;
long long fact[N] , fact_inv[N];

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

long long mul(long long a , long long b) {
    return a * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

long long mod_inv(long long x) {
    return power(x , MOD - 2);
}

long long nCr(long long n , long long r){
    if (!r) return 1;
    if (r > n) return 0;
    return mul(fact[n] , mul(fact_inv[n - r] , fact_inv[r]));
}

void pre() {
    fact[0] = fact_inv[0] = 1;
    for(int i = 1 ; i < N ;i++) {
        fact[i] = mul(fact[i - 1] , i);
        fact_inv[i] = mod_inv(fact[i]);
    }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    pre();

    int r1 , c1 , r2 , c2;
    cin >> r1 >> c1 >> r2 >> c2;

    auto get = [] (int n , int r) {
        if (n < r)
            return 0ll;
        return nCr(n + 1 , r + 1);
    };

    int ans = 0;
    for (int i = r1 ; i <= r2 ;i++)
        ans = add(ans , add(get(i + c2 , i) , -get(i + c1 - 1 , i)));

    cout << ans;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  bool b = true;
  int C_count, x;
  
  for (int i = 2; i < N-1; i++) {
    if (S[i] == 'C') {
      C_count += 1;
      x = i;
    }
  }
  
  if (S[0] != 'A' || C_count != 1) {
    b = false;
  }
  
  for (int i = 1; i < N; i++) {
    if (i == x) {
      continue;
    }
    if (isupper(S[i])) {
      b = false;
      break;
    }
  }
  
  if (b) {
    cout << "AC" << endl;
    return 0;
  }
  cout << "WA" << endl;
}

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

int main(){

    string s;
    cin >> s;

    long long red  = 0;
    long long blue = 0;

    for(int i = 0; i < s.length(); i++){
        if(s[i] == '0') red ++;
        else blue ++;
    }
    cout << 2 * min(red, blue) << endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <stack>
#include <vector>
using namespace std;

int main(){
	string str;
	
	while(getline(cin,str) && str != ".")
	{
		string c;
		for(int i = 0 ; i < str.size() ; i++)
			if(str[i] == ')' || str[i] == '(' || str[i] == '[' || str[i] == ']')
			{
				c += str[i];
			}
		stack<char> s;
		bool f = true;
		for(int i = 0 ; i < c.length() ; i++)
		{
			if(s.empty() || c[i] == '(' || c[i] == '[')
			{
				s.push(c[i]);
			}
			else if( (s.top() == '(' && c[i] == ')') || (s.top() == '[' && c[i] == ']') )
			{
				s.pop();
			}else
			{
				f = false;
				break;
			}
		}
		cout << (f && s.empty() ?"yes":"no") << endl;
	}
}

Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>

using namespace std;

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

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

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

// #([0..n] ∩ kZ)
ll f(ll n, ll k) {
    return n / k;
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll L = lcm(C, D);
    ll ans = (B - f(B, C) - f(B, D) + f(B, L))
       - (A - 1 - f(A - 1, C) - f(A - 1, D) + f(A - 1, L));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int n, a, b[101], m[4][4];
bool mf[4][4];
 
bool rezolva () {
  if (mf[1][1] and mf[1][2] and mf[1][3])
    return true;
  if (mf[2][1] and mf[2][2] and mf[2][3])
    return true;
  if (mf[3][1] and mf[3][2] and mf[3][3])
    return true;
  if (mf[1][1] and mf[2][1] and mf[3][1])
    return true;
  if (mf[1][2] and mf[2][2] and mf[3][2])
    return true;
  if (mf[1][3] and mf[2][3] and mf[3][3])
    return true;
  if (mf[1][1] and mf[2][2] and mf[3][3])
    return true;
  if (mf[1][3] and mf[2][2] and mf[3][1])
    return true;
  return false;
}
 
int main()
{
  for (int l = 1; l <= 3; l++)
    for (int c = 1; c <= 3; c++)
      cin >> m[l][c];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    b[a]++;
  }
  for (int l = 1; l <= 3; l++)
    for (int c = 1; c <= 3; c++)
      if (b[m[l][c]] > 0)
        mf[l][c] = true;
  if (rezolva ())
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Measured memory_bytes: 256