akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll x(n);
    for (ll i = 0; i < n; i++) cin >> x[i];

    ll ans = HIGHINF;
    for (ll i = 1; i <= 100; i++) {
        ll tmp = 0;
        for (ll j = 0; j < n; j++) {
            tmp += (x[j] - i) * (x[j] - i);
        }
        chmin(ans, tmp);
    }
    cout << ans << '\n';
    return 0;
}


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

int main() {
  long long N, D;
  cin >> N >> D;
  
  vector<pair<long long, long long>> p(N);
  for (long long i = 0; i < N; i++) {
    long long a, b;
    cin >> a >> b;
    p.at(i) = make_pair(a, b);
  }
  
  vector<long long> l(N);
  for (long long i = 0; i < N; i++) {
    l.at(i) = p.at(i).first * p.at(i).first + p.at(i).second * p.at(i).second;
  }
  
  long long ans = 0;
  for (long long i = 0; i < N; i++) {
    if (l.at(i) <= D * D) {
      ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 7984
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};



void solve(){

    ll n;
    cin>>n;

    ll arr[n][3];

    rep(i,n){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }

    ll dp[n][3];
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];

    repA(i,1,n-1){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+arr[i][0];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+arr[i][1];
        dp[i][2] = max(dp[i-1][1],dp[i-1][0])+arr[i][2];
    }

    ll ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    db1(ans);

}
int main(){ 



int t=1;
//cin>>t;
while(t--){
 solve();
}
  return 0; 
}





Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;
    string s;
    cin >> s;

    char b = '*';
    int res = 0;
    REP(i,n)
    {
      if(b == s[i])continue;
      ++res;
      b = s[i];
    }

    cout << res << endl;


    return 0;    

}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int n;
    cin>>n;
    set<string>s;
    while(n--) {
        string ss;
        cin>>ss;
        s.insert(ss);
    }
    cout<<s.size()<<'\n';
    return 0;
    
}

Measured memory_bytes: 19244
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

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

    int x, y;
    cin >> x >> y;
    if (x == y) {
        cout << 0 << endl;
    } else if (x < y) {
        if (0 <= x) {
            cout << y - x << endl;
        } else if (x < 0 && 0 < y) {
            if (abs(x) <= abs(y)) {
                cout << 1 + abs(y) - abs(x) << endl;
            } else {
                cout << abs(x) - abs(y) + 1 << endl;
            }
        } else {
            cout << y - x << endl;
        }
    } else {
        if (0 < y) {
            cout << 1 + abs(x) - abs(y) + 1 << endl;
        } else if (y == 0) {
            cout << 1 + abs(x) << endl;
        } else if (y < 0 && 0 < x) {
            if (abs(x) < abs(y)) {
                cout << abs(y) - abs(x) + 1 << endl;
            } else {
                cout << abs(x) - abs(y) + 1 << endl;
            }
        } else if (x < 0) {
            cout << 1 + abs(y) - abs(x) + 1 << endl;
        } else {
            cout << abs(y) + 1 << endl;
        }
    }

    return 0;
}


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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 200500, inf = 1e9 * 2;

const ll MOD = 1e9 + 7ll, INF = 1e18;

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

int mod;

int dp[N], ans[N];

vector<int> g[N];

void dfs1(int v, int pr) {
	for (auto u : g[v]) {
		if (u == pr) continue;
		dfs1(u, v);
	}
	dp[v] = 1;
	for (auto u : g[v]) {
		if (u == pr) continue;
		dp[v] = (dp[v] * 1ll * (dp[u] + 1)) % mod;
	}
}

void dfs2(int v, int pr, int up) {
	ans[v] = ((up + 1) * 1ll * dp[v]) % mod;
	for (int i = 0; i < SZ(g[v]); i++) {
		if (g[v][i] == pr) {
			swap(g[v][i], g[v][SZ(g[v]) - 1]);
			break;
		}
	}
	vector<int> suff(SZ(g[v]), 1);
	for (int i = SZ(g[v]) - 3; i >= 0; i--) { 
		suff[i] = ((dp[g[v][i + 1]] + 1) * 1ll * suff[i + 1]) % mod;
	}
	int pref = (up + 1);
	for (int i = 0; i < SZ(g[v]) - 1; i++) {
		int u = g[v][i];
		dfs2(u, v, (pref * 1ll * suff[i]) % mod);
		pref = (pref * 1ll * (dp[u] + 1)) % mod;
	}
}

int main() {
	FREOPEN();
	int n;
	cin >> n >> mod;
	g[1].pb(0);
	for (int i = 1; i < n; i++)	{
		int x, y;
		scanf("%d %d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs1(1, 0);
	dfs2(1, 0, 0);
	for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 18304
sheet_size = [int(i) for i in input().split()]
rows = sheet_size[0]
columns = sheet_size[1]

spread_sheet = []

for j in range(rows):
    row =  [int(i) for i in input().split()]
    row.append(sum(row))
    spread_sheet.append(row)

additional_row = []
for c in range(columns+1):
    column_value = 0
    for row in spread_sheet:
        column_value += row[c]
    additional_row.append(column_value)

spread_sheet.append(additional_row)


for row in spread_sheet:
    str_row = list(map(str, row))
    print(' '.join(str_row))


Measured memory_bytes: 5684
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b;
  cin >> a >> b;
  if (b%a == 0) cout << a+b << endl;
  else cout << b-a << endl;
  return 0;
}


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

int digit(ll x){
  int p=0;
  while(x>0){
    x/=10;
    p++;
  }
  return p;
}

int main(){
  ll x;
  cin>>x;
  int ans=20;
  for(ll i=1;i*i<=x;i++){
    if(x%i==0){
      ans=min(ans,max(digit(x/i),digit(i)));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N=int(input())
XY=[list(map(int,input().split())) for i in range(N)]
from itertools import combinations
a=9999
def f(X,Y,R2,a):
    if all([(X-x)**2+(Y-y)**2<R2 for x,y in XY]):
        a=min(a,R2**.5)
    return a
for (x1,y1),(x2,y2),(x3,y3) in combinations(XY,3):
    e1=(x2-x3)**2+(y2-y3)**2
    e2=(x3-x1)**2+(y3-y1)**2
    e3=(x1-x2)**2+(y1-y2)**2
    p=e1*(e2+e3-e1)
    q=e2*(e3+e1-e2)
    r=e3*(e1+e2-e3)
    if p+q+r==0:continue
    X=(p*x1+q*x2+r*x3)/(p+q+r)
    Y=(p*y1+q*y2+r*y3)/(p+q+r)
    R2=(X-x1)**2+(Y-y1)**2+10e-9
    a=f(X,Y,R2,a)
for (x1,y1),(x2,y2) in combinations(XY,2):
    X=(x1+x2)/2
    Y=(y1+y2)/2
    R2=(X-x1)**2+(Y-y1)**2+10e-9
    a=f(X,Y,R2,a)
print(a)

Measured memory_bytes: 3188
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  string s ;
  cin >> s ;
  
     int count = 0 ;
  
  if(s.at(0)!='A'){
    cout << "WA" ;
    return 0 ;
  }else{
   for(int i=2;i<(s.size()-1);i++){
    if(s.at(i)=='C'){
        count++ ;
      }
    }
  }
   
   if(count==1){
   for(int i=1;i<=(s.size()-1);i++){
     if(isupper(s.at(i))){
       count++ ;
     }
    } 
   }else{
    cout << "WA" ;
    return 0 ;
   }
  
  if(count==2){
   cout << "AC" ;
    return 0 ;
  }else{
   cout << "WA" ;
    return 0 ;  
  }
    
}


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

int d[31][31];
int board[501][501];
int f[31];
int s[31];
int t[31];

int dfs(int first,int second,int third){
    
    int sum = 0;
    
    for(int i=1;i<=30;i++) {
        
        sum += f[i] * d[i][first];
        sum += s[i] * d[i][second];
        sum += t[i] * d[i][third];
    }
    
    return sum;
    
    
}
int main(int argc, const char * argv[]) {
    
    int n,c;
    
    scanf("%d %d",&n,&c);
    
    for(int i=1;i<=c;i++){
        for(int j=1;j<=c;j++){
            scanf("%d",&d[i][j]);
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            scanf("%d",&board[i][j]);
            int tmp = (i+j)%3;
            if(tmp==0) f[board[i][j]]++;
            else if(tmp==1) s[board[i][j]]++;
            else t[board[i][j]]++;
        }
    }
    int ans = 987654321;
    for(int i=1;i<=c;i++){
        for(int j=1;j<=c;j++){
            if(i==j) continue;
            for(int k=1;k<=c;k++){
                if(i==k || j==k) continue;
                int tmp = dfs(i,j,k);
                if(ans > tmp) ans = tmp;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1152
<?php
$n=trim(fgets(STDIN));
$min=trim(fgets(STDIN));
$MAX=-$min;
for($i=1;$i<$n;$i++){
  $R=trim(fgets(STDIN));
  if($MAX<$s=$R-$min) $MAX=$s;
  if($min>$R) $min=$R;
}
print $MAX;
?>

Measured memory_bytes: 15384
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <map>
#include <queue>
#include <cstring>
#include <set>
#include <stack>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
    	int n,k; cin >> n >> k;
    	if(n==0&&k==0)break;
    	vector<int> a;
    	bool all=0;
    	for(int i=0;i<k;i++){
    		int b; cin >> b;
    		if(b==0)all=1;
    		else a.push_back(b);
    	}
    	if(all)k--;
    	sort(a.begin(),a.end());
    	int ans=1;
    	if(!all){
    		for(int i=0;i<k;i++){
    			int res=1;
    			while(i<k-1&&a[i]+1==a[i+1]){
    				i++;
    				res++;
    			}
    			ans=max(ans,res);
    		}
    	}else{
    		for(int i=0;i<k;i++){
    			int res=1;
    			while(i<k-1&&a[i]+1==a[i+1]){
    				i++;
    				res++;
    			}
    			int cp=i;
    			if(i<k-1&&a[i]+2==a[i+1]){
    				i++; res+=2;
    				while(i<k-1&&a[i]+1==a[i+1]){
    					i++;
    					res++;
    				}
    			}else{
    				res++;
    			}
    			i=cp;
    			ans=max(ans,res);
		    }
	    }
	    cout << ans << endl;
    }
}



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

const int MAX_N = 5000;
const int MAX_A = 5000; 

long long dp[MAX_N+1][MAX_A+1][2];

void solve(long long N, long long T, std::vector<long long> A, std::vector<long long> B){
    for(long long i =0;i<N;i++){
        for(long long j=0;j<T;j++){
            if(j < A[i]){
                dp[i+1][j][0] = dp[i][j][0];
                dp[i+1][j][1] = max(dp[i][j][1],dp[i][j][0] + B[i]);
                continue;
            }
            dp[i+1][j][0] = max(dp[i][j][0],dp[i][j - A[i]][0] + B[i]);
            dp[i+1][j][1] = max(dp[i][j][0] + B[i],max(dp[i][j - A[i]][1] + B[i],dp[i][j][1]));
            // cerr << "i= " << i << "j = " << j <<  "value = " << dp[i+1][j][1] << endl;

        }
    }
    cout << dp[N][T-1][1] << endl;

}

// 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)
int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, T, std::move(A), std::move(B));
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //freopen("data.in", "r", stdin);
  int n;
  cin >> n;
  int c = n%10;
  if (c == 3){
    cout << "bon" << endl;
  }else if (c == 0 || c == 1 || c == 6 || c == 8) {
    cout << "pon" << endl;
  }else {
    cout << "hon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;

  ll ans = N - 1;
  
  for (ll i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      ll j = N / i;
      ans = min(ans, (i + j) - 2);
    }      
  }

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    cout << N*(N-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 A, B;
  std::cin >> A >> B;
  std::cout << A * B << std::endl;
  return 0;
}

Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0) {
				break;
			}

			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					if(i == 0 || j == 0 || i == (H-1) || j == (W-1)) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 34248
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> a(N);
    int ans = 0;
    for(int i=0; i<N; i++) {
        cin >> a[i];
        if(i%2 == 0 && a[i]%2) ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n, k;
	int a[101], dp[100001];
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	for(int i = 0; i <= k; i++){
		dp[i] = 0;
		for(int j = 1; j <= n && a[j] <= i; j++){
			if(dp[i - a[j]] == 0){
				dp[i] = 1;
				break;
			}
		}
	}
	cout << (dp[k] == 1 ? "First" : "Second") << '\n';
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
double dis;
void dfs(vector<int>& path,vector<pair<int,int>>& vec,int curr){
  if(curr == n){
    //for(int i=0;i<n;++i)cout<<path[i]<<" ";cout<<endl;
    
    for(int j=0;j<n-1;++j){
      int i = path[j];
      int k = path[j+1];
      dis += sqrt(
        (vec[i].first-vec[k].first)*(vec[i].first-vec[k].first) +
        (vec[i].second-vec[k].second)*(vec[i].second-vec[k].second)
      );
    }
    
  }
  for(int i=curr;i<n;++i){
    swap(path[curr],path[i]);
    dfs(path,vec,curr+1);
    swap(path[curr],path[i]);
  }
}
int main(){
  cin>>n;
  dis = 0.0;
  vector<pair<int,int>> vec(n);
  for(int i=0;i<n;++i){
    int a,b;cin>>a>>b;
    vec[i] = make_pair(a,b);
  }
  vector<int> path;
  for(int i=0;i<n;++i)path.push_back(i);
  dfs(path,vec,0);
  int tm = 1;
  for(int i=1;i<=n;++i)tm *= i;
  cout<<fixed<<dis/tm<<endl;
  
  return 0;
}

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

static const int MAXP = 1000;
vector<int> ps, fs;
void init(){
  fs.reserve(1 + MAXP);
  for(int i = 0; i <= MAXP; i++){fs.push_back(i);}
  for(int i = 2; i <= MAXP; i++){
    if (fs[i] == i){
      ps.push_back(i);
      for (int j = i; j <= MAXP; j += i){
        fs[j] = min(fs[j], i);
      }
    }
  }
}
static const int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define INT(n) int n;assert(0<scanf("%d",&n))

int main(){
  init();
  INT(n);
  ui ans = 1;
  for(int p: ps){
    if (n < p){break;}
    int cnt = 0, tmp = n;
    while(0 < tmp){
      cnt += tmp / p;
      tmp /= p;
    }
    ans = ((ll) ans * (cnt + 1)) % MOD;
  }
  printf("%u\n", ans);
  return 0;
}

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

using namespace std;

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

    vector<int> child[N];
    int innum[N];  // 入次数
    fill(innum, innum + N, 0);

    for (int i = 0; i < N + M - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        child[u].push_back(v);
        ++innum[v];
    }

    // 入次数が最小=0な頂点が根となる
    int r = min_element(innum, innum + N) - innum;

    int par[N];
    fill(par, par + N, -1);
    queue<int> que;
    que.push(r);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (int sv : child[v]) {
            par[sv] = v;

            // これ以上入ってくる辺がなくなったら探索開始
            if (--innum[sv] == 0) que.push(sv);
        }
    }

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

    return 0;
}


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

typedef long long ll;

int main() {
    string T;
    cin >> T;
    for (int i = 0; i < T.size(); i++) {
        if (T[i] == '?') {
            T[i] = 'D';
        }
    }
    cout << T << endl;
}


Measured memory_bytes: 3712
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			String S = sc.next();
			int rem = 0;
			int ten = 1;
			int[] ret = new int[2019];
			int res = 0;
			
			for(int i=S.length()-1;i>=0;i--) {
				int num = S.charAt(i)-'0';
				rem += num*ten%2019;
				rem%=2019;
				ret[rem]++;
				
				ten = ten*10%2019;
			}
			
			res+=ret[0];
			
			for(int i=0;i<2019;i++) {
				res+=ret[i]*(ret[i]-1)/2;
			}
			
			System.out.println(res);
	    }
				
	}


Measured memory_bytes: 40548
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
 
var inputs = chunk.toString().trim().split('\n').map(Number);
for (var i = 0; i < inputs .length; i++) {
        if (inputs [i] === 0) {
            break;
        }
        console.log('Case ' + (i + 1) + ': ' + inputs[i]);
}
 
 
});

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

using namespace std;

int main(){
  int x, n, ans;
  vector<int> vc(110, 0);
  cin >> x >> n;
  for(int i=0; i<n; i++){
      int p;
      cin >> p;
      vc[p]++;
  }
  int i, k;
  i = k = x;
  while(true){
     if(vc[i] == 0){
       ans = i;
       break;
     }else if(vc[k] == 0){
        ans = k;
        break;
     }else{
        i--;
        k++;
     }
  }

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


Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 123456;

int main() {
    int N;
    while (~scanf("%d", &N)) {
          int px = 0, py = 0, pt = 0;
          bool ans = true;
          for (int i = 0; i < N; i++) {
              int t, x, y;
              scanf("%d %d %d", &t, &x, &y);
              int dx = abs(x - px);
              int dy = abs(y - py);
              if (dx + dy > t - pt) ans = false;
              if ((dx + dy - t + pt) % 2) ans = false;
              px = x, py = y, pt = t;
          }
          puts(ans ? "Yes" : "No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K, S;
    cin >> K >> S;
    int count = 0;
    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K; j++){
            if(S - i - j >= 0 && S - i - j <= K) count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      int n;
      int t1=0,x1=0,y1=0,t2,x2,y2,d;
      cin>>n;
      bool f=true;
      for(int i=0;i<n&&f;i++){
        cin>>t2>>x2>>y2;
        d=abs(x2-x1)+abs(y2-y1);
        if(d<=t2-t1&&(t2-t1)%2==d%2)
          continue;
        else
          f=false;
        t1=t2;x1=x2;y1=y2;
      }
      cout<<(f?"Yes":"No")<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(v) ((int)(v).size())
const int MAXN = 10000005;
const int mod = 998244353;
using lint = long long;
lint ipow(lint x, lint p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

lint fact[MAXN], invf[MAXN], pwr[MAXN];

lint binom(int x, int y){
	return fact[x] * (invf[y] * invf[x-y] % mod) % mod;
}

int main() { 
	int n; cin >> n;
	fact[0] = pwr[0] = 1;
	for(int i=1; i<=n; i++){
		pwr[i] = (pwr[i-1] << 1) % mod;
		fact[i] = fact[i-1] * i % mod;
	}
	invf[n] = ipow(fact[n], mod - 2);
	for(int i=n-1; i>=0; i--){
		invf[i] = invf[i + 1] * (i + 1) % mod;
	}
	lint ans = 0;
	for(int i=0; i<n/2; i++){
		ans += pwr[i+1] * binom(n, i) % mod;
	}
	ans %= mod;
	ans = ipow(3, n) - ans + mod;
	cout << ans % mod << endl;
}


Measured memory_bytes: 234624
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    string A[55], B[55];
    rep(i,0,N) cin >> A[i];
    rep(i,0,M) cin >> B[i];
    rep(i,0,N-M+1){
        rep(j,0,N-M+1){
            bool ok = true;
            rep(n,0,M){
                rep(m,0,M){
                    if(B[n][m] != A[i+n][j+m]){
                        ok = false;
                    }
                }
            }
            if(ok){
                print("Yes");
                return 0;
            }

        }
    }
    print("No");
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::char::*;
use std::cmp::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed 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")
}

const MAX:usize = 100006;
static mut ans: f64 = 0.0;

fn dfs(n: i32, a: &Vec<(i32,i32)>, s: i32, f: &mut Vec<bool>, sum: f64, depth: i32) {
    //println!("s:{}, depth:{}", s, depth);
    f[s as usize] = true;
    if depth == n-1 {
        f[s as usize] = false;
        unsafe{ans += sum;}
        return ();
    }
    for i in 0..n {
        if(f[i as usize]) {continue};
        let d_x:f64 = (a[i as usize].0 - a[s as usize].0).pow(2) as f64;
        let d_y:f64 = (a[i as usize].1 - a[s as usize].1).pow(2) as f64;
        let dist = (d_x + d_y).sqrt();
        
        //println!("i:{}: dist:{}", i, dist);
        dfs(n, a, i, f, sum+dist, depth+1);
    }
    f[s as usize] = false;
}

fn main(){
    let n:i32 = read();
    let a:Vec<(i32,i32)> = (0..n).map(|_| (read(),read())).collect();

    for i in 0..n {
        let mut f:Vec<bool> = vec![false;MAX];
        unsafe {
            //println!("ans_before:{}", ans);
            f[i as usize] = true;
            dfs(n, &a, i, &mut f, 0.0, 0);
            //println!("ans_after:{}", ans);
        }
    }
    let mut p:f64 = 1.0;
    for i in 0..n { p *= (i+1) as f64 }
    unsafe{println!("{}", format!("{:.12}",ans/p));}
}

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

using namespace std;

int main(){
    int n;cin>>n;
    for(int i=0;i<n;++i){
        vector<int>v(3);
        cin>>v[0]>>v[1]>>v[2];
        sort(v.begin(),v.end());
        if(v[0]*v[0]+v[1]*v[1]==v[2]*v[2])cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string S; cin >> S;
    int Q; cin >> Q;
    bool rev = false;

    for (int i = 0; i < Q; i++) {
        int query; cin >> query;
        if (query == 1) {
            if (rev) rev = false;
            else rev = true;
        } else {
            int F; char C; cin >> F >> C;
            if (F == 1) {
                if (rev)
                    S += C;
                else
                    S.insert(S.begin(), C);
            } else {
                if (rev)
                    S.insert(S.begin(), C);
                else
                    S += C;
            }
        }
    }

    if (rev) {
        reverse(S.begin(), S.end());
    }
    cout << S << endl;

}


Measured memory_bytes: 900
import sys
readline = sys.stdin.readline
import collections
class Dinic:
    def __init__(self, vnum):
        self.edge = [[] for i in range(vnum)]
        self.n = vnum
        # infはint型の方が良いかもね
        self.inf = float('inf')
    def addedge(self, st, en, c):
        self.edge[st].append([en, c, len(self.edge[en])])
        self.edge[en].append([st, 0, len(self.edge[st])-1])
    def bfs(self, vst):
        dist = [-1]*self.n
        dist[vst] = 0
        Q = collections.deque([vst])
        while Q:
            nv = Q.popleft()
            for vt, c, r in self.edge[nv]:
                if dist[vt] == -1 and c > 0:
                    dist[vt] = dist[nv] + 1
                    Q.append(vt)
        self.dist = dist
    def dfs(self, nv, en, nf):
        nextv = self.nextv
        if nv == en:
            return nf
        dist = self.dist
        ist = nextv[nv]
        for i, (vt, c, r) in enumerate(self.edge[nv][ist:], ist):
            if dist[nv] < dist[vt] and c > 0:
                df = self.dfs(vt, en, min(nf, c))
                if df > 0:
                    self.edge[nv][i][1] -= df
                    self.edge[vt][r][1] += df
                    return df
            nextv[nv] += 1
        return 0
    def getmf(self, st, en):
        mf = 0
        while True:
            self.bfs(st)
            if self.dist[en] == -1:
                break
            self.nextv = [0]*self.n
            while True:
                fl = self.dfs(st, en, self.inf)
                if fl > 0:
                    mf += fl
                else:
                    break
        return mf


N, M = map(int, readline().split())

G = [[1 if s == '#' else 0 for s in readline().strip()] for _ in range(N)]

T = Dinic(2*N*M+2)
st = 2*N*M
en = st+1
geta = N*M
DIREC = ((1, 0), (-1, 0), (0, 1), (0, -1))


for i in range(N):
    for j in range(M):
        if not G[i][j]:
            if (i+j)%2:
                T.addedge(st, i*M+j, 1)
                for di, dj in DIREC:
                    ni, nj = i+di, j+dj
                    if 0 <= ni < N and 0 <= nj < M and not G[ni][nj]:
                        T.addedge(i*M+j, geta + ni*M+nj, 1)
            else:
                T.addedge(geta + i*M+j, en, 1)

print(T.getmf(st, en))

Ans = [g[:] for g in G]

for i in range(N):
    for j in range(M):
        if not (i+j)%2 and not G[i][j]:
            for vf, c, _ in T.edge[geta + M*i+j]:
                if c == 1 and vf != en:
                    ni, nj = divmod(vf, M)
                    if i == ni:
                        if j < nj:
                            Ans[i][j] = 2
                            Ans[ni][nj] = 3
                        else:
                            Ans[i][j] = 3
                            Ans[ni][nj] = 2
                    else:
                        if i < ni:
                            Ans[i][j] = 4
                            Ans[ni][nj] = 5
                        else:
                            Ans[i][j] = 5
                            Ans[ni][nj] = 4

D = ['.', '#', '>', '<', 'v', '^']

print('\n'.join(''.join(D[ai] for ai in a) for a in Ans))      

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


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

long long n, sum = 0;
vector<long long> a;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) sum += a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = (long long)(1e18), now = 0;
  for(int i = 0; i < n; ++i) {
    now += a[i];
    ans = min(ans, abs(sum - 2 * now));
  }
  return ans;
}

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

int main() {
  int N; cin >> N;
  int A[110];
  for (int i = 0; i < N; i++)
    cin >> A[i];
  
  int B[13] = {};
  for (int i = 0; i < N; i++) {
    int ai = A[i];
    B[ai / 400]++;
  }
  
  int mn = 0, mx = 0;
  for (int j = 0; j <= 7; j++) {
    if (B[j] >= 1) {
      mn++;
      mx++;
    }
  }
  if (mn == 0) mn++;
  
  for (int j = 8; j < 13; j++)
    mx += B[j];
  
  cout << mn << " " << mx << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(){
    int n,k,q;
    scanf("%d %d %d",&n,&k,&q);
    int i,j;

    int player[100000];
    int ans;
    for(i=0;i<n;i++){
        player[i]=0;
    }

    for(i=0;i<q ;i++){
        scanf("%d",&ans);
        player[ans-1]++;
    }
    for(i=0;i<n;i++){
        if(player[i] - q + k >0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    return 0;
}

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

//部分列判定 -> 場所i以降で文字Cが最初に現れる位置を保存しておく
//各文字が文字列のどの位置にあるかのリストを作る
int main(){
  string s, t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);
  vector<vector<int> > is(26);
  rep(i,n) is[s[i] - 'a'].push_back(i);
  rep(i,n) is[s[i] - 'a'].push_back(i + n);
  ll res = 0;
  int p = 0; // p以降
  rep(i,m) {
    int c = t[i] - 'a';
    if (sz(is[c]) == 0) {
      puts("-1");
      return 0;
    }
    p = *lower_bound(is[c].begin(),is[c].end(), p) + 1;//文字ｃが何文字目にあるか
    if (p >= n) {
      p -= n;
      res += n;
    }
  }
  res += p;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1724
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		no1();
	}
 
	static void no1() {
		try (Scanner sc = new Scanner(System.in)) {
			Integer N = sc.nextInt();
 
			Integer a = N / 1000;
			Integer b = (N-a*1000) /100;
			Integer c = (N-a*1000-b*100)/10;
			Integer d = (N-a*1000-b*100-c*10);
 
			if ((a==b && b ==c) || (b ==c && c ==d))
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


def solve(A: int, B: int):
    print(A * B // 100)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens).replace('.', ''))  # type: float
    solve(A, B)


if __name__ == '__main__':
    main()


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 2e3 + 5;

int DP[3 * N][N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	int n, m; cin >> n >> m;
	DP[0][0] = 1;
	for (int i = 1; i <= 3 * n; i++) for (int j = 0; j <= (i >> 1); j++) {
		DP[i][j] = DP[i - 1][j];
		if (j && i >= 2) DP[i][j] = (DP[i][j] + 1LL * (i - 1) * DP[i - 2][j - 1] % m) % m;
		if (j && i >= 3) DP[i][j] = (DP[i][j] + 1LL * (i - 1) * (i - 2) % m * DP[i - 3][j - 1] % m) % m;
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) ans = (ans + DP[3 * n][i]) % m;
	cout << ans << endl;


	return 0;
}


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        a: [usize; 5]
    }
    let v = a.iter().filter(|&v| v % 10 > 0).map(|v| v % 10).min().unwrap_or(0);
    let sum = a.iter().map(|&v| {
        if v % 10 == 0 {
            v
        } else {
            v / 10 * 10 + 10
        }
    }).fold(0, |sum, v| sum + v);
    println!("{}", if v > 0 { sum - 10 + v } else { sum });
}


Measured memory_bytes: 4352
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    static StringBuffer sb = new StringBuffer();
    public static void main(String args[]){
        int N=sc.nextInt(),sum=0,min=Integer.MAX_VALUE;
        for(int i=0;i<N;i++){
            int s=sc.nextInt();
            sum+=s;
            if(s%10!=0) min=Math.min(min,s);
        }
        if(min==Integer.MAX_VALUE) System.out.println(0);
        else System.out.println(sum%10!=0?sum:sum-min);
    }
}

Measured memory_bytes: 35932
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long dp[100010][4];
int main()
{
    string s;
    cin>>s;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='?')
        {
            dp[i+1][3]=(3*dp[i][3]+dp[i][2])%mod;
            dp[i+1][2]=(3*dp[i][2]+dp[i][1])%mod;
            dp[i+1][1]=(3*dp[i][1]+dp[i][0])%mod;
            dp[i+1][0]=3*dp[i][0]%mod;
        }
        else if(s[i]=='A')
        {
            dp[i+1][1]=(dp[i][1]+dp[i][0])%mod;
            dp[i+1][2]=dp[i][2];
            dp[i+1][3]=dp[i][3];
            dp[i+1][0]=dp[i][0];
        }
        else if(s[i]=='B')
        {
            dp[i+1][2]=(dp[i][2]+dp[i][1])%mod;
            dp[i+1][1]=dp[i][1];
            dp[i+1][3]=dp[i][3];
            dp[i+1][0]=dp[i][0];
        }
        else
        {
            dp[i+1][3]=(dp[i][3]+dp[i][2])%mod;
            dp[i+1][1]=dp[i][1];
            dp[i+1][2]=dp[i][2];
            dp[i+1][0]=dp[i][0];
        }
    }
    cout<<dp[s.size()][3]<<endl;
    return 0;
}


Measured memory_bytes: 3584
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = 1
if 0 in a:
    ans = 0
    print(ans)
    exit()
else:
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
print(ans)


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

const int maxn=1000005;
const int zzh=998244353;

inline int read(){
	register int x=0,w=1,ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')w=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-48;
	return w*x;
}

int n,m;
int fac[maxn],ifac[maxn];

inline int pow(int a,int b,int p){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%p)
		if(b&1)ans=1ll*ans*a%p;
	return ans;
}

inline void prework(){
	fac[0]=ifac[0]=1;
	for(int i=1;i<=1000000;i++)fac[i]=1ll*fac[i-1]*i%zzh;
	ifac[1000000]=pow(fac[1000000],zzh-2,zzh);
	for(int i=999999;i>=1;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%zzh;
}

inline int C(int n,int m){
	return 1ll*fac[n]*ifac[n-m]%zzh*ifac[m]%zzh;
}

int main(){
	prework();
	n=read(),m=read();
	int ans=0;
	for(int i=1;i<=min(n,m);i++)
		ans=(ans+1ll*C(2*i,i)*C(n+m-2*i,n-i)%zzh)%zzh;
	ans=1ll*ans*pow(C(n+m,n),zzh-2,zzh)%zzh*pow(2,zzh-2,zzh)%zzh;
	cout<<(ans+max(n,m))%zzh<<'\n';
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;
  cin >> n >> k;

  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
    --a[i];
  }
  int cp = 0;
  ll cyc = 1;
  ll times = 1;
  map<int,int> used;
  used[cp] = 1;
  while(used[a[cp]]==0){
    used[a[cp]] = ++times;
    cp = a[cp];
  }
  cyc = times - used[a[cp]] + 1;
  ll offset = used[a[cp]] - 1;
  // cout << offset << " " << cyc << endl;
  ll st = 0;
  if(k > offset){
    st = a[cp];
    k -= offset;
    k%=cyc;
  }
  int ans = st;
  while(k>0){
    ans = a[ans];
    k--;
  }
  cout << ans+1 << endl;

  return 0;
    

}


Measured memory_bytes: 13160
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int N=0,m=0,c=0;
  cin >> N;

  int p[N]={0};
  for(int i=0;i<N;++i){
    cin >> p[i];
  }
  
  sort(p, p+N);

  for(int i=0;i<N-1;++i){
    c += p[i];
  }

  cout << c + p[N-1]/2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod.m での a の逆元 a^ { -1 } を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x /gcd(x, y) * y );
}

ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
char c[2010][2010];
ll sum[2010][2010];
ll res[10][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, k;
	cin >> n >> k;
	double ans = 0;
	for (ll i = 1;i <= n;++i) {
		double res = 1 / (double)n;
		ll res2 = i;
		while (res2 < k) {
			res /= (double)2;
			res2 *= 2;
		}
		ans += res;
	}
	exout(ans);
	return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n,imos[100010];

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

	cin>>n;
	REP(i,n) {
		int a,b;cin>>a>>b;
		imos[a]++,imos[b+1]--;
	}
	REP(i,100000) imos[i+1]+=imos[i];
	int ans=0;
	REP(i,n+2) {
		if(imos[i]+1>=i) ans=max(ans,i);
	}
	cout<<max(0,ans-1)<<endl;

	return 0;
}



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

#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 INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> A(m);
  set<int> s;
  rep(i,m){
    int tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  vector<ll> W(n+1,0);//W(i)はi段目までの生き方
  W.at(0)=1;
  rep1(i,n+1){
    if(s.count(i))continue;
    else{
      //段差踏める。
      if(!s.count(i-1))W.at(i)=W.at(i-1)%MOD;
      if(i-2>=0&&!s.count(i-2))W.at(i)+=(W.at(i-2)%MOD);
    }
  }
  cout<<W.at(n)%MOD<<endl;
}

Measured memory_bytes: 6144
#include <stdio.h>

int main(void){
    char line[100];
    int i=0,sign=0;
    scanf("%s",line);
    while(line[i]){
        if(line[i] == '9')
            sign=1;
        i++;
    }
    if(sign)
        puts("Yes");
    else
        puts("No");


  return 0;
}


Measured memory_bytes: 128
my $N = <STDIN>;
my $str = <STDIN>;
@s = split(/ /,$str);
#print "$s";

my @sorted;
@sorted= sort { $a <=> $b } @s;

my $flag = 0;
my @flagnum= ();
for(my $i=0;$i<=$#s;$i++ ){
  if( $s[$i] == $sorted[$i]){
     
  }else{
     $flag++;
  }
}

if($flag > 2){
  print "NO\n";
}elsif($flag == 2){
  print "YES\n";

}elsif($flag == 1){
  #print "okasii\n";
}else{
  print "YES\n";
}



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

using namespace std;
int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  int m1 = max(max(a1, a2), a3);

  if (a1 == m1) {
    a1 = 0;
  } else if (a2 == m1) {
    a2 = 0;
  } else if (a3 == m1) {
    a3 = 0;
  }
  int m2 = max(max(a1, a2), a3);
  int result = m1 - m2;

  if (a1 != m1 && a1 != m2 && a1 != 0) {
    result += m2 - a1;
  }
  if (a2 != m1 && a2 != m2 && a2 != 0) {
    result += m2 - a2;
  }
  if (a3 != m1 && a3 != m2 && a3 != 0) {
    result += m2 - a3;
  }

  cout << result << endl;
  return 0;
}


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

int main()
{
	char string[10];
	cin >> string;
	int total = 700;
	for (int i = 0 ; i < 3 ; ++i)
	{
		if (string[i] == 'o')
			total += 100;
	}
	cout << total << "\n";
	return 0;
}

Measured memory_bytes: 256