akhauriyash/Code-Regression huggingface dataset:
def task_scheduling_problem(A1: int, A2: int, A3: int)->int:
    return max(A1, A2, A3) - min(A1, A2, A3)


if __name__ == "__main__":
    A1, A2, A3 = map(int, input().split())
    ans = task_scheduling_problem(A1, A2, A3)
    print(ans)


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

int main(){

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

    string s, t;
    cin >> s >> t;

    int n = s.length();
    int m = t.length();

    int ans = m;
    for(int i=0; i<=n-m; i++){
        int count=0;
        for(int j=0; j<m; j++){
            if(s[i+j]==t[j]){
                count++;
            }
        }
        ans=min(ans,m-count);
    }

    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    int N; cin >> N;
    ll L[N]; rep(i,N) cin >> L[i];

    int ans = 0;
    for (int i = 0; i < N-2; ++i) {
        for (int j = i+1; j < N-1; ++j) {
            for (int k = j+1; k < N; ++k) {
                ll sum = L[i] + L[j] + L[k];
                ll mx = max(L[i],max(L[j], L[k]));
                if (2*mx < sum && L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}





Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
#define MAX 100005

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

P Q[MAX+1];
int head=1, tail, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail+1==MAX){
    tail=0;
  }
  else{
    tail++;
  }
}

P dequeue(){
  P a=Q[head];
  if (head+1>= MAX) {
    head=0;
  }
  else{
    head++;
  }
  return a;
}


int main(){
  int elaps = 0;
  int count=0;
  int i,q;

  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  tail=n+1;

  for(i=1;i<=count+n;i++){
    if(Q[head].t<=q){
      printf("%s",Q[head].name);
      elaps=elaps+Q[head].t;
      printf(" %d\n",elaps);
      dequeue();
    }
    else {
      count++;
      elaps=elaps+q;
      Q[head].t=Q[head].t-q;
      enqueue(Q[head]);
      dequeue();
    }
  }
  return 0;
}

Measured memory_bytes: 10756
import java.util.*;

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

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] H = new int[N + 1];
        int[] maxH = new int [N + 1];

        Map<Integer, Set<Integer>> map = new HashMap<>();

        for (int i = 1 ; i <= N ; i++) {
            H[i] = scanner.nextInt();
            map.put(i, new HashSet<>());
            maxH[i] = 0;
        }


        for (int i = 0 ; i < M ; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();

            if (H[b] > maxH[a]) {
                maxH[a] = H[b];
            }
            if (H[a] > maxH[b]) {
                maxH[b] = H[a];
            }
        }

        int count = 0;
        for (int i = 1 ; i <= N ; i++) {
            if (H[i] > maxH[i]) count++;
        }

        System.out.println(count);
    }
}


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

typedef pair<int,int> PII;

int main(){
	int s,a[1000010];
	cin>>s;

	a[1]=s;
	int n=2;
	while(1){
		if(a[n-1]%2==0){
			a[n]=a[n-1]/2;
		}else{
			a[n]=a[n-1]*3+1;
		}

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

		n+=1;
	}

}

Measured memory_bytes: 256
package main

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

var r = bufio.NewReader(os.Stdin)

func main() {
    var a,b,c int
    fmt.Fscan(r,&a)
    fmt.Fscan(r,&b)
    fmt.Fscan(r,&c)
    if a <= b&&b <= c{
        fmt.Println(a, b, c)
    }else if a <= c&&c <= b{
        fmt.Println(a, c, b)
    }else if b <= a&&a <= c{
        fmt.Println(b, a, c)
    }else if b <= c&&c <= a{
        fmt.Println(b, c, a)
    }else if c <= b&&b <= a{
        fmt.Println(c, b, a)
    }else if c <= a&&a <= b{
        fmt.Println(c, a, b)
    }
}



Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define mx 200005
using namespace std;


int main(){
	int n, ans = 0, a[mx], anm[mx], m = 1;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	sort(a, a+n);
	anm[0] = 1;
	for(int i = 1; i < n; i++){
		if(a[i-1] == a[i]) anm[m-1]++;
		else{
			a[m] = a[i];
			anm[m] = 1;
			m++;
		}
	}
	for(int i = m-1; i >= 0; i--){
		while(anm[i]){
			anm[i]--;
			long long t = 1;
			for(; t <= a[i]; t<<=1);
			t -= a[i];
			int it = lower_bound(a, a+m, t) - a;
			if(it < m && a[it] == t && anm[it]){
				anm[it]--;
				ans++;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1792
package main

// Solution for https://atcoder.jp/contests/abc173/tasks/abc173_a

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	e := 1000 - n%1000
	e %= 1000
	con.Println(e)
	return nil
}


Measured memory_bytes: 1844
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


class Tree:
    def __init__(self):
        self.child = []
        self.count = 0

if __name__ == "__main__":
    N, Q = map(int, sys.stdin.readline().split())
    node_list = [Tree() for _ in range(N + 1)]

    for _ in range(N - 1):
        a, b = map(int, sys.stdin.readline().split())
        node_list[a].child.append(b)

    for _ in range(Q):
        p, x = map(int, sys.stdin.readline().split())
        node_list[p].count += x

    ans = []
    for n in node_list[1::]:
        ans.append(n.count)
        for nc in n.child:
            node_list[nc].count += n.count
    print(*ans)

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

vector<int> bitToVec(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main() {
    int64_t N, M, X;
    cin >> N >> M >> X;
    vector<int> price_list(N);
    vector<vector<int>> vec(N, vector<int>(M));
    for (int i=0; i < N; i++) {
        cin >> price_list.at(i);
        for (int j=0; j < M; j ++) {
            cin >> vec[i].at(j);
        }
    }

    int minPrice = INT_MAX;
    for (int bit=0; bit < (1<<N); bit++) {
        int price = 0;
        vector<int> skill_list(M, 0);
        vector<int> bit_vec = bitToVec(bit, N);
        for (int i=0; i < bit_vec.size(); i++) {
            int index = bit_vec[i];
            price += price_list[index];
            for (int j=0; j < M; j++) {
                skill_list[j] += vec[index][j];
            }
        }

        bool is_passed = true;
        for (int i=0; i < M; i++) {
            if (X > skill_list[i]) {
                is_passed = false;
                break;
            }
        }

        if (is_passed && minPrice > price) {
            minPrice = price;
        }
    }

    if (minPrice == INT_MAX) {
        cout << "-1" << endl;
    } else {
        cout << minPrice << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

ll n, a, b, mem, x;
ll cnt;

int main() {
	cin >> n >> a >> b >> x;
	cnt = 0;
	lp(n - 1) {
		cin >> mem;
		cnt += min((mem - x)*a, b);
		x = mem;
	}
	cout << cnt << endl;
	return 0;
}


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

typedef long long ll;

int n, m, c;
vector<int> b(20);

int a[20][20];

int main(){
    cin >> n >> m >> c;
    for (int i = 0; i < m; i++){
        cin >> b[i];
    }

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

    int cnt = 0;
    for (int i = 0; i < n; i++){
        int res = 0;
        for (int j = 0; j < m; j++){
            res += a[i][j] * b[j];            
        }
        res += c;
        if (res > 0) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main()
{

    int numofTimes = 0;
    std::vector<int> input;
    std::cin >> numofTimes;
    for (int i = 0; i < numofTimes; i++)
    {
        int num;
        std::cin >> num;
        input.push_back(num);
    }
    bool flag;
    for (size_t i = 0; i < input.size(); i++)
    {
        flag = input[i] != i + 1;
        if (flag)
        {
            int temp = input[i];
            input[i] = input[temp - 1];
            input[temp - 1] = temp;
            break;
        }
    }

    for (size_t i = 0; i < input.size() - 1; i++)
    {
        if (input[i] + 1 != input[i + 1])
        {
            std::cout << "NO";
            return 0;
        }
    }

    std::cout << "YES";

    return 0;
}

Measured memory_bytes: 3572
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int sum = 0;

        while(k > 0){
            if(a > 0){
                a--;
                sum++;
            }else if(b > 0){
                b--;
            }else{
                c--;
                sum--;
            }
            k--;
        }

        System.out.println(sum);

    }
}


Measured memory_bytes: 35776
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String before = s.substring(0, 2);
        String after = s.substring(2, 4);
        int bNum = Integer.valueOf(before);
        int aNum = Integer.valueOf(after);
        if(isMonthOk(bNum) && isMonthOk(aNum)) System.out.println("AMBIGUOUS");
        else if(!isMonthOk(bNum) && !isMonthOk(aNum)) System.out.println("NA");
        else if(isMonthOk(bNum)) System.out.println("MMYY");
        else System.out.println("YYMM");
    }
    private static boolean isMonthOk(int num) {
        return num >= 1 && num <= 12;
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a,b,k;
    scanf("%lld %lld %lld",&a,&b,&k);
    if(a-k >= 0){
        a = a - k;
    } else if(a-k < 0 && b-(k-a) >= 0){
        b = b - (k - a);
        a = 0;
    } else {
        a = 0;
        b = 0;
    }
    
    printf("%lld %lld\n",a,b);
    
    return 0;
}


Measured memory_bytes: 256
while True:
	m, f, r = map(int, input().split())
	if m == -1 and f == -1 and r == -1:
		break
	if m == -1 or f == -1:
		print("F")
	elif m + f >= 80:
		print("A")
	elif m + f >= 65:
		print("B");
	elif m + f >= 50:
		print("C")
	elif m + f >= 30:
		if r >= 50:
			print("C")
		else:
			print("D")
	else:
		print("F")
        
        




Measured memory_bytes: 5592
def check_two_stones(S, A, B, C, D):
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            return False
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            return False

    return True

N, A, B, C, D= map(int, input().split(" "))
S_org = input()

S = S_org + "#"
if (B < C and C < D) or (C < B and B < D):
    if check_two_stones(S, A, B, C, D) is False:
        print("No")
        exit()
else:
    check = True
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            check = False

    #  ゴールと手前が"##"
    #if check is True and S[D-2] is "#":
         # 途中に"..."があれば回避できる

    S = S_org + "#."
    for j in range(B-2, D-1):
        if S[j] is "." and S[j+1] is "." and S[j+2] is ".":
            check = True
            break
        else:
            check = False

    if check is False:
        print("No")
        exit()

    S = S_org + "#"
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3892
<?php
$n = fgets(STDIN);
for($i=1; $i<=$n; ++$i){
  $num = fscanf(STDIN, '%d %d %d');
  //valueを小さい順に並べ替える(sort)
  sort($num);
  if (pow($num[0], 2) + pow($num[1], 2) === pow($num[2], 2)){
    echo 'YES';
  } else {
    echo 'NO';
  }
    echo PHP_EOL;
}

Measured memory_bytes: 6572
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)

#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了

cumsum(リスト) #累積和をリストで返す
cumsum_number(N,K,x) #N個の数が含まれるリストx内のK個からなる部分和をリストで返す
"""
N,K=map(int,input().split())
for i in range(10000):
    if K**i<=N<K**(i+1):
        print(i+1)
        exit(0)



Measured memory_bytes: 27016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0 ; i<n ; i++){
        cin>>arr[i];
    }
    sort(arr , arr+n , greater<int>());
    int a, b;
    a = 0 ;
    b = 0;
    for(int i = 0 ; i<n ; i++){
        if(!(i%2)){
            a+=arr[i];
        }
        else{
            b+=arr[i];
        }
    }
    cout<<abs(a-b);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(ll i = f; i < t; i++)

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n);
    for (auto &v : x)
        cin >> v;
    
    ll minLen = 300000000;
    for (ll i = 0; i < n - k + 1; i++) {
        auto f = x[i], t = x[i + k - 1];
        if (t <= 0) {
            minLen = min(abs(f), minLen);
        } else if (f >= 0) {
            minLen = min(t, minLen);
        } else {
            minLen = min(min(abs(f) * 2 + t, abs(f) + t * 2), minLen);
        }
    }
    
    cout << minLen << endl;
    
}



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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 50;
const int MAX_M = 100;
const int MAX_MONEY = 2500;

int N, M, S;
struct E {
  E(int to = 0, int a = 0, int b = 0) : to(to), a(a), b(b) {}
  int to, a, b;
};
vector<E> edge[MAX_N];
int C[MAX_N];
int D[MAX_N];

int dist[MAX_N][MAX_MONEY+1];

struct P {
  P(int cost = 0, int pos = 0, int money = 0) : cost(cost), pos(pos), money(money) {}
  int cost;
  int pos, money;
  const bool operator < (const P& p) const {
    return cost < p.cost;
  }
  const bool operator > (const P& p) const {
    return cost > p.cost;
  }
};

signed main()
{
  cin >> N >> M >> S;
  S = min(S, MAX_MONEY);
  REP(m,M) {
    E e;
    int f, t, a, b;
    cin >> f >> t >> a >> b;
    f--; t--;
    edge[f].push_back(E(t,a,b));
    edge[t].push_back(E(f,a,b));
  }
  REP(n,N) {
    cin >> C[n] >> D[n];
  }

  REP(n,MAX_N) {
    REP(j,2501) {
      dist[n][j] = INF_LL;
    }
  }
  dist[0][S] = 0;

  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push(P(0,0,S));
  while(pq.size()) {
    P p = pq.top(); pq.pop();
    if (dist[p.pos][p.money] < p.cost) continue;

    // お金の両替
    if (p.money + C[p.pos] <= MAX_MONEY) {
      if (dist[p.pos][p.money + C[p.pos]] > p.cost + D[p.pos]) {
        dist[p.pos][p.money + C[p.pos]] = p.cost + D[p.pos];
        pq.push(P(dist[p.pos][p.money + C[p.pos]], p.pos, p.money + C[p.pos]));
      }
    }

    // 移動
    for(E e : edge[p.pos]) {
      if (e.a <= p.money) {
        if (dist[e.to][p.money - e.a] > p.cost + e.b) {
          dist[e.to][p.money - e.a] = p.cost + e.b;
          pq.push(P(dist[e.to][p.money - e.a], e.to, p.money-e.a));
        }
      }
    }
  }

  FOR(i,1,N) {
    int ans = INF_LL;
    REP(n,MAX_MONEY+1) {
      ans = min(ans, dist[i][n]);
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 7336
#include<stdio.h>
int main()
{
  int n,y,f=0;
  scanf("%d", &n);
  scanf("%d", &y);
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
        if(y==10000*i+5000*j+1000*(n-i-j) && (n-i-j)>=0){
          printf("%d %d %d\n", i,j,n-i-j);
          f=1;
          break;
        }
    }
    if(f==1) break;
  } 
  if(f==0) printf("-1 -1 -1\n");
  return 0;
}

Measured memory_bytes: 128
/*
テァツュツ氾」ツ?暗」ツ?ッテ」ツ??テ」ツ?凝」ツつ嘉ゥツ??ァツ閉ェテ」ツ?ォテ」ツ??, 4, 7, 11テ」ツ?ィテ・ツ「ツ療」ツ?暗」ツ?ヲティツ。ツ古」ツ??

2 ---> 4 ---> 7 ---> 11
   +2     +3     +4

テヲツ閉ーテ・ツ按療」ツ?ョテゥツ堋」テ」ツ?ィテ」ツ?ョテ・ツキツョテ」ツ?古」ツ??テ」ツ?堙」ツ?、テ・ツ「ツ療」ツ?暗」ツ?ヲテ」ツ??」ツつ凝」ツ?禿」ツ?ィテ」ツ?ォテヲツーツ療」ツ?・テ」ツ?湘」ツ??
forテヲツ鳴?」ツ?ァティツカツウテ」ツ?療」ツ?禿」ツつ禿」ツ?ァテ」ツ??」ツ?妥」ツ?ーテ」ツ??」ツ??」ツ??

 */
#include <stdio.h>

int main(void){
  int n;
  int i, ans;

  while(1){
    if(scanf("%d", &n) == EOF) break;

    ans = 1;
    for(i = 1; i <= n; i++){
      ans += i;
    }
    printf("%d\n", ans);
  }

  return 0;
}

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

int foo(string t){
  int a;
  a = (t[0] - '0') * 10 * 3600 + (t[1] - '0') * 3600 + (t[3] - '0') * 10 * 60 + (t[4] - '0')* 60 + (t[6] - '0') * 10 + (t[7] - '0');
  return a;
}

int main(){
  int n, f ,k;
  int i, l;
  
  while(1){
    string t, j;
    int z[3600 * 24 + 10] = {};
    int max = 0;
    cin>>n;
    
    if(n == 0) break;
    
    for(i = 0; i < n; i++){
      cin>>t>>j;
      f = foo(t);
      k = foo(j);
      for(l = f; l < k; l++){
	z[l]++;
      }
    }
    
    for(i = 0; i < 3600 * 24; i++){
      if(max < z[i]) {max = z[i];}//cout<<z[i]<<" "<<i<<endl;
    }

    cout<<max<<endl;
    
  }
  
  return 0;
}



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

int main(){
    int n, in;
    vector <int> val;

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> in;
        val.push_back(in);
        if(i != n - 1){
            cout << in << " ";
        }else{
            cout << in << endl;
        }
    }
    for(int i = 1; i < n; i++){
        int v = val[i];
        int j = i - 1;
        while(j >= 0 && val[j] > v){
            val[j + 1] = val[j];
            j--;
        }
        val[j + 1] = v;

        for(int k = 0; k < n; k++){
            if(k != n - 1){
                cout << val[k] << " " ;
            }else{
                cout << val[k] << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3148
n,k = map(int,input().split())

l = [0 for _ in range(n)]

for i in range(k):
  d = int(input())
  a = list(map(int,input().split()))
  
  for j in a:
    l[j-1] += 1
    
c = 0
for n in l:
  if n == 0 :
    c += 1
    
    
print(c)
  
  

Measured memory_bytes: 9184
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007
typedef long long ll;

using namespace std;


int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
int gcd(int x, int y)
{
    if(x%y==0)return y;
    else if(y%x==0)return x;
    else return gcd(x%y,y%x);
}
ll gcd(ll x, ll y)
{
    if(x%y==0)return y;
    else if(y%x==0)return x;
    else return gcd(x%y,y%x);
}


long long max1,max2;
int main()
{
    int n;
    cin>>n;
    int a[n];
    rep(i,n)
    {
        cin>>a[i];
    }
    int cnt=0;
    rep(i,n-1)
    {
        if(a[i]==a[i+1])
        {
            cnt++;
            a[i+1]+=20000;
        }
    }
    W(cnt)
    return 0;
}

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

int main() {
    ll X;
    cin >> X;
    for (ll A = -200; A < 201; A++) {
        for (ll B = -200; B < 201; B++) {
            if (A * A * A * A * A - B * B * B * B * B == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3616
n,p=map(int,input().split())
a=list(map(int,input().split()))

n_odd=0
n_even=0

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


for i in a:
    if i%2==0:
        n_even+=1
    else:
        n_odd+=1

ans=0

if p==0:    
    #p=0
    for j in range(n_odd+1):
        if j%2==1:
            continue
        else:
            tmp=0
            for l in range(n_even+1):
                tmp+=cmb(n_even,l)
            
            ans+=cmb(n_odd,j)*tmp
elif p==1:
    #p=1
    for k in range(n_odd+1):
        if k%2==0:
            continue
        else:
            tmp=0
            for l in range(n_even+1):
                tmp+=cmb(n_even,l)

            ans+=cmb(n_odd,k)*tmp

print(ans)



Measured memory_bytes: 9552
STDIN.each_line(chomp: true) do |line|
  joi, ioi = 0, 0
  (0...line.size).each do |i|
    joi += 1 if line[i, 3] == "JOI"
    ioi += 1 if line[i, 3] == "IOI"
  end
  puts joi, ioi
end


Measured memory_bytes: 6848
#include <stdio.h>
#include <string.h>

void printstr(int a, int b, char *str) {
	int length = strlen(str);
	char s[length+1];

	strncpy(s, str+a, b-a+1);

	s[b-a+1] = '\0';

	printf("%s\n", s);
}

void reversestr(int a, int b, char *str) {
	int length = strlen(str);
	char s[length + 1];
	
	strcpy(s, str);

	int i;
	for (i = 0; i < b - a + 1; i++) {
		str[a + i] = s[b - i];
	}
}

void replacestr(int a, int b, char *str, char *p) {
	int i;
	for (i = 0; i < b - a + 1; i++) {
		str[a + i] = p[i];
	}
}

int main(void)
{
	int a, b;
	char str[1001], command[8], p[1001];

	scanf("%s", str);

	int q;

	scanf("%d", &q);

	for (; q > 0; q--) {
		scanf("%s %d %d", command, &a, &b);

		if (strcmp(command, "print") == 0)
			printstr(a, b, str);
		else if (strcmp(command, "reverse") == 0)
			reversestr(a, b, str);
		else if (strcmp(command, "replace") == 0) {
			scanf("%s", p);
			replacestr(a, b, str, p);
		}
	}

	return 0;
}

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

int main() {
    string a;
    cin >> a;

    int n = 0, w = 0, s = 0, e = 0;
    for (int i = 0, m = a.size(); i < m; i++)
        switch (a.at(i)) {
            case 'N':
                n++;
                break;
            case 'W':
                w++;
                break;
            case 'S':
                s++;
                break;
            case 'E':
                e++;
                break;
        }
    
    if ((n > 0  && w > 0  && s > 0  && e > 0 )
     || (n > 0  && w == 0 && s > 0  && e == 0)
     || (n == 0 && w > 0  && s == 0 && e > 0 )
     || (n == 0 && w == 0 && s == 0 && e == 0))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    bool ok = true;
    int a1 = 0;
    int b1, b2, b3;
    cin >> b1 >> b2 >> b3;
    int c21, c22, c23;
    cin >> c21 >> c22 >> c23;
    int a2 = c21 - b1;
    if (a2 + b2 != c22) ok = false;
    if (a2 + b3 != c23) ok = false;
    int c31, c32, c33; 
    cin >> c31 >> c32 >> c33;
    int a3 = c31 - b1;
    if (a3 + b2 != c32) ok = false;
    if (a3 + b3 != c33) ok = false;
    printf(ok?"Yes\n":"No");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

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

    int N;
    cin >> N;
    vector<int> A(3 * N);
    cin >> A;


    auto solve = [&]() {
        RSORT(A);
        ll sum = 0;
        REP(i, N) {
            sum += A[i * 2 + 1];
        }
        return sum;
    };

    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

ll power(ll a,ll n)
{
	if(n==0)
	return 1;
	if(n%2==0)
	return power((a*a)%mod,n/2)%mod;
	return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
}


int main()
{
int n,k;
  scf(n);scf(k);
  int a[n];
  rep(i,0,n)
    scf(a[i]);
  int sum=0;
  sort(a,a+n);
  rep(i,0,k)
    sum+=a[i];
  pri(sum);
return 0;
}

Measured memory_bytes: 3820
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 3000 + 10;
LL mat[MAXN][MAXN];
LL dp[4][MAXN][MAXN];





int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    int a, b, c; cin >> a >> b >> c;
    mat[a][b] = c;
  }
  memset(dp, -1, sizeof(dp));
  dp[0][1][1] = 0;
  if (mat[1][1] > 0) dp[1][1][1] = mat[1][1];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int u = 0; u < 4; u++) {
        if (dp[u][i][j] == -1) continue;
        if (j+1 <= m) {
          dp[u][i][j+1] = max(dp[u][i][j+1], dp[u][i][j]);
          if (mat[i][j+1] > 0 && u < 3) dp[u+1][i][j+1] = max(dp[u+1][i][j+1], dp[u][i][j] + mat[i][j+1]);
        }
        if (i+1 <= n) {
          dp[0][i+1][j] = max(dp[0][i+1][j], dp[u][i][j]);
          if (mat[i+1][j] > 0) dp[1][i+1][j] = max(dp[1][i+1][j], dp[u][i][j] + mat[i+1][j]);
        }
      }
    }
  }
  LL ret = 0;
  for (int u = 0; u < 4; u++) {
    ret = max(ret, dp[u][n][m]);
  }
  cout << ret << '\n';






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 356708
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

char a;
int main(){
    cin>>a;
    if('a'<=a && a<='z'){
        cout<<'a'<<endl;
    }else{
        cout<<"A";
    }

    return 0;
}

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


int main(){
    ll X;
    cin >> X;
    ll num = X/100;
    ll kuku = X % 100;
    bool flag = true;
    if(X < 100){
        cout << 0;
    }else{
        if(5 * num < kuku){
            cout << 0;
        }else{
            cout << 1;
            /*
            for(ll i=2;i<kuku;i++){
                if(kuku % i == 0 && flag){
                    cout << 1;
                    flag = false;
                }
            }
            if(kuku == 5|kuku == 3 ||kuku == 2||kuku == 1|| kuku ==0){
                cout << 1;
                flag = false;
            }

            if(flag){
                cout << 0;
            }
            */
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    ll n, m, x;    cin >> n >> m >> x;
    vector<ll> c(n);
    vector<vector<ll>> a(n, vector<ll>(m));
    for(ll i=0; i<n; i++){
        cin >> c.at(i);
        for(ll j=0; j<m; j++)  cin >> a.at(i).at(j);
    }

    ll sum = -1;
    for(ll i=0; i<(1<<n); i++){
        ll tmp=0;
        vector<ll> lr(m, 0);
        bool flag = true;
        for(ll j=0; j<n; j++){
            if(i&1<<j){
                tmp += c[j];
                for(ll t=0; t<m; t++) lr[t] += a[j][t];
            }
        }
        for(ll t=0; t<m; t++){
            if(x<=lr[t]) continue;
            flag = false;
        }
        if(flag){
            if(sum<0) sum = tmp;
            else sum = min(sum, tmp);
        }
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 5;
typedef long long ll;
int p[maxn], n;
ll add[maxn], cnt[maxn];
struct Edge{
    int a, b;
    ll c;
}e[maxn];
bool Cmp(Edge a, Edge b){return a.c > b.c;}
int Find(int x){
    if(p[x] == x)return x;
    if(Find(p[x]) == p[x])return p[x];
    add[x] += add[p[x]];
    p[x] = p[p[x]];
    //add[x] -= add[p[x]];
    return p[x];
}
void Merge(int a, int b, ll c){
    int x = Find(a), y = Find(b);
    add[x] += c * cnt[y];
    add[y] += c * cnt[x];
    cnt[x] += cnt[y];
    add[y] -= add[x];
    p[y] = x;
}
int main(){
//    freopen("e:\\in.txt","r",stdin);
    cin>>n;
    int a, b;
    ll c;
    for(int i = 0; i < n - 1; i++)scanf("%d%d%lld", &e[i].a, &e[i].b, &e[i].c);
    sort(e, e + n - 1, Cmp);
    for(int i = 1; i <= n; i++)p[i] = i, add[i] = 0, cnt[i] = 1;
    for(int i = 0; i < n - 1; i++){
        Merge(e[i].a, e[i].b, e[i].c);
    }
//    for(int i = 1; i <= n; i++){
//        cout<<p[i]<<' '<<add[i]<<endl;
//    }
    for(int i = 1; i <= n; i++){
        Find(i);
//        cout<<p[i]<<' '<<add[i]<<endl;
        ll ans;
        if(p[i] == i)ans = add[i];
        else ans = add[i] + add[p[i]];
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 1e6+100;
int const M = N;
map<ll,set<ll> > factors;
map<ll,ll> spf;
map<ll,bool>vs;
vector<ll>prms;
 
void factorize(ll n){ 
    ll k = n;
    int count = 0; 
    while (!(n % 2)) { 
        n >>= 1;
        count++; 
    } 
    if (count)factors[k].insert(2);
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count)factors[k].insert(i);
    } 
    if (n > 2)factors[k].insert(n);
}

int main(){
    ll a, b; 
    scanf("%lld%lld", &a, &b);
    factorize(a);
    factorize(b);
    for(auto j: factors[a]){
          vs[j] = true;
    }
    ll an = 0;
    for(auto j: factors[b]){
        if(vs[j])++an;
    }
    printf("%lld\n",an+1);
} 


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

namespace AtCoder.ABC169
{
    public class Problem2
    {
        public static void Main(string[] args)
        {
            try
            {
                var count = decimal.Parse(Console.ReadLine());

                var ins = Console.ReadLine().Split(" ");

                var result = (decimal)1;

                var nums = ins.Select(x => decimal.Parse(x)).OrderBy(x => x);

                var m = (decimal)Math.Pow(10, 18);

                if (nums.Contains(0))
                {
                    Console.WriteLine((0).ToString());
                    return;
                }

                foreach (var num in nums)
                {
                    result *= num;
                    if (result > m)
                    {
                        Console.WriteLine((-1).ToString());
                        return;
                    }
                }

                Console.WriteLine(result.ToString());
                return;
            }
            catch
            {
                Console.WriteLine((-1).ToString());
                return;
            }
        }
    }
}


Measured memory_bytes: 49184
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int a[15];

int main(void){
	int i;

	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int n,k;
	cin >> n >> k;
	for(i=1;i<=k;i++){
		int p;
		cin >> p;
		a[p]=1;
	}

	int ans;
	for(i=1;i<=10*n;i++){
		if(i>=n){
			bool f=true;
			int x=i;
			while(1){
				int r=x%10;
				x=x/10;
				if(a[r]==1){
					f=false; break;
				}

				if(x==0) break;
			}

			if(f){
				ans=i; break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	int tmp, a = INF, b = 0;
	rep(i, n) {
		scanf("%d", &tmp);
		a = min(a, tmp);
		b = max(b, tmp);
	}
	printf("%d", b - a);

	Please AC;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	while (b > 0) {
		if (b & 1) {res = (res * a); b--;}
		a = (a * a);
		b >>= 1;
	}
	return res;
}
ll n;
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

vector <ll> dp(100005,-1);
vector <ll> v;

ll solve(ll k){
	//cout<<n<<"\n";
	if(dp[k]!=-1)
		return dp[k];
	ll ans=0;
	int f=0;
	for(ll j=0;j<n;j++){
		if(v[j]>k)
			break;
		f=1;
		ans|=(solve(k-v[j])-1)*(-1);
	}
	if(f==0)
		return dp[k]=0;
	if(ans==1)
		return dp[k]=1;
	else
		return dp[k]=0;
}

int main() {
	/*ios_base::sync_with_stdio(false);
	cin.tie(0);*/
	ll kk;
	cin>>n>>kk;
	for(ll i=0;i<n;i++){
		ll dd;
		cin>>dd;
		v.pb(dd);
	}
	sort(all(v));
	ll ans=0;
	ans=solve(kk);
	if(dp[kk]==1)
		cout<<"First\n";
	else
		cout<<"Second\n";

}

Measured memory_bytes: 10256
#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i, a, n) for(int i = a;i < n;i++)
using namespace std;


void solve(int s){
	rep(i, 1, 317){
		if(i*i == s){
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}


int main(){
	int a, b;
	int s;

	cin >> a >> b;

	s = a;

	s = s*(int)pow(10, 1+(int)log10(b)) + b;

	solve(s);

	return 0;
}

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

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

int main(){
  long long N, X; cin >> N >> X;
  if(X>N/2){
    X=N-X;
  }
  long long ans=gcd(X, N)*(N/gcd(X, N)-1)*3;
  cout << ans << endl;
}

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

int main()
{
	string s;
	while(cin >> s){
		long long ans = 0;
		int j = 0;
		for(int i = 0;i < s.length();i++){
			if(s[i] == 'W'){
				ans += i - j;
				j++;
			}
		}
		cout << ans << endl;
	}
	return 0;	
} 


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

using namespace std;

#define ll long long
#define uint unsigned int

int c[10][10];

int main() {
    int h, w;
    scanf("%d %d", &h, &w);

    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            scanf("%d", &c[i][j]);
        }
    }

    for (int k = 0; k < 10; ++k) {
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    ll res = 0;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            int x;
            scanf("%d", &x);
            if (x != -1) {
                res += c[x][1];
            }
        }
    }

    printf("%lld\n", res);

    return 0;
}


Measured memory_bytes: 256