akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

/**
 * @author masayamatu
 * 
 */
public class Main {
  
  public static void main(String[] args) throws IOException{
    FastScanner sc = new FastScanner();
    int n = sc.nextInt();
    int q = sc.nextInt();
    Graph[] graph = new Graph[n+1];
    for(int i = 0; i < n+1; i++) {
      graph[i] = new Graph();
    }
    for(int i = 1; i < n; i++) {
      int a = sc.nextInt(); int b = sc.nextInt();
      graph[a].child.add(graph[b]);
      graph[b].child.add(graph[a]);
    }
    for(int i = 0; i < q; i++) {
      int a = sc.nextInt(); int b = sc.nextInt();
      graph[a].value += b;
      } 
    dfs(graph[1] , null , 0);
    
    for(int i = 1; i < n+1; i++) {
      System.out.println(graph[i].value+ " ");
    }
  }
  
  public static class Graph{
      int  value=0;
      List<Graph> child = new ArrayList<Graph>();
  }
  public static void dfs(Graph graph,Graph parent,int value) {
        graph.value += value;
          for(Graph i:graph.child) {
            if(i != parent) {
              dfs(i,graph,graph.value); 
            }
          }           
      }      
}
class FastScanner {
  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;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  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();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 108628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top, S[1000];
void push(int);
int pop();
int main(){
  int x,y;
  char s[100];
  top = 0;
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x=pop();
      y=pop();
      push(x+y);
    } else if ( s[0] == '-' ){
      y=pop();
      x=pop();
      push(x-y);
    } else if ( s[0] == '*' ){
      x=pop();
      y=pop();
      push(x*y);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}
void push(int x){
  top++;
  S[top]=x;
}
int pop(){
  top--;
  return S[top+1];
}



Measured memory_bytes: 2104
#include <iostream>
#include <cmath>
#include <cstdlib> // rand
#include <cfloat> // DBL_MAX
#include <map>
#include <vector>
#include <algorithm> // sort
#include <utility> // pair

typedef long long ll;
using namespace std;

int main(){
  ll N;
  cin >> N;

  vector<int> As(N);
  for(int i=0; i<N; i++){
    cin >> As[i];
  }

  ll ans=1;
  for(int i=1; i<N; i+=2){
    ans = (ans*2) % 1000000007;
  }


  sort(As.rbegin(), As.rend());
  for(int i=0; i<N; i++){
    int should = (N-1) - (i/2)*2;
    if(As[i] != should){
      ans = 0;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
 
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int f[n],a[n],t[n],x[n],y[n];
  for(int i=0;i<n;i++)
    cin>>f[i]>>a[i]>>t[i]>>x[i]>>y[i];
 
  double dist[2];
  double time[2];
  bool passed[2];
  dist[0]=dist[1]=0.0;
  time[0]=time[1]=0.0;
  passed[0]=passed[1]=false;

  if(n==1){
    puts("-1 -1");
    puts("-1 -1");
  }else{
    for(int i=1;i<n;i++){
      if(a[i]!=a[i-1] && t[i]==t[i-1]){
	double d=sqrt(pow((double)(x[i]-x[i-1]),2)+pow((double)(y[i]-y[i-1]),2));
	if(dist[t[i]] < d){
	  dist[t[i]]=d;
	  time[t[i]]=((double)(f[i]-f[i-1])/60.0);
	  passed[t[i]]=true;
	}else if(dist[t[i]] == d && time[t[i]]>(double)(f[i]-f[i-1])/60.0){
	  time[t[i]]=((double)(f[i]-f[i-1])/60.0);
	}
      }
    }
    if(passed[0]==true)
      printf("%lf %lf\n",dist[0],time[0]);
    else
      puts("-1 -1");
    
    if(passed[1]==true)
      printf("%lf %lf\n",dist[1],time[1]); 
    else
      puts("-1 -1");
  }
   
  return 0;
}

Measured memory_bytes: 1192
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

X, N = LI()
P = LI()
# u = X
# d = X
# Pに含まれない整数（負も含まれる）で最もXに近くて最小の値を探す

if N == 0:
    print(X)
    sys.exit()

elif (N != 0) and (X not in P):
    print(X)
    sys.exit()

Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda x: (abs(x - X), x))  # maspyさん解法
# python の min() は、順序比較のためのキーを指定できて、abs(x-X) が最小のもののうち x が最小のものをとるとかはこんな感じで書いたりできます。
print(ans)

Measured memory_bytes: 9264
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// ?????¬???????????¬??????
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), c.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;


// ??°?????????????????¬??????
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int n;
  cin >> n;

  bool card[4][13] = {false};
  for(int i=0; i<n; ++i) {
    char mark;
    int markN;
    int number;

    cin >> mark >> number;
    if (mark=='S') markN = 0;
    else if (mark=='H') markN = 1;
    else if(mark=='C') markN = 2;
    else if(mark=='D') markN = 3;

    card[markN][number-1] = true;
  }
  char m[4] = {'S', 'H', 'C', 'D'};
  rep(i, 4) {
    rep(j, 13) {
      if(card[i][j] == false) printf("%c %d\n", m[i], j+1);
    }
  }
  return 0;
}

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

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;

// 深さ優先探索
vector<bool> seen;  // 探索したか記録
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto e : G[v]) {
        if (!seen[e.to]) {  // 訪問済みでなければ探索
            dfs(G, e.to);
        }
    }
}

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

    Graph G(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back({b-1});
        G[b-1].push_back({a-1});
    }

    seen.assign(n, false);  // 初期化
    int cnt = 0; 
    for (int i = 0; i < n; i++) {
        if (!seen[i]) {
            dfs(G, i);
            cnt++; // dfsした回数をカウント
        }
    }
    cout << cnt-1 << endl;

    return 0;
}

Measured memory_bytes: 9596
n = int(input())
b2 = []
while n != 0:
    rem = n % -2
    n //= -2
    if rem == -1:
        rem = 1
        n += 1
    b2.insert(0, rem)

if len(b2) == 0:
    print(0)
else:
    print(str(b2).replace("[", "").replace("]", "").replace(", ", ""))

Measured memory_bytes: 3064
import Control.Monad
import Data.Maybe (fromJust)
import Data.List (elemIndex)

type Pos = (Int, Int)

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine :: IO [Int]
  ss <- map (map read . words) <$> replicateM n getLine :: IO [[Int]]
  ps <- map (map read . words) <$> replicateM m getLine :: IO [[Int]]
  let students = [(x,y) | s <- ss, let (x,y) = (head s, last s)]
  let points = [(x,y) | s <- ps, let (x,y) = (head s, last s)]
  let distances points st =  [man | pt <- points, let man = manhattan st pt]
  forM_ students (print . (+1) . minsInd . distances points)
  
manhattan :: Pos -> Pos -> Int
manhattan (x1,y1) (x2,y2) =
  abs (x1-x2) + abs (y1-y2)

minsInd :: [Int] -> Int
minsInd ns = fromJust $ elemIndex m ns 
  where m = minimum ns


Measured memory_bytes: 1020
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,t,a;
    cin>>n>>t>>a;
    vector<int>h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    double ans=INF;
    int id;
    for(int i=0;i<n;i++){
        double tmp=t-h[i]*0.006;
        double diff=abs(tmp-a);
        if(diff<ans){
            ans=diff;
            id=i+1;
        }
    }
    cout<<id<<endl;
    return 0;  
}

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

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

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

  ll n, a, b; cin >> n >> a >> b;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];

  ll ans = 0;
  rep(i, n-1) {
    ans += min(b, (x[i+1]-x[i])*a);
  }

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


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <cmath>

using namespace std;

int main(){

	string a;
	cin >> a;
	
	vector<char> b;

	for(int i=a.size()-1; i>=0; i--){
		b.push_back(a.at(i));
	}

	string x;
	for(char c:b){
		x += c;
	}
	if(a == x){
		puts("Yes");
	}else{
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if(x == 1) ans += 3e5;
  if(x == 2) ans += 2e5;
  if(x == 3) ans += 1e5;
  if(y == 1) ans += 3e5;
  if(y == 2) ans += 2e5;
  if(y == 3) ans += 1e5;
  if(x == 1 && y == 1) ans += 4e5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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

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



int main(){
    int a, b, t;
    cin >> a >> b >> t;
    int x = 0;
    int res = 0;
    while(true){
        if(x + a > t){
            break;
        }
        res += b;
        x += a;
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool dfs(int l, int r, vector<bool>& f, int fcnt, int scnt, int turn) {
    if(fcnt == 0) {
        return true;
    } else if(scnt == 0) {
        return false;
    }
    if(turn == 0) {
        bool res = false;
        bool put = false;
        if(1 <= l && f[l]) {
            res |= dfs(l-1, r, f, fcnt-1, scnt, (turn+1)%2);
            put = true;
        }
        if(r < 14 && f[r]) {
            res |= dfs(l, r+1, f, fcnt-1, scnt, (turn+1)%2);
            put = true;
        }
        if(!put) {
            res |= dfs(l, r, f, fcnt, scnt, (turn+1)%2);
        }
        return res;
    } else {
        bool res = true;
        bool put = false;
        if(1 <= l && !f[l]) {
            res &= dfs(l-1, r, f, fcnt, scnt-1, (turn+1)%2);
            put = true;
        }
        if(r < 14 && !f[r]) {
            res &= dfs(l, r+1, f, fcnt, scnt-1, (turn+1)%2);
            put = true;
        }
        if(!put) {
            res &= dfs(l, r, f, fcnt, scnt, (turn+1)%2);
        }
        return res;
    }
}

int main() {
    int N;
    cin >> N;
    while(N--) {
        vector<bool> f(14);
        for(int i=0; i<6; ++i) {
            int g; cin >> g;
            f[g] = true;
        }
        if(dfs(6, 8, f, 6, 6, 0)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 3084
from itertools import permutations


class Graph():
    def __init__(self):
        self.adjacency_dict = {}

    def add_vertex(self, v):
        self.adjacency_dict[v] = []

    def add_edge(self, v1, v2):
        self.adjacency_dict[v1].append(v2)
        self.adjacency_dict[v2].append(v1)

    def exists(self, path):
        for i in range(len(path)-1):
            if not path[i+1] in self.adjacency_dict[path[i]]:
                return False
        return True


def main():
    N, M = map(int, input().split())
    edges = [tuple(map(int, input().split())) for _ in range(M)]

    graph = Graph()
    for v in range(1, N+1):
        graph.add_vertex(v)
    for e in edges:
        graph.add_edge(e[0], e[1])

    count = 0
    for path in permutations(range(2, N+1)):
        path = list(path)
        path.insert(0, 1)
        if graph.exists(path):
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<cctype>

int main(){
    char ch;
    
    while(1){
        scanf("%c", &ch);{
            if(isalpha(ch)){
                if(islower(ch)){
                    printf("%c",toupper(ch));
                }else{
                    printf("%c",tolower(ch));
                }
            }else{
                printf("%c",ch);
            }
        }
    if (ch=='\n') break;    
    }
    return 0;
}


Measured memory_bytes: 2508
import sys
input = sys.stdin.readline
Q=int(input())
lr=[list(map(int,input().split())) for _ in range(Q)]
#素数リスト
n = 100000+100
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
#print(primes)
from bisect import bisect_left as bl
a=[0]*100001
for i in primes:
    s=bl(primes,(i+1)//2)
    if primes[s]==(i+1)//2:
        a[i]=1
#print(a)
for i in range(1,100001):
    a[i]+=a[i-1]

for i in range(Q):
    print(a[lr[i][1]]-a[lr[i][0]-1])


Measured memory_bytes: 79320
#include <bits/stdc++.h>
using namespace std;
int main(){
  string T;
  cin >> T;
  int N = T.size();
  for (int i = 0; i < N; i++){
    if (T[i] == '?'){
      T[i] = 'D';
    }
  }
  cout << T << endl;
}

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

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

int main(){
    ll N;
    cin >> N;
    ll t = 1000 - N % 1000;
    if(t==1000) t = 0;
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MOD=1e9+7;

int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}

int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}

int c[5001][5001];
int sum[2001];
int S[2001][2001];
int S2[2001][2001];
int S3[2001][2001];
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(c[a][b]!=-1) return c[a][b];
	if(a==b) return 1;
	return (c[a][b]=add(choose(a-1,b),choose(a-1,b-1)));
}

int modpow(int a, int b)
{
	if(b<0) return 0;
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(c,-1,sizeof(c));
	int r,b; cin>>r>>b;
	int ans=0;
	for(int i=0;i<=2000;i++)
	{
		for(int j=0;j<=i;j++)
		{
			S[i][j] = choose(i,j);
			S2[i][j]=mult(choose(i,j),j);
			S3[i][j]=mult(choose(i,j),choose(j,2));
			if(j>0)
			{
				S[i][j]=add(S[i][j],S[i][j-1]);
				S2[i][j]=add(S2[i][j],S2[i][j-1]);
				S3[i][j]=add(S3[i][j],S3[i][j-1]);
			}
		}
	}
	for(int k=1;k<=b;k++)
	{
		//how many k in front
		int coeff = choose(b-1,k-1);
		int R = r - (b - k);
		int B = b - k;
		//cerr<<R<<' '<<B<<'\n';
		if(R>=0)
		{
			for(int j = 0; j <= B; j++)
			{
				//RR...R<length b>RRR...R<length j starting and ending with B>RRR...RBB....B (default)
				if(j==0)
				{
					ans=add(ans,mult(coeff,R+1));
					continue;
				}
				else if(j==1)
				{
					for(int kk=0;kk<=R;kk++)
					{
						int rem=R-kk;
						if(rem>=1) ans=add(ans,mult(coeff,rem));
					}
					continue;
				}
				int res=0;
				res=add(res,mult((R*(R+1))/2, S[j-2][min(j-2,R)]));
				res=add(res,mult(MOD-R,S2[j-2][min(j-2,R)]));
				res=add(res,S3[j-2][min(j-2,R)]);
				ans=add(ans,mult(coeff,res));
			}
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 144128
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	s := nextString()
	// keyence := []byte("keyence")
	// b := []byte(s)
	for i := 0; i < len(s); i++ {
		for j := i; j < len(s); j++ {
			key := s[:i] + s[j:]
			// log.Println(i, j, key)
			if key == "keyence" {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
}

func intPow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func intMax(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func intMin(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func intSum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func intAbs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = newScanner()
}

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 896
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int n;
    string str;
    cin >> n >> str;

    string before = str.substr(0, n);
    string after = str.substr(n, n);
    reverse(after.begin(), after.end());

    map<pair<string, string>, int> bm;
    map<pair<string, string>, int> am;

    for (int mask = 0; mask < (1 << n); mask++) {
        string before_first;
        string before_second;
        string after_first;
        string after_second;
        for (int j = 0; j < n; j++) {
            if (mask & (1LL << j)) {
                before_first += before[j];
                after_first += after[j];
            } else {
                before_second += before[j];
                after_second += after[j];
            }
        }

        bm[make_pair(before_first, before_second)]++;
        am[make_pair(after_first, after_second)]++;
    }

    int ret = 0;

    for (auto it = bm.begin(); it != bm.end(); it++) {
        auto it2 = am.find(it->first);
        if (it2 != am.end()) {
            ret += it->second * it2->second;
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 91904
#include<iostream>
#include<string>
using namespace std;
string s[55];
int n,m;
int ans[55][55];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)   cin>>s[i];
	for(int i=1;i<=n;i++)
	  for(int j=0;j<m;j++)
	  {
	  	if(s[i][j]=='#')
	  	{
	  		ans[i][j]=-1;
	  	}
	  	else if(s[i][j]=='.')
	  	{
	  		for(int k=-1;k<=1;k++)
	  		  for(int l=-1;l<=1;l++)
	  		  {
	  		  	if(k!=0||l!=0)
	  		  	{
	  		  		if(s[i+k][j+l]=='#')   ans[i][j]++;
	  		  	}
	  		  }
	  	}
	  }
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<m;j++)
	 	 {
		  	if(ans[i][j]==-1)   cout<<"#";
			else                cout<<ans[i][j];
		  }
		  cout<<endl;
	}
	  
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int ans=0;
  for(int i=0;i<K;i++)
    ans+=A.at(i);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
n = int(input())
l = list(map(int, input().split(' ')))
sorted_l = sorted(l)

max_ = sorted_l[-1]
med = sorted_l[-1] / 2
# print(med)
left = 0
right = n - 1
while left < right:
    m = int((left + right) // 2)
    # print(left, right, sorted_l[m])
    if sorted_l[m] < med:
        left = m + 1
    else:
        right = m

median = sorted_l[m]
if (m + 1 < n and (abs(sorted_l[m + 1] - med) < abs(median - med))):
    median = sorted_l[m + 1]

if (0 < m - 1 and (abs(sorted_l[m - 1] - med) < abs(median - med))):
    median = sorted_l[m - 1]

if n == 2:
    print(max_, sorted_l[0])
else:
    print(max_, median)


Measured memory_bytes: 58664
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

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

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << "[" << e << "] ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	vector<int> ord{ -1, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
	int x, y;
	cin >> x >> y;

	if (ord[x] == ord[y]) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

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

int main () {
  int A, B; //10000 <= A <= B <=99999
  cin >> A >> B;
  int x = A;
  int n = 0;
  for (int i = 0; i < B - A + 1; i++) {
    int o1, o2, o3, o4, o5;
    o1 = x / 10000;
    o2 = x / 1000 % 10;
    o3 = x / 100 % 10;
    o4 = x / 10 % 10;
    o5 = x % 10;
    if ((o1 == o5)&&(o2 == o4)) {
      n++;
    }
    x++;
  }
  cout << n << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}

import Control.Monad
import Control.Applicative
import Control.Monad.ST
import Control.Monad.State
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)

getWords = getLine >>= return . words

readIntBS = fst . fromJust . BS.readInt

buildGraph :: (Int,Int) -> [(Node,Node,Cost)] -> Graph
buildGraph bound dat = runST $ do
  graph <- newArray bound [] :: ST s (STArray s Int [Edge])
  forM_ dat $ \(s,e,c) -> do
    modifyArray graph s ((e,c):)
    modifyArray graph e ((s,c):)
  freeze graph
  
for = flip map

main :: IO ()
main = do
  (n,m,r) <- listToTuple3 . map read . words <$> getLine :: IO (Int,Int,Int)
  rs <- map read . words <$> getLine :: IO [Int]
  graph <- buildGraph (1,n) . map (listToTuple3 . map readIntBS . BS.words) . BS.lines <$> BS.getContents :: IO Graph
  let wf = warshall_floyd graph

  print $ minimum . for (permutations rs) $ \xs -> sum . for [1..r-1] $ \i -> wf!(xs!!(i-1),xs!!i)

type Node = Int
type Cost = Int
type Edge = (Node, Cost)
type Graph = Array Node [Edge]

inf = div maxBound 2 :: Int

warshall_floyd :: Graph -> Array (Node,Node) Cost
warshall_floyd graph = runST $ do
  let (s,e) = bounds graph
  dp <- newArray ((s,s),(e,e)) inf :: ST s (STUArray s (Node,Node) Cost)

  forM_ [s..e] $ \i -> do
    writeArray dp (i,i) 0

  forM_ [s..e] $ \i -> do
    forM_ (graph ! i) $ \(j,c) -> do
      writeArray dp (i,j) c

  forM_ [s..e] $ \k -> do
    forM_ [s..e] $ \i -> do
      forM_ [s..e] $ \j -> do
        a <- readArray dp (i,j)
        b <- readArray dp (i,k)
        c <- readArray dp (k,j)
        writeArray dp (i,j) $ min a (b+c)

  freeze dp


Measured memory_bytes: 11644
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 7368791+10
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
//7368791
int main(){
    int n,m;
    while(cin>>n>>m,n+m){
        vector<int>num(MAX,0);
        vector<bool>flag(MAX,true);
        int cnt=0;
        for(int i=n;i<=MAX;i++){
            if(!flag[i])continue;
            cnt++;
            for(int j=1; i*j<MAX;j++)
                flag[i*j]=false;
            if(cnt==m)break;
        }
        int ans=0;
        for(int i=n;i<MAX;i++){
            if(flag[i]){ans=i; break;}
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 32756
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int a,b,alf[30],ans=-1;
string s;

int main() {
	cin>>s;
	for(int i=0;i<s.size();i++){
		alf[s[i]-'a']++;
	}
	for(int i=0;i<26;i++)if(alf[i]==0){ans=i;break;}
	string t="";
	if(ans==-1)t="None";
	else t+=(char)(ans+'a');
	cout<<t<<endl;
	return 0;
}



Measured memory_bytes: 512
import bisect
import sys
from collections import deque
import heapq
sys.setrecursionlimit(100000000)

def solve():
  n,m = (int(i) for i in input().split())
  query = []
  for i in range(n):
    a,b = (int(i) for i in input().split())
    query.append((a,b))
  query = sorted(query,reverse = False)
  query2 = []
  for i in range(n):
    query2 += [query[i][0]]

  ans = 0
  judge = []
  for i in range(m):
    left = bisect.bisect_left(query2,i+1)
    right = bisect.bisect_right(query2,i+1)
    for j in range(left,right):
     b,a = (query[j])
     heapq.heappush(judge, [-a,b])
    #print(judge)
    if len(judge) != 0:
     b,a = heapq.heappop(judge)
     ans += -b
  print(ans)
solve()
  
  

Measured memory_bytes: 31308
#include <stdio.h>
#include <stdlib.h>
#define N 1000

int main()
{
	char c;
	char *str;
	if( (str = (char*)malloc(N+1)) != NULL ) {
		scanf("%s", str);
		while(*str != '\0') {
			if( (c = *str-3) < 'A' )
				c += 26;
			putchar(c);
			str++;
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 536
/*
☭░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░☆
☭░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░☆
☭░░░░░░░░▓▓░▓▓▓▓▓▓▓▓░░▓▓▓░░░░░░░☆
☭░░░░░░░█▓▓░░░▓▓▓▓▓▓▓▓▓▓░▓░░░░░░☆
☭░░░░░░░█▓░░░░░░░░░░░░░▓▓▓▓░░░░░☆
☭░░░░░░▓█░░░░░░░░░░░░░░▓░▓▓░░░░░☆
☭░░░░░░▓▓░▀▀▀▀░░▀▀▓▓▓░░░▓▓▓░░░░░☆
☭░░░░░░░▓░██▓▓░░██▓░░░░░░▓▓░░░░░☆
☭░░░░░░▓░░░░░░░░░░░░░░░░░░▓░░░░░☆
☭░░░░░░▓░░░░░▓░░▓░░░░░░░░▓░░░░░░☆
☭░░░░░░▓▓░░▓▓░██░▓▓░░░░░░▓░░░░░░☆
☭░░░░░░░░▓███▀▀▀████░░░░▓▓▓░░░░░☆
☭░░░░░░░░▓░░░░░░░░░░░░░░▓▓▓▓░░░░☆
☭░░░░░░░░▓░░░░░░░░░░░░░▓▓▓▓▓░░░░☆
☭░░░░░░▓▓▓▓▓░▓▓▓▓▓░░░░▓▓▓▓▓░░░░░☆
☭░▓☆▓▓▓▓▓▓▓▓▓▓░░▓▓░░░▓▓▓▓▓▓▓▓░░░☆
▓▓▓▓▓▓▓▓▓█☆█▓▓▓▓▓░░░▓▓▓▓☆█▓▓▓▓☆▓▓
▓▓▓▓▓▓▓▓▓▓██
*/
#include <bits/stdc++.h>
using namespace std;

string a[302];
int ans[302][302];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif
  int h, w, k;
  cin >> h >> w >> k;
  int cnt = 0;
  for (int i = 0; i < h; i++) {
    cin >> a[i];
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        cnt++;
        ans[i][j] = cnt;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 1; j < w; j++) {
      if (ans[i][j] == 0) {
        ans[i][j] = ans[i][j - 1];
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = w - 1; j >= 0; j--) {
      if (ans[i][j] == 0) {
        ans[i][j] = ans[i][j + 1];
      }
    }
  }

  for (int i = 1; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (ans[i][j] == 0) {
        ans[i][j] = ans[i - 1][j];
      }
    }
  }

  for (int i = h - 1; i >= 0; i--) {
    for (int j = w - 1; j >= 0; j--) {
      if (ans[i][j] == 0) {
        ans[i][j] = ans[i + 1][j];
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << ans[i][j] << " ";
    }
    cout << "\n";
  }


  return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int main(void)
{
 int n;
   scanf("%d",&n); 
  
  int i;
  double x,sum=0;
  char u[4];
    
 for(i=0;i<n;i++){
  scanf("%lf %s",&x, u); 
   if(u[0]=='B')
    x=x*380000;
   sum+=x;
  }
  
 printf("%lf",sum);

 return 0;
}

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

const int N = 1010;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

struct Node {
    int x, y;
    Node(int X = 0, int Y = 0) {
        x = X;
        y = Y;
    }
};

int vis[N][N], d[N][N];
char str[N];
std::queue<Node> Q;

int main() {

    int n, m, ans = 0;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) {
        scanf("%s", str + 1);
        for(int j = 1; j <= m; j++) {
            if(str[j] == '#') {
                Q.push(Node(i, j));
                vis[i][j] = 1;
                d[i][j] = 0;
            }
        }
    }

    while(Q.size()) {
        int x = Q.front().x, y = Q.front().y;
        Q.pop();
        for(int i = 0; i < 4; i++) {
            int tx = x + dx[i], ty = y + dy[i];
            if(tx < 1 || ty < 1 || tx > n || ty > m || vis[tx][ty]) {
                continue;
            }
            vis[tx][ty] = 1;
            d[tx][ty] = d[x][y] + 1;
            Q.push(Node(tx, ty));
            ans = std::max(ans, d[tx][ty]);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 16400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int answer = 0;
		
		if (N == 100000) {
			answer = 9 + 900 + 90000;
		} else if (N <= 99999 && N >= 10000) {
			answer = 9 + 900 + (N - 9999);
		} else if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;
const double inf = 1e18;
struct e{
    int x, y;
    double nx, ny;
    char p;
}a[maxn];
int n;
double F(double mid)
{
    double maxx = -inf, minx = inf, maxy = -inf, miny = inf;
    for (int i = 0; i < n; ++i){
        a[i].nx = a[i].x, a[i].ny = a[i].y;
        if(a[i].p == 'L') a[i].nx = (double)a[i].x - mid;
        else if(a[i].p == 'R') a[i].nx = (double)a[i].x + mid;
        else if(a[i].p == 'U') a[i].ny = (double)a[i].y + mid;
        else a[i].ny = (double)a[i].y - mid;
        minx = min(minx, a[i].nx);
        maxx = max(maxx, a[i].nx);
        miny = min(miny, a[i].ny);
        maxy = max(maxy, a[i].ny);
    }
    return (maxx - minx) * (maxy - miny);
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> a[i].x >> a[i].y >> a[i].p;
    }
    double l = 0, r = 1e8;
    for (int i = 0; i < 100; ++i){
        double len = (r - l) / 3;
        double lmid = l + len, rmid = l + 2 * len;
        if (F(lmid) < F(rmid)) r = rmid;
        else l = lmid;
    }
    cout << fixed << F((l + r) / 2) << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string S;
    cin >> S;
    bool check = true;
    bool n = false, s = false;
    for (char c : S) {
        if (c == 'N') {
            n = true;
        }
        else if (c == 'S') {
            s = true;
        }
        if (n && s) {
            break;
        }
    }
    if (n != s) {
        cout << "No" << endl;
        return 0;
    }
    bool w = false, e = false;
    for (char c : S) {
        if (c == 'W') {
            w = true;
        }
        else if (c == 'E') {
            e = true;
        }
        if (w && e) {
            break;
        }
    }
    if (w == e) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3624
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j :
     for i in A:
             if i % 2 == 0 or i == 0:
                     A[A.index(i)] = i / 2
             else:
                     j = False
     if j == True:             
     	count += 1
print(count)

Measured memory_bytes: 3060
n,k = map(int,input().split())
p = list(map(int,input().split()))

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)


ans = []
s = sum(e_p[:k])
ans.append(s)
for i in range(1,n-k+1):
    s -= e_p[i-1]
    s += e_p[i+k-1]
    ans.append(s)
print(max(ans))


Measured memory_bytes: 25060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> p(m);
	vector<string> s(m);
	rep(i, m) {
		cin >> p[i] >> s[i];
	}

	vector<int> wa(n + 1, 0), ac(n + 1, 0);

	rep(i, m) {
		if (s[i] == "AC") {
			ac[p[i]]++;
		}
		else {
			if (ac[p[i]] >= 1) continue;
			wa[p[i]]++;
		}
	}
	
	int res1 = 0;
	int res2 = 0;
	rep(i, n + 1) {
		if (ac[i]) {
			res1++;
			res2 += wa[i];
		}
	}

	cout << res1 << ' ' << res2 << endl;

	return 0;
}


Measured memory_bytes: 6912
import numpy as np

N,M,C=map(int, input().split())
B_lst=list(map(int, input().split()))
A_lst=[]
for _ in range(N):
    A_lst.append(list(map(int, input().split())))

A=np.array(A_lst)
B=np.array(B_lst)

print(sum(((np.dot(A, B)+C)>0)*1))

Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5,inf=1e18+5;
ll n,k,a[N];
bool chk(ll x){
    ll tot=0;
    for(ll i=0;i<n;i++){
        if(a[i]<0){
            ll l=-1,r=n;
            while(l+1<r){
                ll mid=(l+r)/2;
                if(a[mid]*a[i]<x)r=mid;
                else l=mid;
            }
            tot+=n-r;
        }
        else{
            ll l=-1,r=n;
            while(l+1<r){
                ll mid=(l+r)/2;
                if(a[mid]*a[i]<x)l=mid;
                else r=mid;
            }
            tot+=r;
        }
        if(a[i]*a[i]<x)tot--;
    }
    tot/=2;
    return tot<k;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    for(ll i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll l=-inf,r=inf;
    while(l+1<r){
        ll mid=(l+r)/2;
        if(chk(mid))l=mid;
        else r=mid;
    }
    cout<<l;
}


Measured memory_bytes: 1792
function Main(input) {
	input = input.split("\n");
	
	var n = parseInt(input[0], 10);
	var s = [];
	
	for (var i = 1; i < n + 1; i++) {
	s.push(input[i]);
	}
	
	var AC = s.filter(item => item === 'AC')
	var WA = s.filter(item => item === 'WA')
	var TLE = s.filter(item => item === 'TLE')
	var RE = s.filter(item => item === 'RE')
	
	console.log("AC x " + AC.length);
	console.log("WA x " + WA.length);
	console.log("TLE x " + TLE.length);
	console.log("RE x " + RE.length);
	
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 42604
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long llint;
#define inf 1e18

llint n,m;
void solve(){
	cin >> n >> m;
	llint t=n-m;
	llint ans=100*t;
	ans+=1900*m;
	ans*=pow(2.0,m);
	cout << ans << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 512
def read_input():
    n, x = map(int, input().split())
    ls = [0] + list(map(int, input().split()))
    return n, x, ls


def submit():
    n, x, ls = read_input()

    curr = 0
    count = 0
    for l in ls:
        curr += l
        if curr <= x:
            count += 1

    print(count)


if __name__ == '__main__':
    submit()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int count = 0;
        for(int i = 0; i < n; i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(Math.pow(x, 2.0) + Math.pow(y, 2.0) <= Math.pow(d, 2)){
                count++;
            }
        }
        System.out.println(count);
    }
}

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

using namespace std;

typedef long long LL;

int main() 
{
	LL N;
	cin >> N;

	LL i0, i1;
	i0 = 2;
	i1 = 1;
	LL h = 0;
	for (int i = 0; i < N; i ++)
	{
		h = i0 + i1;
		i0 = i1;
		i1 = h;
	}
	cout << i0 << endl;
	return 0;
}

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

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


int S, W;

int main(){
	cin>>S>>W;
	if(W >= S){
		cout<<"unsafe"<<endl;
	}else{
		cout<<"safe"<<endl;
	}
	return 0;
}


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

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<ll> A(N + 1), B(N);
  rep(i, N + 1) cin >> A[i];
  rep(i, N) cin >> B[i];
  ll ans = 0;
  rep(i, N){
    ll c = min(A[i], B[i]);
    B[i] -= c;
    A[i] -= c;
    ans += c;
    c = min(A[i + 1], B[i]);
    B[i] -= c;
    A[i + 1] -= c;
    ans += c;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,k;
    cin >> n >> k;
    cout << min(n%k,k-n%k) << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;



int main(int argc, char *args[]) {
	int a, b;
	cin >> a >> b;
	if (a > b)cout << a - 1 << endl;
	else cout << a << endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    int maxi = 0, now = 0;
    rep(i,1,N){
        if(V[i-1] >= V[i]){
            now++;
        }else{
            maxi = max(maxi, now);
            now = 0;
        }
    }
    maxi = max(maxi, now);
    cout << maxi << endl;
}

Measured memory_bytes: 640
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d", $a, $b);

if ($a + $b == 15) {
    echo "+\n";
    exit;
}
if ($a * $b == 15) {
    echo "*\n";
    exit;
}
echo "x\n";


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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FU(i, a, b) for (int i = a; i < b; ++i)
#define fu(i, b) FU(i, 0, b)
#define FA(i, x) for (auto i : x)
#define all(V) (V).begin(), (V).end()
#define sz(V) ((int)V.size())
#define FD(i, a, b) for (int i = b - 1; i >= a; --i)
#define fd(i, b) FD(i, 0, b)

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string al, bo, ch;
  map<char, string> m;
  cin >> al;
  cin >> bo;
  cin >> ch;
  reverse(all(al)); reverse(all(bo)); reverse(all(ch));
  m['a'] = al; m['b'] = bo; m['c'] = ch;
  char curr = 'a';
  while (1){
    if (!m[curr].length()) {
      cout << (char)(curr - 32) << '\n';
      break;
    }
    else {
      char temp = m[curr].back();
      m[curr].pop_back();
      curr = temp;
    }
  }

  
  return 0;

}


Measured memory_bytes: 256
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    loop {
        let n:usize = read();
        let k:usize = read();
        if n == 0 && k == 0 {
            break;
        }
        let arr:Vec<i32> = (0..n).map(|_| read()).collect();
        let mut s:Vec<i32> = vec![0; n+1];
        for i in 0..n {
            s[i+1] = s[i] + arr[i];
        }

        let mut ans = std::i32::MIN;
        for i in 0..n-k {
            ans = max(ans, s[i+k]-s[i]);
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 5048
#include<stdio.h>
int main()
{
    int a,b,c,f=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a!=b) f++;
    if(a!=c) f++;
    if(b!=c) f++;
    if(a==b && a==c) f=1;
    printf("%d",f);
    return 0;
}


Measured memory_bytes: 128
package main

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

func main() {
	var a, b int
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		strs := strings.Split(line, " ")
		a, _ = strconv.Atoi(strs[0])
		b, _ = strconv.Atoi(strs[1])
	}

	var output string
	if a < b {
		output = "a < b"
	} else if a == b {
		output = "a == b"
	} else {
		output = "a > b"
	}

	fmt.Printf("%v\n", output)
}



Measured memory_bytes: 1092