akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

char buf[100];
bool calc(int n) {
  REP(i, n) {
    if(buf[i] != buf[n-1-i]) {
      return false;
    }
  }
  REP(i, n/2) {
    if(buf[i] != buf[n/2-1-i]) {
      return false;
    }
  }
  return true;
}

int main(void) {
  cin >> buf;
  int n = strlen(buf);
  bool ok = calc(n);
  puts(ok ? "Yes" : "No");
}


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

const int N = 1505;
const int INF = 1e9;
typedef pair<int,int> ii;

int n, m;
vector <ii> g[N];
vector <int> rev[N];
int d[N][N];
int deg[N];
bool ok[N];
int mx;

void dijkstra(int s) {
    for (int i = 1; i <= n; ++i) d[s][i] = INF;
    d[s][s] = 0;
    priority_queue < ii, vector<ii>, greater<ii> > pq;
    pq.push(ii(0, s));

    while(!pq.empty()) {
        ii top = pq.top(); pq.pop();
        int u = top.second, du = top.first;
        if (du != d[s][u]) continue;

        for (auto &e : g[u]) {
            int v = e.second, w = e.first;
            if (d[s][v] > d[s][u] + w) {
                pq.push(ii(d[s][v] = d[s][u] + w, v));
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    while(m--) {
        int u, v, w; cin >> u >> v >> w;
        g[u].push_back(make_pair(w, v));
        g[v].push_back(make_pair(w, u));
    }
    for (int i = 1; i <= n; ++i) {
        dijkstra(i);
        for (int j = 1; j <= n; ++j) {
            mx = max(mx, d[i][j]);
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) deg[j] = 0, rev[j].clear();
        for (int j = 1; j <= n; ++j) {
            for (auto &e : g[j]) if (d[i][j] + e.first == d[i][e.second]) {
                rev[e.second].push_back(j);
            }
        }
        // solve
        queue<int> q;
        for (int j = 1; j <= n; ++j) if (d[i][j] == mx) deg[j] = 1, q.push(j);
        while(!q.empty()) {
            int u = q.front(); q.pop();
            ok[u] = true;
            for (int &v : rev[u]) {
                if (!deg[v]) deg[v] = 1, q.push(v);
            }
        }
    }

    int res = 0;
    for (int i = 1; i <= n; ++i) if (!ok[i]) ++res;
    printf("%d\n", res);
    for (int i = 1; i <= n; ++i) if (!ok[i]) printf("%d\n", i);
}


Measured memory_bytes: 12356
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <queue>
#include <map>

#define fir first
#define sec second
#define sz(s) (s).size();
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i,j,k) for(int (i)=(j);(i)<=(k);(i)++)
#define repdown(i, j, k) for(int (i)=(j);(i)>=(k);(i)--)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using ll = long long;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;

const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const int INF = 10241024;
const ll LINF = 1001002003004005006ll;

//_____________________________________Templates_________________________________________//

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

//mainly use for dynamic prog
template<class T1, class T2>
void update(T1 &a, T2 b){
  a += b;
  if(a > Mod) a %= Mod;
}

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

//_____________________array calc____________________________________//
/*
vvi mul(vvi &A, vvi &B){
  vvi C(A.size(), vi(B.size()))
  rep(i,A.size()){
    rep(j,B.size()){
      rep(k,B[0].size()){
        C[i][j] = (C[i][j] A[i][k] + B[k][j]) % Mod;
      }
    }
  }

  return C;
}

vvi pow(vvi A, ll n){
  vvi B(A.size(), vi(A.size()));
  rep(i=0;i<A.size();i++){
    B[i][i] = 1;
  }

  while (n >0){
    if (n & 1) B = mul(B, A);
    A = mul(A, A);
    n = n >> 1;
  }
  return B;
}
*/
//_____________________Bynary Indexed Tree __________________________//
/*
const max_st = (1 << 15) - 1;
int bit[max_st];
int sum (int i){
  int s = 0;
  while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x){
  while(i <= n){
    bit[i] += x;
    i += i & -i;
  }
}
*/
//_____________________　following sorce code_________________________//
const int MX = (1e5)+5;
vll dp(MX+1,LINF);
int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,w;IN(n,w);
  dp[0] = 0;
  rep(i,0,n-1){
    int a,b;IN(a,b);
    repdown(j,MX,b){
      chmin(dp[j],dp[j-b]+a);
    }
  }
  ll ans = 0;
  rep(i,0,MX){
    if(dp[i]<=w)
    {
      chmax(ans, i);
    }
  }
  OUT(ans);
  return 0;
}

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

int main() {
	long long n, minStep = 1E15;
	cin >> n;
	
	for (long long i = 1; i*i <= n; ++i) {
		minStep = (n % i == 0) ? i + n / i - 2 : minStep;
	}
	
	minStep = (minStep == 1E15) ? n - 1 : minStep;
	
	cout << minStep << "\n";
	return 0;
}

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

using vi=vector<int>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int n,m,q;
    cin>>n>>m>>q;
    vvi s(n,vi(m));
    for(int i=0;i<n;i++){
        string buf; cin>>buf;
        for(int j=0;j<m;j++){
            s[i][j]=buf[j]-'0';
        }
    }

    vvi eh(n,vi(m-1));
    vvi ev(n-1,vi(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(!s[i][j]) continue;
            if(i+1!=n){
                if(s[i+1][j]) ev[i][j]=true;
            }
            if(j+1!=m){
                if(s[i][j+1]) eh[i][j]=true;
            }
        }
    }
    auto d2sum=[&](const vvi& t1,vvi& t2){
        for(int i=1;i<=t1.size();i++){
            for(int j=1;j<=t1[i-1].size();j++){
                t2[i][j]=t2[i-1][j]+t2[i][j-1]-t2[i-1][j-1]+t1[i-1][j-1];
            }
        }
    };
    vvi ehsum(n+1,vi(m));
    d2sum(eh,ehsum);
    vvi evsum(n,vi(m+1));
    d2sum(ev,evsum);
    vvi ssum(n+1,vi(m+1));
    d2sum(s,ssum);
    auto rect=[&](int x1,int y1,int x2,int y2,const vvi& table){
        return table[x2][y2]-table[x1][y2]-table[x2][y1]+table[x1][y1];
    };
    
    while(q--){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        x1--,y1--;
        int sv=rect(x1,y1,x2,y2,ssum);
        int ehv=rect(x1,y1,x2,y2-1,ehsum);
        int evv=rect(x1,y1,x2-1,y2,evsum);
        cout<<sv-ehv-evv<<endl;
    }
    return 0;
}

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

void Main() {
    // input
    string S, T;
    cin >> S;
    cin >> T;


    // translate


    // output
    if (!(S.length() >= 1 && S.length() <= 10)) {
        cout << "No" << endl;
        return;
    }

    if (T.substr(0, S.length()) != S) {
        cout << "No" << endl;
        return ;
    }

    cout << "Yes" << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int ll

const int M = 998244353;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
const int oo = 1e9 + 100;
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


#define N 300001

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

	int n, m;
	cin >> n >> m;
	vvi a(n, vi(m));

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

	vector <bool> used(m, false);
	int mx = n;
	for (int i = 0; i < m; i++)
	{
		vi par(n, -1);
		vector <pair <int, int> > g(m);

		for (int i = 0; i < m; i++)
			g[i].second = i;

		for (int j = 0; j < n; j++)
		{
			for (int h = 0; h < m; h++)
			{
				if (!used[a[j][h]])
				{
					g[a[j][h]].first++;
					break;
				}
			}
		}

		sort(ALL(g));

		mmin(mx, g[m - 1].first);
		used[g[m - 1].second] = true;

	}

	cout << mx;



}


Measured memory_bytes: 1024
/*
Author: Xjrjyy
LANG: C++
PROG: agc010_a.cpp
Mail: admin@xjrjyy.com
Blog: https://blog.xjrjyy.cn/
*/

#include <cstdio>
#include <cctype>
#include <vector>
#include <iostream>

#define MAXN ()

int n, a, sum;

int main()
{
    scanf("%d", &n);
    while (n--)
    {
        scanf("%d", &a);
        sum = sum ^ (a & 1);
    }
    printf("%s", sum ? "NO" : "YES");
    return 0;
}


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

Measured memory_bytes: 580
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		if (Integer.parseInt(s.substring(0, 1)) == 1) count++;
		if (Integer.parseInt(s.substring(1, 2)) == 1) count++;
		if (Integer.parseInt(s.substring(2, 3)) == 1) count++;
		System.out.println(count);
		sc.close();
	}
}


Measured memory_bytes: 21844
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y
def primes(n):
    P = [2]
    for L in range(3, n):
        isP = True
        for L2 in P:
            isP = isP and L%L2
            if not isP: break
        if isP: P.append(L)
    return P

N,K=LI()
num_red = N-K
FACT=FLIST(4000)

for i in range(1, K+1):
    num_barr = i-1
    if num_barr > num_red or i > K:
        print(0)
    else:
        pat_blue = (((FACT[K+num_barr-i] * INV(FACT[num_barr])) % DVSR) * INV(FACT[K-i])) % DVSR
        pat_red = ((FACT[num_red+1] * INV(FACT[num_barr+1]) % DVSR) * INV(FACT[num_red - num_barr])) % DVSR
        # print("pat_blue {}, pat_red {}".format(pat_blue, pat_red))
        print(pat_red*pat_blue%DVSR)


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

int n, m;
const int N = 500;
int a[N][N];
int pt[N];
int cnt[N];
bool bad[N];

bool check(int mx) {
	for (int i = 0; i < n; i++) {
		pt[i] = 0;
	}
	
	for (int i = 0; i < m; i++) {
		cnt[i] = 0;
		bad[i] = 0;
	}
	
	for (int i = 0; i < n; i++) {
		cnt[a[i][pt[i]]]++;
	}
	
	for ( ; ; ) {
		int ind = -1;
		for (int j = 0; j < m; j++) {
			if (cnt[j] > mx) {
				ind = j;
				break;
			}
		}
		if (ind == -1) return true;
		cnt[ind] = 0;
		bad[ind] = 1;
	    
		for (int i = 0; i < n; i++) {
		    if (!bad[a[i][pt[i]]]) continue;
			while (pt[i] < m && bad[a[i][pt[i]]]) pt[i]++;
			if (pt[i] == m) {
				return false;
			} else {
				cnt[a[i][pt[i]]]++;
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			a[i][j]--;
		}
	}
	
	int l = 0;
	int r = n;
	while (r - l > 1) {
		int m = (r + l) >> 1;
		if (check(m)) {
			r = m;
		} else {
			l = m;
		}
	}
	cout << r;
	
	return 0;
	
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include<cmath>
using namespace std;
const long INF = 1e9;
vector<long> hoge(long n,long a){
    vector<long> ans(2);
    ans[1] = 0;
    int x = 9;
    while(a>0){
        if (n-x*(a%9) <0) break;
        ans[1]+=a%9;
        n-=x*(a%9);
        x*=9;
        a/=9;
    }
    ans[0] = n;
    return ans;
}
int main(){
    long n,b;
    cin >> n;
    vector<long> vec;
    long ans = INF;
    for(long i = 0;i<pow(9,5);i++){
        b = i;
        vec = hoge(n,b);
        b = 46656;
        while(vec[0]>=6){
            if(vec[0]>=b){
                vec[1]+=vec[0]/b;
                vec[0]%=b;
            }
            b/=6;
        }
        ans = min(ans,vec[0]+vec[1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
l = 0
r = n + 1
for i in range(m):
  l2 , r2 = map(int, input().split())
  if l < l2:
    l = l2
  if r2 < r:
    r = r2
if r < l:
  print(0)
else:
  print(r-l+1)

Measured memory_bytes: 3060
using System;
class Program
{
	static void Main(string[] args)
	{
      string[] input = Console.ReadLine().Split(' ');
      int H= int.Parse(input[0]);
      int A=int.Parse(input[1]);
      int B=0;
      int sum=0;
      sum=H/A;
      B=H%A;
      if(B!=0){
        sum++;
      }
      Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>;
using namespace std;
char s[100010];
int main(){
    scanf("%s",&s);
    int k=strlen(s);
    if(k%2!=0){//如果项数是奇数，则一定不是镜像字符串 
        printf("No");
        return 0;
    }
    for(int i=0;i<k/2;i++){
    	int u=abs(s[i]-s[k-i-1]);
        if(u!=1&&u!=2){//两项的差要么为1，要么为2 
        	printf("No");//两项之差不为1，不为2，说明不是镜像字符串 
            return 0;
        }
    }
    printf("Yes");//到这里程序还没结束，则是镜像字符串 
    return 0;
}

Measured memory_bytes: 384
N=int(input())

a=[]
ans=0
for i in range(N):
  s=input()
  
  if i>=1:
    if s[0]!=a[-1][-1]:
      ans=1
      break
   
  if a.count(s)>0:
    ans = 1
    break
  
  a.append(s)

print("No" if ans==1 else "Yes")

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

ll check(ll n, ll k) {
	if(n%k == 0) {
		return check(n/k, k);
	} else {
		return n%k;
	}
}

void solve()
{
    ll n;
    cin >> n;
    if(n == 2) {
    	cout << "1\n";
    	return;
    }
    ll calc = 2;
    for(ll i=2;i*i<=n-1;i++) {
    	if((n-1)%i == 0) {
    		calc += 2;
    		if(i*i == n-1) {
    			calc--;
    		}
    	}
    }
    for(ll i=2;i*i <= n;i++) {
    	if(n%i == 0) {
    		// cout << i << " " << n/i << " " << check(i, n/i) << " " << check(n/i, i) << "\n";
    		if(check(n/i, i) == 1) {
    			calc++;
    		}
    		if(i*i == n) {
    			continue;
    		}
    		if(check(i, n/i) == 1) {
    			calc++;
    		}
    	}
    }
    cout << calc << "\n";
}

int main()
{
    FAST_IO;
    // #ifndef ONLINE_JUDGE 
      // OC;
    // #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
inline int read(){
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    write(a); puts("");
}
string s;
int main(){
    cin>>s;
    if(s.length()<4||s[0]!='Y'||s[1]!='A'||s[2]!='K'||s[3]!='I'){
    	puts("No");
	}else puts("Yes");
}

Measured memory_bytes: 256
def opp(i):  #対戦希望相手
    return a[i][nex[i]]

from sys import stdin
#入力
readline=stdin.readline
n=int(readline())
m=n*(n-1)//2
a=[list(map(lambda x:int(x)-1,readline().split())) for _ in range(n)]

nex=[0]*n
before=set(range(n))
day=0
for day in range(1,m+1):
    now=set()
    while len(before)>0:
        p=before.pop()
        q=opp(p)
        if opp(q)==p and p not in now and q not in now:
            nex[p]+=1
            nex[q]+=1
            if nex[p]<n-1:
                now.add(p)
            if nex[q]<n-1:
                now.add(q)
            if q in before:
                before.remove(q)
    before=now
    if len(before)==0:
        break

if min(nex)==n-1:
    print(day)
else:
    print(-1)

Measured memory_bytes: 35060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


class SegmentTree {
private:
	using Monoid = int;
	const Monoid INI = 0;
	Monoid op(Monoid a, Monoid b) {
		return a | b;
	}

	int num;
	vector<Monoid> dat;

public:
	SegmentTree(int n_) {
		num = 1;
		while (num < n_) num *= 2;
		dat = vector<Monoid>(2 * num, INI);
	}

	SegmentTree(const vector<Monoid> &m) : SegmentTree(m.size()) {
		int n = m.size();
		for (int i = 0; i < n; i++) {
			dat[num - 1 + i] = m[i];
		}
		for (int i = num - 2; i >= 0; i--) {
			dat[i] = op(dat[2 * i + 1], dat[2 * i + 2]);
		}
	}

	// Update the k-th value (0-indexed) to a.
	void update(int k, Monoid a) {
		k += num - 1;
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = op(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}

	// Get the value of the range [a, b).
	// k: The index of the node.
	// [left, right): The range corresponds to the k-th node.
	// Call like getval(a, b).
	Monoid getval(int a, int b, int k = 0, int left = 0, int right = -1) {
		if (right < 0) right = num;
		if (right <= a || b <= left) return INI;
		if (a <= left && right <= b) return dat[k];
		Monoid vleft = getval(a, b, 2 * k + 1, left, left + (right - left) / 2);
		Monoid vright = getval(a, b, 2 * k + 2, left + (right - left) / 2, right);
		return op(vleft, vright);
	}
};

int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		v[i] = 1 << (s[i] - 'a');
	}
	SegmentTree seg(v);
	int q; cin >> q;
	while (q--) {
		int tp; cin >> tp;
		if (tp == 1) {
			int pos; char c; cin >> pos >> c;
			pos--;
			seg.update(pos, 1 << (c - 'a'));
		}
		else {
			int l, r; cin >> l >> r;
			l--;
			int st = seg.getval(l, r);
			int cnt = 0;
			for (int i = 0; i <= 'z' - 'a'; i++) {
				cnt += (st >> i) & 1;
			}
			cout << cnt << endl;
		}

	}
	return 0;
}


Measured memory_bytes: 6916
#include <iostream>

using namespace std;

int main()
{
	int m1, m2, d1, d2;
	cin >> m1 >> d1 >> m2 >> d2;

	if (m1 == m2) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,P1,P2;
vector<pair<int,bool> >G[600];
vector<int>cnt[2];
bool vis[600];
void dfs(int u,int id)
{
	vis[u]=true;
	cnt[id].push_back(u);
	for(pair<int,bool>e:G[u])
	{
		int v=e.first;
		if(vis[v])continue;
		dfs(v,e.second?id:1-id);
	}
}
main()
{
	while(cin>>N>>P1>>P2,N+P1+P2)
	{
		for(int i=0;i<P1+P2;i++)
		{
			G[i].clear();
			vis[i]=false;
		}
		for(int i=0;i<N;i++)
		{
			int a,b;string s;cin>>a>>b>>s;
			a--,b--;
			G[a].push_back(make_pair(b,s=="yes"));
			G[b].push_back(make_pair(a,s=="yes"));
		}
		vector<pair<vector<int>,vector<int> > >A;
		for(int i=0;i<P1+P2;i++)
		{
			if(vis[i])continue;
			cnt[0].clear();
			cnt[1].clear();
			dfs(i,0);
			A.push_back(make_pair(cnt[0],cnt[1]));
		}
		vector<vector<int> >dp(A.size()+1,vector<int>(P1+1));
		dp[0][0]=1;
		for(int i=0;i<A.size();i++)
		{
			for(int j=P1;j>=0;j--)
			{
				if(dp[i][j]==0)continue;
				if(dp[i][j]>2)dp[i][j]=2;
				int k=dp[i][j];
				if(j+A[i].first.size()<=P1)
				{
					dp[i+1][j+A[i].first.size()]+=k;
				}
				if(j+A[i].second.size()<=P1)
				{
					dp[i+1][j+A[i].second.size()]+=k;
				}
			}
		}
		if(dp[A.size()][P1]>1)
		{
			cout<<"no"<<endl;
		}
		else
		{
			vector<int>ans;
			int id=P1;
			for(int i=A.size();i--;)
			{
				if(id-(int)A[i].first.size()>=0&&dp[i][id-A[i].first.size()]==1)
				{
					for(int k:A[i].first)ans.push_back(k);
					id-=A[i].first.size();
				}
				else
				{
					for(int k:A[i].second)ans.push_back(k);
					id-=A[i].second.size();
				}
			}
			sort(ans.begin(),ans.end());
			for(int k:ans)cout<<k+1<<endl;
			cout<<"end"<<endl;
		}
	}
}



Measured memory_bytes: 3216
a = list(input())

n = len(a)
cnt = {}
for c in a:
    if c in cnt:
        cnt[c] += 1
    else:
        cnt[c] = 1

ans = 0
for c in cnt:
    k = cnt[c]
    ans += k * (n - k)
ans //= 2
ans += 1

print(ans)

Measured memory_bytes: 61936
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-3;
const double PI = acos(-1);

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

int d[9][9];
bool f[9][9];

vector<pii> v(9);

void input(){
	rep(i, 9) rep(j, 9) cin>>d[i][j], f[i][j] = false;
}
void output(){
	for(int i = 0; i < 9; i++){
		for(int j = 0; j < 9; j++){
			printf("%c%d", f[i][j]?'*':' ', d[i][j]);
		}
		printf("\n");
	}
}
void calc(){
	for(int i = 0; i < 8; i++){
		for(int j = i + 1; j < 9; j++){
			if(v[i].fi == v[j].fi){
				f[v[i].se/10][v[i].se%10] = true;
				f[v[j].se/10][v[j].se%10] = true;
			}
		}
	}
}

int main(){
	int n;
	cin>>n;
	rep(Case, n){
		if(Case != 0) printf("\n");
		input();
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				v[j] = mp(d[i][j], i*10+j);
			}
			calc();
		}
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				v[j] = mp(d[j][i], j*10+i);
			}
			calc();
		}
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 3; k++){
					for(int l = 0; l < 3; l++){
						int y = i * 3 + k, x = j * 3 + l, idx = k * 3 + l;
						v[idx] = mp(d[y][x], y* 10 + x);
					}
				}
				calc();
			}
		}
		output();
	}
}

Measured memory_bytes: 1176
//0011
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main(){
	int w,h;
	char dummy;
	std::cin>>w>>h;
	std::vector<int> vec(w);
	for(int i=0;i<w;++i)vec[i]=i+1;
	for(int i=0;i<h;i++){
		int a, b;
		std::cin>>a>>dummy>>b;
		{
			using std::swap;
			swap(vec[a-1],vec[b-1]);
		}
	}
	for(int i=0;i<w;i++){
		std::cout<<vec[i]<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1192
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let k:usize = read();
    let mut v:Vec<usize> = (0..n).map(|_| read()).collect();
    v.sort();
    let mut cnt = std::usize::MAX;
    for i in v.windows(k) {
        cnt = std::cmp::min(cnt, i[k-1] - i[0]);
    }
    println!("{}", cnt);
}


Measured memory_bytes: 3024
N = input()
H = list(map(int, input().split()))
last_h = float('inf')
cnt, ans = -1, 0
for h in H:
  if h <= last_h:
    cnt += 1
  else:
    ans = max(ans, cnt) # update
    cnt = 0 # reset
  last_h = h
ans = max(ans, cnt)
print(ans)

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

#define pout(n)  printf ("%d\n", n)
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)
const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };
#define MAX_N (int)2e5+20
typedef long long ll;
using namespace std;

int n;
int ans = 0;
int main(){
    scanf("%d",&n);
    vector<int> a(n+2,0);
    rep(i, 1, n+1) {
        cin >> a[i];
        ans += abs(a[i]-a[i-1]);
    }
    ans += abs(a[n+1]-a[n]);
    rep(i,1,n+1){
        int y = abs(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]));
        int z = abs(a[i+1]-a[i-1]);
        pout(ans-y+z);
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one

    struct Child {
        ll value;
        int prev;
    };
}

int main() {

    int n = inp1;
    vector<ll> a = inp(n);
    vector<Child> childs(n);
    rep(i, n) {
        childs[i].value = a[i];
        childs[i].prev = i;
    }

    // 大きいやつから左端に行くか右端に行くか選択する
    sort(allof(childs), [](Child& lhs, Child& rhs) {
        return lhs.value > rhs.value;
        });

    // dp[i][j] := 左にi人，右にj人移動させたときのうれしさの最大値
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0LL));

    rep(i, n) { // i+1人目を移動
        rep(j, i + 1) { // すでにj人左に送った
            // 右に送った数
            int right = i - j;
            // 左に送る
            chmax(dp[j + 1][right], dp[j][right] + childs[i].value * abs(childs[i].prev - j));
            // 右に送る
            chmax(dp[j][right + 1], dp[j][right] + childs[i].value * abs(childs[i].prev - (n - right - 1)));
        }
    }

    ll ans = 0LL;
    rep(i, n + 1) { // 左に送った人の数
        chmax(ans, dp[i][n - i]);
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 34672
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int i,l=s.size();
    if(l%2==0)
    {
        for(i=0;i<l;i++)
        {
            if(s[i]=='h' && s[i+1]=='i')
                i++;
            else
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        if(i==l)
            cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
        return 0;
}


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


def solve(H: int, W: int):
    if((H==1)or(W==1)): print(1)
    elif(H%2 == 0): print(H//2 * W)
    elif(W%2==0):print(W//2*H)
    else:
        print((W+1)//2*H - (H+1)//2 + 1)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(H, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#define N 100000
#define INF 1000000000

int ceil(int a, int b) {
	if(a%b==0) return a/b;
	else return a/b + 1;
}

int main(int argc, char const* argv[])
{
	int i, ans=0;
	int a, b;
	scanf("%d%d",&a,&b);
	printf("%d",ceil(b-1, a-1));

	return 0;
}


Measured memory_bytes: 128
import math
S =  list(map(int,input().split()))
A = S[0]
B = S[1]
N = S[2]
if N<B:
    print(math.floor(A*N/B)-math.floor(N/B)*A)
else:
    print(math.floor(A*(B-1)/B)-math.floor((B-1)/B)*A)


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,t; cin >> n >> t;
    vl c(n),d(n);
    rep(i,n)cin >> c[i] >> d[i];
    ll res = INF;
    rep(i,n){
        if(d[i] <= t)res = min(c[i],res);
    }
    cout << (res==INF?"TLE":to_string(res)) << endl;
}


Measured memory_bytes: 256
<?php
//ワーシャルフロイド（全点対最短路問題）
//スタート地点１つに対してゴールが２つ。流れるものは水
//故に、単純に $cost[$s][$g1] + $cost[$s][$g2] とするとWA
//スタート〜ある点までは合流道。ある点〜それぞれのゴールまでは二股に分かれて進むイメージ
//また、有向グラフ（一方通行）なので注意。
//と言ってもむしろ$cost[$b][$a] = $cost[$a][$b]というコピーが不要になるので楽。


$file_handle = fopen('php://stdin', "r");
//$file_handle = fopen('aoj2005_in.txt', "r");


function warshall_floyd($cost) {
	global $n;

	for ($i = 1; $i <= $n; ++$i) {
	    for ($j = 1; $j <= $n; ++$j) {
	        for ($k = 1; $k <= $n; ++$k) {
	            // j -> kへ行くのにiを経由した方が良いかどうか(cost)
	            $via = $cost[$j][$i] + $cost[$i][$k];
	            if ($via < $cost[$j][$k]) {
	                $cost[$j][$k] = $via;
	            }
	        }
	    }
	}
	return $cost;
}


while(1){
	//ファイル読み込み
	$info = trim(fgets($file_handle));
	$explode = explode(' ', $info);
	$n = $explode[0]; $m = $explode[1]; $s = $explode[2]; $g1 = $explode[3]; $g2 = $explode[4];
	//終了条件
	if ($n==0 && $m==0 && $s==0 && $g1==0 && $g2==0) break;
	
	//初期化
	$cost = array();

	//ワーシャルフロイド準備。
	for ($i=1; $i<=$n; ++$i){
		for ($j=1; $j<=$n; ++$j){
			if ($i === $j){
				$cost[$i][$i] = 0;
			} else {
				$cost[$i][$j] = INF;
			}
		}
	}

	//辺の情報を格納
	for ($i=1; $i<=$m; ++$i){
		$info2 = trim(fgets($file_handle));
		$explode = explode(' ', $info2);
		$a = $explode[0]; $b = $explode[1]; $c = $explode[2];
		$cost[$a][$b] = $c;
	}

	//探索。先に全点対最短路を求めておく必要がある
	$cost = warshall_floyd($cost);
	
	//最小値計算
	$min = INF;
	for($i=1; $i<=$n; ++$i){
		//どこで分岐するのが最も総コストが低いか比較
		$min = min($min, $cost[$s][$i] + $cost[$i][$g1] + $cost[$i][$g2]);
	}
	
	//出力
	echo $min;
	echo PHP_EOL;
}

fclose($file_handle);

Measured memory_bytes: 9864
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cin >> a ;
cin >> b ;
cin >> c ;
if((-100 <= a ) && (a <= 100) && (-100 <= b) && (b<= 100) && (-100 <= c) && (c <= 100))
    {
    if((a==b) && (a!=c))
        cout << c;
    else if((b==c)&& (b!=a))
        cout << a;
    else if ((a==c)&& (a!=b))
        cout << b;
    }
else
    cout << "wrong inputs";
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split(" ")))

l=[]

for i in range(1,n+1):
	l.append(i)

c=0
for i in range(n):
	if(a[i]!=l[i]):
		c+=1
if(c==2 or c==0):
	print("YES")
else:
	print("NO")









Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    int X, A;
    cin >> X >> A;

    if (X < A) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    if(n==1)cout << 1 << endl,exit(0);
    vpl p(n);rep(i,n){
        cin >> p[i].fi >> p[i].se;
    }
    ll ans=0;
    map<pl,ll> mp;
    rep(i,n){
        rep(j,n){
            if(i==j)continue;
            mp[{p[i].fi-p[j].fi,p[i].se-p[j].se}]++;
        }
    }
    for(auto p:mp){
        chmax(ans,p.se);
    }
    cout << n-ans <<endl;
}

Measured memory_bytes: 3720
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	#初期化
	S = list(input())
	N = len(S)
	SS = S + S
	K = int(input())

	#計算
	x = 0
	c = 1
	for i in range(1, N):
		if S[i] == S[i - 1]:
			c += 1
		else:
			x += c // 2
			c = 1
	x += c // 2

	y = 0
	c = 1
	for i in range(1, 2 * N):
		if SS[i] == SS[i - 1]:
			c += 1
		else:
			y += c // 2
			c = 1
	y += c // 2

	judge = "Yes"
	for i in range(N - 1):
		if S[i] != S[i + 1]:
			judge = "No"


	#答え
	if judge == "No":
		print(x + (y - x) * (K - 1))
	else:
		print(N * K // 2)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3444
'''input
31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

'''

n = int(input())
a = list( map( int , input().split() ))
prod =1

if 0 in a:
	print(0)
	exit(0)
 
for i in a :
  # print(prod)
  if  i * prod > 1e18:
    print(-1)
    exit(0)
  else:
    prod = prod *  i
 
print(prod)







































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

using namespace std;

void solve()
{
	string str;
	while(cin >> str)
	{
		for(int i = 0; i < str.size(); ++i)
		{
			if(str[i] == '@')
			{
				for(int j = 0; j < (str[i + 1] - '0'); ++j)
				{
					cout << str[i + 2];
				}
				i += 2;
			}
			else
			{
				cout << str[i];
			}
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(void){
    int N, tempInt;
    vector<int> Mochi;
    cin  >> N;
    for(int i = 0; i < N; i++){
        cin >> tempInt;
        Mochi.push_back(tempInt);
    }
    sort(Mochi.begin(), Mochi.end());
    
    tempInt = -1;
    
    int count = 0;
    for(int i = 0; i < Mochi.size(); i++){
        if(tempInt != Mochi[i]){
            tempInt = Mochi[i];
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

using namespace std;

bool check(string s, ll a){
	for (ll i = 0; i < s.size(); ++i){
		if (i == a) continue;
		if (!('0' <= s[i] && s[i] <= '9')) return 0;
	}return 1;
}

int main(){
	ll a, b; cin >> a >> b;
	string s; cin >> s;
	if (s[a] == '-' && check(s,a)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d  long double
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;


 
signed main()
{
    haha
    int a,b;
    cin>>a>>b;
   for(int i=1;i<=10000;i++)
   {
       if(i*8/100==a && i/10==b)
       {
           cout<<i;
           return 0;
       }
   }
   cout<<-1;
    
    
    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(r,n,p) for(r::iterator it=p.begin();it!=p.end();++it)
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int ans = 0;
        rep(i,10)rep(j,10)rep(k,10)rep(l,10)
        {
            if(i+j+k+l == n)
            {
                ans ++;
            }
        }
        cout << ans<<endl;

    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<tuple>
#include<set>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
int main() {
	int i, N, D, X, a;
	cin >> N >> D >> X;
	for (i=0; i<N; i++) {
		cin >> a;
		X+=(D-1)/a+1;
	}
	cout << X;
}

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

#ifdef DEBUG
struct test {
    int N;
    char S[200][201];
    int a;
} t[] = {
    {
        6, {"011000", "100100", "100010", "010001", "001001", "000110"}, 4
    },
    {
        2, {"01", "10"}, 2
    },
    {
        3, {"011", "101", "110"}, -1
    },
    {
        6, {"010110", "101001", "010100", "101000", "100000", "010000"}, 4
    }
};
#endif

#define min(a, b)   ((a)>(b)?(b):(a))
#define max(a, b)   ((a)<(b)?(b):(a))

void
solver(int n, char s[200][201])
{
    int i, j, k;
    int d[200][200];
    int a=0;
    int row;

    for (i=0; i<n; i++) {
        row = 0;
        for (j=0; j<n; j++) {
            if (i==j) {
                d[i][j] = 0;
            }
            else if (s[i][j]=='0') {
                d[i][j] = 2 * n;
            }
            else {
                d[i][j] = 1;
            }
            row = row + d[i][j];
        }
        if (row==2*n*(n-1)) {
            printf("-1\n");
            return;
        }
    }

#ifdef TRACE
    printf("Start\n");
    for (i=0; i<n; i++) {
        for (j=0; j<n; j++) {
            printf("%d ", d[i][j]);
        }
        printf("\n");
    }
#endif
    
    for (k=0; k<n; k++) {
        for (i=0; i<n; i++) {
            for (j=0; j<n; j++) {
                if (d[i][k]==2*n || d[k][j]==2*n)
                    continue;
                if (j!=k && ((d[k][j]==1 && d[i][j] == d[i][k]) || (d[i][k]==1 && d[i][j]==d[k][j]))) {
                    //printf("%d, %d, %d: %d %d %d\n", i, j, k, d[i][j], d[i][k], d[k][j]);
                    printf("-1\n");
                    return;
                }
                if (d[i][j]>=d[i][k]+d[k][j]) {
//                    printf ("%d <- %d + %d\n", d[i][j], d[i][k], d[k][j]);
                    d[i][j] = d[i][k]+d[k][j];
                }
            }
        }
    }
    for (i=0; i<n; i++) {
        for (j=0; j<n; j++) {
            a = max(a, d[i][j]);
        }
    }
#ifdef TRACE
    printf("End\n");
    for (i=0; i<n; i++) {
        for (j=0; j<n; j++) {
            printf("%d ", d[i][j]);
        }
        printf("\n");
    }
#endif
    printf("%d\n", a+1);
}
    
int
main(int argc, char *argv[])
{
    int i;
    int N;
    char S[200][201];
    
#ifdef DEBUG
    for (i=0; i<1; i++) {
        solver(t[i].N, t[i].S);
        printf("%d\n", t[i].a);
    }
#else
    scanf("%d", &N);
    for (i=0; i<N; i++) {
        scanf("%s", S[i]);
    }
    solver(N, S);
#endif

    return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;

  set<pair<string, int>> st;
  st.insert(make_pair("a", 1));

  for(int i = 1; i < N; i++){
    
    set<pair<string, int>> st2;

    for(auto itr = st.begin(); itr != st.end(); itr++){

      for(int j = 0; j < itr->second; j++){
        st2.insert(make_pair(itr->first + char(int('a'+j)), itr->second));
      }

      int num = itr->second;
      st2.insert(make_pair(itr->first + char(int('a'+num)), num+1));

    }
    st = st2;

  }


  for(auto itr = st.begin(); itr != st.end(); itr++){
    cout << itr->first << endl;
  }
  
  return 0;
}


Measured memory_bytes: 21504
h,w,a,b=map(int,input().split())
s = [[0 for _ in range(w)] for __ in range(h)]

for i in range(a):
    for j in range(b):
        s[j][i] = 1

for i in range(w-a):
    for j in range(h-b):
        s[b+j][a+i] = 1

for i in range(h):
    print(''.join([str(x) for x in s[i]]))

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

using ll    = long long;
using vll   = vector<ll>;
using pll   = pair<ll,ll>;
using ld    = long double;

const ll mod = (ll)1e9 + 7;
const ll mxN = (ll)1e6 + 3;



void solve() {
	ll n;cin>>n;ll ans=0;
	vector<ll> div(n+1);
	for(int i=1;i<=n;i++) 
		for(int j=i;j<=n;j+=i)
			div[j]++;
	for(int i=1;i<=n;i++)
		ans+=i*div[i];
	cout<<ans<<"\n";
	
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	pre();
//	ll t;cin>>t;while (t--)
		solve();
}


Measured memory_bytes: 81304
n, m = map(int, input().split())
a, b = 0, 10 ** 12
while b - a > 1:
    k = (a + b) // 2
    if 2 * k <= m and k <= n + (m - 2 * k) // 2:
        a = k
    else:
        b = k
print(a)

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;






int main() {

	int n;
	cin >> n;
	cout << (n - 2) * 180 << endl;

	
}

Measured memory_bytes: 256