akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
  while (1) {
    int m, f, r;
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) break;
    if (m == -1 || f == -1) cout << 'F' << endl;
    else if (m + f >= 80) cout << 'A' << endl;
    else if (m + f >= 65) cout << 'B' << endl;
    else if (m + f >= 50) cout << 'C' << endl;
    else if (m + f >= 30) {
      if (r >= 50) cout << 'C' << endl;
      else cout << 'D' << endl;
    }
    else cout << 'F' << endl;
  }
  return 0;
}



Measured memory_bytes: 3024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


    using namespace std;
 
    int main(){
      int a,b,c;
      cin >> a >> b >>c;
      if(b-a==c-b)cout << "YES" << endl;
      else cout << "NO" << endl;
      return 0;}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,m,a[310],p[310];
ll ans,d,f[310][55];
ll solve(){
	for (int i=0;i<=n*m;i++)
		for (int j=0;j<(1<<(n-1));j++)
			f[i][j]=0;
	f[0+n*a[n]][0]=1;
	for (int i=0;i<n*m;i++){
		if (!(i%n)) continue;
		int x=p[i%n];
		for (int s=0;s<(1<<(n-1));s++)
			for (int j=i;j<=n*m;j++)
				if (!(s&(1<<(x-1))))
					f[min(n*m,max(j,i+n*a[x]))][s|(1<<(x-1))]+=f[j][s];
	}
	return f[n*m][(1<<(n-1))-1];
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n-1;i++) p[i]=i;
	do{
		ans+=solve();
		d++;
	} while (next_permutation(p+1,p+n));
	for (int i=1;i<=n-1;i++) d=d*m;
	printf("%.16lf",(double)ans/d);
	return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()
ans = 'Yes'
li = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
for i in range(a):
    if s[i] not in li:
        ans = 'No'
if s[a] != '-':
    ans = 'No'
for j in range(1, b):
    if s[-j] not in li:
        ans = 'No'
print(ans)

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

void merge_sort(long long x[], int n)
{
	static long long y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	long long H, a[100001], b[100001];
	scanf("%d %lld", &N, &H);
	for (i = 0; i < N; i++) scanf("%lld %lld", &(a[i]), &(b[i]));

	long long max = 0, sum[100001] = {}, ans, count;
	for (i = 0; i < N; i++) if (a[i] > max) max = a[i];
	merge_sort(b, N);
	sum[N-1] = b[N-1];
	for (i = N - 2; i >= 0; i--) sum[i] = sum[i+1] + b[i]; 
	ans = (H - 1) / max + 1;
	for (i = 0; i < N; i++) {
		count = (H - sum[i] <= 0)? 0: (H - sum[i] - 1) / max + 1;
		count += N - i;
		if (count < ans) ans = count;
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	cout << (a + b > 23 ? a + b - 24 : a + b) << endl;
	
	return 0;
}

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

int main()
{
  int n,i,j,v1,v2,m;
  int map[101][101];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      map[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&v1,&m);
    for(j=0;j<m;j++){
      scanf("%d",&v2);
      map[v1-1][v2-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",map[i][j]);
    }
    printf("%d\n",map[i][j]);
  }
  return 0;
}



Measured memory_bytes: 2060
object Main extends App{
    val n = scala.io.StdIn.readInt
    val s = scala.io.StdIn.readLine
    
    val output = (1 until n).map(e => (s.take(e).distinct, s.drop(e).distinct)).map(e => e._1 intersect e._2).map(_.length).max
    println(output)
}


Measured memory_bytes: 28284
import math

N = int(input())

M = N
tmp = 0
A = 0

for i in range(2,int(math.sqrt(N))+1):
    if N % i == 0:
        tmp = N / i
        if abs(tmp - i) < M:
            M = abs(tmp-i)
            A = tmp+i
if A == 0:
    print(N-1)
else:
    print(int(A-2))

Measured memory_bytes: 3188
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    string s;

    cin >> s;

    string rs = s;

    reverse(rs.begin(), rs.end());

    int ans = 0;

    
    for(int i = 0; i < s.size() / 2; i++){
        if(s[i] != rs[i]){
            ans++;
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
	vector<int> v(3);
	for(auto &it:v)cin>>it;
	sort(all(v));
	//print(v);
	int cnt=0;
	for(int i=1;i<3;i++)cnt+=abs(v[i]-v[i-1]);
	cout<<cnt<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
    int a,b,ret;
    while((ret=scanf("%d%d",&a,&b))!=EOF)
    {
        int i=0;
        while(++i)
        {
            if(pow(10,i)>a+b) break;
        }
        printf("%d\n",i);
    }
    return 0;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll MAX_N = 100005;
ll a[MAX_N];

int main()
{
	ll N,x;
	cin >> N >> x;
	ll ans = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		if (i != 0)
		{
			if (a[i-1] + a[i] > x)
			{
				ll eat = a[i-1] + a[i] - x;
				ans += eat;
				a[i] = max(a[i]-eat,(ll)0);
			}
		}
	}

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

Measured memory_bytes: 1024
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
	dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))
print(dp[-1])

Measured memory_bytes: 84980
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i <= 9; i++)
            {
                for (int I = 1; I <= 9; I++)
                {
                    Console.WriteLine(i.ToString()+"x"+I.ToString()+"="+(i*I).ToString());
                }
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9060
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
    }
    let mut ans = (1 + (n - 1)) * (n - 1) / 2;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main() {
	int a, b, c, d, ans = 0;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	for (int i = 0; i < 100; i++) {
		if (a <= i && i < b && c <= i && i < d) {
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func sum(a ...int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

type Edge struct {
	to, cost int
}

// 辺のリストで表現されるグラフ
type Graph struct {
	Edges [][]Edge // Edge[i][j]: 頂点iのj番目の辺
}

// 頂点数nのリスト型グラフを返す
func NewGraph(n int) *Graph {
	g := &Graph{
		Edges: make([][]Edge, n),
	}
	for i := 0; i < n; i++ {
		g.Edges[i] = make([]Edge, 0)
	}
	return g
}

// 辺の追加
func (g *Graph) AddEdge(from, to, cost int) {
	g.Edges[from] = append(g.Edges[from], Edge{to, cost})
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	g := NewGraph(n)
	for i := 0; i < n-1; i++ {
		a, b := nextInt()-1, nextInt()-1
		g.AddEdge(a, b, 0)
		g.AddEdge(b, a, 0)
	}
	c := nextInts(n)
	sort.Sort(sort.Reverse(sort.IntSlice(c)))

	val := make([]int, n)
	que := make([]int, 0)
	que = append(que, 0)
	for i := 0; len(que) > 0; {
		node := que[0]
		que = que[1:]
		if val[node] > 0 {
			continue
		}
		val[node] = c[i]
		i++
		for _, e := range g.Edges[node] {
			if val[e.to] == 0 {
				que = append(que, e.to)
			}
		}
	}

	score := sum(c...) - max(c...)
	puts(score)
	for i := range val {
		if i < n-1 {
			putf("%d ", val[i])
		} else {
			puts(val[i])
		}
	}
}


Measured memory_bytes: 3892
#include<stdio.h>
int a[1000001],b[1000001],c[1000001],p[1000001],x[1000001];
int main(void)
{
	long long int n,m,s,sum,i;
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=m;i++) scanf("%d",&p[i]);
	for(i=1;i<n;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]);
	for(i=1;i<m;i++){
		if(p[i]<p[i+1]){
			x[p[i]]++; x[p[i+1]]--;
		}
		if(p[i]>p[i+1]){
			x[p[i]]--; x[p[i+1]]++;
		}
	}
	s=0; sum=0;
	for(i=1;i<=n;i++){
	//printf("s=%d sum=%d\n",s,sum);
		s+=x[i];
		if(a[i]*s<b[i]*s+c[i]) sum+=a[i]*s;
		else sum+=b[i]*s+c[i];
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_;i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define INF 10000000

int main(){
    int n,d,kotae=0;
    cin >> n;
    set<int> s;
    set<int>::iterator ite;
    REP(i, n)
    {
        cin >> d;
        s.insert(d);
    }
    REP(i,100){
        if (s.find(i+1) != s.end()){
            kotae++;
        }
    }
    cout << kotae << endl;
}

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

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		int n = nextInt();
		int t = nextInt();
		
		int[] a = new int[n];
		int minPref = Integer.MAX_VALUE;
		
		int maxProfit = 0;
		int[] profitHere = new int[n];
		
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
			profitHere[i] = a[i] - minPref;
			minPref = Math.min(minPref, a[i]);
			maxProfit = Math.max(maxProfit, profitHere[i]);
		}
		
//		System.err.println(Arrays.toString(profitHere));
		
		int ans = 0;
		
		for (int i = 0; i < n; i++) {
			if (profitHere[i] == maxProfit) {
				ans++;
			}
		}
		
		out.println(ans);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 23792
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

O = {'+': lambda l, r: l + r,
     '-': lambda l, r: l - r,
     '*': lambda l, r: l * r}

P = {'+': 0,
     '-': 0,
     '*': 0}

class Source():
    def __init__(self, S, i=0):
        self.S = S
        self.pos = i

def peek(S):
    return S.S[S.pos] if S.pos < len(S.S) else 'a'

def next(S):
    S.pos += 1

def expr(S, i):
    # print(S.pos)
    if i == 0:
        left = factor(S)
    else:
        left = expr(S, i - 1)

    while peek(S) in O and P[peek(S)] == i:
        ope = peek(S)
        next(S)
        if i == 0:
            right = factor(S)
        else:
            right = expr(S, i - 1)
            
        left = O[ope](left, right)
        
    # print(left, i)
    return left


def factor(S):
    if peek(S) == '(':
        next(S)
        res = expr(S, 2)
        next(S)
    else:
        res = num(S)
    return res

def num(S):
    sign = 1
    if peek(S) == '-':
        sign = -1
        next(S)
    res = 0
    while '0' <= peek(S) <= '9':
        res = res * 10 + int(peek(S))
        next(S)

    return sign * res

S = input()
ans = -int(1e19)

for plus in range(3):
    P['+'] = plus
    for minus in range(3):
        P['-'] = minus
        for times in range(3):
            P['*'] = times
            ans = max(ans, expr(Source(S), 2))
            
print(ans)


Measured memory_bytes: 5632
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;


int main()
{
    string t[3]={"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;
    rep(i,3){
        if(s==t[i]){
            cout << t[(i+1)%3] << endl;
        }
    }
    return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M,a,b; cin>>N>>M;
	map<int,int> ct;
	for (int i=0; i<M; i++) {
		cin>>a>>b;
		ct[a]++; ct[b]++;
	}

	for (auto it : ct)
		if(it.second%2) {
			cout<<"NO\n";
			return 0;
		}
	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 4352
//confirm 0LL and 1LL
//confirm cornercases such as 0
//confirm times of cin < 1^6
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(T n){cout << n << endl;}
template <typename T>
void cosp(T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];
	rep(i, n){
		if(!i){
			if(a[i] != 0){
				co(-1);
				return 0;
			}
		}else{
			if(a[i] > a[i-1]+1){
				co(-1);
				return 0;
			}
		}
	}

	ll ans = 0;
	rep(i, n){
		if(!i) continue;
		if(a[i] == a[i-1]+1) ans++;
		else ans += a[i];
	}
	co(ans);

	return 0;
}


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

using namespace std;
int main(){
	int N;
  	long before_A;
  	cin >> N;
  	vector<long> A(N);
  	for(int i = 0; i < N; i++){
      long tmp;
      cin >> tmp;
      A[i] = tmp;
    }
  	sort(A.begin(), A.end());
  	before_A = A[0];
  	for(int i = 1; i < N; i++){
      	if(A[i] == before_A){
        	cout << "NO" << endl;
          	return 0;
        }
      	else{
        	before_A = A[i];
        }
    }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1792
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Jan  5 17:10:08 2019
//
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	nums := [4]int{int(s[0] - '0'), int(s[1] - '0'), int(s[2] - '0'), int(s[3] - '0')}
	for i := 0; i < (1 << 3); i++ {
		ans := nums[0]
		ops := []string{}
		for j := uint8(0); j < 3; j++ {
			if i&(1<<j) != 0 {
				ans += nums[j+1]
				ops = append(ops, "+")
			} else {
				ans -= nums[j+1]
				ops = append(ops, "-")
			}
		}
		if ans == 7 {
			fmt.Printf("%d%s%d%s%d%s%d=7\n", nums[0], ops[0], nums[1], ops[1], nums[2], ops[2], nums[3])
			return
		}
	}
}


Measured memory_bytes: 512
n,m,x=(int(i) for i in input().split())
a=[]
c=[]
for i in range(n):
  a.append(list(map(int,input().split())))
  c.append(a[i][0])
  del a[i][0]
  
INF=1001001001
ans=INF

for s in range(1<<n):
  cost=0
  d=[0]*m
  for i in range(n):
    if(s>>i&1):
      cost+=c[i]
      for j in range(m):
        d[j]+=a[i][j]
  ok=True
  for j in range(m):
    if(d[j]<x):
      ok=False
  if ok:
    ans=min(ans,cost)
if ans==INF:
  print(-1)
else:
  print(ans)


Measured memory_bytes: 9200
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=40400,P=998244353;
int i,j,k,n,m,ans;
int A[N],B[N],a[N],b[N],Jc[N],Jc_[N],rev[N],W[2][N];
char s1[N],s2[N];
int ksm(int x,int y) {
	int z=1;
	for (;y;y>>=1,x=(ll) x*x%P) if (y&1) z=(ll) z*x%P;
	return z;
}
void pre(int n) {
	int i;
	Jc[0]=Jc_[0]=1;
	for (i=1;i<=n;i++) Jc[i]=(ll) Jc[i-1]*i%P;
	Jc_[n]=ksm(Jc[n],P-2);
	for (i=n-1;i;i--) Jc_[i]=(ll) Jc_[i+1]*(i+1)%P;
}
void Pre(int n,int m) {
	int i,j,k;
	for (i=0;i<n;i++) {
		k=i;
		for (j=0;j<m;j++) (rev[i]<<=1)|=k&1,k>>=1;
	}
	int w=ksm(3,(P-1)/n);
	W[0][0]=W[1][0]=1;
	for (i=1;i<n;i++) W[0][i]=(ll) W[0][i-1]*w%P;
	for (i=1;i<n;i++) W[1][i]=W[0][n-i];
}
void FFT(int *A,int n,int fg) {
	int i,j,k,l,t,u;
	for (i=0;i<n;i++) if (i<rev[i]) swap(A[i],A[rev[i]]);
	for (i=1;i<n;i<<=1)
		for (j=0;j<n;j+=i<<1)
			for (k=0,l=0;k<i;k++,l+=n/(i<<1)) {
				t=(ll) W[fg][l]*A[i+j+k]%P;
				u=A[j+k];
				A[j+k]=(u+t)%P;
				A[i+j+k]=(u+P-t)%P;
			}
	int inv=ksm(n,P-2);
	if (fg) for (i=0;i<n;i++) A[i]=(ll) A[i]*inv%P;
}
void Mul(int *A,int *B,int n) {
	int i;
	for (i=0;i<n;i++) a[i]=A[i],b[i]=B[i];
	FFT(a,n,0);FFT(b,n,0);
	for (i=0;i<n;i++) a[i]=(ll) a[i]*b[i]%P;
	FFT(a,n,1);
	for (i=0;i<=m;i++) A[i]=a[i];
}
int main() {
	scanf("%s",s1);
	scanf("%s",s2);
	int len=strlen(s1);
	for (i=0;i<len;i++) if (s1[i]=='1') {
		if (s2[i]=='1') m++;
		else n++;
	}
	pre(len+1);
	int nn=0;
	while ((1<<nn)<=m) nn++;
	nn++;
	Pre(1<<nn,nn);
	A[0]=1;
	for (i=0;i<=m;i++) B[i]=Jc_[i+1];
	for (k=n;k;k>>=1,Mul(B,B,1<<nn)) if (k&1) Mul(A,B,1<<nn);
	for (i=0;i<=m;i++) ans=(ans+A[i])%P;
	ans=(ll) ans*Jc[n]%P*Jc[m]%P*Jc[n+m]%P;
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
  string s;
  cin >> s;
  
  if (s[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  
  int cnt = 0;
  for (int i = 2; i <= (int)s.length()-2; ++i) {
    if (s[i] == 'C') ++cnt;
  }
  if (cnt != 1) {
    cout << "WA" << endl;
    return 0;
  }
  
  if (s[1] >= 'A' and s[1] <= 'Z') {
    cout << "WA" << endl;
    return 0;
  }
  
  for (int i = 2; i < (int)s.length(); ++i) {
    if (s[i] == 'C') continue;
    if (s[i] >= 'A' and s[i] <= 'Z') {
      cout << "WA" << endl;
      return 0;
    }
  }
  cout << "AC" << endl;
}

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<int,int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> s, t;
  rep(i,n) {
    cin >> a[i];
    if (a[i] < 0) t.push_back(a[i]);
    else s.push_back(a[i]);
  }

  int S = s.size();
  int T = t.size();
  bool ok = false;
  if (S > 0) {
    if (n == k) ok = (T%2==0);
    else ok = true;
  } else {
    ok = (k%2==0);
  }

  mint ans = 1;
  if (!ok) {
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    rep(i,k) ans *= a[i];
  } else {
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (k%2 == 1) {
      ans *= s.back();
      s.pop_back();
    }
    vector<ll> p;
    while (s.size() >= 2) {
      ll x = s.back(); s.pop_back();
      x *= s.back(); s.pop_back();
      p.push_back(x);
    }
    while (t.size() >= 2) {
      ll x = t.back(); t.pop_back();
      x *= t.back(); t.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    rep(i,k/2) ans *= p[i];
  }

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


Measured memory_bytes: 6328
#include<cstdio>
#include<set>
#include<stack>
#include<queue>
int main()
{
long long int a,b,c,d,x,ans;
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
ans=a*c;
x=a*d;
if(ans<x){ans=x;}
x=b*c;
if(ans<x){ans=x;}
x=b*d;
if(ans<x){ans=x;}
printf("%lld",ans);

}

Measured memory_bytes: 1716
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long x,long long y){
if(x==0|| y==0)
  return max(x,y);
  else {
  if(x<y)
    return gcd(x,y%x);
    else if(y<x)
      return gcd(y,x%y);
    else
      return x;
  
  }

}
long long lcm(long long x,long long y){
return (x/gcd(x,y))*y;
}

int main(){
int N;
  cin>>N;
  long long ans=1;
  for(int i=0;i<N;i++){
  long long T;
    cin>>T;
    ans=lcm(ans,T);
  
  } cout<<ans<<endl;
  
  return 0;
}

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

int main(){
  int n,k; cin>>n>>k;
  vector<int> sweet(n);
  for(int i=0;i<k;i++){
    int d; cin>>d;
    vector<int> a(d);
    for(int &j:a)
      cin>>j;
    for(int j:a)
      sweet[j-1]++;
  }
  int ans=0;
  for(int i:sweet){
    if(i==0)
      ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

int main() {
    long long n;

    std::cin >> n;

    std::map<long long, long long> m;
    for (long long i = 0; i < n; i++) {
        long long num;
        std::cin >> num;
        m[num]++;
    }

    //for (auto it = m.begin(); it != m.end(); it++) {
    //    if (it->second % 3 == 0) {
    //        it->second = 1;
    //    } else {
    //        it->second %= 3;
    //    }
    //}

    long long count = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        //std::cout << it->first << " " << it->second << std::endl;
        if (it->second != 1) {
            count += it->second - 1;
        }
    }
    long long ans = m.size();

    if (count % 2 == 1) {
        ans--;
    }
    std::cout << ans<< std::endl;

    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <complex>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

typedef complex<double> P;
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L() {}
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
};

int main(){
  int N;
  while(cin>>N && N){
    double sx, sy, ex, ey;
    cin>>sx>>sy>>ex>>ey;
    double ans = INF;
    L root = L(P(sx,sy), P(ex,ey));
    REP(i, N){
      double mx, my, nx, ny, h;
      cin>>mx>>my>>nx>>ny>>h;
      if(mx <= sx && sx <= nx && my <= sy && sy <= ny) ans = 0;
      L ls[4];
      ls[0] = L(P(mx,my),P(nx,my));
      ls[1] = L(P(mx,my),P(mx,ny));
      ls[2] = L(P(mx,ny),P(nx,ny));
      ls[3] = L(P(nx,my),P(nx,ny));
      REP(j, 4){
        L l = ls[j];
        double dist = distanceSS(root, l);
        if(dist == 0) ans = 0;
        //cout<<l[0]<<" "<<l[1]<<":"<<dist<<endl;
        double radian;
        if(dist - EPS < h) radian = dist;
        else radian = (h*h + dist*dist)/(2*h);
        ans = min(ans, radian);
      }
    }
    printf("%.10lf\n", ans);
  }
  return 0;
}

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

#define REP(i, st, cn) for (int i = (st); i < (int)(cn); ++i)
#define rep(i, cn) REP(i, 0, cn)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N, M;

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

    priority_queue<int> A;
    rep(i, N) {
        int a;
        cin >> a;
        A.push(a);
    }

    rep(i, M) {
        int a = A.top();
        A.pop();
        A.push(a / 2);
    }

    ll sum = 0;
    rep(i, N) {
        sum += A.top();
        A.pop();
    };


    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 892
D = [
    (1, 5, 2, 3, 0, 4), # 'U'
    (3, 1, 0, 5, 4, 2), # 'R'
    (4, 0, 2, 3, 5, 1), # 'D'
    (2, 1, 5, 0, 4, 3), # 'L'
]
C = 'NESW'

*L, = map(int, input().split())
for c in input():
    L[:] = (L[e] for e in D[C.index(c)])
print(L[0])


Measured memory_bytes: 5604
/********include********/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;

/***/
//#include <iomanip>
//#include <cmath>
#include <bits/stdc++.h>

/********define********/

#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define rrep(i,x) for(long long i=x-1;i>=0;i--)
#define rrepn(i,x) for(long long i=x;i>1;i--)
#define REP(i,n,x) for(long long i=n;i<x;i++)
#define REPN(i,n,x) for(long long i=n+1;i<x;i++)

#define pr printf
#define re return
#define mod 1000000007
//#define mod 998244353
#define INF 1e18+5//19桁
const double PI=3.14159265358979323846;
#define fi first
#define se second
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

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


/********よく使う関数********/

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 約数列挙
vector<long long> calc_divisor(long long n) {
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

//最大公約数
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

//最大公約数 複数個
int gcd(const vector<int> &v) {
	int ret = v[0];
	for (int i = 1; i < v.size(); i++)
		ret = gcd(ret, v[i]);
	return ret;
}

//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }

//最小公倍数 複数個
int lcm(const vector<int> &v) {
	int ret = v[0];
	for (int i = 1; i < v.size(); i++)
		ret = lcm(ret, v[i]);
	return ret;
}

/********変数宣言********/
//vector<long long> g[200020];
vector<pair<long long,long long>> g[200020];
ll s[200020];
bool used[200020];
bool dp[100005];
ll answer;

ll A,B,C,D,H,K,M,N,Q,T,W,X,Y;
double dA,dB,dC,dH,dK,dM,dN,dQ,dT,dW,dX,dY;
ll counter;
void solve(ll curre, ll flg){
    if(curre > N)return;
    //if(flg && 0b111)counter++;
    if(flg == 0b111)counter++;
    solve(curre*10+7,flg | 0b001);
    solve(curre*10+5,flg | 0b010);
    solve(curre*10+3,flg | 0b100);

}
int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    counter=0;
    solve(0,0);
    cout << counter;
    re 0;
    
}


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

using namespace std;

int main()
{
	int op = 0;
	
	int n;
	cin >> n;
	
	string a, b, c;
	cin >> a >> b >> c;
	
	for(int i = 0; i < n; i++)
	{
		if(a[i] == b[i] && a[i] == c[i])
			continue;
		
		if(a[i] == b[i] || a[i] == c[i] || b[i] == c[i])
			op++;
		else
			op += 2;
	}
	
	cout << op;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    int d=n*a;
    if(d<b)
        printf("%d\n",d);
        else if(d==b)
            printf("%d\n",d);
    else
        printf("%d\n",b);
    return 0;
}


Measured memory_bytes: 128
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)

typedef long long LL;
const int maxl = 205;
char sa[maxl], sb[maxl];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifndef ONLINE_JUDGE
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	scanf("%s", sa);
	scanf("%s", sb);
	
	int alen = strlen(sa), blen = strlen(sb);
	
	if (alen == blen) {
		int tmp = strcmp(sa, sb);
		
		if (tmp == 0) {
			puts("EQUAL");
		} else if (tmp < 0) {
			puts("LESS");
		} else {
			puts("GREATER");
		}
	} else if (alen > blen) {
		puts("GREATER");
	} else {
		puts("LESS");
	}
	
	// #ifndef ONLINE_JUDGE
		// printf("time = %ldms.\n", clock());
	// #endif
	
	return 0;
}


Measured memory_bytes: 256
yen500 = int(input())
yen100 = int(input())
yen50 = int(input())
to = int(input())

res = 0

for i in range(yen500 + 1):
    if i * 500 > to:
        break
    for j in range(yen100 + 1):
        if 500 * i + 100 * j > to:
            break
        for k in range(yen50 + 1):
            if i*500 + j*100 + k*50 == to:
                res += 1
                break

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int a, b;;
	cin >> a >> b;
	if (a + b == 15)cout << "+";
	else if (a * b == 15) cout << "*";
	else cout << "x";

	return 0;
}



Measured memory_bytes: 256
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map (fun x -> int x)

let r, g, b = readIntArray() |> fun x -> (x.[0], x.[1], x.[2])
if (r * 100 + g * 10 + b) % 4 = 0 then "YES" else "NO"
|> printfn "%s"

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct SegmentTree {
private:
    int n;
    vector<int> node;
 
public:
    SegmentTree() {
        int sz = 210000;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = 0;
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
 
    void add(int x, int val) {
        x += (n - 1);
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }
    // hannkaikukann 
    int getmin(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];
 
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};


int main() {
    //cout.precision(10);
    vector<l_l> balls;
    ll N;
    cin >> N;
    ll max_max = 0;
    ll max_min = INF;
    ll min_max = 0;
    ll min_min = INF;
    for(int i = 1; i <= N; i++) {
        ll x, y;
        cin >> x >> y;
        if(x < y) swap(x, y);
        max_max = max(max_max, x);
        max_min = min(max_min, x);
        min_max = max(min_max, y);
        min_min = min(min_min, y);
        balls.push_back({x, i});
        balls.push_back({y, i});
    }
    SegmentTree seg;
    ll ans = (max_max - max_min) * (min_max - min_min);
    sort(balls.begin(), balls.end());
    ll delta = max_max - min_min;
    ll left = 0;
    ll right = 0;//半開区間
    while(right <= 2 * N) {
        if(seg.getmin(1, N + 1) > 0) {
            ans = min(ans, (balls[right - 1].first - balls[left].first) * delta);
            //cout << left << " " << right << " " << balls[right].first << " " <<  balls[left].first << endl;
            seg.add(balls[left].second, -1);
            left++;
            continue;
        }
        seg.add(balls[right].second, 1);
        right++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10604
import java.util.*;

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

	int z = sc.nextInt();

	while(z!=0){
	    int z3 = z*z*z;
	    int x3 = 0;
	    int y3 = 0;
	    int sum = 0;
	    for(int i=1;i<z; i++){
		x3 = i*i*i;
		if(x3>z3){break;}
		for(int j=1; j<z; j++){
		    y3 =j*j*j;
		    if(x3+y3>z3){j=z-1; continue;}
		    if(sum<x3+y3){sum = x3+y3;}
		}
	    }

	    int ans = z3 - sum;
	    System.out.println(ans);

	    z = sc.nextInt();
	}
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<P,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

int main(){
    string S;
    cin >> S;
    ll ans=0;
    ll count=0;
    for(ll i=0;i<S.size();i++){
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T')count++;
        else count=0;
        chmax(ans,count);
    }print(ans)
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

int main(){
	fast;
	
	string s;
	cin>>s;
	
	int cnta=0,cntb=0;
	forr(i,0,s.size()){
		if(s[i]=='A')
		cnta++;
		
		else
		cntb++;
	}
	
	if(cnta!=0 && cntb!=0)
	cout<<"Yes";
	
	else
	cout<<"No";
	return 0;
}


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

int main()
{
  int a, s, d;
  cin >> a >> s >> d ;
  
 if(a==s&&s==d)
   cout << "1";
   else if(a!=s&&a!=d&&s!=d)
     cout << "3";
     else
       cout << "2";
     cout << endl;     
  

}  


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

vi divisor(int n){  // 約数全列挙{{{
  vi p,q;
  for(int i=1; i*i<=n; i++){
    if (n%i==0){
      p.pb(i);
      if (i*i!=n) q.pb(n/i);
    }
  }
  reverse(all(q));
  p.insert(p.end(), all(q));
  return p;
}//}}}

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

int solve(){
  int n,k;cin>>n>>k;
  vector<int> a(n);
  int s = 0;
  int g = 0;
  rep(i, n) {
    cin>>a[i];
    s+=a[i];
    g = gcd(g, a[i]);
  }
  dump(a);
  dump(g);
  auto div = divisor(s);

  int ans = g;
  each(d, div){
    vi R;
    int t = 0;
    rep(i, n){
      int r = a[i]%d;
      t += r;
      if (r!=0){
        R.pb(r);
      }
    }
    sort(all(R));
    dump(R);

    int v = 0;
    rep(j, sz(R)-t/d){
      v += R[j];
    }
    dump(d, v, t);
    if (v<=k) chmax(ans, d);
  }
  cout << ans << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String str = br.readLine();
			String[] compare_array = str.split(" ");
			if (Integer.parseInt(compare_array[0]) < Integer.parseInt(compare_array[1])) {
				System.out.println("a < b");
			} else if (Integer.parseInt(compare_array[0]) > Integer.parseInt(compare_array[1])) {
				System.out.println("a > b");
			} else if (Integer.parseInt(compare_array[0]) == Integer.parseInt(compare_array[1])) {
				System.out.println("a == b");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}



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

int main(void){
    int L,N,i;
    cin >> N >> L;

    string s[N];

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

    sort(s,s+N);

    for(i=0; i<N; i++){
        cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256