akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int n; string s;
bool used[1000000];
vector<int>O, I;
bool ok(int t) {
	if (I.size() < t || O.size() < t)return false;
	memset(used, 0, sizeof(used));
	rep(i, t)used[I[i]] = 1, used[O[i]] = 1;
	int p = n - 1;
	rep(i, t) {
		p = min(p - 1, O[i] - 1);
		while (0 <= p && (used[p] || s[p] == 'O'))p--;
		if (p < 0)return false;
	}
	return true;
}
int main() {
	cin >> n >> s;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'I')I.push_back(i);
		if (s[i] == 'O'&&O.size() < I.size())O.push_back(i);
	}
	int l = 0, r = n / 3;
	while (l != r) {
		int t = (l + r) / 2;
		if (r - l == 1)t = r;
		if (ok(t))l = t;
		else r = t - 1;
	}
	printf("%d\n", l);
}

Measured memory_bytes: 10136
N = int(input())
l_h = list(map(int,input().split()))
m = l_h[-1]
for i in reversed(range(N-1)):
    if l_h[i] - l_h[i+1] > 1:
        print("No")
        exit()
    elif l_h[i] - l_h[i+1] == 1:
        l_h[i] -= 1
print("Yes")

Measured memory_bytes: 63984
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

int main(){
	int K, S;
	int m;
	int cnt = 0;
	cin >> K >> S;
	for(int i = 0; i <= K; i++){
		for(int n = 0; n <= K; n++){
			m = S - (i + n);
			if(m >= 0 && m <= K) cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

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

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

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }



int main() {
    int n, w;
    cin >> n >> w;
    auto dp = make_v(n+1, 100001, INF<int>);
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        v[i] = make_pair(a, b);
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
        int a, b;
        tie(a, b) = v[i];
        for (int j = 0; j <= 100000; ++j) {
            if(j >= b) dp[i+1][j] = min(dp[i+1][j], dp[i][j-b] + a);
            dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
        }
    }
    int ans = 0;
    for (int i = 0; i <= 100000; ++i) {
        if(dp[n][i] <= w) ans = max(ans, i);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 40192
#include <iostream>
#include <map>
#include <string>
int main() {
	int n;
	std::cin >> n;
	std::map<std::string, int> map;
	for (auto i = 0; i < n; ++i) {
		int o, x;
		std::string str;
		std::cin >> o >> str;
		switch (o) {
		case 0: std::cin >> x; map[str] = x; break;
		case 1: if (map.find(str) != map.end()) std::cout << map[str] << std::endl; else std::cout << 0 << std::endl; break;
		case 2: map.erase(str); break;
		default:
			std::string r;
			std::cin >> r;
			auto end = map.upper_bound(r);
			for (auto begin = map.lower_bound(str); begin != end; ++begin) {
				std::cout << (*begin).first << ' ' << (*begin).second << std::endl;
			}
		}
	}
}


Measured memory_bytes: 27708
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    ll N,M; cin >> N >> M;
    int a[100010]; fill(a,a+100001,0);
    int sum[100010]; fill(sum,sum+100001,0);
    for (int i = 0; i < M; i++){
        int l,r; cin >> l >> r;
        a[l]++; a[r+1]--;
    }
    for (int i = 1; i < 100001; i++){
        sum[i] = a[i]+sum[i-1];
    }
    int ans = 0;
    for (int i = 1; i < 100001; i++){
        if (sum[i] >= M){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int[] k = new int[w];
        for(int i = 0; i < w; i++){
            k[i] = i+1;
        }
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            String s = sc.next();
            int h = 0;
            for(h = 0; h < s.length(); h++){
                if(s.charAt(h) == ','){
                    break;
                }
            }
            int a = Integer.parseInt(s.substring(0,h));
            int b = Integer.parseInt(s.substring(h+1,s.length()));
            //swap(k[a-1], k[b-1]);
            int c = k[a-1];
            k[a-1] = k[b-1];
            k[b-1] = c;
        }
        for(int i = 0; i < w; i++){
            System.out.println(k[i]);
        }
    }
}


Measured memory_bytes: 25756
#include <iostream>

int main() {
    std::string N;
    std::cin >> N;
    int fx = 0;
    for (int i = 0; i < N.size(); ++i) {
        fx += std::stoi(N.substr(i, 1));
    }
    std::cout << (std::stoi(N) % fx == 0 ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    *t++;
    while(t != V.end()) {
        cout << " " << *t++;
        // if(t != V.end()) cout << " ";
    }
    cout << endl;
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c;
    cin >> n;
    vector<vector<int>> G(n, vector<int>(n, 0));
    rep(i, n) {
        cin >> a >> b;
        rep(j, b) {
            cin >> c;
            G[a - 1][c - 1] = 1;
        }
    }
    rep(i, n) {
        rep(j, n) { cout << G[i][j] << (j + 1 != n ? " " : "\n"); }
    }
}


Measured memory_bytes: 3196
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
k = inp()
cnt = 1
res = 0
if s[0] == s[-1]:
    l = 1
    r = 1
    for i in range(n-1):
        if s[i] == s[i+1]:
            l += 1
        else:
            break
    for i in range(n-1)[::-1]:
        if s[i] == s[i+1]:
            r += 1
        else:
            break
    if l == n and r == n:
        res = (n*k)//2
    else:
        # print(l,r)
        if r > 1:
            res += r//2
        if l > 1:
            res += l//2
        res += ((r+l)//2)*(k-1)
        # print(res)
        for i in range(l,n-r-1):
            if s[i] == s[i+1]:
                cnt += 1
            elif cnt > 1:
                res += (cnt//2)*k
                cnt = 1
        if cnt > 1:
            res += (cnt//2)*k
else:
    for i in range(n-1):
        if s[i] == s[i+1]:
            cnt += 1
        elif cnt > 1:
            res += (cnt//2)*k
            cnt = 1
    if cnt > 1:
        res += cnt//2*k
print(res)


Measured memory_bytes: 39020
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn f(l: usize, x: u64) -> u64 {
    if l == 0 {
        1
    } else if x == 1 {
        0
    } else if 2 <= x && x <= (1 << (l + 1)) - 2 {
        f(l - 1, x - 1)
    } else if x == (1 << (l + 1)) - 1 {
        1 + f(l - 1, (1 << (l + 1)) - 3)
    } else if 1 << (l + 1) <= x && x <= ((1 << (l + 2)) - 4) {
        1 + f(l - 1, (1 << (l + 1)) - 3) + f(l - 1, x - (1 << (l + 1)) + 1)
    } else if x == (1 << (l + 2)) - 3 {
        1 + 2 * f(l - 1, (1 << (l + 1)) - 3)
    } else {
        unreachable!()
    }
}

fn main() {
    input! {
        N: usize,
        X: u64
    };

    let ans = f(N, X);
    println!("{:?}", ans);
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int, input().split()))
#case1
i = 0
su = 0
cost1 = 0
while i < N:
  if i%2==0 and su+A[i]>0:
    su = su+A[i]
  elif i%2==1 and su+A[i]<0:
    su = su+A[i]
  elif i%2==0 and su+A[i]<=0:
    cost1 += 1-(su+A[i])
    su = 1
  elif i%2==1 and su+A[i]>=0:
    cost1 += 1+(su+A[i])
    su = -1  
  i += 1
#case2
i = 0
su = 0
cost2 = 0
while i < N:
  if i%2==0 and su+A[i]<0:
    su = su+A[i]
  elif i%2==1 and su+A[i]>0:
    su = su+A[i]
  elif i%2==0 and su+A[i]>=0:
    cost2 += 1+(su+A[i])
    su = -1
  elif i%2==1 and su+A[i]<=0:
    cost2 += 1-(su+A[i])
    su = 1 
  i += 1

print(min(cost1,cost2))

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    int a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}


Measured memory_bytes: 3592
from sys import stdin
input = stdin.readline

def solve():
    n,m = map(int,input().split())
    p = [tuple(map(int,inp.split())) for inp in stdin.read().splitlines()]
    father = [-1] * n
    count = n
    def getfather(x):
        if father[x] < 0: return x
        father[x] = getfather(father[x])
        return father[x]


    def union(x, y):
        x = getfather(x)
        y = getfather(y)
        nonlocal count
        if x != y:
            count -= 1
            if father[x] > father[y]:
                x,y = y,x
            father[x] += father[y]
            father[y] = x

    for a,b in p:
        union(a-1,b-1)
        
    print(count - 1)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 95568
import sys
if sys.version_info[0]>=3: raw_input=input

n=int(raw_input())
for i in range(0,n):
	y,m,d=[int(e) for e in raw_input().split()]
	y-=1;m-=1
	print(196471-y*195-y//3*5-m*20+(m//2 if y%3!=2 else 0)-d)

Measured memory_bytes: 6720
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		int input1 = int.Parse(Console.ReadLine());
		string[] input2 = Console.ReadLine().Split(' ');
		int[] input2a = Array.ConvertAll(input2, int.Parse);
		int counter = 0;
        for (int i = 0; i < input2a.Length; i += 2)
        {
            if (input2a[i] % 2 != 0)
            {
				counter++;
            }
        }
		
		Console.WriteLine(counter);
	}
}

Measured memory_bytes: 27472
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

bool check(int x){
    int a[5];
    rep(i,5){
        a[i] = x%10;
        x /=10;
    }
    
    if(a[0] == a[4] and a[1] == a[3]) return 1;
    else return 0;
}

int main(){
    string a,b,c; cin >> a >> b >> c;
    
    cout << a[0] << b[1] << c[2] << endl;
    

}







Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    public static void Main()
    {
        int N = IntRead();
        HashSet<int> hash = new HashSet<int>();
        int box;
        for (int i = 0; i < N; i++) {
            box = IntRead();
            if (!hash.Contains(box)) hash.Add(box);
        }
        Console.WriteLine(hash.Count());
    }
}

public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
}


Measured memory_bytes: 13280
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip() # ignore trailing spaces 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

def main():
    s = ns()
    ACGT = "AGCT"
    ans = 0
    tmp = 0
    for i in s:
        if i in ACGT:
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 0
    ans = max(ans, tmp)
    print(ans)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 38484
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    int A, B, C;
    if (scanf("%d%d%d", &A, &B, &C) < 3) return 0;

    if (A == B) printf("%d\n", C);
    else if (A == C) printf("%d\n", B);
    else printf("%d\n", A);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1 << 60);

struct UnionFind
{
	vector<int> par;
	vector<int> sizes;

	UnionFind(int n) : par(n), sizes(n, 1) {
		rep(i, n) par[i] = i;
	}

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

	void unite(int x, int y) {
		x = find(x);
		y = find(y);

		if (x == y) return;

		if (sizes[x] < sizes[y]) swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;
	}

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

	int size(int x) {
		return sizes[find(x)];
	}
};

int N, Q;
UnionFind U(0);

int main() {
	cin >> N;
	U = UnionFind(N);
	cin >> Q;
	rep(i, Q){
		int com, x, y;
		cin >> com >> x >> y;
		if(com == 0){
			U.unite(x, y);
		}
		else{
			cout << U.same(x, y) << endl;
		}
	}
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
 
    vector<int> l;
    int temp;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        l.push_back(temp);
    }
    sort(l.begin(), l.end());

    int a, b;
    int ans = 0;

    for (int i = 0; i < n - 2; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            a = l[i];
            b = l[j];

            auto itr = lower_bound(l.begin(), l.end(), a + b);
            int idx = itr - l.begin();

            if (idx > j) ans += idx - ( j + 1 );
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    N = int(input())
    S = [input() for i in range(N)]

    print("AC x {}".format(S.count('AC')))
    print("WA x {}".format(S.count('WA')))
    print("TLE x {}".format(S.count('TLE')))
    print("RE x {}".format(S.count('RE')))


if __name__ == "__main__":
    main()


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

ll gcd(ll a, ll b)
{
    ll r = a % b;
    if (r == 0)
        return b;
    return gcd(b, r);
}

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;

    rep(i, n)
    {
        int c;
        cin >> c;
        mp[c]++;
    }

    for (auto x : mp)
    {
        if (x.second >= 2)
        {
            OP("NO");
            return 0;
        }
    }

    OP("YES");

    return 0;
}

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

public class Main {
    Stack<String> stack = new Stack<String>();

    String clear(String line){
        String res = "";
        for(int i=0; i<line.length(); i++){
            char c = line.charAt(i);
            if( c == '(' || c == ')' || c == '[' || c == ']' || c == '.'){
                res += String.valueOf(c);
            }
        }
        return res;
    }

    public static void main(String[] args){
        Main m = new Main();
        m.run();
    }


    void run(){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String line = ".";

            try{
                line = br.readLine();
            }catch(IOException e){ }

            // end
            if(line.charAt(0) == '.'){
                break;
            }

            line = clear(line);  // カッコとドットだけにする

            //System.out.println(line);
            if(line.length() == 1){ // >>  .
                System.out.println("yes");
                continue;
            }else if(line.length()%2 == 0){  // .の分+1
                //System.out.println("奇数");
                System.out.println("no");
                continue;
            }

            // 1文字毎のチェック
            boolean f = true;
            int pu = 0;
            int po = 0;
            stack = new Stack<String>();
            for(int i=0; i<line.length(); i++){
                f = true;
                String s = line.substring(i, i+1);
                //System.out.println(i + " " + s);
                if(s.equals(".")){
                    f = stack.empty();
                    //System.out.println(f);
                    break;
                }else if(s.equals("(") || s.equals("[")){  // push
                    stack.push(s);
                    pu++;
                    //System.out.println("push " + s);
                }else{
                    String head = "";
                    try{
                        head = stack.pop();
                        //System.out.println("pop " + head);
                        po++;
                    }catch(EmptyStackException e){  // あまりが出た
                        f = false;
                        //System.out.println("あまり");
                        break;
                    }

                    if(head.equals("(") && s.equals("]") || head.equals("[") && s.equals(")")){  // ちぐはぐ
                        f = false;
                        //System.out.println("ちぐはぐ");
                        break;
                    }
                }
                //System.out.println(stack);
            }

            
            //System.out.printf("pu %d po %d\n", pu, po);
            if(f){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }

        }

    }

}

Measured memory_bytes: 57576
#include<iostream>
using namespace std;
int main(){
  int i,j,H,W;
  while(true){
    cin >> H >> W;
    if(H==0 && W==0)break;
    for(i=1;i<=H;i++){
      int a=i/2;
      if(i==2*a+1){
        for(j=1;j<=W;j++){
          int b=j/2;
          if(j==2*b+1){
            cout << "#";
          }else{
            cout << ".";
          }
        }
        cout << endl;
      }else{
        for(j=1;j<=W;j++){
          int c=j/2;
          if(j==2*c+1){
            cout << ".";
          }else{
            cout << "#";
          }
        }
        cout << endl;
      }
    }
    cout << endl;
  }
}

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


#define INF 1000000001
using namespace std;

int partition(vector<pair<char,int> > &pair_array,const int p,const int r){
    int x = pair_array[r].second;
    vector<pair<char,int> >::iterator itr_i = pair_array.begin() + p;
    int counter = p;
    for(vector<pair<char,int> >::iterator itr_j = pair_array.begin() + p;itr_j != pair_array.begin()+r+1;itr_j++){
        if(itr_j->second <= x){
            swap(*itr_j,*itr_i);
            itr_i++;
            counter++;
        } 
    }
    return counter;
}

void quickSort(vector<pair<char,int> > &pair_array,int p,int r){
    if(p < r){
        int q = partition(pair_array,p,r)-1;
        quickSort(pair_array,p,q-1);
        quickSort(pair_array,q+1,r);
    }
}

void merge(vector<pair<char,int> > &A,const int left,const int mid,const int right){
    int n1 = mid - left;
    int n2 = right - mid;
    vector<pair<char,int> > L(n1+1),R(n2+1);
    for(int i = 0;i < n1;i++) L[i] = A[left + i];
    for(int i = 0;i < n2;i++) R[i] = A[mid  + i];
    L[n1].second = INF;R[n2].second = INF;
    int j = 0,k = 0;
    for(int i = left;i < right;i++){
        if(L[j].second <= R[k].second){
            A[i] = L[j];
            j++; 
        }else if(L[j].second > R[k].second){
            A[i] = R[k];
            k++;
        }
    }
}

void mergeSort(vector<pair<char,int> > &A,int left,int right){
    if(left + 1 < right){
        int mid = (left + right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}


int main(){
    int len_array;
    int  temp_num,max_val = 0;
    char temp_c;
    scanf("%d",&len_array);
    
    vector<pair<char,int> > trump_array1(len_array);
    vector<pair<char,int> > trump_array2(len_array);
    
    for(int i = 0;i < len_array;i++){
        cin >> temp_c >> temp_num;
        trump_array1[i] = make_pair(temp_c,temp_num);
        trump_array2[i] = make_pair(temp_c,temp_num);
    }
    int r = len_array -1;
    mergeSort(trump_array1,0,len_array);
    quickSort(trump_array2,0,r);
    if(trump_array1 == trump_array2) printf("Stable\n");
    else printf("Not stable\n");
    for(auto itr = trump_array2.begin();itr!=trump_array2.end();itr++){
        printf("%c %d\n",itr->first,itr->second);
    }
    return 0;   
}



Measured memory_bytes: 5164
a = int(input())
global s
s = 0

def de(ppp,h):
	re = False
	co  = 0
	global s
	for lo in ppp:
		for j ,cell in enumerate(lo):
			k = j
			p = j
			if k <= 2:
				while cell == lo[k+1] and cell != None:
					co += 1
					if k == 3:
						j = k+1
						break
					k += 1
					j = k
				if co >= 2:
					re = True
					s += (co+1)*cell
					for l in range(5):
						if l >= p and l <= j:
							lo[l] = None
				co = 0

	return re



def mo(ppp,h):
	for i ,roe in enumerate(ppp):
		for j , cell in enumerate(roe):
			kkk = i
			while i != 0 and ppp[kkk-1][j] == None:
				ppp[kkk-1][j] = ppp[kkk][j]
				ppp[kkk][j] = None
				if kkk == 1:
					break
				kkk -= 1


while a != 0:
	ppp = [list(map(int,input().split())) for i in range(a)]
	ppp.reverse()
	while(de(ppp,a) == True):
		mo(ppp,a)
	print(s)

	s = 0

	a = int(input())



Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define Rep(i, N) for(int i = 0; i < N; i++)
#define Reps(i, x, N) for(int i = x; i < N; i++)

signed main()
{
  int M, nmin, nmax;
  int P, save;
  
  while(cin >> M >> nmin >> nmax, M || nmin || nmax) {
    int maxp = -1, maxv = 0;
    
    cin >> save;
    Reps(i, 1, M) {
      cin >> P;
      if(i >= nmin && i <= nmax) {
	if(maxv <= save - P) { 
	  maxp = i, maxv = save - P;
	}
      }
      save = P;
    }
    
    cout << maxp << endl;
    
  }

  return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   int n,k;
   cin>>n>>k;
   
   vector<int>vec(n+1);
   
   for(int i=0;i<k;i++)
   {
       int d;
       cin>>d;
       
       for(int j=1;j<=d;j++)
       {
           int x;
           cin>>x;
           
           vec[x]++;
       }
   }
  
   int cnt=0;
   
   for(int i=1;i<=n;i++)
   {
       if(vec[i]==0)
       cnt++;
   }
   
   cout<<cnt<<endl;
   return 0;
}


Measured memory_bytes: 3652
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 998244353;
//}}}

int main(){
  int a, b;
  cin >> a >> b;
  if (a + b == 15) {
    cout << '+' << endl;
  } else if (a * b == 15) {
    cout << '*' << endl;
  } else {
    cout << 'x' << endl;
  }
  return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_N = 1000000;
int n, q;
int a, v;
int cnt[MAX_N+1];
priority_queue<pii> que;

int main()
{
  cin >> n >> q;
  while(q--){
    cin >> a >> v;
    cnt[a] += v;
    que.push(mp(cnt[a], -a));

    while(!que.empty()){
      pii popop = que.top();
      if(cnt[-popop.second] == popop.first){
        cout << -popop.second << " " << popop.first << endl;
        break;
      }
      que.pop();
    }
  }


  return 0;
}

Measured memory_bytes: 6008
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 998244353;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

lint dp[3001][3001];

int main() {
  
  lint A, B, C, D; cin >> A >> B >> C >> D;
  dp[A][B] = 1;
  for (int i = 0; i <= C; i++) {
    for (int j = 0; j <= D; j++) {
      if (dp[i][j] == 0) continue;
      if (i != C) {
        dp[i + 1][j] += dp[i][j] * j;
        dp[i + 1][j] %= MOD;
      }
      if (j != D) {
        dp[i][j + 1] += dp[i][j] * i;
        dp[i][j + 1] %= MOD;
      }

      if (i != C and j != D) {
        dp[i + 1][j + 1] = dp[i + 1][j + 1] - dp[i][j] * i * j % MOD + MOD;
        dp[i + 1][j + 1] %= MOD;
      }
    }
  }

  /*
  for (int i = 0; i <= C; i++) {
    for (int j = 0; j <= D; j++) {
      cerr << dp[i][j] << " ";
    }
    cerr << endl;
  }
  */

  cout << dp[C][D] << endl;
  return 0;
}


Measured memory_bytes: 73972
def time_to_min(H, M):
  return H * 60 + M


def resolve():
  H1, M1, H2, M2, K= map(int, input().split(" "))
  start = time_to_min(H1, M1)
  end = time_to_min(H2, M2)
  print(end - start - K)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 9116
// 1:45
#include <iostream>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <tuple>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll,ll>;
using tll = tuple<ll,ll,ll>;
#define pb push_back
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll i=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll i=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)
#define DEBUG 0
#if DEBUG
    #define dump(v1) dump_1(#v1, v1)
    #define dump2(v1,v2) dump_2(#v1, v1, #v2, v2)
    #define dump3(v1,v2,v3) dump_3(#v1, v1, #v2, v2, #v3, v3)
#else
    #define dump(v1)
    #define dump2(v1,v2)
    #define dump3(v1,v2,v3)
#endif
#if DEBUG
template <typename T>
void dump_1(const string& n1, const T& v1)
{
    cerr << n1 << ": " << v1 << endl;
}
template <typename T1, typename T2>
void dump_2(const string& n1, const T1& v1, const string& n2, const T2& v2)
{
    cerr << n1 << ": " << v1 << "  " << n2 << ": " << v2 << endl;
}
template <typename T1, typename T2, typename T3>
void dump_3(const string& n1, const T1& v1, const string& n2, const T2& v2, const string& n3, const T3& v3)
{
    cerr << n1 << ": " << v1 << "  " << n2 << ": " << v2 << "  " << n3 << ": " << v3 << endl;
}
template <typename T1,typename T2>
ostream& operator << (ostream& os, const pair<T1,T2>& v)
{
    os << "(" << v.first << ", " << v.second << ")";
    return os;
}
template <typename T1,typename T2, typename T3>
ostream& operator << (ostream& os, const tuple<T1,T2,T3>& v)
{
    os << "(" << get<0>(v) << ", " << get<1>(v) << ", " << get<2>(v) << ")";
    return os;
}
template <typename T>
ostream& operator << (ostream& os, const vector<T>& v)
{
    os << "[";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << *it;
    }
    os << "]";
    return os;
}
template <typename T>
ostream& operator << (ostream& os, const set<T>& v)
{
    os << "{";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << *it;
    }
    os << "}";
    return os;
}
template <typename T1, typename T2>
ostream& operator << (ostream& os, const map<T1,T2>& v)
{
    os << "{";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << it->first << ":" << it->second;
    }
    os << "}";
    return os;
}
#endif // DEBUG
template <typename T>
void print(const T& v)
{
    cout << v << endl;
}
//---------------------------------------------------------

void solve()
{
    ll N,K,X,Y;
    cin >> N >> K >> X >> Y;
    if (N <= K) {
        print(N * X);
    } else {
        print(K * X + (N - K) * Y);
    }
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int n,r=0;cin>>n;
  long int a[n];for(long int i=0;i<n;i++)cin>>a[i];
  for(long int i=0;i<n-1;i++)
  {
    if(a[i]>a[i+1])
    {
      r+=(a[i]-a[i+1]);
      a[i+1]=a[i];
    }
  }
  cout<<r<<endl;
}

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

int main(void) {
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if (a < b && b < c) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int n, s;
int cou;
void dfs(int i, int sum,int num_of_add) {
	if (sum == s&&num_of_add==n) {
		cou++;
		return;
	}
	if (n == num_of_add||i==10)return;
	dfs(i + 1, sum, num_of_add);
	dfs(i + 1, sum + i, num_of_add + 1);
}
int main() {
	while (cin >> n >> s,n != 0 || s != 0) {
		cou = 0;
		dfs(0, 0, 0);
		cout << cou << endl;
	}
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}
const int N = 1e5 + 5;
vector <int> adj[N];
bool vis[N];
int h[N];
int ans;

void dfs(int u)
{
    vis[u] = 1; bool ok=1;
    for(auto it:adj[u])
    {
        if( h[u] <= h[it] )
        {
            ok=0; break;
        }
    }
    if(ok) ans++;
    for(auto it:adj[u])
    {
        if(vis[it]) continue;
        dfs(it);
    }
}


int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll x; cin>>x;
	for(ll i=1;i<10000;i++)
	{
	    for(ll j=-10000;j<=10000;j++)
	    {
	        if( pow(i,5) - pow(j,5) == x )
	        {
	            cout<<i<<' '<<j;
	            return 0;
	        }
	    }
	}
	
	
	return 0;
}


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

int main() {
    int n;
    cin>>n;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
        cout<<"hon"<<endl;
    else if(n%10==0||n%10==1||n%10==6||n%10==8)
        cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;
    return 0;
}


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

namespace lineAralgebra
{
	class Program
	{
		public static void Main(String[] args)
		{
			var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
			var n = input[0];
			var k = input[1];

			var h = Console.ReadLine().Split().Select(long.Parse).ToArray();
			Array.Sort(h);

			long ans = 0;
			for (var i = h.Length - 1; i >= 0; i--)
			{
				if (k > 0)
				{
					k--;
					// ans++;
					continue;
				}

				ans += h[i];
			}

			System.Console.WriteLine(ans);
		}
	}
}



Measured memory_bytes: 39552
#include <iostream>
#define s system("pause")
using namespace std;


int main(){
	
	int n;
	cin>>n;
	if(n % 1000 == 0 ){
		cout<<0<<endl;
	}
	else if (n %  1000 > 0){
	for (int i = 0;i < 100;i++){
		if(i * 1000 > n){
			cout<<(i * 1000) -n<<endl;
			break;
		}			
	}
	}
s;
}

Measured memory_bytes: 3196
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <iomanip>

using namespace std;


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

    int count[10001]={};

    int temp=0;
    for(int x=1;x<101;++x){
        for(int y=1;y<101;++y){
            for(int z=1;z<101;++z){
                temp =x*x + y*y +z*z + x*y + y*z + z*x;
                if(temp > N){
                    break;
                }
                count[temp]+=1;
            }
            if(y*y +2*y+1>N){
                break;
            }
        }
        if(x*x +2*x +1>N){
            break;
        }
    }

    for(int i=1;i<N+1;++i){
        cout<< count[i]<<endl;
    }
}



Measured memory_bytes: 3660
# 問題文誤読して30分経過してた
# ソートしたとき「自分より小さいいずれの値も自分の素因数に含まれない」
# これはなんか実装しにくいので、A<10^6を利用して、調和級数的なノリでやってみる
n = int(input())
a = sorted(list(map(int, input().split())))

t = {}
for av in a:
    if av not in t:
        t[av] = 1
    else:
        t[av] += 1
limit = a[-1]

d = [True] * (limit + 1)
for av in a:
    start = av
    # 複数あった場合は自分自身も粛清の対象になる
    if t[av] == 1:
        start *= 2
    for i in range(start, limit + 1, av):
        d[i] = False

ans = 0
for av in a:
    if d[av]:
        ans += 1

print(ans)

Measured memory_bytes: 38508
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

const lli N = 1e5;

vector<bool> prime_table(lli x){
    vector<bool> p(x, true);
    if(x >= 0) p[0] = false;
    if(x >= 1) p[1] = false;
    for(int i = 2; i*i <= x; i++){
        if(!p[i]) continue;
        for(int j = i+i; j < x; j+=i){
            p[j] = false;
        }
    }
    return p;
}

lli q;

int main(void){
    cin >> q;
    auto pt = prime_table(N+10);
    vector<lli> s(N+5);
    for(int i = 1; i <= N; i++){
        s[i] = s[i-1];
        if(i%2 == 1 && pt[i] && pt[(i+1)/2]) s[i]++;
    }
    rep(i, q){
        lli l, r;
        cin >> l >> r;
        cout << s[r]-s[l-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 4060
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect, bisect_left

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()

A = []
for _ in range(N):
  A.append(read())

if A[0] != 0 or not all(A[i-1] >= A[i] - 1 for i in range(1, N)):
  print(-1)
  exit()

S = sorted(set(i - A[i] for i in range(N)))
print('S:', S, file=stderr)

ans = 0
for i in range(N):
  x = bisect_left(S, i) - bisect_left(S, i - A[i])
  print(i, x, file=stderr)
  ans += x
print(ans)


Measured memory_bytes: 29352
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();
            int Y = in.nextInt();
            int Z = in.nextInt();
            System.out.println((X - Z) / (Y + Z));
        }
    }
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int K,N; 
	int ans=0;
	cin>>N>>K;

	vector<int> v(N);
	for(int i=0;i<N;i++)cin>>v.at(i);
	sort(v.begin(),v.end());
	
	for(int i=0;i<K;i++) ans+=v.at(i);
	cout<<ans<<endl;
}

Measured memory_bytes: 3660
# D - Patisserie ABC

import itertools

N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(N)]

ans = []
for collect in list(itertools.product([1, -1], repeat = 3)):
    gain = []
    for idx in range(N):
        tmp = 0
        for i in range(3):
            tmp += xyz[idx][i] * collect[i]
        gain.append(tmp)
    gain = sorted(gain, reverse = True)
    ans.append(sum(gain[:M]))
    
print(max(ans))

Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X,Y;
  bool S=true;
  cin>>X;
  for(Y=X;;Y++){
    S=true;
    for(long long Z=2;Z<=Y/2;Z++){
      if(Y%Z==0){
        S=false;
      }
    }
    if (S==true){
      break;
    }
  }
  cout<<Y<<endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main()
{
  int h, a, x = 0;

  scanf("%d %d", &h, &a);
  
  h >= a ? x = (h + a) / a : x++;
  if (h % a == 0)
  {
    x--;
  }
  

  printf("%d\n", x);
  
return 0;
}


Measured memory_bytes: 1724
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author otsuhata
 */
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        //System.out.println("???H * ?¨?W ?????§???????????????????????????????????°????????§??????");
        //System.out.println("H??¨W?????????3??????300?????????????????\????????????????????????");
        
        for(int i = 0; i < 3000; i ++) {
            //System.out.print("??????????§????????????????????????§??\?????????????????????(0 0??§???????????????):");
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                printUpBtm(W);
                
                for(int height = 0; height < (H - 2) ; height++) {
                    printFrame(W);
                }
                
                printUpBtm(W);
            }else {
                //System.out.println("##### GAME OVER #####");
                break;
            }
            
            //printUpBtm(W);
            
            System.out.print("\n");
        }
    }    

    public static void printFrame(int W) { 
        System.out.print("#"); 
	for(int i = 0; i < (W - 2); i++) {
		System.out.print(".");                
	}
        System.out.print("#"); 
        System.out.print("\n");    
    }
    
     public static void printUpBtm(int W) {  
	for(int i = 0; i < W; i++) {
		System.out.print("#");                
	}
        System.out.print("\n");    
    }
    
    
    public static boolean printJudge(int H, int W) {
        if((H == 0 && W == 0)) {
            return false;
        }else return !(H < 3 || H > 300 || W < 3 || W > 300);
    }
    
}

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

int main(int args, char *argv[])
{
  long N, M;
  cin >> N;
  cin >> M;
  if (N == 1 && M == 1)
  {
    cout << 1 << endl;
  }
  else if (N == 1)
  {
    cout << M - 2 << endl;
  }
  else if (M == 1)
  {
    cout << N - 2 << endl;
  }
  else
  {
    cout << (N - 2) * (M - 2) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;  //英小文字
  cin >> c;  //入力
  
  bool isVowel = false;  //Cが母音であるかどうか（true : 母音である false : 子音である）

 //母音かどうかの判定
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    isVowel = true;
  }

//出力
  if (isVowel) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl; 
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  ll ans = 0;
  REP(i,n){
    int l, r;
    cin >> l >> r;
    --l;
    ans += (ll) r - l;
  }
  cout << ans << endl;
  
  return 0;
}

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

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

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

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int n;
int l[10],x[10],y[10];

double H(double Y,double X){
    double m=500000;
    for(int i=0;i<n;i++)
        m=min(m,l[i]*l[i]-(Y-y[i])*(Y-y[i])-(X-x[i])*(X-x[i]));
    return m;
}

double Y(double X){
    double l=-100,r=100;
    for(int i=0;i<100;i++){
        double m1=(l*2+r)/3,m2=(l+r*2)/3;
        if(H(m1,X)<H(m2,X))
            l=m1;
        else
            r=m2;
    }
    return H(l,X);
}

double X(){
    double l=-100,r=100;
    for(int i=0;i<100;i++){
        double m1=(l*2+r)/3,m2=(l+r*2)/3;
        if(Y(m1)<Y(m2))
            l=m1;
        else
            r=m2;
    }
    return Y(l);
}
int main(){
    while(cin>>n,n){
        for(int i=0;i<n;i++)
            cin>>x[i]>>y[i]>>l[i];
        double ans=sqrt(X());
        printf("%.7f\n",ans);
    }
}

Measured memory_bytes: 1196