akhauriyash/Code-Regression huggingface dataset:
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter};
use std::ops::{Index, IndexMut};
use std::collections::VecDeque;
use std::f32::MAX;

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn main(){
    let_all!(n: usize, m: usize);
    let mut sections = Vec::with_capacity(m);
    for _ in 0 .. m {
        let_all!(c: usize, d: usize);
        sections.push(Section{from: c, to: d});
    }
    sections.sort_by_key(|s|s.from);
    let mut current = Section{from: 0, to: 0};
    let mut result = 0;
    for s in &sections {
        if current.has_intersection(s) {
            current = current.merged(s);
        }else {
            result += current.to - current.from;
            current = *s;
        }
    }
    result += current.to - current.from;
    println!("{}", result * 2 + n + 1);
}
#[derive(Copy, Clone)]
struct Section {
    from: usize, to: usize,
}
impl Display for Section {
    fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
        write!(f, "({}, {})", self.from, self.to)
    }
}
impl Section {
    fn has_intersection(&self, other: &Section) -> bool {
        !self.has_no_intersection(other)
    }
    fn has_no_intersection(&self, other: &Section) -> bool {
        self.to < other.from || other.to < self.from
    }
    fn merged(&self, other: &Section) -> Section {
        Section{from: min(self.from, other.from), to: max(self.to, other.to)}
    }
}




Measured memory_bytes: 5052
use std::str::FromStr;

fn main() {
	let n = read_vec_i32()[0];
	let ds = read_string();
	let x = (n..).find(|x| x.to_string().chars().all(|c| !ds.chars().any(|c2| c2 == c))).unwrap();
	println!("{}", x);
}

fn read_string() -> String {
	let mut line = String::new();
	std::io::stdin().read_line(&mut line).unwrap();
	line
}

fn read_vec_i32() -> Vec<i32> {
	let mut line = String::new();
	std::io::stdin().read_line(&mut line).unwrap();
	line.trim().split(' ').map(|str| i32::from_str(str).unwrap()).collect()
}

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
const int MAX = 26;
typedef long long int ll;
vector<ll>pp;
bool prime[90000000];
const string st="abacaba";

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

    ll  m,n,t,ab,k,a,b,c,d,flag=0;

    string s1,s2,s;
    //vector<ll>vec;

    char ch;
    vector<ll>vec1;
    map<ll,ll>mp1;
    map<char,ll>mp2;
    vector<ll>vec2;
    //ll  sum=0;
    set<char>st;


    cin>>a>>b>>c>>d;
    ll sum1=(a*c);
    ll sum2=(a*d);
    ll sum3=(b*c);
    ll sum4=b*d;

    ll maxx=max(max(sum1,sum4),max(sum2,sum3));
    cout<<maxx<<endl;
}


Measured memory_bytes: 3652
#include<iostream>
//#include<string>
#include<vector>
#include<algorithm>
//#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int psn,mon,can,n;//ps:power source number,mon:motor number,can:cable number
	while(1){
		cin>>psn>>mon>>can;
		if(!psn && !mon && !can)break;
		int frac[psn+mon+can];
		rep(i,psn+mon+can)frac[i]=-1;//-1:??????????????£????????????
		cin>>n;
		vector<vector<int> > vec;
		rep(i,n){
			int check[3];
			bool logic;
			cin>>check[0]>>check[1]>>check[2]>>logic;
			if(logic){
				rep(j,3){
					frac[check[j]-1]=1;//1:??£???
				}
			}else{
				vector<int> alt;
				rep(j,3)alt.push_back(check[j]);
				vec.push_back(alt);
			}
		}
		rep(i,vec.size()){
			if(frac[vec[i][0]-1]==1 && frac[vec[i][1]-1]==1)frac[vec[i][2]-1]=0;//0:??????
			else if(frac[vec[i][1]-1]==1 && frac[vec[i][2]-1]==1)frac[vec[i][0]-1]=0;
			else if(frac[vec[i][2]-1]==1 && frac[vec[i][0]-1]==1)frac[vec[i][1]-1]=0;
		}
		rep(i,psn+mon+can){
			if(frac[i]==-1)cout<<2<<endl;
			else cout<<frac[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1292
require 'complex'
n, d = gets.split.map(&:to_i)
input_list = Array.new
n.times do |input|
  input = gets.split.map(&:to_i)
  input_list.push(input)
end
#p input_list
count=0
i = 0
while i < n - 1
  #print("i=#{i}\n")
  m = i + 1
  while m <= n - 1

    #k:計算中の要素のindexを入れる変数
    k = 0
    x = 0
    y = 0
    while k < d
      #print("i=#{i}, m=#{m}, k=#{k}\n")
      #print("#{input_list[i][k]} - #{input_list[m][k]}\n")
      x += (input_list[i][k] - input_list[m][k]) ** 2
      #p x
      k += 1
    end
    xr = Math.sqrt(x)
    #p xr

    if xr == xr.to_i
      count+=1
    end
  m += 1
end
i += 1
end
p count


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

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int N, M;
    cin >> N;
    vector<string> s(N);
    REP(i, N){
        cin >> s[i];
    }
    cin >> M;
    vector<string> t(M);
    REP(i, M){
        cin >> t[i];
    }

    int ans = 0;
    REP(i, N){
        int tmp = 0;
        REP(j, N){
            if(s[j] == s[i]) tmp++;
        }
        REP(j, M){
            if(t[j] == s[i]) tmp--;
        }
        ans = max(ans, tmp);
    }

    cout << ans;
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 256
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
ll dp[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
       ll n;
       cin>>n;
       ll h[100005];
       for(int i=1;i<=n;i++)
       cin>>h[i];
       for(int i=1;i<=n;i++)
       	dp[i]=hell;
       dp[1]=0;
       dp[2]=abs(h[2]-h[1]);
       for(int i=3;i<=n;i++)
       {
       	  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i]);
       	  dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i]);
       }
       cout<<dp[n];   
    }
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(1) {
    C -= B;
    if(C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if(A <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3616
words = lambda t : list(map(t, input().split()))
n,k = words(int)
a = words(int)
ans = 10 ** 9 
for i in range(n-k+1):
    l = a[i]
    r = a[i+k-1]
    #print(l,r, ans)
    if l < 0 and r <= 0:
        ans = min(ans, abs(l))
    elif l < 0 and r > 0:
        ans = min(ans, min(abs(l), r) * 2 + max(abs(l), r))
    else: # l >= 0 and r > 0
        ans = min(ans, r)

print(ans)


Measured memory_bytes: 14224
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,m,p,i;
    cin>>n>>m;
    ll y;
    vector<pair<int,ll>> v;
    set<int> pm;
    map<pair<int,ll>,string> ans;
    vector<ll> yrs[100001];
    for (i=0;i<m;i++)
    {
        cin>>p>>y;
        v.pb(mp(p,y));
        pm.insert(p);
        yrs[p].pb(y);
    }
    string a,b;
    for (int x: pm)
    {
        sort(yrs[x].begin(),yrs[x].end());
        for (i=0;i<yrs[x].size();i++)
        {
            a=to_string(x);
            b=to_string(i+1);
            string res=string(6-a.size(),'0')+a+string(6-b.size(),'0')+b;
            ans[mp(x,yrs[x][i])]=res;
        }
    }
    for (auto e: v)
        cout<<ans[e]<<endl;
}

Measured memory_bytes: 24176
package main

import "fmt"

func main() {
	var N, M, X int
	fmt.Scan(&N, &M, &X)
	var leftCost, rightCost int
	for i := 0; i < M; i++ {
		var A int
		fmt.Scan(&A)
		if A < X {
			leftCost++
		} else {
			rightCost++
		}
	}
	fmt.Println(min(leftCost, rightCost))
}

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

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);


int main() {
    string str;
    cin >> str;

    str.at(3) = '8';
    cout << str << endl;

    return 0;
}

// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 256
n, t = map(int, input().split())
a = [int(x) for x in input().split()]
lst = [0]
mina = a[0]
for i in range(1, n):
    mina = min(mina, a[i-1])
    lst.append(max(0, a[i]-mina))

lst.sort(reverse=True)
cnt = 1
for i in range(1, n):
    if lst[0] == lst[i]: cnt += 1
    else: break

print(cnt)

Measured memory_bytes: 20016
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest 119：B - Digital Gifts


def main():
    N = int(raw_input().strip())
    x = []
    for _ in range(N):
        instr = raw_input().strip().split(' ')
        if instr[1] == 'JPY':
            y=1
        else:
            y=0
        x.append((float(instr[0]), y))
    x.sort()
    # print x

    sumy = 0.0
    for xx in x:
        if xx[1] == 1:
            sumy += xx[0]
        else:
            sumy += xx[0] * 380000.0
    print sumy


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    ((ll)1ll<60)
#define INF     ((int)INT_MAX)
#define EPS     (1e-9)
#define MOD     (1000000007)
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool b=1;for(auto s:t)os<<(exchange(b,0)||strlen(abi::__cxa_demangle(typeid(S).name(),0,0,0))>20?"":" ")<<s;return os<<endl;}

struct segTree{
	vi val,lazy;
	vector<bool> lazyFlag;
	int N;
	segTree():segTree(100000){}
	segTree(int n){
		N=1;
		while(N<n)N*=2;
		val.resize(N*2,INF);
		lazy.resize(N*2,0);
		lazyFlag.resize(N*2,false);
	}
	
	void eval(int k, int l, int r){
		if(lazyFlag[k]){
			val[k]=lazy[k];
			if(r-l>1){
				lazy[2*k]=lazy[2*k+1]=lazy[k];
				lazyFlag[2*k]=lazyFlag[2*k+1]=true;
			}
			lazyFlag[k]=false;
		}
	}

	void update(int a, int b, int x){return update(a,b,1,0,N,x);}
	void update(int a, int b, int k, int l, int r, int x){
		eval(k,l,r);
		if(r<=a or l>=b) return;
		if(a<=l and r<=b) {
			lazy[k]=x;
			lazyFlag[k]=true;
			eval(k,l,r);
		}else{
			int m=(l+r)/2;
			update(a,b,2*k,l,m,x);
			update(a,b,2*k+1,m,r,x);
			val[k]=min(val[2*k],val[2*k+1]);
		}
	}
	
	int minimum(int a, int b){return minimum(a,b,1,0,N);}
	int minimum(int a, int b, int k, int l, int r){
		eval(k,l,r);
		if(r<=a or l>=b) return INF;
		if(a<=l and r<=b) return val[k];
		int m=(l+r)/2;
		return min(minimum(a,b,k*2,l,m),minimum(a,b,k*2+1,m,r));
	}	
	
	int getData(int k){return minimum(k,k+1);}
};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,q;
	while(cin>>n>>q){
		segTree st(n);
		rep(_,q){
			int c,s,t,x;
			cin>>c;
			if(c==0){
				cin>>s>>t>>x;
				st.update(s,t+1,x);
			} else {
				cin>>x;
				cout<<st.getData(x)<<endl;
			}
		}
	}
	return 0;
}
 



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

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		int n =sc.nextInt();
				for (int i = 0; i < n; i++) {
					BigInteger bint1 = sc.nextBigInteger();
					BigInteger bint2 = sc.nextBigInteger();
					bint1 = bint1.add(bint2);
						if (bint1.toString().length() > 80) {
							System.out.println("overflow");
						} else {
							System.out.println(bint1);
						}
				}

	}

}


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

int main() {
    ll k , l , r ;
    cin >> k >> l >> r ;

    ll res = k ;
    while(res<=r){
        if (res>=l and res<=r) {
            cout << "OK\n" ;
            return 0 ;
        }
        res+=k ;

    }
    cout << "NG\n" ;

    return 0 ;
}


Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int lcs(string x, string y)
{
	int m = x.size();
	int n = y.size();
	vector<vector<int>> dp(m, vector<int>(n));

	dp[0][0] = (x[0] == y[0]) ? 1 : 0;
	for (int i = 1; i < m; i++)
	{
		if (y[0] == x[i]) dp[i][0] = 1;
		else dp[i][0] = max(dp[i - 1][0], 0);
	}
	for (int i = 1; i < n; i++)
	{
		if (x[0] == y[i]) dp[0][i] = 1;
		else dp[0][i] = max(dp[0][i - 1], 0);
	}

	for (int i = 1; i < m; i++)
	{
		for (int j = 1; j < n; j++)
		{
			if (x[i] == y[j]) dp[i][j] = dp[i - 1][j - 1] + 1;
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	return dp[m - 1][n - 1];
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string x, y;
		cin >> x >> y;
		cout << lcs(x, y) << endl;
	}
}


Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{
	string s,t; cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	if (s < t)
		cout << "Yes\n";
	else
		cout << "No\n";
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N;
int main() {
    while (cin >> N) {
        vector<long long> A(N);
        long long sum = 0;
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
            sum += A[i];
        }
        cout << sum - N << endl;
    }
}































Measured memory_bytes: 256
a, b= map(int, input().split())
c = list(map(int, input().split()))
num = c.index(1)
left = num
right = a - left - 1
left_2 = left % (b - 1)
right_2 = right % (b - 1)
for i in range(b+1):
    if (left - i) % (b - 1) == 0:
        amari = (right - (b-1-i)) % (b - 1)
        kaisu_left = (left - i) // (b - 1)
        kaisu_right = (right - (b-1-i)) // (b - 1)
if amari == 0:
    print(kaisu_left + kaisu_right +1)        
if amari != 0:
    print(kaisu_left + kaisu_right +2)   

Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, M; cin >> N >> M;
    vector<int> s[M];
    vector<int> p(M);
    for(int i=0; i<M; i++){
        int k; cin >> k;
        for(int j=0; j<k; j++){
            int kk; cin >> kk; kk--;
            s[i].push_back(kk);
        }
    }
    for(int i=0; i<M; i++) cin >> p[i];

    int ans = 0;
    
    for(int bit=0; bit<(1<<N); bit++){
        int tmp = 0;
        for(int i=0; i<M; i++){
            int cnt = 0;
            for(int j=0; j<s[i].size(); j++) if(bit&(1<<s[i][j])) cnt++;
            if(cnt%2 == p[i]) tmp++;
        }
        if(tmp == M) ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	static int cnt;
	void doIt() {
		int n = sc.nextInt();
		int[] h = new int[n];
		int min = 101;
		cnt = 0;
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
			if(h[i] < min)min = h[i];
		}
		getAns(h, 0, n - 1, 0);
		System.out.println(cnt);
	}

	void getAns(int[] h, int l, int r, int d) {
		if(l > r)return;
		int min = 101, idx = -1;
		for(int i = l; i <= r; i++) {
			if(min > h[i]) {
				min = h[i];
				idx = i;
			}
		}
		cnt += min - d;
		if(min <= d)min = d;
		if(min - d == 0) d = 0;
		getAns(h, l, idx - 1, min);
		getAns(h, idx + 1, r, min);
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 23380
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'='|'>='|'>'|'<='|'<'='=')=>{for(let i=0;i<a.length;i+=2){if(op==='='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};

const main = ()=>{
  let [a,b,c]=nrin(3)
  out(min(a*b,c))
}
main()

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define set_zero(a) memset(a,0,sizeof(a));
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000000
#define INF 1000000 
#define M 1000000007
using namespace std;
int main(){
   fast_io
   ll n,x,t;
   cin>>n>>x>>t;
   ll ans = 0;
   while(true){
     if(n < x){
        break;
     }
     else{
        n = n-x;
        ans += t;
     }
   }
   if(n > 0){
      ans += t;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3656
def prime_table(n):
  list = [True for _ in xrange(n + 1)]
  i = 2
  while i * i <= n:
    if list[i]:
      j = i + i
      while j <= n:
        list[j] = False
        j += i
    i += 1

  table = [i for i in xrange(n + 1) if list[i] and i >= 2]
  return table

table = prime_table(999999)
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
        
    m = 0
    for i in table:
        if i<=n:
            m+=1
        else:
            break
    print m

Measured memory_bytes: 14452
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#include <queue>
#define ll long long
using namespace std;

int main() {
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    while (a > 0 && c > 0) {
        c -= b;
        if (c <= 0) {
            cout<<"Yes";
            return 0;
        }
        a -= d;
    }
    if (a <= 0) {
        cout<<"No";
    }
}


Measured memory_bytes: 3672
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 5e5 + 20;
int n, a[N], b[N], mx[N];
string s;

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

	cin >> s;

	n = _sz(s);

	for (int i = 0; i < n; i++) a[i] = s[i] - '0';

/*
	bool fin = 0;

	while (!fin)
	{
		fin = 1;
		for (int i = 0; i < n - 1; i++)
		{
			if (a[i] <= a[i + 1]) continue;
			fin = 0;
		
			int y = (a[i] - a[i + 1] + 10) / 11;

			a[i] -= y;
			a[i + 1] += 10 * y;
		}
	}

	cout << '\t' << a[n - 1] << ' ' << a[n - 2] << '\n';

	cout << (a[n - 1] + 8) / 9 << '\n';;
*/

	int low = 0, high = N;

	while (high - low > 1)
	{
		for (int i = 0; i < n; i++) b[i] = a[i];

		int mid = (low + high) / 2;

		bool ok = 1;

		for (int i = n - 1; i >= 0; i--)
		{
			if (i == n - 1) mx[i] = 9 * mid;
			else mx[i] = mx[i + 1];

			int k = (mx[i] % 10 + 10) % 10;
			k = mx[i] - k;
			k += (a[i] % 10 + 10) % 10;

			if (k > mx[i]) k -= 10;

			mx[i] = k;

			assert((mx[i] - a[i]) % 10 == 0);

			if (mx[i] < a[i])
			{
				ok = 0;
				break;
			}

			a[i - 1] -= (mx[i] - a[i]) / 10;
			a[i] = mx[i];
		}

		if (ok) high = mid;
		else low = mid;

		for (int i = 0; i < n; i++) a[i] = b[i];
	}

	cout << high << '\n';
}


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

int main() {
  int N;
  cin >> N;
  int n = N;
  int sum = 0;
  
  while(n > 0) {
    sum += (n % 10);
    n /= 10;
  }
  if(N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        s: [chars;n],
    }

    let mut c0 = 0;
    let mut c1 = 0;
    let mut c2 = 0;
    let mut c3 = 0;

    for result in s {
        let mut result_st: String = result.iter().collect();
        if result_st=="AC" {
            c0 += 1;
        } else if result_st=="WA" {
            c1 += 1;
        } else if result_st=="TLE" {
            c2 += 1;
        } else if result_st=="RE" {
            c3 += 1;
        }
    }

    println!("AC x {}", c0);
    println!("WA x {}", c1);
    println!("TLE x {}", c2);
    println!("RE x {}", c3);

}

Measured memory_bytes: 7604
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(_, b) = readLine.trim.split(' ').map(_.toInt)
  println(
    b * b * b * math.Pi / 3 * 4
  )

  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 44204
//In The Name of Beauty
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 1e2 + 8;
ll const INF  = 1e12 + 8;
ll const delta = 1000000007;
int main()
{
    IB;
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vll temp;
    ll t;
    for(ll i = 0;i < n;i++){
        cin >> t;
        temp.pb(t);
    }
    vll ans;
    while(temp.size()){
        t = -1;
        for(ll i = 0;i < temp.size();i++){
            if(temp[i] == i + 1)t = i;
        }
        if(t == -1)return cout << -1,0;
        ans.pb(temp[t]);
        temp.erase(temp.begin() + t);
    }
    for(ll i = ans.size() - 1;i >= 0;i--)cout << ans[i] << endl;
    return 0;
}
//Written by M_H_H_7


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

int main() {
  int N; cin >> N;
  vector<tuple<int, int, int>> v(N);
  for (int i = 0; i < N; i ++) {
    int x, y, h;
    cin >> x >> y >> h;
    v.at(i) = make_tuple(h, x, y);
  }
  sort(v.begin(), v.end(), greater<tuple<int, int, int>>());
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      bool flag = true;
      int h = abs(get<1>(v.at(0))-i) + abs(get<2>(v.at(0))-j) + get<0>(v.at(0));
      for (int k = 1; k < N; k++) {
        int tmp = max(h - abs(get<1>(v.at(k))-i) - abs(get<2>(v.at(k))-j), 0);
        if (tmp != get<0>(v.at(k))) flag = false;
      }
      if (flag) {
        cout << i << " " << j << " " << h << endl;
        return 0;
      }
    } 
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
string s;
int main()
{
    cin>>s;
    if(s!="AAA"&&s!="BBB")cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdin=new Scanner(System.in);
		int k=stdin.nextInt();
		int x=stdin.nextInt();
		int kotae[]=new int[1000000];
		int t=0;
		int j=x-k+1;
//		for(int i=(x-k+1);i<(k*2-1);i++) {
//			kotae[t]=i;
//			j++;
//			t++;
//		}
//		for(int i=0;i<(k*2-1);i++)
//			System.out.print(kotae[i]);
		for(;;) {
			//j=x-k+1;
			kotae[t]=j;

			if(t>=(k*2-1)) break;
			j++;
			t++;
		}
		for(int i=0;i<t;i++) System.out.printf("%d ",kotae[i]);
	}

}


Measured memory_bytes: 26580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
    
  cin >> a >> b;
  
  if(a % 2 == 1 && b % 2 == 1){
    cout << "Odd" << endl;
  }else{
    cout << "Even" << endl;
  }
    
}


Measured memory_bytes: 256
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 1000000 //10^6:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define PN 1 //素数のマークは1

//MAXR(=10^6)までの整数が素数であると仮定する
vector<ll> PN_chk(MAXR+1,PN);//0indexでi番目が整数iに対応(0~MAXR)


//O(MAXR)
void se(){
    ll MAXRR=sqrt(MAXR)+1;
    //2以上の数の素因数分解をするので無視して良い
    PN_chk[0]=0;PN_chk[1]=0;
    FOR(i,2,MAXRR){
        //たどり着いた時に素数と仮定されているなら素数
        //ある素数の倍数はその素数で割り切れるのでマークづけ
        if(PN_chk[i]==1) FOR(j,i,ll(MAXR/i)){PN_chk[j*i]=i;}
    }
}

vector<ll> check(MAXR+1,0);

//O(logn)
//primeはこの場合は整列されてないので注意！！！
//一回のみのcheck
map<ll,ll> prime;

void prime_factorize(ll n){
    if(n<=1) return;
    //1の場合はnは素数
    if(PN_chk[n]==1){prime[n]+=1;return;}
    //マークされている数は素数
    prime[PN_chk[n]]+=1;
    //マークされている数でnを割った数を考える
    prime_factorize(ll(n/PN_chk[n]));
}

ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
    //xの方が常に大きい
    ll r;
    while(y>0){
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}

signed main(){
    se();
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll n;cin>>n;
    vector<ll> a(n);REP(i,n)cin>>a[i];
    //check二回つくか
    REP(i,n){
        prime_factorize(a[i]);
        FORA(j,prime){
            check[j.F]++;
        }
        prime.clear();
    }
    ll g=gcd(a[0],a[1]);
    FOR(i,2,n-1){
        g=gcd(g,a[i]);
    }
    REP(i,MAXR+1){
        if(check[i]>=2){
            if(g==1){
                cout<<"setwise coprime"<<endl;
            }else{
                cout<<"not coprime"<<endl;
            }
            return 0;
        }
    }
    cout<<"pairwise coprime"<<endl;
}


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

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> vec(1e5+1, 0);
  for (ll i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    ++vec[a];
  }

  ll q;
  cin >> q;

  ll vsum = 0;
  for (ll j = 1; j <= 1e5+1; ++j)
    vsum += j * vec[j];

  for (ll i = 0; i < q; ++i) {
    ll b, c;
    cin >> b >> c;
    vsum -= vec[b] * b;
    vsum += vec[b] * c;
    vec[c] += vec[b];
    vec[b] = 0;
    cout << vsum << endl;
  }
}

Measured memory_bytes: 4028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		scan.close();
		if(x < r || y < r || x > W - r || y > H - r) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 26312
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve()
{
	int n,k;
	cin>>k>>n;
	vector<int> ar(2*k),prefix(2*k);
	for(int i=0;i<n;i++)
	{
		int temp;
		cin>>temp;
		temp%=k;
		ar[temp]=1;
		ar[temp+k]=1;
	}
	prefix[0]=ar[0];
	for(int i=1;i<2*k;i++)
		prefix[i]=prefix[i-1]+ar[i];
	// for(auto i:prefix)
	// 	cout<<i<<" ";
	// cout<<"\n";
	int ans=1e13;
	// ans,min length
	unordered_map<int,int> mp;
  mp.reserve(1024);
  mp.max_load_factor(0.25);
	for(int i=0;i<2*k;i++)
	{
		mp[prefix[i]]=i;
		if(prefix[i]>=n && mp.count(prefix[i]-n))
			ans=min(ans,i-mp[prefix[i]-n]);
	}
	//ans=min(ans,k-ans);
	cout<<ans-1;
}
int32_t main()
{
    _FAST
    int t;
    t=1;
    while(t--)
        solve();
    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/


Measured memory_bytes: 73704
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n:usize = read();
    let arr:Vec<i32> = (0..n).map(|_| read()).collect();
    selection_sort(arr, n);
}

fn selection_sort(mut a:Vec<i32>, n:usize)->() {
    let mut cnt = 0;
    for i in 0..n {
        let mut min = i;
        for j in i..n {
            if a[j] < a[min] {
                min = j;
            }
        }
        if a[i] != a[min] {
            a.swap(i, min);
            cnt += 1;
        }
    }
    println!("{}", a.into_iter()
        .map(|x| x.to_string())
        .collect::<Vec<String>>()
        .join(" "));
    println!("{}", cnt);
}


Measured memory_bytes: 5036
/*Bismillahir Rahmanir Raheem*/

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

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;

// defined for taking input
#define gl(x) getline(cin, x)
#define sf scanf
#define sfi(x) scanf("%d", &x)
#define sfc(x) scanf("%c", &x)
#define sfl(x) scanf("%lld", &x)
#define sflu(x) scanf("%llu", &x)
#define sfii(x, y) scanf("%d %d", &x, &y)
#define sfll(x, y) scanf("%lld %lld", &x, &y)
#define sfiii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sflll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)

//defined for printing
#define pf printf
#define pfn pf("\n")
#define pfcas pf("Case %d: ", cas)
#define pfyes pf("YES");
#define pfno pf("NO");
#define pfi(x) pf("%d", x)
#define pfl(x) pf("%lld", x)

//defined for loop

//increament
#define loopi(i, j, k) for (int i = j; i < k; i++)
#define loopl(i, j, k) for (ll i = j; i < k; i++)
#define loopc(i, j, k) for (char i = j; i < k; i++)
#define looplu(i, j, k) for (ull i = j; i < k; i++)
//decreament
#define loopri(i, j, k) for (int i = j; i > k; i--)
#define looprl(i, j, k) for (ll i = j; i > k; i--)
#define looprlu(i, j, k) for (ull i = j; i > k; i--)
#define looprc(i, j, k) for (char i = j; i > k; i--)
#define wa(t) while (t--)

//testcases
#define testc(t) for (char cas = 1; cas <= t; cas++)
#define testi(t) for (int cas = 1; cas <= t; cas++)
#define testl(t) for (ll cas = 1; cas <= t; cas++)

//some cmd
#define pb push_back
#define ppb pop_back
#define mp make_pair

//code start

int main()
{
    // freopen("/home/grimfirefly/Programming/input.txt","r",stdin);
    // freopen("/home/grimfirefly/Programming/output.txt","w",stdout);
    int n,k;
    sfii(n,k);
    ll H[n];
    loopi(i,0,n){
        sfl(H[i]);
    }
    if(k>=n)
    return pf("0\n"),0;
    if(!k)
       return pfl(accumulate(H,H+n,0LL)),pfn,0;

    sort(H,H+n);
    pfl(accumulate(H,H+(n-k),0LL));
    pfn;
    return 0;
}

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

int main() {
  string S;
  cin>>S;
  int a=S.size();
  int ans=0;
  
    for(int i=0;i<a/2;i++){
      if(S[i]!=S[a-1-i]) ans++;
    }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
W=gets.split[~c=0].to_i+1
s=$<.read
b,w=[?0,?1].map{|t|s.tr('#
.','10'+t).to_i 2}
(b|=b*2|b/2|b>>W|b<<W
b&=w
c+=1)while b<w
p c

Measured memory_bytes: 91084
import sys
def main():
    n = int(input())
    d = ""
    while len(d) != n:
        d += "".join(input().split())
    digits = set()
    for i in range(n):
        for j in range(i+1,n+1):
            # print(i,j)
            seq = d[i:j]
            if not seq:
                continue
            digits.add(int(seq))
    digits = sorted(list(digits))
    for i in range(digits[-1]+1):
        if i != digits[i]:
            print(i)
            return
            

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
    int n; cin >> n;
    
    int a[1050];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    bool flag = false;
    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 0 ){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                flag = true;
            }
        }
    }
    if(flag) puts("DENIED");
    else puts("APPROVED");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		System.out.println(gcd(x, y));
		sc.close();
	}

	public static int gcd(int a, int b) {
		int v = a % b;
		if (v == 0) {
			return b;
		} else {
			return gcd(b, v);
		}
	}
}



Measured memory_bytes: 26132
#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(void)
{
    int64_t k,i,ans;
    string n;

    k = 0;

    cin >> n;

    for(i=0;i<n.size();i++){
        k += (n[i] - '0');
    }

    if(k%9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
V<int> v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    v.pb(a);
  }
  uniq(v);
  cout << sz(v) << endl;
}

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

int main(){
  int n; cin >> n;
  int ans = 1;
  for(int i = 2; i * i <= n; i++){
    int cnt = i;
    while(cnt <= n){
      cnt *= i;
    }
    ans = max(ans, cnt/i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
static const int MOD = 10000007;
static const int MAX = 100005;
// static const int NMAX = 5005;

// typedef priority_queue<int, greater<int>> RevQ;
int N, L;
// vector<ll> a(MAX);



int main(){
  cin >> N;
  if (N%2 == 0) {
    cout << 1/2.0 << endl;
  } else {
    cout << (float)(N+1)/(2.0*N) << endl;
  }
}


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

int main()
{
	int A,B;
	cin >>A >>B;
	if(A>B){
		cout <<2*A-1;
	}else if (A<B){
		cout <<2*B-1;
	}else {
		cout <<A+B;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <fstream>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> stones(n);
	for(int i=0; i<n;i++)
	{
		cin>>stones[i];
	}
	vector<int> cost(n,INT_MAX);
	cost[0] = 0;
	for(int i = 0; i<n ;i++)
	{
		for(int j = i+1; j<=i+k; j++ )
		{
			if(j<n)
			{
				cost[j] = min(cost[j] , cost[i] + abs(stones[i] - stones[j]));
			}
		}
	}
	cout<<cost[n-1];
    return 0;
}

Measured memory_bytes: 1024
fn main(){
  let n = read();
  let mut dv: Vec<usize> = Vec::new();

  for _ in 0 .. n {
    dv.push(read());
  }

  let mut r : usize = 0;

  for i in 0 .. n - 1 {
    if i > r { break; }

    let t = if dv[i] / 10 + i < n { dv[i] / 10 + i } else { n - 1 };
    if t > r { r = t; }
  }

  let mut l : usize = n - 1;
  
  for i in (1 .. n).rev() {
    if i < l { break; }

    let t = if i >= dv[i] / 10 { i - dv[i] / 10 } else { 0 };
    if t < l { l = t; }
  }
  
  println!("{}", if l == 0 && r == n - 1 { "yes" } else { "no" });
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}



Measured memory_bytes: 9956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    int n = s.length() + 1;
    vector<int> a(n);
    rep(i,n-1){
        if(s[i] == '<'){
            a[i+1] = max(a[i+1], a[i]+1);
        }
    }
    
    for (int i = n-1; i >= 0; i--)
    {
        if(s[i] == '>'){
            a[i] = max(a[i], a[i+1]+1);
        }
    }
    ll ans = 0;
    rep(i,n){
        ans += a[i];
    }
    cout << ans << endl;
    
    return 0;
}

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

int main()
{
	int r = 0 , c = 0 , i = 0 , j = 0 , box[256][256];
	cin >> r >> c ;
	for ( i = 0 ; i < r ; i ++ )
	{
		for ( j = 0 ; j < c ; j++ )
		{
			cin >> box[i][j] ;
			box[i][c] += box[i][j] ;
			box[r][j] += box[i][j] ;
			if ( i == r-1 ) box[r][c] += box[r][j] ;
		}
	}
	for ( int i2 = 0 ; i2 <= r ; i2++ )
	{
		for ( int j2 = 0 ; j2 <= c ; j2++ )
		{
			cout << box[i2][j2] ;
			if ( j2 != c ) cout << " " ;
			else cout << endl ;
		}
	}
	return 0;
}



Measured memory_bytes: 3172