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

using namespace std;

const long long Q = 998244353;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    string s; cin >> s;

    long long ans = 1;
    int R = 0, G = 0, B = 0;
    for(auto c : s)
    {
        if(c == 'R')
        {
            ++R;
            int tmp;
            if(R > G && R > B) tmp = R - max(G, B);
            else if(R <= G && R <= B) tmp = R;
            else tmp = R - min(G, B);
            ans *= tmp;
            ans %= Q;
        }
        if(c == 'G')
        {
            ++G;
            int tmp;
            if(G > R && G > B) tmp = G - max(R, B);
            else if(G <= R && G <= B) tmp = G;
            else tmp = G - min(R, B);
            ans *= tmp;
            ans %= Q;
        }
        if(c == 'B')
        {
            ++B;
            int tmp;
            if(B > G && B > R) tmp = B - max(G, R);
            else if(B <= G && B <= R) tmp = B;
            else tmp = B - min(G, R);
            ans *= tmp;
            ans %= Q;
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 720
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    a, b, c, d = get_li()
    c_min = (a + c - 1) // c
    c_max = b // c
    if c == d:
        print(b - a + 1 - (c_max - c_min + 1))
        return
    d_min = (a + d - 1) // d
    d_max = b // d
    e = c * d // gcd(c, d)
    if c == e:
        print(b - a + 1 - (d_max - d_min + 1))
        return
    if d == e:
        print(b - a + 1 - (c_max - c_min + 1))
        return
    e_min = (a + e - 1) // e
    e_max = b // e
    print(b - a + 1 - (c_max - c_min + 1) - (d_max - d_min + 1) + (e_max - e_min + 1))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


Measured memory_bytes: 65388
import bisect
N,H = map(int,input().split())
a = []; b = []
for i in range(N):
    ai,bi = map(int,input().split())
    a.append(ai)
    b.append(bi)

a = sorted(a)
b = sorted(b)
strn_a = a[N-1]
damage = [strn_a]
for i in range(bisect.bisect_left(b,strn_a),N):
    damage.append(b[i])

ans = 0
for i in damage[::-1]:
    H -= i
    ans += 1
    if H <= 0:
        break
if H > 0:
    if H % damage[0] == 0:
        ans += H // damage[0]
    else:
        ans += H // damage[0] + 1

print(ans)

Measured memory_bytes: 12516
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = 1000000
a = 0
if x not in p:
    a = 1
else:#xがpに入っていない場合
    for i in range(n):
        ch = abs(x-p[i])
        ans = min(ans,ch)
count = x-ans-1
if a == 1:
    print(x)
elif count not in p:
    print(count)
else:
    for j in range(ans,10000,1):
        if (x-j>=0) and x-j not in p:
            print(x-j)
            break
        elif x+j not in p:
            print(x+j)
            break

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

int main(){
  int a[3];
  int max = 0;
  int min = 101;
  for(int i = 0; i < 3; i++){
    cin >> a[i];
    if(max < a[i]) max = a[i];
    if(min > a[i]) min = a[i];
  }
  cout << max - min << endl;
  return 0;
}

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

namespace ConsoleApp1
{
    static class BUnevenNumbers
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            int count = 0;
            for (int i = 1; i <= n; i++)
            {                
                if (i.ToString().Length % 2 == 0)
                {
                    i *= 10;
                    i--;
                    continue;
                }
                count++;
            }

            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,m,i;
	string s;
	cin >> n;
	cin >> s;
	m = s.l_ength();
	for(i=0; i<m; ++i){
		s[i] -= 'A';
		s[i] += n; 
		s[i] %= 26;
		s[i] += 'A';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }eni(!=) cerr  << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
} sim dor(rge<c> d) { *this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
#define err(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll=long long;
using vi=vector<int>;



int main()
{
    ios::sync_with_stdio (false), cin.tie (0);
    ll a, b;
    cin >> a >> b;
    a = __gcd (a, b);
    ll cnt = 1;
    for (ll d = 2; d * d <= a; d++)
        if (a % d ==0)
        {
            while(a % d == 0){
                a/= d;
            }
            cnt++;
        }

    if (a != 1)
        cnt++;
    cout << cnt << '\n';



    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(x) x&(-x)
using namespace std;
 
typedef long long ll;
 
const int maxn=2e5+10;
 
int a[maxn],b[maxn],c[maxn];
bool vis[maxn];


int n,m,x;
ll k;

int main()
{
    
    cin>>n>>k;
    for( int i=1;i<=n;i++ ) cin>>a[i];
    
    int now=1,cnt=0;
	
	int i;
   	for( i=1;!vis[i];i=a[i] )
   	{
   		c[i]=cnt;
   		b[cnt++]=i;
   		vis[i]=1;
   	}
   	int xu=cnt-c[i],st=c[i];
	if( k<=st )
	{
		cout<<b[k]<<endl;
	}
	else
	{
		k-=st;
		k%=xu;
		cout<<b[k+st]<<endl;
	}

}

Measured memory_bytes: 6012
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
           /* string[] data1 = Console.ReadLine().Split(' ');
            string[] data2 = Console.ReadLine().Split(' ');*/
            string data3 = Console.ReadLine();




            for (int i = 0; i < data3.Length; i++) Console.Write("x");


            //Console.WriteLine(a+" "+b);
            
            
        }
    }
}


Measured memory_bytes: 11092
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		int N = Integer.parseInt(input());

		for (int i = 0; i < N; i++) {

			String num1 = input();
			String num2 = input();

			if (80 < num1.length() || 80 < num2.length()) {

				System.out.println("overflow");

			} else {

				BigInteger bigNum1 = new BigInteger(num1);
				BigInteger bigNum2 = new BigInteger(num2);
				String result = bigNum1.add(bigNum2).toString();

				if (80 < result.toString().length()) {

					System.out.println("overflow");

				} else {

					System.out.println(result.toString());

				}
			}
		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26084
#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 x first
#define y second

int main()
{
	int n;
	int ans = 0;
    read(n);
    int mode = 0;
    int last = -1;
    for(;n--;){
        int a; read(a);
        if(mode == 2){
            if(last >= a) last=a;
            else mode=0;
        } else if(mode == 3){
            if(last <= a) last=a;
            else mode=0;
        }
        if(mode == 0){
            ++ans;
            mode = 1;
            last = a;
        } else if(mode == 1){
            if(last == a) continue;
            mode = 2 + (last<a);
            last = a;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	ll n; cin>>n;
	ll sum = 0;
	vl cnt(1e5+10, 0);
	vl a(n); forn(i, n) cin>>a[i], sum += a[i], cnt[a[i]]++;
	ll q; cin>>q;
	forn(i, q){
		ll b, c; cin>>b>>c;
		sum += cnt[b]*(c-b);
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout<<sum<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	while(t--)
		solve();
}

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

int main() {
    int N;
    cin >> N;
    int a[N + 1];
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }

    vector<int> b(N + 1, 0);
    vector<int> ans;
    for (int i = N; i >= 1; i--)
    {
        int cnt = 0;
        for (int j = i; j <= N; j += i)
        {
            if(b[j] == 1) cnt++;
        }
        if(cnt % 2 != a[i]) {
            b[i] = 1;
            ans.push_back(i);
        }
    }

    reverse(ans.begin(), ans.end());

    cout << ans.size() << endl;
    for (auto i : ans)
    {
        cout << i << endl;
    }
}

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;

int main()
{
   int x,y;
   cin>>x>>y;
   if(x==y)
   {
       cout<<"Yes"<<endl;
   }
   else 
   {
       cout<<"No"<<endl;
   }

    return 0;
}


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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

int getans(vector<int> &v, int l, int r){
    // write(l, r);
    // cout<<endl;
    if(l>r){
        return 0;
    }
    if(l==r){
        int ret = v[l];
        v[l] = 0;
        return ret;
    }
    int ans = MOD;
    for(int i=l; i<=r; i++){
        ans = min(ans, v[i]);
    }
    set<int> os;
    for(int i=l; i<=r; i++){
        v[i]-=ans;
        if(v[i]==0)
            os.insert(i);
    }
    os.insert(r+1);
    int prev = 0;
    for(int x: os){
        ans += getans(v, prev, x-1);
        prev = x+1;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int n; cin>>n;

    vector<int> v(n);

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

    int ans = getans(v, 0, n-1);

    // printarr(v);

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main(){
    int A,B,ans;
    cin >> A >> B;
    if(A > B)ans = 2 * A - 1;
    else if(A < B)ans = 2 * B - 1;
    else ans = 2 * A;
    cout << ans << endl;
    return 0;
}

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

/**
 * https://abc056.contest.atcoder.jp/tasks/arc070_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		int[] a = new int[N];
		for(int i=0; i<N; i++) a[i] = Integer.parseInt(sc.next());
		sc.close();
		
		Arrays.sort(a);
		long c=0;
		long ans = N;
		for(int i=N-1; i>=0; i--){
			if(c+a[i]<K){
				c +=a[i];
			}else{
				ans = i;
			}
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 26948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 cin >> N;
 if (N <= 999) {
   cout << "ABC" << endl;
 }
 if ( N <= 1998 && N >= 1000) {
   cout << "ABD" << endl;
 }
   
  
}
  

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let s = scan.chars();
    let mut ret = 0;
    for i in 0..s.len()/2 {
        if s[i] != s[s.len() - i - 1] {
            ret += 1;
        }
    }
    println!("{}", ret);
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

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

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#define MAX 2000000
using namespace std;
int H,a[MAX+1];
void max(int i)
{
  int l,r,large;
  l = 2*i;
  r = 2*i+1;
  if(l<=H&&a[l]>a[i])
    large = l;
  else large = i ;
  if(r<=H&&a[r]>a[large])
     large = r;
  if(large != i)
{  swap(a[i],a[large]);
  max(large);
  }
}
int main ()
{
   cin>>H;
   for(int i = 1;i<=H;i++) cin>>a[i];
   for(int i = H/2;i>=1;i--)
      max(i);
   for(int i = 1;i<=H;i++)
     cout<<" "<<a[i];
  cout<<endl;
  return 0 ;
  }


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

typedef long long ll;

typedef pair <ll, ll> pii;
typedef pair <pii, ll> ppi;
#define xp first.first
#define yp first.second
#define zp second

const ll MAX_N = 1e5 + 5;
ll X, Y, Z, ans;
ppi Arr[MAX_N];
ll prefix[MAX_N];
ll suffix[MAX_N];
multiset <ll> Set;

bool cmp (ppi a, ppi b) {
	return a.xp - a.yp > b.xp - b.yp;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> X >> Y >> Z;
	for (ll i = 0; i < X + Y + Z; i++)
		cin >> Arr[i].xp >> Arr[i].yp >> Arr[i].zp;

	sort(Arr, Arr + X + Y + Z, cmp);

	ll sum = 0;
	for (ll i = 0; i < X + Y + Z; i++) {
		Set.insert(Arr[i].xp - Arr[i].zp);
		sum += Arr[i].xp;

		while (Set.size() > X) {
			sum -= *Set.begin();
			Set.erase(Set.begin());
		}

		prefix[i] = sum;
	}

	Set.clear();
	sum = 0;
	for (ll i = X + Y + Z - 1; ~i; i--) {
		Set.insert(Arr[i].yp - Arr[i].zp);
		sum += Arr[i].yp;

		while (Set.size() > Y) {
			sum -= *Set.begin();
			Set.erase(Set.begin());
		}

		suffix[i] = sum;
	}

	for (ll i = X - 1; i < X + Z; i++)
		ans = max(ans, prefix[i] + suffix[i + 1]);

	cout << ans << "\n";
	return 0;
}

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

int main() {
    long long N;
    long long Ans=10000000000000000;
    cin >> N;
    for(long long i=1;i<=sqrt(N);i++){
        if(!(N%i)){
            long long x = N/i-1;
            long long y = i-1;
            if(Ans>(x+y)){
                Ans = x + y;
            }
        }
    }
    cout << Ans << endl;
}

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

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

vector<int> A;
vector<ll> S;

int main(){
    int N;
    ll ans=0, sum=0;

    cin >> N;
    A.resize(N);
    S.resize(N+1);
    S[0]=0;

    rep(i,N){
        cin >> A[i];
        S[i+1] = S[i] + A[i];
    }

    sort(S.begin(), S.end());

    sum=1;
    for(int i=1; i<=N; i++){
        if(S[i-1]==S[i]){
            sum++;
        }else{
            ans += sum*(sum-1)/2;
            sum=1;
        }
    }
    ans += sum*(sum-1)/2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read.ToCharArray();
            var T = cin.Read.ToCharArray();
            var count = 0;
            for (int i = 0; i < 3; i++)
            {
                if (S[i] == T[i])
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll a[n];
	ll tr=0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			tr++;
		}
	}
	if(tr)
	{
		cout<<"0";
		exit(0);
	}
	ll tot=1e18;
	ll mu=1;
	for(ll i=0;i<n;i++)
	{
		//cout<<mu<<" "<<((tot+a[i]-1)/a[i])<<"\n";
		if(mu<=((tot)/a[i]))
		{
			mu*=a[i];
		}
		else
		{
			mu=-1;
			break;
		}
	}
	
	cout<<mu;
	
}

Measured memory_bytes: 4308
K,N = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
ld = [0]*N
for i in range(1,N):
    ld[i] = li[i] - li[i-1]
ld[0] = li[0] + K - li[-1]
print(K - max(ld))


Measured memory_bytes: 77388
#include<iostream>
#include<vector>
#include<string>
#include<map>

using namespace std;

map<char,char> a;
int main(){
    a['A']  = 'T';
    a['C'] = 'G';
    a['T'] = 'A';
    a['G'] = 'C';
    char s;
    cin >> s;
    cout << a[s];
}

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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;

bool rec(ll x, ll y, bool b) {
    for (int i = 1; 2 * i <= x; i++) {
        bool d = rec(x - (2 * i), y + i, !b);
        if (b == d) return b;
    }
    for (int i = 1; 2 * i <= y; i++) {
        bool d = rec(x + 1, y - (2 * i), !b);
        if (b == d) return b;
    }
    return !b;
}

int main() {
    ll x, y;
    cin >> x >> y;

    if (abs(x - y) <= 1) {
        cout << "Brown" << endl;
    } else {
        cout << "Alice" << endl;
    }

//    for (ll x = 1; x <= 10; x++) {
//        for (ll y = 1; y <= 10; y++) {
//            cout << x << ' ' << y << ' ';
//
//            bool b = rec(x, y, true);
//            if (b) {
//                cout << "Alice" << endl;
//            } else {
//                cout << "Brown" << endl;
//            }
//        }
//    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int mod_pow(int x,int y) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%mod;
        }
        x = x*x%mod;
        y/=2;
    }
    return res;
}
int fac[200005], finv[200005], inv[200005];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 200005; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
signed main() {
    int N,M,K;
    cin >> N >> M >> K;
    COMinit();
    int ans = 0;
    for(int i = 1; i < N; i++) {
        ans += i*M%mod*M%mod*(N-i)%mod*COM(N*M-2,K-2)%mod;
        ans %= mod;
    }
    for(int i = 1; i < M; i++) {
        ans += i*N%mod*N%mod*(M-i)%mod*COM(M*N-2,K-2)%mod;
        ans %= mod;
    }
    cout << ans << endl;
}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    string s, t;
    cin >> s >> t;
    ll ans = INT_MAX;
    for (ll i = 0; i <= s.size() - t.size(); i++) {
        ll temp = 0;
        for (ll j = 0; j < t.size(); j++) {
            temp += (s[i + j] != t[j]);
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

int main() {
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

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


int main() {
	int p;
	cin>>p;
	int x=p;
	int an=0;
	while(x!=0)
	{
		an+=x%10;
		x/=10;
	}
	if(p % an==0)
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll l[3005], r[3005];
ll N, M;
string S;
ll inv[1000000];
ll FactorialInv[1000000];
ll Factorial[1000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    Factorial[0] = 1;
    FactorialInv[0] = 1;
    inv[0] = 1;
    for(int i = 2; i < 1000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll dp[3005][3005];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination();
    cin >> N >> M >> S;
    S = "#" + S;
    for(int i = 1; i <= M; i++) {
        cin >> l[i] >> r[i];
        if(r[i] <= r[i-1]) {
            i--;
            M--;
        }
    }
    l[M+1] = N+1;
    /*
    for(int i = 1; i <= M; i++) {
        cerr << l[i] << " " << r[i] << endl;
    }
    */
    ll mini = 0;
    ll maxi = 0;
    dp[0][0] = 1;
    for(int i = 1; i <= M; i++) {
        ll newmini = 1e9;
        ll newmaxi = 0;
        ll num = 0;
        ll interval = min(l[i+1]-1, r[i]) - l[i] + 1;
        for(int j = max(l[i], r[i-1] + 1); j <= r[i]; j++) {
            if(S[j] == '1') num++;
        }
        mini += num;
        maxi += num;
        for(ll before = mini; before <= maxi; before++) {
            ll nowmaxi = min(before, r[i] - l[i+1] + 1);
            chmax(nowmaxi, 0LL);
            ll nowmini = before - (l[i+1] - l[i]);
            chmax(nowmini, 0LL);
            chmax(newmaxi, nowmaxi);
            chmin(newmini, nowmini);
            for(ll after = nowmini; after <= nowmaxi; after++) {
                ll now = before - after;
                //cerr << i << " " << before << " " << after << " " << mini << " " << maxi << " " << nowmini << " " << nowmaxi << endl;
                dp[i][after] += dp[i-1][before-num] * combination(interval, now);
                dp[i][after] %= mod;
            }
        }
        maxi = newmaxi;
        mini = newmini;
        /*
        for(int j = mini; j <= maxi; j++) {
            cerr << i << " " << j << " " << dp[i][j] << endl;
        }
        */
    }
    cout << dp[M][0] << endl;
    return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_N = 100000;
int n;
pii a[MAX_N];

int main()
{
  fastio();

  cin >> n;
  forn(i,n) {
    cin >> a[i].fst;
    a[i].snd = i+1;
  }

  sort(a,a+n);

  forn(i,n)
    cout << a[i].snd << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
#define CoutV(vec)        \
    for (auto v : vec)    \
    {                     \
        cout << v << " "; \
    }                     \
    cout << endl;
#define CoutVV(vecvec)      \
    for (auto vec : vecvec) \
        CoutV(vec);

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

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int a, b, c;
    cin >> a >> b >> c;

    bool isPoor = false;

    if (a == b && b != c)
        isPoor = true;
    else if (b == c && c != a)
        isPoor = true;
    else if (a == c && c != b)
        isPoor = true;

    cout << (isPoor ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  char c1,c2,c3,c4;
  scanf("%c %c %c %c",&c1,&c2,&c3,&c4);
  if(c1==c2){
    if(c1!=c3&&c3==c4)
      printf("Yes\n");
    else
      printf("No\n");
  }
  else if(c1==c3){
    if(c1!=c2&&c2==c4)
      printf("Yes\n");
    else
      printf("No\n");
  }
    else if(c1==c4){
    if(c1!=c2&&c2==c3)
      printf("Yes\n");
    else
      printf("No\n");
  }
  else
    printf("No\n");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int main(){
	int N,P;
	cin>>N>>P;
	int a=0,b=0;
	rep(i,N){
		int x;
		cin>>x;
		if(x%2==0) a++;
		else b++;
	}
	ll ans = (1LL<<N);
	if(b!=0) ans/=2;
	else if(P==1) ans = 0;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll N,K;
  cin >> N >> K;
  ll ans = 1;
  if(K==1)
  {
    cout << N*N*N << endl;
  }
  else if(K==2)
  {
    if(N%2==0)
    {
      cout << ((N/2)*(N/2)*(N/2)) * 2 << endl;
    }
    else
    {
      cout << ((N/2)*(N/2)*(N/2)) + (((N+1)/2)*((N+1)/2)*((N+1)/2)) << endl;
    }
  }
  else if(K%2!=0)
  {
    cout << (N/K) * (N/K) * (N/K) << endl;
  }
  else
  {
    if(N/(K/2)%2==0)
    {
      cout << (N/K) * (N/K) * (N/K) * 2 << endl;
    }
    else
    {
      cout << (N/K) * (N/K) * (N/K) + ((N/K)+1) * ((N/K)+1) * ((N/K)+1) << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
	int sum,a,b,count;
	scanf("%d%d",&a,&b);
	count=sum=0;
	if(b==1)
		count=0;	
	else
	{
	
	while(1)
	{
		if(count==0)
			sum=sum+a;
		count++;
		if(sum>=b)
			break;
		sum=sum+(a-1);
	}
	}
	printf("%d",count);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int b = 0;
		int[] c = new int[n+1];

		for(int i=1;i<=n;i++) 	a[i] = sc.nextInt();
		for(int i=1; i<=n; i++) 	b+= sc.nextInt();
		for(int i=1; i<=n-1; i++) c[i] = sc.nextInt();

		for(int i=1; i<n; i++) {
			if(a[i+1]-a[i] ==1) {
				b+=c[a[i]];
			}
		}

		System.out.println(b);
	}
}


Measured memory_bytes: 21844
c = int(input())
p1 = 0
p2 = 0
for i in range(c):
    s1,s2 = map(str,input().split())
    if s1 > s2:
        p1 = p1 + 3
    elif s1 < s2:
        p2 = p2 + 3
    else:
        p1 = p1 + 1
        p2 = p2 + 1
print("{0} {1}".format(p1,p2))


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

using namespace std;

int main(){
    
    int s, m, h;
    
    cin >> s;
    
    h = s/3600;
    m = s%3600/60;
    s = s%60;
    
    cout << h << ":" << m << ":" << s << endl;
    
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using vd = vector<double>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

struct Node;
using NodeP = shared_ptr<Node>;
struct Node {
  int key;
  NodeP right, left, parent;
};

NodeP root, NIL;

void insert(int k) {
  auto y = NIL;
  auto x = root;
  auto z = make_shared<Node>();
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    x = (z->key < x->key) ? x->left : x->right;
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

NodeP find(NodeP u, int k) {
  while (u != NIL && k != u->key) {
    u = (k < u->key) ? u->left : u->right;
  }
  return u;
}

void inorder(NodeP &u) {
  if (u == NIL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(NodeP &u) {
  if (u == NIL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;
  cin >> n;
  REP(i, n) {
    cin >> com;
    if (com == "insert") {
      cin >> x;
      insert(x);
    } else if (com == "find") {
      cin >> x;
      cout << ((find(root, x) != NIL) ? "yes" : "no") << endl;
    } else if (com == "print") {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
}


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

using namespace std;

int main()
{
    int N;

    cin >> N;

    string s;

    s = to_string(N);

    string ans;
    ans = "No";

    if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))
    {
        ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial,sqrt
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    s=SI()
    n=len(s)
    ans=inf
    c=Counter(list(s))
    #print(c)
    for strs in c.keys():
        mx=0
        key=0
        for i in range(n):
            if s[i]==strs:
                mx=max(mx,key)
                key=0
            else:
                key+=1
        mx=max(mx,key)
        #print(mx)
        ans=min(ans,mx)
    print(ans)
        
            
                
                
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 67768
macro_rules! input {
    ($t:ty) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty ;) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ; $n:expr) => {
        (0..$n).map(|_|
            input!($t)
        ).collect::<Vec<_>>()
    };
}

fn main(){
    let (a,b,c) = input!(usize,usize,usize);
    let mut x = vec![a,b,c];
    let mut ans = "No";
    x.sort();
    if x[0]+x[1]==x[2]{
        ans = "Yes";
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b;
    cin>>a>>b;
    ll s=a*b;
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3584
import math
import queue

def readInt():
	return int(input())

def readInts():
	return list(map(int, input().split()))

def readChars():
	return input().split()


x = readInts()
n = x[0]
m = x[1]
a = readInts()

x = sum(a)

if x<=n:
	print(n-x)
else:
	print(-1)

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

int N, Q;
vector<vector<int>> t;
vector<int> ans;
vector<bool> flag;

void f(int s, int p) {
  flag[p] = true;

  ans[s] += ans[p];
  for (int i = 1; i < t[s].size(); ++i)
    if (!flag[t[s][i]])
      f(t[s][i], s);
}

int main() {
  cin >> N >> Q;
  vector<int> a(N - 1), b(N - 1), p(Q), x(Q);
  for (int i = 0; i < N - 1; ++i)
    cin >> a[i] >> b[i];
  for (int i = 0; i < Q; ++i)
    cin >> p[i] >> x[i];

  t.resize(N + 1, vector<int>(1));
  t[0].push_back(1);
  for (int i = 0; i < N - 1; ++i)
    t[a[i]].push_back(b[i]), t[b[i]].push_back(a[i]);

  ans.resize(N + 1);
  for (int i = 0; i < Q; ++i)
    ans[p[i]] += x[i];

  flag.resize(N + 1);
  f(1, 0);

  for (int i = 1; i <= N; ++i)
    if (i == N)
      cout << ans[i] << endl;
    else
      cout << ans[i] << ' ';
}

Measured memory_bytes: 26624
#include<iostream>
using namespace std;
int main(){
	int n;
	int a[200000];
	int b[200000];

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

	if(n % 2 == 0){
		for(int i = 0; i < n / 2; i++){
			b[i] = a[n - 1 - 2 * i];
		}
		for(int i = 0; i < n / 2; i++){
			b[i + n / 2] = a[2 * i];
		}
	}else if(n % 2 == 1){
		for(int i = 0; i < n / 2 + 1; i++){
			b[i] = a[n - 1 - 2 * i];
		}
		for(int i = n / 2 + 1; i < n; i++){
			b[i] = a[(i - n / 2 - 1) * 2 + 1];
		}
	}

	for(int i = 0; i < n; i++){
		cout << b[i];
		if(i == n - 1) cout << endl;
		else cout << " ";
	}

	return 0;
}


Measured memory_bytes: 3712
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    
    val x1 = sc.nextInt()
    val y1 = sc.nextInt()
    val x2 = sc.nextInt()
    val y2 = sc.nextInt()

    val a = x2 - x1
    val b = y2 - y1

    val x3 = x2 - b
    val y3 = y2 + a
    val x4 = x3 - a
    val y4 = y3 - b

    println(arrayOf(x3, y3, x4, y4).joinToString(" "))
}


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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int INF = 1000*1000*1000;
const int N = 1000;
int dp[N+1][N+1];

int main() {
  int i, j;
  string s, t;
  cin >> s;
  cin >> t;
  for (i=0; i<=(int)s.size(); i++)
    for (j=0; j<=(int)t.size(); j++)
      dp[i][j] = INF;
  for (i=0; i<=(int)s.size(); i++) dp[i][0] = i;
  for (j=0; j<=(int)t.size(); j++) dp[0][j] = j;
  
  for (i=1; i<=(int)s.size(); i++)
    for (j=1; j<=(int)t.size(); j++) {
      int x = (s[i-1]==t[j-1]) ? 0 : 1;
      dp[i][j] = min(dp[i-1][j-1]+x, min(dp[i-1][j]+1, dp[i][j-1]+1));
    }
  printf("%d\n", dp[s.size()][t.size()]);
  return 0;
}

Measured memory_bytes: 5096
<>;$P=8*atan2 1,1;for$s(@a=<>){($x,$y,$~)=glob$s;printf"%f\n",sort{$b<=>$a}0,map+(($_-$~)/$P-.5,$~=$_)[0],(@b=sort{$a<=>$b}map{/ /;atan2$'-$y,$`-$x}grep$_ ne$s,@a),"@b"+$P;}

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long

signed main() {
	int n;
	cin >> n;
	set<int> st;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if(st.count(a)){
			st.erase(a);
		}
		else {
			st.insert(a);
		}
	}

	cout << st.size() << endl;
	return 0;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#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 <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 = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 5003;

i64 n;

string s;

unordered_map<i64, i64> q;

i64 th[MAXN];


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    /*
    srand(time(0));
    cout << MAXN << endl;
    stringstream ss;
    for (i64 i = 0; i < MAXN; i++) {
        ss << char('a' + rand() % 26);
    }
    cout << ss.str() << endl;;
    */

    cin >> n >> s;
    q.rehash(n * n);

    i64 R = 0;

    for (i64 i = 0; i < n; i++) {
        th[i] = 5381;
    }

    for (i64 j = 0; j <= s.size() / 2 + 1; j++) {
        i64 TR = R;
        for (i64 i = s.size() -j - 1; i >= 0; i--) {
            auto& h = th[i];
            h = ((h << 5) + h) + s[i + j];

            auto it = q.find(h);
            if (it == q.end()) {
                q.insert({ h, i });
            }
            else {
                if (i + j < it->second) {
                    R = max(R, j + 1);
                }
            }
        }
        if (R == TR) {
            break;
        }
    }

    cout << R << endl;

    return 0;
}


Measured memory_bytes: 403584
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	ll x_o = 0, x_t = 0, y_o = 0, y_t = 0;
	ll vecx = 0, vecy = 0;
	ll nagasa = 0;
	std::cin >> x_o >> y_o >> x_t >> y_t;
	vecx = std::abs(x_t - x_o);
	vecy = std::abs(y_t - y_o);
	if (x_t >= x_o && y_t < y_o) {
		std::cout << x_t + vecy << " " << y_t + vecx << " " << x_o + vecy << " " << y_o + vecx << std::endl;
		return 0;
	}
	else if (x_t >= x_o && y_t > y_o) {
		std::cout << x_t - vecy << " " << y_t + vecx << " " << x_o - vecy << " " << y_o + vecx << std::endl;
		return 0;
	}
	else if (x_t < x_o && y_t >= y_o) {
		std::cout << x_t - vecy << " " << y_t - vecx << " " << x_o - vecy << " " << y_o - vecx << std::endl;
		return 0;
	}
	else {
		std::cout << x_t + vecy << " " << y_t - vecx << " " << x_o + vecy << " " << y_o - vecx << std::endl;
		return 0;
	}
}

Measured memory_bytes: 256