akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  float r;
  cin>>r;
  float ans;
  ans=2*M_PI*r;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3800
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int N = reader.nextInt();
		int T = reader.nextInt();
		int A = reader.nextInt();
		int[] H = new int[N];
		for(int i=0; i<N; i++) {
		    H[i] = reader.nextInt();
		}
		int ans     = -1;
		double diff = 1000000;
		for(int i=0; i<N; i++) {
		    double tmp = Math.abs((double)T-(double)H[i]*0.006-(double)A);
		    if (tmp < diff) {
		        ans = i+1;
		        diff = tmp;
		    }
		}
		System.out.println(ans);
	}
	
	public static void solver(int H, int W, boolean[][] matrix) {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 21588
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int min, maxDiff = 1 << 31;
  maxDiff *= -1;
  cin >> min;
  for (int i = 1; i < n; i++) {
    int r;
    cin >> r;
    if (r - min > maxDiff) {
      maxDiff = r - min;
    }
    if (r < min) {
      min = r;
    }
  }
  cout << maxDiff << endl;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 40;
int n,ma,mb;
int dp[maxn][maxn*10+1][maxn*10+1],a[maxn],b[maxn],c[maxn];
int solve(int i,int x,int y){
	if( i == n )return  x && x * mb == y * ma ? 0 : 1e18;
	int & ans = dp[i][x][y];
	if( ans != -1 )return ans;
	ans = 1e18;
	ans = min( ans , solve(i+1,x,y) );
	ans = min( ans , c[i] + solve(i+1,x+a[i],y+b[i]) );
	return ans;
}
int32_t main(){
	IOS
	memset(dp,-1,sizeof(dp));
	cin>>n>>ma>>mb;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	int ans = solve(0,0,0);
	cout << ( ans < 1e18 ? ans : -1 ) << endl;
 }
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 53848
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()

a, b, c = ds_in()
print(a * b // 2)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int n, d; cin >> n >> d;

    cout << (n + (d * 2)) / (d * 2 + 1) << endl;
    return 0;
}



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

int main() {
  
  int r, g, b;
  cin >> r >> g >> b ;
  
  if (g%2 == 0 && b%4 == 0) {
    cout << "YES" << endl;
  }
  else if (g%2 == 1 && b%4 == 2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  
  
return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;

ll n;

void solve() {
  // N = mx + y where y < m
  // N mod m = y, [N / m] = x thus N = (m + 1)y where y < m
  vector<ll> v;
  for (ll i = 1;i<sqrt(n);i++) {
    if (n % i == 0 && n / i - 1 > i) {
      v.push_back(n / i - 1);
    }
  }
  ll ans = 0;
  for (int i=0;i<v.size();i++) {
    ans += v[i];
  }
  cout << ans << endl;
}

int main() {
  cin >> n;
  solve();
}


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

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

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

int main() {
    int64_t N;
    cin >> N;
    vector<string> S(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> S[i];
    }
    
    multiset<pair<int64_t,int64_t>> add,del;
    for ( int64_t i = 0; i < N; ++i){
        int64_t cur = 0, mi = 0;
        for ( auto c: S[i]) {
            if ( c == '(' ) ++cur;
            else --cur;
            mi = min(mi,cur);
        }
        if ( cur >= 0 ) add.insert({-mi,cur});
        else del.insert({-mi+cur,-cur});
    }
    
    int64_t cur = 0;
    bool possible = true;
    for ( auto p : add ) {
        // p.first の少ない方から読み込まれる
        if ( cur - p.first < 0 ) possible = false;
        else cur += p.second;
    }
    
    int64_t x = cur;
    cur = 0;
    for ( auto p : del ) {
           // p.first の少ない方から読み込まれる
           if ( cur - p.first < 0 ) possible = false;
           else cur += p.second;
    }
    
    if ( cur == x and possible ) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int h, w, n, x, y, res;
set<ii> st;
vii a;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> h >> w >> n;

	res = h;

	while (n--) {
		cin >> x >> y;
		if (x >= y) a.emplace_back(x, y);
	}

	sort(all(a));

	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		x = a[i].fi, y = a[i].se;

		if (x - y > d && !st.count(ii(x, y))) res = min(res, x - 1);
		if (x - y == d) d++;
		st.emplace(x+1, y);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 9456
n,k=map(int,input().split())
l=list(map(int,input().split()))
i=0
cnt=0
lcnt=0
sl=[0]*n
for p in range(k):
  if sl[i]==0:
    sl[i]=1
    i=l[i]-1
    cnt+=1
  elif sl[i]==1:
    sl[i]=2
    lcnt+=1
    i=l[i]-1
  else:
    c=(k-cnt)%lcnt
    if c!=0:
      for tmp in range(c):
        i=l[i]-1
    break
print(i+1)


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){if(a < b) a = b;}


ll fnc1(string sn, int q){
	int cn=sz(sn); 
	vector<VL> p(5, VL(2));
	p[0][0]=1;
	rep(i, cn){
		vector<VL> np(5, VL(2));
		rep(j, q+1)  rep(d, 10) {
			int nj = j;
			if(d>0) nj = j+1;
			if(d < sn[i] -'0') np[nj][1] += p[j][0];
			else if(d== sn[i] -'0') np[nj][0] += p[j][0];
			np[nj][1] += p[j][1];
		}
		swap(p, np);
	}
	return p[q][0] + p[q][1];
}

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int k;
	string sn;
	cin >>sn >>k;
	cout << fnc1(sn, k) <<"\n";;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;

#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin() , (a).end()
#define rall(a) (a).rbegin() , (a).rend()

ll next(){ll x; cin >> x;return x;}
const int maxn = 2e5 + 2 , intf = 2e9;
const ll inf = 2e18 , mod = 1e9 + 7;
const ld eps = 1e-9;


void solve(){
    int n , x , y;
    cin >> n >> x >> y; x-- , y--;
    vector <int> ans(n , 0);
    for (int i = 0; i < n; ++i){
        for (int j = i + 1; j < n; ++j){
            ans[min(abs(i - j) , min(abs(i - x) + abs(j - y) + 1 , abs(i - y) + abs(j - x) + 1))]++;
        }
    }
    for (int i = 1; i < n; i ++){
        cout << ans[i] << '\n';
    }
}


signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    
    for (int t = 1; t--;) solve();

	return 0;
}
/*


*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c; cin >> a >> b >> c;
    if(max(a,b)-min(a,b) < max(a,c)-min(a,c)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
A = [set() for i in range(N+1)]
for i in range(M):
  a, b = map(int, input().split())
  A[a].add(b)
  A[b].add(a)
B = [0 for i in range(N+1)]
C = [0 for i in range(N+1)]
d = deque()
n = 1
for i in range(1, N+1):
  if B[i] != 0:
    continue
  d.append(i)
  C[n] += 1
  B[i] = n
  while len(d):
    e = d.pop()
    for k in A[e]:
      if B[k] == 0:
        d.append(k)
        C[n] += 1
        B[k] = 1
  n += 1
print(max(C))

Measured memory_bytes: 184216
#include <cstdio>

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

int main() {
    int N;
    scanf("%d", &N);
    int sum = 0;
    for (int i=1; i<=N; ++i) {
        for (int j=1; j<=N; ++j) {
            for (int k=1; k<=N; ++k) {
                int t = gcd(i, j);
                sum += gcd(t, k);
            }
        }
    }
    printf("%d", sum);
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

bool jump(const int i, const int j, const string& s, VI& A)
{
    const int n = s.size();
    FOR(x,1,n+1) if (s[x-1] == '#')
        A[x] = 2;
    A[i] = 1;
    FOR(x,1,n+1) if (A[x] == 1) {
        FOR(d,1,3) {
            const int y = x+d;
            if (y <= j && A[y] != 2)
                A[y] = 1;
        }
    }
    return A[j] == 1;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,a,b,c,d;
    while (cin >> n >> a >> b >> c >> d) {
        string s; cin >> s;
        VI A(n+2), B(n+2);
        bool ans = false;
        if (jump(a,c,s,A) && jump(b,d,s,B)) {
            if (a > b)
                swap(a,b), swap(c,d);
            if (c < d)
                ans = true;
            else {
                FOR(i,1,n+1) if (B[i] == 1 && A[i-1] == 1 && A[i+1] == 1)
                    ans = true;                
            }
        }
        cout << (ans ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 2128
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] array1 = new int[n];
    int[] array2 = new int[n];
    int[] array3 = new int[n-1];
    int satis = 0;
    int pp=0;

    for(int i=0; i<n; i++){
      array1[i] = sc.nextInt();
    }
    for(int i=0; i<n; i++){
      array2[i] = sc.nextInt();
    }
    for(int i=0; i<n-1; i++){
      array3[i] = sc.nextInt();
    }

    for(int i=0; i<n; i++){
      int num = array1[i];
      satis += array2[num-1];
      if(i>0){
        if(array1[i]-array1[i-1]==1){
        pp = array1[i-1];
        satis += array3[pp-1];
        //System.out.println("PASS");
        }
      }
      //System.out.println(satis);
    }
    System.out.println(satis);
  }
}

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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second

using namespace std;

const int N = 300100;
int n, k, a[N];

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	out << v.size() << '\n';
	for(auto e : v) out << e << ' ';
	return out;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];

	int r = 1, msk = a[1];
	long long ans = 0;
	a[0] = 0;
	for(int i = 1; i <= n; i++) {
		if(r == i - 1) msk = a[++r];
		else msk ^= a[i - 1];
		while(r < n && (msk & a[r + 1]) == 0) msk |= a[++r];
		ans += 1LL * (r - i + 1);
	}
	cout << ans << '\n';

}	

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let k = read::<usize>();
    let v = read_vec::<usize>();
    let (a, b) = (v[0], v[1]);
    for i in a..b + 1 {
        if i % k == 0 {
            println!("OK");
            return;
        }
    }
    println!("NG");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2112
A, B, C, D = gets.split('').map(&:to_i)

2.times do |i|
  2.times do |j|
    2.times do |k|
      op1 = i==0 ? '+' : '-'
      op2 = j==0 ? '+' : '-'
      op3 = k==0 ? '+' : '-'
      str = "#{A}#{op1}#{B}#{op2}#{C}#{op3}#{D}"
      plus = str.scan(/\+([0-9]+)/).flatten.map(&:to_i).inject(:+)
      minus = str.scan(/\-([0-9]+)/).flatten.map(&:to_i).inject(:+)
      plus.nil? && (plus = 0)
      minus.nil? && (minus = 0)
      if A + plus - minus == 7
        puts "#{str}=7"
        exit
      end
    end
  end
end

Measured memory_bytes: 1788
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

//階乗,二項係数
//*
ll fact[100010];
ll invfact[100010];
void makefact(int n,ll m){
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}
//*/

int main(){
	makefact(2000,MOD);
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%lld\n",choose(n-1,n-m,MOD));
}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			long sum = 0;
			
			for(int i = 0 ; i < s.length() ; i++ ) {
				char c = s.charAt(i);
				int digit = c - '0';
				sum += digit;
			}
			
			System.out.println(sum % 9 == 0 ? "Yes" : "No");
		}
	}

}

Measured memory_bytes: 40384
from sys import stdin
s = stdin.readline().rstrip()
if s[2:-1].count('C') == 1:
    ic = s[2:-1].index('C')+2
    if ic>len(s):
      ic=len(s)-1
    if s[0]=='A' and (s[1:ic]+s[ic+1:]).islower():
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3060
while True:
    a,b = map(int,input().split())
    ans = []
    if a == 0  and b == 0:
        break

    for v in range(a):
        if v % 2 == 0:
            for i in range(b):
                if i % 2 == 0:
                    ans.append("#")
                else:
                    ans.append(".")
            print("".join(ans))
            ans.clear()            
        else:
            for i in range(b):
                if i % 2 == 1:
                    ans.append("#")
                else:
                    ans.append(".")   
            print("".join(ans))
            ans.clear()
    print()
    


Measured memory_bytes: 5612
#include <stdio.h>
#include <string.h>
int main(){
    int N;
    scanf("%d",&N);
    char S[N][11];
    int P[N];
    for(int i=0; i<N; i++){
        scanf("%s %d",&S[i-1][11],&P[i]);//iは0番からなのでレストランの番号はi+1
    }
    //printf("%s %d\n",S[1],P[1]);
    int count = 0;
    while(count<N){
        int min = 0;
        for(int j=1; j<N; j++){
            if(strcmp(S[j],S[min])<0){
                min = j;
            }
            else if(strcmp(S[j],S[min])==0){
                if(P[j]>P[min]){
                    min = j;
                }
            }
            //printf("%sあ\n",S[min]);
        }
        strcpy(S[min],"zzzzzzzzz");
        printf("%d\n",min+1);
        count++;
    }
    return 0;
}



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

using namespace std;

void isStable(vector<pair<int, char>>& bubble, vector<pair<int, char>>& selection, int N) {
	for (int i = 0; i < N; ++i) {
		if (bubble[i].second != selection[i].second) {
			cout << "Not stable" << endl;
			return;
		}
	}
	cout << "Stable" << endl;
}

void output(vector<pair<int, char>> &A, int N) {
	for (int i = 0; i < N - 1; ++i) {
		cout << A[i].second << A[i].first << " ";
	}
	cout << A[N - 1].second << A[N - 1].first;
	
	cout << endl;
}

int main() {
	int N;
	cin >> N;
	vector<pair<int, char>> bubble(N);
	vector<pair<int, char>> selection(N);
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		bubble[i] = make_pair(s[1] - '0', s[0]);
		selection[i] = make_pair(s[1] - '0', s[0]);
	}

	for (int i = 0; i < N; ++i) {
		for (int j = N - 1; j > i; --j) {
			if (bubble[j].first < bubble[j - 1].first)swap(bubble[j], bubble[j - 1]);
		}
	}

	int minV_point;
	for (int i = 0; i < N; ++i) {
		minV_point = i;
		for (int j = i + 1; j < N; ++j) {
			if (selection[j].first < selection[minV_point].first) {
				minV_point = j;
			}
		}
		swap(selection[i], selection[minV_point]);
	}

	output(bubble, N);
	cout << "Stable" << endl;
	output(selection, N);
	isStable(bubble, selection, N);


	return 0;
}


Measured memory_bytes: 3124
'use strict';
function main(input) {
  const args = input.split('\n'),
        N = parseInt(args[0]),
        A = args[1].split(' '),
        B = args[2].split(' ');
  let cnt = 0;
  for (let i = 0; i < N; ++i) {
    let a = parseInt(A[i]), aNext = parseInt(A[i+1]),
        b = parseInt(B[i]), difference = b-a;
    if (difference > 0) {
      cnt += a;
      let differenceNew = aNext - difference;
      if (differenceNew > 0) {
        cnt += difference;
        A[i+1] = differenceNew.toString();
      } else {
        cnt += aNext;
        A[i+1] = '0';
      }
    } else {
      cnt += b;
    }
  }
  console.log(cnt);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 34840
#include<stdio.h>
#define nmax 500000


void merge(int,int,int);
void mergeSort(int,int);

int A[nmax],count=0;
int main(){
  
  int n;
  int i;

  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ )
    scanf("%d",&A[i]);

  mergeSort(0,n);

  for( i = 0 ; i < n-1 ; i++ )
    printf("%d ",A[i]);
  printf("%d\n",A[i]);
  printf("%d\n",count);

  return 0;
}

void merge(int left,int mid,int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1],R[n2+1];
  int i,j,k;

  for( i = 0 ; i < n1 ; i++ )
    L[i] = A[left+i];
  for(i = 0 ; i < n2 ; i++ )
    R[i] = A[mid+i];
  L[n1] = 10000000000;
  R[n2] = 10000000000;
  i = 0;
  j = 0;
  for( k = left ; k < right ; k++ )
    {
      count++;
      if(L[i] <= R[j]){
	A[k] = L[i];
	i = i + 1;
      }
      else
	{
	  A[k] = R[j];
	  j = j + 1;
	}
    }
}

void mergeSort(int left,int right)
{
  int mid;

  if( left+1 < right )
    {
      mid = (left+right)/2;
      mergeSort(left,mid);
      mergeSort(mid,right);
      merge(left,mid,right);
    }

}

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

using namespace std;

const int maxn = 100010;

typedef long long ll;

priority_queue<ll> pq;
map<ll, int> mp;

int n, l[maxn], dep[maxn], sz[maxn], w[maxn], vis[maxn], e_u[maxn], e_v[maxn], tot, e = 0;
ll D[maxn], S[maxn];

struct Edge {
    int v, x;
} E[maxn];

inline void addEdge(int u, int v) {
    E[e].v = v; E[e].x = l[u]; l[u] = e++;
}

void dfs1(int u) {
    sz[u] = 1;
    for (int p = l[u]; p >= 0; p = E[p].x) {
        int v = E[p].v;
        dep[v] = dep[u] + 1;
        dfs1(v);
        sz[u] += sz[v];
    }
}

void dfs2(int u) {
    for (int p = l[u]; p >= 0; p = E[p].x) {
        int v = E[p].v;
        S[v] = S[u] + n - 2 * sz[v];
        dfs2(v);
    }
}

int main() {
    memset(l, -1, sizeof(l));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", &D[i]);
    for (int i = 1; i <= n; i++) {
        mp[D[i]] = i;
        pq.push(D[i]);
        w[i] = 1;
    }
    vis[0] = 1;
    while (pq.size() > 1) {
        ll v = pq.top(); pq.pop();
        int u = mp[v];
        vis[u] = 1;
        if (!vis[mp[v + 2 * w[u] - n]]) {
            int t = mp[v + 2 * w[u] - n];
            w[t] += w[u];
            addEdge(t, u);
            ++ tot;
            e_u[tot] = t; e_v[tot] = u;
        } else {
            puts("-1");
            return 0;
        }
    }
    int r = mp[pq.top()];
    dfs1(r);
    for (int i = 1; i <= n; i++) S[r] += dep[i];
    dfs2(r);
    for (int i = 1; i <= n; i++) {
        if (S[i] != D[i]) {
            puts("-1");
            return 0;
        }
    }
    for (int i = 1; i <= tot; i++) printf("%d %d\n", e_u[i], e_v[i]);
    return 0;
}

Measured memory_bytes: 15092
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

const ll mod = 1e9+7;
struct mint
{
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod){}
    mint operator-() const {return mint(-x);}
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if(!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    ll val(){ return x; }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x;}
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
};

struct Comb {
    const ll mod;
    vector<ll> fact, ifact;
    ll mod_pow(ll x, ll n, const ll mod){
        ll ans = 1;
        while(n){
            if(n & 1) ans = ans*x%mod;
            x = x*x%mod;
            n >>= 1;
        }
        return ans;
    }
    Comb(ll n, ll mod) : fact(n+1), ifact(n+1), mod(mod) {
        fact[0] = 1;
        for(ll i = 1; i <= n; i++) fact[i] = fact[i-1] * i % mod;
        ifact[n] = mod_pow(fact[n], mod-2, mod);
        for(ll i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i % mod;
    }
    ll operator()(ll n, ll k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
    }
    ll perm(ll n, ll k){
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[n-k]%mod;
    }
};

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

    Comb C = Comb(m, mod);
    mint ans;
    for(ll i = 0; i <= n; i++) {
        mint tmp = C(n, i);
        tmp *= C.perm(m, i);
        tmp *= C.perm(m-i, n-i);
        tmp *= C.perm(m-i, n-i);
        if(i & 1) ans -= tmp;
        else ans += tmp;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11032
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <limits>
//std::numeric_limits<int>::max(), min()

int main (void) {

  std::string S;
  std::cin >> S;

  int a = std::atoi(S.substr(0,2).c_str());
  int b = std::atoi(S.substr(2,2).c_str());

  if ( a >= 1 && a <= 12 && b>=1 && b<=12 ) {
    std::cout << "AMBIGUOUS" << std::endl;
    return 0;
  }
  if ( !(a >= 1 && a <= 12) && b>=1 && b<=12 ) {
    std::cout << "YYMM" << std::endl;
    return 0;
  }
  if ( a >= 1 && a <= 12 && !(b>=1 && b<=12) ) {
    std::cout << "MMYY" << std::endl;
    return 0;
  }
  if ( !(a >= 1 && a <= 12) && !(b>=1 && b<=12) ) {
    std::cout << "NA" << std::endl;
    return 0;
  }

  return 0;
}

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

int main(){
    int k, x;
    cin >> k >> x;

    if(500*k>=x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 105;
const ll mm = 1e+18;
int dist(pair<int,int>a,pair<int,int>b){
    return abs(a.f-b.f)+abs(a.s-b.s);
}
void solve()
{
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>a(n);
    vector<pair<int,int>>b(m);
    rep0(i,n) cin>>a[i].f>>a[i].s;
    rep0(i,m) cin>>b[i].f>>b[i].s;
    rep0(i,n){
        set<pair<int,int>>s;
        rep0(j,m){
            s.insert({dist(a[i],b[j]),j+1});
        }
        auto it=s.beg;
        cout<<it->second<<"\n";
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main()
{
    int H, W;
    cin >> H >> W;

    vector<string> grid(H);
    rep(i, 0, H) cin>>grid[i];

    vector<vector<ll>> dp(H+1, vector<ll>(W+1, 0));
    dp[0][0] = 1;

    rep(h, 0, H)
        rep(w, 0, W)
        {
            if (grid[h][w] == '#') continue;

            dp[h+1][w] += dp[h][w];
            dp[h][w+1] += dp[h][w];
            dp[h+1][w] %= MOD;
            dp[h][w+1] %= MOD;
        }

    cout << dp[H-1][W-1]  << endl; 
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    string s; int k,n;
    cin >> n >> k >> s;
    k--;
    rep(i,n){
        char c = s[i];
        if(i == k) c += 32;
        cout << c;
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a % 2 == 0 || b % 2 == 0) {
			System.out.print("Even");
		} else {
			System.out.print("Odd");
		}
	}

}

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

}


Measured memory_bytes: 3752
/*author : Yashvardhan
Sunday, May 03, 2020
5:28 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	string s;
	cin >> s;

	if(s == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl; 
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



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

int main() {
  string s, t;
  cin >> s >> t;

  int n;
  n = s.size();

  int count = 0;

  for (int i = 0; i < n; i++) {
    if (s.substr(i, 1) != t.substr(i, 1)) {
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 3824
MOD = int(1e9 + 7)

N,M = list(map(int, input().split()))
A = list()
for i in range(M):
  A.append(int(input()))

A.sort(reverse=True)

for i in range(M-1):
  if A[i+1] - A[i] == 1:
    print(0)
    exit(0)
  
dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
  if len(A) > 0 and i+1 == A[-1]:
    A.pop()
  else:  
    dp[i+1] = (dp[i] + dp[i-1]) % MOD
'''
  if len(A) < 1:
    dp[i+1] = (dp[i] + dp[i-1]) % MOD
  elif i-1 < 0 or i-1 == A[-1]:
    dp[i+1] = dp[i] % MOD
  elif i == A[-1]:
    dp[i+1] = dp[i-1] % MOD
  else:
    dp[i+1] = (dp[i] + dp[i-1]) % MOD
'''
print(dp[N])
#print(dp)

Measured memory_bytes: 7824
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
#define MAX 10000
#define INFTY 10000000
#define DEFLT 0
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra(){
  int u, v, d[MAX], color[MAX];
  priority_queue<pair<int, int> > PQ; // uからvへの重みcとuに隣接する頂点の番号vのペア: pair<c, v*(-1)>

  for(int i=0; i<n; i++){
    color[i] = WHITE;
    d[i] = INFTY;
  }
  d[DEFLT] = 0;
  color[0] = GRAY;

  PQ.push(make_pair(0, DEFLT));

  while(!PQ.empty()){
    pair<int, int> f = PQ.top();
    PQ.pop();
    u = f.second;
    color[u] = BLACK;

    for(int i=0; i<adj[u].size(); i++){
      v = adj[u][i].second;
      if(color[v] != BLACK && d[u] + adj[u][i].first < d[v]){
        //cout << "u=" << u << ", v=" << v << ", d[u]=" << d[u] << ", d[v]=" << d[v] << "adj[u][i].first=" << adj[u][i].first << endl;
        d[v] = d[u] + adj[u][i].first;
        color[v] = GRAY;
        PQ.push(make_pair(d[v] * (-1), v));
      }
    }
  }

  for(int i=0; i<n; i++){
    cout << i << " " << d[i] << endl;
  }
}

int main(void){
  int u, k, v, c;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> u >> k;
    for(int j=0; j<k; j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(c, v));
    }
  }

  dijkstra();
  return 0;
}



Measured memory_bytes: 7996
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>

#define rep(i,x,y) for (int i=x;i<=y;i++)
#define dep(i,y,x) for (int i=y;i>=x;i--)
#define sz(x) (int)(x.size())

using namespace std;

typedef long long LL;   
typedef unsigned long long uLL;

const int maxn=500000+10;

LL n,A,B,C,D,l,r,L[maxn],R[maxn];

int main()
{
    scanf("%lld%lld%lld%lld%lld",&n,&A,&B,&C,&D);

    L[0]=R[0]=0;
    rep(i,1,n) L[i]=L[i-1]+C,R[i]=R[i-1]+D;

    rep(i,0,n-1)
    {
        l=A+L[i],r=A+R[i];
        l-=R[n-i-1],r-=L[n-i-1];

        if ((l<=B)&&(B<=r)) {printf("YES\n");return 0;}
    }

    printf("NO\n");

    // system("pause");
    return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(17);
  int n, x;
  cin >> n >> x;
  int y; cin >> y;
  int ans = abs(x - y);
  for(int i = 1; i < n; i++){
    cin >> y;
    ans = __gcd(ans, abs(x - y));
  }
  cout << ans << "\n";
  return 0;
}


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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod (int)1e18+50000
#define inf (int)1e18

const int mxn = 1e5+10;
int a[mxn];

int32_t main(){
	NINJA;

	int n; cin >> n;

	fo(i,n) cin >> a[i];
	int mul = 1ll;
	int zero = 0;

	fo(i,n){
		int x =a[i];
		if(x==0) zero++;
		if(zero>0){
			cout << 0 << endl;
			return 0;
		}
	}
	fo(i,n){
		if(a[i]<=(1000000000000000000/mul))
			mul = mul*a[i];
		else{
			cout << -1 << endl;
			return 0;
		}
		
	}
	
	cout << mul << endl;
	// cout << mul << endl;
	
	return 0;
}

Measured memory_bytes: 4448
#include<bits/stdc++.h>
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))  
#define lli long long int
#define ll long long 
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define BS binary_search
#define pii pair<lli,lli>
const long long int mod=1000000009;
//const long long int mod=998244353;
const long double PI=3.141592653589793;
const long long int inf=1e18;
const long long int inf2=LLONG_MAX;
#define setBitCount(x) __builtin_popcountll(x)
#define all(a) (a).begin(), (a).end()
#define all_r(a) (a).rbegin(), (a).rend()
lli gcd(lli a,lli b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}
// calculating (x^y)%p
lli power(lli x,lli y,lli p)
{
    lli res = 1;      
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) //y is odd  
        res = (res*x) % p;
        y = y>>1; 
        x = ( (x%p)*(x%p) )% p;  
    }
    return res%p;
}
// calculating modular inverse using fermat little theorem
lli modInverse(lli n,lli p) 
{
    return power(n, p-2, p)%p;
}

// policy based data structures !!
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
// s.order_of_key (k) : Number of items strictly smaller than k
// *(s.find_by_order(k)) : K-th element in a set (counting from zero)

void solve()
{
   string s,t;
   cin>>s>>t;
   
   lli len1=s.size();
   lli len2=t.size();
   
   lli dp[len1+5][len2+5];
   mem(dp,0);
   
   for(lli i=1;i<=len1;i++)
   {
      for(lli j=1;j<=len2;j++)
      {
         if(s[i-1]==t[j-1])
         dp[i][j]=dp[i-1][j-1]+1;
         else
         dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
   }
   
   string ans="";
   lli i=len1;
   lli j=len2;
   while(i>0 and j>0)
   {
      if(s[i-1]==t[j-1])
      {
         ans.pb(s[i-1]);
         i--;
         j--;
      }
      else
      {
         if(dp[i-1][j]>dp[i][j-1])
         i--;
         else
         j--;
      }
   }
   reverse(all(ans));
   cout<<ans;
}
int main()
{
   
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    lli T;
    //cin>>T;
    T=1;
    while(T--)
    {
        solve();
    }




    return 0;
}

Measured memory_bytes: 70784
N,K=map(int,input().split())
a=list(map(int,input().split()))
dp=[0 for j in range(K+1)]
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            dp[i]=max((dp[i-a[j]]+1)%2,dp[i])
if dp[K]:
    print("First")
else:
    print("Second")



Measured memory_bytes: 45296
<?php
  fscanf(STDIN,"%d %d",$a,$b) ;
$ans=1;
$c = min($a,$b);
$d = max($a,$b);
$r = 1 ;
while($r!=0){
	$r=$d%$c ;
  if($r==0){
  break ;
  }
    $d=$c;
    $c=$r;
}
  if($c%2==0){
    ++$ans;
    while($c%2==0){
    $c/=2 ;
    }
  } 

  for($i=3;$i*$i<=$c;$i+=2){
    if($c%$i==0){
      ++$ans;
      while($c%$i==0){
      	$c/=$i ;
    }
   }
  }
if($c>2){
++$ans;
}
echo $ans ;

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int a, b;
  	cin >> a >> b;
  	int n = b-a;
  	n = n*(n+1)/2;
  	cout << n-b << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
N,H,W = map(int,input().split(' '))

A = []
B = []

for i in range(N):

    a,b = map(int,input().split(' '))

    A.append(int(a))
    B.append(int(b))


cnt = 0

for j in range(N):

    if A[j] >= H:
        if B[j] >= W:
            cnt =cnt + 1

print(cnt)


Measured memory_bytes: 3060
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

vector<int> red(MAX), green(MAX), mixed(MAX);
int x, y, a, b, c;

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int x, y, a, b, c;

    cin>>x>>y>>a>>b>>c;

    int val;
    for(int i = 0; i < a; i++){
        cin>>red[i];
    }
    sort(red.begin(), red.end());

    for(int i = 0; i < b; i++){
        cin>>green[i];
    }
    sort(green.begin(), green.end());

    for(int i = 0; i < c; i++){
        cin>>mixed[i];
    }
    sort(mixed.begin(), mixed.end());

    ll ans = 0;

    for(int i = x + y; i > 0; i--){
        int r = (red.empty() || x <= 0) ? 0 : red.back();
        int g = (green.empty() || y <= 0) ? 0 : green.back();
        int m = mixed.empty() ? 0 : mixed.back();

        if(r >= m && r >= g){
            ans += (ll) red.back();
            red.pop_back();
            x--;
        }
        else if(g >= m && g >= r){
            ans += (ll) green.back();
            green.pop_back();
            y--;
        }
        else{
            ans += (ll) mixed.back();
            mixed.pop_back();
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1408