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

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll max_h = 0;
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    if (a[i] >= max_h) {
      max_h = a[i];
    } else {
      ans += max_h - a[i];
      // cout << max_h << "," << a[i] << endl;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4836
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<functional>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define double long double
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n;
vector<int> prime;
bool primecheck(int n) {
	for (int i = 2; i <= sqrt(n); i++) if (n%i == 0)return false;
	return true;
}
signed main(){
	for (int i = 18; i <= 55555; i++) {
		if (primecheck(i) && i % 5 == 1)prime.push_back(i);
	}
	cin >> n;
	rep(i, n - 1) cout << prime[i] << " ";
	cout << prime[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception
	{
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		 String line = br.readLine();
		 StringTokenizer st = new StringTokenizer(line);
		 System.out.print((int)Math.floor(Integer.parseInt(st.nextToken())/3));
	}
}


Measured memory_bytes: 21204
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define F(i,n) for(ll i=0;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=2e5+5;
    	/*	bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff > b.ff;
			}*/
 /*void bfs(ll x)
 {
 	queue<ll> q;
	q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
            	l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	set<ll> s;
	for(ll i=0;i<n;i++)
	{
		ll d;
		cin>>d;
		for(ll j=0;j<d;j++)
		{
			cin>>a[j];
			s.insert(a[j]);
		}
	}
	cout<<n-s.sz;
}
int32_t main(){
	mr_ad_0501;
	ll t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include<cmath>
using namespace std;
#define endl '\n'

using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int x,temp=100,count=0;
    cin >> x;
    while(temp<x){
        temp = temp * 1.01;
        count++;
    }
    cout << count;
    return 0;
}

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

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

int main() {
  int n,X;
  cin>>n>>X;
  int x[100005];
  for (int i=0; i<n; i++) {
    cin>>x[i];
  }
  x[n]=X;
  sort(x,x+(n+1));
  int d[100005];
  for (int i=0; i<n; i++) {
    d[i]=x[i+1]-x[i];
  }
  int ans;
  ans=d[0];
  for (int i=0; i<n-1; i++) {
    ans=gcd(ans,d[i+1]);
  }
  cout<<ans<<endl;     
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
    
int main(){
    string s;
    cin >> s;
    int z = count(s.begin(), s.end(), '0');
    int o = count(s.begin(), s.end(), '1');
    cout << 2 * min(z, o) << endl;
    return 0;
}

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

using namespace std;

int main(){
    int n; cin >> n;
    long long a, b; cin >> a >> b;
    vector<long long> pos(n);
    vector<long long> dis(n);

    cin >> pos[0];

    long long boarder = 0;
    long long ans = 0;
    for(int i = 1; i < n; i++){
        cin >> pos[i];
        dis[i-1] = pos[i] - pos[i-1];
        if(dis[i-1] * a >= b){
            boarder++;
            ans += b;
        }
        else{
            ans += dis[i-1] * a;
        }
    }
    cout << ans << endl;



	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <math.h>
#include <set>

using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
ll MOD = 1000000007;
ll X[200000];
ll Y[200000];
int main() {
	ll N; cin >> N;
	rep(i, 0, N) {
		ll t; cin >> t;
		X[i] = t;
		Y[i] = t;
	}

	sort(Y, Y + N);
	ll a = Y[N / 2 - 1];
	ll b = Y[N / 2];

	rep(i, 0, N) {
		if (a >= X[i]) {
			cout << b << endl;
		}
		else if (b <= X[i]) {
			cout << a << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5376
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//abc140D
int main(void) {
  int n, i=0, j=0, k=0, len=0, lmax=0,c=0;
  char sx;
  scanf("%d %d", &n, &k);
  int s[n];
  for(i=0; i < n; i++){
    scanf(" %c", &sx);
    if(sx == 'L') s[i]=0;
    else s[i]=2;
    //printf("%d",s[i]);
  }

  //printf("\n");

  for(i=0; i < n; i++){ //s: 0 LUnhappy,1 LHappy,2 RU,3 RH
    if(s[i] == 0 && i != 0 && s[i - 1] <= 1) s[i]=1;
    else if(s[i] == 2 && i != n - 1 && s[i + 1] >= 2) s[i]=3;
    if(s[i]==1||s[i]==3)c++;
    //printf("%d",s[i]);
  }
  if(c+2*k<n)printf("%d",c+2*k);
  else printf("%d",n-1);


  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const LL Maxn = 4010;
const LL Mod = 924844033;
LL n, K;
LL f[2][Maxn][2], l;
bool v[Maxn];
int main() {
	LL i, j, k;
	scanf("%lld%lld", &n, &K);
	l = 0;
	for(i = 1; i <= K; i++){
		l += (n-i)/K+1;
		v[l+1] = true;
	}
	for(i = 1; i <= K; i++){
		l += (n-i)/K+1;
		v[l+1] = true;
	}
	f[0][0][0] = 1;
	LL st = 0;
	for(i = 2; i <= l+1; i++){
		st ^= 1;
		if(v[i]){
			for(j = 0; j <= i; j++){
				f[st][j][0] = (f[st^1][j][0]+f[st^1][j][1])%Mod;
				f[st][j][1] = 0;
			}
		} else {
			for(j = 0; j <= i; j++){
				f[st][j][0] = (f[st^1][j][0]+f[st^1][j][1])%Mod;
				if(j) f[st][j][1] = f[st^1][j-1][0];
			}
		}
	}
	LL jc = 1, ans = 0;
	for(i = n; i >= 0; i--){
		if(i&1) ans = (ans-jc*f[st][i][0]%Mod+Mod)%Mod;
		else ans = (ans+jc*f[st][i][0]%Mod)%Mod;
		jc = jc*(n-i+1)%Mod;
	}
	printf("%lld\n", ans);
	return 0;
}

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

long long int gcd(long long int a, long long int b) {
    if(a>b) {
      if(a%b==0) return b;
      else return gcd(b, a%b);
    } else {
      if(b%a==0) return a;
      else return gcd(a, b%a);
    }
  }

int main() {
  int n;

  cin >> n;
  long long int ans = 0;
  for(int i=0;i<n;i++) {
    if(i==0) cin >> ans;
    else {
      long long int t;
      cin >> t;
      ans = t / gcd(ans, t) * ans;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private static HashMap<Integer, List<Integer>> graph;
    private static int[] in;
    public static void main(String[] args) throws Exception{
        FastScanner scanner = new FastScanner();
        int V = scanner.nextInt();
        int E = scanner.nextInt();

        graph = new HashMap<>(V);
        in = new int[V];
        for(int i = 0; i < V; ++i){
            graph.put(i, new LinkedList<>());
        }

        for(int i = 0; i < E; ++i){
            int u = scanner.nextInt();
            int v = scanner.nextInt();
            graph.get(u).add(v);
            ++in[v];
        }

        LinkedList<Integer> queue = new LinkedList<>();
        for(int i = 0; i < V; ++i){
            if(in[i] == 0){
                queue.add(i);
            }
        }

        List<Integer> result = new ArrayList<>(V);
        while(!queue.isEmpty()){
            Integer u = queue.remove();
            result.add(u);
            for(Integer v : graph.get(u)){
                --in[v];
                if(in[v] == 0){
                    queue.add(v);
                }
            }
        }

        PrintWriter printWriter = new PrintWriter(System.out);
        for(Integer n : result){
            printWriter.println(n);
        }
        printWriter.flush();
    }

    private static 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;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); 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() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 44196
#include <stdio.h>
#include <ctype.h>
#define SIZE 200

void push(int);
int pop(void);

int top = 0;
int s[SIZE];

int main(void){
	int c, a, op1, op2;
	while((c = getchar()) != EOF){
		if(isdigit(c)){
			ungetc(c, stdin);
			scanf("%d", &a);
			push(a);
		}else{
			switch(c){
			case '+':
					op2 = pop();
					op1 = pop();
					push(op1 + op2);
					break;
			case '*':
					op2 = pop();
					op1 = pop();
					push(op1 * op2);
					break;
			case '-':
					op2 = pop();
					op1 = pop();
					push(op1 - op2);
					break;
			case '\n':
					printf("%d\n", pop());
					break;
			case ' ':
					break;
			default:
					break;
			}
		}
	}

	return 0;
}

void push(int x){
	if(top < SIZE){
		top++;
		s[top] = x;
	}else{
		printf("error: Stack full\n");
	}
}

int pop(void){
	if(top > 0){
		top--;
		return s[top + 1];
	}else{
		printf("error: Stack empty\n");
	}
}

Measured memory_bytes: 1820
X, K, D = map(int, input().split())

if X == 0 and K%2 == 0:
  print(0)
elif X == 0 and K%2 == 1:
  print(abs(D))
elif X > 0 and X - D*K >= 0:
  print(X - D*K)
elif X < 0 and X + D*K <= 0:
  print(abs(X + D*K))
else:
  i = abs(X)//D
  if (K - i) % 2 == 0:
    print(abs(X)%D)
  else:
    print(abs(abs(X)%D-D))

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

int main (){
  string s,t,s1,t1;
  cin >> s >> t;
  vector<char> a(s.size());
  vector<char> b(t.size());
  for(int i = 0; i < s.size(); i++)
    a.at(i) = s.at(i);
  for(int j = 0; j < t.size(); j++)
    b.at(j) = t.at(j);
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  for(int i = 0; i < s.size(); i++)
    s1 += a.at(i);
  for(int j = 0; j < t.size(); j++)
    t1 += b.at(j);
  if (s1 < t1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
w, h, n = list(map(int, input().split()))
x0, y0 = 0, 0
for _ in range(n):
    x, y, a =list(map(int, input().split()))
    if a == 1:
        x0 = max(x0, x)
    elif a == 2:
        w = min(w, x)
    elif a == 3:
        y0 = max(y0, y)
    else:
        h = min(h, y)

print(max(0, w - x0) * max(0, h - y0))



Measured memory_bytes: 3060
#create date: 2020-09-19 21:14

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, x, m = na()
    ans = x
    l = [x]
    a = x
    for i in range(n-1):
        a = a**2
        a %= m
        if a == 0:
            ans += a
            print(ans)
            quit()
        if a in l:
            #print(a, l)
            j = l.index(a)
            r = i - j + 1
            res = sum(l[j:])
            k = ((n-i-1)%r)
            #print(k, n-i-1, r, l[j:(j+k)])
            ans += (n-i-1)//r * res + sum(l[j:(j+k)])
            break
        l.append(a)
        ans += a
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 68532
package main

import (
	"fmt"
	"io"
	"os"
)

func dfs(e [][]int, f []bool, i int) {
	f[i] = true
	for _, v := range e[i] {
		if f[v] != true {
			dfs(e, f, v)
		}
	}
}

func answer(reader io.Reader, writer io.Writer) {
	var n, m int
	_, _ = fmt.Fscan(reader, &n, &m)
	e := make([][]int, n)

	for i := 0; i < m; i++ {
		var x, y, z int
		_, _ = fmt.Fscan(reader, &x, &y, &z)
		x--
		y--
		e[x] = append(e[x], y)
		e[y] = append(e[y], x)
	}
	f := make([]bool, n)
	count := 0
	for i := 0; i < n; i++ {
		if f[i] == false {
			count++
			dfs(e, f, i)
		}
	}
	_, _ = fmt.Fprintf(writer, "%d", count)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 37376
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

struct Pos
{
  int i, j;
  void read() { scanf("%d %d", &i, &j); i--, j--; }
  bool operator==(const Pos &other) const { return i == other.i && j == other.j; }
};

int n, m, k;
Pos origin, destination;
vector<vector<char>> mat;

int manhattan(Pos &pos)
{
  return abs(destination.i - pos.i) + abs(destination.j - pos.j);
}
int euclid(Pos &pos)
{
  int dx = destination.i - pos.i, dy = destination.j - pos.j;
  return sqrt(dx*dx + dy*dy);
}

struct Node
{
  lli dist, hdist; Pos pos; int dir, combo;
  bool operator<(const Node &other) const { return dist > other.dist; }
  // bool operator<(const Node &other) const { return dist > other.dist || (dist == other.dist && hdist > other.hdist); }
  void print() { printf("\t%lld (%d, %d) %d %d\n", dist, pos.i, pos.j, dir, combo); }
};
int di[4] = {1, -1, 0, 0}, dj[4] = {0, 0, 1, -1};
vector<vector<vector<lli>>> dist;
int dijkstra()
{
  priority_queue<Node> pq;
  pq.push(Node{0, 0, origin, 4, 1});
  dist[origin.i][origin.j][4] = 0;
  while (!pq.empty())
  {
    Node u = pq.top(); pq.pop();
    DEBUG u.print();
    if (u.dist > dist[u.pos.i][u.pos.j][u.dir])
      continue;

    // rotate
    for (int dir = 0; dir < 4; dir++)
    {
      lli newDist = (u.dist / k + (u.dist % k != 0)) * k;
      if (newDist < dist[u.pos.i][u.pos.j][dir])
        pq.push(Node{dist[u.pos.i][u.pos.j][dir] = newDist, newDist, u.pos, dir, u.combo});
    }
    // move
    if (u.dir != 4)
    {
      Pos newPos = {u.pos.i + di[u.dir], u.pos.j + dj[u.dir]};
      if (newPos.i < 0 || newPos.i >= n || newPos.j < 0 || newPos.j >= m || mat[newPos.i][newPos.j] == '@') continue;
      lli newDist = u.dist + 1;
      if (newDist < dist[newPos.i][newPos.j][u.dir])
        pq.push(Node{dist[newPos.i][newPos.j][u.dir] = newDist, newDist, newPos, u.dir, u.combo});
    }
  }
  lli ans = 1e18;
  for (int i = 0; i < 5; i++)
    ans = min(ans, dist[destination.i][destination.j][i]);
  return ans == 1e18 ? -1 : ans / k + (ans % k != 0);
}

int main()
{
  while (scanf("%d %d %d", &n, &m, &k) != EOF)
  {
    mat.clear();
    mat.resize(n, vector<char>(m));
    dist.clear();
    dist.resize(n, vector<vector<lli>>(m));
    origin.read(); destination.read();

    char line[m + 1];
    for (int i = 0; i < n; i++)
    {
      scanf(" %s", line);
      for (int j = 0; j < m; j++)
      {
        mat[i][j] = line[j];
        dist[i][j].resize(5, 1e18);
      }
    }

    int ans = dijkstra();
    printf("%d\n", ans);
  }
  return 0;
}


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

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

int main(){
  int n;
  cin>>n;
  int p[n];
  rep(i,n)
    cin>>p[i];
  sort(p,p+n);
  int ans=0;
  rep(i,n-1)
    ans+=p[i];
  ans+=p[n-1]/2;
  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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 = 1e18;

int dp[100010];

signed main(){
    int n, w; cin >> n >> w;
    REP(i,n){
        int a, b; cin >> a >> b;
        RREP(j,100005)if(j-a>-1) chmax(dp[j],dp[j-a]+b);
    }
    cout << dp[w] << endl;
}

Measured memory_bytes: 1024
loop do
	m,f,r = gets.chomp.split(" ").map(&:to_i)
	break if m == -1 && f == -1 && r == -1
	
	if m == -1 || f == -1
		puts "F"
		next
	elsif m + f >= 80
		puts "A"
		next
	elsif m + f >= 65 && m + f < 80
		puts "B"
		next
	elsif m + f >= 50 && m + f < 65
		puts "C"
		next
	elsif m + f >= 30 && m + f < 50
		if r >= 50
			puts "C"
		else
			puts "D"
		end
		next
	elsif m + f < 30
		puts "F"
		next
	end
end

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

template<typename Type> class RangeMin {
private:
	int size_;
	std::vector<Type> dat;
public:
	RangeMin() : size_(0), dat(std::vector<Type>()) {};
	RangeMin(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat.resize(size_ << 1, std::numeric_limits<Type>::max());
	}
	template<class T>
	RangeMin(T begin_, T end_) {
		int n = end_ - begin_;
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max());
		for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i);
		for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
	}
	inline unsigned size() { return size_; }
	inline void update(int i, Type x) {
		i += size_; dat[i] = x;
		while (i > 1) {
			i >>= 1;
			dat[i] = std::min(dat[i << 1], dat[i << 1 | 1]);
		}
	}
	inline Type query(int l, int r) {
		Type ret = std::numeric_limits<Type>::max();
		l += size_; r += size_;
		while (l != r) {
			if (l & 1) ret = std::min(ret, dat[l++]); l >>= 1;
			if (r & 1) ret = std::min(ret, dat[--r]); r >>= 1;
		}
		return ret;
	}
};

long long N, K; char c[1 << 18];
long long dp[1 << 18];
RangeMin<int> Z;

int main() {
	cin >> N >> K;
	for (int i = 0; i <= N; i++) cin >> c[i];

	Z = RangeMin<int>(N + 2);

	dp[N] = 0; Z.update(N, 0);
	for (int i = N - 1; i >= 0; i--) {
		if (c[i] == '1') { dp[i] = 1000000000; }
		else { dp[i] = min(1000000000, Z.query(i + 1, min(i + K, N) + 1) + 1); }
		Z.update(i, dp[i]);
	}

	vector<int> vec; int cx = 0; vec.push_back(0);
	while (cx < N) {
		int cl = cx + 1, cr = N + 1, cm, minx = (1 << 30);
		for (int i = 0; i < 24; i++) {
			cm = (cl + cr) / 2;
			int V = Z.query(cx + 1, cm + 1);
			if (V < dp[cx]) { minx = min(minx, cm); cr = cm; }
			else { cl = cm; }
		}
		cx = minx; vec.push_back(cx);
	}

	if (dp[0] == 1000000000) {
		cout << "-1" << endl;
	}
	else {
		for (int i = 0; i < (int)vec.size() - 1; i++) { if (i) cout << " "; cout << vec[i + 1] - vec[i]; }
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2812
S_nk = input().split(" ") #標準入力（N, K）
S_h = input().split(" ") #標準入力（Hi）

N = int(S_nk[0]) #モンスターの種類
K = int(S_nk[1]) #必殺技の制限回数
H = [] #モンスターのヒットポイント
for i in range(N):
  H.append(int(S_h[i]))

#ヒットポイントの大きい順にソート
H.sort(reverse=True)

if K < len(H):
  for i in range(K):
  	H[i] = 0
  print(sum(H))
else:
  print(0)

Measured memory_bytes: 27128
#include<stdio.h>
int main(){
  int a,b,c=0;
  scanf("%d %d",&a,&b);
  for(int i=1; i<=a; i++){
    for(int j=1; j<=b; j++){
      if(i==(j/10)*(j%10)&&j>=20&&(j%10)>=2){
        c++;
      }
    }
  }
  printf("%d",c);
  return 0;}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}



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

using namespace std;
using ll = long long;

void solve(ll A, long double B) {
  cout << fixed << setprecision(0) << floor(A * B) << endl;
  // cout << A * Bint / 100 << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll A;
  long double B;
  cin >> A >> B;

  solve(A, B);

  return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll dp[1001][1001];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,N);
  AIN(ll,A,N);
  map<int,int> count;
  ll a = 0,b = 0;
  REP(i,N){
    count[A.at(i)]++;
    if(count[A.at(i)] >= 2){
      if(chmax(b,A.at(i))){
        if(a < b)
          swap(a,b);
        count[A.at(i)] = 0;
      }
    }
  }
  OUT(a*b);
}



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

int main(){
    int a[3];
    int k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(a, a+3);
    for(int i=0; i<k; i++) a[2] *= 2;
    cout << a[0] + a[1] + a[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int N;
int A[1000000];

int cnt;
int m;
vector<int> G;

void isort(int g) {
    for (int i = g; i < N; i++) {
        int v = A[i];
        int j;
        for (j = i - g; j >= 0 && A[j] > v; j -= g) {
            A[j + g] = A[j];
            cnt++;
        }
        A[j + g] = v;
    }
}

void solve() {
    cnt = m = 0;
    for (int i = max(N / 2, 1); i > 0; i /= 2) {
        m++;
        isort(i);
        G.push_back(i);
    }
}

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

    solve();

    cout << m << endl;
    cout << G[0];
    for (int i = 1; i < (int)G.size(); i++) {
        cout << " " << G[i];
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < N; i++) {
        cout << A[i] << endl;
    }
}

Measured memory_bytes: 5124
#include <stdio.h>

int main(){

    
    double r,SA,SL;
     
 	  scanf("%lf",&r);
 
    SA=3.141592653589*r*r;
    SL=3.141592653589*2.0000000000000*r;
 
 	printf("%.6f %.6f\n",SA,SL);

	return 0;
}

Measured memory_bytes: 652
/*
 * @Author: Kaizyn
 * @Date: 2020-05-30 19:56:47
 * @LastEditTime: 2020-05-30 20:07:00
 */ 
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;

int h1, m1, h2, m2, k;

inline void solve() {
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int t = m2-m1+(h2-h1)*60-k;
  cout << max(0, t) << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3632
while True:
    n=int(input())
    if n==0:
        break
    else:
        max_s=0
        min_s=2000
        sum_s=0
        for i in range(n):
            s=int(input())
            sum_s=sum_s+s
            if s<min_s:
                min_s=s
            if s>max_s:
                max_s=s
        print((sum_s-max_s-min_s)//(n-2))


Measured memory_bytes: 5596
#include<stdio.h>
int main(void){
	int h=1, w=1,countah,countaw;
	while (h != 0 && w != 0){
		scanf("%d", &h);
		scanf("%d", &w);
		for (countah = 1; countah <= h; countah++){
			for (countaw = 1; countaw <= w; countaw++){
				printf("#");
			}
			printf("\n");
		}
		if (h != 0 && w != 0){
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 572
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string s;
int K;
set<string> st;

int main() {
  cin >> s;
  cin >> K;

  for (int i = 0; i < s.size(); ++i) {
    string subst = "";
    for (int j = i; j < min(i + 5, int(s.size())); ++j) {
      subst.push_back(s[j]);
      st.insert(subst);
    }
  }

  auto iter = st.begin();
  rep(i, 0, K - 1) { ++iter; }
  cout << *iter << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

    int X;
    cin >> X;

    if (X >= 30) {
        cout << "Yes";
    }
    else cout << "No";
}

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() == b[0] && b.back() == c[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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


const int INF = 1001001001;

int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n);
  rep(i, n)
  {
    queue<int> q;
    vector<int> sht(n, INF);
    int p;
    sht[i] = 0;
    q.push(i);
    while (!q.empty())
    {
      p = q.front();
      q.pop();
      if (p + 1 < n && sht[p + 1] == INF)
        q.push(p + 1), sht[p + 1] = sht[p] + 1;
      if (p - 1 >= 0 && sht[p - 1] == INF)
        q.push(p - 1), sht[p - 1] = sht[p] + 1;
      if (p == x && sht[y] == INF)
        q.push(y), sht[y] = sht[p] + 1;
      if (p == y && sht[x] == INF)
        q.push(x), sht[x] = sht[p] + 1;
    }
    rep(i, n) ans[sht[i]]++;
  }
  rep(i, n) ans[i] /= 2;
  for (int i = 1; i < n; i++)
  {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

vector<ll> f(ll a) {
    vector<ll> ret(30);
    for(int i = 0; i < 30; i++) {
        ret[i] = a % 3;
        a /= 3;
        //cerr << ret[i] << " ";
    }
    //cerr << endl;
    return ret;
}

vector<ll> v[4];
ll beki[35];

ll val(vector<ll> v) {
    ll ret = 0;
    for(int i = 0; i < 30; i++) {
        ret += beki[i] * v[i];
    }
    return ret;
}

bool contain(vector<ll> v, vector<ll> w, int idx) {
    if(val(v) > val(w)) {
        return contain(w, v, idx);
    }
    for(int i = 0; i < idx; i++) {
        v[i] = 2;
    }
    if(v[idx] == 2) {
        v[idx] = 3;
    }
    ll delta = 0;
    for(int i = 0; i < 30; i++) {
        delta += (w[i] - v[i]) * beki[i];
    }
    return delta >= beki[idx];
}

void solve() {
    ll a[4];
    for(int i = 0; i < 4; i++) {
        cin >> a[i];
        a[i]--;
        v[i] = f(a[i]);
    }
    bool Hsame = true;
    bool Wsame = true;
    ll ans = abs(a[0] - a[2]) + abs(a[1] - a[3]);
    for(ll idx = 29; idx >= 0; idx--) {
        if(v[0][idx] != v[2][idx]) Hsame = false;
        if(v[1][idx] != v[3][idx]) Wsame = false;
        if(!Hsame and !Wsame) {
            cout << ans << endl;
            return;
        }
        if(Hsame and Wsame) continue;
        cerr << idx << " " << Hsame << " " << Wsame << endl;
        if(Hsame) {
            ll tmp = 1e18;
            //cerr << v[0][idx-1] << endl;
            if(v[0][idx] != 1) continue;
            if(!contain(v[1], v[3], idx)) continue;
            ll bone = a[0] % beki[idx];
            ll btwo = a[2] % beki[idx];
            cerr << bone << " " << btwo << endl;
            chmin(tmp, (bone + 1) * 2);
            chmin(tmp, (btwo + 1) * 2);
            chmin(tmp, (beki[idx] - bone) * 2);
            chmin(tmp, (beki[idx] - btwo) * 2);
            cout << ans + tmp << endl;
            return;
        }
        if(Wsame) {
            ll tmp = 1e18;
            if(v[1][idx] != 1) continue;
            if(!contain(v[0], v[2], idx)) continue;
            ll bone = a[1] % beki[idx];
            ll btwo = a[3] % beki[idx];
            chmin(tmp, (bone + 1) * 2);
            chmin(tmp, (btwo + 1) * 2);
            chmin(tmp, (beki[idx] - bone) * 2);
            chmin(tmp, (beki[idx] - btwo) * 2);
            cout << ans + tmp << endl;
            return;
        }
    }
    cout << ans << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Q;
    cin >> Q;
    beki[0] = 1;
    for(ll i = 1; i <= 30; i++) {
        beki[i] = beki[i-1] * 3;
    }
    while(Q--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    string s,r;
    while(cin >> s){
        r.clear();
        for(int i = 0; i < s.size(); i++){
            if(s[i] == '@'){
                for(int z = 0; z < s[i+1] - '0'; z++)
                    r += s[i+2];
                i += 2;
            }
            else{
                r += s[i];
            }
        }
        cout << r << endl;
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, K;
vector<int> P, C;
map<int,vector<pair<ll,int>>> memo;
vector<pair<ll,int>> f(int k) {
	if (memo.count(k)) return memo[k];
	if (k == 1) {
		vector<pair<ll,int>> r(N);
		for (int i = 0; i < N; ++ i) {
			r[i] = {C[P[i]], P[i]};
		}
		return memo[k] = r;
	} else {
		int x = k/2;
		if (N < K-N && k > K-N) {
			x = K-N;
		}
		int y = k-x;
		auto a = f(x);
		auto b = f(y);
		vector<pair<ll,int>> r(N);
		for (int i = 0; i < N; ++ i) {
			auto x = a[i];
			auto y = b[x.second];
			r[i] = {x.first+y.first, y.second};
		}
		return memo[k] = r;
	}
}
int main() {
	cin >> N >> K;
	P.resize(N);
	C.resize(N);
	for (auto& x : P) { cin >> x; -- x; }
	for (auto& x : C) cin >> x;
	auto res = -(1LL<<62);
	for (int kk = 1; kk <= K; ++ kk) {
		if (kk == N+1 && kk < K-N) kk = K-N;
		for (auto x : f(kk)) {
			res = max(res, x.first);
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 788744
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#include <ctime>
#define Maxn 100005
#define Maxm 1000005
#define Mod 9973
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define random(x) (rand()%x)
#define LL long long
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
int main()
{
	int arr[Maxn],n,ans;
	//input;output;
	while(~scanf("%d",&n))
	{
		ans=0;
		for(int i=1;i<=n;i++)
			scanf("%d",arr+i);
		for(int i=1;i<=n;i++)
			if(arr[arr[i]]==i)
				ans++;
		printf("%d\n",ans/2);
	}
	return 0;
}

Measured memory_bytes: 640
s = input()
t = input()

maiores = []
maior = 0

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j] == t[j]:
            maior += 1
    maiores.append(maior)
    maior = 0


print(len(t) - max(maiores))

Measured memory_bytes: 67712
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll b=0;
  vector<ll>vec(a);
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
    b+=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<b-vec.at(a-1)/2<<endl;
  return 0;
}
    
    
  


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

using namespace std;

int main()
{
	long long int n, k, max_seg = 0, first_seg, prev_seg, curr_seg;
    cin >> k >> n;
    cin >> first_seg;
    prev_seg = first_seg;
    for(int i = 1; i < n; ++i) {
        cin >> curr_seg;
        max_seg = max(max_seg, curr_seg - prev_seg);
        prev_seg = curr_seg;
    }
    max_seg = max(max_seg, k - curr_seg + first_seg);
    cout << k - max_seg << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void)
{
  int n, k, h[100000], min=1000000000, d, i;
  
  scanf("%d %d", &n, &k);
  for(i=0; i<n; i++){
    scanf("%d", &h[i]);
  }
  qsort(h, n, sizeof(int), compare_int);
  for(i=0; i<n-k+1; i++){
    d = h[i+k-1] - h[i]; 
    if(d < min){
      min = d;
    }
  }
  printf("%d\n", min);
  
  return 0;
}

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

int a[100007];
int b[100007];
int main(){
	int n;
	long long ans = 0;
	
	cin >> n;
	for(int i = 0;i<=n;i++){
		cin >> a[i];
	}
	for(int i = 0;i < n;i++){
		cin >> b[i];
	}
	for(int i = 0;i < n;i++){
		if(b[i]>=a[i]+a[i+1]){
			ans+=(a[i]+a[i+1]);
			a[i] = a[i+1] = 0;
		}
		else{
			if(b[i] > a[i]) a[i+1] = a[i]+a[i+1]-b[i];
			ans+=b[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;

const int maxn = 1e5+5;
bool vis[maxn];
int n, m, x, y, dp[maxn];
vector<int> vs[maxn], topo;

void dfs(int v){
	vis[v] = true;
	for(int e: vs[v]) if (!vis[e]) dfs(e);
	topo.push_back(v);
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i<m; i++){
		scanf("%d %d", &x, &y);
		vs[--x].push_back(--y);
	}
	for(int i = 0; i<n; i++) if (!vis[i]) dfs(i);
	reverse(topo.begin(), topo.end());
	int ans = -1;
	for(int v: topo)
		for(int e: vs[v]) ans = max(dp[e] = max(dp[e], dp[v]+1), ans);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 8824
char s[72],r[72],x;main(i){for(read(0,r,71);i<4;puts(r))for(printf("%d\n",90*i++),memcpy(s,r,71),x=72;x--;)x%9-8&&(r[x]=s[x/9+(7-x%9)*9]);exit(0);}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 100000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

void solve(void){
    int Q;
    cin >> Q;
    rep(Q, i) {
        ll A, B;
        scanf("%lld %lld\n", &A, &B);
        ll K = A*B, lim = (ll)sqrt(K);
        if (lim * lim == K) {
            ll ans = 2*lim-3;
            if (A==B) ans++;
            printf("%lld\n", ans);
        }
        else {
            ll ans = lim*2-1;
            if (lim == (K-1LL) / lim) {
                if (lim*lim >= K) ans-=2;
                else ans--;
            }
            ans -= (B == (K-1LL) / A);
            printf("%lld\n", ans);
        }
    }
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    if(n%10==3) cout<<"bon"<<endl;
    else if(n%10==0||n%10==1||n%10==6||n%10==8) cout<<"pon"<<endl;
    else cout<<"hon"<<endl;

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include <string> 
using namespace std;
long max(long x, long y) {
	if (x > y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

int dig(long a) {
	int b=0;
	while (a > 0) {
		a /= 10;
		b++;
	}
	return b;
}

void m_sort(int a[], int tmp[], int left, int right);
void m_sort(int a[], int tmp[], int left, int right);
void sort(int a[], int total) {
	int tmp;
	for (int i = 0; i < total; i++) {
		for (int j = i + 1; j < total; j++) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

}

void mergeSort(int a[], int tmp[], int size)
{
	m_sort(a, tmp, 0, size - 1);
}
void merge(int a[], int tmp[], int left, int mid, int right)
{
	int i, left_end, num_elements, tmp_pos;

	left_end = mid - 1;
	tmp_pos = left;
	num_elements = right - left + 1; // 要素 

	while ((left <= left_end) && (mid <= right))
	{
		if (a[left] <= a[mid])
		{
			tmp[tmp_pos] = a[left];
			tmp_pos = tmp_pos + 1;
			left = left + 1;
		}
		else
		{
			tmp[tmp_pos] = a[mid];
			tmp_pos = tmp_pos + 1;
			mid = mid + 1;
		}
	}


	while (left <= left_end)
	{
		tmp[tmp_pos] = a[left];
		left = left + 1;
		tmp_pos = tmp_pos + 1;
	}

	while (mid <= right)
	{
		tmp[tmp_pos] = a[mid];
		mid = mid + 1;
		tmp_pos = tmp_pos + 1;
	}


	for (i = 0; i <= num_elements; i++)
	{
		a[right] = tmp[right];
		right = right - 1;
	}
}
void m_sort(int a[], int tmp[], int left, int right)
{
	int mid;

	if (right > left)
	{
		mid = (right + left) / 2;
		m_sort(a, tmp, left, mid);
		m_sort(a, tmp, mid + 1, right);

		merge(a, tmp, left, mid + 1, right);
	}
}

long N, a[100000], a2[100000], b[100000], K, ans, num[100001];


int main(){
	cin >> N >> K;
	for (int i = 0; i < 100001; i++) {
		num[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
		num[a[i]] += b[i];
	}

	for (int i = 0; i < 100001; i++) {
		K -= num[i];
		if (K <= 0) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
w,h,n=map(int,input().split())

y_min=0
y_max=h
x_min=0
x_max=w

for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    x_min=max(x_min,x)
  if a==2:
    x_max=min(x_max,x)
  if a==3:
    y_min=max(y_min,y)
  if a==4:
    y_max=min(y_max,y)

y_ok=y_max-y_min
x_ok=x_max-x_min

if y_ok>=0 and x_ok>=0:
  print(y_ok*x_ok)
else:
  print(0)

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

int N;
int A[210];

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];

  int res = 0;

  while (true) {
    bool flag = false;
    for (int i = 0; i < N; ++i) {
      if (A[i] % 2 != 0) flag = true;
    }

    if (flag) break;

    for (int i = 0; i < N; ++i) {
      A[i] /= 2;
    }
    ++res;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int main(void){
	
	int n,m;
	
	while(scanf("%d %d", &n, &m) && n != 0 ){
		vector<int > a;
		int temp;
		int ans = 0;
		
		for(int i = 0; i < n; i++){
			scanf("%d", &temp);
			a.push_back(temp);
		}
		
		sort(a.begin(),a.end(),greater<int>());
		
		for(int i = 0; i < n; i++){
			if( ( i+1)%m != 0  ) ans += a[i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
(n, ), *r = [[*map(int, i.split())] for i in open(0)]
s = sorted([[x + l, x - l] for x, l in r])
c = 1
p = s[0][0]
for i in s[1:]:
    if i[1] >= p:
        c += 1
        p = i[0]
print(c)


Measured memory_bytes: 100668
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		char[] s = sc.next().toCharArray();
		int cnt = 0;
		ArrayList<Integer> aryVal = new ArrayList<Integer>();

		for(int i = 0; i < s.length; i++){
			if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
				cnt++;
			}else{
				if(cnt > 0){
					aryVal.add(cnt);
					cnt = 0;
				}
			}
		}
      
        aryVal.add(cnt);

		Collections.sort(aryVal, Collections.reverseOrder());

		System.out.println(aryVal.get(0));

		sc.close();
	}
}


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

int main(){ 
	int a, b;
	cin >> a >> b;
	for(int i = 1; i <= 1e5; ++i) {
		if((int)(i * 0.08) == a && (int)(i * 0.1) == b)
			return cout << i, 0;
	}
	cout << -1;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
	while(1){
	int ar[99999]={0};
	int n,num=0,res=0;
	cin >> n;
	if(n==0) return 0;
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		ar[a]=b+c;
	}
	for(int i=1;i<=10000;i++){
		if(ar[i]>num){
			res=i;
			num=ar[i];
		}
	}
	cout<<res<<" "<<num<<endl;
	}
	return 0;
}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll n, sum, ans;
    ll a[200005];
    cin >> n;

    sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum = sum ^ a[i];
    }
    for(int i = 0; i < n; i++) {
        ans = 0;
        if(i != 0)
            cout << ' ';
        ans = sum ^ a[i];
        cout << ans;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll N;
    cin >> N;
    char p, q;
    string P, Q;
    for ( int i = 0; i < N; i++ ) {
        cin >> p;
        P.push_back(p);
    }
    for ( int i = 0; i < N; i++ ) {
        cin >> q;
        Q.push_back(q);
    }
    string t;
    for ( int i = 0; i < N; i++ ) {
        t.push_back('1' + i);
    }
    vector<string> s;
    s.push_back(t);
    while( next_permutation(t.begin(), t.end()) ) {
        s.push_back(t);
    }
    sort(s.begin(), s.end());
    ll a = lower_bound(s.begin(), s.end(), P) - s.begin();
    ll b = lower_bound(s.begin(), s.end(), Q) - s.begin();
    ll ans = abs(a-b);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2424
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		long a=in.nextLong();
		long b=in.nextLong();
		long ans=0;
		if((b-a)%2==1)
		{
			ans=Math.min(a-1,n-b)+1+(b-a-1)/2;
		}
		else
		{
			ans=(b-a)/2;
		}
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 23124
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX];

void maxH(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;

	if (l <= H && A[l] > A[i])largest = l;
	else largest = i;
	if (r <= H && A[r] > A[largest])largest = r;

	if (largest != i) {
		swap(A[i], A[largest]);
		maxH(largest);
	}
}

void heapI(int i, int key) {
	if (key < A[i])return;

	A[i] = key;
	while (i > 1 && A[i / 2] < A[i]) {
		swap(A[i], A[i / 2]);
		i = i / 2;
	}
}

void insert(int key) {
	H++;
	A[H] = -INFTY;
	heapI(H, key);
}

int extract() {
	if (H < 1)return 0;

	int max = A[1];
	A[1] = A[H];
	H--;
	maxH(1);

	return max;
}

int main() {
	int key;
	char com[10];

	while (1) {
		scanf(" %s", &com);
		if (com[0] == 'e' && com[1] == 'n')break;
		if (com[0] == 'i') {
			scanf("%d", &key);
			insert(key);
		}
		else {
			printf("%d\n", extract());
		}
	}
	return 0;
}


Measured memory_bytes: 7092
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll s, w;
	cin >> s >> w;
	cout << (s <= w ? "unsafe" : "safe") << endl;
}


Measured memory_bytes: 3636