akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
a = list(map(int, input().split()))
x=bin(k)[2:]

ans=0
flag=True

for i in range(50):
    count=0
    for j in range(n):
        if (a[j]>>(50-i-1))&1==1:
            count+=1

    if 50-i-1>len(x)-1:
        ans+=2**(50-i-1)*count

    elif not flag:
        ans+=2**(50-i-1)*max(count, n-count)
    else:
        if 2*count>=n:
            if int(x[-(50 - i)]) == 1:
                ans+=2**(50-i-1)*count
                flag=False
            else:
                ans += 2 ** (50 - i - 1) * count
        
        else:
            if int(x[-(50-i)])==1:
                ans+=2**(50-i-1)*(n-count)
            else:
                ans+=2**(50-i-1)*count

print(ans)


Measured memory_bytes: 69264
#include<iostream>
using namespace std;
int main(){
        string s;
	while(cin>>s){
		int a=0,b=0;
		for(int i=0;i<s.size()-1;i++){
			if(s[i]=='J'&&s[i+1]=='O'&&s[i+2]=='I'){
				a+=1;
			}
			if(s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I'){
				b+=1;
			}
		}	
	cout<<a<<endl<<b<<endl;
    }
	return 0;
}		


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> d;
  rep(i,n) {
    auto it = lower_bound(d.rbegin(), d.rend(), a[i]);
    if (it == d.rbegin()) {
      d.push_back(a[i]);
    } else {
      --it;
      *it = a[i];
    }
  }
  int ans = d.size();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int w,h,x,y,flag=0;
	scanf("%d%d%d%d",&w,&h,&x,&y);
	if(w%2==0&&x==w/2&&h%2==0&&y==h/2)flag=1;
	double s=(double)w*(double)h;
	printf("%.6lf %d",s/2,flag);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    int t = sc.nextInt();
    int s = sc.nextInt();
    String ans = "Yes";
    if((s * t) < d) ans = "No";
    System.out.println(ans);
  }
}

Measured memory_bytes: 35708
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, T;
int A[100010];
int M[100010];


void makeM(){
	M[N-1] = A[N-1];
	repr(i, N-1, 0) M[i] = max(M[i+1], A[i]);
}


int solve(){
	int ans = 0;
	int MX = -INF;
	rep(i, 0, N-1)
		if(MX < M[i+1]-A[i]) MX = M[i+1]-A[i], ans = 1;
		else if(MX == M[i+1]-A[i]) ans++;
	return ans;
}


signed main(){
	cin >> N >> T;
	rep(i, 0, N) cin >> A[i];

	makeM();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1024
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cerr << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> PII;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

int N;
vector<string> S;


bool checkS(int a, int b) {
    REP(i, N) {
        FOR(j, i + 1, N){
            if (S[a + i][b + j] != S[a + j][b + i]) {
                return false;
            }
        }
    }
    return true;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i, N) {
        string s;
        cin >> s;
        S.push_back(s + s);
    }

    REP(i, N) {
        S.push_back(S[i]);
    }

    int ans = 0;
    REP(i, N) {
        if (checkS(0, i)) {
            ans += N;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a[3],b,c;
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  cin>>b>>c;
  c=min(b,c);
  cout<<a[0]+c-50<<endl;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {
			int N = sc.nextInt();
			
			if(N == 0) {
				break;
			}

			int sum = 0;

			int count = 0;

			for (int i = 1; i < N; i++) {
				sum = i;
				for (int j = i + 1; j < N; j++) {
					sum += j;
					if (N == sum) {
						count++;
					}
					if (N < sum) {
						break;
					}
				}
			}

			System.out.println(count);

		}

	}

}

Measured memory_bytes: 19860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        String a = s.next(),b=s.next(),c=s.next();
        if(a.charAt(a.length()-1)==b.charAt(0)&&b.charAt(b.length()-1)==c.charAt(0)) System.out.println("YES");
        else System.out.println("NO");

    }


}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25336
N = int(input())
S = list(input())

A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

for i,s in enumerate(S):
    n = A.index(s)
    if n+N > 25:
        nn = n+N-26
    else:
        nn = n+N
    S[i]=A[nn]

Ans=''.join(S)
print(Ans)

Measured memory_bytes: 3060
import java.util.HashMap;
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		SortedSet<KeyValuePair> a = new TreeSet<KeyValuePair>();
		HashMap<Integer, Integer> num = new HashMap<Integer, Integer>();

		for (int i = 1; i <= n; i++) {
			String str = sc.next();
			int z = sc.nextInt() * (-1);

			a.add(new KeyValuePair(z, str));
			num.put(z, i);
			// System.out.println(str + " " + z + " " + i);
		}

		for (KeyValuePair keyValuePair : a) {
			System.out.println(num.get(keyValuePair.key));
		}

		sc.close();
	}
}
class KeyValuePair implements Comparable<KeyValuePair> {
	int key;
	String value;

	public KeyValuePair(int key, String value) {
		super();
		this.key = key;
		this.value = value;
	}

	public int compareTo(KeyValuePair o) {
		return value.equals(o.value) ? key - o.key : value.compareTo(o.value);
	}
}

Measured memory_bytes: 21716
#include<stdio.h>
int main()
{
	int n,m,i,j;
	char s[101][101];
	scanf("%d %d",&n,&m);
	for(i = 0;i < n;i++)
		scanf("%s",s[i]);
	j = 0;
	for(i = 0;i < 2 * n;i++)
	{	
		printf("%s\n",s[j]);
		if(i % 2 != 0)
			j++;
	}
	return 0;
}


Measured memory_bytes: 128
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
answer = 1
if n!=1: flag = np.sign(a[1]-a[0])
for i in range(1,n-1):
	num = np.sign(a[i+1]-a[i])
	if flag==0:
		flag = num
	elif num==-flag:
		answer += 1
		flag = 0
print(answer)

Measured memory_bytes: 23100
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+4;
int n,m;
int a[N],b[N];
int cnt[N];
ll sum;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int main() {
//	freopen("in.txt","r",stdin);
	n=read();
	for (register int i=1;i<=n;++i) {
		a[i]=read();
		++cnt[a[i]];
		sum+=a[i];
	}
	m=read();
	for (register int i=0;i<m;++i) {
		int x=read(),y=read();
		sum+=1ll*cnt[x]*(y-x);
		cnt[y]+=cnt[x];
		cnt[x]=0;
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 4436
//テンプレート
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(){
    int i,j,k,strLength=0,strMax=0;
    char S[10],T[10];
    scanf("%s",S);
    
    for (i=0; S[i]!='\0'; i++) {
        strLength=0;
        for (j=i,k=0; S[j]=='A'||S[j]=='C'||S[j]=='G'||S[j]=='T'; j++,k++) {
            T[k]=S[j];
            strLength++;
        }
        if (strMax < strLength) {
            strMax = strLength;
        }
    }
    printf("%d\n",strMax);
    return 0;
}



Measured memory_bytes: 128
function main(p){
  const num = parseInt(p.split('\n')[0], 10)
  let ans
  for (let i=1; i<=Math.sqrt(num); i++){
    if(num % i === 0){
      ans = num/i + i - 2
    }
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int n;
int a[1000];

int main() {
	while (cin >> n) {
		if (!n) break;
		for (int i = 0; i < n; i++) cin >> a[i];
		sort(a, a + n);
		
		int ans = 1145141919;
		for (int i = 0; i < n - 1; i++) ans = min(ans, a[i + 1] - a[i]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

minimum = 1234567890
for i in range(n):
    ti = t - h[i] * 0.006
    if abs(minimum - a) > abs(ti - a):
        minimum = ti
        ans = i + 1
        
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,ans,a[300010];
int main()
{
	cin>>n;
	for(int i=1;i<=3*n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+3*n+1);
	for(int i=3*n-1;i>=n+1;i-=2) ans+=a[i];
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int d[110],w,q;

int check(int wide){
	int cnt=0;
	rep(i,0,w+1){
		if(d[i]){
			cnt=0;
		}else{
			cnt++;
		}
		if(cnt==wide) return i+1-cnt;
	}
	return -1;
}

signed main(){
	while(1){
		cin>>w>>q;
		if(w+q==0) break;
		char c;
		int id,wide;
		rep(i,0,w) d[i]=0;
		d[w]=1;

		map<int,pii> mp;
		rep(i,0,q){
			cin>>c;
			if(c=='s'){
				cin>>id>>wide;
				mp[id].first=wide;
				int ind=check(wide);
				if(ind==-1) o("impossible");
				else{
					o(ind);
					mp[id].second=ind;
					rep(j,0,wide){
						d[ind+j]=1;
					}
				}
			}else{
				cin>>id;
				rep(j,0,mp[id].first){
					d[mp[id].second+j]=0;
				}
			}
		}
		o("END");
	}
}

Measured memory_bytes: 1196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        System.out.print(n+":");
        for (int i=2; i*i<=n; i++){
        	while (n%i==0) {
        		if (i%4==0) break;
        		n/=i;
        		System.out.print(" "+i);
        	}
        }
        if (n!=1) System.out.print(" "+n);
        System.out.println();
        br.close();
	}
}

Measured memory_bytes: 24408
K, N = map(int, input().split())
A = list(map(int, input().split()))

ans_root = K
for i in range(N):
    if i==0:
        root = A[N-1] - A[0]
    else:
        root = A[i-1]+K - A[i]
    if ans_root > root:
        ans_root = root
print(ans_root)

Measured memory_bytes: 26100
#include "bits/stdc++.h"
using namespace std;
 
int main() {
    int n,m;
    cin >> n >> m;
    long long sum = 0;
    priority_queue<int> q;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        q.push(a);
        sum += a;
    }
    for(int i = 0; i < m; i++){
        int t = q.top();
        q.pop();
        int s = t / 2;
        sum -= (t-s);
        q.push(s);
    }
    cout << sum << endl;
}

Measured memory_bytes: 892
# 条件下の「橋」を、「エッジを1つしか持たないノード」から
#「エッジを3つ以上持つノード」の間にあるエッジと考える
from collections import defaultdict

def remove_checked():
  global check_nodes,dd
  for n in check_nodes:
    if n in dd:
      dd.pop(n)
    for k in dd:
      if n in dd[k]:
        dd[k].remove(n)
  check_nodes=set()        

n,m=map(int,input().split())
dd=defaultdict(list)
check_nodes=set()
for i in range(m):
  a,b=map(int,input().split())
  dd[a].append(b)
  dd[b].append(a)

cnt=0
while True:
  for k in dd.keys():
    if k in check_nodes:
      continue
    nodes=dd[k]
    if len(nodes) == 1:
      nxt=k
      while len(nodes) <= 2:
        check_nodes.add(nxt)
        cnt+=1
        nxt=nodes[0]
        if nxt in check_nodes:
            nxt = nodes[1]
        nodes=dd[nxt]
        if len(nodes) == 1:
          check_nodes.add(nxt)
          break
  if check_nodes==set():
    break
  remove_checked()

print(cnt)    

Measured memory_bytes: 9264
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	string w; cin >> w;
	vector<string> a(w.size()), b(w.size());
	for (int i = 0; i < w.size(); i++) {
		a[i] = w[i];
	}
	b = a;
	ssort(a);
	eerase(a);
	int cnt,num;
	for (int i = 0; i < a.size(); i++) {
		cnt = count(b.begin(), b.end(), a[i]);
		if (cnt % 2 != 0) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();

    let ans = 1000 - n % 1000;
    println!("{}", ans % 1000);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2240
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
template <class T>
using vt = vector<T>;
using vvl = vector<vt<ll>>;

int main(){

  int a;
  cin >> a;

  cout << (a == 0 ? 1:0) << endl;
  return 0;
}


Measured memory_bytes: 3632
/***/





#include<bits/stdc++.h>

using namespace std;

#define fastinput   ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll          long long
#define bn          1000090
#define sn          1010
#define mod         100000007
#define iii(i)      cin>>i
#define ooo(i)      cout<<i
#define sss         cout<<" "
#define nnn         cout<<"\n"/**
#define iii(i)      iii>>i
#define ooo(i)      ooo<<i
#define sss         ooo<<" "
#define nnn         ooo<<"\n"*/
#define ff          first
#define ss          second
#define psb         push_back

/**
        ifstream iii;iii.open("D:\\prgrms\\codechef cntst 1\\input.txt");
        ofstream ooo;ooo.open("D:\\prgrms\\codechef cntst 1\\my output.txt");
*/

ll a[bn];

int main()
{
	///fastinput;
	ll n,s; iii(n>>a[1]); s = a[1];
	for(ll i = 2; i <= n; i++)
	{
	        iii(a[i]);
	        s ^= a[i];
	}
	for(ll i = 1; i <= n; i++)
        {
                ll m; m = s^a[i];
                ooo(m);sss;
        }
        return 0;
}




/**

4
20 11 9 24











*/















/***/


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

  int n;
  cin>>n;

  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      if((4*i+7*j)==n){
	cout<<"Yes"<<endl;
	return 0;
      }
    }
  }

  cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

bool isPrime(int n){
  if(n==1) return false;
  for(int i=2;i<=sqrt(n)+1;i++)
    if(n%i==0)
      return false;
  return true;
}

int main(){
  int N;
  cin >> N;
  int x = 6;
  while(1){
    if(isPrime(x)){
      cout << x << " ";
      N --;
    }
    if(N<=0)
      break;
    x += 5;
  }
  return 0;
}


Measured memory_bytes: 256
def dfs(u, cnt):
    cnt += point[u]
    counter[u] = cnt
    color[u] = GRAY
    for v in M[u]:
        if color[v] == WHITE:
            dfs(v, cnt)
    color[u] = BLACK

import sys
sys.setrecursionlimit(1000000)

n, q = map(int, input().split())
M = [[] for _ in range(n)]
point = [0] * n
for i in range(n-1):
    a, b = map(int, input().split())
    M[a-1].append(b-1)
    M[b-1].append(a-1)
for i in range(q):
    p, x = map(int, input().split())
    point[p-1] += x
#print(M, point)
    
WHITE, GRAY, BLACK = 0, 1, 2
color = [WHITE] * n

counter = [0] * n
dfs(0, 0)

print(*counter)


Measured memory_bytes: 227976
#include <bits/stdc++.h>
using namespace std;
int main() {
    long n,big = 0,ans = 0;
  	cin >> n;
    vector<long> l(n);
  	for(long i = 0; i< n; i++){
      cin >> l[i];
      if(big <= l[i]){
        big = l[i];
      }
      ans = ans+l[i];
    }
  	if(ans-big>big){
      cout << "Yes" << endl;
    }
  	else{
      cout << "No" << endl;
    }
}
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Measured memory_bytes: 256
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<cmath>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<functional>

using namespace std;
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template<typename T>
bool chmin(T& l, T r) {
	bool res = l > r;
	if (res)l = r;
	return res;
}
template<typename T>
istream& operator>>(istream& is, vector<T> &v) {
	for (auto &it : v)is >> it;
	return is;
}
typedef vector<int> V;
int f(int x, int y, int z) {
	return x + y + z;
}
int main() {
	int N, M, P;
	while (cin >> N>>M>>P, N+M+P) {
		V x(N);
		cin >> x;
		int X = 0;
		REP(i, N)X += x[i];
		int Y = X*(100 - P);
		if (x[M - 1] == 0)cout << 0 << endl;
		else cout << Y / x[M - 1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int64_t a;
  cin >> a;
  int64_t count = 0;
  int64_t ans = 0;
  for (int64_t i = 1; i <= a; i++)
  {
    if (i % 3 == 0 && i % 5 == 0) // iが3の倍数かつ5の倍数
      count += 1;
    else if (i % 3 == 0) // iが3の倍数(かつ、5の倍数でない)
      count += 1;
    else if (i % 5 == 0) // iが5の倍数(かつ、3の倍数でない)
      count += 1;
    else // iが3の倍数でも5の倍数でもない
      ans += i;
  }
  cout << ans << endl;
}

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

main() {
  int bell[3]; rep(i, 3) cin >> bell[i];
  sort(bell, bell + 3);
  cout << bell[0] + bell[1] << endl;
}

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

int main()
{
  int64_t N,K ;
  cin>>N>>K ;
  
  if(N<K){
    cout<<(N>K-N?K-N:N)<<endl ;
    return 0 ;
  }
  
  N-=K*(N/K) ;
  cout<<(N>K-N?K-N:N)<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int keta(int n){
  int cnt =0;
  while(n>0){
    n/=10;
    cnt++;
  }
  return cnt;
}
int main() {
  int N;
  cin>>N;
  int cnt=0;
  REP(i,1,N+1){
    if(keta(i)%2==1){
      cnt++;
    }
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
 
#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c) 
 
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100;
 
int main(void){
    ll a,b;
    ll answer = 0;
    
    in2(a,b);
    For(i,a,b+1){
        str num = ltos(i);
        if (num[0] == num[4] && num[1] == num[3]) answer ++;
    }

    prl(answer);
 
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

int main() {
    string s, t;
    cin >> s >> t;
    map<char, vector<int>> m1;
    map<char, vector<int>> m2;

    rep(i, s.size()) {
        m1[s[i]].push_back(i);
        m2[t[i]].push_back(i);
    }

#if 0
    for(auto itr: m1) {
        cout << itr.first << " [";
        for(auto n : itr.second)
           cout  << n << ",";
        cout << "]" << endl;
    }

    for(auto itr: m2) {
        cout << itr.first << " [";
        for(auto n : itr.second)
           cout  << n << ",";
        cout << "]" << endl;
    }
#endif
    rep(i, s.size()) {
        if(m1[s[i]].empty())
            continue;
        if(m1[s[i]] != m2[t[i]]) {
            cout << "No" << endl;
            return 0;
        }
        m1.erase(s[i]);
        m2.erase(t[i]);
#if 0
        cout << i << endl;
        for(auto n : m1[s[i]])
           cout << " " << n << ",";
        cout << endl;
        for(auto n : m2[t[i]])
           cout << " "  << n << ",";
        cout << endl;
#endif
    }
    cout << "Yes" << endl;

    return 0;
}



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

ll gcm(ll m, ll n){
	if(m==0)return n;
	if(n==0)return m;
	if(m<n)return gcm(m,n%m);
	else return gcm(n,m%n);
}

ll lcm(ll m,ll n){
	if(m==0 or n==0)return 0;
	return m/gcm(m,n)*n;
}

int main(){
	ll n,t;
	ll cnt=1;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>t;
		cnt=lcm(cnt,t);
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N, ans;
int C, K;

int main(){
    int A;
    scanf("%d", &N, &K);
    for (int i=1; i<=N; i++) {
        scanf("%d", &A);
        if (A == C) K++;
        else {
            ans += (K / 2);
            C = A, K = 1;
        }
    }
    ans += (K / 2);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int k;
	cin>>k;
	int a,b,count=0;
	cin>>a>>b;
	for (int i=a;i<=b;i++){
	    if (i%k==0){
	        count++;
	    }
	}
	if (count>0){
	    cout<<"OK"<<endl;
	}
	else
	    cout<<"NG"<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)

int main() {
	ll n; cin >> n;
	ll a[100000] = {};
	ll maxV = 0;
	rep(i, 0, n) {
		cin >> a[i];
		maxV = max(maxV, a[i]);
		a[i] *= 2;
	}

	ll diff = 1e16;
	ll result = 0;
	rep(i, 0, n) {
		if (diff >= abs(a[i] - maxV)) {
			diff = abs(a[i] - maxV);
			result = a[i] / 2;
		}
	}

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

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cmath>
using namespace std;
long long n, a[300009], minx = (1LL << 60), s, t;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; }
	for (int i = 0; i < n - 1; i++) { t += a[i]; minx = min(minx, abs(t - (s - t))); }
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

a, b, c, d = map(int, input().split())
while True:
    c -= b
    if c <= 0:
        print('Yes')
        sys.exit()
    a -= d
    if a <= 0:
        print('No')
        sys.exit()

Measured memory_bytes: 10420
#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() {
    ll n ,k;
    cin >> n >> k;
    //cout << "n=" << n << " k=" << k << endl;
    ll min = 0;
    //ll sa=0;
    ll x = n/k;     //n<kのときは？->0だからok
    min = n - x*k; //正の範囲で最小
    ll min2;
    min2 = abs(min - k);
    if(min <= min2){
        cout << min << endl;
    }else{
        cout <<  min2 << endl;
    }
    
    /*
    while(1){
        sa = abs(min-k);
        //cout << "sa=" << sa << endl;
        if(sa < min){
            min = sa;
        }else{
            break;
        }
    }
    */
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int n;
ll k;
int a[400005];
int rest[200005];
int to[51][200005];
ll cnt[51][200005];
int ans[200005];
int len=0;

int main(void){
	scanf("%d%lld",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		a[i+n]=a[i];
	}
	memset(rest,-1,sizeof(rest));
	for(int i=n*2-1;i>=0;i--){
		if(rest[a[i]]==-1){
			rest[a[i]]=i;
		}else{
			to[0][i]=(rest[a[i]]+1)%n;
			//printf("%d\n",to[0][i]);
			if(rest[a[i]]+1>=n){
				cnt[0][i]=1;
			}
			if(rest[a[i]]+1>=n*2){
				cnt[0][i]++;
			}
			rest[a[i]]=i;
		}
	}
	for(int i=0;i<50;i++){
		for(int j=0;j<n;j++){
			to[i+1][j]=to[i][to[i][j]];
			cnt[i+1][j]=cnt[i][j]+cnt[i][to[i][j]];
		}
	}
	ll loop=0;
	int pos=0;
	bool flag=true;
	while(flag){
		flag=false;
		//printf("%lld %d\n",loop,pos);
		for(int i=50;i>=0;i--){
			if(cnt[i][pos]+loop<k){
				//printf("%d %d %d\n",i,pos,to[i][pos]);
				flag=true;
				loop+=cnt[i][pos];
				pos=to[i][pos];
				break;
			}
		}
	}
	memset(rest,-1,sizeof(rest));
	//printf("%d %lld\n",pos,loop);
	for(int i=pos;i<n;i++){
		if(rest[a[i]]==-1){
			rest[a[i]]=len;
			ans[len]=a[i];
			len++;
		}else{
			int tmp=len;
			len=rest[a[i]];
			for(int j=rest[a[i]];j<tmp;j++){
				//printf("erase%d\n",ans[j]);
				rest[ans[j]]=-1;
			}
		}
	}
	if(loop==(k-2LL)){
		for(int i=0;i<n;i++){
			if(rest[a[i]]==-1){
				rest[a[i]]=len;
				ans[len]=a[i];
				len++;
			}else{
				int tmp=len;
				len=rest[a[i]];
				for(int j=rest[a[i]];j<tmp;j++){
					//printf("erase%d\n",ans[j]);
					rest[ans[j]]=-1;
				}
			}
		}
	}
	for(int i=0;i<len;i++){
		printf("%d%c",ans[i],(i+1)==len?'\n':' ');
	}

	return 0;
}

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


int main(){
  string s,a;
  cin >> s;
  bool f=true;
  a=s;
  reverse(a.begin(),a.end());
  if(a!=s)f=false;
  int n=(s.size()-1)/2;
  rep(i,n){
    if(s[i]!=s[n-i-1])f=false;
  }
  rep(i,n){
    if(s[i+n+1]!=s[s.size()-i-1])f=false;
  }
  if(f)cout<<"Yes";
  else cout<<"No";
}


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

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

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

while(x<=y){
  x*=2;
  count++;
}

cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input(""))

A=N%10

if A == 2 or A == 4 or A == 5 or A == 7 or A == 9:
      print("hon")
elif A == 0 or A == 1 or A == 6 or A == 8:
      print("pon")
else:
      print("bon")

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

#define gc() getchar()
template<typename T> void read(T &x){
    x = 0; int f = 1; char ch = gc();
    while(!isdigit(ch) ) { if(ch == '-') f = -1; ch = gc();}
    while( isdigit(ch) ) {x = x * 10 + ch - 48; ch = gc();}
    x *= f;
}
template<typename T, typename... Args> void read(T& x, Args&... args)
{ read(x), read(args...); }
template<typename T> void write(T x) {
    if(x < 0) putchar('-'), write(-x);
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

const int maxn = 200200;
int n, m, _x, _y, deg[maxn], cnt;
int u = -1, v = -1;
vector<int> G[maxn];

void dfs(int a, int fa) {
    for(auto g : G[a]) if(g != fa) {
        if(deg[g] == 2) dfs(g, a);
        else if(g == u) cnt += 2;
        else if(g == v) cnt += 1;
        else assert(false);
    }
}

int main() {
    read(n, m);
    rep(i, m) {
        read(_x, _y);
        deg[_x]++;
        deg[_y]++;
        G[_x].push_back(_y);
        G[_y].push_back(_x);
    }
    rep(i, n) {
        if(deg[i] & 1) {
            puts("No");
            return 0;
        }
    }
    rep(i, n) if(deg[i] > 4) {
        puts("Yes");
        return 0;
    }
    int ok = 0;
    rep(i, n) if(deg[i] == 4) ok++;
    if(ok == 0) { puts("No"); return 0; }
    else if(ok > 2) { puts("Yes"); return 0; }
    else if(ok == 1) { puts("No"); return 0; }
    else {
        rep(i, n) if(deg[i] == 4) {
            if(u == -1) u = i;
            else v = i;
        }
        dfs(u, -1);
        if(cnt > 5) puts("Yes");
        else puts("No");
    }
    
    return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

typedef tuple<int, int, int> T;

void solve() {
  int h, w;
  cin >> h >> w;
  vvi m(h, vi(w));
  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) m[i][j] = (s[j] == '.' ? 0 : 1);
  }
  int ans = 0;
  rep(i, h) rep(j, w) {
    if (m[i][j]) continue;
    deque<T> q;
    vvi d(h, vi(w, -1));
    q.push_back(T(i, j, 0));
    while (!q.empty()) {
      int ui, uj, ud;
      tie(ui, uj, ud) = q.front();
      q.pop_front();
      if (d[ui][uj] != -1) continue;
      if (m[ui][uj] == 1) continue;
      d[ui][uj] = ud;
      if (0 < ui) q.push_back(T(ui - 1, uj, ud + 1));
      if (ui < h - 1) q.push_back(T(ui + 1, uj, ud + 1));
      if (0 < uj) q.push_back(T(ui, uj - 1, ud + 1));
      if (uj < w - 1) q.push_back(T(ui, uj + 1, ud + 1));
    }
    int mx = 0;
    rep(y, h) rep(x, w) maxs(mx, d[y][x]);
    maxs(ans, mx);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

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

    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    long N = scanner.nextLong();
    long M = scanner.nextLong();
    long Nx = 1;
    long Mx = 1;
    long ans = 0;
    for (int i = 1; i <= N; i++){
      Nx = Nx * i % 1000000007;
    }
    for (int i = 1; i <= M; i++){
      Mx = Mx * i % 1000000007;
    }
    if(N == M){
      ans = 2 * Nx * Mx % 1000000007;
    } else if (N == M - 1 || N == M + 1){
      ans =  Nx * Mx % 1000000007;
    } else {
      ans = 0;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
int pre;
int main() {
    int n;
    int mod = 1e9 + 7;
    while (~scanf("%d", &n)) {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int a;
            scanf("%d", &a);
            sum = (sum + (long long)pre * a) % mod;
            pre = (pre + a) % mod;
        }
        printf("%d\n", sum);
    }
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	for (int i = 1; i <= 9; ++i)
	{
		for (int j = 1; j <= 9; ++j)
		{
			if(i*j==N)
			{
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}

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

int main() {
  int n, k, q, a;
  string s;
  cin >> n >> k >> q;
  vector<int> p(n + 1);
  for (int i = 0; i < q; i++) {
    cin >> a;
    p[a]++;
  }
  for (int i = 1; i <= n; i++) {
    if (p[i] - q + k <= 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    S=input()
    
    ans=0
    now="A"
    for i in range(N):
        if S[i]==now:
            ans+=1
        now=S[i]
    
    ans=(min(N-1,ans+K*2))
    print(ans)
        

main()


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

int main()
{
    vector <string> v;
    int n;
    cin >> n;
    cin.ignore();
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        v.push_back(s);
    }
    int c0 = count(v.begin(),v.end(),"AC");
    int c1 = count(v.begin(),v.end(),"WA");
    int c2 = count(v.begin(),v.end(),"TLE");
    int c3 = count(v.begin(),v.end(),"RE");
    cout << "AC x " << c0 << "\nWA x " << c1 << "\nTLE x " << c2 << "\nRE x " << c3 << "\n";
}


Measured memory_bytes: 7468
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

#define MOD 1000000007

int main()
{
    long long n,m;
    vector<long long> a;
    
    a.push_back(0);
    long long  ac;
    cin >> n >> m;
    for (long long i = 1;i <= m;i++){
        cin >> ac;
        a.push_back(ac);
    }
    
    long long dp[100005];
    
    if (a[1] == 1){
        dp[1] = 0;
        if (a[2] == 1){
            dp[2] = 0;
        }
        else {
            dp[2] = 1;
        }
    }
    else {
        dp[1] = 1;
        if (a[1] == 2){
            dp[2] = 0;
        }
        else {
            dp[2] = 2;
        }
    }
    
    for (int i = 3;i <= n;i++){
        if (!binary_search(a.begin(),a.end(),i-1) && !binary_search(a.begin(),a.end(),i-2)){
            dp[i] = (dp[i-1] + dp[i-2])%MOD;
        }
        else if (!binary_search(a.begin(),a.end(),i-1) && binary_search(a.begin(),a.end(),i-2)){
            dp[i] = dp[i-1];
        }
        else if (binary_search(a.begin(),a.end(),i-1) && !binary_search(a.begin(),a.end(),i-2)){
            dp[i] = dp[i-2];
        }
        else {
            dp[i] = 0;
        }
    }
    cout << dp[n] << endl;
}


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

int n;
class Edge{
public:
	long long cost;
	int from, to;
	Edge(long long c, int f, int t){
		cost = c;
		from = f;
		to = t;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef pair<long long, long long> P;
typedef pair<P, int> PP;
P ans;
Graph g;

P func(int r, int x, int y){
	vector<long long> v(n, 0);
	queue<PP> q;
	if(x == -1 && y == -1) q.push(PP(P(r, -1), 0));
	else{
		for(int i=0; i<g[r].size(); ++i)
			q.push(PP(P(g[r][i].to, n), 0));
	}
	while(!q.empty()){
		PP pp = q.front();
		q.pop();
		P p = pp.first;
		int d = pp.second;
		int a = p.first;
		int pr = p.second;
		long long m = g[a].size();
		if(x != -1) --m;
		else if(d != 0) --m;
//		if(a == x || a == y) --m;
		v[d] = max(v[d], m);
		for(int i=0; i<g[a].size(); ++i){
			int t = g[a][i].to;
			if((a == x && t == y) || (a == y && t == x) || (t == pr)) continue;
			q.push(PP(P(t, a), d+1));
		}
	}
	P res = P(1, 1);
	for(int i=0; i<n; ++i){
		if(v[i] == 0) break;
		res.second *= v[i];
		++res.first;
	}
	if(x != -1) res.second <<= 1;
/*	if(x != -1 || y != -1){
		cout << r << "\n";
		for(int i=0; i<n; ++i)
			cout << v[i] << " \n"[i==n-1];
		cout << res.first << " " << res.second << "\n";
	}
*/	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	g.resize(n+1);
	for(int i=0; i<n-1; ++i){
		int a, b;
		cin >> a >> b;
		g[a-1].push_back(Edge(1, a-1, b-1));
		g[b-1].push_back(Edge(1, b-1, a-1));
	}
	ans = P(1e18, 1e18);
	for(int i=0; i<n; ++i) ans = min(ans, func(i, -1, -1));
//	cout << ans.first << " " << ans.second << "\n";
	for(int i=0; i<n; ++i)
		for(int j=0; j<g[i].size(); ++j){
			int t = g[i][j].to;
			if(t < i) continue;
			g[n].clear();
			g[n].push_back(Edge(1, n, i));
			g[n].push_back(Edge(1, n, t));
			P a = func(n, i, t);
			ans = min(ans, a);
		}
	cout << ans.first << " " << ans.second << "\n";
}

Measured memory_bytes: 256