akhauriyash/Code-Regression huggingface dataset:
blue = []
red = []
score = 0
n = gets.to_i
n.times do
  blue << gets.to_s
end
m = gets.to_i
m.times do
  red << gets.to_s
end

b_uniq = blue.uniq
counter = 0

b_uniq.each do |b|
  b_count = blue.count(b)
  r_count = red.count(b)
  sum = b_count - r_count
  counter = sum if counter < sum
end

p counter

Measured memory_bytes: 1788
import sys
import numpy as np

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

nums = np.array(read().split(), np.int32)[2:]

cond = np.all(np.bincount(nums) % 2 == 0)
print('YES' if cond else 'NO')

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define PB push_back
#define MP make_pair
#define IN insert
#define F first
#define S second

#define repa(i,fr,to,inc) for(int i = fr ; i <= to ; i += inc)
#define repb(i,fr,to,dec) for(int i = fr ; i >= to ; i -= dec)

clock_t present = clock();
void complexiti(){present = clock() - present;cerr << "TIME : " << float(present)/CLOCKS_PER_SEC << '\n';}
ll nax = 1000000LL * 1000000LL * 1000000LL;


void solver(){
	//~ type your code here
	int a , b;
	cin >> a >> b;
	int ans = 0;
	int make = 1;
	while(make < b){
		make += a-1;
		ans++;
	}
	cout << ans << endl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int queries = 1;
	//~ cin >> queries;
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	complexiti();
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  while(true){
    int d,w;
    cin>>d>>w;
    if(d==0&&w==0)return 0;
    vector<vector<int>>e(d,vector<int>(w));
    for(int i=0;i<d;i++){
      for(int j=0;j<w;j++){
        cin>>e[i][j];
      }
    }

    int ans=0;

    for(int x1=0;x1<w;x1++){
      for(int x2=x1+2;x2<w;x2++){
        for(int y1=0;y1<d;y1++){
          for(int y2=y1+2;y2<d;y2++){

            int exMin=INF;
            for(int x=x1;x<=x2;x++){
              exMin=min(exMin,e[y1][x]);
              exMin=min(exMin,e[y2][x]);
            }
            for(int y=y1;y<=y2;y++){
              exMin=min(exMin,e[y][x1]);
              exMin=min(exMin,e[y][x2]);
            }

            int inMax=0;
            for(int x=x1+1;x<x2;x++){
              for(int y=y1+1;y<y2;y++){
                inMax=max(inMax,e[y][x]);
              }
            }

            int sum=0;
            if(exMin>inMax){
              for(int x=x1+1;x<x2;x++){
                for(int y=y1+1;y<y2;y++){
                  sum+=(exMin-e[y][x]);
                }
              }
            }

            ans=max(ans,sum);
          }
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MAX(a,b) ((a >= b) ? (a) : (b))
#define MIN(a,b) ((a >= b) ? (b) : (a))
#define ABS(a) (((a) > 0) ? (a) : (-a))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))

LL rt[4010][3];

int main() {

	char s[4010];
	LL n,i, ans = 0, j;

	cin>>n;
	scanf("%s", s);

	for(i = n-2; i>=0; i--) {

		if(s[i+1] == 'R') {
			rt[i][0] = rt[i+1][0] + 1;
			rt[i][1] = rt[i+1][1];
			rt[i][2] = rt[i+1][2];

		} else if(s[i+1] == 'G') { 
			rt[i][1] = rt[i+1][1] + 1;
			rt[i][0] = rt[i+1][0];
			rt[i][2] = rt[i+1][2];
		} else {
			rt[i][2] = rt[i+1][2] + 1;
			rt[i][0] = rt[i+1][0];
			rt[i][1] = rt[i+1][1];
		}
	}

	for(i = 0 ; i <= n-3; i++) {
		for(j = i+1; j <=n-2 ; j++) {

			if(s[i] == s[j]) {
				continue;
			}

			if((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')) {
				ans += rt[j][2] - (j+j-i >=n ? 0 : s[j+j-i] == 'B' ? 1 : 0) ;
			} else if ((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')) {
				ans += rt[j][1] - (j+j-i >=n ? 0 : s[j + j - i] == 'G' ? 1 : 0);
			} else if ((s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G')) {
				ans += rt[j][0] - (j+j-i >=n ? 0 : s[j + j -i] == 'R' ? 1 :0);
			}
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int f[N], a[N];

int find(int k) {
  return f[k] == k ? f[k] : f[k] = find(f[k]);
}

void merge(int x, int y) {
  int fx = find(x), fy = find(y);
  f[fx] = fy;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for(int i = 1; i <= n; ++i) {
    f[i] = i;
    scanf("%d", &a[i]);
  }
  for(int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d",  &x, &y);
    merge(x, y);
  }
  int ans = 0;
  for(int i = 1; i <= n; ++i) {
    if(find(i) == find(a[i])) ans++;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	i, err := strconv.Atoi(readString())
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

func main() {
	defer stdout.Flush()

	// readString() string
	// readInt() int
	// readIntSlice(n int) []int
	// readLengthAndSlice() []int

	a := readIntSlice(3)
	sort.Ints(a)
	d := a[2] - a[1] + a[2] - a[0]

	ans := d / 2
	if d%2 != 0 {
		ans += 2
	}
	println(ans)

}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

bool compare_by_a(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<1>(a) != get<1>(b)){
        return get<1>(a) < get<1>(b);
    }else{
        return get<2>(a) > get<2>(b);
    }
}

int main()
{
    cout << fixed << setprecision(15);

    int N;
    cin >> N;

    vector<tuple<int, string, int> > t(N);

    REP(i ,N){
        string s;
        int p;
        cin >> s;
        cin >> p;
        get<0>(t[i]) = i+1;
        get<1>(t[i]) = s;
        get<2>(t[i]) = p;
    }

    // 1つ目のキーで昇順ソート
    sort(t.begin(), t.end(), compare_by_a);
    // cout << "1つ目の値でソート後" << endl;
    for(ll i=0; i<N; i++){
        cout << get<0>(t[i]) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  int N;
  while (cin >> N) {
    vector<int> v(N);
    for (int i : range(N)) cin >> v[i];
    int res = 1 << 29, res2 = -1111;
    for (int x : range(-200, 200)) {
      int temp = 0;
      for (int i : range(N)) temp += (x - v[i]) * (x - v[i]);
      if (temp < res) {
        res = temp;
        res2 = x;
      }
    }

    cout << res << endl;
  }
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x,y;

	scanf("%d", &x);//body
	scanf("%d", &y);//leg

	for (int i = 0; i <= x; i++) {
		int tmp = 4 * (x - i) + 2 * i;
		if (tmp == y) {
			puts("Yes");
			return 0;
		}
	}

	puts("No");

	return 0;
}

Measured memory_bytes: 2092
# 桁DP
MOD = 10 ** 9 + 7
length = gets.to_i
# dp[上から i 桁まで][0 を使ったかどうか][9 を使ったかどうか]の出現回数
dp = (length + 1).times.map { 2.times.map { Array.new(2, 0) } }
# 初期化
# dp[0 桁目まで][0 は使っていない][9 は使っていない]の出現回数は 1
dp[0][0][0] = 1

# 桁数分ループする（i は遷移元の桁）
length.times do |i|
  dp_current = dp[i]
  # 最適化のため、事前に 1 行分だけ参照渡しをする
  # dp_next と dp[i + 1] の object_id は同じ
  dp_next = dp[i + 1]
  nonzero_nonnine = dp_current[0][0]
  nonzero_nine = dp_current[0][1]
  zero_nonnine = dp_current[1][0]
  zero_nine = dp_current[1][1]
  dp_next_0 = dp_next[0]
  dp_next_1 = dp_next[1]
  dp_next_0[0] += nonzero_nonnine * 8
  dp_next_0[1] += nonzero_nonnine + nonzero_nine * 9
  dp_next_1[0] += nonzero_nonnine + zero_nonnine * 9
  dp_next_1[1] += nonzero_nine + zero_nonnine + zero_nine * 10
  dp_next_0[0] %= MOD
  dp_next_0[1] %= MOD
  dp_next_1[0] %= MOD
  dp_next_1[1] %= MOD
end

puts dp.last.last.last % MOD


Measured memory_bytes: 192116
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;

int main(void){
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int ax,ay,bx,by;
	cin>>ax>>ay>>bx>>by;
	string sol="";
	REP(i,1,by-ay) {
		sol+="U";
	}
	REP(i,1,bx-ax) {
		sol+="R";
	}
	REP(i,1,by-ay)sol+="D";
	REP(i,1,bx-ax+1)sol+="L";
	REP(i,1,by-ay+1) {
		sol+="U";
	}
	REP(i,1,bx-ax+1) {
		sol+="R";
	}
	sol+="DR";
	REP(i,1,by-ay+1)sol+="D";
	REP(i,1,bx-ax+1)sol+="L";
	sol+="U";
	cerr<<sol.length();
	cout<<sol;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3596
import java.io.PrintWriter;
import java.util.*;

public class Main {
    class Pair {
        int b, h;

        public Pair(int b, int h) {
            this.b = b;
            this.h = h;
        }

        @Override
        public String toString() {
            return this.b + ", " + this.h;
        }
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        PriorityQueue<Pair> incPq = new PriorityQueue<>((p1, p2) -> p2.b - p1.b);
        PriorityQueue<Pair> decPq = new PriorityQueue<>((p1, p2) -> p2.b - p1.b);

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            int b = 0;
            int h = 0;
            for (char c : s.toCharArray()) {
                if (c == '(') {
                    h++;
                } else {
                    h--;
                }
                b = Math.min(b, h);
            }

            if (h < 0) {
                Pair p = new Pair(b - h, -h);
                decPq.add(p);
            } else {
                Pair p = new Pair(b, h);
                incPq.add(p);
            }
        }

        int current = 0;
        while (!incPq.isEmpty()) {
            Pair p = incPq.remove();
//            debug("inc", p);
            if (current + p.b < 0) {
                System.out.println("No");
                return;
            }
            current += p.h;
        }

        int current2 = 0;
        while (!decPq.isEmpty()) {
            Pair p = decPq.remove();
//            debug("dec", p);
            if (current2 + p.b < 0) {
                System.out.println("No");
                return;
            }
            current2 += p.h;
        }

        if (current == current2) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }


        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

using namespace std;
using ll = long long;

const int mx = 2e5 + 9;

int on[25];
int a[mx];

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

    a[n + 1] = (1 << 30) - 1;
    ll ans = 0;

    int l = 1, r = 1;
    while (l <= n) {
        r = max(r, l);
        while (r <= n) {
            bool ok = true;
            for (int j = 0; j < 25; j++) {
                if (a[r] & (1 << j)) {
                    on[j]++;
                    if (on[j] > 1) ok = false;
                }
            }

            if (ok) {
                // printf("%d %d\n", l, r);
                r++; continue;
            }

            ans += (r - l);
            for (int j = 0; j < 25; j++) {
                if (a[r] & (1 << j)) {
                    on[j]--;
                }
            }

            break;
        }

        if (r > n) ans += (r - l);
        for (int j = 0; j < 25; j++) {
            if (a[l] & (1 << j)) {
                on[j]--;
            }
        }

        l++;
    }

    printf("%lld\n", ans);
}

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

public class hello
{
	public static void Main()
	{
		var c = new string[] { "R", "G", "B" };
		var n = int.Parse(Console.ReadLine().Trim());
		var p = 0;
		while (p++ < n)
		{
			string[] line = Console.ReadLine().Trim().Split(' ');
			var a = Array.ConvertAll(line, int.Parse);
			string[] s = Console.ReadLine().Trim().Split(' ');
			var ans = 1;
			for (int i = 0; i < 3; i++)
			{
				var w2 = new List<int>();
				for (int j = 0; j < 9; j++)
					if (s[j] == c[i]) w2.Add(a[j]);
				var w = w2.OrderBy(x => x).ToList();
				var wc = w.Count();
				if (wc > 0 && wc % 3 != 0) { ans = 0; goto end; }
				else if (wc == 3 && !check3(w)) { ans = 0; goto end; }
				else if (wc == 6 && !check6(w)) { ans = 0; goto end; }
				else if (wc == 9 && !check9(w)) { ans = 0; goto end; }
			}
		end:;
			Console.WriteLine(ans);
		}
	}
	static bool check9(List<int> a)
	{
		var d = getDic(a);
		foreach (var x in d)
		{
			if (x.Value == 3 | x.Value == 4)
			{
				var t = x.Key;
				for (int i = 0; i < 3; i++) a.Remove(t);
				if (check6(a)) return true;
				for (int i = 0; i < 3; i++) a.Add(t);
				a.Sort();
			}
		}
		var dist = a.Distinct().ToList();
		for (int i = 0; i <= dist.Count() - 3; i++)
			if ((dist[i] + 1 == dist[i + 1]) && (dist[i + 1] + 1 == dist[i + 2]))
			{
				var t = dist[i];
				for (int j = 0; j < 3; j++) a.Remove(t + j);
				if (check6(a)) return true;
				for (int j = 0; j < 3; j++) a.Add(t + j);
				a.Sort();
			}
		return false;
	}
	static bool check3(List<int> a) =>
		(a[0] == a[1] && a[1] == a[2]) | (a[0] + 1 == a[1] && a[1] + 1 == a[2]);
	static bool check6(List<int> a)
	{
		var d = getDic(a);
		foreach (var x in d)
			if (x.Value == 3 | x.Value == 4)
			{
				for (int i = 0; i < 3; i++) a.Remove(x.Key);
				return check3(a);
			}
		var dist = a.Distinct().ToList();
		for (int i = 0; i <= dist.Count() - 3; i++)
			if ((dist[i] + 1 == dist[i + 1]) && (dist[i + 1] + 1 == dist[i + 2]))
			{
				var t = dist[i];
				for (int j = 0; j < 3; j++) a.Remove(t + j);
				if (check3(a)) return true;
				for (int j = 0; j < 3; j++) a.Add(t + j);
				a.Sort();
			}
		return false;
	}
	static Dictionary<int, int> getDic(List<int> a)
	{
		var d = new Dictionary<int, int>();
		for (int i = 0; i < a.Count(); i++)
			if (d.ContainsKey(a[i])) d[a[i]]++;
			else d[a[i]] = 1;
		return d;
	}
}



Measured memory_bytes: 18512
from collections import deque
n = int(input())
to = [[] for _ in range(n)]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u , v = u-1, v-1
    to[u].append([v, w])
    to[v].append([u, w])
color = [-1] * n
color[0] = False
q = deque([0])
while q:
    v = q.popleft()
    for u, w in to[v]:
        if color[u] != -1:
            continue
        if w % 2 != 0:
            color[u] = color[v] ^ 1
        else:
            color[u] = color[v]
        q.append(u)
for c in color:
    print(int(c))

Measured memory_bytes: 45368
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint D;
llint c[30];
llint s[400][30];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> D;
	for(int i = 0; i < 26; i++) cin >> c[i];
	for(int i = 1; i <= D; i++){
		for(int j = 0; j < 26; j++){
			cin >> s[i][j];
		}
	}
	
	for(int i = 0; i < D; i++) cout << i % 26 + 1 << endl;
	
	return 0;
}

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

int main(){
	int dx[]={-1,0,1,0};
	int dy[]={0,-1,0,1};
	int n;
	while(cin>>n and n>0){
		int a[450][450]={};
		pair<int,int> num[n+1];
		a[200][200]=1;
		num[1].first=200;
		num[1].second=200;
		rep(i,n-1){
			int nu,d; cin>>nu>>d;
			//cout<<nu<<" "<<d<<endl;
			num[i+2].first=num[nu+1].first+dx[d];
			num[i+2].second=num[nu+1].second+dy[d];
			a[num[i+2].first][num[i+2].second]=i+2;
		}
		int xmin=200,xmax=200,ymin=200,ymax=200;
		rep(i,450){
			rep(j,450){
				if(a[i][j]>0){
					if(xmin>i) xmin=i;
					if(xmax<i) xmax=i;
					if(ymin>j) ymin=j;
					if(ymax<j) ymax=j;
				}
			}
		}
		cout<<xmax-xmin+1<<" "<<ymax-ymin+1<<endl;
	}
    return 0;
}



Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <thread>
#include <chrono>

using namespace std;

int main(void){
	vector<int> v(3);
	for(int i=0;i<3;i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	cout << v[2]*10 + v[1] + v[0] << endl;
	return 0;
}

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

int N, M, L, a, b, d, e;
int cnt;
int hyou[110][110];

int main() {
	while(cin >> N >> M >> L, N) {
		vector<tuple<int, int, int>> road[110];
		rep(n, N) rep(i, L + 1) hyou[n][i] = 100000000;
		hyou[0][0] = 0;
		rep(m, M) {
			cin >> a >> b >> d >> e;
			a --;
			b --;
			road[a].push_back(make_tuple(b, d, e));
			road[b].push_back(make_tuple(a, d, e));
		}
		deque<int> dq;
		dq.push_back(0);
		while(!dq.empty()) {
			int p = dq.front() / 1000;
			int c = dq.front() % 1000;
			int t = hyou[p][c];
			dq.pop_front();
			for(auto r : road[p]) {
				int to = get<0>(r);
				int nt = get<2>(r) + t;
				int nc = get<1>(r) + c;
				if(hyou[to][c] > nt) {
					hyou[to][c] = nt;
					dq.push_back(to * 1000 + c);
				}
				if (nc <= L and hyou[to][nc] > t) {
					hyou[to][nc] = t;
					dq.push_back(to * 1000 + nc);
				}
			}
		}
		int ans = 100000000;
		rep(i, L + 1) {
			ans = min(hyou[N - 1][i], ans);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3188
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int array[3];
	for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
	for(int i = 2; i > 0; i--){
		for(int j = 0; j < i; j++){
			if(array[j] > array[j+1])swap(array[j],array[j+1]);
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
}



Measured memory_bytes: 2688
#include<iostream>
using namespace std;
int main(){
	int a, b;
	do{
		cin >> a >> b;
		if (a == 0 || b == 0)
			break;
		for (int j = 0; j < a; j++){
			for (int i = 0; i < b; i++){
				if ((i+j)%2==0)
					cout <<"#";
				else
					cout <<".";
			}
			cout << endl;
		}
		cout << endl;
	} while (true);
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
bool solve(ll t){
	ll x,y;
	cin>>x>>y;
	x=(x>0)?x:-x;
	y=(y>0)?y:-y;
	if(ceil(sqrt((x*x)+(y*y)))<=t)return 1;
	else return 0;
}
int main(){
	FASTIO
	ll t,target,count=0;
	cin>>t>>target;
	while(t--){
		if(solve(target))count++;
	}
	cout<<count<<"\n";
	return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
using namespace std;
static const LL INF = 1LL<<61LL;
typedef pair<int,int> PII;

string a,b;
string ans;
int M;
char t[]={'0','1','2','3','4','5','6','7','8','9'};

void add(int n,int m,int c,string s){
    int k;
    //cout<<s<<" "<<a[n-1]<<" "<<b[m-1]<<" "<<c<<endl;
    if(n-1<0&&m-1<0){
        if(c!=0)s+=t[c];
        for(int i=s.size()-1;i>=0;--i){
            ans+=s[i];
        }
        return ;
    }
    if(n-1>=0&&m-1>=0)k=a[n-1]-'0'+b[m-1]-'0'+c;
    else if(n-1>=0)k=a[n-1]-'0'+c;
    else if(m-1>=0)k=b[m-1]-'0'+c;
    if(k>=10){
        k-=10;
        c=1;
    }
    else c=0;
    add(n-1,m-1,c,s+t[k]);
}

/*bool MOD1(string num){
    bool res=false;
    LL k=num.size();
    LL mod;
    int i=-1;
    LL n=0;
    while(k){
        n=(n*10)+num[i+1]-'0';
        mod=n%M;
        n=mod;
        k--;
        i++;
    }
    if(mod==0)return true;
    return false;
}
bool MOD2(string num){
    bool res=false;
    LL k=num.size();
    LL mod;
    int i=-1;
    LL n=0;
    while(k){
        n=(n*10)+num[i+1]-'0';
        mod=n%5;
        n=mod;
        k--;
        i++;
    }
    if(mod==0)return true;
    return false;
}
bool MOD3(string num){
    bool res=false;
    LL k=num.size();
    LL mod;
    int i=-1;
    LL n=0;
    while(k){
        n=(n*10)+num[i+1]-'0';
        mod=n%7;
        n=mod;
        k--;
        i++;
    }
    if(mod==0)return true;
    return false;
}
bool MOD4(string num){
    bool res=false;
    LL k=num.size();
    LL mod;
    int i=-1;
    LL n=0;
    while(k){
        n=(n*10)+num[i+1]-'0';
        mod=n%11;
        n=mod;
        k--;
        i++;
    }
    if(mod==0)return true;
    return false;
}*/
int main(){
    int n;
    cin>>n;
    rep(i,n){
    cin>>a>>b;
    //cin>>M;
        add(a.size(),b.size(),0,"");
        //if(!MOD1(ans)&&!MOD2(ans)&&!MOD3(ans)&&!MOD4(ans))cout<<ans<<endl;
        //else cout<<"king is angry"<<endl;
        if(ans.size()<=80&&a.size()<=80&&b.size()<=80)cout<<ans<<endl;
        else cout<<"overflow"<<endl;
        ans.clear();
    }
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#define INF 1.0e9
using namespace std;
typedef long long ll;

int N, T, A;
const int MAX_N = 1000;
int H[MAX_N];

int main() {
    cin >> N >> T >> A;
    for (int i = 0; i < N; i++) cin >> H[i];
    double min_tmp = INF;
    int ans = 0;
    for (int i = 0; i < N; i++){
        double tmp = T - H[i] * 0.006;
        if (min_tmp > abs(tmp - A)) {
            min_tmp = abs(tmp - A);
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

// graph template
template<typename T>
class edge{
    public:
        int src, to; T cost;

        edge(int to, T cost): src(-1), to(to), cost(cost){}
        edge(int src, int to, T cost): src(src), to(to), cost(cost){}
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using AdjacencyList = vector<Edges<T>>;
template<typename T>
using Matrix = vector<vector<T>>;

template<typename T>
void warshall_floyd(Matrix<T> &g, T INF){
    for(int k = 0; k < (int)g.size(); k++){
        for(int i = 0; i < (int)g.size(); i++){
            for(int j = 0; j < (int)g.size(); j++){
                if(g[i][k] == INF or g[k][j] == INF) continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

int main(void){
  int V, E;
  scanf("%d %d", &V, &E);
  Matrix< int > mat(V, vector< int >(V, INT_MAX));
  for(int i = 0; i < V; i++) mat[i][i] = 0;
  for(int i = 0; i < E; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    mat[x][y] = z;
  }
  warshall_floyd(mat, INT_MAX);
  for(int i = 0; i < V; i++) {
    if(mat[i][i] < 0) {
      puts("NEGATIVE CYCLE");
      return 0;
    }
  }
  for(int i = 0; i < V; i++) {
    for(int j = 0; j < V; j++) {
      if(j > 0) putchar(' ');
      if(mat[i][j] == INT_MAX) printf("INF");
      else printf("%d", mat[i][j]);
    }
    putchar('\n');
  }

  return 0;
}


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

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
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;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;

  int A[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout << A[n - 1] << endl;

  // cout << pow(n, 2) << endl;

  return 0;
};


Measured memory_bytes: 256
#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>;

int main() {
  ios::sync_with_stdio(false);
	cin.tie(0);
  ll n,k;
  cin >> n>>k;
  vector<double> p(n);
  rep(i,n){
    cin>>p[i];
    p[i]+=1;
    p[i]/=2;
  //  cout<<p[i]<<endl;
  }
  double cnt=0;
  rep(i,k)cnt+=p[i];
ll now=0;
double ans=0;
ans=max(ans,cnt);
while(now+k<n){

  cnt-=p[now];
  cnt+=p[now+k];
  ans=max(ans,cnt);
//  cout<<ans<<endl;
  now++;
}
cout<<setprecision(8)<<ans;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a == b && b == c) cout << "1" << endl;
  else if(a == b || b == c || c == a) cout << "2" << endl;
  else cout << "3" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T>
T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T>
T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main()
{
    cin >> n >> k;
    FOR(i, k + 1, n + 1)
    {
        ans += (n / i) * (i - k);
        if(n%i>=k){
            ans += n % i;
            if(k!=0){
                ans += 1 - k;
            }
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    int k=a;
    if(a>b)
    k=b;
    if(k==a){
        while(b--)
        cout<<k;
    }
    else
    {
        while(a--)
        cout<<k;
    }

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	int bin[20] = {};
	bin[0] = 1;
	for (int i = 1; i < 20; i++) {
		bin[i] = bin[i - 1] * 2;
	}
	while (N) {
		int num[17][17] = {};
		int dp[65536] = {};
		bool ed[65536] = {};
		for (int i = 1; i <= N; i++) {
			for (int j = 0; j <= N; j++)cin >> num[i][j];
		}
		for (int i = 1; i < bin[N]; i++)dp[i] = 10000000;
		set<pair<int, int>>s;
		for (int i = 0; i < bin[N]; i++) {
			int c = i;
			int box = 0;
			while (c) {
				if (c % 2)box++;
				c /= 2;
			}
			if (box != N)s.insert({ box,i });
		}
		vector<pair<int, int>>v(s.begin(), s.end());
		for (auto k : v) {
			int c = k.second;
			bool flag[17] = {};
			flag[0] = true;
			for (int i = 1; i <= N; i++) {
				if (c % 2)flag[i] = true;
				c /= 2;
			}
			c = k.second;
			for (int i = 1; i <= N; i++) {
				if (!flag[i]) {
					int box = 10000000;
					for (int j = 0; j <= N; j++) {
						if (flag[j]) {
							box = min(box, num[i][j]);
						}
					}
					dp[c + bin[i-1]] = min(dp[c + bin[i-1]], dp[c] + box);
				}
			}
		}
		cout << dp[bin[N]-1] << endl;

		cin >> N;
	}
	return 0;
}

Measured memory_bytes: 6920
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 3; ++i)
    {
        int f = 1;
        for (int j = i; j < 3; ++j)
        {
            f = f && (s[j] == 'R');
            if (f)
                ans = max(ans, j - i + 1);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>

using namespace std;

int main(){
  long long A, B, K;
  cin >> A >> B >> K;
  if(A>=K) cout << A-K << " " << B << endl;
  else if (A+B>=K) cout << 0 << " " << A+B-K << endl;
  else cout << 0 << " " << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = list(map(int, list(input())))
k = int(input())

dp0 = [[0]*3]*len(n)
dp1 = [[0]*3]*len(n)
dp0[0][0] = 1
dp1[0][0] = max(0, n[0]-1)
for i in range(1, len(n)):
    if n[i]==0:
        dp0[i] = dp0[i-1]
    else:
        dp0[i] = [0]+dp0[i-1][:2]

    dp1[i] = [
        dp1[i-1][0]+dp0[i-1][0]*(n[i]!=0)+9,
        dp1[i-1][1]+dp0[i-1][1]*(n[i]!=0)+dp0[i-1][0]*max(0, n[i]-1)+dp1[i-1][0]*9,
        dp1[i-1][2]+dp0[i-1][2]*(n[i]!=0)+dp0[i-1][1]*max(0, n[i]-1)+dp1[i-1][1]*9,
    ]

print(dp0[-1][k-1]+dp1[-1][k-1])

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

typedef long long ll;
typedef pair<ll, ll> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int n, h[111];
int mx = -1, cnt = 0;
int main() {
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> h[i];
        if (mx<=h[i]) {
            cnt++;
            mx = h[i];
        }
    }

    cout << cnt << endl;
}

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

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
vector<int>v;
bool isPresent(int n){
    for(int i=0;i<v.size();i++){
        if(v[i]==n) return true;
    }
    return false;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    int sum=0;
    while(t--){
    
       int i;
       cin>>i;
       if(i<=((i/100))*111) cout<<((i/100))*111;
       else cout<<(((i/100))+1)*111;
    }
}
    

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	
	static long res, MOD = (int) 1e9 + 7;
	static ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader();
		int n = in.nextInt();
		int k = in.nextInt();
		
		for (int i=0; i<n; i++)
			adj.add(new ArrayList<>());
		
		for (int i=0; i<n-1; i++) {
			int u = in.nextInt() - 1;
			int v = in.nextInt() - 1;
			adj.get(u).add(v);
			adj.get(v).add(u);
		}
		
		res = k;
		dfs(0, -1, k);
		System.out.println(res);
	}
	
	public static void dfs(int cur, int parent, int k) {
		if (adj.get(cur).size() + 1 > k)
			endProgram();
		int sub = parent == -1 ? 1 : 2;
		for (int index: adj.get(cur)) if (index != parent) {
			res *= (k - sub++);
			res %= MOD;
			dfs(index, cur, k);
		}
	}
	
	public static void endProgram() {
		System.out.println(0);
		System.exit(0);
	}
	
	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 74380
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <vector>
#include <functional>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <deque>
#include <random>
#include <chrono>
#include <ctime>
#include <climits>
#include <stack>
#include <array>
#include <iomanip>
#include <complex>
#include <bitset>
#include <iostream>
#include <cstring>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace
#define y0 withindarkness
#define y1 apinklotusbloomed
#define yn carryingapurplesoul
#define j1 togetherformingtheTeam

void useiostream() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(8);
}

void drop(char const* bu) {
	printf("%s", bu);
	exit(0);
}

ull gcd(ull a, ull b) {
	return b == 0 ? a : gcd(b, a % b);
}

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

ld const pi = acos(-1.0L);
ld const eps = 0.0001L;

template<typename T, typename TT> bool mi(T& a, TT b) { return a > b ? (a = b, true) : false; }
template<typename T, typename TT> bool ma(T& a, TT b) { return a < b ? (a = b, true) : false; }

mt19937 ran(996);

int const mod = 1000000007;

ull bm(ull a, ull p, ull mod) {
	return (a * p - (ll)((ld)a * p / mod) * mod + mod) % mod;
}

ull bp(ull a, ull p, ull mod) {
	ull re = 1;
	while (p) {
		if (p & 1)re = bm(re, a, mod);
		p >>= 1;
		a = bm(a, a, mod);
	}
	return re;
}

int n;
int a[200005];

int main() {
	useiostream();
#ifdef _DEBUG
	(void)freopen("input.txt", "r", stdin);
	(void)freopen("output.txt", "w", stdout);
#else
	//(void)freopen("bisector.in", "r", stdin);
	//(void)freopen("bisector.out", "w", stdout);
#endif

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int need = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] == need) {
			need++;
		}
	}

	if (need == 1) {
		need = n + 2;
	}
	cout << n - need + 1;

	return 0;
}

Measured memory_bytes: 1024
/*
    Author: Aryan Yadav
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define fm(i, a, b) for (long long i = a; i > b; i--)
#define repm(i, a, b) for (long long i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define pqmaxi priority_queue<int>
#define pqmaxl priority_queue<ll>
#define pqmini priority_queue<int, vi, greater<int>>
#define pqminl priority_queue<ll, vl, greater<ll>>
#define all(x) x.begin(), x.end()
#define test     \
    ll test;     \
    cin >> test; \
    while (test--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL)
#define eee 1000000000000000000
queue<ll> q;
bool visited[1001] = {false};
vl adj[1001];
int main()
{
    fast;
    ll n;
    cin >> n;
    vl v(n);
    f(i, 0, n)
    {
        cin >> v[i];
    }
    sort(all(v));
    ll ans = 1;
    bool clr = true;
    ;
    f(i, 0, n)
    {
        if (v[i] > eee / ans)
        {
            clr = false;
            break;
        }
        ans *= v[i];
        if (ans == 0)
        {
            clr = true;
            break;
        }
    }
    if (clr == true)
    {
        cout << ans;
    }
    else
    {
        cout << "-1";
    }
    return 0;
}


Measured memory_bytes: 3992
/**
 * @Author:      G_BG
 * @DateTime:    2018-10-06 17:24:37
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define dwn(x, y, z) for (int x = y; x >= z;--x)
#define lowbit(x) (x & (-x))
typedef long long LL;
typedef unsigned long long ULL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn=1e5+10;
map<string,int> dict,dict1;
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    int n , m;cin >> n;
    rep(i,0,n) {
        string s;
        cin >> s;
        dict[s]++;
    }
    cin >> m;
    rep(i,0,m){
        string s;
        cin >> s;
        dict1[s]++;
    }
    int ans = 0;
    for(auto i = dict.begin();i != dict.end();i++){
        ans = max(ans,i->second-dict1[i->first]);
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[200],dp[200000],n,k;

int stone(int a){
	if(a == 0) return 2;
	if(dp[a] != 0) return dp[a];
	else{
		for(int i = 1; i <= n; i++){
			if(arr[i] > a) break;
			if(stone(a - arr[i]) == 2){
				dp[a] = 1;
				break;
			}
		}
		if(dp[a] == 0) dp[a] = 2;
	}
	
	return dp[a];
}
int main (){
	memset(dp,0,sizeof dp);
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		cin >> arr[i]; 
	}
	sort(arr + 1, arr + n + 1);
	
	int ans = stone(k);
	
	if(ans == 1)cout << "First" << endl;
	else cout << "Second" << endl;
}

Measured memory_bytes: 4096
import sys
input=sys.stdin.readline

n=int(input())
t=list(map(int,input().split()))
m=int(input())
drinks=list(list(map(int, input().split())) for _ in range(m))

total=sum(t)
for i in range(m):
    print(total-t[drinks[i][0]-1]+drinks[i][1])

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,t,s,v; cin>>n>>t;
    vector<vector<int>> dpl(n,vector<int>(3001,0)),dpr(n,vector<int>(3001,0));
    vector<pp> g(n);
    rep(i,n){
        int a,b; cin>>a>>b;
        g[i]=mk(a,b);
    }
    for(int i=1;i<=n-1;i++){
        tie(s,v)=g[i-1];
        rep(j,3001){
            dpl[i][j]=dpl[i-1][j];
            if(j>=s){
                if(dpl[i][j]<dpl[i-1][j-s]+v)
                dpl[i][j]=dpl[i-1][j-s]+v;
            }
        }
    }
    for(int i=1;i<=n-1;i++){
        tie(s,v)=g[n-i];
        rep(j,3001){
            dpr[i][j]=dpr[i-1][j];
            if(j>=s){
                if(dpr[i][j]<dpr[i-1][j-s]+v)
                dpr[i][j]=dpr[i-1][j-s]+v;
            }
        }
    }
    int ans=0,cnt;
    rep(i,n){
        rep(j,t){
            cnt=g[i].second+dpl[i][j]+dpr[n-1-i][t-1-j];
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define  mem(a,x) memset(a,x,sizeof(a));
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;
int main()
{
    ft
    int n;
    cin>>n;
    double ans=0.0,x;
    string s;
    while(n--)
    {
        cin>>x>>s;
        if(s=="JPY")
        {
            ans+=x;
        }
        else
        {
            ans+=(x*380000.0);
        }
    }
    cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 3840
import itertools

n,k = map(int, input().split())
z = [list(map(int, input().split())) for i in range(n)]

a = [i for i in range(n)]
c = list(itertools.combinations(a,2))
ans = float('inf')


for x in c:
    for y in c:
        d = 0
        x1 = max(z[x[0]][0],z[x[1]][0])
        x2 = min(z[x[0]][0],z[x[1]][0])
        y1 = max(z[y[0]][1],z[y[1]][1])
        y2 = min(z[y[0]][1],z[y[1]][1])
        for i in range(n):
            if x2 <= z[i][0] <= x1 and y2 <= z[i][1] <= y1:
                d += 1
        if d == k:
            ans = min(ans, (x1-x2)*(y1-y2))

print(ans)

Measured memory_bytes: 52060
N = int(input())
S = []
P = []
ID = []
for n in range(N):
    S_temp, P_temp = list(input().split())
    S_temp = str(S_temp)
    P_temp = int(P_temp)
    S.append(S_temp)
    P.append(P_temp)
    ID.append(n + 1)

for n in range(N):
    for m in range(N - 1, n, -1):
        if S[m] < S[m - 1]:
            S[m], S[m - 1] = S[m - 1], S[m]
            P[m], P[m - 1] = P[m - 1], P[m]
            ID[m], ID[m - 1] = ID[m - 1], ID[m]
        elif S[m] == S[m - 1]:
            if P[m] > P[m - 1]:
                S[m], S[m - 1] = S[m - 1], S[m]
                P[m], P[m - 1] = P[m - 1], P[m]
                ID[m], ID[m - 1] = ID[m - 1], ID[m]

for n in range(N):
    #print(str(S[n]) + " " + str(P[n]) + " " + str(ID[n]))
    print(ID[n])


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

const int N = 2 * 100 * 1000 + 2;
long long n, q, counter[N];
vector <int> adj[N];

void dfs(int u, int par) {
	for (int v: adj[u]) {
		if (v == par)
			continue;
		counter[v] += counter[u];
		dfs(v, u);
	}
}

int main() {
	
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n >> q;
	for (int i = 1, u, v; i < n; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 0, p, x; i < q; i++) {
		cin >> p >> x;
		counter[p] += x;
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++)
		cout << counter[i] << ' ';
	
	return 0;
}

Measured memory_bytes: 24320
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	a := scanInts(n)

	f := true
	for i := 0; i < n; i++ {
		if a[i]%2 == 0 {
			if !(a[i]%3 == 0 || a[i]%5 == 0) {
				f = false
			}
		}
	}

	if f {
		fmt.Println("APPROVED")
	} else {
		fmt.Println("DENIED")
	}
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ans := (n + 1) * n / 2
	for i := 2; i <= n; i++ {
		for j := 1; i*j <= n; j++ {
			ans += i * j
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1788
use std::collections::HashSet;

fn main(){
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  let mut it = buf.split_whitespace();
  let x: u32 = it.next().unwrap().parse().unwrap();
  let n: u32 = it.next().unwrap().parse().unwrap();

  if n == 0 {
    println!("{}", x);
  } else {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    let hs: HashSet<u32> = buf.split_whitespace().map(|e| e.parse().unwrap()).collect();

    let mut i: u32 = 0;

    loop {
      if ! hs.contains(&(x - i)) {
        println!("{}", x - i);
        break;
      } else if ! hs.contains(&(x + i)) {
        println!("{}", x + i);
        break;
      } else {
        i += 1;
      }
    }
  }
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    if(s=="MON"){
        cout<<6<<endl;
    }
    else if(s=="TUE"){
        cout<<5<<endl;
    }
    else if(s=="WED"){
        cout<<4<<endl;
    }
    else if(s=="THU"){
        cout<<3<<endl;
    }
    else if(s=="FRI"){
        cout<<2<<endl;
    }
    else if(s=="SAT"){
        cout<<1<<endl;
    }
    else cout<<7<<endl;
    return 0;
    }


Measured memory_bytes: 256