akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

void DisplayArray(int A[], int N)
{
    int i;
    for (i = 0; i < N; i++) {
        if (i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

int SelectionSort(int A[], int N)
{
    int i, j, minj, tmp;
    int checkFlag, count = 0;

    for (i = 0; i < N; i++) {
        minj = i;
        checkFlag = 0;
        for (j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
                checkFlag = 1;
            }
        }
        if (checkFlag && i != minj) count++;
        tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
    }

    return count;
}

int main(void)
{
    int N, i, numOfExchanges;
    scanf("%d%*c", &N);
    int* A = (int*)malloc(sizeof(int) * N);

    for (i = 0; i < N; i++) scanf("%d", &A[i]);
    scanf("%*c");

    numOfExchanges = SelectionSort(A, N);
    DisplayArray(A, N);
    printf("%d\n", numOfExchanges);

    return 0;
}

Measured memory_bytes: 604
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int p = nextInt();
		int q = nextInt();
		int r = nextInt();

		out.println(Math.min(q + r, Math.min(p + q, p + r)));
	}

	private void solveB() {
		int n = nextInt();
		int[] wk = new int[n];
		for (int i = 0; i < wk.length; i++) {
			wk[i] = nextInt();
		}

		int[] rui = new int[n];
		int[] rui2 = new int[n];
		rui[0] = wk[0];
		for (int i = 1; i < rui.length; i++) {
			rui[i] = rui[i - 1] + wk[i];
		}
		double res = Integer.MAX_VALUE / 10;
		for (int i = 0; i < Math.min(100, n - 1); i++) {
			res = Math.min(res, Math.abs((rui[n - 1] - rui[i]) - rui[i]));
		}

		out.println((int) res);
	}

	private void solveC() {
		int n = nextInt();

		out.println("");
	}

	private void solveD() {
		int n = nextInt();

		out.println("");
	}

	private void solveE() {
		int n = nextInt();

		out.println("");
	}

	private void solveF() {
		int n = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21460
#include<stdio.h>

int main(){
  int a,b,c,k,max;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  if(k==(a+b+c)){
    max = a-c;
  } else if(k<(a+b+c) && k>=(a+b)){
    max = a-(k-a-b);
  } else if(k<(a+b) && k>=a){
    max = a;
  } else{
    max = k;
  }
  printf("%d",max);
  return 0;
}
  

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

int main(){
  ll N;
  cin >>N;
  
  ll a = 2;
  ll b = 1;
  ll ans ;
  rep(i,1,N){
    ans = a+b;
    a = b;
    b = ans;
  }
  
  if(N==1) ans = 1;
  cout <<ans<< endl;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
        "sort"
)

func solution(n, k int, a []int) int {
        seen := make(map[int]int, 0)

        for i := range a {
                seen[a[i]]++
        }

        l := len(seen)
        if l <= k {
                return 0
        }

        tmp := make([][]int, 0, l)
        for key, val := range seen {
                tmp = append(tmp, []int{key, val})
        }
        sort.SliceStable(tmp, func(i, j int) bool {
                return tmp[i][1] < tmp[j][1]
        })
        out := 0
        for i := range tmp[:l-k] {
                out += tmp[i][1]
        }
        return out
}

func main() {
        var n, k int
        fmt.Scan(&n, &k)
        a := make([]int, n)
        for i := range a {
                fmt.Scan(&a[i])
        }
        fmt.Println(solution(n, k, a))
}

Measured memory_bytes: 20760
IDENTIFICATION DIVISION.
PROGRAM-ID. 159C.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 L          PIC 9(4).
01 H          PIC 9(3)V9(8).
01 OUT        PIC Z(7)9.9(7).
*>
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT L.
*>
  COMPUTE H = L / 3.
  COMPUTE OUT = H ** 3.
*>
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


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

int main(void){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n/2; i++){
        int x = n-i;
        if(x != i){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
int main(){
    int n,w;
    scanf("%d %d",&n,&w);
    LL dp[100005];
    MEM(dp);
    for(int i=1;i<=n;i++){
        int ww,v;
        scanf("%d %d",&ww,&v);
        for(int j=w-ww;j>=0;j--){
            dp[j+ww]=max(dp[j+ww],dp[j]+v);
        }
    }
    printf("%lld\n",dp[w]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}

int main(){
    int X, Y, Z;
  cin>>X>>Y>>Z;
  cout<<Z<<" "<<X<<" "<<Y<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define EACH(e,v) for(auto& e:v)

const int MOD = (int)1e9 + 7;
const int INF = 1 << 30;
const ll INFF = 1LL << 62;

inline int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}

int N;
vector<int> A, B;

const int bucketSize = 400;

signed main() {

  cin >> N;

  A.resize(N);
  REP(i, N) cin >> A[i];

  B.resize(N / bucketSize + 10);
  {
    int g = 0, piv = 0;
    REP(i, N) {
      if ((i - 1) % bucketSize == 0) {
        B[piv++] = g;
        g = 0;
      } else {
        g = gcd(g, A[i]);
      }
    }
  }

  function<int(int,int)> query = [&](int l, int r) {
    int ret = 0;
    for (int x = l; x < r;) {
      int bi = x / bucketSize;
      if (l <= bi * bucketSize && (bi + 1) * bucketSize <= r) {
        // バケット
        ret = gcd(ret, B[bi]);
        x += bucketSize;
      } else {
        // 余った部分
        ret = gcd(ret, A[x]);
        ++x;
      }
    }
    return ret;
  };

  int res = 0;
  REP(i, N) res = max(res, gcd(query(0, i), query(i + 1, N)));
  cout << res << endl;

}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
const int MAX_N = 500000;
vector<int> par(MAX_N);
vector<int> Rank(MAX_N);
vector<int> gNum(MAX_N);

void init(int n) {
	for (int i = 0; i < n; ++i) {
		par[i] = i;
		Rank[i] = 0;
		gNum[i] = 1;
	}
}

int root(int x) {
	if (par[x] == x) {
		return x;
	}
	par[x] = root(par[x]);
	return par[x];
}

bool same(int x, int y) {
	return root(x) == root(y);
}

void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y)return;
	
	if (Rank[x] < Rank[y]) {
		par[x] = y;
		gNum[y] += gNum[x];
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y]) {
			Rank[x]++;
		}
		gNum[x] += gNum[y];
	}
}
void solve() {
	string str;
	cin >> str;//全部hi
	int len = str.length();
	if (len % 2) {
		cout << "No" << endl;
		return;
	}
	bool ret = true;;
	for (int i = 0; i < len; ++i) {
		if (i % 2 == 0 && str[i] != 'h') {
			ret = false;
		}
		else if(i%2 ==1 && str[i] != 'i' ){
			ret = false;
		}
	}
	if (ret) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

int gcd(int a, int b){
	if(!a) return b;
	return gcd(b%a,a);
}

int lcm(int x, int y){
	if(x == 0 || y==0) return 0;
	return x/gcd(x, y) *y;
}

signed main() {
  int N, M;
  cin >> N >> M;
  string S, T;
  cin >> S >> T;
  
  int L = lcm(N, M);
  
  map<int, char> koyaku;
  for( int i = 0; i < N; i++ ){
    koyaku[i*(L/N)] = S.at(i);
  }
  
  for( int i = 0; i < M; i++ ){
    if( koyaku.count(i*(L/M)) ){
      if( koyaku.at(i*(L/M)) != T.at(i) ){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  
  cout << L << endl;
    
  
  
}


Measured memory_bytes: 6144
program AIsing2020B
    implicit none
    integer(8)::N,i,ans=0
    integer(8),allocatable,dimension(:)::A
    read*,N
    allocate(A(N))
    read*,A
    do i=1,N,2
        if(mod(A(i),2)==1)ans=ans+1
    end do
    print'(i0)',ans
end program AIsing2020B

Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, L;
    cin >> N >> L;
    string list[N];
    for(int i = 0; i<N;i++) {
        cin >> list[i];
    }

    sort(list, list + N);
    for(int i = 0; i<N; i++) {
        cout << list[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 02, 2020 6:00 PM
 *    Problem Name  : D - Alter Altar
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc174/tasks/abc174_d
 *    @genarated by : ai-virtual-assistant
**/

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

int main(){
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    string s;
    cin >> s;

    string s1 = "";
    s1 = s;

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

    int cnt=0;

    for(int i=0; i<n; i++){
        if(s[i] != s1[i]) cnt++;
    }

    cout << cnt/2 << endl;

    return 0 ;
}


Measured memory_bytes: 3932
a = list(input())

c = 0
count = 0
while c <= len(a)-3:
  if a[c] == a[c+1]:
    count += 1
    c += 3
  else:
    c +=1
if c== len(a)-2:
  if a[c] == a[c+1]:
    count +=1
print(len(a)-count)

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, X, S[200];
unordered_map<int, ll>DP[201];
ll f[201],inv[201], res;

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1) {
			a = a*x%mod;
		}
		x = x*x%mod;
		y >>= 1;
	}
	return a;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}

int main(){
	cin >> N >> X;
	f[0] = 1;
	inv[0] = modinv(1);
	for (int i = 1; i <= N; ++i) {
		f[i] = f[i - 1] * i % mod;
		inv[i] = modinv(f[i]);
	}
	for (int i = 0; i < N; ++i) {
		cin >> S[i];
	}
	DP[0][X] = 1;
	sort(S, S + N, greater<>());
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= i; ++j) {
			for (auto it = DP[j].begin(); it != DP[j].end(); ++it) {
				int k = it->first;
				ll s = it->second;
				DP[i + 1][k%S[i]] = (DP[i + 1][k%S[i]] + s * f[N - j - 1] % mod * inv[N - i - 1]) % mod;
			}
		}
	}
	for (int j = 0; j <= X; ++j) {
		res = (res + j * DP[N][j]) % mod;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 26788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	string S;
	cin >> S;
	int Z = S.size();
	string T = "CODEFESTIVAL2016";
	int cnt = 0;
	rep(i, Z) {
		if (S[i] != T[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <string>
#include <cctype>

using namespace std;
int cur = 0;
string S;
int expression();
int term();
int factor();
int main() {
  int times;
  cin >>times;
  for(int i = 0 ; i < times; i++){
      cin >> S;
      cur = 0;
      S.resize(S.size()-1);
      cout << expression() <<endl;
  }

}
int digit() {
  assert(isdigit(S[cur]));
  int n = S[cur] -'0';
  cur = cur+1;
  return n;
}
int number() {
  int n = digit();
  while(cur <S.size() && isdigit(S[cur])){
      n = n*10 + digit();
  }
  return n;
}
int expression() {
  int sum = term();
  while (S[cur] == '+' || S[cur] == '-'){
    char op = S[cur];
    cur +=1;
    int b = term();
    if(op ==  '+') sum +=b;
    else sum -= b;
  }
  return sum;
}
int term() {
  int a = factor();
  while(cur < S.size()
        && (S[cur] == '*' || S[cur] == '/')){
          char op = S[cur];
          cur +=1;
          int b = factor();
          if(op == '*') a *=b;
          else a/=b;
        }
  return a;
}
int factor() {
  if(S[cur] != '(' ) return number();
  cur +=1;
  int n =expression();
  assert(S[cur] == ')');
  cur +=1;
  return n;
}

Measured memory_bytes: 1208
def main():
    inf=float("inf")
    n=int(input())
    alst=[list(map(int,input().split())) for _ in range(n)]

    for i in range(n):
        alst[i][i]=inf

    sm=0
    token=0

    for i in range(n):
        for j in range(i+1,n):
            for k in range(n):
                if alst[i][k]+alst[k][j]>alst[i][j]:
                    continue
                elif alst[i][k]+alst[k][j]==alst[i][j]:
                    break
                else:
                    token=1
                    break
            else :
                sm+=alst[i][j]
    
    if token : sm=-1

    print(sm)

main()

Measured memory_bytes: 12664
<?php

fscanf(STDIN, '%d', $n);
for ($i = 0; $i < $n; $i++) {
    $line = trim(fgets(STDIN));
    $B = 0;
    $C = 0;
    $bool = true;
    foreach (explode(' ', $line) as $ball) {
        $diff1 = $ball - $B;
        $diff2 = $ball - $C;
        //容器BとCの一番上の玉が新しい玉より大きい
        if ($diff1 < 0 && $diff2 < 0) {
            $bool = false;
            break;
        //容器Cにしか入れられない
        } elseif ($diff1 < 0) {
            $C = $ball;
        //容器Bにしか入れられない
        } elseif ($diff2 < 0) {
            $B = $ball;
        //どちらにも入れられるので差異が小さい方に入れる
        } else {
            if ($diff1 < $diff2) {
                $B = $ball;
            } else {
                $C = $ball;
            }
        }
    }

    echo $bool ? "YES\n" : "NO\n";
}

Measured memory_bytes: 6604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W[] = new int[N];
		int nowSum = 0;
		int allSum = 0;
		int minSum = Integer.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			allSum += W[i];
		}

		for (int i = 0; i < N; i++) {
			nowSum += W[i];
			minSum = Math.min(minSum, Math.abs(nowSum - (allSum - nowSum)));
		}

		System.out.println(minSum);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
LL mod = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n); sll(t); sll(a);
	vector< pair<LD, LL> > temps;
	rep(i, 0, n) {
		sll(h);
		temps.push_back(make_pair(((LD)t) - 0.006 * ((LD)h), i+1));
	}
	sort(temps.begin(), temps.end());
	LD vals[n];
	rep(i, 0, n)	vals[i] = temps[i].first;
	LL pos = lower_bound(vals, vals+n, (LD)a) - vals;
	if((pos == n) || (pos >= 1 && abs(vals[pos-1]-a) < abs(vals[pos]-a)))	pos--;
	pll(temps[pos].second); nl;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {

        // 入力
        var n = int.Parse(Console.ReadLine());
        int[] v = Console.ReadLine().Split().Select(int.Parse).ToArray();

        //偶数奇数で登場回数の多い数字
        //int[] olist = new int[1000000];
        //int[] elist = new int[1000000];
        var olist = new Dictionary<int, int>() { };
        var elist = new Dictionary<int, int>() { };
        for (int i = 0; i < n; i++)
        {
            if (i % 2 == 0)
            {
                if (!olist.ContainsKey(v[i]))
                {
                    olist.Add(v[i], 1);
                }
                else
                {
                    olist[v[i]]++;
                }
            }
            else
            {
                if (!elist.ContainsKey(v[i]))
                {
                    elist.Add(v[i], 1);
                }
                else
                {
                    elist[v[i]]++;
                }
            }
        }

        var maxov = olist.OrderByDescending(val => val.Value).First().Value;
        var maxok = olist.OrderByDescending(val => val.Value).First().Key;
        var maxoc = olist.Where(val => val.Value == maxov).Count();
        var maxev = elist.OrderByDescending(val => val.Value).First().Value;
        var maxek = elist.OrderByDescending(val => val.Value).First().Key;
        var maxec = elist.Where(val => val.Value == maxev).Count();
        //Console.WriteLine(maxov);
        //Console.WriteLine(maxok);
        //Console.WriteLine(maxoc);
        //Console.WriteLine(maxev);
        //Console.WriteLine(maxek);
        //Console.WriteLine(maxec);

        //数字が被っていないことを確認
        if (maxok == maxek)
        {
            if (maxoc == 1 && maxec == 1 && olist.Count() != 1 && elist.Count() != 1)
            {
                //2番目の数の出現回数が多い方を採用
                var secondo = olist.OrderByDescending(val => val.Value).Skip(1).First().Value;
                var seconde = elist.OrderByDescending(val => val.Value).Skip(1).First().Value;
                if (secondo >= seconde)
                {
                    maxov = secondo;
                }
                else
                {
                    maxev = seconde;
                }
            }
            else if (maxoc == 1)
            {
                elist[maxek] = 0;
                maxev = elist.OrderByDescending(val => val.Value).First().Value;

            }
            else if (maxec == 1)
            {
                olist[maxok] = 0;
                maxov = olist.OrderByDescending(val => val.Value).First().Value;

            }
        }        
        //Console.WriteLine(maxov);
        //Console.WriteLine(maxev);



        var ans = n - maxov - maxev;
        Console.WriteLine(ans);

    }
}


Measured memory_bytes: 26592
import sys
import heapq
input = sys.stdin.readline
N, M = map(int, input().split())
a = list(map(int, input().split()))
res = 0
if M == 0:
  if N == 1:
    print(0)
  elif N == 2:
    print(sum(a))
  else: print("Impossible")
  exit(0)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rnk = [0] * (n + 1)

  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return 
    elif self.rnk[x] > self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x] == self.rnk[y]:
        self.rnk[y] += 1

  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  def Count(self, x):
    return -self.root[self.Find_Root(x)]

uf = UnionFind(N - 1)
for _ in range(M):
  u, v = map(int, input().split())
  uf.Unite(u, v)
hs = [[] for _ in range(N + 1)]
for x in range(N):
  y = uf.Find_Root(x)
  heapq.heappush(hs[y], a[x])
#print(hs)
c = 0
t = []
for x in range(N):
  if len(hs[x]):
    c += 1
    res += heapq.heappop(hs[x])
    t += hs[x]
t.sort()
#print(c, t, hs, res)
if c == 1:
  print(0)
  exit(0)
if len(t) < c - 2:
  print("Impossible")
  exit(0)
for i in range(c - 2):
  if i >= c - 2:
    print("Impossible")
    exit(0)
  res += t[i]
print(res)

Measured memory_bytes: 97464
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;
  int c = 0;
  rep(i, 0, s.size()) if (s[i] == 'o') c++;
  if (15 - s.size() + c >= 8)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


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

int sumXor(const vector<int> &a, const vector<int> &b){
    int foo = 0;
    int n = a.size();
    vector<int> c(n, 0);
    for(int k=0; k<=28; k++){
        const int msk = (1<<(k+1))-1;
        for(int i=0; i<n; i++){
            c[i] = b[i] & msk;
        }
        sort(c.begin(), c.end());
        for(int i=0; i<n; i++){
            const int sup = a[i] & msk;
            if((distance(lower_bound(c.begin(), c.end(), (1<<k)-sup), lower_bound(c.begin(), c.end(), (1<<(k+1))-sup)) + distance(lower_bound(c.begin(), c.end(), (3<<k)-sup), c.end())) & 1){
                //fprintf(stderr, "k=%d, a[i]=%d, cnt=%ld\n", k, a[i], (distance(lower_bound(c.begin(), c.end(), (1<<k)-sup), lower_bound(c.begin(), c.end(), (1<<(k+1))-sup)) + distance(lower_bound(c.begin(), c.end(), (3<<k)-sup), lower_bound(c.begin(), c.end(), (1<<(k+2))-sup))));
                foo ^= 1<<k;
            }
        }
    }
    return foo;
}

int main(){
    int n;
    while(scanf("%d", &n)!=EOF){
        vector<int> a(n, 0);
        vector<int> b(n, 0);
        for(int i=0; i<n; i++)scanf("%d", &a[i]);
        for(int i=0; i<n; i++)scanf("%d", &b[i]);
        printf("%d\n", sumXor(a, b));
    }
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int solve(char ma[105][105], int h, int w, char fruit){
    if(fruit == ma[h][w]) ma[h][w] = '.';
    else return 0;

    solve(ma, h + 1, w,fruit); 
    solve(ma, h - 1, w,fruit); 
    solve(ma, h, w + 1,fruit); 
    solve(ma, h, w - 1,fruit); 

    return 1;
}

int main(){
    int h, w;
    while(cin >> h >> w, h||w){
        int ans = 0;
        char ma[105][105];
        rep(i,105) rep(j,105) ma[i][j] = '.';
        rep(i,h){
            rep(j,w){
                cin >> ma[i + 1][j + 1];
            }
        }

        range(i,1,h + 1){
            range(j,1,w + 1){
                if(ma[i][j] != '.') ans+=solve(ma, i, j, ma[i][j]);
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 1636
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #整数1つinput
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii())
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #文字列1つinput
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

n = ii()
arr = llint(n)
dp = [[0]*3 for _ in range(n)]
dp[0][0],dp[0][1],dp[0][2]=arr[0][0],arr[0][1],arr[0][2]
for i in range(1,n):
    for abc in [0,1,2]:
        if abc==0:
            dp[i][0] = max(arr[i][0]+dp[i-1][1],arr[i][0]+dp[i-1][2])
        elif abc==1:
            dp[i][1] = max(arr[i][1]+dp[i-1][0],arr[i][1]+dp[i-1][2])
        else:
            dp[i][2] = max(arr[i][2]+dp[i-1][1],arr[i][2]+dp[i-1][0])

print(max(dp[-1][0],dp[-1][1],dp[-1][2]))


Measured memory_bytes: 94936
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	a, b, c = map(int, input().split())
	
	ans = "Yes"
	
	if a == b == c:
		ans = "No"
	if a != b and b != c and c != a:
		ans = "No"
	
	print(ans)


if __name__ == "__main__":
	main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX 30

signed main(){
    int n;
    ll k;
    cin >> n >> k;
    ll a[n],b[n];
    REP(i,n){
        cin >> a[i] >> b[i];
    }
    vector<ll> cand;
    for(int bit = MAX - 1; bit >= 0; bit--){
        if(k & 1 << bit){
            ll t = 0;
            for(int i = MAX - 1; i > bit; i--){
                if(k & 1 << i) t |= 1 << i;
            }
            for(int i = bit - 1; i >= 0; i--){
                t |= 1 << i;
            }
            cand.emplace_back(t);
        }
    }
    cand.emplace_back(k);
    ll ans = 0;
    for(auto c : cand){
        ll sum = 0;
        for(int i = 0; i < n; i++){
            for(int bit = 0; bit < MAX; bit++){
                if(a[i] & 1 << bit && !(c & 1 << bit)) goto no;
            }
            sum += b[i];
            no:;
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
n=int(input())
k=0
for i in range(1,n+1):
  if (i*(i+1))//2==n:
    k=i
    break
else:
  k=-1
if k==-1:
  print('No')
else:
  arr=[[k] for _ in range(k+1)]
  tmp=0
  tk=0
  while k-tk>0:
    for i in range(tmp+1,tmp+k+1-tk):
      arr[tk].append(i)
    for i in range(tk+1,k+1):
      arr[i].append(tmp+i-tk)
    tmp+=(k-tk)
    tk+=1
  print('Yes')
  print(k+1)
  for row in arr:
    print(*row)

Measured memory_bytes: 12580
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int main(){

  int N;
  cin>>N;
  map<int,int> m;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    m[a]+=b;
  }
  vector<pii> v;
  for(map<int,int>::iterator it=m.begin();
      it!=m.end();it++){
    v.push_back(pii(-it->second,it->first));
  }
  sort(v.begin(),v.end());
  cout<<v[0].second<<" "<<v[0].first*-1<<endl;

  return 0;
}

Measured memory_bytes: 1208
n, k = map(int, input().split())
A = list(map(int, input().split()))
B = [max(0, a) for a in A]

from itertools import accumulate
A = [0]+A
A = list(accumulate(A))
B = [0]+B
B = list(accumulate(B))

#print(A)
#print(B)

ans = -10**18
for i in range(n-k+1):
    temp = max(0, A[i+k]-A[i])
    temp += B[i]-B[0]
    temp += B[-1]-B[i+k]
    #print(i,  A[i+k]-A[i], B[i]-B[0], B[-1]-B[i+k])
    ans = max(ans, temp)
print(ans)


Measured memory_bytes: 79008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
const int maxn = 10000001;
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << '\n';
}  


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin>>n;
    vector<ll>a(n);
    vector<ll>buk(n+1,0);
    vector<ll>pat(n+1,0);

    rep(i,n){
        cin>>a[i];
        buk[a[i]]++;
    }

    rep1(i,0,n+1){
        ll ai=buk[i];
        pat[i] = max(0LL,ai*(ai-1)/2);
        sum += pat[i];
    }

    rep(i,n){
        ll old = buk[a[i]];
        ll oldp= pat[a[i]];
        ll newp=max(0LL,(old-1)*(old-2)/2);

        if(oldp>0){
            cout << sum-oldp+newp<<'\n';
        }else{
            cout << sum<<'\n';
        }
    }


    //cout <<fixed<<setprecision(16)<< << endl;
    //cout<<ans<<endl;
    
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 7296
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
b = list(map(int, input().split()))
checker = Counter(b)
a = []
for key in checker.keys():
    a.append(key)
if len(a) == 1 and a[0] == 0:
    print('Yes')
    exit()
if len(a) == 2:
    if a[0] == 0:
        if checker[0] == int(N/3) and checker[a[1]] == int(2*N/3):
            print('Yes')
            exit()
    elif a[0] != 0:
        if checker[0] == int(N/3) and checker[a[0]] == int(2*N/3):
            print('Yes')
            exit()
if len(a) != 3:
    print('No')
    exit()
if a[0] == a[1]^a[2] and a[1] == a[0]^a[2] and a[2] == a[0]^a[1]:
    ans = 1
else:
    ans = 0
for key, value in checker.items():
    if N % 3 == 0 and value == int(N/3):
        ans *= 1
    else:
        ans *= 0
if ans == 1:
    print('Yes')
elif ans == 0:
    print('No')





Measured memory_bytes: 14468
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int max=a[0];
    for(int i=0;i<n;i++){
        if(max-a[i]>1){
            cout<<"No";
            return 0;
        }
        if(max<a[i]){
            max=a[i];
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 640
n=int(input())
l=list(map(int,input().split()))
l1=[0 for i in range(n)]
l1[0]=l[0]
l1[1]=l[0]
for i in range(0,n-2):
  if l[i]>l[i+1]:
    l1[i+1]=l[i+1]
  l1[i+2]=l[i+1]
sum=0
for i in l1:
  sum+=i
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

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

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, ans = 0;
    cin >> n >> k;
    set<ll> s;
    map<ll,ll> mp;
    for(int i=1;i*i<=n;i++)if(n%i==0)s.insert(i),s.insert(n/i);
    for(auto& i:s){
    	mp[i] = modpow(k,(i+1)/2);
    	for(auto& j:s){
    		if(i<=j) continue;
    		if(i % j == 0) (mp[i] -= mp[j]) %= mod;
    	}
    	ans += mp[i]*(i&1?i:i/2)%mod;
    	ans %= mod;
    }
    ans += mod;
    cout << ans%mod << endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++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;}

int main(){
	ll a,b,c;
	cin >> a >> b >> c;
	
	if(4*a*b < (c-a-b)*(c-a-b) && c-a-b > 0) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll mod = 1e9+7;

ll add(ll a,ll b)
{
	return (mod+(a+b)%mod)%mod;
}

ll mul(ll a,ll b)
{
	return (mod+(a*b)%mod)%mod;
}

int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n,k;
	cin>>n>>k;
	
	ll arr[n+1];
	
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	
	ll cost[n+1];
	
	for(ll i=0;i<n;i++)
	{
		ll c = 0;
		for(ll j=0;j<n;j++)
		{
			if(arr[i]<arr[j])c++;
		}
		cost[i] = c;
	}
	ll ans = 0;
	for(ll i=0;i<n;i++)
	{
		ll d = 0;
		for(ll j=0;j<i;j++)
		{
			if(arr[i]<arr[j])d++;
		}
		//cout<<cost[i]<<" "<<d<<endl;
		ans = add(ans,mul(d,k));
		if(k>1)
		{
			ll c = k;
			ll b = k-1;
			if(c%2==0)
			{
				c=c/2;
			}
			else{
				b = b/2;
			}
			ans = add(ans,mul(mul(c,b),cost[i]));
		}
	}
	cout<<ans<<endl;	
	
}



Measured memory_bytes: 256
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    k, t = ns()
    a = na()
    a.sort()

    total = sum(a)-a[-1]

    ans = max(0, a[-1]-total-1)

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 13664
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N;
	cin >> N;
	if (N <= 9) {
		cout << N;
	}
	else if (N >= 10 && N <= 99) {
		cout << 9;
	}
	else if (N >= 100 && N <= 999) {
		cout << 9 + N - 100+1;
	}
	else if (N >= 1000 && N <= 9999) {
		cout << 909;
	}
	else if (N >= 10000 && N <= 99999) {
		cout << 9 + 900 + N - 10000 + 1;
	}
	else {
		cout << 90909;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
//#include <string>
#include <math.h>
//#include <vector>

using namespace std;

int main() {
  int N, P;
  int i,j;
  int tmp; 
  int even = 0, odd = 0;
  long long int ans = 0;
  
  cin >> N >> P;
  for(i=0;i<N;i++){
    cin >> tmp;
    if(tmp%2) odd++;
    else even++; 
  }

  //  printf("E%d O%d\n",even,odd);
  
  if(odd==0){
    if(P==1)
      ans = 0;
    else
      ans = pow(2,even);
  }else{
    ans = pow(2,even)*pow(2,odd-1);
  }
  cout << ans; 
  
  return 0;
}


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

int main(){
  string s;
  int n;
  cin >> s >> n;
  for(int i=0; i<n; ++i){
    int si = s[i] - '0';
    if(si>1){
      cout << si << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;

int main(void){
    string s;
    cin>>s;
    if(s.length()%2==1){
        cout<<"No";
        return 0;
    }
    for(int i=0;i<s.length();i+=2){
        if(s[i]=='h'&&s[i+1]=='i'){}
        else{
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

/*
73 

*/

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

#define EMPTY -1

void drop(vector<vector<int> >& block){
  int h = block.size();
  int w = block[0].size();
  for(int i = 0; i < w; i++)
    for(int j = 0; j < h; j++)
      for(int k = 0; k < h - 1; k++)
        if(block[k][i] == EMPTY)
          swap(block[k][i], block[k + 1][i]);
  return;
}


bool simulate(vector<vector<int> > block, int n){
  drop(block);
  int h = block.size();
  int w = block[0].size();

  bool flag;
  do{
    flag = false;
    vector<vector<bool> > reservation(h, vector<bool>(w, false));
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(block[i][j] != EMPTY){
          int continuity;
          for(continuity = 1; j + continuity < w && block[i][j] == block[i][j + continuity]; continuity++);
          if(continuity >= n){
            for(int k = 0; k < continuity; k++){
              reservation[i][j + k] = true;
            }
          }
          for(continuity = 1; i + continuity < h && block[i][j] == block[i + continuity][j]; continuity++);
          if(continuity >= n)
            for(int k = 0; k < continuity; k++)
              reservation[i + k][j] = true;
        }
      }
    }

    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++)
        if(reservation[i][j] && block[i][j] != EMPTY){
          block[i][j] = EMPTY;
          flag = true;
        }

    drop(block);
  }while(flag);

  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      if(block[i][j] != EMPTY)
        return false;

  return true;
}


int main(void){
  int h, w, n;
  cin >> h >> w >> n;

  string input;
  vector<vector<int> > block(h, vector<int>(w));
  for(int i = h - 1; i >= 0; i--){
    cin >> input;
    for(int j = 0; j < w; j++){
      if(input[j] == '.'){ block[i][j] = EMPTY; }
      else{ block[i][j] = input[j] - 'A'; }
    }
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w - 1; j++){
      swap(block[i][j], block[i][j + 1]);
      if(simulate(block, n)){
        cout << "YES" << endl;
        return 0;
      }
      swap(block[i][j], block[i][j + 1]);      
    }
  }

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

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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int edges[4][4];

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int a,b;

    for(int i=0;i<3;++i) {
        cin >> a >> b;
        --a; --b;
        edges[a][b] = 1;
        edges[b][a] = 1;
    }

    vector<int> v{0,1,2,3};
    do {
        bool ok = true;
        for(int i=0;i<3;++i) {
            if(!edges[v[i]][v[i+1]]) {
                ok = false;
                break;
            }
        }
        if(ok) {
            cout << "YES\n";
            return 0;
        }
    } while(next_permutation(all(v)));

    cout << "NO\n";

}


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

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sull(x) scanf("%llu",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf
#define clean fflush(stdout)

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

ll dx[10]={1,0,-1,0};
ll dy[10]={0,-1,0,1};

ll power(ll a,ll b)
{
    if(b==0)return 1;
    ll x=power(a,b/2);
    x=x*x;
    if(b%2)x=x*a;
    return x;
}

ll bigmod(ll a,ll b)
{
    if(b==0)return 1;
    ll x=bigmod(a,b/2)%mod;
    x=(x*x)%mod;
    if(b%2)x=(x*a)%mod;
    return x;
}


ll Set(ll N,ll pos){return N=N | (1LL<<pos);}
ll reset(ll N,ll pos){return N= N & ~(1LL<<pos);}
bool check(ll N,ll pos){return (bool)(N & (1LL<<pos));}

/**
double cosine_rule(double a,double b,double c)
{
    double res=(a*a+b*b-c*c)/(2*a*b);
    res=acos(res);
    return res;
}
*/
//ll arr[mx];

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    /** Use "long double"(%Lf) instead of double for precision safety*/
    ll tst,a,b,c,k,n,m,res=0,ans=0,t=0;
    sl(m),sl(n);
    for(ll i=1;i<=n;i++)
    {
        sl(a);
        res+=a;
    }
    if(res>=m)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }



    return 0;
}


Measured memory_bytes: 3768