akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
class Node{
public:
  int location;
  int p,l,r;
  Node(){}
};
class Point{
public:
  int id,x,y;
  Point(){}
  Point(int id,int x,int y): id(id),x(x),y(y){}
  bool operator<(const Point &p)const{
    return id<p.id;
  }
  void print(){
    printf("%d\n",id);
  }
};
static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1,const Point &p2){return p1.x<p2.x;}
bool lessY(const Point &p1,const Point &p2){return p1.y<p2.y;}

int makeKDTree(int l,int r,int depth){
  if(!(l<r)) return NIL;
  int mid=(l+r)/2;
  int t = np++;
  if(depth%2==0){
    sort(P+l,P+r,lessX);
  }else{
    sort(P+l,P+r,lessY);
  }
  T[t].location=mid;
  T[t].l=makeKDTree(l,mid,depth+1);
  T[t].r=makeKDTree(mid+1,r,depth+1);
  return t;
}

void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
  int x=P[T[v].location].x;
  int y=P[T[v].location].y;
  if(sx<=x&&x<=tx&&sy<=y&&y<=ty){
    ans.push_back(P[T[v].location]);
  }
  if(depth%2==0){
    if(T[v].l!=NIL){
      if(sx<=x) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
    }
    if(T[v].r!=NIL){
      if(x<=tx) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
    }
  }else{
    if(T[v].l!=NIL){
      if(sy<=y) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
    }
    if(T[v].r!=NIL){
      if(y<=ty) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
    }
  }
} 
   
int main(){
  int x,y;
  scanf("%d",&N);
  for(int i=0;i<N;i++) {
    scanf("%d %d",&x,&y);
    P[i]=Point(i,x,y);
    T[i].l = T[i].r = T[i].p = NIL;
  }
  np=0;
  int root=makeKDTree(0,N,0);

  int q;
  scanf("%d",&q);
  int sx,tx,sy,ty;
  vector<Point> ans;
  for(int i=0;i<q;i++){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    for(int j=0;j<(int)ans.size();j++){
      ans[j].print();
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 16452
n = int(input())
hs = list(map(int, input().split()))
hs = [ hs[i] - hs[i-1] if i!=0 else 0 for i in range(n) ]

max_c = 0
c = 0

for i in range(1, n):
  if hs[i] > 0:
    max_c = max(max_c, c)
    c = 0
  else:
    c += 1

if c > 0:
  max_c = max(max_c, c)
print(max_c)

Measured memory_bytes: 14252
from collections import defaultdict
 
n = int(input())
V = defaultdict(list)

for _ in range(n-1):
    a, b,c = map(int, input().split())
    V[a].append([b,c])
    V[b].append([a,c])

def dfs(source):
    dist = [-1]*(n+1)
    dist[source] = 0
    q = [source]
    while q:
        a = q.pop()
        for b in V[a]:
            if dist[b[0]]!=-1:
                continue
            dist[b[0]] = dist[a] + b[1]
            q.append(b[0])
    return dist

q,k = map(int, input().split())
dk = dfs(k)

for i in range(q):
    x,y = map(int,input().split())
    print(dk[x]+dk[y])

Measured memory_bytes: 55200
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int k; string s;
    cin >> k >> s;
    if(s.size() <= k) cout << s << "\n";
    else cout << s.substr(0, k)+"..." << "\n";
    return 0;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
nodes = tuple([] for i in range(N))
for i in range(M):
    a, b = MAP()
    a -= 1
    b -= 1
    nodes[a].append(b)
    nodes[b].append(a)

# 二部グラフ判定
color = [-1] * N
def rec(u, prev, c):
    if color[u] == -1:
        color[u] = c
    else:
        if color[u] == c:
            return True
        else:
            return False
    for v in nodes[u]:
        if v != prev:
            if not rec(v, u, 1-c):
                return False
    return True

if rec(0, -1, 0):
    a = sum(color)
    b = N - a
    ans = a*b - M
else:
    ans = N*(N-1) // 2 - M
print(ans)


Measured memory_bytes: 31212
#include <stdio.h>

int main(void)
{
        int a,b,k,i,j;

        scanf("%d%d%d",&a,&b,&k);

        for (i=a;i<=b;i++)
                if ((i<a+k)||(i>b-k))
                        printf("%d\n",i);
                        

        return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
  char k;
  cin>>k;
  if(k>='a'&& k<='z')cout<<"a";
  else cout<<"A";
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i)-1 = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main()
{	
    ll x;
    cin >> x;
    ll ans = 0;
    if(400 <= x && x < 600) ans = 8;
    if(600 <= x && x < 800) ans = 7;
    if(800 <= x && x < 1000) ans = 6;
    if(1000 <= x && x < 1200) ans = 5;
    if(1200 <= x && x < 1400) ans = 4;
    if(1400 <= x && x < 1600) ans = 3;
    if(1600 <= x && x < 1800) ans = 2;
    if(1800 <= x && x < 2000) ans = 1;    

    cout << ans << endl;
}


Measured memory_bytes: 3620
a,b,c,d = map(int,input().split())
A = a*c
B = a*d
if a<=0:
  if b>=0:
    C = 0
  else:
    C = a*c
else:
  C = a*c
if c <=0:
  if d >=0:
    D = 0
  else:
    D = a*c
else:
  D = a*c

E = b*c
F = b*d
print(max([A,B,C,D,E,F]))
    


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N, M;
    cin >> N >> M;

    vll A(M);
    rep(i, M) cin >> A[i];

    ll rem = N;
    rep(i, M){
        rem -= A[i];
        if(rem<0){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << rem << endl;
}


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

int main(){

    int K, X;
    cin >> K >> X;
    if (500*K >= X) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 
	
	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		int n = s.nextInt();
		int[] ar = new int[n+1];
		for(int i=1;i<=n;i++) {
			ar[i] = s.nextInt();
		}
		int c=0;
		for(int i=1;i<=n;i++) {
			if(i%2!=0 && ar[i]%2!=0)c++;
		}
		System.out.println(c);
		
	}
}

Measured memory_bytes: 32684
#include <iostream>
#include<stdio.h>
using namespace std;
#define int long long

signed main(){
    // Your code here!
    int n,m,o;
    int a[10001];
    
    o = 0;
    
    cin >> n >> m;
    for(int i = 0; i < 10001; i ++){
        a[i] = 0;
    }
    for(int s=0; s < m ;s++){
        cin >> a[s];
        o+=a[s];
    }
    if(n>=o){
        cout << n-o;
    }else{
        printf("-1");
    }
    
}


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

using namespace std;

struct Edge {
  int from, to, cost;
  Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

vector<optional<int>> BellmanFord(vector<Edge> &edges, int src, int node_size) {
  vector<optional<int>> dists(node_size);
  dists[src] = 0;
  for (int i = 0; i < node_size; ++i) {
    for (auto &e : edges) {
      if (!dists[e.from].has_value()) {
        continue;
      }

      int dist = dists[e.from].value() + e.cost;
      if (!dists[e.to].has_value() || dists[e.to].value() > dist) {
        dists[e.to] = dist;
        if (i == node_size - 1) {
          dists[node_size - 1].reset();
          break;
        }
      }
    }
  }

  return dists;
}

int main(int argc, const char *argv[]) {
  int n, m, p;
  cin >> n >> m >> p;
  vector<Edge> edges;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    c = p - c;
    g[b].push_back(a);
    edges.emplace_back(a, b, c);
  }

  queue<int> q;
  set<int> seen;
  q.push(n - 1);
  while (!q.empty()) {
    auto idx = q.front();
    q.pop();
    if (seen.count(idx) > 0) {
      continue;
    }

    seen.insert(idx);
    for (auto child : g[idx]) {
      q.push(child);
    }
  }

  auto it = remove_if(edges.begin(), edges.end(), [&](auto &edge) {
    return !seen.count(edge.from) || !seen.count(edge.to);
  });
  edges.erase(it, edges.end());

  auto ans = BellmanFord(edges, 0, n);
  if (ans[n - 1].has_value()) {
    int score = -ans[n - 1].value();
    cout << max(0, score) << '\n';
  } else {
    cout << -1 << '\n';
  }
}

Measured memory_bytes: 3924
import java.util.Scanner;

// 0306
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = "";
        while (n > 0) {
            s = (n % 3 == 0 ? "0" : n % 3 == 1 ? "+" : "-") + s;
            n = n % 3 == 2 ? n / 3 + 1 : n / 3;
        }
        System.out.println(s);
    }
}


Measured memory_bytes: 26224
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
s = S_LIST()
if len(set(s)) == 4:
    print('Four')
else:
    print('Three')

Measured memory_bytes: 5144
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};



int main(){
	double a,b,ans;
	cin>>a>>b;
	ans=ceil((a+b)/2);
	print(ans);


}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
 
int main() {
  int n,x,i,j,num;
  while(1){
    int num=0;
    cin>>n;
    if (n==0) break;
    cin>>x;
    for (i=1;i<=n;i++){
      for (j=1;j<=n;j++){
        if (i>j&&j>x-i-j&&x-i-j>0) num++;
      }
    }
    cout<<num<<endl;
  }
}

Measured memory_bytes: 1164
N,M,X,Y= map(int, raw_input().split())
xlist= map(int, raw_input().split())
ylist= map(int, raw_input().split())
xlist.sort()
ylist.sort()
if X<xlist[-1]<Y<ylist[0] or xlist[-1]<X<Y<ylist[0] or X<xlist[-1]<ylist[0]<Y or xlist[-1]<X<ylist[0]<Y:
    print "No War"
else:
    print "War"


Measured memory_bytes: 2568
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int prime[50000];
char flag[50001];

int getPrime()
{
	
	flag[0] = flag[1] = 0;
	
	memset(flag, 1, sizeof(flag));
	for (int i = 2; i < 50001; i++){
		if (flag[i] == 1){
			for (int j = 2; i * j < 50001; j++){
				flag[i * j] = 0;
			}
		}
	}
	int cnt = 0;
	for (int i = 2; i < 50001; i++){
		if (flag[i] == 1){
			prime[cnt++] = i;
		}
	}
	
	return (cnt);
}

int main(void)
{
	int primeCount;
	
	primeCount = getPrime();
	
	while (1){
		int n;
		int ans;
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		ans = 0;
		for (int i = 0; prime[i] <= n / 2; i++){
			if (binary_search(prime, prime + primeCount, n - prime[i]) == true){
				ans++;
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC128
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ap = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine((ap[0] * 3 + ap[1]) / 2);
        }
    }
}


Measured memory_bytes: 13268
import math
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, X = list(map(int, sys.stdin.readline().split()))
S = list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


def mod_invs(max, mod):
    """
    逆元のリスト 0 から max まで
    :param max:
    :param mod:
    :return:
    """
    invs = [1] * (max + 1)
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


S.sort()

invs = mod_invs(N, MOD)
dp = np.arange(X + 1) % S[0]
for i in range(1, N):
    dp += dp[np.arange(X + 1) % S[i]] * invs[i]
    dp %= MOD
print(int(dp[X] * math.factorial(N) % MOD * invs[N] % MOD))


Measured memory_bytes: 14808
// 2016-12-02
#include <iostream>
#include <string>
using namespace std;

int main() {
	int n;
	int c = 0;
	string s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'A') {
			c++;
		} else {
			c--;
			if (c < 0) {
				break;
			}
		}
	}
	if (c) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let () =
  let l = read_line () in
  match List.map int_of_string (split l ' ') with
  | [] -> exit 1
  | ns -> begin
      List.iteri (fun i n ->
        if i = 0 then Printf.printf "%d" n
        else Printf.printf " %d" n)
        (List.sort compare ns);
      print_newline ()
    end

Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Converter(Console.ReadLine());
            Console.WriteLine(Calc(x));
        }

        static List<int> Converter(string str)
        {
            var array = str.Split(' ').ToList();
            return array.ConvertAll(int.Parse);
        }

        static string Calc(List<int> x)
        {
            int area = x.Aggregate((now, next) => now * next);
            int length = x.Aggregate((now, next) => (now * 2) + (next * 2));
            return area + " " + length;
        }
    }
}



Measured memory_bytes: 9432
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	int b[n - 1]; rep(i,n-1) cin >> b[i];
	int ans = 0;
	rep(i,n-2) {
		ans += min(b[i], b[i + 1]);
	}
	ans += b[0];
	ans += b[n - 2];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
e = [[str(i) for i in input().split()] for i in range(n)]
sum = 0.0
for i in range(n):
    if(str(e[i][1]) == "BTC"):
        e[i][0] = 380000*float(e[i][0])
    else:
        e[i][0] = float(e[i][0])
    sum = sum + float(e[i][0])

print(sum)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <bitset>
#include <queue>
#include <iostream>
 
using namespace std;
 
#define MAXN 510
#define INF 0x3f3f3f3f
typedef long long LL;
 
int main()
{
    int n, a, cnt = 0, vis[10] = {};
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i){
        scanf("%d", &a);
        if(a < 400) vis[0] = 1;
        else if(a < 800) vis[1] = 1;
        else if(a < 1200) vis[2] = 1;
        else if(a < 1600) vis[3] = 1;
        else if(a < 2000) vis[4] = 1;
        else if(a < 2400) vis[5] = 1;
        else if(a < 2800) vis[6] = 1;
        else if(a < 3200) vis[7] = 1;
        else ++cnt;
    }
    a = 0;
    for(int i = 0; i < 8; ++i)
        a += vis[i];
    printf("%d %d\n", a ? a : 1, a + cnt);
    return 0;
}

Measured memory_bytes: 256
#n = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
x,a,b = list(map(int,input().split(" ")))
#string = input()

distA = abs(x - a)
distB = abs(x - b)

if distA >= distB:
  print("B")
else:
  print("A")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define mii map<int,int>


using namespace std;

int main(){
    int k,n;
    cin>>n>>k;
    vi a(n);
    ll sum=0;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	sum+=a[i];
    }

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

    if(k>=n)
    	cout<<0<<endl;
    else{
    	for(int i=0;i<k;i++){
	    	sum-=a[n-i-1];
	    }
	    cout<<sum<<endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define vector3D(K, N, M, DP) vector<vector<vector<ll>>> DP(K, vector<vector<ll>>(N, vector<ll>(M)));
#define vector4D(K, N, M, O, DP) vector<vector<vector<vector<ll>>>> DP(K, vector<vector<vector<ll>>>(N, vector<vector<ll>>(M, vector<ll>(O))));
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;

/* ここからコード開始 */

vector<vector<ll>> A;
ll H, W, ans{};

void saiki(set<P> hw,ll kyori){
  ans = kyori;
  set<P> hw2;
  for(auto&& i : hw){
    iikae h = i.first;
    iikae w = i.second;
    if(h+1 < H) A[h+1][w] = min(kyori+1, A[h+1][w]);
    if(h > 0) A[h-1][w] = min(kyori+1, A[h-1][w]);
    if(w+1 < W) A[h][w+1] = min(kyori+1, A[h][w+1]);
    if(w > 0) A[h][w-1] = min(kyori+1, A[h][w-1]);
    if(h+1 < H && A[h+1][w] == kyori+1) hw2.insert(P(h+1, w));
    if(h > 0 && A[h-1][w] == kyori+1) hw2.insert(P(h-1, w));
    if(w+1 < W && A[h][w+1] == kyori+1) hw2.insert(P(h, w+1));
    if(w > 0 && A[h][w-1] == kyori+1) hw2.insert(P(h, w-1));
  }
  if(1-hw2.empty()) saiki(hw2, kyori+1);
}

int main(){
  kyopro;
  cin >> H >> W;
  char a;
  A.assign(H, vector<ll>(W,MOD));
  set<P> start;
  rep(i, 0, H) rep(j, 0, W){
    cin >> a;
    if(a == '#') start.insert(P(i, j));
  }
  for(auto&& i : start){
    A[i.first][i.second] = 0;
  }
  saiki(start, 0);
  cout << ans << rt;
}

Measured memory_bytes: 133376
n = int(input())


ans = 1

a = list(map(int, input().split()))

for e in a:
    if(e == 0): 
        print(0)
        exit()

for e in a:
    ans = ans * e
    if(ans > 1000000000000000000): 
        print(-1)
        exit()


print(ans)


Measured memory_bytes: 21664
from collections import defaultdict as ddict
from itertools import combinations as comb

n = int(input())
s = [input() for _ in range(n)]

dd = ddict(int)
for name in s:
    for i in ['M', 'A', 'R', 'C', 'H']:
        if name.startswith(i):
            dd[i] += 1

ans = sum(dd[i1] * dd[i2] * dd[i3] for i1, i2, i3 in comb(dd.keys(), 3))

print(ans)


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

using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;

ll qpow(ll a, ll b, ll mod = MOD) {
    ll res = 1;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

ll dp[maxn];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    ll res = 0;
    for (int i = k; i; i--) {
        dp[i] = qpow(k / i, n);
        for (int j = i + i; j <= k; j += i) dp[i] -= dp[j];
        res = (res + i * dp[i] % MOD) % MOD;
    }
    printf("%lld\n", (res + MOD) % MOD);
    return 0;
}


Measured memory_bytes: 4524
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a>>m>>b;
  while(a<=n)
  {
    a*=2;
    k++;
  }
  while(m<=a)
  {
    m*=2;
    k++;
  }
  if(k<=b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;

P Q [LEN];
int head, tail, n;

void enpueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

P depueue(){
    P x=Q[head];
    head = (head+1)%LEN;
    return x;
}
int min (int a,int b){return a < b ? a : b;}

int main(void){
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d %d", &n, &q);
    for(i=1;i<=n;i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;
    tail=n+1;
    while(head!=tail){
        u=depueue();
        c=min(q, u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0){
            enpueue(u);
        }else{
            printf("%s %d\n",u.name, elaps);
        }
    }
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s;
  cin >> s;
  vl counts(26,0);
  REP(i,4){
    counts[s[i]-'A']++;
  }
  ll c2 = 0;
  REP(i,counts.size()){
    if(counts[i]==2) c2++;
  }
  if(c2==2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>

int main(){
	int N;
	std::cin >> N;
	
	std::map<std::string, int> words;
	std::string strCur,strPre;
	bool isShiritori = true;
	for (int i=0;i<N;i++) {
		std::cin >> strCur;
		
		auto itr = words.find(strCur);
		if(itr == words.end()) {
			words[strCur] = 1;
		} else {
			isShiritori = false;
		}
		
		if(i>0 && strPre.back() != strCur.front()) {
			//std::cout << strPre.back() << ':' << strCur.front() << '\n';
			isShiritori = false;
		}
		
		strPre = strCur;
	}
	
	if (isShiritori) std::cout << "Yes" << '\n';
	else std::cout << "No" << '\n';

	return 0;
}

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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> a(n);
    int ate = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        int an = 1;
        int j = 1;
        while(an <= d){
            an = a[i] * j + 1;
            ate++;
            j++;
        }
    }
    cout << ate + x;
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    long long ans=0;
    int cnt=0;
    for (int i = s.size()-1; i >= 0; --i) {
        if(s[i]=='B'){
            ans+=s.size()-1-i-cnt;
            ++cnt;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<i32> = (0..n).map(|_| read()).collect();
    println!(
        "{}",
        a.iter()
            .map(|&x| {
                let mut x = x;
                for i in 0i32.. {
                    if x % 2 == 0 {
                        x /= 2;
                    } else {
                        return i;
                    }
                }
                0
            })
            .min()
            .unwrap()
    );
}

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


Measured memory_bytes: 4352
a, b, c = map(int, input().split())

ans = 'NO'
if (a == 5 and b == 7 and c == 5) or (a == 5 and b == 5 and c == 7) or (a == 7 and b == 5 and c == 5):
    ans = 'YES'
print(ans)

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

using namespace std;
int main(){
    int n,k,x;
    cin>>n>>k;
    int ans=0;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x>=k) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll;
#define pb push_back
#define endl        '\n'
#define PI 3.14159265358979
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    double a,b,x;
    cin>>a>>b>>x;
    if(2*x/(a*b)<=a){
    double ans=(atan(a*b*b/(2.0*x)))*180/PI;
    cout  << fixed  <<  setprecision(8) << ans <<  endl;
    }
    else
    {
        double ans=(atan((2*a*a*b-2*x)/(a*a*a)))*180/PI;
        cout  << fixed  <<  setprecision(8) << ans <<  endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long k = sc.nextLong();

    long a = n % k;
    long b = Math.abs(a - k);

    if(a>b){
      System.out.println(b);
    }else{
      System.out.println(a);
    }


  }
}

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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}

 
/*CODE START HERE*/
int main() {
  int n;
  cin >> n;
  int min_num ;
  vector<int> a(n);
  forn(i,n){
    cin >> a.at(i);
  }
  min_num= a.at(0);
  int min_count = 0;
  forn(i,n){
    if ( min_num>=a.at(i)){
      min_count ++;
      min_num=a.at(i) ;
    }
  }
  cout << min_count << endl;
}

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

int main(){
  string s;
  cin >> s;
  int count=0;
  for(int i=0; i<4; ++i){
    if(s[i]=='+')
      count ++;
    else if(s[i]=='-')
      count--;
  }
  cout << count << endl;
}
    

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
K = INT()
X = INT()
Y = INT()

if N <= K:
	print(X*N)
else:
	print(X*K + Y*(N-K))

Measured memory_bytes: 5200
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int res[100000+10],n; 
int main(){
	cin>>n;
	rb(i,1,n){
		int ai;
		cin>>ai;
		res[ai]=i;
	}
	rb(i,1,n) cout<<res[i]<<' ';
	return 0;
}


Measured memory_bytes: 1152
N = int(input())

if N < 10:
  print(N)
elif N < 100:
  print(9)
elif N < 1000:
  print(N - 90)
elif N < 10000:
  print(909)
elif N < 100000:
  print(N - 9090)
elif N == 100000:
  print(90909)

Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 10000000
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int a, b;
	cin >> a >> b;
	if (abs(a - b) % 2)puts("IMPOSSIBLE");
	else cout << min(a, b) + abs(a - b) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double EPS = 1e-9; // 許容誤差^2
const double INF = 1e9;
#define X real()
#define Y imag()
// #define LE(n,m) ((n) < (m) + EPS)
#define LE(n,m) ((n) - (m) < EPS)
// #define GE(n,m) ((n) + EPS > (m))
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

// 外積　cross(a,b) = |a||b|sinθ
double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

// 点の進行方向
int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

// 2直線の交点
Point crosspointLL(Point a1, Point a2, Point b1, Point b2) {
  double d1 = cross(b2-b1, b1-a1);
  double d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  assert(!EQ(d2, 0)); // 交点がない
  return a1 + d1/d2 * (a2-a1);
}

// 凸多角形クリッピング
VP convexCut(const VP& ps, Point a1, Point a2) {
  int n = ps.size();
  VP ret;
  rep(i,n) {
    int ccwc = ccw(a1, a2, ps[i]);
    if (ccwc != -1) ret.push_back(ps[i]);
    int ccwn = ccw(a1, a2, ps[(i + 1) % n]);
    if (ccwc * ccwn == -1) ret.push_back(crosspointLL(a1, a2, ps[i], ps[(i + 1) % n]));
  }
  return ret;
}

// ボロノイ領域
VP voronoiCell(Point p, const VP& ps, const VP& outer) {
  VP cl = outer;
  rep (i, ps.size()) {
    if (EQ(norm(ps[i]-p), 0)) continue;
    Point h = (p+ps[i])*0.5;
    cl = convexCut(cl, h, h + (ps[i]-h)*Point(0,1) );
  }
  return cl;
}

// 多角形の符号付面積
double area(const VP& ps) {
  double a = 0;
  rep (i, ps.size()) a += cross(ps[i], ps[(i+1) % ps.size()]);
  return a / 2;
}

int main(){
    int n,m;
    while(cin >>n >>m,n){
        VP island(n);
        rep(i,n){
            int x,y;
            cin >>x >>y;
            island[i] = Point(x,y);
        }

        VP castle(m);
        rep(i,m){
            int x,y;
            cin >>x >>y;
            castle[i] = Point(x,y);
        }

        rep(i,m){
            double S = abs(area(voronoiCell(castle[i], castle, island)));
            printf("%.10f\n", S);
        }
    }
    return 0;
}



Measured memory_bytes: 3200
import java.util.*;
public class Main {
    static double[][] nums;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int min=Integer.MAX_VALUE;
        int ans=0;
        int tmp;
        for(int i=0;i<n;i++){
            tmp=sc.nextInt();
            if(min>tmp){
                min=tmp;
                ans=i;
            }
        }
        System.out.println(ans+1);
    }


    
}


Measured memory_bytes: 68556
#include <iostream>
#include <string>
using namespace std;
int main() {
    int i,j,b;
    int flag=0;
    int count=0;
    int n;
    cin>>n;
    int a[n];
    for(i=0; i<n; ++i){
        cin>>a[i];
    }
    while(flag==0) {
        for (i = 0; i < n; ++i) {
            if (a[i] % 2 == 0) { a[i] = a[i] / 2; }
            else { flag = 1; break;}
        }
        if(flag==0)++count;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
str = list(input())
q = int(input())
for i in range(q):
    s = list(input().split())
    s[1] = int(s[1])
    s[2] = int(s[2])
    if s[0] == 'print':
        print(''.join(str[s[1]:s[2]+1]))
    elif s[0] == 'reverse':
        str[s[1]:s[2]+1] = ''.join(reversed(str[s[1]:s[2]+1]))
    elif s[0] == 'replace':
        str[s[1]:s[2]+1:1] = s[3]

Measured memory_bytes: 7616
#include<stdio.h>
#define N 25
#define NIL -1

struct node{
  int parent;
  int left;
  int right;
};

struct node a[N];
int n;

void preorder(int u){
  if(u==NIL) return;
  printf(" %d",u);
  preorder(a[u].left);
  preorder(a[u].right);
}

void inorder(int u){
  if(u==NIL) return;
  inorder(a[u].left);
  printf(" %d",u);
  inorder(a[u].right);
}

void postorder(int u){
  if(u==NIL) return;
  postorder(a[u].left);
  postorder(a[u].right);
  printf(" %d",u);
}

int main(){
  int i,p,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    a[i].parent=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&p,&l,&r);
    a[p].left=l;
    a[p].right=r;
    if(l!=NIL) a[l].parent=p;
    if(r!=NIL) a[r].parent=p;
  }

  for(i=0;i<n;i++) if(a[i].parent==NIL) root=i;
  
  printf("Preorder\n");
  preorder(root);
  printf("\n");
  printf("Inorder\n");
  inorder(root);
  printf("\n");
  printf("Postorder\n");
  postorder(root);
  printf("\n");

  return 0;
}


Measured memory_bytes: 2048
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define ull unsigned long long
#define y1 asjdlfaskavslbcjasndscf
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter vector< int >::iterator
#define iter1 multiset<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=1e7+7;
const int inf=1e18+1e9;
const int mod=998244353;
const ld eps=1e-9;

//const int MAX_MEM=1e8;
//int mpos=0;
//char mem[MAX_MEM];
//
//inline void * operator new(size_t n){
//    char *res=mem+mpos;
//    mpos+=n;
//    assert(mpos<=MAX_MEM);
//    return (void*)res;
//}
//
//inline void operator delete(void *) {}

int f[N],st2[N];
int rev[N];

int st(int n,int k)
{
    int res=1;
    while(k){
        if (k%2==1){
            res=(res*n)%mod;
        }
        n=(n*n)%mod;
        k/=2;
    }
    return res;
}

int C(int n,int k)
{
    int ans=f[n];
    ans=(ans*rev[k])%mod;
    ans=(ans*rev[n-k])%mod;
    return ans;
}

main ()
{
    ios;
    st2[0]=1;
    for (int i=1;i<N;++i){
        st2[i]=(st2[i-1]*2)%mod;
    }
    f[0]=1;
    for (int i=1;i<N;++i){
        f[i]=(f[i-1]*i)%mod;
    }
    rev[N-1]=st(f[N-1],mod-2);
    for (int i=N-2;i>=0;--i){
        rev[i]=(rev[i+1]*(i+1))%mod;
    }
    int n;
    cin>>n;
    int ans=st(3,n);
    int f=0;
    for (int i=n/2+1;i<=n;++i){
        f+=(C(n,i)*st2[n-i])%mod;
        f%=mod;
    }
    f=(f*2)%mod;
    ans=(ans-f+mod)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 234624
n  = int(input()) - 1

def f(n):
    p = 0
    ans=[]
    while True:
        if n >= 26**(p+1):
            n -=26**(p+1)
            p+=1
        else:
            for i in range(p+1):
                ans.append( chr( ord('a') + n%26 ) )
                n //= 26
            break
    print(''.join(reversed(ans)))

f(n)



Measured memory_bytes: 9044