akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cstdlib>

using namespace std;
const int N = 707;
bitset <N> dp;
int vv[N][N], col[N], used[N];
int x(0), y(0), n;
void dfs(int v, int c)
{
    //cout << v << " ";
    used[v] = 1;
    col[v] = c;
    if(c == 2)
        x++;
    else
        y++;
    for(int i = 1; i <= n; i++)
    {
        if(!vv[v][i])
        {
            if(used[i] && col[i] == c)
            {
                cout << -1;
                exit(0);
            }
            if(!used[i])
                dfs(i, 3 - c);
        }
    }
}

int main()
{
    dp[0] = 1;
    int m;
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int f, t;
        cin >> f >> t;
        vv[f][t] = 1;
        vv[t][f] = 1;
    }
    for(int i = 1; i <= n; i++)
        vv[i][i] = 1;

    for(int i = 1; i <= n; i++)
        if(!used[i])
        {
            x = 0; y = 0;
            dfs(i, 1);;
            dp = dp << x | dp << y;
        }

    int ans = 1e9;
    for(int i = 0; i <= n; i++)
        if(dp[i])
            ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
    cout << ans;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ll long long
#define fop(i,m,n) for(int i=m; i<n; i++)
#define MOD 998244353
#define ios ios::sync_with_stdio(0), cin.tie(0)
 
using namespace std;

int main()
{
    ios;
    
    int n;
    cin >> n;
    int h[n];
    fop(i,0,n) cin >> h[i];
    
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    fop(i,2,n){
        int a = dp[i-1] + abs(h[i] - h[i-1]);
        int b = dp[i-2] + abs(h[i] - h[i-2]);
        dp[i] = min(a, b);
    }
    cout << dp[n-1];
    
    
    return 0;
}

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

using namespace std;

int N;

int A[3][3];
bool ans[3][3];

int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}
	cin >> N;
	for (int k = 0; k < N; k++) {
		int b;
		cin >> b;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (A[i][j] == b) {
					ans[i][j] = true;
				}
			}
		}
	}
	if (ans[0][0] && ans[1][1] && ans[2][2]) {
		cout << "Yes" << endl; return 0;
	}
	if (ans[0][2] && ans[1][1] && ans[2][0]) {
		cout << "Yes" << endl; return 0;
	}
	for (int i = 0; i < 3; i++) {
		bool flag = true;
		for (int j = 0; j < 3; j++) {
			if (!ans[i][j]) { flag = false; }
		}
		if(flag){ cout << "Yes" << endl; return 0; }
	}
	for (int i = 0; i < 3; i++) {
		bool flag = true;
		for (int j = 0; j < 3; j++) {
			if (!ans[j][i]) { flag = false; }
		}
		if (flag) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()
    val d = sc.nextLong()

    val z = c * d
    var x = c
    var y = d
    if (x < y) {
        val tmp = x
        x = y
        y = tmp
    }

    var r = x % y
    while (r != 0L) {
        x = y
        y = r
        r = x % y
    }
    val mm = z / y

    val all = b - a + 1
    val result = all - countMP(c, a, b) - countMP(d, a, b) + countMP(mm, a, b)
    print(result)
}

fun countMP(n: Long, min: Long, max: Long): Long {
    return (max / n) - ((min-1) / n)
}


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

int n, T;
int main() {
    cin >> n >> T;
    int p = 1e9;
    for(int i = 0; i < n; ++i) {
        int c, t;
        cin >> c >> t;
        if(t > T) continue;
        p = min(p, c);
    }
    if(p == 1e9) {
        cout << "TLE" << endl;
    } else {
        cout << p << endl;
    }
}


Measured memory_bytes: 256
import sys
from bisect import *
from collections import *
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,D = map(int, input().split())
    XS = [list(map(int, input().split())) for _ in range(N)]
    ans = 0
    for i,j in combinations(XS, 2):
        total = sum([(x-y)**2 for x,y in zip(i,j)])
        if total == floor(sqrt(total))**2: ans += 1

    print(ans)

if __name__ == '__main__':
    main()

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));

  rep(i, h) rep(j, w) cin >> a[i][j];

  vector<vector<int>> ans;
  rep(i, h) rep(j, w) {
    if (a[i][j] % 2 == 0) continue;

    if (j + 1 < w && a[i][j + 1] % 2 == 1) {
      a[i][j]--;
      a[i][j + 1]++;
      ans.push_back({i, j, i, j + 1});
      continue;
    }

    if (i + 1 < h && a[i + 1][j] % 2 == 1) {
      a[i][j]--;
      a[i + 1][j]++;
      ans.push_back({i, j, i + 1, j});
      continue;
    }

    if (j + 1 < w) {
      a[i][j]--;
      a[i][j + 1]++;
      ans.push_back({i, j, i, j + 1});
      continue;
    }

    if (i + 1 < h) {
      a[i][j]--;
      a[i + 1][j]++;
      ans.push_back({i, j, i + 1, j});
      continue;
    }
  }

  cout << ans.size() << endl;
  for (auto move : ans) {
    printf("%d %d %d %d\n", move[0] + 1, move[1] + 1, move[2] + 1, move[3] + 1);
  }

  return 0;
}

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

using namespace std;

#define DPRINTF(...) printf(__VA_ARGS__)
#define FOR0(i, n) for(int i=0;i<n;i++)
#define ALL(c) (begin(c)), (end(c))
#define fst(t) get<0>(t)
#define snd(t) get<1>(t)
#define thd(t) get<2>(t)

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

ll MOD = 1e9 + 7;

ll inv(ll a, ll p){
    ll res = 1ll;
    ll n = p - 2;
    
    while(n > 0){
        if(n & 1ll){
            res = res * a % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return res;
}

ll fact[300000];

ll nCk(int n, int k){
    if(n < k){return 0;}

    return fact[n] * inv(fact[n-k], MOD) % MOD * inv(fact[k], MOD) % MOD;
}

int main(){
  //*
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  /*/
  /*/

  fact[0] = 1ll;
  for(int i=1;i<300000;i++){
      fact[i] = fact[i-1] * i % MOD;
  }

  int H, W, A, B;
  cin >> H >> W >> A >> B;

  ll res = nCk(H-1 + W-1, H-1);

  // cout << "all:" << res << endl;
  
  FOR0(i, B){
      // cout << nCk(H-A-1 + i, i) * nCk(A-1 + W-i-1, A-1) << endl;
      res = ((res - nCk(H-A-1 + i, i) * nCk(A-1 + W-i-1, A-1) % MOD) % MOD + MOD) % MOD;
  }

  cout << res << endl;
}


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

using namespace std;

int main(){
	
	string s1,s2;
	int n,m;
	cin>>s1>>s2;
	n=s1.length();
	m=s2.length();
	int dp[n+1][m+1];
	for (int i=0;i<=n;i++){
		for (int j=0;j<=m;j++){
			if (i==0||j==0){
				dp[i][j]=0;
			}
			else if (s1[i-1]==s2[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else {
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int index = dp[n][m]; 
	//cout<<dp[n][m];
   char lcs[index+1]; 
   lcs[index] = '\0';
	int i = n, j = m; 
   while (i > 0 && j > 0){ 
    	if (s1[i-1] == s2[j-1]){ 
	        lcs[index-1] = s1[i-1];
	        i--; j--; index--;
    	} 
	    else if (dp[i-1][j] > dp[i][j-1]) 
	        i--; 
	    else
	        j--; 
   } 	
   cout<<lcs<<endl;
 	
	
}

Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); i < (end); i++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; i >= (end); i--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n, a;
  cin >> n;
  multiset<int> c{-1};
  REP(i, n) {
    cin >> a;
    auto itr = c.lower_bound(a);
    if (itr == c.begin()) {
      c.insert(a);
    } else {
      itr--;
      c.erase(itr);
      c.insert(a);
    }
  }
  
  cout << c.size() << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<stack>
#include<set>
#include<map>
#include<vector>
using namespace std;
string a="AKIHABARA";
string b;
int main(){
	cin>>b;
	int n=b.length();
	if(n>9){
		printf("NO");
		return 0;
	}
	int f=1,j=0;
	for(int i=0;i<n;i++){
		if(j>=9){
			f=0;
			break;
		}
		if(b[i]==a[j]){
			j++;
		}
		else if(a[j]=='A'){
			i--;
			j++;
		}
		else if(b[i]!=a[j]){
			f=0;
			break;
		}
	}
	if(j<8) f=0;
	if(f) printf("YES");
	else printf("NO");
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int x, a, b;
int main() {
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
       char a;
       cin>>a;

       if(a>='A' and a<='Z')printf("A\n");
       else{
        printf("a\n");
       }

        //printf("Case %d: ",++te);
    }
    return 0;
}






Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        int N = cin.Nextint;
        var S = new int[N];
        for (int i = 0; i < N; i++)
        {
            S[i] = cin.Nextint;
        }
        Array.Sort(S);
        if (S.Sum() % 10 != 0)
        {
            WriteLine(S.Sum());
        }
        else
        {
            //bool flag = false;
            for (int i = 0; i < N; i++)
            {
                if (S[i] % 10 != 0)
                {
                    WriteLine(S.Sum() - S[i]);
                    return;
                }

            }
            WriteLine(0);
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 13392
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x<1200){
			System.out.println("ABC");
		}else{
			System.out.println("ARC");
		}
		sc.close();
	}
}

Measured memory_bytes: 23508
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF INT_MAX/3

#define MAX_N 1000

int n,k;
int d[10];

int main(){
	cin>>n>>k;
	REP(i,k) cin>>d[i];
	FOR(i,n,100000){
		string s = to_string(i);
		bool flag = true;
		REP(j,s.length())REP(l,k){
			if(s[j]-'0'==d[l]) flag = false;
		}
		if(flag){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  cout<<n-m+1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
struct Vec2D
{
    T x, y;
};

int SumOfDigits(int n)
{
    int sumOfDigits {};

    while (n > 0)
    {
        sumOfDigits += n % 10;
        n /= 10;
    }

    return sumOfDigits;
}

bool IsPalindromic(std::string s)
{
    using namespace std;

    bool isPalindromic = true;
    for (int l = 0, r = s.size() - 1; l < r; ++l, --r)
    {
        if (s[l] != s[r])
        {
            isPalindromic = false;
            break;
        }
    }

    return isPalindromic;
}

void solve()
{
    using namespace std;
    int a, b; cin >> a >> b;

    int count {};

    for (int i = a; i <= b; ++i)
        if (IsPalindromic(to_string(i)))
            ++count;

    cout << count << endl;

}

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

Measured memory_bytes: 256
def task_A(N, h):
    res = [0]*N
    res[0] = 0
    res[1] = abs(h[1] - h[0])
    for k in range(2, N):
        a = res[k - 1] + abs(h[k - 1] - h[k])
        b = res[k - 2] + abs(h[k - 2] - h[k])
        res[k] = min(a, b)
    return res[N - 1]
  
N = int(input())
h = [int(x) for x in input().split()]
result = task_A(N, h)
print(result)

Measured memory_bytes: 13928
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i64>();
    let (h, w) = (line[0], line[1]);

    if h%3 == 0 || w%3 == 0{
        println!("0");
        return;
    }

    //chocolate is wide
    let (h, w) = (cmp::min(h, w), cmp::max(h, w));

    let (mut a, mut b) = (0, 0);
    let mut c = h*w;
    let mut ans1 = h*w;
    for _ in 0..w-1{
        a += h/2;
        b += (h+1)/2;
        c -= h;
        let smax = cmp::max(cmp::max(a, b), c);
        let smin = cmp::min(cmp::min(a, b), c);
        ans1 = cmp::min(cmp::max(smax-smin, 0), ans1);
    }

    let (mut a, mut b) = (0, 0);
    let mut c = h*w;
    let mut ans2 = h*w;
    for _ in 0..h-1{
        a += w/2;
        b += (w+1)/2;
        c -= w;
        let smax = cmp::max(cmp::max(a, b), c);
        let smin = cmp::min(cmp::min(a, b), c);
        ans2 = cmp::min(cmp::max(smax-smin, 0), ans2);
    }

    println!("{}", cmp::min(ans1, cmp::min(ans2, cmp::min(h, w))));
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
    int n, max, sum = 0;
    scanf("%d", &n);
    int h[n];
    for(int i=0; i<n; i++){
        scanf("%d", &h[i]);
    }
    max = h[0];
    for(int i=0; i<n; i++){
        if(h[i] == max){
            sum++;
        }else if(h[i] > max){
            sum++;
            max = h[i];
        }
    }
    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N, x; cin >> N >> x;
	vl a(N);
	REP(i, N) cin >> a[i];
	ll res = 0;
	REP(i, N - 1) {
		if (a[i] + a[i + 1] > x) {
			ll diff = a[i] + a[i + 1] - x;
			a[i + 1] -= diff;
			res += diff;
			if (a[i + 1] < 0) {
				a[i] += a[i + 1];
			}
			a[i + 1] = max((ll)0, a[i + 1]);
		}
	}
	// debug(a);
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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


using namespace std;


int main(){
    string S,T;
    cin >> S >> T;
    vector<int> start(26,-1);
    vector<int> goal(26,-1);

    for(int i=0;i<S.size();i++){
        int a=S[i]-'a';
        int b=T[i]-'a';

        if(start[a] != -1 || goal[b] != -1){
            if(start[a] != b || goal[b]!=a){
                cout << "No" << endl;
                return 0;
            }
        }else{
            start[a]=b;
            goal[b]=a; 
        }
    }

    cout<<"Yes" << endl;


    return 0;
    
}

Measured memory_bytes: 776
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
ans = 1
l = [0]*N
for i in range(N):
    l[A[i]] += 1
for i in range(N):
    c = l[i]
    if N%2 == i%2:
        if c:
            ans *= 0
    else:
        if c == 0:
            ans *= 0
        if c == 1:
            if i != 0:
                ans *= 0
        if c == 2:
            ans *= 2
print(ans%mod)

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

int main() {
    int n;
    cin >> n;
    vector<int> H(n);
    for (int i = 0; i < n; ++i) cin >> H.at(i);
    reverse(H.begin(), H.end());
    string ans = "Yes";
    for (int i = 0; i < n-1; ++i) {
        if (H.at(i+1) - H.at(i) > 1) {
            ans = "No";
            break;
        }
        else if (H.at(i+1) - H.at(i) == 1) {
            H.at(i+1)--;
        }
    }
    cout << ans << endl;
}

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

int A,B;

int main()
{
    cin>>A>>B;

    int cnt=0;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 0; j <= 9; j++)
        {
            for (int k = 0; k <= 9; k++)
            {
                int x = 10001*i + 1010*j + 100*k;
                if(A<=x && x<=B ) cnt++;
            }
        }
    }
    
    
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
v = [int(i) for i in input().split()]
even = [0] * int(1e5+1)
odd = [0] * int(1e5+1)

for i, k in enumerate(v):
    if (i & 1 == 0):
        even[k] += 1
    else:
        odd[k] += 1

if even.index(max(even)) == odd.index(max(odd)):
    even.sort(reverse=True)
    odd.sort(reverse=True)
    print(min(n - even[1] - odd[0],
              n - even[0] - odd[1]))
else:
    even.sort(reverse=True)
    odd.sort(reverse=True)
    print(n - even[0] - odd[0])

Measured memory_bytes: 14268
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
  int a[9], b[9]={}, n;
  for(int i=0; i<9; i++) cin >> a[i];
  cin >> n;
  for(int i=0; i<n; i++){
    int c;
    cin >> c;
    for(int i=0; i<9; i++){
      if (c==a[i]) b[i]=1;
    }
  }
  if(b[0]==1&&b[3]==1&&b[6]==1) cout << "Yes";
  else if(b[1]==1&&b[4]==1&&b[7]==1) cout << "Yes";
  else if(b[2]==1&&b[5]==1&&b[8]==1) cout << "Yes";
  else if(b[0]==1&&b[1]==1&&b[2]==1) cout << "Yes";
  else if(b[3]==1&&b[4]==1&&b[5]==1) cout << "Yes";
  else if(b[6]==1&&b[7]==1&&b[8]==1) cout << "Yes";
  else if(b[0]==1&&b[4]==1&&b[8]==1) cout << "Yes";
  else if(b[2]==1&&b[4]==1&&b[6]==1) cout << "Yes";
  else cout << "No";
    return 0;
}


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

int main(void)
{
    int n;
    cin >> n;
    vector<tuple<string,int,int>> v;
    for(int i = 0;i < n; i++) {
        string s;
        int p;
        cin >> s >> p;
        v.emplace_back(make_tuple(s,-p,i+1));
    }
    sort(v.begin(),v.end());

    for(int i = 0; i < n; i++){
        cout << get<2>(v[i]) << endl;;
    }

    return 0;
}

Measured memory_bytes: 256
for(2..1e5){
	for($i=$_;($i+=$_)<=1e5;){
		$_[$i]=1
	}
}
$_[$_]|=$_[$_+1>>1]for sort{1}3..1e5;
$p=$s[$_]=$p+!$_[$_]for 3..1e5;

<>;/ /,print$s[$']-$s[$`-1],$/for<>


Measured memory_bytes: 28448
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  int a[200005];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int> b;
  for(int i=0;i<n;i+=2){
    b.push_back(a[i]);
  }
  reverse(b.begin(),b.end());
  for(int i=1;i<n;i+=2){
    b.push_back(a[i]);
  }
  if(n%2==0)reverse(b.begin(),b.end());
  for(int i=0;i<n-1;i++){
    cout<<b[i]<<" ";
  }
  cout<<b[n-1]<<"\n";
  return 0;
}


Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int A, B, C,D;

	cin >> A >> B >> C >>D;

	int ans = 0;

	if (A > B) {
		ans += B;
	}
	else {
		ans += A;
	}

	if (C > D) {
		ans += D;
	}
	else {
		ans += C;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int h[N],dp[N];
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch&15),ch=getchar();
	return x*f;
}
int main()
{
	int n=read();
	for (register int i=1;i<=n;++i) h[i]=read();
	dp[1]=0;
	for (register int i=2;i<=n;++i)
	{
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		if (i>2) dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,c,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> n >> m >> c;
	vector<int> b(m);
	for(i=0;i<m;i++) {
		cin >> b[i];
	}
	for(j=0;j<n;j++) {
		x = 0;
		for(i=0;i<m;i++) {
			cin >> a;
			x += a*b[i];
		}
		if (x + c > 0) ans++;
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
int N;
  in(N);
 int  M;
  in(M);
  vl A(M);  
  int ans =0;
  rep(i,M) {
    in(A[i]); 
    ans += A[i];
  }
 if(ans <= N) out(N-ans);
  else out(-1);
}


Measured memory_bytes: 3708
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		String harai="",oturi="";
		 str=bfr.readLine();
		 harai=str;

		 str=bfr.readLine();
		 oturi=str;

		 int ha=Integer.parseInt(harai);
		 int ot=Integer.parseInt(oturi);

		 if(ha%500<=ot) {
			 System.out.println("Yes");
		 }
		 else {
			 System.out.println("No");
		 }
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
using namespace std;

int main()
{
    ll n,m,x,t;
    ll i,j,k;
    ll res=0;
    cin>>n>>x>>t;
    if(n%x==0)cout<<(n/x)*t;
    else cout<<(n/x+1)*t;
}

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

int
main(int argc, char *argv[])
{
    unsigned int X;

    scanf("%u", &X);

    unsigned int a = X / 500;
    unsigned int b = X % 500;
    unsigned int c = b / 5;

    printf("%u\n", a * 1000 + c * 5);

    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    int h,n;
    cin >> h>>n;
    int a[100005];
    ll temp=0;
    rep(i,n){
        cin >> a[i];
        temp+=a[i];
    }
    if(temp>=h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}



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

int main(){
  int n; cin >> n;
  char s,s0;
  int c=1;
  for (int i=0;i<n;i++){
    cin >> s;
    if (i == 0)s0 = s;
    if (s0 == s)continue;
    else{
      c++;
      s0 = s;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        ArrayList<Integer>[] graph = new ArrayList[n];
        
        for(int i=0; i<n; i++){
            graph[i] = new ArrayList<>();
        }
        
        for(int i=0; i<m; i++){
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            graph[a].add(b);
            graph[b].add(a);
        }
        
        int[] dist = new int[n];
        Arrays.fill(dist, (int)1e7);
        dist[0] = 0;
        ArrayDeque<Integer> q = new ArrayDeque<>();
        q.addLast(0);
        boolean[] used = new boolean[n];
        used[0] = true;
        int[] ans = new int[n];
        while(q.size()!=0){
            int now = q.pollFirst();
            for(int next : graph[now]){
                if(dist[now]+1 < dist[next]){
                    q.add(next);
                    dist[next] = dist[now]+1;
                    used[next] = true;
                    ans[next] = now+1;
                }
            }
        }
        
        System.out.println("Yes");
        for(int i=1; i<n; i++){
            System.out.println(ans[i]);
        }
        
    }
    
}

Measured memory_bytes: 68360
A, B, K = map(int, input().split())

k = K-1
if A+k >= B-k:
    for i in range(A, B+1):
        print(i)
else:
    for j in range(A, A+k+1):
        print(j)
    for k in range(B-k, B+1):
        print(k)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
using ll = long long;
typedef pair<ll, ll> P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*ナップサック*/
/*制約w小さい、価値v大きい*/
/*dp[w] wの重さで得られる最大の価値*/

/*def*/
ll dp[100100];
ll n, w;
ll wi, vi;

int main() {
/*input*/
    cin >> n >> w;

/*main貰うdp*/
    for (int i = 0; i < n; i++){
        cin >> wi >> vi;
        for (int j = w; j > 0; j--){
            if (j-wi >= 0){
                chmax(dp[j], dp[j-wi] + vi);
            }
        }
    }

/*output*/
/* for debug

    for(int i = 1; i<=w;i++){
        cout << dp[i] << endl;
    }

*/
    cout << dp[w] << endl;
    return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    if (n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    for (int i = 0; i < n / 2; i++)
    {
        if (s[i] != s[n / 2 + i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int x,y,tmp;
	
	while(scanf("%d %d",&x,&y),x || y){
		if(x < y)
			printf("%d %d\n",x,y);
		else
			printf("%d %d\n",y,x);
	}
	
	return 0;
}

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

using namespace std;

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

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

#endif

template<class Monoid>
class SegmentTree {

public:
    /**
     * @param N size
     * @param e identity element
     * @param operation operation to merge `data`
     * @param updater operation to update `data`
     */
    SegmentTree(size_t N, Monoid e, function<Monoid(Monoid, Monoid)> operation,
                function<Monoid(Monoid, Monoid)> updater)
            : e(e), operation(operation), updater(move(updater)) {
        n = 1;
        while (n < N) {
            n *= 2;
        }
        data = vector<Monoid>(2 * n - 1, e);
        for (int i = n - 2; i >= 0; i--) {
            data[i] = operation(data[2 * i + 1], data[2 * i + 2]);
        }
    }

    /**
     * iの値をxに更新 ( 0-indexed )
     */
    void update(int i, Monoid x) {
        i += n - 1;
        data[i] = updater(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    /**
     * [a, b)の区間でクエリを実行
     */
    Monoid query(int a, int b) {
        return query(a, b, 0, 0, n);
    }

    /**
     * 添字でアクセス( 0-indexed )
     */
    Monoid operator[](int i) {
        return data[i + n - 1];
    }

private:
    int n;
    vector<Monoid> data;
    Monoid e;
    function<Monoid(Monoid, Monoid)> operation;
    function<Monoid(Monoid, Monoid)> updater;

    Monoid query(int a, int b, int k, int l, int r) {
        // 交差しない
        if (r <= a || b <= l) return e;
        // 区間 [a, b) に l, r が含まれる
        if (a <= l && r <= b) return data[k];
        // 左の子
        Monoid c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
        // 右の子
        Monoid c2 = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return operation(c1, c2);
    }
};

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    auto B = A;
    sort(B.begin(), B.end());
    B.erase(unique(B.begin(), B.end()), B.end());
    rep(i, N) {
        ll idx = lower_bound(B.begin(), B.end(), A[i]) - B.begin();
        A[i] = idx;
    }
    SegmentTree<ll> segmentTree(N, 0, [](ll a, ll b) { return max(a, b); }, [](ll a, ll b) { return b; });
    rep(i, N) {
        ll a = A[i];
        segmentTree.update(a, segmentTree.query(0, a) + 1);
    }
    cout << segmentTree.query(0, N) << '\n';
}

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



Measured memory_bytes: 6548
import sys
inputs = sys.stdin.readlines()
A = [int(i.rstrip('\n')) for i in inputs]
B = sorted(A)
m = B[-1]

P = [2, 3, 5, 7]
for i in range(11, m + 1, 2):
    if i % 5 == 0 or i % 7 == 0:
        continue
    is_prime = True
    for p in P:
        if p * p > i:
            break
        if i % p == 0:
            is_prime = False
            break
    if is_prime:
        P.append(i)
P.append(1000000)

l = len(P)
for a in A:
    for i in range(l):
        if P[i] > a:
            print(i)
            break








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

#define PI (3.14159265358979323846264338327950288)

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

  double a, b, x;
  cin >> a >> b >> x;
  double c = x/(a * a);
  if (x > a * b * 0.5 * a) {
    double a_2 = b - (2.0 * c - b);
    cout << (atan(a_2/a) * 180.0)/PI << endl;
  } else {
    double a_2 = (2.0 * a * c)/b;
    cout << 90.0 - (atan(a_2/b) * 180.0)/PI << endl;
  }
  return 0;
}


Measured memory_bytes: 256
S=str(input())
sl=S[::2]
sr=S[1::2]
N=len(S)
n1=len(sl)
n2=len(sr)
num1=sl.count('0')
num2=sr.count('0')
ans1=num1+n2-num2
ans2=num2+n1-num1
a=min(ans1,ans2)
print(a)

Measured memory_bytes: 3188
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val B = in.head
  
  val ret = B.map{ e =>
    e match {
      case 'A' => 'T'
      case 'T' => 'A'
      case 'C' => 'G'
      case 'G' => 'C'
    }
 }
 println(ret)
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 924844033;

const int MAX_N = 2002;

int N, K;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> K;

  vint nex(N<<1, -1);
  rep(i, N-K) {
    nex[i] = N+i+K;
    nex[N+i] = i+K;
  }

  vector<vint> dp(N+1, vint(2));
  dp[0][0] = 1;
  rep(i, K) {
    bool flag = true;
    //cout << i << ":";
    for(int v = nex[i]; v != -1; v = nex[v]) {
      //cout << " -> " << v;
      vector<vint> dp2(N+1, vint(2));
      rep(j, N) {
	dp2[j][0] = (dp[j][0]+dp[j][1])%mod;
	dp2[j+1][1] = (dp[j][1]*flag+dp[j][0])%mod;
      }
      dp.swap(dp2);
      flag = false;
    }
    //cout << endl;
    flag = true;
    //cout<< N+i << ":";
    for(int v = nex[N+i]; v != -1; v = nex[v]) {
      //cout << " -> " << v;
      vector<vint> dp2(N+1, vint(2));
      rep(j, N) {
	dp2[j][0] = (dp[j][0]+dp[j][1])%mod;
	dp2[j+1][1] = (dp[j][1]*flag+dp[j][0])%mod;
      }
      dp.swap(dp2);
      flag = false;
    }
    //cout << endl;
    //cout<<dp[1][0]<<" "<<dp[1][1]<<endl;
  }

  vint f(N+1);
  rep(i, N+1) f[i] = (dp[i][0]+dp[i][1])%mod;

  vint fact(N+1);
  fact[0] = 1;
  reps(i, 1, N+1) fact[i] = fact[i-1]*i%mod;

  int ans = 0;
  rep(i, N+1) {
    //cout<<ans<<endl;
    if(i&1) ans += mod-f[i]*fact[N-i]%mod;
    else ans += f[i]*fact[N-i]%mod;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
int32_t main()
{
	fastio();
	int n,k;
	cin>>n>>k;
	int tt=n-k;
	if(k==1)
		cout<<0;
	else
	cout<<tt;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
num=[0]*100001
for i in a:
  num[i]+=1
x=0
for i in num:
  if i<=0:
    continue
  elif i%2==0:
    n-=i
    x+=1
  else:
    n-=i-1
    
if x%2:
  x-=1
  
print(n+x)

Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main(){
    int n;
        cin >> n;
    vector<int> a(n);

    for (int i=0;i<n;i++){
        cin >> a.at(i);
    }
    int want = 1;
    int cnt = n;
    for (int i=0;i<n;i++){
        if(a.at(i)==want){
            cnt--;
            want++;
        }
    }
    if(cnt>=n) cnt=-1;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string n;
	cin >> n;
	ll k;
	ll c = 0;
	cin >> k;
	ll ans = 0;
	ll t;
	t = n.size();
	if (k == 1){
		cout << (t-1)*9+n[0]-'0' << endl;
	}
	else if (k == 2){
		if (t < 2){
			cout << 0 << endl;
			return 0;
		}
		ans += (t-1)*(t-2)/2*ll(9*9);
		ans += max(ll(0),ll(n[0]-'0'-1))*(t-1)*9;
		ll c = 0;
		c++;
		t--;
		while (n[c] == '0' && c < n.size()){
			c++;
			t--;
		}
		if (c == n.size()){
			cout << ans << endl;
			return 0;
		}
		ans += (t-1)*9+n[c]-'0';
		cout << ans << endl;
	}
	else if (k == 3){
		if (t < 3){
			cout << 0 << endl;
			return 0;
		}
		ans += (t-1)*(t-2)*(t-3)/ll(6)*ll(9*9*9);
		ans += max(ll(0),ll(n[0]-'0'-1))*(t-1)*(t-2)/2*ll(9*9);
		ll c = 0;
		c++;
		t--;
		while (n[c] == '0' && c < n.size()){
			c++;
			t--;
		}
		if (c == n.size()){
			cout << ans << endl;
			return 0;
		}
		ans += (t-1)*(t-2)/2*ll(9*9);
		ans += max(ll(0),ll(n[c]-'0'-1))*(t-1)*9;
		c++;
		t--;
		while (n[c] == '0' && c < n.size()){
			c++;
			t--;
		}
		if (c == n.size()){
			cout << ans << endl;
			return 0;
		}
		ans += (t-1)*9+n[c]-'0';
		cout << ans << endl;
	} 
	
} 
 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#define LL long long
using namespace std;
#define maxn 107
#define maxx 1000000

char a[maxn][maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    int n=100,i,j,k,x,y;
    scanf("%d%d",&x,&y);
    for(i=1;i<=50;i++)
    {
        for(j=1;j<=100;j++)
        {
            a[i][j]='.';
            a[i+50][j]='#';
        }
    }
    x--;
    y--;
    for(i=1;i<=100;i+=2)
    {
        for(j=1;j<=100;j+=2)
        {
            if(y--) a[i][j]='#';
            else break;
        }
        if(y<=0) break;
    }
    for(i=100;i>=1;i-=2)
    {
        for(j=100;j>=1;j-=2)
        {
            if(x--) a[i][j]='.';
            else break;
        }
        if(x<=0) break;
    }
    printf("100 100\n");
    for(i=1;i<=100;i++)
    {
        for(j=1;j<=100;j++)
        {
            printf("%c",a[i][j]);
        }
        printf("\n");
    }


    return 0;
}


Measured memory_bytes: 256
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
N = int(input())
X = list(map(int, input().split()))

p = sum(X) / N
p = Decimal(str(p)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
ans = 0
for x in X:
    ans += (x - p) ** 2

print(ans)

Measured memory_bytes: 5076
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <climits>

using namespace std;

int main() {
   int a, b, c;

   cin >> a >> b >> c;

   if (a + b >= c)
       cout << "Yes\n";
   else
       cout << "No\n";
}


Measured memory_bytes: 256
#define rep(i, m, n) for(int i = m; i < n; i++)
#define repM(i, m, n) for(int i = n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll; using namespace std;
//typedef pair<int,int> pii;
// d = distance(lower_bound(all(x)), upper_bound(all(x)));
int INF = 1e9;
int M = 1e9+7;
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
//#include <algorithm>

int main(){
  int N; cin >> N; int a[N], b[N-1]; fill(a, a+N, 0);
  for(int i=0; i<N-1; i++) cin >> b[i]; a[0] = b[0]; a[N-1] = b[N-2];
  for(int i=1; i<N-1; i++) {
    a[i] = min(b[i-1], b[i]);
  } int an=0;
  for(int i=0; i<N; i++) an+=a[i];
  cout << an << endl;
}

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

using namespace std;

int main() {
	int N,cnt=0,Pd,Qd;
	cin >> N;
	vector<int> P(N), Q(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> P.at(i);
	}
	for (size_t i = 0; i < N; i++)
	{
		cin >> Q.at(i);
	}
	vector<int> S;
	for (size_t i = 1; i <= N; i++)
	{
		S.push_back(i);
	}

	vector<vector<int>> T;
	do {
		T.push_back(S);
	} while (next_permutation(S.begin(), S.end()));
	for (size_t i = 0; i < T.size(); i++)
	{
		if (P==T.at(i))
		{
			Pd = i;
		}
		if (Q==T.at(i))
		{
			Qd = i;
		}
	}
	cout << abs(Pd - Qd);
}


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

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

int main(){

    int n;
    cin>>n;
    string tmpa,tmpb;
    cin>>tmpa;
    set<string> st;
    st.insert(tmpa);
    FOR(i,1,n){
        cin>>tmpb;
        if(tmpa[tmpa.size()-1]==tmpb[0]&&st.count(tmpb)==0){
            st.insert(tmpb);
            tmpa=tmpb;
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;


    return 0;
}


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

main() {
  int N; cin >> N;
  string s; cin >> s;
  s += s[0];

  string init[4] = {"SS", "SW", "WS", "WW"};
  string ans{};
  for (int i = 0; i < 4; i++) {
    string res = init[i];
    for (int j = 0; j < N - 1; j++) {
      if (res.substr(j, 2) == "SS") res += (s[j + 1] == 'o') ? 'S' : 'W';
      if (res.substr(j, 2) == "SW") res += (s[j + 1] == 'o') ? 'W' : 'S';
      if (res.substr(j, 2) == "WS") res += (s[j + 1] == 'o') ? 'W' : 'S';
      if (res.substr(j, 2) == "WW") res += (s[j + 1] == 'o') ? 'S' : 'W';
    }

    bool ok = false;
    if (res.back() != res.front()) continue;
    if (res.substr(N - 1, 2) == "SS") {
      if (s[0] == 'o' && res[1] == 'S' || s[0] == 'x' && res[1] == 'W') ok = true;
    }
    if (res.substr(N - 1, 2) == "SW") {
      if (s[0] == 'o' && res[1] == 'W' || s[0] == 'x' && res[1] == 'S') ok = true;
    }
    if (res.substr(N - 1, 2) == "WS") {
      if (s[0] == 'o' && res[1] == 'W' || s[0] == 'x' && res[1] == 'S') ok = true;
    }
    if (res.substr(N - 1, 2) == "WW") {
      if (s[0] == 'o' && res[1] == 'S' || s[0] == 'x' && res[1] == 'W') ok = true;
    }

    if (ok) ans = res.substr(0, N);
  }
  cout << ( (ans.empty()) ? "-1" : ans ) << endl;
}


Measured memory_bytes: 736
N = int(input())
A = [0] + list(map(int,input().split())) + [0]

total = 0
for i in range(N+1):
    total += abs(A[i+1]-A[i])

for i in range(N):
    print(total - abs(A[i+1]-A[i]) - abs(A[i+2]-A[i+1]) + abs(A[i+2]-A[i]))

Measured memory_bytes: 13920
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n%2==0 or n%5==0)
	{
		cout<<-1<<endl;
	}
	else
	{
		int x=0;
		int count=1;
		while(count<=n)
		{
			x = (x*10+7)%n;
			if(x==0)
			break;
			count++;
		}
		cout<<count<<endl;
	}
	return 0;
}


Measured memory_bytes: 3600