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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_N = 100;
int a[MAX_N];
int x;
int mx;

int main()
{
  while(cin >> x) a[x-1] += 1;

  rep(i, MAX_N) maxup(mx, a[i]);

  rep(i, MAX_N) if(mx == a[i]) cout << i + 1 << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i < x + k; i++) {
		cout << i << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>

using namespace std;

set<long long> divisors(long long n) {
    set<long long> div;
    for (long long i = 1; i * i <= n ; i++) {
        if (n % i == 0) {
            div.insert(i);
            div.insert(n / i);
        }
    }
    return div;
}

int main() {
    long long N;
    cin >> N;
    long long ans = 0;
    set<long long> div = divisors(N);
    div.erase(1);
    for (auto& d : div) {
        long long temp = N;
        while (temp >= d) {
            if (temp % d)
                temp %= d;
            else
                temp /= d;
        }
        if (temp == 1)
            ans++;
    }
    ans += divisors(N - 1).size() - 1;
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
using namespace std;
int main() {
    int n;
    cin>>n;
    int k=n%10;
    if(k==2||k==4||k==5||k==7||k==9)cout<<"hon";
    else if(k==3)cout<<"bon";
    else cout<<"pon";
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int n = sc.nextInt();
			long d = sc.nextLong();

			int count = 0;
			for (int i = 0; i < n; i++) {
				long x = sc.nextLong();
				long y = sc.nextLong();
				if (x * x + y * y <= d * d) {
					count++;
				}
			}
			System.out.println(count);

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

Measured memory_bytes: 60736
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<60);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
	init();
	ll N,K;cin>>N>>K;
	ll ans=0;
	for(int i=0;i<N;i++){
		ll x;cin>>x;
		ans+=min(abs(x),abs(K-x));
	}
	cout<<2*ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        long answer = input - 1;
        answer = getAnswer(input, answer);
        System.out.println(answer);
    }

    private static long getAnswer(long input, long answer) {
        int newStart = (int) Math.sqrt(input);
        for (long i = newStart; i > 1; i --) {
            if (input % i == 0) {
                long divisible = input / i;
                long possibleAnswer = (i - 1) + (divisible - 1);
                return possibleAnswer;
            }
        }
        return answer;
    }
}

Measured memory_bytes: 21972
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

long long gcd(long long a, long long b) {
  return b != 0 ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b) {
  return a * b / gcd(a, b);
}

int main() {
  // Input
  long long A, B, C, D;
  std::cin >> A >> B >> C >> D;

  // Main
  long long numAll = B - A + 1;
  long long numModC = (B / C) - ((A + C - 1) / C) + 1;
  long long numModD = (B / D) - ((A + D - 1) / D) + 1;
  long long CD = lcm(C, D);
  long long numModCD = (B / CD) - ((A + CD - 1) / CD) + 1;
  // std::cout << numAll << std::endl;
  // std::cout << numModC << std::endl;
  // std::cout << numModD << std::endl;
  // std::cout << numModCD << std::endl;

  // Output
  long long res = numAll - numModC - numModD + numModCD;
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define sqrt(d) pow((long double) (d), 0.50)
 
const ll INF = 2e9;
const ll large_P = 1e9 + 7;
 
 
int main(){
  int N; cin >> N;
  int a1, a2, a3;
  a1 = N/100; N -= 100*a1;
  a2 = N/10; N -= 10*a2;
  a3 = N;
  
  if(a1 == 7 || a2 == 7 || a3 == 7) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(void)
{
	int a, b, c, d;
	scanf("%d%d%d", &a, &b, &c);
	d = a + b + c;
	if (d >= 22) {
		printf("bust\n");
	}
	else if (d <= 21) {
		printf("win\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

int main(int argc, char ** argv) {
	ll r, g, b;
	cin >> r >> g >> b;
	ll ans = 100*r + 10*g + b;
	if(ans%4 == 0) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
Imports System

Public Class Program


    Public Shared Sub Main(args As String())

        Dim Input() As Decimal = Array.ConvertAll(Of String, Decimal)(Console.ReadLine.Split, AddressOf Decimal.Parse)

        Dim HAngle As Decimal = Math.PI / 6 * (Input(2) + Input(3) / 60)
        Dim MAngle As Decimal = Math.PI / 30 * Input(3)

        Dim TH As Decimal = Math.Abs(HAngle - MAngle)

        Console.WriteLine(Math.Sqrt(Input(0) ^ 2 + Input(1) ^ 2 - 2 * Input(0) * Input(1) * Math.Cos(TH)))



    End Sub




End Class

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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=4e5+50;
int n,q,mn[N],anc[N];
long long ans;

struct data {
	int x,y,w;
	data(int x,int y,int w) : x(x),y(y),w(w) {}
	friend inline bool operator <(const data &a,const data &b) {return a.w<b.w;}
};
vector <data> edge;

inline int ga(int x) {return (anc[x]==x) ? x : (anc[x]=ga(anc[x]));}
int main() {
	n=rd(), q=rd();
	for(int i=0;i<2*n;i++) mn[i]=0x3f3f3f3f;
	for(int i=1;i<=q;i++) {
		int x=rd(), y=rd(), w=rd();
		mn[x]=min(mn[x],w+1);
		mn[y]=min(mn[y],w+2);
		edge.push_back(data(x,y,w));
	}
	for(int i=1;i<2*n;i++) mn[i]=min(mn[i],mn[i-1]+2);
	for(int i=0;i<=n-1;i++) {
		int w=min(mn[i],mn[i+n]);
		int x=i%n, y=(i+1)%n;
		edge.push_back(data(x,y,w));
	} sort(edge.begin(),edge.end());
	for(int i=0;i<n;i++) anc[i]=i;
	for(auto v:edge) {
		int x=ga(v.x), y=ga(v.y);
		if(x==y) continue;
		ans+=v.w; anc[x]=y; 
	} cout<<ans<<'\n';
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)


int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    vector<P> color(n,P(-1,-1));
    for (int i = 0;i < m;++i) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int q;
    cin >> q;
    vector<int> v(q),d(q),c(q);
    for (int i = 0;i < q;++i) {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    for (int i = q-1;i >= 0;--i) {
        if (color[v[i]].second >= d[i]) continue;
        deque<P> que;
        que.push_back(P(v[i],d[i]));
        while (!que.empty()){
            P p = que.front();que.pop_front();
            if (color[p.first].first < 0) color[p.first] = P(i,p.second);
            if (p.second < 1) continue;
            for (int j : edges[p.first]) {
                if (color[j].second < p.second-1) {
                    que.push_back(P(j,p.second-1));
                    color[j].second = p.second-1;
                }
            }
        }
    }
    for (int i = 0;i < n;++i) {
        int j = color[i].first;
        cout << (j > -1 ? c[j] : 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 8924
#include<bits/stdc++.h>
#define N 501000

using namespace std;
typedef long long LL;

int a[N];

int main()
{
    int n,cnt,ji;
    while(cin>>n)
    {
        int flag=0;
        cnt=ji=0;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            if(a[i]%4==0)
                cnt++;
            if(a[i]%2!=0)
                ji++;
        }
        if(ji==cnt+1&&ji+cnt==n)
            flag=1;
        if(cnt>=ji)
            flag=1;
        if(flag==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>
bool is_prime(T x) {
  if(x<=1)return false;
  for(T i = 2; i * i <= x; i++) {
    if(!(x%i)) return false;
  }
  return true;
}

int n,m,_,x,y,q,key;
string s,sb;
bool ok;

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

  cin>>q; bool a[50000]; int b[50001]={}; a[0]=false;
  rep(i,50000){
    if(is_prime(i*2+1)&&is_prime(i+1))a[i]=true;
  }
  rep(i,50000)b[i+1]=b[i]+a[i];
  rep(i,q){
    cin>>x>>y; pri1(b[y/2+1]-b[x/2]);
  }
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    bool flag=false;
    cin>>a>>b>>c;
    for(i=0;i<b;i++){
        if((i*a)%b==c)flag=true;
    }
    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll n,k,c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  ll sum = 0;
  vector<ll> vec1(n,0);
  vector<ll> vec2(n,0);
  rep(i,n){
    if(s[i] == 'o'){
      sum++;
      vec1[i]++;
      i += c;
    }
  }
  if(sum == k){
    for(ll i = n-1;i >= 0;i--){
      if(s[i] == 'o'){
        vec2[i]++;
        i -= c;
      }
    }
    ll cou1 = 0;
    ll cou2 = 0;
    rep(i,n){
      cou1 += vec1[i];
      cou2 += vec2[i];
      if(cou1 == cou2 && vec1[i] &&  vec2[i]){
        cout << i + 1 << endl;
      }
    }
  }else{

  }
}

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

using namespace std;

#define ll long long
#define vi vector<int>
#define mkp make_pair
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD = 1e9 + 7;
int R[mxn];
int G[mxn];
int B[mxn];
int n, m, k;
string s;

ll pow(ll A,ll B,ll R=1)
{while(B){if(B&1)R=R*A%MOD;A=A*A%MOD;B>>=1;}return R;}

void init(){
    for(int i = 1; i < n; i++){
        R[i] += R[i - 1] + (s[i] == 'R');
        G[i] += G[i - 1] + (s[i] == 'G');
        B[i] += B[i - 1] + (s[i] == 'B');
    }
}

void read(){
    cin >> n >> s;
//    for(int i = 0, u, v; i < n; i++){
//        cin >> arr[i];
//    }
    init();
}

void solve(){
    ll ans = 0;
    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            if(s[i] == s[j]) continue;
            char last = (char)((int)'R' + (int)'G' + (int)'B' - (int)s[i] - (int)s[j]);
            if(last == 'R') ans += R[n - 1] - R[j];
            if(last == 'G') ans += G[n - 1] - G[j];
            if(last == 'B') ans += B[n - 1] - B[j];
            if(j + (j - i) >= n) continue;
            ans -= (s[j + j - i] == last);
        }
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    //init();
    while(T--) read(), solve();
    return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i=j;i<k;i++)
int main(){
  string buf;
  cin >> buf;
  rep(i,0,buf.length()){
    if(i%2==1){
      if(buf[i]=='R'){
        cout << "No\n";
        return 0;
      }
    }
    else{
      if(buf[i]=='L'){
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
}


Measured memory_bytes: 256
def main():
    minLen = int(input())
    begin = list(input())
    end = list(input())

    iMax = 0

    if begin == end:
        iMax = minLen
    else:
        for i in range(minLen):
            if i == 0: continue
            if begin[-i:] == end[:i]: iMax = i
            #print(begin[-i:], end[:i])

    print(2*minLen - iMax)

    #print(lenOut)

if __name__ == '__main__':
  main()


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll i, j,k,l;

int main(){
    scanf("%lld%lld%lld%lld", &i,&j,&k,&l);
    printf("%lld", (i - k) * (j - l));

    return 0;
}

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

int main() {
    int n, a, rate[8]={0}, cnt_free=0;
    cin >> n;

    for(int i=0; i<n; i++) {
        cin >> a;
        if(a<3200) rate[a/400]++;
        else cnt_free++;
    }

    int cnt_min=0, cnt_max;
    for(int i=0; i<8; i++) if(rate[i]!=0) cnt_min++;

    cnt_max = cnt_min+cnt_free;

    if(cnt_min==0) cnt_min=1;



    cout << cnt_min << " " << cnt_max << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cstdio>
#include<map>

#define N 2048

using namespace std;

struct rectangle{
  int x1,y1;
  int x2,y2;
  rectangle():
    x1(0),y1(0),x2(0),y2(0) {}
  rectangle(int a, int b, int c, int d):
    x1(a),y1(b),x2(c),y2(d) {}
};

typedef pair<int,int> pi;
typedef map<int,int> CCS; // compressed coordinate system

void CompressCCS( CCS & ccs ){
  int cnt = 0;
  for(CCS::iterator itCC = ccs.begin(); itCC != ccs.end(); ++itCC){
    itCC->second = cnt;
    ++cnt;
  }
  return ;
}

bool isinside( pi p, int h, int w ){
  return 0 <= p.first && p.first < h-1 && 0 <= p.second && p.second < w - 1;
}

void BFS(int st, int ed, int h, int w, int tapes[][N]){
  queue< pi > qp;
  static const int di[] = {-1,0,1,0};
  static const int dj[] = {0,1,0,-1};

  qp.push( pi( st, ed ) );
  tapes[st][ed] = -1;
  while( !qp.empty() ){
    pi now = qp.front();

    qp.pop();

    for(int k = 0; k < sizeof(di)/sizeof(*di); ++k){
      pi next( now.first + di[k], now.second + dj[k] );
      if( isinside( next, h, w ) ){
	if( tapes[next.first][next.second] == 0 ){
	  tapes[next.first][next.second] = -1;
	  qp.push( next );
	}
      }
    }
  }
}

int main()
{
  while( true ){
    int ans = 0;
    static int tapes[N][N];
    CCS CCx; // compressed coordinate system
    CCS CCy;
    vector< rectangle > vrect;
    
    int W,H;
    scanf("%d%d", &W, &H);
    if( W == 0 && H == 0 ) break;
    CCx[0]=CCx[W]=0;
    CCy[0]=CCy[H]=0;
    
    int n;
    scanf("%d", &n);
    
    for(int i = 0; i < n; ++i){
      int a,b,c,d;
      scanf("%d%d%d%d", &a, &b, &c, &d);
      CCx[a]=CCx[c]=0;
      CCy[b]=CCy[d]=0;
      vrect.push_back( rectangle( a, b, c, d ) );
    }

    CompressCCS( CCx );
    CompressCCS( CCy );

    for(int i = 0; i < N; ++i){
      for(int j = 0; j < N; ++j){
	tapes[i][j] = 0;
      }
    }

    for(int i = 0; i < vrect.size(); ++i){
      CCS::iterator xbeg = CCx.find( vrect[i].x1 );
      CCS::iterator xend = CCx.find( vrect[i].x2 );
      for( CCS::iterator itCCx = xbeg; itCCx != xend; ++itCCx ){
	CCS::iterator ybeg = CCy.find( vrect[i].y1 );
	CCS::iterator yend = CCy.find( vrect[i].y2 );
	for( CCS::iterator itCCy = ybeg; itCCy != yend; ++itCCy ){
	  tapes[ itCCy->second ][ itCCx->second ]++;
	}
      }
    }
    
    /*
    for(int i = 0; i < CCy.size(); ++i){
      for(int j = 0; j < CCx.size(); ++j){
	cout << tapes[i][j] << ' ';
      }
      cout << endl;
    }
    cout << endl;
    */

    for(int i = 0; i < CCy.size(); ++i){
      for(int j = 0; j < CCx.size(); ++j){
	if( tapes[i][j] == 0 && isinside( pi(i,j), CCy.size(), CCx.size() ) ){
	  BFS( i, j, CCy.size(), CCx.size(), tapes );
	  ++ans;
	}
      }
    }

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

Measured memory_bytes: 16000
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
int main() {
	int H, W, i, j;
	cin >> H >> W;
	string S(W + 2, '#');
	vector<vector<char>> a(H, vector<char>(W));

	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> a[i][j];
		}
	}
	cout << S << endl;
	for (i = 0; i < H; i++) {
		cout << "#";
		for (j = 0; j < W; j++) {
			cout << a[i][j];
		}
		cout << "#" << endl;
	}
	cout << S << endl;
	cin >> S;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt,n,s;
void func(int sum,int c,int j){
	int i;
	if(c<n){
		for(i=j;i<10;i++){
			if(sum+i>s)break;
			if(sum+i==s&&c+1==n) cnt++;
			else if(sum+i<s&&c+1<n)	func(sum+i,c+1,i+1);
		}
	}
}
int main(void){
	int i;
	while(1){
		cin>>n>>s;
		if(n==0)break;
		cnt=0;
		func(0,0,0);
		cout<<cnt<<endl;
	}
	return 0;
}

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

void solve()	{
	int n;
	cin >> n;
	int l[n];
	for(int i=0; i<n; i++)	cin >> l[i];
	sort(l,l+n);
	int ans=0;
	for(int i=0; i<n; i++)	{
		for(int j=i+1; j<n; j++)	{
			for(int k=j+1; k<n; k++)	{
				if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i])	{
					if(l[i]+l[j]>l[k])	ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

int main()	
{
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

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

int main()
{
  string S;
  int64_t K, cnt = 0;
  cin >> S >> K;
  char prev = S.at(0);
  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) != prev)
    {
      break;
    }
    else if (i == S.size() - 1)
    {
      cout << S.size() * K / 2 << endl;
      return 0;
    }
  }
  for (int i = 0; i < S.size() - 1; i++)
  {
    if (S.at(i) == S.at(i + 1))
    {
      cnt++;
      i++;
    }
  }
  cnt *= K;
  if (S.at(0) == S.at(S.size() - 1))
  {
    int a = 1, b = 1;
    for (int i = 1; i < S.size(); i++)
    {
      if (S.at(i - 1) == S.at(i))
        a++;
      else
        break;
    }
    for (int i = S.size() - 2; i >= 0; i--)
    {
      if (S.at(i + 1) == S.at(i))
        b++;
      else
        break;
    }
    cnt -= (a / 2 + b / 2 - (a + b) / 2) * (K - 1);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  
  int h[n];
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  
  int count=0;
  for(int i=0;i<n;i++){
    if(h[i]>=k){
      count++;
    }
  }
  
  printf("%d",count);
  
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>

int maps[1005][1005][3]={{{0}}};
int main(void){
  int m,n,k;
  scanf("%d%d%d",&m,&n,&k);
  int i,j,p;
  char zi[1002];
  for(i=1;i<=m;i++){
    scanf("%s",zi);
    for(j=1;j<=n;j++){
      for(p=0;p<3;p++){
	maps[i][j][p]=maps[i-1][j][p]+maps[i][j-1][p]-maps[i-1][j-1][p];
      }
      switch(zi[j-1]){
      case 'J':
	maps[i][j][0]++;
	break;
      case 'O':
	maps[i][j][1]++;
	break;
      case 'I':
	maps[i][j][2]++;
	break;
      }
    }
  }
  int a,b,c,d;
  int ans[3]={0};
  for(i=0;i<k;i++){
    scanf("%d%d%d%d",&a,&b,&c,&d);
    for(p=0;p<3;p++){
      ans[p]=maps[c][d][p]-maps[c][b-1][p]-maps[a-1][d][p]+maps[a-1][b-1][p];
    }
    printf("%d %d %d\n",ans[0],ans[1],ans[2]);
  }
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int main()
{
	fastio;

	int a, b, c;
	int k;

	cin >> a >> b >> c;
	cin >> k;

	while (a >= b)
		b *= 2, k--;

	while (b >= c)
		c *= 2, k--;

	cout << (k < 0 ? "No\n" : "Yes\n");

	return 0;
}


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

int main() {
    int N, K; cin >> N >> K;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // ソート
    sort(a.begin(), a.end());

    // K 差の最小値
    long long res = 1LL<<60; // INF の気持ち //「1LL<<60」は2^60の意味
    for (int i = 0; i+K-1 < N; ++i) res = min(res, a[i+K-1] - a[i]);
    cout << res << endl;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2 * 1000 * 100 + 47;
int C[MAX][2];
string s;
vector<int> g[MAX];
queue<int> q;

int main()
{
	//freopen("in.txt","r", stdin);
	ios::sync_with_stdio(false);cin.tie(0);
	int n, m;
	cin >> n >> m >> s;
	FOR(i, 0, m)
	{
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		g[a].PB(b);
		C[a][s[b] - 'A']++;
		g[b].PB(a);
		C[b][s[a] - 'A']++;
	}

	int cnt = 0;
	FOR(i, 0, n)
	{
		if (C[i][0] == 0 || C[i][1] == 0)
		{
			q.push(i);
		}
	}

	while (!q.empty())
	{
		int v = q.front();
		q.pop();
		cnt++;

		FOR(i, 0, SZ(g[v]))
		{
			int to = g[v][i];
			if (C[to][0] == 0 || C[to][1] == 0) continue;

			C[to][s[v] - 'A']--;
			if (C[to][s[v] - 'A'] == 0)
			{
				q.push(to);
			}
		}
	}

	if (cnt == n)
	{
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 12368
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;

int N,M;
struct Edge
{
    int u,v,next;
}edge[MaxM];
int cont;
int head[MaxN];
void add(int u, int v)
{
    edge[cont].u = u;
    edge[cont].v = v;
    edge[cont].next = head[u];
    head[u] = cont++;
}
void Add(int u, int v)
{
    add(u,v),add(v,u);
}

void init()
{
    cont = 0;
    MST(head, -1);
}

int vis[MaxN];
int DFS(int u, int nums)
{
   // cout << u << " " << nums << endl;
    vis[u] = nums;
    if(nums == N) return 1;
    int ans = 0;
    for(int i=head[u];i!=-1;i=edge[i].next)
    {
        int v = edge[i].v;
        if(vis[v]&&vis[v]<nums) continue;
        else
        {
            ans += DFS(v, nums+1);
        }
    }
    vis[u] = 0;
    return ans;
}
void solve()
{
    int ans = DFS(1,1);
    printf("%d\n", ans);
}
int main()
{
    //std::ios::sync_with_stdio(false);
    init();
    scanf("%d%d", &N, &M);
    int a,b;
    while(M--)
    {
        scanf("%d%d", &a, &b);
        Add(a,b);
    }
    solve();
    //system("pause");
}


Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())
ans1 = c * 2 * min(x,y) + a * (x-min(x,y)) + b * (y-min(x,y))
ans2 = a*x + b*y
ans3 = c * 2 * max(x,y)
print(min(ans1,ans2,ans3))

Measured memory_bytes: 3060
n, m = map(int,input().split())
a = [[] for _ in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    a[x-1] += [y-1]
for i in a[0]:
    for j in a[i]:
        if j == n-1 :
            print("POSSIBLE")
            exit()
print("IMPOSSIBLE")

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

int main(){
  int w, h; cin >> w >> h;
  ll p[w], q[h];
  pair<ll, int> r[w+h];
  REP(i, w){
    cin >> p[i];
    r[i] = {p[i], 0};
  }
  REP(i, h){
    cin >> q[i];
    r[i+w] = {q[i], 1};
  }

  sort(r, r+w+h);

  ll cost = 0, a = w+1, b = h+1;
  REP(i, w+h){
    if(r[i].second){
      cost += a*r[i].first;
      b--;
    }
    else{
      cost += b*r[i].first;
      a--;
    }
  }

  cout << cost << endl;

  return 0;
}


Measured memory_bytes: 4992
"""
https://atcoder.jp/contests/abc095/tasks/abc095_a
"""

s = str(input())
s_1, s_2, s_3 = s[0], s[1], s[2]

price = 700
add_price = 0
for x in (s_1, s_2, s_3):
    if x == "o":
        add_price += 100

last_price = price + add_price
print(last_price)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
string S;

int main(){
	cin >> S;
	int N = S.size();
	vector<int> cum;
	cum.push_back(0);
	for(int i=0; i<N; i++) cum.push_back(S[i]-'0'+cum[i]);

	for(int k=(N+1)/2; k<=N; k++){
		int n = cum[k]-cum[N-k];
		//cout << k << " " << N-k << " " << n << endl;
		if(0<n&&n<2*k-N){
			cout << k-1 << endl;
			return 0;
		}
	}

	cout << N << endl;
	return 0;
}


Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int getWeight(int a, int b, int c) {
  return a*200 + b*300 + c*500;
}

int getMoney(int a, int b, int c) {
  int res = 0;
  
  int a_ori = a%5;
  int a_dis = a-a_ori;
  res += a_dis*380*0.80 + a_ori*380;
  
  int b_ori = b%4;
  int b_dis = b-b_ori;
  res += b_dis*550*0.85 + b_ori*550;
  
  int c_ori = c%3;
  int c_dis = c-c_ori;
  res += c_dis*850*0.88 + c_ori*850;
  
  return res;
}

int main() {
  int N;
  while(cin >> N && N) {
    int ans = (int)1e9;
    for(int i=0; i<30; i++)
      for(int j=0; j<30; j++)
	for(int k=0; k<30; k++)
	  if(getWeight(i, j, k) == N) {
	    ans = min(ans, getMoney(i, j, k));
	  }
    
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cassert>
#include<ctime>
#include<climits>
#include<queue>
#include<fstream>
#include<deque>
#include<iomanip>
#include<list>
#include<stack>
#include<sstream>
#include<string>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define F first
#define S second
#define all(n) n.begin(),n.end()
#define pb push_back
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define INF (1<<27)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<P,int> PI;
typedef pair<P,P> PP;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};

int main(){
  int h,n;
  while(true){
  cin >> n >> h;
  if(n+h == 0)break;
  long area = n*n*n;

  
  map<PI,bool> coor;
  while(h-- > 0){
    string coordinate;
    int a,b;
    cin >> coordinate >> a >> b;
    int x,y,z;
   
    if(coordinate == "xy"){
      REP(i,1,n+1){
	if(!coor[PI(P(a,b),i)]){
	  coor[PI(P(a,b),i)] = true;
	}
      }
    }
    else if(coordinate == "xz"){
      REP(i,1,n+1){
	if(!coor[PI(P(a,i),b)])coor[PI(P(a,i),b)] = true;
      }
    }
    else if(coordinate == "yz"){
      REP(i,1,n+1){
	if(!coor[PI(P(i,a),b)])coor[PI(P(i,a),b)] = true;
      }
    }
    else assert(false);
    
  }
  cout << n*n*n - coor.size() << endl;
  }
return 0;
}

Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool flag = false;
  
  for(int i = 0; i < N; i++){
    string C;
    cin >> C;
    if(C == "Y")
      flag = true;
  }
  
  if(flag){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
S = input()
dp0 = [0]*13
dp0[0] = 1
dp = [dp0]
#print(dp[0])
for i in range(len(S)):
  dpi = dp[i]
  dpn = [0]*13
  c = S[i]
  e = (10**((len(S)-i-1)%12))%13
  if c == "?":
    for j in range(13):
      r = 0
      for d in range(10):
        r += dpi[(j+13-d*e)%13]
      dpn[j] = r%1000000007
  else:
    d = int(c)
    for j in range(13):
      dpn[j] = dpi[(j+13-d*e)%13]
  #print(dp[i+1])
  dp.append(dpn)
print(dp[len(S)][5])


Measured memory_bytes: 65628
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, m, k[10], s[10][10], p[10];
  scanf("%d %d", &n, &m);
  for(int i = 0; i < m; i++){
    scanf("%d", &k[i]);
    for(int j = 0; j < k[i]; j++) scanf("%d", &s[i][j]);
  }
  for(int i = 0; i < m; i++) scanf("%d", &p[i]);

  int sw[1024][10]; int d, r, l; int w = 1;
  for(int i = 0; i < n; i++){
    w *= 2;
  }
  for(int j = 0; j < w; j++){
    r = j; l = 0;
    while(r > 0){
      sw[j][l++] = r % 2;
      r /= 2;
    }
  }

 
 

  int sum; int flag; int ans = 0;

  for(int i = 0; i < w; i++){
    flag = 0;
    for(int j = 0; j < m; j++){
      sum = 0;
      for(int q = 0; q < k[j]; q++){
	sum += sw[i][s[j][q] - 1];
      }
      if(sum % 2 == p[j]) flag++;
      else break;
    }
    if(flag == m) ans++;
  }

  printf("%d\n", ans);

  return 0;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define endl '\n'
#define int long long


int32_t  main()
{
    IOS; 
    int n;
    cin>>n;
    if(n%10==3)
    {
        cout<<"bon";
        return 0;
    }
    if(n%10==0||n%10==1||n%10==6||n%10==8)
    {
        cout<<"pon";
        return 0;
    }
    cout<<"hon";
}

Measured memory_bytes: 3612
s = list(input())
kids = [0] * len(s)

for d in ["R", "L"]:
    c = 0
    for i in range(len(s)):
        if s[i] == d:
            c += 1
        else:
            kids[i] += c // 2
            kids[i - 1] += (c + 1) // 2
            c = 0
    s.reverse()
    kids.reverse()

print(" ".join([str(k) for k in kids]))


Measured memory_bytes: 11180
#include <stdio.h>
#include <math.h>

/***Σ(゜д゜;) ナゼッ…***/

int main(void)
{
	int n, i;
	int ans;
	double xa, ya, ra,
		  xb, yb, rb;
	double x, y, len, tmp;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);
		
		x = xb - xa;
		y = yb - ya;
		
		len = sqrt((x * x) + (y * y));
		
		/*
		printf("%f %f\n", x, y);
		printf("%f\n", len);
		*/
		
		if (len <= ra + rb){
			if (len + rb < ra){
				ans = 2;
			}
			else if (len + ra < rb){
				ans = -2;
			}
			else {
				ans = 1;
			}
		}
		else {
			ans = 0;
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 640
"use strict";
    
const main = arg => {
    const formula = arg.split("\n")[0].split(" ");
    const A   = parseInt(formula[0]);
    const ope = formula[1];
    const B   = parseInt(formula[2]);
    
    console.log(ope == "+" ? A + B : A - B);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <stdlib.h>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <stdio.h>
#include <fstream>
#include <time.h>
using namespace std;
const double PI = 3.14159265358979323846;
const long long int MOD = 1000000000 + 7;

struct UnionFind {
    vector<int> parent;

    UnionFind(int N) : parent(N) {
        for (int i = 0; i < N; i++) {
            parent[i] = -1;
        }
    }

    int root(int i) {
        if (parent[i] < 0) {
            return i;
        }
        return (parent[i] = root(parent[i]));
    }

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx != ry) {
            parent[ry] += parent[rx];
            parent[rx] = ry;

            return true;
        }
        else {
            return false;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int treeSize(int x) {
        

        return -parent[root(x)];
    }
};

long long int modpow(long long int base, long long int pow, long long int mod) {
    if (pow == 1) {
        return base;
    }
    else if (pow == 0) {
        return 1;
    }

    if (pow % 2 == 0) {
        auto temp = modpow(base, pow / 2, mod);
        return (temp * temp) % mod;
    }
    else {
        return base * modpow(base, pow - 1, mod) % mod;
    }
}

long long int moddiv(long long int X, long long int Y, long long int mod) {
    auto fermatDiv = modpow(Y, mod - 2, mod);

    return (X * fermatDiv) % mod;
}



int main() {
    long long result = 1;
    long long N;
    cin >> N;
    vector<long long> A(N);
    bool isContainZero = false;
    for (long long i = 0; i < N; i++) {
        long long temp;
        cin >> temp;
        A[i] = temp;

        if (temp == 0) {
            isContainZero = true;
        }
    }

    if (!isContainZero) {
        for (long long i = 0; i < N; i++) {
            result *= A[i];
            if (result > 1000000000000000000 || result <= 0) {
                cout << -1 << endl;
                return 0;
            }
        }
        cout << result << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 4052
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
ceil = math.ceil
FT = []
s = input()
x,y = ma()
if s[0]=="T":
    FT.append(0)
prev = s[0]
cnt=0
for i in range(len(s)):
    if s[i]==prev:
        cnt+=1
    else:
        FT.append(cnt)
        cnt=1
    prev=s[i]
FT.append(cnt)
Fxy = [[],[]]
idx=0#0->x 1->y
for i in range(len(FT)):
    if i%2==0:
        Fxy[idx].append(FT[i])
    else:
        if FT[i]%2==0:
            pass
        else:
            idx=(idx+1)%2
def reach(xls,x,f=False):
    l = len(xls)
    su = sum(xls)
    if abs(x) >su:
        return False
    dp = [[False]*(2*su+1) for _ in range(l+1)] #dp[i][j] i 個使ったときにjにいられるか
    dp[0][0] =True

    for i in range(l):
        d = xls[i]
        if i==0 and f:
            if s[0]=="F":
                dp[1][d]=True
                continue
        for j in range(-su,su+1):
            dp[i+1][j] = dp[i][j-d] or dp[i][j+d]
    #print(dp)
    return dp[-1][x]
fx = reach(Fxy[0],x,f=True)
fy = reach(Fxy[1],y)
yn(fx and fy)
#print(FT)
#print(dpx)
#print(dpy)


Measured memory_bytes: 199536
function Main(input){

    var H = input.split("\n")[0].split(" ")[0];
    var W = input.split("\n")[0].split(" ")[1];
    var h = input.split("\n")[1].split(" ")[0];
    var w = input.split("\n")[1].split(" ")[1];
    H = parseInt(H,10);
    W = parseInt(W,10);
    h = parseInt(h,10);
    w = parseInt(w,10);

    var a = H * W - (H * w + W * h);
    var b = a + h * w;
    console.log(b);



}

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

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

void dfs(int dp[],bool vis[],int u,vector<int> adj[]){
    vis[u]=true;
    for(int i=0;i<adj[u].size();i++){
        if(!vis[adj[u][i]]){
            dfs(dp,vis,adj[u][i],adj);
        }
        dp[u] = max(dp[u],1+dp[adj[u][i]]);
    }
}

int main(){
    int n,m,i,j;
    cin>>n>>m;
    vector<int> adj[n+1];
    for(i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    int dp[n+1],mx=0;
    memset(dp,0,sizeof(dp));
    bool vis[n+1];
    memset(vis,false,sizeof(vis));
    for(i=1;i<=n;i++){
        if(!vis[i]){
            dfs(dp,vis,i,adj);
        }
    }
    for(i=1;i<=n;i++){
        mx = max(dp[i],mx);
    }
    cout<<mx;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;
const int INF = INT_MAX;

typedef pair<int, int> P;

vector<int> G[300010];
vector<pair<int, int> > edge[1001000];
vector<int> isvisit;
vector<int> TG[200100];

int idx;

void dfs(int v, int k){
    if(isvisit[v] == k) return;
    isvisit[v] = k;
    G[idx].push_back(v);
    G[v].push_back(idx);
    for(auto&& n : TG[v]){
        dfs(n, k);
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    REP(i,M){
        int p, q, c;
        cin >> p >> q >> c;
        p--, q--, c--;
        edge[c].emplace_back(p,q);
    }

    isvisit.resize(N, -1);
    idx = N;
    REP(i,1001000){
        if(edge[i].size() == 0) continue;

        vector<int> vec;
        for(auto&& e : edge[i]){
            int p = e.first;
            int q = e.second;
            TG[p].push_back(q);
            TG[q].push_back(p);
            vec.push_back(p);
            vec.push_back(q);
        }


        for(auto&& n : vec){
            if(isvisit[n] == i) continue;
            dfs(n, i);
            idx++;
        }

        for(auto&& e : edge[i]){
            int p = e.first;
            int q = e.second;
            TG[p].clear();
            TG[q].clear();
        }
    }

    vector<int> d(idx, INF);
    d[0] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0, 0));
    while(!que.empty()){
        auto p  = que.top(); que.pop();
        int cost = p.first;
        int ver = p.second;
        if(d[ver] < cost) continue;
        for(auto&& n : G[ver]){
            if(d[n] > cost + 1){
                d[n] = cost + 1;
                que.push(P(d[n], n));
            }
        }
    }

    if(d[N-1] == INF){
        cout << -1 << endl;
    }
    else{
        cout << d[N-1]/2 << endl;
    }

    return 0;
}


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

int main(){
	int a[3];
	for(int i=0; i<3; ++i) scanf("%d", &a[i]);
	set<int> st;
	for(int i=0; i<3; ++i) st.insert(a[i]);
	printf("%lu\n", st.size());
}

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  
  int max_l = 0;
  int sum = 0;
  
  for(int i=0; i<n; i++){
    cin >> l[i];
    sum += l[i];
    if(max_l<l[i]) max_l = l[i];
  }
  
  if(max_l < sum-max_l) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		
		//First number given is |V| = n
		int size = in.nextInt();
		
		//initialize the graph matrix
		int[][] graph = new int[size][size];
		for(int i = 0; i < size; i++) {
			for(int j = 0; j < size; j++) {
				graph[i][j] = 0;
			}
		}
				// note that graph[0] is for vertex 1
		
		for(int i = 0; i < size; i++) {
			int pos = in.nextInt() - 1; // the next number is the vertex we are on
			// next number given is number of relations for that particular vertex
			int numOfEdges = in.nextInt();
			for(int edge = 1; edge <= numOfEdges; edge++) {
				int col = in.nextInt() - 1;
				graph[pos][col] = 1;
			}
		}
		
		in.close();
		
		for(int i = 0; i < size; i++) {
			for(int j = 0; j < size; j++) {
				if(j == size - 1)
					System.out.print(graph[i][j]);
				else
					System.out.print(graph[i][j] + " ");
			}
			System.out.println();
		}

	}

}



Measured memory_bytes: 31168
#include<bits/stdc++.h>
#define maxn 405
using namespace std;
int n,h,in[maxn],out[maxn],f[maxn];
bool ok[maxn];
int find(int x){return !f[x]?x:f[x]=find(f[x]);}
int main()
{
	scanf("%d%d",&n,&h);
	for(int i=1,A,B,C,D;i<=n;i++){
		scanf("%d%d%d%d",&A,&B,&C,&D);
		int x=C?C+h:A, y=D?D:B+h;
		out[x]++,in[y]++;
		if((x=find(x))!=(y=find(y))) f[x]=y;
	}
	for(int i=1;i<=h;i++) if(in[i]>out[i]) return puts("NO"),0;
	for(int i=h+1;i<=h<<1;i++) if(out[i]>in[i]) return puts("NO"),0;
	for(int i=1;i<=h<<1;i++) if(in[i]!=out[i]||!(in[i]+out[i])) ok[find(i)]=1;
	for(int i=1;i<=h<<1;i++) if(!f[i]&&!ok[i]) return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 3816
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    int n;
    cin >> n;
    map<ll,ll,greater<ll>> mp;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    ll ans = 0;
    
    for(auto p : mp){
        if(p.second>=4){
        ans = p.first * p.first;
        break;
        }
    }
    ll max1=0,max2=0;
    for(auto p : mp){
        if(p.second>=2){
            if(max1==0) max1 = p.first;
            else{
                max2 = p.first;
                break;
            }
        }
    }
    ans = max(max1*max2,ans);
    
    
    cout << ans << ENT;
    return 0;
}

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


Measured memory_bytes: 6528
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	int N;
	int i;
	uint64_t Lp = 2, Lc = 1, Ln;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i < N; i++) {
		Ln = Lc + Lp;
		Lp = Lc;
		Lc = Ln;
	}
	printf("%" PRIu64 "\n", Lc);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
using namespace std;

#define Rep(i,l,r) for (int i = (l); i <= (r); ++ i)
#define RepD(i,r,l) for (int i = (r); i >= (l); -- i)
#define RepG(i,x) for (int i = hd[x]; i; i = e[i].nxt)

const int N = 200005;
int a[N], x, w, n, l, t, pos = 0;

int main () {
	scanf ("%d%d%d", &n, &l, &t);
	Rep(i,1,n) {
		scanf ("%d%d", &x, &w);
		if (w==1) a[i] = (x+t)%l, pos = pos+(x+t)/l;
		else a[i] = ((x-t)%l+l)%l, pos = pos+(x-t)/l-(x<t&&(x-t)%l);
	}
	sort (a+1, a+n+1); pos = (pos%n+n)%n+1;
	Rep(i,pos,n) printf ("%d\n", a[i]);
	Rep(i,1,pos-1) printf ("%d\n", a[i]);
	return 0;
}


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

int main(){
    int n; cin>>n;
    deque<int> dq;
    for(int i=1;i<=n;i++){
        int a; cin>>a;
        if((n-i)%2==0)dq.push_front(a);
        else dq.push_back(a);
    }
    for(auto it=dq.begin();it!=dq.end();it++){
        cout<<*it<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 3580