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

using namespace std;

int main() {
    string s1, s2;
    cin >> s1 >> s2;

    for (auto i = s1.begin(); i != s1.end(); ++i) {
        auto j = s2.begin();
        auto k = i;
        while (j != s2.end() && k != s1.end()) {
            if (*k != *j) {
                break;
            }
            ++k; ++j;
        }
        if (j == s2.end()) {
            cout << distance(s1.begin(), i) << endl;
        }
    }

    return 0;
}

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

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

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

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

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    let mut pairs = vec![];
    for _ in 0..n {
        let (x, y): (i64, i64) = (sc.input(), sc.input());
        pairs.push((x, y));
    }

    let mut x_plus_y = vec![];
    let mut x_minus_y = vec![];
    for (x, y) in &pairs {
        x_plus_y.push(x + y);
        x_minus_y.push(x - y);
    }

    let x_plus_y_max = x_plus_y.iter().max().unwrap();
    let x_plus_y_min = x_plus_y.iter().min().unwrap();
    let x_minus_y_max = x_minus_y.iter().max().unwrap();
    let x_minus_y_min = x_minus_y.iter().min().unwrap();
    println!("{}", std::cmp::max(x_plus_y_max - x_plus_y_min, x_minus_y_max - x_minus_y_min));
}


Measured memory_bytes: 8540
n=int(input())
t=[[0 for i in range(10)]for j in range(10)]
for i in range(1,n+1):
  i=str(i)
  t[int(i[0])][int(i[-1])]+=1
  
ans=0
for i in range(10):
  for j in range(10):
    ans+=t[i][j]*t[j][i]
    
print(ans)

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

int gcd(int a, int b){
  if (b == 0) {return a;}

  return gcd(b, a % b);
}

int main(){
  int K;
  int a, c;
  int sum = 0;

  cin >> K;

  for (int i = 1; i < K + 1; i++){
    for (int j = 1; j < K + 1; j++){
      for (int k = 1; k < K + 1; k++){
        a = gcd(i,j);
        c = gcd(k,a);
        sum += c;
      }
    }
  }

  cout << sum << endl;

  return 0;


}


Measured memory_bytes: 3568
import java.util.Scanner;

/**
 * @author xushengbo
 */

public class Main {
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        if (K * 2 - 1 <= N) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 23252
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,k,a[200005];
int main(){
    scanf("%d%d",&n,&k);
    if(k==1||k==n*2-1)puts("No");
    else{
        puts("Yes");
        int _=2;
        for(int i=1;i<=n*2-4;++i){
            if(_==k)++_;
            a[i]=_++;
        }
        for(int i=1;i<n-1;++i)printf("%d\n",a[i]);
        printf("1\n%d\n%d\n",k,n*2-1);
        for(int i=n-1;i<=n*2-4;++i)printf("%d\n",a[i]);
    }
    //system("pause");
    return 0;
}


Measured memory_bytes: 2304
<?php

class main{
    public function main(){
        fscanf(STDIN,"%d",$k);
        $a = 7%$k;
        if($k==2){
            echo "-1\n";
            return 0;
        }
        for($i=1;$i<=$k;$i++){
            if($i>1000001){
                echo "-1\n";
                return 0;
            }
            if($a===0){
                echo $i."\n";
                return 0;
            }
            $a=$a*10+7;
            $a%=$k;
        }
        echo "-1\n";
    }
}
new main();

Measured memory_bytes: 16232
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a == b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main argv =
    let [|a;b|] = reads int
    if b % a = 0
    then printfn "%i" (a + b)
    else printfn "%i" (b - a)
    0

Measured memory_bytes: 11996
import numpy as np

n,m = map(int,input().split())
arr = list(map(int,input().split()))
d = {}

snake = [0 for i in range(n)]

temp = 0
for i in range(n):
    temp += arr[i]
    temp %= m
    snake[i] = temp

# print(snake)

def sig(n):
    return n*(n+1)//2

for a in snake:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1

ans = 0
# print(d)
if 0 in d:
    ans += d[0]
for k in d.keys():
    ans += sig(d[k]-1)

print(ans)


Measured memory_bytes: 25912
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



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

	//input
	int n, m;
	cin >> n >> m;

	vector<int> a;
	for (int i = 0; i < m; i++){
		int ai;
		cin >> ai;
		a.push_back(ai);
	}


	//calc
	int prev = 0;
	int ans = 1;
	int m_index = 0;
	for (int i = 0; i < n; i++){
		if (m_index < m && i + 1 == a[m_index]){
			prev = ans;
			ans = 0;

			m_index++;
		}
		else{
			int next_ans = (prev + ans) % 1000000007;
			prev = ans;
			ans = next_ans;
		}

	}



	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 892
// in the name of Allah ;
#include<bits/stdc++.h>
using namespace std ;
int main ()
{
	string s ;
	cin >> s ;
	for ( int i = 0 ; i < s.size() ; i++ )
		if ( s[i] == ',' ) 
			cout << " " ;
		else
			cout << s[i] ;
	cout << endl;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a,b;
	a=(s[0]-'1'+1)*10+s[1]-'1'+1;
	b=(s[2]-'1'+1)*10+s[3]-'1'+1;
	if(b<=12&&a<=12&&b>0&&a>0){
		cout<<"AMBIGUOUS";
	}else if(b<=12&&b>0){
		cout<<"YYMM";
	}else if(a<=12&&a>0){
		cout<<"MMYY";
	}else{
		cout<<"NA";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b,c;
    cin>>a>>b>>c;
    a-=b;
    if(c>a)
        cout<<c-a<<endl;
    else
        cout<<"0"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int W[10010], S[10010];
ll V[10010];
ll dp[1010][20010];
int idx[10010];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		cin >> W[i] >> S[i] >> V[i];
		idx[i] = i;
	}
	sort(idx, idx + N, [&](int a, int b) {
			return W[a] + S[a] < W[b] + S[b];
			});
	// debug(vi(idx, idx + N));

	dp[0][0] = 0;
	rep(i, 0, N) {
		int v = idx[i];
		rep(j, 0, 20000 + 1) {
			if(j <= S[v] && j + W[v] <= 20000) {
				MAX(dp[i + 1][j + W[v]], dp[i][j] + V[v]);
			}
			MAX(dp[i + 1][j], dp[i][j]);
		}
	}
	ll res = 0;
	rep(j, 0, 20000 + 1) {
		MAX(res, dp[N][j]);
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 157824
#include <iostream>
using namespace std;
int main() {
  int N, C[501], S[501], F[501];
  cin >> N;
  for (int i = 1; i <= N-1; i++)
    cin >> C[i] >> S[i] >> F[i];
  for (int i = 1; i <= N; i++) {
    int time = 0;
    for (int j = i; j <= N-1; j++) {
      int tempS = S[j];
      while(1) {
	if (time <= tempS) {
	  time = tempS + C[j];
	  break;
	}
	else
	  tempS += F[j];
      }
    }
    cout << time << endl;
  }
  return 0;
}


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

int main()
{
    int m;
    int n;
    
    cin >>m>>n;
    
    int b[m+1][n+1]={0};
    int d=0;
    for (int i=0;i<m;i++){
        int c=0;
        for (int j=0;j<n;j++){
            cin>>b[i][j];
            c+=b[i][j];
        }
        
        b[i][n]=c;
        d+=c;
    }
    
    for (int i=0;i<n;i++){
        int c=0;
        
        for (int j=0;j<m;j++){
            
            c+=b[j][i];
        }b[m][i]=c;
        
    }b[m][n]=d;
    
    for (int i=0;i<m+1;i++){
        for (int j=0;j<n+1;j++){
            cout<< b[i][j];
            if (j!=n){
                cout << " ";
            }
            
        }cout<<endl;
    }
    
   
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int N, D, X; cin >> N >> D >> X;
	int ans = X;
	for (int i = 0; i < N; i++) {
		int tmp; cin >> tmp;
		ans += D / tmp;
		if (D % tmp != 0) ans++;
	}
	cout << ans << endl;


	return 0;
}

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

int main(){
   int k;
   cin>>k;
   vector<int> d={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   k--;
   cout<<d[k]<<endl;
}

Measured memory_bytes: 3604
def solve():
    a, b = map(int, input().split())
    if a == b:
        return a
    elif abs(a - b) % 2 == 0:
        return int(min(a, b) + (max(a, b) - min(a, b)) / 2)
    else:
        return "IMPOSSIBLE"


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
unsigned long long n,m,nd;
int main()
{
    cin>>n>>m;
    nd=2*n;
    if(nd>m)
    {
        cout<<(m>>1)<<endl;
        return 0;
    }
    else if(nd==m)
    {
        cout<<n<<endl;
        return 0;
    }
    else
    {
        m-=nd;
        m/=4;
        cout<<n+m<<endl;
        return 0;
    }
}

Measured memory_bytes: 764
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int ans = INF;
    int n;
    cin >> n;
    rep(i, n)
    {
        int tmp;
        int tmp_ans = 0;
        cin >> tmp;
        while ((tmp % 2) == 0)
        {
            tmp_ans++;
            tmp /= 2;
        }
        ans = min(ans, tmp_ans);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// 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<<" ";
    }
    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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    string ans="";
    if(a+b+c>=22){
        ans="bust";
    }else{
        ans="win";
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if (op=='?') break;
        if (op=='+'){
            printf("%d\n",a + b);
        } else if (op=='-'){
            printf("%d\n",a - b);
        } else if (op=='*'){
            printf("%d\n",a * b);
        } else if (op=='/'){
            printf("%d\n",a / b);
        }
    }
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



int main() {
    int A,P;
    cin >> A >> P;
    cout << (A*3+P)/2 << endl;

}



Measured memory_bytes: 256
from sys import stdin
import bisect
def main():
    #入力
    readline=stdin.readline
    inf=10**18
    a,b,q=map(int,readline().split())
    s=[int(readline()) for _ in range(a)]
    s.insert(0,-inf)
    s.append(inf)
    t=[int(readline()) for _ in range(b)]
    t.insert(0,-inf)
    t.append(inf)
    x=[int(readline()) for _ in range(q)]

    for i in range(q):
        j=bisect.bisect_left(s,x[i])
        k=bisect.bisect_left(t,x[i])
        s_i=(s[j-1],s[j])
        t_i=(t[k-1],t[k])
        ans=float("inf")
        for u in s_i:
            for v in t_i:
                ans=min(ans,abs(u-x[i])+abs(v-u))

        for v in t_i:
            for u in s_i:
                ans=min(ans,abs(v-x[i])+abs(u-v))

        print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 16168
#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() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, w, k; cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(is, 1<<h) rep(js,1<<w) {
        int cnt = 0;
        rep(i,h) rep(j, w) {
            if (is>>i&1) continue;
            if (js>>j&1) continue;
            if (s[i][j] == '#') cnt++;
        }
        if (cnt == k) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

struct UnionFind {
	UnionFind(int n) {
		par = new int[n + 1];
		size = new int[n + 1];
		height = new int[n + 1];
		for (int i = 0; i <= n; ++i) {
			par[i] = i;
			size[i] = 1;
			height[i] = 1;
		}
	}

	void unite(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) return;
		if (height[a] < height[b]) {
			par[a] = b;
			size[b] += size[a];
		}
		else {
			par[b] = a;
			size[a] += size[b];
			if (height[a] == height[b]) {
				height[a]++;
			}
		}

	}

	int root(int a) {
		return par[a] == a ? a : par[a] = root(par[a]);
	}

	int getSize(int a) {
		return size[root(a)];
	}

	bool isSame(int a, int b) {
		return root(a) == root(b);
	}

	int* size;
	int* height;
	int* par;
};

void dfs(UnionFind& uf, vector<vector<int>>& tree, int a, int b) {

}

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

	ll n,x; cin >> n >> x;

	ll layer = 1;
	vector<ll> p(n+1); p[0] = 1;
	rep(i,n) { layer = 2*layer + 3; p[i+1] = 2*p[i] + 1; }
	

	ll l = 1, r = layer + 1, level = n;
	ll ans = 0;
	while (level >= 0) {
		ll mid = (l + r) / 2;
		if (x < l) break;
		if (r <= x) { ans += p[level]; break; }
		if (level == 0 && l == x) { ans++; break; }

		if (mid == x) { ans += p[level - 1] + 1; break; }
		if (mid < x) { l = mid + 1; r--; ans += p[level - 1] + 1; }
		else { r = mid; l++; }
		level--;
	}
	cout << ans << endl;

}

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    long int h;
    cin >> h;
    long int num = 1;
    long int ans = 0;
    while(h > 0){
        ans += num;
        h /= 2;
        num *= 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v.at(i);
  
  sort(v.begin(), v.end());
  double ans = v.at(0);
  for(int i = 1; i < n; i++){
    ans = (ans + v.at(i))/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

int main() {
  ll n;
  cin >> n;
  string s = to_string(n);
  ll sum=0;
  rep(i, s.size()){
    sum += stoi(to_string(s[i]))-48;
  }
  if(n%sum==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	ll a, b, c, d, k;
	cin >> a >> b >> c >> d;
	k = max(0ll, (a - c) / b - 1ll);
	a -= k * b;
	if (a - b > c) {
		a -= b;
	}
	if (a < b) {
		cout << "No" << endl;
		return;
	}
	if (b > d) {
		cout << "No" << endl;
		return;
	}
	if (b == d) {
		cout << "Yes" << endl;
		return;
	}
	ll g = gcd(b, d);
	k = max(0ll, (a - c) / g - 1);
	a -= k * g;
	if (a - g > c) {
		a -= g;
	}
	if (a < b) {
		cout << "No" << endl;
		return;
	}
	cout << "Yes" << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    cin >> t;
    while(t--){
        solve();    
    }
}


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

const int maxn=1e6+7,mod=1e9+7;
LL fac[maxn],inv[maxn],f[maxn];
int n,siz[maxn];
vector<int> to[maxn];

LL poww(LL a,LL b)
{
	LL ans=1;
	while(b) {
		if(b&1) ans=(ans*a)%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}

void dfs(int x,int fa)
{
	siz[x]=1;
	for(int i=0;i<to[x].size();++i) {
		int t=to[x][i];
		if(t==fa) continue;
		dfs(t,x);
		siz[x]+=siz[t];
	}
}

void dfs2(int x,int fa)
{
	for(int i=0;i<to[x].size();++i) {
		int t=to[x][i];
		if(t==fa) continue;
		f[t]=(f[x]*siz[t]%mod)*inv[n-siz[t]]%mod;
		dfs2(t,x);
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i) {
		int a,b;
		scanf("%d %d",&a,&b);
		to[a].push_back(b);
		to[b].push_back(a);
	}
	fac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<maxn;++i) fac[i]=fac[i-1]*i%mod;
	for(int i=2;i<maxn;i++) inv[i]=inv[mod%i]*(mod-mod/i)%mod;
	dfs(1,0);
	f[1]=fac[n];
	for(int i=1;i<=n;++i) 
		f[1]=(f[1]*inv[siz[i]])%mod;
	dfs2(1,0);
	for(int i=1;i<=n;++i) printf("%lld\n",f[i]);
}

Measured memory_bytes: 53876
#include <bits/stdc++.h>
#define int signed long long
using namespace std;

signed main(void) {
    int n;
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
    }

    sort(s.begin(), s.end());
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += s.at(i);
    }
    bool ok = true;
    if (sum % 10 == 0) {
        for (int i = 0; i < n; i++) {
            if (s.at(i) % 10 != 0) {
                sum -= s.at(i);
                ok = true;
                break;
            } else {
                ok = false;
            }
        }
    }

    if (ok) {
        cout << sum << endl;
    } else {
        cout << 0 << endl;
    }
}

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

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> distances;
  for (int i = 0; i < n-1; i++) {
    int tmp;
    cin >> tmp;
    distances.push_back(tmp);
  }

  int move_sum = 0, pos = 0;
  for (int i = 0; i < m; i++) {
    int move;
    cin >> move;
    if (move > 0) {
      while (move--) {
        move_sum += distances[pos];
        pos++;
      }
    } else {
      move *= -1;
      while (move--) {
        pos--;
        move_sum += distances[pos];
      }
    }
    move_sum %= 100000;
  }

  cout << move_sum << endl;
  return 0;
}

Measured memory_bytes: 1676
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	char o[50], e[50];
	scanf("%s%s", o, e);
	rep(i, strlen(e)) {
		printf("%c%c", o[i], e[i]);
	}
	if (strlen(o) - strlen(e))printf("%c", o[strlen(o) - 1]);
	printf("\n");

	return 0;
}


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

int main(){
  int x,y;
  cin>>x>>y;
  if((x==1||x==3||x==5||x==8||x==7||x==10||x==12) && (y==1||y==3||y==5||y==8||y==7||y==10||y==12)){
    cout<<"Yes"<<endl;
  }
  else if ((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
    cout<<"Yes"<<endl;
  }
  else if(x==2 &&y==2){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  string S;cin>>S;
  REP(i,S.length()) {
    cout << 'x';
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define lu unsigned long long int
#define pi pair<ll, ll>
#define pll pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define vll ve<ll>
#define vpl ve<pll>
#define lr(n) for(ll i = 0; i < n; i++)
#define ltr(i, l, r) for (ll i = l; i <= r; i++)
#define rtl(i, l, r) for (ll i = r; i >= l; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define be begin
#define sz(a) (ll)(a.size())
#define con continue
#define ret return
#define endl "\n"
const ll INF = 1e18;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

// ll gcd(ll a, ll b){
// 	return b == 0 ? a : gcd(b, a % b);
// }

// ll mod = 1e9+7;

// ll mult(ll x, ll y){
//     ll rem=1;
//     while(y){
//         if(y&1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y>>=1;
//     }
//     return rem;
// }


void solve(ll T){
	ll k;
	cin>>k;
	string s = "ACL";
	string t = "";
	for(ll i=0;i<k;i++) t += s;
	cout << t << "\n";	
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// std::cout << std::unitbuf;
	ll T=1;
	// cin>>T;
	for(ll t=1;t<=T;t++){
		solve(t);
	}
	return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main(void)
{
	int h1,h2,k1,k2,a,b,c,d,h,k,na,nb;
	scanf("%d %d %d %d %d %d %d %d",&h1,&h2,&k1,&k2,&a,&b,&c,&d);
	na=h1/10*c;
	nb=h2/10*b;
	h=h1*a+h2*b+h1/10*c+h2/20*d;
	na=k1/10*c;
	nb=k2/10*b;
	k=k1*a+k2*b+k1/10*c+k2/20*d;
	if(h>k){
	printf("hiroshi\n");
	}
	else	if(h<k){
	printf("kenjiro\n");
	}
	else	{
	printf("even\n");
	}
	return 0;
	}
	
	



Measured memory_bytes: 2620
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;

# define pi           3.14159265358979323846 

int ll26(ll num,vector<ll>& a){
  int i = 0;
  ll L = 26;
  while( num > 0 ) {
    a[i++] = num % L;
    num /= L;
  }
  return i;
}
string calc(ll n){
  vector<ll> a(100,0);
  if( n <= 26 ) {
    string ret;
    char c  = 'a' + n - 1;
    ret += c;
    return ret;
  }
  int len = ll26(n,a);
  string ret = "";
  for(int i = 0 ; i < len ; i++ ){
    char c;
    if( i == len - 1 && a[i] == 0 ) break;
    if( a[i] < 0 ) {
      a[i] += 26;
      a[i+1] --;
    }
    if(  a[i] == 0 ) {
      a[i] += 26;
      a[i+1] --;
    }
    c = 'a' + a[i] -1;
    ret += c;
  }
  reverse(ret.begin(),ret.end());
  return ret;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  cout <<   calc(n) << endl;


  return 0;
}



Measured memory_bytes: 3660
#include <iostream>

std::pair<double, double> to_pair(const double &d1, const double &d2){
	if (d1 > d2){
		return std::make_pair(d1, d2);
	}else{
		return std::make_pair(d2, d1);
	}
}
int main(){
	double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
	while (std::cin >> xa1){
		std::cin >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2;
		std::pair<double, double> xa = to_pair(xa1, xa2);
		std::pair<double, double> ya = to_pair(ya1, ya2);
		std::pair<double, double> xb = to_pair(xb1, xb2);
		std::pair<double, double> yb = to_pair(yb1, yb2);
		if ((xa.first >= xb.first and xb.first >= xa.second) or (xb.first >= xa.first and xa.first >= xb.second)){
			if ((ya.first >= yb.first and yb.first >= ya.second) or (yb.first >= ya.first and ya.first >= yb.second)){
				std::cout << "YES\n";
			}else{
				std::cout << "NO\n";
			}
		}else{
			std::cout << "NO\n";
		}
	}
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

const int INF = 2000000000;
const double pi = 3.1415926;
const int base = 1000000007;

string s, t;
int a, b;

int main()
{
    //ifstream cin ("input.txt");
    //ofstream cout ("output.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        cout << 'x';
    }
    return 0;
}

Measured memory_bytes: 256
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
	int n;
	cin>>n;
	ldb ans = 1;
	ldb mx = 1e18;


	for(int i=0;i<n;i++){
		ldb a;
		cin>>a;
		if(ans!=-1)
			ans = ans*a;
		if(ans>mx or ans<0){
			ans=-1;
		}
		if(a==0)
			ans=0;

	}
	cout<<fixed<<setprecision(0);
	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s;
    cin >> s;

    int n = s.size();

    vector<int> ans(n+1, 0);
    
    int cntR = 0, cntL = 0;
    for(int i = 0; i < n; i++) {
        if (s[i] == '<') cntR++;
        else cntR = 0;
        ans[i+1] = cntR;
    }
    for(int i = n-1; i >= 0; i--) {
        if (s[i] == '>') cntL++;
        else cntL = 0;
        ans[i] = max(cntL, ans[i]);
    }

    ll sum = 0;
    for(int i = 0; i <= n; i++) {
        sum += ans[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 5876
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    vector<int> As(N);
    map<int, int> diff2NumMap;
    for (int i = 1; i <= N; ++i)
    {
        int Ai; cin >> Ai;
        As[i - 1] = Ai;
        ++diff2NumMap[i - Ai];
    }
    LLONG ans = 0;
    for (int a = 1; a < N; ++a)
    {
        int Aa = As[a - 1];
        int diff = a - Aa;
        --diff2NumMap[diff];
        int key = a + Aa;
        if (diff2NumMap.find(key) != diff2NumMap.end())
        {
            ans += diff2NumMap[key];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 12656
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 12 17:17:55 2020

@author: matsui
"""
def check(N,K):
    ans=0
    for i in range(N+1):
        c=0
        for s in str(i):
            if int(s)!=0: c+=1
        if c==K: ans+=1
    return ans

N=input()
L=len(N)
K=int(input())

ans=0
if K==1:
    ans=int(N[0])+(L-1)*9
           
if K==2:
    dp=[0]*(L+1)
    for i in range(2,L):
        dp[i]=9*9*(i-1)
          
    dp[L]=(int(N[0])-1)*9*(L-1)
    
    for i in range(1,L):
        if int(N[i])!=0:
            dp[L]+=int(N[i])+9*(L-i-1)
            break
     
    ans=sum(dp)
    
if K==3:
    dp=[0]*(L+1)
    for i in range(3,L):
        dp[i]=9*(dp[i-1]/9+9*9*(i-2))
        
        
    dp[L]=(int(N[0])-1)*(dp[L-1]/9+9*9*(L-2))
    
    for i in range(1,L):
        if int(N[i])!=0:
            dp[L]+=(int(N[i])-1)*9*(L-i-1)+9*9*(L-i-1)*(L-i-2)/2
            break
        
    for j in range(i+1,L):
        if int(N[j])!=0:
            dp[L]+=int(N[j])+9*(L-j-1)
            break
        
    
    
           
    ans=sum(dp)
    
print(int(ans))
#print(check(int(N),K))

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

int main() {
  string s;cin>>s;
  if (s[0] == '9' || s[1] == '9') cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
class Node():
    def __init__(self):
        self.left=None
        self.right=None
        self.key=None
        self.parent=None

def setkeys(T):
    length=len(T)
    ls=[Node() for i in range(length)]
    for i in range(length):
        ls[i].key=T[i]
        if i+1!=1:
            ls[i].parent=T[(i+1)//2-1]
        if length>=2*(i+1):
            ls[i].left=T[2*i+1]
        if length>=2*(i+1)+1:
            ls[i].right=T[2*i+2]
    return ls


h=int(input())
nodes=[int(i) for i in input().split()]
ls=setkeys(nodes)
j=0
for i in ls:
    j+=1
    if i.parent and i.left and i.right:
        print('node '+str(j)+': key = '+str(i.key)+', parent key = '+str(i.parent)+', left key = '+str(i.left)+', right key = '+str(i.right)+', ')
    elif i.left and i.right:
        print('node '+str(j)+': key = '+str(i.key)+', left key = '+str(i.left)+', right key = '+str(i.right)+', ')
    elif i.parent and i.left:
        print('node '+str(j)+': key = '+str(i.key)+', parent key = '+str(i.parent)+', left key = '+str(i.left)+', ')
    elif i.left:
        print('node '+str(j)+': key = '+str(i.key)+', left key = '+str(i.left)+', ')
    else:
        print('node '+str(j)+': key = '+str(i.key)+', parent key = '+str(i.parent)+', ')
   
    


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int N, K, i;
  cin >> N >> K;
  vector<ll> H(N);
  ll result = 0;
  REP(i, N) {
    cin >> H[i];
  }
  sort(H.begin(), H.end(), greater<ll>());
  FOR(i, K, N) {
    result += H[i];
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A >= 6 && A <= 12) {
			B /= 2;
		} else if (A <= 5) {
			B = 0;
		}

		System.out.println(B);
		sc.close();
	}
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,p=998244353;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,m,K,ans,a[N],f[N][N],g[N][N];
char ch[N];
void check(int &x,int y){if ((x+=y)>=p) x-=p;}
void dp(int L){
	n+=L;
	for (int i=0;i<=n;i++)
	for (int j=i-1;j>=0;j--){
		g[i][j]=f[i][j+1];
		check(g[i][j],g[i][j+1]);
	}
	for (int i=1;i<=n;i++)
	for (int j=1;j<=i;j++) check(f[i][j],f[i-1][j-1]);
	for (int i=n;i;i--)
	for (int j=L+1;j<=i;j++)
	check(f[i][j],p-f[i-L-1][j-L-1]);
	for (int i=0;i<=n;i++)
	for (int j=0;j<=i;j++) check(f[i][j],g[i][j]);
}
int main(){
	scanf("%s %d",ch+1,&K);
	n=strlen(ch+1);
	int cnt=0;
	for (int i=1;i<=n;i++)
	if (ch[i]=='0'){a[++m]=cnt;cnt=0;}
	else cnt++;
	a[++m]=cnt;
	f[0][0]=1;n=0;
	for (int i=m;i;i--)
	dp(a[i]);
	for (int i=0;i<=min(n,K);i++) check(ans,f[i][0]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4532
#include<bits/stdc++.h>
using namespace std;
int a,b;
string ans;
main(){
  cin>>a>>b;
  if(a==1||b==1){
    if(a==1&&b==1){
      ans="Draw";
    }else if(a==1){
    ans="Alice";
    }else if(b==1){
      ans="Bob";
    }
  }else if(a>b){
    ans="Alice";
  }else if(a<b){
    ans="Bob";
  }else{
    ans="Draw";
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as V
import Data.Array.IArray (listArray, accumArray, (!))
import Data.Array.MArray
import Data.Array.ST (STUArray, runSTUArray)
import Data.Array.Unboxed (UArray)
import Data.List (sortOn, sortBy, unfoldr, partition)
import Data.Char (isSpace)
import Control.Monad.ST (ST)
import Control.Monad.Trans.State (StateT(..))
import qualified Data.ByteString.Char8 as B

-- utility functions

--   Input functions
readInt = B.readInt . B.dropWhile isSpace

readInts :: Int -> B.ByteString -> [Int]
readInts n = take n . unfoldr readInt

readIntsV :: Int -> B.ByteString -> V.Vector Int
readIntsV n = V.unfoldrN n readInt

readIntsA :: Int -> B.ByteString -> UArray Int Int
readIntsA n bs = runSTUArray $ do
  arr <- newArray_ (0,n-1)
  go arr 0 bs
  return arr
  where
    go :: STUArray s Int Int -> Int -> B.ByteString -> ST s ()
    go arr i bs
      | i==n = return ()
      | otherwise = do
        let Just (x,bs') = readInt bs
        writeArray arr i x
        go arr (i+1) bs'

readTsV :: Int -> B.ByteString -> V.Vector (Int,Int)
readTsV n = V.unfoldrN n $ runStateT ((,) <$> StateT readInt <*> StateT readInt)

readTs :: Int -> B.ByteString -> [(Int,Int)]
readTs n = take n . unfoldr readT where
  readT = runStateT ((,) <$> StateT readInt <*> StateT readInt)

-- main

solv n s
  | null s' = 0
  | otherwise = minimum $ go 0 bnum s'
  where
    s' = reverse . dropWhile (=='.') $ s
    go wn bn [] = [bnum]
    go wn bn ('.':xs) = bn + (wn+1) : (go (wn+1) bn xs)
    go wn bn ('#':xs) = (bn-1) + wn : (go wn (bn-1) xs)
    bnum = length . filter (=='#') $ s'

main = do
  n <- read <$> getLine :: IO Int
  s <- getLine
  print $ solv n s


Measured memory_bytes: 13948
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int N; cin >>N;
  vector<int> ds(N);
  for(int& d : ds) cin >>d;
  sort(ds.begin(), ds.end());
  cout <<ds[N / 2] - ds[N / 2 - 1] <<endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main() {
	int K,S;
	int count = 0;//条件を満たす個数をカウント

	//入力
	cin >> K >> S;

	//0<=X,Y,Z<=K.X+Y+Z=Sを満たすのは何通り？
	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {
			int z = S - x - y;
			if (0 <= z && z <= K) {
				count++;
			}
		}
	}

	cout << count << endl;

}

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

int main(int argc, char const* argv[])
{
	int H, W;
	while ((cin >> H >> W) && (H || W)) {
		for (int i=0; i<H; i++) {
			for (int j=0; j<W; j++) {
				if ((i%2==0 && j%2==0) || (i%2!=0 && j%2!=0)) {
					cout << "#";
				} else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1152
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

a,b=input2()

if a<=b*2:
	print(0)
else:
	print(a-b*2)









Measured memory_bytes: 13620
import sys
s = sys.stdin.readlines()

N,M,Q = map(int,s[0].split())

Section = [[0]*N for _ in range(N)]
for L,R in (map(int, e.split()) for e in s[1:M+1]):
    Section[L-1][R-1] += 1

Sum = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        Sum[i+1][j+1] = Sum[i][j+1]+Sum[i+1][j]-Sum[i][j]+Section[i][j]

for p,q in (map(int, e.split()) for e in s[M+1:]):
    print(Sum[q][q]-Sum[p-1][q])

Measured memory_bytes: 36860
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
m=0
for i in range(n-1):
    if a[i+1]-a[i]==1:
        ai=a[i]-1
        m+=c[ai]

s=sum(b)
print(s+m)

Measured memory_bytes: 3064
N, K = map(int, input().split())

A = list(map(int, input().split()))
d = {}

d[1] = A[0]

idx = 1
start = 0
count = 0
while True:
  count += 1
  if K == count:
    print(A[idx-1])
    exit()
  d[idx] = A[idx-1]
  idx = A[idx-1]
  if idx in d:
    start = idx
    break


e = {}
l = []
while True:
  e[start] = A[start-1]
  l.append(e[start])
  start = A[start-1]
  if start in e:
    break


amari = ((K-count-len(l)) % len(l))
if amari != 0:
  print(l[amari-1])
else:
  print(l[-1])



Measured memory_bytes: 33212