akhauriyash/Code-Regression huggingface dataset:
/* This code is written by Nemlit */
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define maxn 1000005
int n, m, ch[maxn][27], rt, cnt, is[1000005][27], ton[27], fa[1000005], pax, ans;
struct node {
    string c;
    int len;
}e[maxn];
il bool cmp(node a, node b) {
    return a.len > b.len;
}
il void insert(int &now, int pa, int x) {
    if(x == -1) return;
    if(!now) now = ++ cnt;
    pax = now;
    insert(ch[now][e[pa].c[x] - 'a' + 1], pa, x - 1);
    fa[ch[now][e[pa].c[x] - 'a' + 1]] = now;
}
il int find(int now, int pa, int x) {
    if(x == 0) return is[now][e[pa].c[0] - 'a' + 1];
    if(ch[now][e[pa].c[x] - 'a' + 1]) return find(ch[now][e[pa].c[x] - 'a' + 1], pa, x - 1);
    return 0;
}
signed main() {
	n = read();
    rep(i, 1, n) cin >> e[i].c, e[i].len = e[i].c.size();
    sort(e + 1, e + n + 1, cmp);
    rep(i, 1, n) {
        ans += find(rt, i, e[i].len - 1);
        insert(rt, i, e[i].len - 1);
        rep(j, 0, e[i].len - 1) {
            ton[e[i].c[j] - 'a' + 1] = 1;
            rep(k, 1, 26) is[pax][k] += ton[k];
            pax = fa[pax];
        }
        rep(i, 1, 26) ton[i] = 0;
    }
    cout << ans;
	return 0;
}

Measured memory_bytes: 300804
def agc005_a():
  x = str(input())
  s_accum = [0]
  t_accum = [0]
  t_up = 0
  for ch in x:
    # SとTの出現回数の累積和
    if ch == 'S':
      s_accum.append(s_accum[-1] + 1)
      t_accum.append(t_accum[-1])
    else:
      s_accum.append(s_accum[-1])
      t_accum.append(t_accum[-1] + 1)
    # Tの左側にいるSとの差分が、残るTの数で、プラスの値ならTが先頭に残る
    if ch == 'T':
      t_up = max(t_up, t_accum[-1] - s_accum[-1])
  ans = 2 * t_up
  print(ans)

agc005_a()

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

int main () {
    int N;
    cin >> N;
    string r = "";

    if(N == 0){
        cout << 0 << endl;
        return 0;
    }

    while(N!=0){
        if(N%2 == 0){
            r = "0"+r;
        }else{
            N--;
            r = "1"+r;
        }
        N /= -2;
    }

    cout << r << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int goukei = 0, i, n;
	for(i = 0;i < 5;i++){
		scanf("%d", &n);
		if(n < 40){
			goukei = goukei + 40;
		}
		else{
			goukei = goukei + n;
		}
	}
	printf("%d\n", goukei / 5);
	return 0;
}


Measured memory_bytes: 2136
#include<stdio.h>
int main(void) {
	int N, i;
	long long sum = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) sum += i;
	}
    printf("%lld",sum);
	return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int a, b;
  cin >> a >> b;
  --a, --b;
  int c[3] = {1, 1, 1};
  c[a] = c[b] = 0;
  rep(i, 3) if (c[i]) cout << i + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
N = input()
input_list = list(map(int, input().split()))

def cal_division(n):
    return int(n / 2)

flag = False
count = 0
while True:
    # 偶数チェック
    for i in input_list:
        if i % 2 != 0:
            flag = True
            break

    if flag:
        break

    # リスト内を÷2
    count += 1
    input_list = list(map(cal_division, input_list))

print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
using namespace std;

typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

typedef vector<bool> VBL;
typedef vector<VBL> VVBL;

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

int main(){
  VVLL bingo(3,VLL(3,0));
  VVBL result(3,VBL(3,false));
  FOR(i,0,3){
    cin >> bingo[i][0] >> bingo[i][1] >> bingo[i][2];
  }

  int N;
  cin >> N;
  int nums[N];
  FOR(i,0,N){
    cin >> nums[i];
  }


  for(int j=0;j<3;++j){
    for(int k=0;k<3;++k){
      FOR(i,0,N){
        if(bingo[j][k] == nums[i]){
          result[j][k] = true;
          break;
        }
      }    
    }
  }

  // cout << result[0][0] << result[1][1] << result[2][2] << endl;

  for(int j=0;j<3;++j){
    if(result[j][0] && result[j][1] && result[j][2] ){
      cout << "Yes" << endl;
      return 0;
    }

    if(result[0][j] && result[1][j] && result[2][j] ){
      cout << "Yes" << endl;
      return 0;
    }
  }

  if(result[0][0] && result[1][1] && result[2][2] ){
      cout << "Yes" << endl;
      return 0;
  }

  if(result[0][2] && result[1][1] && result[2][0] ){
      cout << "Yes" << endl;
      return 0;
  }


  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N=5*1E3,MAX_M=1E5;

int n,m;

vector<int> G[MAX_N];

int grad[MAX_N];	//grad[i]=i???????????????
bool visit[MAX_N];
int in[MAX_N];	//??\?¬???°

void bfs(){
	bool flg=false;
	for (int i=0;i<n;i++){
		for (int j=0;j<G[i].size();j++){
			in[G[i][j]]++;
		}
	}
	for (int i=0;i<n;i++){
		//i???????????????????±??????????
		int v=-1;
		for (int j=0;j<n;j++){
			if (in[j]==0 && !visit[j]){
				if (v!=-1){
					//????£?????????°??????
					flg=true;
				}
				v=j;
			}
		}
		visit[v]=true;
		grad[i]=v;
		for (int j=0;j<G[v].size();j++){
			in[G[v][j]]--;
		}
	}
	for (int i=0;i<n;i++){
		printf("%d\n",grad[i]+1);
	}
	printf("%d\n",flg ? 1 : 0);
}

int main(){
	scanf("%d",&n);
	scanf("%d",&m);
	for (int i=0;i<m;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		G[a-1].push_back(b-1);
	}
	bfs();
	return 0;
}

Measured memory_bytes: 1768
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;


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



Measured memory_bytes: 3612
#include <vector>
#include <algorithm>
#include <cstdio>
#define LIMIT 10000
using namespace std;
bool ck(vector<int>&v){
	for(int i=0;i<v.size();i++)if(v[i]!=i+1)return false;
	return true;
}
main(){
	int n,i,j,s,x,l;
	vector<int>tri;
	for(i=1;i<299;i++)tri.push_back(i*(i+1)/2);
	for(;scanf("%d",&n),n;){
		vector<int>v;
		for(s=i=0;i<n;i++){
			scanf("%d",&x);
			s+=x;
			v.push_back(x);
		}
		vector<int>::iterator idx=find(tri.begin(),tri.end(),s);
		i=LIMIT+1;
		if(idx!=tri.end()){
			for(i=0;i<=LIMIT&&!ck(v);i++){
				l=v.size();
				for(j=0;j<l;j++)v[j]--;
				v.erase(remove(v.begin(),v.end(),0),v.end());
				v.push_back(l);
			}
		}
		printf("%d\n",i>LIMIT?-1:i);
	}
}

Measured memory_bytes: 1056
import java.util.*;

public class Main{
  public static void main(String args[]) {
    Scanner in  = new Scanner(System.in);
    int rnum = in.nextInt();
    int taro = 0, hanako = 0;

    for(int i = 0; i < rnum; i++){
      String p1 = in.next();
      String p2 = in.next();
      if( p1.compareTo(p2) < 0){
        hanako +=3;
      } else if(p1.compareTo(p2) > 0){
        taro += 3;
      } else if(p1.compareTo(p2) == 0){
        taro += 1;
        hanako += 1;
      }
    }

    System.out.println(taro + " " + hanako);
  }
}



Measured memory_bytes: 29544
import java.util.Scanner;

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

		// 入力値の取得
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();
		
		// 結果の出力
		if (K >= (A + B)) {
			System.out.println("0 0");
		}
		else if (K >= A) {
			System.out.println("0 " + (B - (K - A)));
		}
		else {
			System.out.println((A - K) + " " + B);
		}
		
		sc.close();
	}
}


Measured memory_bytes: 27116
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=5010;
const int mod=1e9+7;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

VI e[N];
int root,siz[N],fac[N],n;
int f[N][N],C[N][N],v[N],fa[N];
inline void dfs(int k) {
	siz[k]=1;int mx=0;
	for (int t:e[k])
		if (t!=fa[k]) {
			fa[t]=k;
			dfs(t);
			siz[k]+=siz[t];
			mx=max(mx,siz[t]);
		}
	mx=max(mx,n-siz[k]);
	if (mx*2<n) root=k;
}
int main()
{
	int i,j,k,a,b,w,ans,m=0;n=gi();
	for (i=1;i<n;i++) {
		a=gi(),b=gi();
		e[a].pb(b),e[b].pb(a);
	}
	for (i=fac[0]=1;i<=n;i++) fac[i]=1LL*fac[i-1]*i%mod;
	dfs(1);
	if (root) {
		for (i=0;i<=n;i++)
			for (j=C[i][0]=1;j<=i;j++)
				C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
		for (int t:e[root])
			v[++m]=fa[root]==t?n-siz[root]:siz[t];
		f[0][1]=1;
		for (i=1;i<=m;i++)
			for (j=1;w=f[i-1][j];j++)
				for (k=0;k<=v[i];k++)
					f[i][j+v[i]-k]=(f[i][j+v[i]-k]+(k&1?-1LL:1LL)*w*C[v[i]][k]%mod*C[v[i]][k]%mod*fac[k])%mod;
		for (i=1,ans=0;i<=n;i++)
			ans=(ans+1LL*f[m][i]*fac[i])%mod;
	} else ans=1LL*fac[n/2]*fac[n/2]%mod;
	cout<<(ans+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 194944
# coding: utf-8

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

appear_D = {}


def sosuu(n):
    output = []
    for i in range(1, int(pow(n, 0.5))+1):
        if n % i == 0:
            output.append(i)
            if i != n // i:
                output.append(n // i)

    return output


ans_cantdidate = []

min_fst = a[0]
for i in range(n):
    if a[i] < min_fst:
        min_fst = a[i]

min_snd = a[0] if a[0] != min_fst else a[1]
for i in range(n):
    if min_fst < a[i] < min_snd:
        min_snd = a[i]

sosuus = set(sosuu(min_fst)) | set(sosuu(min_snd))
for num in sosuus:
    not_common = 0
    for i in range(n):
        if a[i] % num > 0:
            not_common += 1
        if not_common > 1:
            break
    if not_common < 2:
        ans_cantdidate.append(num)

print(max(ans_cantdidate))

Measured memory_bytes: 14400
N = int(input())
S = list(input())

W = [ 1 if S[i]=='W' else 0 for i in range(N)]
E = [ 1 if S[i]=='E' else 0 for i in range(N)]

for i in range(1,N):
    W[i] = W[i-1]+W[i]
    E[-i-1] = E[-i] + E[-i-1]

ans = 3 * 10 **5

for i in range(N):
    if i == 0:
        ans = min(ans,E[1])
    elif i == N-1:
        ans = min(ans,W[N-2])
    else:
        ans = min(ans,W[i-1]+E[i+1])
print(ans)

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

int main()
{
	int X, Y, Z, K;
	scanf("%d%d%d%d", &X, &Y, &Z, &K);
	std::vector<long long> A(X), B(Y), C(Z);
	for (auto& e: A) scanf("%lld", &e);
	for (auto& e: B) scanf("%lld", &e);
	for (auto& e: C) scanf("%lld", &e);
	std::vector<long long> AB(X * Y);
	for (int i{}; i < X; i++)
		for (int j{}; j < Y; j++)
			AB[i * Y + j] = A[i] + B[j];
	std::sort(AB.rbegin(), AB.rend());
	const int size{std::min(X * Y, K)};
	std::vector<long long> ans(size * Z);
	for (int i{}; i < size; i++)
		for (int j{}; j < Z; j++)
			ans[i * Z + j] = AB[i] + C[j];
	std::sort(ans.rbegin(), ans.rend());
	for (int i{}; i < K; i++)
		printf("%lld\n", ans[i]);

	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long a[n],sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	cout<<a[0]<<" "<<a[n-1]<<" "<<sum<<endl;
	return 0;
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000ll
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// 例外を十分に含む一般化．想像力の限界
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

string s; 
int K; cin >> s >> K;

rep(i, 0, s.size()){
    int d = 'z' - s[i] + 1;
    if (d <= K && s[i] != 'a') {
        s[i] = 'a';
        K -= d;
    }
}

if (K > 0)
    s.back() += K % 26;

cout << s << "\n";

}

// 境界，出力文字列 チェック



Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << ” = ” << (x) << ” (L” << __LINE__ << “)” << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
       return l.first<r.first || (l.first==r.first && l.second > r.second);
       });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
   int a,b;
   cin>>a>>b;
   cout<<max(0,a-2*b)<<endl;





   return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d,i,j,k,l;
	while(~scanf("%d%d",&a,&b))
	{
		if(a<=9&&b<=9)
		{
		c=a*b;	
		printf("%d\n",c);
		}
		else
		printf("-1\n");
	}
}

Measured memory_bytes: 128
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < (int)n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

string A;
vector<int> length;
vector<int> pos[26];
bool appeared[26];
string ans;
int main() {
	cin >> A;
	int len = 1;
	length.resize(A.size());

	REPM(i, A.size(), 0) {
		appeared[A[i] - 'a'] = true;
		
		length[i] = len;
		bool completed = true;
		REP(p, 0, 26) {
			if (!appeared[p]) completed = false;
		}
		if (completed) {
			len++;
			fill(appeared, appeared + 26, false);
		}
	}

	REP(i, 0, A.size()) {
		pos[A[i] - 'a'].push_back(i);
	}

	int curr_len = len;
	int curr_pos = -1;
	while (true) {
		REP(c, 0, 26) {
			auto it = upper_bound(pos[c].begin(), pos[c].end(), curr_pos);
			if (it == pos[c].end()) {
				ans += 'a' + c;
				cout << ans << endl;
				return 0;
			}
			if (length[*it] == curr_len - 1) {
				curr_len--;
				curr_pos = *it;
				ans += 'a' + c;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2180
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

list<int> l;

void dfs(int rest, int ub){
	if(rest == 0){
		int cnt = 0;
		for(list<int>::iterator iter = l.begin(); iter != l.end(); iter++){
			if(cnt) cout << " ";
			else cnt++;
			cout << *iter;
		}
		cout << endl;
		return;
	}
	for(int i = ub; i >= 1; i--){
		if(i > rest) continue;
		l.push_back(i);
		dfs(rest - i, i);
		l.pop_back();
	}
}

int main(){
	int n;
	while(cin >> n && n){
		dfs(n, n);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<climits>
#include<numeric>
#include<algorithm>
#include <sstream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<utility>
#include<array>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<forward_list>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main()
{
long long int n;
cin>>n;
int count=0;
for (int i = 1; i<=9; ++i)
{
	/* code */
	for (int j = 1; j<=9; ++j)
	{
		if(i*j==n){
			cout<<"Yes"<<endl;
			count=1;
			break;
		}
		/* code */
	}
	if (count==1)
	{
		break;
		/* code */
	}
}
if(count==0)
{
	cout<<"No"<<endl;
}

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

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

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int main(){
	long long a[3]={0},m[3];
	while(cin >> a[0] >> m[0] , a[0]){
		rep(i,2)cin >> a[1+i] >> m[1+i];
		
		int d[3] = {0};
		
		rep(i,3){
			int pos = 1;
			do{
				pos = (a[i] * pos) % m[i];
				d[i]++;
			}while(pos != 1);
		}
		cout << (long long)lcm(lcm(d[0],d[1]),d[2]) << endl;
	}
}
	

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

int main(){
  int a,log,s=0;
  cin>>a;
  log=a;
  for(int i=0;i<10;i++){
    s+=log%10;
    log/=10;
  }
  if(a%s==0) cout<<"Yes";
  else cout<<"No";
  cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n,ans=0;

	cin >> n;
	
	vecll d(n);
	
	forll(i, 0, n)
		cin >> d[i];

	sort(d.begin(), d.end());

	ans = max(d[n / 2] - d[n / 2 - 1],(ll)0);

	cout << ans;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int a[n+2];
    a[0] = 0;
    a[n+1] = 0;
    for(int i = 1; i < n+1; i++){
        cin >> a[i];
    }
    int sum = 0;
    for(int i = 0; i < n+1; i++){
        sum += abs(a[i] - a[i+1]);
    }
    for(int i = 1; i < n+1; i++){
        int p = abs(a[i-1] - a[i+1]);
        int q = abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]);
        cout << sum + p - q << endl; 
    }

    return 0;
}

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

int main() {
  int a, b, ans;
  cin >> a >> b;
  bool found = 0;
  for (ans = 10 * b; ans < 10 * (b + 1); ans++) {
    if (floor(0.08 * (double)ans) == a) {
      found = 1;
      break;
    }
  }
  if (found)
    cout << ans << endl;
  else
    cout << -1 << endl;
}

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

int main(){
   
    string S;cin>>S;
    string T;
    for(int i=0;i<S.size();i++){
        if(S[i]=='A') T+="X";
        else if(i<S.size()-1&&S[i]=='B'&&S[i+1]=='C') T+="Y";
        else if(!(i>0&&S[i]=='C'&&S[i-1]=='B')) T+="Z";
    }
    long long int ans=0;
    vector<long long int> M(T.size()+1,0);
    for(int i=T.size()-1;i>=0;i--){
        if(T[i]=='Z') M[i]=0;
        if(T[i]=='Y') M[i]=M[i+1]+1;
        if(T[i]=='X') M[i]=M[i+1];
     }
    for(int i=0;i<T.size();i++){
        if(T[i]=='X') ans+=M[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2312
from math import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    a,b,d = map(int, input().split())
    r=radians(d)
    h=b*sin(r)
    s=a*h/2
    l=(a**2+b**2-2*a*b*cos(r))**0.5+a+b
    print(s)
    print(l)
    print(h)

main()



Measured memory_bytes: 5732
#include <bits/stdc++.h>
#define DAU  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
const int Dim(26);
int n, q, op, x, y, res, p2[Dim];
char ch;
string s;
class AINT {
public:
    AINT() {}
    AINT(int _n) : n(_n) { arb = vector<int>(4 * n); }
    inline void Build(int node, int st, int dr) {
        if (st == dr) {
            arb[node] = p2[s[st - 1] - 'a'];
            return;
        }
        int mid = (st + dr) / 2;
        Build(2 * node, st, mid);
        Build(2 * node + 1, mid + 1, dr);
        arb[node] = (arb[2 * node] | arb[2 * node + 1]);
    }
    inline void Update(int node, int st, int dr, int pos, int val) {
        if (st == dr) {
            arb[node] = val;
            return;
        }
        int mid = (st + dr) / 2;
        if (pos <= mid)
            Update(2 * node, st, mid, pos, val);
        else Update(2 * node + 1, mid + 1, dr, pos, val);
        arb[node] = (arb[2 * node] | arb[2 * node + 1]);
    }
    inline int Query(int node, int st, int dr, int l, int r) {
        if (l <= st && dr <= r)
            return arb[node];
        int mid = (st + dr) / 2, r1(0), r2(0);
        if (l <= mid)
            r1 = Query(2 * node, st, mid, l, r);
        if (mid < r)
            r2 = Query(2 * node + 1, mid + 1, dr, l, r);
        return (r1 | r2);
    }
private:
    int n;
    vector<int> arb;
};
int main() {
    DAU
    p2[0] = 1;
    for (int i = 1; i < Dim; ++i)
        p2[i] = p2[i - 1] * 2;
    cin >> n >> s >> q;
    AINT aint(n);
    aint.Build(1, 1, n);
    for (int i = 1; i <= q; ++i) {
        cin >> op >> x;
        if (op == 1) {
            cin >> ch;
            aint.Update(1, 1, n, x, p2[ch - 'a']);
        }
        else {
            cin >> y;
            cout << __builtin_popcount(aint.Query(1, 1, n, x, y)) << '\n';
        }
    }
    PLEC
}

Measured memory_bytes: 8732
#include<cstdio>
#include<vector>


using namespace std;

using vi=vector<int>;


int gcd(int a, int b)
{
	int c;

	while((c=a%b))
	{
		a=b;
		b=c;
	}
	return b;
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n);

		for(int i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
		}
		int ans=a[0];
		for(int i=1;i<n;i++)
		{
			ans=gcd(a[i], ans);
		}
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, a, b, ans = 0;
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++){
        int x = i;
        int sum = 0;
        while(x > 0){
            sum += x % 10;
            x /= 10;
        }
        if(a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int n, p[50], i=0, j, f, a=0;

   scanf("%d",&n);
   for(f=0;f<n;f++){
      scanf("%d",&p[f]);
      if(p[f]!=f+1)
         a++;
   }

   if(a==0)
      printf("YES\n");
   else if(a==2){
      for(f=0;f<n;f++){
         if((p[f]!=f+1)&&(i==0))
            i=f+1;
         else if(p[f]!=f+1)
            j=p[f];
      }
      if(i==j)
         printf("YES\n");
      else
         printf("NO\n");
   }
   else
      printf("NO\n");
   return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int a,b,n,x,y;
	scanf("%d %d",&a,&b);
	n=a+b;
	x=n/2;
	y=n%2;
	if(y>=1){
		printf("%d\n",x+1);
	}
	else{
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	// a x + b y = c
	// d x + e y = f
	double a,b,c,d,e,f;
	
	
	// 複数のデータセットが与えられる(入力の最後まで処理)
	while(cin>>a>>b>>c>>d>>e>>f){
		
		// ad x + bd y = cd
		// ad x + ea y = af
		// (bd - ae) y = cd - af
		// y = (cd - af)/(bd - ae)
		const double y = int((c*d - a*f)/(b*d - a*e)*10000)/10000.0;
		
		// ae x + be y = ce
		// bd x + be y = bf
		// (ae - bd) x = ce -bf
		// x = (ce - bf)/(ae - bd)
		const double x = int((c*e - b*f)/(a*e - b*d)*10000)/10000.0;
		
		//各値は小数点以下第３位まで出力(小数点以下第４位を四捨五入)
		printf("%.3f %.3f\n",x,y);
	}
}


Measured memory_bytes: 3128
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//Segment Tree
template <class num> struct ST {
private:
	int n;
	vector<num> node;
public:
	ST(vector<num> v) {
		int sz = v.size();
		n = 1; while (n < sz)n *= 2;
		node.resize(n * 2 - 1, INF);

		for (int i = 0; i < sz; i++)node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)node[i] = min(node[2 * i + 1], node[2 * i + 2]);
	}
	void update(int x, num val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[2 * x + 1], node[2 * x + 2]);
		}
	}
	num get(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		if (r <= a || b <= l)return INF;
		if (a <= l && r <= b)return node[k];
		return min(
			get(a, b, 2 * k + 1, l, (l + r) / 2),
			get(a, b, 2 * k + 2, (l + r) / 2, r)
		);
	}
};


int main() {
	int N, Q;
	cin >> N >> Q;
	vector<double> S(N), T(N);
	vector<int> X(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i] >> T[i] >> X[i];
	}
	vector<int> D(Q), ans(Q);
	for (int i = 0; i < Q; i++)cin >> D[i];

	vector<ll> a(N,INF);
	ST<ll> b(a);

	//time,No,Query
	set<pair<pair<double, int>, int>> e;
	for (int i = 0; i < N; i++) {
		e.insert({ {S[i] - X[i] - 0.5,i},0 });
		e.insert({ {T[i] - X[i] - 0.5,i},1 });
	}
	for (int i = 0; i < Q; i++) {
		e.insert({ {D[i],i},2 });
	}

	for (auto itr = e.begin(); itr != e.end(); itr++) {
		auto q = *itr;
		if (q.second == 0) {
			//a[q.first.second] = 1;
			b.update(q.first.second, X[q.first.second]);
		}
		if (q.second == 1) {
			//a[q.first.second] = 0;
			b.update(q.first.second, INF);
		}
		if (q.second == 2) {
			auto tmp = b.get(0, N+1);
			if (tmp == INF)ans[q.first.second] = -1;
			else ans[q.first.second] = tmp;
		}
	}

	for (int i = 0; i < Q; i++) {
		cout << ans[i] << endl;
	}

}

Measured memory_bytes: 51044
///
// File:  dpl_1_b.cpp
// Author: ymiyamoto
//
// Created on Wed Nov  1 23:21:00 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct item_t {
  int32_t value;
  int32_t weight;
};

#define MAX_NUM 101
#define MAX_WEIGHT 10001

static vector<item_t> weights;
static int32_t dp[MAX_NUM][MAX_WEIGHT];

int32_t main()
{
  int32_t N, W;
  cin >> N >> W;

  weights.push_back({0, 0});
  for (int32_t i = 0; i < N; i++) {
    int32_t value, weight;
    cin >> value >> weight;
    weights.push_back({value, weight});
  }

  for (int32_t n = 1; n <= N; n++) {
    for (int32_t weight = 0; weight <= W; weight++) {
      item_t item = weights[n];

      dp[n][weight] = dp[n - 1][weight];
      if (weight - item.weight >= 0) {
        dp[n][weight] = max(dp[n][weight], item.value + dp[n - 1][weight - item.weight]);
      }
    }
  }

  cout << dp[N][W] << endl;

  return 0;
}

Measured memory_bytes: 7004
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

const double PI=3.14159265358979323846;
int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(n);
    double ans = n * 2 * PI;


    co(ans);

    return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <iomanip>
#include <queue>
using namespace std;
double a[55];
priority_queue<double> que;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		que.push(-1 * a[i]);
	}

	//cout << que.size() << endl;

	while(que.size() > 1)
	{
		double b,c;
		b = que.top();
		que.pop();
		c = que.top();
		que.pop();

		que.push((b+c)/2);
		//cout << "a";
	}

	cout << -1 * que.top() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <cstring>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

ll N, K;
vector<ll> A;

ll dp[40][2];
ll dfs(ll k, bool less)
{
  if (k == -1) return 0;

  int x = (K >> k) & 1;
  int r = (less ? x : 1);

  ll num[2] = { };
  REP(i, N) {
    if ((A[i] >> k) & 1) num[1]++;
    else num[0]++;
  }

  ll &ret = dp[k][less];
  if (~ret) return ret;

  for (ll i = 0; i <= r; i++) {
    ret = max(ret, dfs(k - 1, less && i == r) + num[1 - i]*(1LL << k));
  }

  return ret;
}

int main()
{
  memset(dp, -1, sizeof(dp));
  cin >> N >> K;
  A = vector<ll>(N);
  REP(i, N) cin >> A[i];

  cout << dfs(39, true) << endl;;

  return 0;
}

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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

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

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 16;

int n;
int a[N][N];
int LOG[1 << N];
ll val[1 << N];
ll dp[1 << N];
bool vis[1 << N];
vi adj[1 << N];

void getVal(int msk) {
	for (int i = 0; i < n; i++) {
		if (msk & (1 << i)) {
			for (int j = i + 1; j < n; j++) {
				if (msk & (1 << j)) {
					val[msk] += a[i][j];
				}
			}
		}
	}
	vi v;
	int tmp = (~msk) & ((1 << n) - 1);
	while (tmp) {
		int idx = tmp & -tmp;
		v.pb(LOG[idx]);
		tmp -= idx;
	}
	int sz = SZ(v);
	for (int nxt = 1; nxt < (1 << sz); nxt++) {
		tmp = nxt;
		int cur = 0;
		while (tmp) {
			int idx = tmp & -tmp;
			cur |= 1 << v[LOG[idx]];
			tmp -= idx;
		}
		adj[msk].pb(cur);
	}
}

ll calc(int msk) {
	if (msk == (1 << n) - 1)
		return 0;
	ll &ret = dp[msk];
	if (vis[msk])
		return ret;
	vis[msk] = 1;
	ret = LLONG_MIN;
	for (int nxt : adj[msk]) {
		ret = max(ret, calc(msk | nxt) + val[nxt]);
	}
	return ret;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	for (int i = 0; i < N; i++)
		LOG[1 << i] = i;
	for (int msk = 0; msk < (1 << n); msk++) {
		getVal(msk);
	}
	cout << calc(0) << endl;
	return 0;
}


Measured memory_bytes: 174076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,ans;
    char c;
    cin>>c;
    if(c>='A' && c<='Z')
    {
        cout<<"A"<<endl;

    }
    else
    {
        cout<<"a"<<endl;
    }


}


Measured memory_bytes: 3556
#include <stdio.h>

int main(void){
	for(;;){
		int h, w, i, j;

		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0)
			break;

		for(i = 0; i < h; i++){
			for(j = 0; j < w; j++)
				putchar((i+j) % 2 ? '.' : '#');
			putchar('\n');
		}
		putchar('\n');
	}
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define bg(x) (x).begin()
#define ed(x) (x).end()
#define ar array
#define ll long long int

const ll mod = 1e9 + 7;

int main() {
   
    int t = 1;
    // cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<ll> dp(max(n + 1, 4), 0);
        dp[3] = 1;
        for (int i = 4; i <= n; ++i) {
        	dp[i] = 1;
        	for (int j = 3; j <= n; ++j) {
        		if (i - j >= 3) {
        			dp[i] = (dp[i] + dp[j]) % mod;
        		}
        	}
        }
        cout << dp[n];
    }

    return 0;
}

Measured memory_bytes: 3604
K=int(input())
A,B = map(int, input().split(" "))
counter=0
if (A<=1000) and B <=1000 and A<=B:
    for i in range(A,B+1):
        # print(i)
        if i%K == 0:
            counter=1
    if counter==1:
        print("OK")
    else:
        print("NG")

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int m[1010];

int main() {
  int n, x;
  cin >> n >> x;
  int sum = 0;
  int minval = 1e9;
  for (int i = 0; i < n; ++i) {
    cin >> m[i];
    sum += m[i];
    minval = min(minval, m[i]);
  }
  x -= sum;
  int res = n;
  for (int i = x; i >= minval; i -= minval) {
    ++res;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans = 1;
ll a[100005];

int main(void) {
    ll n;
    cin >> n;
    rep(i, 0, n) {
        cin >> a[i];
        if (a[i]==0) {
            puts("0");
            return 0;
        }
    }
/*
    rep(i, 0, n) {
        if (ans>((ll)1e18)/a[i]) {
            puts("-1");
            return 0;
        }
        ans *= a[i];
    } 
*/
    rep(i, 0, n) {
        if (__int128(ans)*a[i]>(ll)1e18) {
            puts("-1");
            return 0;
        }
        ans *= a[i];
    } 

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 4328
#!/usr/bin/env python3
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

from collections import defaultdict

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        self.all_group_member=defaultdict(list)
        for i in range(self.n):
            self.all_group_member[self.find(i)].append(i)
        return self.all_group_member

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n,q = map(int, input().split())
    uf=UnionFind(n)
    for _ in range(q):
        t,u,v=map(int, input().split())
        if t==0:
            uf.union(u,v)
        else:
            print(1 if uf.same(u,v) else 0)



if __name__ == '__main__':
    main()


Measured memory_bytes: 12236
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n;
    vector<int> a;
    Problem(LL n):n(n),a(n){};
    void no(){cout <<"No"<<"\n"; exit(0);}
    void yes(){cout <<"Yes"<<"\n"; exit(0);}
    void solve(){
        for(int i=0; i<n; ++i){
            cin >> a[i];
        }
        sort(a.begin(),a.end());
        int diff=a[n-1]-a[0];
        if(diff>=2)no();
        if(diff==0){
            if(a[0]*2<=n or a[0]==n-1) yes();
            else no();
        }


        //diff=1, a[0]+1 types
        int s=upper_bound(a.begin(),a.end(),a[0])-a.begin();
        int l=n-s;
        DBG(l,s)
        if((a[0]+1-s)>0 and  2*(a[0]+1-s)<=l)yes();
        else no();
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 640
n = int(input())
s = list(input())

w_sum = [0]
b_sum = [0]
for i in range(len(s)):
    if s[i] == '.':
        w_sum.append(w_sum[-1] + 1) 
        b_sum.append(b_sum[-1])
    else:
        b_sum.append(b_sum[-1] + 1)
        w_sum.append(w_sum[-1])

assert len(w_sum) == len(b_sum)
assert len(w_sum) == len(s) + 1

minSum = 10 ** 5
for i in range(len(s)):
    minSum = min(minSum, b_sum[i] + (w_sum[-1] - w_sum[i+1]))
    
print(minSum)

# .##...####... ->
# ......#######



Measured memory_bytes: 14184
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n,m;
vector<int> g[100005];
int ans;
int dp[100005];

int rec(int v) {
  if(dp[v] != -1) return dp[v];

  int res = 0;

  for(int i = 0; i < g[v].size(); i++) {
    res = max(res,rec(g[v][i]) + 1);
  }

  return dp[v] = res;
}

int main() {
  cin >> n >> m;

  for(int i = 0; i < m; i++) {
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
  }

  fill(dp,dp+n,-1);
  
  for(int i = 0; i < n; i++) {
    ans = max(ans,rec(i));
  }

  cout << ans << endl;
}


Measured memory_bytes: 8192
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int dp[2][512][501];
const int mod = 998244353LL;

int main() {
	int N, X; cin >> N >> X;
	for (int k = 0; k <= 500; ++k)
		dp[0][0][k] = 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j < 512; ++j) {
			for (int k = 0; k <= 500; ++k) {
				dp[i & 1][j][k] = dp[(i - 1) & 1][j ^ k][k];
				if (k)
					dp[i & 1][j][k] += dp[i & 1][j][k - 1];
				dp[i & 1][j][k] %= mod;
			}
		}
	}
	cout << dp[N & 1][X][X] << endl;
	return 0;
}


Measured memory_bytes: 5116
import java.util.Scanner;


public class Main {
    static Scanner s = new Scanner(System.in);
    static Pollock[] pol = new Pollock[1000000];
    static int count=0;

    static class Pollock{
        int all;
        int odd;

        Pollock(int all, int odd) {
            this.all = all;
            this.odd = odd;
        }
    }

    public static void main(String[] args) {
        pol[0]=new Pollock(0,0);
        while (true) {
            int N = s.nextInt();
            if (N == 0) break;

            if(N>count)
                calc(N);

            System.out.println(pol[N].all+" "+pol[N].odd);
        }
    }

    public static void calc(int N){
        while(count<N){
            calc_min(++count);
        }

    }

    public static void calc_min(int count){
        int i=1;
        int min_all=pol[count-1].all+1;
        int min_odd=pol[count-1].odd+1;

        while(true){
            i++;
            int tetrahedron=i*(i+1)*(i+2)/6;
            if(tetrahedron>count) break;

            min_all=Math.min(min_all,pol[count-tetrahedron].all+1);
            if(tetrahedron%2==1)
                min_odd=Math.min(min_odd,pol[count-tetrahedron].odd+1);
        }
        pol[count]=new Pollock(min_all,min_odd);
    }
}

Measured memory_bytes: 47892
#include<cstdio>

int main(){
    int count[1201];
    for(int i = 0; i < 1201; i++){
        count[i] = 0;
 	}
    char ch;
    while(scanf("%c",&ch) != EOF){
        if(ch >= 'a' && ch <= 'z'){
            count[ch-'a']++;
        }
        else if(ch >= 'A' && ch <= 'Z'){
            count[ch-'A']++;
        }
    }
    for(int j = 0;j < 26; j++){
        printf("%c : %d\n",j + 'a',count[j]);
    }
    return 0;
}


Measured memory_bytes: 2720
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
  lli arr[13];
  lli arrNext[13];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N= S.length();
  vector <int>m;
  int nowmod=0;
  int summod=1;
  REPR(i,N-1){
	  if (S[i]=='?'){
		  m.push_back(summod);
	  }else{
		  int p=S[i]-'0';
		 // cout <<p<<endl;
	//	  cout <<"  *  "<<summod*p<<endl;
		  nowmod+=summod*p;
		  nowmod%=13;
	  }
	  summod=(summod*10)%13;
  }
  arr[nowmod]=1;
 // cout <<nowmod<<" "<<m[0]<<" "<<m.size()<<endl;
 	REP(i,(int)m.size()){
		 lli val=m[i];
		 REP(j,10){
			 REP(k,13){
				 int nextk=	( val*j+k)%13;
				 arrNext[nextk]+=arr[k];
				 arrNext[nextk]%=MOD;
			 }
		 }
		 REP(j,13){
			 arr[j]=arrNext[j];
			 arrNext[j]=0;
	//		 cout <<arr[j]<<" ";
		 }
	//	 cout <<endl;
 	}
  cout <<arr[5]<<endl;
}

Measured memory_bytes: 1020
import java.util.*;
public class Main {

	static boolean isprime(int p){
		for (int i=2;i<p; i++){
			if(p%i==0){
				return false;
			}
		}
		return true;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int prime[]=new int[N];
		int j= N-1;
		for(int i=2; i<55555;i++){
			if(isprime(i)==true && i%5==1){
					prime[j]=i;
					j=j-1;
					if(j<0){
						break;
					}
			}
		}
	for(int i=N-1;i>=0;i--){
		System.out.print(prime[i]+" ");
	}
	System.out.println();
	}
}


Measured memory_bytes: 22868
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
double cur[3][3],next[3][3];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int X[9]={0,0,0,1,1,1,2,2,2};
int Y[9]={0,1,2,0,1,2,0,1,2};
int sx,sy,gx,gy,mx,my,n;
P to(int x,int y,int d)
{
	int nx=x+dx[d],ny=y+dy[d];
	if(nx<0||nx>=3||ny<0||ny>=3)return P(x,y);
	if(nx==mx&&ny==my)return P(x,y);
	return P(nx,ny);
}
int main()
{
	while(1)
	{
		cin >> n;
		if(n==0)break;
		char s,g,m;
		cin >> s >> g >> m;
		sx = X[s-'A']; sy = Y[s-'A'];
		gx = X[g-'A']; gy = Y[g-'A'];
		mx = X[m-'A']; my = Y[m-'A'];
		memset(cur,0,sizeof(cur));
		memset(next,0,sizeof(next));
		cur[sx][sy]=1.0;
		for(int t=0;t<n;t++)
		{
			for(int i=0;i<3;i++)
			{
				for(int j=0;j<3;j++)
				{
					for(int d=0;d<4;d++)
					{
						P ne = to(i,j,d);
						next[ne.fi][ne.sec]+=cur[i][j]/4.0;
					}
				}
			}
			memcpy(cur,next,sizeof(next));
			memset(next,0,sizeof(next));
		}
		printf("%.12f\n",cur[gx][gy]);
	}
	return 0;
}

Measured memory_bytes: 1184