akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)

char IO;
int rd(){
	int s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}

const int N=5e5+10;

int n;
int a[N];
int b[N];
int cnt;
int s[N];
void Add(int p,int x){
	while(p<=cnt) s[p]=max(s[p],x),p+=p&-p;
}
int Que(int p){
	int res=0;
	while(p) res=max(res,s[p]),p-=p&-p;
	return res;
}
int ans;

int main(){
	rep(i,1,n=rd()) a[i]=b[i]=rd();
	sort(b+1,b+n+1);
	cnt=unique(b+1,b+n+1)-b-1;
	drep(i,n,1){
		a[i]=lower_bound(b+1,b+cnt+1,a[i])-b;
		int res=Que(a[i])+1;
		ans=max(ans,res);
		Add(a[i],res);
	}
	printf("%d\n",ans);
}



















Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

vll divisor(ll m){
    vll ret;
    for(ll i = 1; i*i <= m; i++){
        if(m%i==0){
            if(i*i!=m){
                ret.emplace_back(m/i);
            }
            ret.emplace_back(i);
        }
    }
    sort(ALL(ret));
    return ret;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vll div = divisor(m);
    ll ans = 0;
    for(auto&& e: div){
        if(n*e <= m){
            chmax(ans, e);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e6+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int t[MAXN],s[3][MAXN],p[MAXN],d[MAXN],Fpow[20],N,len,n,tot=1,ans[MAXN];char ch[MAXN];
struct Node{int id,x,d;};
inline void Build(){
	queue<Node>q;q.push((Node){1,0,0});
	while(!q.empty()){
		int x=q.front().id;d[x]=q.front().d,p[x]=q.front().x,q.pop();
		if(d[x]<n)Rep(i,0,2)s[i][x]=++tot,q.push((Node){s[i][x],p[x]+Fpow[d[x]]*i,d[x]+1});
	}
}
inline void pushr(int x){swap(s[1][x],s[2][x]),t[x]^=1;}
inline void pushdown(int x){if(t[x])pushr(s[0][x]),pushr(s[1][x]),pushr(s[2][x]),t[x]=0;}
inline void Add(int x){
	pushdown(x);if(d[x]==n)return;
	int s0=s[0][x],s1=s[1][x],s2=s[2][x];
	s[1][x]=s0,s[2][x]=s1,s[0][x]=s2,Add(s[0][x]);
}
void dfs(int x,int val,int d){if(x!=1)ans[p[x]]=val;pushdown(x);if(d==n)return;Rep(i,0,2)dfs(s[i][x],val+Fpow[d]*i,d+1);}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),scanf("%s",ch+1),len=strlen(ch+1);
	Fpow[0]=1;Rep(i,1,n)Fpow[i]=Fpow[i-1]*3;N=Fpow[n];
	Build();
	Rep(i,1,len){
		if(ch[i]=='S')pushr(1);	
		else if(ch[i]=='R')Add(1);
	}dfs(1,0,0);Rep(i,0,N-1)cout<<ans[i]<<' ';cout<<"\n";
	return 0;
}




Measured memory_bytes: 25352
#include <stdio.h>
#define N 100
#define White 0
#define Gray 1
#define Black 2

int n,M[N][N],color[N],time=0;
int enter[N],ex[N];
//
void dfs_visit(int u){
  int v;
  color[u]=Gray; //?¨????
    enter[u]=++time;// ?¨??????????
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;//?????????????????´???
    if(color[v]==White){//????¨??????????
      dfs_visit(v);
    }
  }
  color[u]=Black;
  ex[u]=++time;
}
//
void dfs(){
  int i;
  for(i=0;i<n;i++)color[i]=White;// ?????????
  
  for(i=0;i<n;i++){
    if(color[i]==White)dfs_visit(i);
  }
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,enter[i],ex[i]);
  
  }
}
//
int main(){
  int u,v,k,i,j;

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

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;//0 origin    
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;//0 origin
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}

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

void dfs(int v, const vector<vector<int>>& graph, vector<bool>& reachable) {
  if (reachable[v]) return;
  reachable[v] = true;
  for (const auto& u : graph[v]) {
    dfs(u, graph, reachable);
  }
}

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

  int n, m, p;
  cin >> n >> m >> p;

  vector<tuple<int, int, int>> edges;
  vector<vector<int>> graph(n);
  vector<vector<int>> rev_graph(n);
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    c = -(c - p);
    edges.emplace_back(a, b, c); 
    graph[a].push_back(b);
    rev_graph[b].push_back(a);
  }

  vector<bool> reachable(n, false);
  vector<bool> rev_reachable(n, false);
  dfs(0, graph, reachable);
  dfs(n-1, rev_graph, rev_reachable);
  rep(i, n) { reachable[i] = reachable[i] && rev_reachable[i]; }

  vector<int> d(n, INT_MAX/2);
  d[0] = 0;
  bool updated = true;
  int update_count = 0;
  while (updated) {
    updated = false;
    rep(i, m) {
      int a, b, c;
      tie(a, b, c) = edges[i];
      if (!reachable[a]) continue;
      if (!reachable[b]) continue;
      int newD = d[a] + c;
      if (newD < d[b]) {
        updated = true;
        d[b] = newD;
      }
    }
    update_count++;
    if (update_count > n) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << max(-d[n-1], 0) << endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define fastcin() ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(), (x).end()
#define heap priority_queue
using namespace std;
typedef pair<int, int> ii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 2700, mod = 1e9 + 7; 
int n, k, a[maxn]; 
signed main()
{ 
	cin >> n >> k; 
	for(int i = 1; i <= n; i++) cin >> a[i]; 
	int ans = 0, K = (k * (k + 1) / 2) % mod, KK = (k * (k - 1) / 2) % mod; 
	for(int i = 1; i <= n; i++) {
		int l = 0, r = 0; 
		for(int j = 1; j < i; j++) l += (a[j] > a[i]); 
		for(int j = i + 1; j <= n; j++) r += (a[j] > a[i]); 
		ans = (ans + l * K % mod + r * KK % mod) % mod; 
	}
	cout << ans; 
}


Measured memory_bytes: 256
import heapq
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))
B = list(map(int, sys.stdin.buffer.readline().split()))


# 逆から貪欲に操作可能
def solve():
    heap = [(-b, i) for i, b in enumerate(B)]
    heapq.heapify(heap)
    ret = 0
    while heap:
        b, i = heapq.heappop(heap)
        b *= -1
        a = A[i]
        if b < a:
            return -1
        if b == a:
            continue
        step = B[(i - 1) % N] + B[(i + 1) % N]
        if (b - a) // step == 0:
            return -1
        cnt = (b - a) // step
        ret += cnt
        b -= cnt * step
        B[i] = b
        heapq.heappush(heap, (-b, i))
    return ret


ans = solve()
print(ans)


Measured memory_bytes: 122488
#include<iostream>
using namespace std;
int main() {
	int S;
	cin >> S;
	bool l = 1 <= S / 100 && S / 100 <= 12, r = 1 <= S % 100 && S % 100 <= 12;
	if (l && r) cout << "AMBIGUOUS" << endl;
	else if (l && !r) cout << "MMYY" << endl;
	else if (!l && r) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int n,m;
int main()
{
    cin>>n;
    long long x=n*(n+1)/2;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}

int main() {
  long long int N;
  cin >> N;
  Bint A[N];
  Bint sum=1;
  long long int flag0=0;
  for(long long int i=0;i<N;i++){
    cin >> A[i];
    //cout << A[i]<< " " << flag0 << endl;
    if(A[i]==0){
      flag0=1;
    }
  }
  if(flag0==1){
    cout << "0";
  }
  else{
    for(long long int i=0;i<N;i++){
      sum*=A[i];
      if(sum>1000000000000000000||sum<0){
        sum=-1;
        break;
      }
    }
    cout << sum;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 6816
#include<bits/stdc++.h>
#define ll long long
using namespace std;
pair<int,int> a[100050];
void solve(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i].first);
		a[i].second=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		printf("%d ",a[i].second);
	}
	
}

signed main(){
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const vector<pll> dir={{0,1},{1,0},{-1,0},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm (ll a,ll b) {return a*b/gcd(a,b);}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}

vector<ll> func,inv;
void init(ll n){
    func.resize(n+1);inv.resize(n+1);
    func[0]=1;
    rep(i,0,n) {func[i+1]=func[i]*(i+1)%MOD;}
    inv[n]=intpow(func[n],MOD-2);
    rrep(i,1,n+1) {inv[i-1]=inv[i]*i%MOD;}
}
ll comb(ll a,ll b) {return func[a]*inv[b]%MOD*inv[a-b]%MOD;}

inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
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;}

int main(){
    ll n;
    cin>>n;
    double ans=0;
    rep(i,0,n) {
        double a;
        cin>>a;
        ans+=1/a;
    }
    cout<<1/ans;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// LCM : find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a / GCD(a, b) * b

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

func gcd(a, b int) int {
	if b != 0 {
		return gcd(b, a%b)
	}
	return a
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

func x2(n int) int {
	ret := 0
	for n%2 == 0 {
		ret++
		n /= 2
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	//
	for i := 0; i < N; i++ {
		a[i] /= 2
	}

	t := x2(a[0])
	// out(t)
	a[0] >>= uint(t)
	for i := 1; i < N; i++ {
		if x2(a[i]) != t {
			out(0)
			return
		}
		a[i] >>= uint(t)
	}

	M >>= uint(t)

	l := LCM(1, 1, a...)

	M /= l
	out((M + 1) / 2)
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  LL a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

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

  if (2 * a < b) b = 2 * a;
  if (2 * b < c) c = 2 * b;

  d = min(2 * c, d);
  LL ans = (n / 2) * d + (n % 2) * c;;

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


Measured memory_bytes: 256
/*

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

using namespace std;

#define ll           long long int
#define mp           make_pair
#define pb           push_back
#define fi           first
#define si           second
#define fastIO       ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n)       for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n)      for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n)       for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n)      for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m)    for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m)   for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m)   for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
const int nax = 1e7;
const int mod = 1e9+7;



int main(){
fastIO
	ll n, k; cin>>n>>k;
	ll *h = new ll[n];
	F(h, n);
	ll *dp = new ll[n];
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for(ll i=2; i<n; i++){
		dp[i] = INT_MAX;
		for(int j = 1; j <= k; j++){
			if(i-j >= 0){
				dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
			}
			else{
				break;
			}
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 5156
/*
shiftÊµÖÊÉÏÊÇ°ÑÒ»¸öÔªËØÍùÇ°ÒÆ»òÕßÍùºóÒÆ
¿¼ÂÇÈç¹ûÈ·¶¨Ò»Ð©ÔªËØ²»¶¯µÄ»°£¨ÏÔÈ»ËüÃÇµÄÏÂ±êºÍÖµ¶¼µ¥Ôö£©£¬ÄÇÃ´¶ÔÓÚÏàÁÚÁ½¸öÈ·¶¨²»¶¯µÄÏÂ±êaºÍbÖ®¼äµÄÏÂ±êx(a < x < b)£¬»áÓÐÈçÏÂÊÂ£º
(1)P[x] < P[a]£¬ÄÇÃ´ÐèÒª°ÑP[x]ÍùÇ°ÒÆ
(2)P[b] < P[x]£¬ÄÇÃ´ÐèÒª°ÑP[x]ÍùºóÒÆ
(3)Ê£ÏÂµÄËùÓÐP[a] < P[x] < P[b]µÄÔªËØ£¬¿ÉÒÔÈ«ÓÃmin(A, B)µÄ´ú¼ÛÅÅºÃÐò
Ö±½Ódp¼´¿É 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int Max_N(5050);
typedef long long int LL;

int N, P[Max_N], Pre[Max_N][Max_N], Suf[Max_N][Max_N];
LL F[Max_N][Max_N], A, B;

inline void upd(LL &a, LL b)
{
	a = min(a, b);
}

int main()
{
	scanf("%d%lld%lld", &N, &A, &B);
	for (int i = 1;i <= N;++i)
		scanf("%d", P + i), Pre[i][P[i]] = Suf[i][P[i]] = 1;
	for (int i = 1;i <= N;++i)
	{
		for (int j = 1;j <= N + 1;++j)
			Pre[i][j] += Pre[i][j - 1];
		for (int j = N;j >= 0;--j)
			Suf[i][j] += Suf[i][j + 1];
		for (int j = 1;j <= N;++j)
			Pre[i][j] += Pre[i - 1][j], Suf[i][j] += Suf[i - 1][j];
	}
	memset(F, 0X3F, sizeof(F)), F[0][0] = 0LL;
	P[0] = 0, P[N + 1] = N + 1;
	for (int i = 1;i <= N + 1;++i)
		for (int j = 0, t;j <= i - 1;++j)
		{
			upd(F[i][j], F[i - 1][j]);
			if (P[j] < P[i])
			{
				t = (i - 1) - j;
				t -= (Pre[i - 1][P[j]] - Pre[j][P[j]]) + (Suf[i - 1][P[i]] - Suf[j][P[i]]);
				upd(F[i][i], F[i - 1][j] + (Pre[i - 1][P[j]] - Pre[j][P[j]]) * B + (Suf[i - 1][P[i]] - Suf[j][P[i]]) * A + t * min(A, B));
			}
		}
	printf("%lld", F[N + 1][N + 1]);
	return 0;
}

Measured memory_bytes: 397696
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}

map< int64_t, ll > prime_factor(int64_t n) {
  map< int64_t, ll > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
const ll mod = 1000000007;
const ll INF = 1e9;

// 変数定義start(vectorはresizeしようね)
ll N;
vl D;
vl deep;
// 変数定義end

void solve(){
	cin >> N;
	D.resize(N);
	REP(i, N){
		cin >> D[i];
	}
	deep.resize(N);
	REP(i, N){
		deep[i] = 0;
	}
	ll ans = 1;
	ll max_num = 0;
	REP(i, N){
		deep[D[i]]++;
	}
	REP(i, N){
		if(D[i] > max_num){
			max_num = D[i];
		}
	}
	for(ll i = 1; i < max_num+1; i++){
		if(D[0] == 0 && deep[0] == 1){
			ans *= modpow(deep[i-1], deep[i], 998244353);
			ans %= 998244353;
		} else {
			ans = 0;
		}
		if(deep[i] == 0){
			ans = 0;
		}
	}
	cout << ans << endl;
}

int main(){

    //clock_t start = clock();

    cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	//clock_t end = clock();

    //const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    //printf("time %lf[ms]\n", time);
}


Measured memory_bytes: 1792
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A
 */
#include <iostream>
#include <vector>

using namespace std;

bool
chkcombi(const vector<int> &a, const int index, const int sum, const int val)
{
    bool ret = false;
    for (int i = index; ret == false && i < a.size(); i++) {
        int s = sum + a.at(i);
        if (s == val) {
            ret = true;
            break;
        } else if (s > val) {
            continue;
        }
        ret = chkcombi(a, i + 1, s, val);
    }
    return ret;
}

int
main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n; cin.ignore();

    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i]; cin.ignore();
    }

    int q;
    cin >> q; cin.ignore();
    for (int i = 0; i < q; i++) {
        int m;
        cin >> m; cin.ignore();
        cout << (chkcombi(A, 0, 0, m) ? "yes" : "no") << endl;
    }

    return 0;
}

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

using LL = long long;
const int maxn = 11111;
int w;
char s[maxn];

signed main() {
  // freopen("in", "r", stdin);
  while(cin >> s >> w) {
    for(int i = 0; s[i]; i++) {
      if(i % w == 0) putchar(s[i]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
float PHI = 1.6180339;
//const float  PI_F=3.14159265358979f;
#define MAX 100000 
#define endl "\n"    
//typedef long long float;
#define int long long
//#define float unsigned long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);

    string s,t;
    cin>>s>>t;
    string f=t+s;
    cout<<f<<endl;

}

    
    

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

int x, y, z;
double dp[51][5100];
int rulet[5];
std::pair<int, int>event[51];

int main(){

	while (std::cin >> x >> y >> z){

		if (x == 0 && y == 0 && z == 0)break;
		
		memset(dp, 0, sizeof(dp));
		memset(event, 0, sizeof(event));

		for (int i = 0; i < x; i++){
			std::cin >> rulet[i];
		}
		for (int i = 0; i < z; i++){
			int n, e, a;
			std::cin >> n >> e >> a;
			event[n] = std::make_pair(e, a);
		}

		dp[0][0] = 1.0;

		for (int i = 0; i < y; i++){
			for (int j = 0; j <= 5000; j++){
				if (dp[i][j] != 0){
					for (int k = 0; k < x; k++){
						int coin = j;
						int to = std::min(y, i + rulet[k]);
						int c = event[to].first;

						if (c == 1)to = std::min(y, to + event[to].second);
						else if (c == 2)coin += event[to].second;
						else if (c == 3)coin = std::max(0, coin - event[to].second);

						dp[to][coin] += dp[i][j] / x;
					}
				}
			}
		}

		double res = 0;
		for (int i = 0; i <= 5000; i++){
			res += i*dp[y][i];
		}
		std::cout << (int)res << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#define inf 1<<29
using namespace std;
char ch;
int a[4];
bool op[4],g;
int main(){
	ios::sync_with_stdio(false);
	for(int i=1;i<=4;i++){
		cin>>ch;
		a[i]=ch-'0';
	}
	for(int i=0;i<=1;i++){
		for(int j=0;j<=1;j++){
			for(int k=0;k<=1;k++){
				int su=a[1];
				if(i) su+=a[2];else su-=a[2];
				if(j) su+=a[3];else su-=a[3];
				if(k) su+=a[4];else su-=a[4];
				if(su==7){
					cout<<a[1];
					if(i) cout<<"+";else cout<<"-";
					cout<<a[2];
					if(j) cout<<"+";else cout<<"-";
					cout<<a[3];
					if(k) cout<<"+";else cout<<"-";
					cout<<a[4]<<"=7"<<endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

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

const int MOD = 1000000007;
string S;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

long long dp[210000][5];

int main() {
  while (cin >> S) {
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < S.size(); ++i) {
	  for (int j = 0; j < 5; ++j) {
		if (S[i] != '?') add(dp[i+1][j], dp[i][j]);
		else add(dp[i+1][j], dp[i][j] * 3 % MOD);
	  }
	  if (S[i] == 'A' || S[i] == '?') add(dp[i+1][1], dp[i][0]);
	  if (S[i] == 'B' || S[i] == '?') add(dp[i+1][2], dp[i][1]);
	  if (S[i] == 'C' || S[i] == '?') add(dp[i+1][3], dp[i][2]);  
	}
	cout << dp[S.size()][3] << endl;
  }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> edges(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    edges.at(a).push_back(b);
    edges.at(b).push_back(a);
  }

  queue<int> q;
  vector<int> d(n, -1);
  vector<int> sign(n, -1);
  q.push(0);
  d.at(0) = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int x : edges.at(v)) {
      if (d.at(x) != -1) continue;
      q.push(x);
      d.at(x) = d.at(v) + 1;
      sign.at(x) = v;
    }
  }

  cout << "Yes" << endl;
  for (int i = 1; i < n; i++) {
    cout << sign.at(i) + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 10604
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S, w):
    
    return S[::w]


def main():
    S = read_str()
    w = read_int()

    
    print(slv(S, w))


if __name__ == '__main__':
    main()


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[2][102];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
  cin>>s;
  ll n=s.size();
  ll ans=0;
  REP(i,n){
    if(s[i]=='1')
      ans++;
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const ll mod = 1e9 + 7;				//adjust mod value according to your need
int main()
{
	SPEED
	int n;
	cin >> n;
	int data[n][3];
	for (int i = 0; i < n; ++i)
	{
		cin >> data[i][0] >> data[i][1] >> data[i][2];
	}
	int dp[n][3];
	for (int i = 1; i < n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			dp[i][j] = 0;
		}
	}
	dp[0][0] = data[0][0];
	dp[0][1] = data[0][1];
	dp[0][2] = data[0][2];

	for (int i = 1; i < n; ++i)					//for current row
	{
		for (int j = 0; j < 3; ++j)				//for current processing col
		{
			for (int k = 0; k < 3; ++k)			//the preceding col
			{
				if (j!=k)
				{
					dp[i][j] = max(dp[i][j], dp[i-1][k]+data[i][j]);
				}
			}
		}
	}
	/*
	cout << '\n';
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cout << dp[i][j] << " ";
		}
		cout << '\n';
	}*/

	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  vl H(N);
  REP(i, N) cin >> H[i];
  sort(ALL(H), REV(ll));
  ll ans = 0;
  REP(i, N) {
    if (i < K)
      continue;
    ans += H[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  vl n(4);
  rep(i, 4) cin >> n[i];
  sort(all(n));
  cout << (n[0]==1 && n[1]==4 && n[2]==7 && n[3]==9 ? "YES" : "NO") << newl;
  return 0;
}

Measured memory_bytes: 256
n,l = map(int, input().split())


total = []
for i in range(1,n+1):
  total.append(l+i-1)
total2 = sum(total)

if l >= 0:
  print(total2-l)
elif abs(l) < n:
  print(total2)
elif abs(l) >= n:
  print(total2 - (l+n-1))


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

long long mod = 1000000000 + 7;

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	rep(i, N)cin >> A[i];
	
	long long ans = 0;
	long long twoPow = 1;
	rep(i, 60) {
		long long count0 = 0;
		long long count1 = 0;
		rep(j, N) {
			if (A[j] & (1LL << i))count1++;
			else count0++;
		}
		ans += (count0 * count1) % mod * twoPow % mod;
		ans %= mod;
		twoPow = (twoPow * 2) % mod;
	}
	cout << ans;
}

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




int a[3],k,n,answer;
int main(){
	for(int i=0;i<3;i++){
		cin>>a[i];
	}
	cin>>n;

	sort(a,a+3);
	int k=n/a[0];
	int o=n/a[1];
	for(int i=0;i<=k;i++){
		for(int l=0;l<=o;l++){
			if((n-(a[0]*i)-(a[1]*l))%a[2]==0&&n-(a[0]*i)-(a[1]*l)>=0){
				answer++;
			}
		}
	}
	cout<<answer<<endl;
}



Measured memory_bytes: 256
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

vector < ll > g[200005];
bool vis[200005];
ll cnt;

void dfs(ll node)
{
	cnt++;
	vis[node] = 1;

	for(auto it: g[node])
	{
		if(vis[it] == 0) dfs(it);
	}
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n >> m)
    {
		for(ll i = 1; i <= n; i++) g[i].clear();

		for(ll i = 1; i <= m; i++)
		{
			ll u, v;

			cin >> u >> v;

			g[u].pb(v);
			g[v].pb(u);
		}

		memset(vis,0,sizeof vis);

		ans = 1;

		for(ll i = 1; i <= n; i++)
		{
			if(vis[i] == 0)
			{
				cnt = 0;
				dfs(i);

				ans = max(ans, cnt);
			}
		}

		cout << ans << "\n";

    }


}






Measured memory_bytes: 21000
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	int t,n=0;
	string s;
	cin>>t>>s;
	t=0;
	for(int i=0;i<s.size();++i){
		if(s[i]=='I')++t;
		else --t;
		if(n<t)n=t;
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ios                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define fill(x, v) memset(x, v, sizeof(x))
const ll mod = 1000000007;
#define trace1(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
//--------dsu----------
vector<int> volume(1000000);
vector<int> parent(1000000);

void initialise_dsu()
{
    for (int i = 0; i < volume.size(); i++)
        volume[i] = 1;
    for (int i = 0; i < parent.size(); i++)
        parent[i] = i;
}

int find_par(int v)
{
    return (v == parent[v] ? v : parent[v] = find_par(parent[v]));
}

void union_sets(int a, int b)
{
    a = find_par(a);
    b = find_par(b);
    if (a != b)
    {
        if (volume[a] < volume[b])
            swap(a, b);
        parent[b] = a;
        volume[a] += volume[b];
    }
}

int power(int x, unsigned int y, int p)
{
    int res = 1;

    x = x % p;

    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
//-------------------------
string arr;
map<pair<char, char>, char> mpsym;

int main()
{
    ios;

    ll n, m, sum = 0;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        ll x;
        cin >> x;
        sum += x;
    }
    if (sum > n)
        cout << -1 << endl;
    else
        cout << n - sum << endl;
}

Measured memory_bytes: 11036
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b==15)
		cout<<'+';
	else if(a*b==15)
			cout<<'*';
		else
			cout<<'x';	
	cout<<endl;
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
ll a[N];
int main() {
	int k,n;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		a[i]++,a[i]+=a[i-1];
	}
	ll ans=0;
	for(int i=k;i<=n;i++) {
		ans=max(ans,a[i]-a[i-k]);
	}
	printf("%.12f\n",ans/2.0);
	return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]

INF=float("inf")

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

from itertools import permutations
import math

sum=0
for p in permutations(range(n)):
    for i in range(n-1):
        sum+=(pow((s[p[i]][0]-s[p[i+1]][0]),2)+pow((s[p[i]][1]-s[p[i+1]][1]),2))**0.5
print(sum/math.factorial(n))



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

int main() {
  int n; cin >> n;
  int val[n], cos[n];
  rep(i,n) cin >> val[i];
  rep(i,n) cin >> cos[i];
  
  int ans = 0;
  rep(i,n){
    if(val[i]-cos[i] > 0) ans += val[i]-cos[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;

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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint per(int n, int k) {
        return fact[n]*ifact[n-k];
    }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll s;
    cin >> s;
    
    mint ans = 0;
    combination comb(10000);
    for (int n=1; n*3<=s; n++) {
        ll rem = s - 3*n;
        mint res = 0;
        if (rem>=0) {
            res += comb(rem+n-1, n-1);
        }
        ans += res;
    }
    
    pr(ans);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 2);
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int sum = 0;
    for(int i = 0; i + 1 < n + 2; ++i) {
        sum += abs(a[i] - a[i + 1]);
    }
    for(int i = 1; i <= n; ++i) {
        int t = sum - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]);
        t += abs(a[i - 1] - a[i + 1]);
        cout << t << endl;
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

long long  K,A,B;
long long biscuit = 1;//,yen = 0;

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

	cin >> K >> A >> B;
	
	if( A + 2 < B){
		
		if(K >= A + 1){
			K -= A + 1;
			biscuit += B - 1;


		while(K >= 2){
			K -= 2;	
			biscuit += B - A;	
		}
		}

	}

	cout << biscuit + K << endl;
	

}


Measured memory_bytes: 256
// finish date: 2019/06/29

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 998244353;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    vvi ab(N,vi(2));
    rep(i, N) {
        cin >> ab[i][0] >> ab[i][1];
//        ab[i][1]--;
    }
    sort(ab.begin(), ab.end(),
         [](vi a, vi b) {
             return (a[1] < b[1]);
         });

    ll cum = 0;
    rep(i, N) {
        cum += ab[i][0];
        if (cum > ab[i][1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 11136
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n = int(input())
    x = list(map(int,input().split()))
    p = 0
    ans = []
    for i in range(1,101):
        for j in range(n):
            p += (i - x[j]) ** 2
        ans.append(p)
        p = 0
    print(min(ans))

#endline===============================================
if __name__ == "__main__":
    main()

Measured memory_bytes: 65388
#include<cstdio>

char boul='A';

int main()
{
	char a,b;
	while(scanf("%c,%c",&a,&b)!=EOF)
	{
		if(a==boul)boul=b;
		else if(b==boul)boul=a;
		getchar();
	}

	printf("%c\n",boul);
	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys


input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


S = ST()

if S[-1] == "s":
    print(S + "es")
else:
    print(S + "s")


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

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

		for (i=0; i<n; i++) {
				for (j=0; j<m; j++) {
						c[i]+=a[i][j]*b[j];
						//cout << "i:" << i << ", j:" << j << ", c[" << i << "](=" << a[i][j] << "*" << b[m] << "):" << c[i] << "\n";
				}
		}

		for (i=0; i<n; i++) cout << c[i] << "\n";
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main() {
    int a , b , c ;
    cin >> a >> b ;
    c = a * b ;
    if (c%2 == 0) {
            cout << "Even" ;
    }
    else {
            cout << "Odd" ;
    }
    return 0 ;
}


Measured memory_bytes: 3488
import itertools
n,m,x=map(int,input().split())
lis=tuple(tuple(map(int,input().split())) for _ in range(n)) #再代入しないので二次元tupleでよい
ans=float("inf")

for choice in itertools.product(range(2),repeat=n):#0,1のbit全探索
    cost=0
    skills=[0]*m
    for flag,book in zip(choice,lis):
        if flag:
            C,A = book[0],book[1:]
            cost += book[0]
            for i,a in enumerate(A):
                skills[i]+=a
    if all(v>=x for v in skills):
        ans=min(ans,cost)
if ans==float("inf"):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9232