akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <stack>
#include <cstdio>
#include <deque>
#include <map>
#include <set>
using namespace std;

int main()
{
    set <int> res;
    int n,k,a,m;
    cin>>n;
    int b = 0;
    for (int i = 0; i<n; i++)
    {
        cin>>k;
        if (k>=3200)
        {
            b++;
        }
        else
        {
            res.insert(k/400+1);
        }

    }
    int l = res.size();
    m = l+b;
    if (l==0){
        l = 1;
    }
    cout<<l<<" "<<m<<endl;
}


Measured memory_bytes: 256
n, k = gets.chomp.split.map(&:to_i)
arr = Array.new(n)
n.times do |i|
	arr[i] = gets.chomp.to_i
end
arr = arr.sort

max = 1145141919
0.upto(n - k) do |i|
	sa = arr[i + k - 1] - arr[i]
	max = sa if max > sa
end
puts max

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

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	std::vector<bool> like(m, true);
	for (int i{}; i < n; i++)
	{
		int k;
		scanf("%d", &k);
		std::vector<bool> i_like(m);
		for (int j{}; j < k; j++)
		{
			int a;
			scanf("%d", &a);
			a--;
			i_like[a] = true;
		}
		for (int j{}; j < m; j++)
			if (!i_like[j])
				like[j] = false;
	}
	int count{};
	for (int i{}; i < m; i++)
		if (like[i])
			count++;
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 256
l = int(input())
a = []
for i in range(l):
  a.append(int(input()))
  
dp=[[0]*5 for i in range(l+1)]

for i in range(0,l):
  if a[i]==0:
    even=2
  else:
    even=a[i]%2
  
  dp[i+1][0]=dp[i][0]+a[i]
  dp[i+1][1]=min(dp[i][0],dp[i][1]) + even
  dp[i+1][2]=min(dp[i][0],dp[i][1],dp[i][2]) + (a[i]+1)%2
  dp[i+1][3]=min(dp[i][0],dp[i][1],dp[i][2],dp[i][3]) + even
  dp[i+1][4]=min(dp[i][0],dp[i][1],dp[i][2],dp[i][3],dp[i][4]) + a[i]
  
print(min(dp[l]))
  

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

int main(void){
  int N, D, count = 0, distance;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      cin >> X.at(i).at(j);
    }
  }
  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      distance = 0;
      for(int k = 0; k < D; k++){
        distance += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
      }
      for(int l = 1; l <= distance; l++){
        if(distance  == l * l){
          count++;
          break;
        }
      }
    }
  }
  cout << count << endl;
}


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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define _setl(x) __builtin_popcountll(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007LL

void debug(){
	cerr<<"]\n";
}
template<class H,class ... T> void debug(H h,T... t){
	cerr<<h;
	if(sizeof... (t)){
		cerr<<", ";
	}
	debug(t...);
}
#ifdef DEBUG
	#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", debug(__VA_ARGS__)
	#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"
#else
	#define dbg(...) 0
	#define dpv(...) 0
#endif


void solve(){
	string s,t;
	cin>>s>>t;
	int best = sz(t);
	for(int i=0;i<s.size();i++){
		int cnt =0;
		int l = 0;
		for(int j=i;j-i<t.size() && j<s.size();j++){
			if(s[j] != t[j-i]){
				cnt++;
			}
			l++;
		}
		if((l)== sz(t))
			best = min(best, cnt);
	}
	cout<<best<<"\n";
}


int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	for(int i=1;i<=_;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

/*
   check for overflows int long long
   correct mize of array
*/


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;

int s[3];
int l[9];
int N;
vector<int> v;
int dfs(int k,vector<int> a,vector<int> b,vector<int> c){
    int ret=INF;
    if(k==N){
        sort(ALL(v));
        if((!a.size())||(!b.size())||(!c.size())) return ret;
        do{
            int tmp=0;
            tmp+=abs(s[v[0]]-accumulate(ALL(a),0));
            tmp+=abs(s[v[1]]-accumulate(ALL(b),0));
            tmp+=abs(s[v[2]]-accumulate(ALL(c),0));
            tmp+=10*(a.size()-1)+10*(b.size()-1)+10*(c.size()-1);
            ret=min(ret,tmp);
        }while(next_permutation(ALL(v)));
        return ret;
    }
    a.pb(l[k]);
    ret=min(ret,dfs(k+1,a,b,c));
    a.pop_back();
    b.pb(l[k]);
    ret=min(ret,dfs(k+1,a,b,c));
    b.pop_back();
    c.pb(l[k]);
    ret=min(ret,dfs(k+1,a,b,c));
    c.pop_back();
    ret=min(ret,dfs(k+1,a,b,c));
    return ret;
}

int main(){
    cin >> N;
    for (int i = 0; i < 3; i++) {
        cin >> s[i];
    }
    v.pb(0);
    v.pb(1);
    v.pb(2);
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }
    vector<int> a,b,c;
    cout << dfs(0,a,b,c) << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
  }
  int m;
  cin >> m;
  vector<string> t(m);
  rep(i, m) {
    cin >> t[i];
  }

  int ans = 0;
  rep(i, n) {
    int res = 0;
    rep(j, n) {
      if (s[i] == s[j]) {
        ++res;
      }
    }
    rep(j, m) {
      if (s[i] == t[j]) {
        --res;
      }
    }
    ans = max(ans, res);
  }
  cout << max(0, ans) << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int main()
{   
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0;
    rep(i, n) if(s[i]=='R') r++;

    int ans = r, w = 0;
    rep(i, n) {
        if(s[i]=='R') --r;
        else ++w;
        ans = min(ans, max(r, w));
    }

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


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    int s=0;
    REP(i,N) {
        cin >> A[i];
        s += A[i];
    }
    vector<bitset<2000001>> v(N+1);
    v[0].set(0);
    REP(i,N) {
        v[i+1] = (v[i]<<A[i]);
        v[i+1] |= v[i];
    }
    int ans = 0;
    REP(i,s/2+1) {
        if(v[N][i]) ans = s - i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 489344
#include<stdio.h>
int main(){
	int h, w, i, j;
	while(1){
		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0){
			break;
		}
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
} 


Measured memory_bytes: 2044
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

int main(){
    int A, B, C;
    cin >> A >> B >> C;
if(A <= C&& C <= B)cout << "Yes" << endl;
else if(B <=C && C <= A )cout << "Yes" << endl;
else cout << "No" << endl;
  
}



Measured memory_bytes: 256
while line = STDIN.gets
	if(/exit/ =~ line)
		break
	end
	temp = line.scan(/\d+|-\d+/)
	a = temp[0].to_f
	b = temp[1].to_f
	c = temp[2].to_f
	d = temp[3].to_f
	e = temp[4].to_f
	f = temp[5].to_f
	x = (c*e-b*f)/(a*e-b*d)
	y = (c*d-f*a)/(b*d-e*a)
	if x == -0 then
		x = 0
	end
	if y == 0 then
		y = 0
	end
	print sprintf("%.3f %.3f\n",x,y)
end

Measured memory_bytes: 6144
import sys
from collections import defaultdict

# sys.stdin = open('e1.in')


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


def read_int():
    return int(input())


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


def read_str():
    return input()


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def solve():
    def collinear(x0, y0, x1, y1):
        return x0 * y1 == x1 * y0

    def aligned(i, j, k):
        return collinear(x[j] - x[i], y[j] - y[i], x[k] - x[i], y[k] - y[i])

    n = read_int()
    mod = 998244353
    res = pow(2, n, mod) - n - 1
    x, y = zip(*[read_int_list() for i in range(n)])
    lines = defaultdict(set)
    for i in range(n):
        for j in range(i + 1, n):
            a = y[i] - y[j]
            b = x[j] - x[i]
            g = gcd(a, b)
            a //= g
            b //= g
            if a < 0 or (a == 0 and b < 0):
                a, b = -a, -b
            c = -(a * x[i] + b * y[i])
            lines[(a, b, c)].add(i)
            lines[(a, b, c)].add(j)
    for k, v in lines.items():
        m = len(v)
        res -= pow(2, m, mod) - m - 1
    res %= mod
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11876
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return is_prime

n=int(input())
is_prime=primes(10**6)
for i in range(n,10**6):
    if is_prime[i]:
        print(i)
        exit()

Measured memory_bytes: 46320
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()

int main(){
    string S;
    cin >> S;
    int y = 10 * (S[0] - '0') + (S[1] - '0');
    int m = 10 * (S[2] - '0') + (S[3] - '0');
    string ans;
    if(1 <= y && y <= 12){
        if(1 <= m && m <= 12){
            ans = "AMBIGUOUS";
        }else{
            ans = "MMYY";
        }
    }else{
        if(1 <= m && m <= 12){
            ans = "YYMM";
        }else{
            ans = "NA";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
NX = input().split(" ")
N = int(NX[0])
X = int(NX[1])

M = []

for n in range(N):
    M.append(int(input()))

s = 0
for m in M:
    s += m

X = X - s

min_M = min(M)

a = X % min_M
k = (X - a) / min_M

print(int(N+k))

Measured memory_bytes: 3064
import sys

# 再起回数上限変更
sys.setrecursionlimit(1000000)

N, M = map(int, input().split())


class Graph(object):
    def __init__(self, n: int):
        self.adjacency_dict = {}
        self.n = n
        for i in range(n):
            self.add_vertex(i)

    def add_vertex(self, v: int):
        """ ノードを追加する """
        self.adjacency_dict[v] = []

    def add_edge(self, v1: int, v2: int, undirected=False):
        self.adjacency_dict[v1].append(v2)
        if undirected:
            self.adjacency_dict[v2].append(v1)


def find_longest(v):
    """ vからの有向最長パスをの長さをdp[v]とする """
    global dp
    if dp[v] > 0:
        return dp[v]

    res = 0
    for nv in g.adjacency_dict[v]:
        res = max(res, find_longest(nv) + 1)

    dp[v] = res
    return res


g = Graph(N)
for i in range(M):
    x, y = map(int, input().split())
    g.add_edge(x - 1, y - 1)
# print(g.adjacency_dict)

dp = [-1] * N
# gにおいて出次数が0のところのdpを0とする
for v in range(N):
    if len(g.adjacency_dict[v]) == 0:
        dp[v] = 0
# print(dp)

for v in range(N):
    find_longest(v)

print(max(dp))


Measured memory_bytes: 67556
#include <iostream>

int main(){
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  if((a+b)>(c+d)){
    std::cout << "Left" << std::endl;
  }else if(a+b==c+d){
    std::cout << "Balanced" << std::endl;
  }else{
    std::cout << "Right" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using B = std::bitset<55>;

int main() {
    int n, m;
    std::cin >> n;
    std::vector<i64> p2(55);
    p2[0] = 1;
    for (int i = 1; i <= 50; i++) p2[i] = p2[i - 1] * 2;
    std::vector<std::vector<int>> g(n), edges(n, std::vector<int>(n, -1));
    for (int i = 1; i < n; i++) {
        int a, b;
        std::cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
        edges[a][b] = edges[b][a] = i;
    }
    std::cin >> m;

    std::vector<B> path;
    for (int i = 0; i < m; i++) {
        int u, v;
        std::cin >> u >> v;
        --u; --v;
        std::vector<int> prev(n, -1);
        std::deque<int> q { u };
        while (!q.empty()) {
            int v = q.front();
            q.pop_front();
            for (int to : g[v]) {
                if (to == u || prev[to] >= 0) continue;
                prev[to] = v;
                q.push_back(to);
            }
        }

        B b;
        int curr = v;
        while (true) {
            int p = prev[curr];
            if (p == -1) break;
            b[edges[p][curr]] = 1;
            curr = p;
        }

        path.push_back(std::move(b));
    }

    i64 ret = 0;
    for (int i = 0; i < (1 << m); i++) {
        int pc = __builtin_popcount(i);
        B b;
        for (int j = 0; j < m; j++) if (i & (1 << j)) b |= path[j];
        int cc = n - 1 - b.count();
        i64 d = p2[cc];
        if (pc % 2) ret -= d;
        else ret += d;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define INF (1e9)
#define N c[n-1]*2-1
using namespace std;
int main(){
  int n,c[50],k=0;
  while(cin>>n&&n){
    k++;
    for(int i=0;i<n;i++)cin>>c[i];
    cout<<"Case #"<<k<<": ";
    if(c[0]==1){
      int dp[2001]={};
      for(int i=1;i<=N;i++)dp[i]=INF;
      for(int i=0;i<n;i++)
	for(int j=c[i];j<=N;j++)
	  dp[j]=min(dp[j],dp[j-c[i]]+1);
      int f=0;
      for(int i=1;i<=N;i++){
	int a=0,s=i;
	for(int j=n-1;s!=0;j--){
	  a+=s/c[j];
	  s%=c[j];
	}
	if(a!=dp[i]){f=1;break;}
      }
      if(f)cout<<"Cannot use greedy algorithm"<<endl;
      else cout<<"OK"<<endl;
    }
    
    else cout<<"Cannot pay some amount"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1172
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	fsc := NewFastScanner()
	a, b := fsc.Next(), fsc.Next()
	if a == "H" {
		fmt.Println(b)
	}
	if a == "D" {
		if b == "H" {
			fmt.Println("D")
		} else {
			fmt.Println("H")
		}
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[][][] rooms = new int[4][3][10];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    rooms[i][j][k] = 0;
                }
            }
        }

        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();

            rooms[b-1][f-1][r-1] += v;
        }

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    System.out.print(" "+rooms[i][j][k]);
                }
                System.out.println("");
            }
            if(i < 3){
                System.out.println("####################");
            }
        }



        sc.close();
    }
}


Measured memory_bytes: 29460
function Main(input){
  var list = input.split("\n")[1].split(" ");
  var min = Infinity;
  for(var i of list){
    var cnt = 0;
    while(true){
      if(i%2==0){
        i/=2;
        cnt++;
      }else{
        break;
      }
    }
    min = Math.min(min, cnt);
  }
  console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
  int ans = 0;
  
  if (a + b <= c * 2) {
    ans = a * x + b * y;
  } else if (x == y) {
    ans = c * x * 2;
  } else if (x < y) {
    if (b >= c * 2) ans = c * x * 2 + (y - x) * c * 2;
    else ans = c * x * 2 + (y - x) * b;
  } else if (x > y) {
    if (a >= c * 2) ans = c * x * 2 + (y - x) * c * 2;
    else ans = c * y * 2 + (x - y) * a;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n, m;
    int sum = 0;
    cin >> n >> m;
    forn(i, m)
    {
        int x;
        cin >> x;
        sum += x;
    }
    if(sum > n)
    {
        cout << -1 << endl;
    }
    else cout << n-sum << endl;
}


Measured memory_bytes: 3656
/*
https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d
*/


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> num;
    //vector<int> used(1000,0);
    rep(i,n){
        int j = int(s[i]-'0');
        num.push_back(j);
    }
    //for(auto numm:num) cout << numm << " ";
    //cout << endl;
    int res = 0;
    rep(i,1000){
        int temp=0;
        vector<int> key;
        int dum = i;
        rep(j,3){
            key.push_back(int(dum%10));
            dum/=10;
        }

        reverse(key.begin(),key.end());
        
        rep(j,n){
            if(num[j]==key[temp]) temp++;
            if(temp==3){
                //if(used[i]==1)
                //cout << "i: " << i << endl << "key ";
                //for(auto k:key) cout << k << " ";
                //cout << endl;
                res++;
                break;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int a,b;cin>>a>>b;
  if(a==b)cout<<"Draw"<<endl;
  else if(a==1)cout<<"Alice"<<endl;
  else if(b==1)cout<<"Bob"<<endl;
  else if(a>b)cout<<"Alice"<<endl;
  else if(a<b)cout<<"Bob"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
string s;
int main(){
    cin>>s;
    for(ll i=1;i<s.length();i++){
        if(s[i]==s[i-1]){
            cout<<i<<" "<<i+1<<endl;
            return 0;
        }
        if(i>1 && s[i]==s[i-2]){
            cout<<i-1<<" "<<i+1<<endl;
            return 0;
        }
    }
    cout<<"-1 -1";
    return 0;
}

Measured memory_bytes: 512
class Point
  attr_reader :x, :y

  def initialize(x, y)
    @x=x
    @y=y
  end
end

# 1次関数(2点標準形)
def linear(p1, p2)
  lambda { |p| (p2.y-p1.y)*(p.x-p1.x)-(p2.x-p1.x)*(p.y-p1.y) }
end

# 包含判定
def inner?(p, poly)

  temp=poly+[poly[0]]

  a=linear(temp[0], temp[1]).call(p)
  1.upto(temp.size-2) do |i|
    b=a
    a=linear(temp[i], temp[i+1]).call(p)
    if ((a<0&&b<0)|| (a>0&&b>0))
      next
    else
      return false
    end
  end
  true
end

gets.to_i.times do

  ps = gets.split.map(&:to_i)

  p1=Point.new(ps[0], ps[1])
  p2=Point.new(ps[2], ps[3])
  p3=Point.new(ps[4], ps[5])
  poly=[p1, p2, p3]

  pa=Point.new(ps[6], ps[7]) # altair
  pv=Point.new(ps[8], ps[9]) # vega

  if inner?(pv, poly)
    unless inner?(pa, poly)
      puts :OK
      next
    end
  else
    if inner?(pa, poly)
      puts :OK
      next
    end
  end

  puts :NG

end

Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

int main() {
	int a, b; cin >> a >> b;
	cout << max({ a + b, 2 * a - 1, 2 * b - 1 }) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

#define mod 1000000007;

using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pr;

int price[3];

int main()
{
	for (int i = 0; i < 3; i++)
		cin >> price[i];
	sort(price, price + 3);
	cout << price[0] + price[1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string s;
  cin >> n >>s;
  int r,b;
  r =0;
  b =0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='R'){
      r++;
    }
    else {
      b++;
    }
  }
  cout << (r>b ? "Yes":"No");
}
    

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	while (h != 0) {
		int i, j;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if ((i+j)%2==0)
					cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
	return(0);
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;

    vector<ll> check(n, 0);
    rep(i, n) {
        if (a[i] == b[i] && b[i] == c[i])
            check[i] = 0;
        else if (a[i] == b[i] || b[i] == c[i] || a[i] == c[i])
            check[i] = 1;
        else
            check[i] = 2;
    }

    ll ans = 0;
    rep(i, n) {
        ans += check[i];
        // cout << check[i] << " ";
    }
    cout << endl;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;
int n;
vector<int> a;
map<int, bool> m;

int main(void) {
    cin >> n;
    rep(i, 0, n) {
        int t;
        cin >> t;
        a.pb(t);
    }
    sort(all(a));

    rep(i, 0, n) {
        if (i<n-1 && a[i]==a[i+1]) {
            m[a[i]] = true;
            continue;
        }
        int t = a[i];
        bool ok = true;
        for (int j=1; j*j<=t; j++) {
            if (t%j==0) {
                int x = j, y = t/j;
                if (m[x] || m[y]) ok = false;
            }
        }
        if (ok) ans++;
        m[t] = true;
    }

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



Measured memory_bytes: 32972
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val as = new Array[Int](n)
    for (i <- 0 until n) {
      as(i) = sc.nextInt()
    }

    val sum = as.sum
    val average = math.round(sum.toDouble / as.length.toDouble)

    var ans = 0L
    for (i <- as.indices) {
      ans += math.pow(as(i) - average, 2).toLong
    }

    println(ans)
  }
}

Measured memory_bytes: 27480
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int size = 1 << n;

		int[] a = new int[size];
		for (int i = 0; i < size; i++) a[i] = sc.nextInt();
		Arrays.sort(a);

		int[] next = new int[size];
		next[size - 1] = a[size - 1];
		a[size - 1] = Integer.MAX_VALUE;

		for (int i = 1; i <= n; i++) {
			int x = size - 1;

			for (int j = 0, k = size - 1; j < 1 << (i - 1); j++, k--) {
				while (0 <= x && next[k] <= a[x]) x--;

				if (x == -1 && Arrays.stream(a).anyMatch((y) -> y != Integer.MAX_VALUE)) {
					System.out.println("No");
					return;
				}
				next[j] = a[x];
				a[x] = Integer.MAX_VALUE;
			}
			Arrays.sort(next);
		}

		System.out.println("Yes");
	}
}

Measured memory_bytes: 91300
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


//auto mod int
//https://github.com/atcoder-live/library/blob/master/mint.cpp

//const int mod = 1000000007;
const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://github.com/atcoder-live/library/blob/master/comb.cpp

struct combination {
    vector<mint> frac, ifrac;
    combination(int n):frac(n+1), ifrac(n+1) {
        assert(n < mod);
        frac[0] = 1;
        for (int i = 1; i <= n; ++i) frac[i] = frac[i-1]*i;
        ifrac[n] = frac[n].inv();
        for (int i = n; i >= 1; --i) ifrac[i-1] = ifrac[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return frac[n]*ifrac[k]*ifrac[n-k];
    }
} c(200005);

int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    mint ans = 0;
    mint col = m;
    for(int x = n-1; x >= 0; --x) {
        if(x <= k) {
            mint now = col;
            now *= c(n-1, x);
            ans += now;
        }
        col *= m-1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6228
#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
#define int int64

signed main() {
  // n:100
  // v[i]: 10^3
  // dp[ni][vi] := ni個まで見て, 価値v[i]以下の時のナップサックの容量の最小値
  // 遷移は
  // dp[ni][vi] = max(dp[ni-1][vi], dp[ni-1][vi-v[ni]] + w[ni]);

  // 最後に後ろから見ていき, W以下になるもので価値の最大値を出す

  int n,W;cin>>n>>W;
  vector<int> w(n),v(n);
  for(int i=0;i<n;++i)cin>>w[i]>>v[i];
 
  vector< vector<int> > dp(n+1, vector<int>((1e3+1)*n,1e9+1));
  
  dp[0][0] = 0;

  for(int ni=0;ni<n;++ni){
    for(int vi=0;vi<=n*(1e3+1);++vi){
      if (vi-v[ni]>=0)
        dp[ni+1][vi] = min(dp[ni][vi], dp[ni][vi-v[ni]] + w[ni]);
      else
        dp[ni+1][vi] = dp[ni][vi];
    }
  }
  
  
  int ans = 0;
  
  for(int i=0;i<(1e3+1)*n;++i){
    if(dp[n][i] > W) continue;
    ans = max(ans, i);
  }
  cout << ans << endl;
  
  return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


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

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(9) << (w * h) / 2 << ' ';
    if (x == w / 2 && y == h / 2) {
        cout << "1\n";
    } else {
        cout << "0\n";
    }
}



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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int a, b, c, d, e, n, m, k;
string s, t, r;
char c1, c2, c3;

int A[200005];
int B[200005];
int C[200005];

int main() {
	cin >>a>>b>>c;
  	cout <<c<<" "<<a<<" "<<b<<endl;
	return 0;
}

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

public class AtCoder
{

    public static int[] ReadArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));
    }

    public static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

    public static string ReadStr()
    {
        return Console.ReadLine();
    }

    public static long ReadLong()
    {
        return Convert.ToInt64(Console.ReadLine());
    }

    public static long[] ReadLongArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt64(m));

    }


    public static void Main()
    {
            int[] ii = ReadArray();
	
	    int n = ii[0], k= ii[1];

	    int[] A = ReadArray();

            int[] dp = new int[n];

        for(int i = 1; i < n; i++)
		dp[i] = int.MaxValue/2;
  



	   for(int i = 1; i < n; i++)
		{
			for(int j = Math.Max(0,i-k); j < i; j++)
			{
				dp[i] = Math.Min(dp[i], dp[j] + Math.Abs(A[i] - A[j]));
			}
	

		}

           Console.WriteLine(dp[n-1]);


 

      
       


    }


}


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

double kitaichi[1010];
double souwa[1010];
int main() {
  int N,K; cin >>N>>K;
  vector<int> P(N);
  for (int i=0;i<N;i++){
    cin>>P.at(i);
  }
  souwa[0]=0;
  souwa[1]=1;
  for(int i=2;i<=1000;i++){
    souwa[i]=souwa[i-1]+i;
  }
 
  kitaichi[0]=0;
  kitaichi[1]=1;
  for(int i=2;i<=1000;i++){
    kitaichi[i]=souwa[i]/i;
  }
  //cout <<kitaichi[2]<<" "<<kitaichi[4]<<" "<<kitaichi[5]<<endl;
  double kotae=0;
  double sum=0;
  for(int j=0;j<K;j++){
    sum=sum+kitaichi[P.at(j)];
  }
  kotae=max(kotae,sum);
  for(int i=1;i<=N-K;i++){  
    sum=sum+kitaichi[P.at(i+K-1)]-kitaichi[P.at(i-1)];
    //cout<<sum<<endl;
    kotae=max(kotae,sum);
  }
  cout<<fixed<<setprecision(12)<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 1024
// 2020-08-14 09:56:30
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int V = 100010;
int c[2], visited[2*V];
vector<int> G[2*V];
void dfs(int u) {
  if(visited[u]) return;
  visited[u] = 1;
  c[u/V]++;
  for(int v : G[u]) dfs(v);
}
void answer() {
  int n;
  cin >> n;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    y += V;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  ll ans = 0;
  rep(u, 2*V) {
    if(visited[u]) continue;
    c[0] = c[1] = 0;
    dfs(u);
    ans += 1ll * c[0] * c[1];
  }
  ans -= n;
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 14040
#include<stdio.h>


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



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
     
#define int  long long
#define endl '\n'
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 25 + 1;

void solve(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  stack<char> check;
  for (auto it : s){
	if (check.empty()) check.push(it);
	else{
	 if (it == check.top()) continue;
	 else check.push(it);	
    }
  }
  int ret = (int)check.size();
  cout << ret << endl;
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();	
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
  
#define INF 2000000010
#define mod7 1000000007
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define INF_LL 9223372036854775
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double 
 
using namespace std;

#define MAX_S

string S;

int main(){

  cin >> S;
  for(int i = 0; i < (int)S.length()-1; i++){
    if(S[i] == S[i+1]){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }

  for(int i = 0; i < (int)S.length()-2; i++){
    if(S[i] == S[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }

  cout << -1 << " " << -1 << endl;

  return 0;

}


Measured memory_bytes: 512
from collections import Counter

N=int(input())
S=input()

ans=0
X=Counter()
Y=Counter(S)
for c in S:
    Y[c]-=1
    if Y[c]==0:
        del X[c]
    else:
        X[c]+=1
    ans=max(ans,len(X))
       

print(ans)


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


void solve()
{
	
ll a,ans;
for(int i=0;i<5;i++)
{
	cin>>a;
	if(a==0)ans=i+1;
}


 
 
 cout<<ans;
 
	
	

}




int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);

		solve();
	
return 0;

		
	}
	
	
	


Measured memory_bytes: 3608
#include <stdio.h>

int main() {
  int N;
  
  scanf("%d", &N);
  
  if ((N % 10) == 3) {
    printf("bon");
  }
  else if (((N % 10) == 0) || ((N % 10) == 1) || ((N % 10) == 6) || ((N % 10) == 8)) {
    printf("pon");
  }
  else {
    printf("hon");
  }
  return 0;
}

Measured memory_bytes: 1708
import java.util.*;
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    // 整数の入力
    val a = sc.nextInt()
    val b = sc.nextInt()
    val k = sc.nextInt()

    var list = gcdArr(a, b).map{it}.sortedDescending()
  	println(list[k-1].toString())
}

fun gcdArr(a: Int, b: Int): MutableList<Int> {
    var list: MutableList<Int> = mutableListOf()
    var count = 1
    while(count <= 100) {
        if((a % count == 0) && (b % count == 0)) {
            list.add(count)
        }
        count++
    }
    return list
}

Measured memory_bytes: 35916
#include <iostream>
using namespace std;
int main (){
        string X,Y,Z;
        cin >> X >> Y;
        for(int i = 0; i<X.size() + Y.size(); i++) {
                if(i%2==0) {
                        Z +=X[i/2];
                }else{
                        Z += Y[i/2];
                }
        }
        cout << Z << endl;
        return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, L = map(int, raw_input().split())
if L <= 0 < L + N:
    print sum(i for i in range(L, L + N))
elif 0 < L:
    print sum(i for i in range(L + 1, L + N))
else:
    print sum(i for i in range(L, L + N - 1))

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    double a, b;
    cin >> a >> b;
    vector<int> vec8;
    vector<int> vec10;
    rep(i, 10000){
        vec8.push_back((double)i*0.08);
        vec10.push_back((double)i * 0.1);
    }
    rep(i, 10000){
        if(vec8[i] == a && vec10[i] == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*切り上げの計算！*/
int maxtime(int x) {
	return(x + 9) / 10 * 10;

}
int ggd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
int main() {
	long long int A, B, C, D;
	cin >> A >> B >> C >> D;
	long long int koubaisu = C/ggd(C, D)*D;
	long long cnt = 0;
	if (A % C == 0) {
		cnt = cnt + 1 + (B / C) - (A / C);
	}
	else {
		cnt = cnt + (B / C) - (A / C);
	}
	if (A % D == 0) {
		cnt = cnt + 1 + (B / D) - (A / D);
	}
	else {
		cnt = cnt + (B / D) - (A / D);
	}
	if (A % koubaisu == 0) {
		cnt = cnt - ( 1 + (B / koubaisu) - (A / koubaisu));
	}
	else {
		cnt = cnt - ((B / koubaisu) - (A / koubaisu));
	}
	cout << (B - A) + 1- cnt;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define MN 3010
#define mod 1000000007
#define inv 500000004

int x[MN], y[MN], a[MN];
int f[MN][MN];

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(int i = 1; i <= m; i++) scanf("%d%d", &x[i], &y[i]);
	for(int i = 1; i <= n; i++)
		for(int j = i + 1; j <= n; j++)
			if(a[i] > a[j]) f[i][j]++;
			else if(a[i] < a[j]) f[j][i]++;
	for(int i = 1; i <= m; i++)
	{
		int w;
		for(int j = 1; j <= n; j++)
		{
			if(j == x[i] || j == y[i]) continue;
			w = 1ll * (f[x[i]][j] + f[y[i]][j]) * inv % mod;
			f[x[i]][j] = f[y[i]][j] = w;
			
			w = 1ll * (f[j][x[i]] + f[j][y[i]]) * inv % mod;
			f[j][x[i]] = f[j][y[i]] = w;
		}
		w = 1ll * (f[x[i]][y[i]] + f[y[i]][x[i]]) * inv % mod;
		f[x[i]][y[i]] = f[y[i]][x[i]] = w;
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
		for(int j = i + 1; j <= n; j++)
			ans = (ans + f[i][j]) % mod;
	for(int i = 1; i <= m; i++) ans = ans * 2 % mod;
	printf("%d\n", ans);
}

//考虑求出每对 (i,j) 的贡献，如果 a_i > a_j，那么就是求有多少种方案使得交换完后i在j前面，否则就是求i在j后面
//那可以对每对 (i,j) DP 一下，f[i][j][k]表示前i个操作后第一个数在j，第二个数在k的方案
//把所有(i,j)一起DP，f[i]转移到f[i+1]时只会改n个数 

Measured memory_bytes: 35584
/*
AtCoder Beginner Contest 175 - E - Picking Goods
https://atcoder.jp/contests/abc175/tasks/abc175_e
*/

#include <bits/stdc++.h>
using namespace std; 

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 

double EPS=1e-9; 
int INF=1000000005; 
long long INFF=1000000000000000005ll; 
double PI=acos(-1); 
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 }; 
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define OUT(x) cout << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a)) 
#define EACH(a, b) for (auto&(a) : (b)) 
#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define MAX(a, b) a=max(a, b) 
#define MIN(a, b) a=min(a, b) 
#define SQR(x) ((ll)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define TC(t) while (t--) 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

ll dp[3050][3050][5]; // dp[r][c][k] stores the sum of row r and col c with k items picked
ll x[3050][3050]; // store the value

int main()  
{ 
    FAST_INP;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
    #endif
    
    // int tc; cin >> tc;
    // TC(tc) solve();
    ll R,C,K,r,c,k;
    cin >> R >> C >> K;
    REP(i,K){
        cin >> r >> c >> k;
        x[r][c]=k;
    }
    FORN(i,1,R){ // row
        FORN(j,1,C){ // col
            FORN(kk,0,3){ // only pick at most 3 items
                dp[i][j][kk]=max(dp[i][j-1][kk], dp[i-1][j][3]);
                if(kk) dp[i][j][kk]=max(dp[i][j][kk],max(dp[i][j-1][kk-1],dp[i-1][j][3])+x[i][j]);
            }
        }
    }
    OUT(dp[R][C][3]);
    return 0; 
} 

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

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

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

int main() {
    long long int x, k, d;
    cin >> x >> k >> d;
    long long int p = abs(x) / d, q = abs(x) % d;
    long long int ans;
    if ((k - p) % 2 == 0) ans = q;
    else if ((k - p) % 2 == 1 && q != 0)
        ans = min(q + d, abs(q - d));
    else
        ans = d;
    if (abs(x) / k / d >= 1) ans = abs(x) - k * d;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3672
def main(n):
    if n in [2, 4, 5, 7, 9]:
        return 'hon'
    elif n in [0, 1, 6, 8]:
        return 'pon'
    else:
        return 'bon'

if __name__ == '__main__':
    N = int(input())
    n = N%10
    ans = main(n)
    print(ans)



Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		map<int,int>mp;
		fn{
			cin >> ar[i];
			mp[ar[i]]++;
		}
		fn1{
			cout << mp[i] <<'\n';
		}
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 17920
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	auto n = readln.chomp.to!int;

	foreach (i; 0..n) {
		readln.replace("Hoshino", "Hoshina").write;
	}
}

Measured memory_bytes: 1060
#include <stdio.h>


int main(){

	int x, y;


	while(1){

		scanf( "%d %d", &x, &y );

		if( x == 0 && y==0 ) break;

		if( x < y ) printf( "%d %d\n", x, y );
		else printf( "%d %d\n", y, x );
	}

	return 0;


}

Measured memory_bytes: 600