akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define M 100000
#define MM 2000000000
struct card{
	char suit;
	int num;
}L[M/2+2],R[M/2+2];
card A[M],B[M];
int partition(card B[],int p,int r){
	int x=B[r].num;
	int i=p;
	for(int j=p;j<r;j++){
		if(B[j].num<=x){
			card tmp=B[i];
			B[i]=B[j];
			B[j]=tmp;
			i++;
		}
	}
	card temp=B[i];
	B[i]=B[r];
	B[r]=temp;
	return i;
}

void qsrt(card B[],int p,int r){
	if(p<r){
		int q=partition(B,p,r);
		qsrt(B,p,q-1);
		qsrt(B,q+1,r);
	}
}

void merge(card A[],int l,int r){
	int m=(l+r)/2;
	int n1=m-l;
	int n2=r-m;
	int i;
	for(i=0;i<n1;i++) L[i]=A[l+i];
	for(i=0;i<n2;i++) R[i]=A[m+i];
	L[n1].num=R[n2].num=MM;
	int j=0;
	i=0;
	for(int k=l;k<r;k++){
		if(L[i].num<=R[j].num) A[k]=L[i++];
		else A[k]=R[j++];
	}
}

void mergesort(card A[],int l,int r){
	if(l+1<r){
		int m=(l+r)/2;
		mergesort(A,l,m);
		mergesort(A,m,r);
		merge(A,l,r);
	}
}

int main(){
	int i,n,j,k;

	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++){
		scanf("%c %d",&A[i].suit,&A[i].num);
		getchar();
	} 
	for(i=0;i<n;i++) B[i]=A[i];
	mergesort(A,0,n);
	qsrt(B,0,n-1);
	int judge=1;
	for(i=0;i<n;i++){
		if(A[i].suit != B[i].suit){
			judge=0;
			break;
		}
	}
	if(judge) printf("Stable\n");
	else printf("Not stable\n");
	//for(i=0;i<n;i++){
	//	printf("%c %d\n",A[i].suit,A[i].num);
	//}
	for(i=0;i<n;i++){
		printf("%c %d\n",B[i].suit,B[i].num);
	}
}


Measured memory_bytes: 4956
package main

import (
	"fmt"
)

func main() {
	var N int
	var S string
	fmt.Scanf("%d", &N)
	fmt.Scanf("%s", &S)
	if N%2 == 0 && S[0:N/2] == S[N/2:N] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
N, K = gets.chomp.split(' ').map(&:to_i);

ret = 0
last = N >= K ? (K - 1) : N
(1..last).each { |p|
  log = 0
  x = p
  while (x < K) do
    x *= 2
    log += 1
  end
  ret += (1 / N.to_f) * (0.5 ** log)
}
ret += (N - K + 1) / N.to_f if N >= K
print(ret)


Measured memory_bytes: 1788
dic ={'a':'A','b':'B','c':'C','d':'D','e':'E','f':'F','g':'G',\
      'h':'H','i':'I','j':'J','k':'K','l':'L','m':'M','n':'N',\
      'o':'O','p':'P','q':'Q','r':'R','s':'S','t':'T','u':'U',\
      'v':'V','w':'W','x':'X','y':'Y','z':'Z',' ':' ','.':'.'}


array = map(str, raw_input())

output = ''
for i in range(len(array)):
    output += dic[array[i]]
    
print output

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

int main()
{
	long long X;
	cin >> X;

	long long ans = X;
	if( ans == 2 ) {
	}
	else {
		while( 1 ) {
			if( ans % 2 == 0 ) {
				ans++;
			}
			else {
				int flag = 0;
				for( long long i = 3; i * i <= ans; i += 2 ) {
					if( ans % i == 0 ) {
						ans++;
						flag = 1;
						break;
					}
				}
				if( flag == 0 ) break;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
from itertools import permutations

N = int(input())
p = map(int,input().split())
q = map(int,input().split())

p = tuple(p)
q = tuple(q)

A = sorted(list(permutations(p,N)))

a = A.index(p)
b = A.index(q)

print(abs(a-b))

Measured memory_bytes: 8308
#include<bits/stdc++.h>
using namespace std;
long gcd(long m,long n){
  long temp;
  while(m%n!=0){
    temp=n;
    n=m%n;
    m=temp;
  }
  return n;
}

int main(){
  long A,B;
  cin >> A >>B;
  if(A>B){
    long tmp=A;
    A=B;
    B=tmp;
  }
  long lcm=B*A/gcd(B,A);
  cout << lcm << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 200005;

int n, q;
bool vis[MAXN], vis2[MAXN];
vector<int> op;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> n >> q;
    REP (i, q) {
        int d;
        cin >> d;
        vis[d] = true;
        op.eb(d);
    }

    REP (i, q) {
        if (!vis2[op.back()]) {
            cout << op.back() << endl;
            vis2[op.back()] = true;
        }
        op.pop_back();
    }

    REP1 (i, n) {
        if (!vis[i]) {
            cout << i << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3896
function Main(input) {
  input = input.split('\n');
  var i0 = input[0].split(' ');
  var N = i0[0];
  var K = i0[1];
  var Q = i0[2];

  var results = [];
  for (var i = 0; i < N; i++) {
    results.push(K - Q);
  }
  for (var i = 1; i < input.length; i++) {
    results[input[i] - 1] = results[input[i] - 1] + 1;
  }
  results = results.map(n => n <= 0 ? 'No': 'Yes');
  console.log(results.join('\n'));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main(){
  COMinit();
  string N;
  int K;
  cin >> N >> K;
  ll ans = 0;
  int beki = 1;
  REP(i, K-1){
    beki *= 9;
  }
  // for(int i = N.size()-1; i >= K; i--){
  //   ans += 9 * COM(i-1, K-1) * beki;
  // }
  // cerr << ans << endl;
  int cnt = 0;
  REP(i, N.size()){
    if(N[i] != '0'){
      cnt++;
      if(cnt == K){
        ans += (N[i]-'0');
        ans += COM(N.size()-i-1, 1) * 9;
        break;
      }
      else if(cnt == K-1){
        ans += (N[i]-'0'-1) * COM(N.size()-i-1, 1) * 9;
        ans += COM(N.size()-i-1, 2) * 9 * 9;
      }
      else if(cnt == K-2){
        ans += (N[0]-'0'-1) * COM(N.size()-1, K-1) * beki;
        ans += COM(N.size()-1 , K) * 9 * 9 * 9;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12160
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;


typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

void solve(){
	while(true){
		ll N, M;
		cin >> N >> M;
		if(N == 0 && M == 0) break;
		vector<ll> A(N);
		ll ans = -1;
		for(int i = 0; i < N; i++) cin >> A[i];
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(i == j) continue;
				if(A[i] + A[j] <= M) ans = max(ans, A[i] + A[j]);
			}
		}
		if(ans == -1)cout << "NONE" << endl;
		else cout << ans << endl;
	}
}


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





}



Measured memory_bytes: 3112
length, N = list(map(int, input().split()))

# 位置がsortされてなければsortしてあげる
an = list(map(int, input().split()))
max_interval = 0
for i in range(N):
    if i != N-1:
        max_interval = max(an[i+1] - an[i], max_interval)
    else:
        max_interval = max(an[0] + length - an[i], max_interval)
print(length - max_interval)

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n); rep(i,n) cin>>a[i];
  map<ll,ll> m;
  rep(i,n){
    m[a[i]]++;
    m[a[i]+1]++;
    m[a[i]-1]++;
  }
  ll ans=0;
  for(auto e:m){
    chmax(ans,e.second);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7040
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b,c,n,i;
    
    scanf("%d %d %d",&a, &b, &c);
    
    for(i=a; i<=b; i++){
        if(c%i == 0){
            n++;
        }
    }
    printf("%d\n",n);
    return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main(){
    int i,length,ans=0;
    char n[200010]={};
    scanf("%s",n);
    length=strlen(n);
    for(i=0; i<length; i++){
        ans+=n[i]-48;
    }
    if(ans%9==0){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 1928
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const int INF=1e7;

LL cx[100001],cy[100001];

int main(){
    int n,m;
    cin >> n >> m;
    LL x[n],y[m];
    for(int i=0;i<n;i++) cin >> x[i];
    for(int i=0;i<m;i++) cin >> y[i];
    sort(x,x+n);
    sort(y,y+m);
    for(LL i=1;i<=100000;i++){
        cx[i]=(i+i*(n-i-1))%mod;
        cy[i]=(i+i*(m-i-1))%mod;
    }
    LL sx=0,sy=0;
    for(int i=0;i<n-1;i++){
        sx+=(x[i+1]-x[i])%mod*cx[i+1]%mod;

        sx%=mod;
    }
    for(int i=0;i<m-1;i++){
        sy+=(y[i+1]-y[i])%mod*cy[i+1]%mod;
        sy%=mod;
    }
    cout << sx*sy%mod << endl;
    return 0;
}

Measured memory_bytes: 3328
# get input
n=gets.to_i
target=[]
n.times do
  target << gets.to_i
end

# insertion sort method
def insertion_sort a, n, g
  cnt = 0
  (g..n-1).each do |i|
    v = a[i]
    j = i - g
    while j >= 0 && a[j] > v
      a[j+g] = a[j]
      j = j - g
      cnt+=1
    end
    a[j+g] = v
  end
  return cnt
end

# main

g = [1]
cnt = 0
while (i = 3 * g[0] + 1) < n do
 g.unshift i
end
g.each do |i|
 cnt += insertion_sort target, n, i
end

# output
puts g.length
puts g*' '
puts cnt
target.each do |i|
 puts i
end

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

int main(){
    int A[1000];
    int i,N;
    int v,s,j;
    scanf("%d",&N);
    if(N > 100){
        printf("error!");
        return 1;
    }
    for(i=0;i<N;i++)
    {
        scanf("%d",&A[i]);
        printf("%d",A[i]);
        if(i!=N-1){
            printf(" ");
            
        }
    }
      printf("\n");
    
    for(s=1;s<N;s++){
        v = A[s];
        j = s - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
        for(i=0;i<N;i++){
            printf("%d",A[i]);
            if(i!=N-1){
                printf(" ");
            }
            
        }
        printf("\n");
}
    return 0;
}



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

int main() {
  
  int N;
  cin >> N;
  
  vector<ll> A(N+1), B(N);
  ll killcnt=0;
  for( int i=0; i<N+1; i++ ){
	cin >> A.at(i);
  }
  for( int i=0; i<N; i++ ){
	cin >> B.at(i);
  }
  
  for( int i=0; i<N; i++ ){
	ll kill=min(A.at(i), B.at(i));
    A.at(i)-=kill;
    B.at(i)-=kill;
    killcnt+=kill;
    
    kill=min(A.at(i+1), B.at(i));
    A.at(i+1)-=kill;
    B.at(i)-=kill;
    killcnt+=kill;
  }
  
  cout << killcnt << endl;
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll mod= 998244353;
int main(void){
    ll n,k;cin>>n>>k;
    vector<ll> dp(2*n+10,0);
    vector<pair<ll,ll>> p(k);
    rep(i,k)cin>>p[i].first>>p[i].second;
    dp[0]=1;
    dp[1]=-1;
    rep(i,n){
        if(i!=0)dp[i]=(dp[i]+dp[i-1])%mod;
        rep(j,k){
            ll l=p[j].first,r=p[j].second;
            dp[i+l]+=dp[i];
            dp[i+l]%=mod;
            dp[i+r+1]+=(mod-dp[i]);
            dp[i+r+1]%=mod;
        }
    }
    //rep(i,n)cout<<i<<" "<<dp[i]<<endl;
    cout<<dp[n-1]<<endl;
}

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

typedef long long ll;

int main()
{
  ll A, B;


  std::cin >> A >> B;
  ll ans = A + B;
  ans = std::max(ans, A - B);
  ans = std::max(ans, A * B);

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


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt=0;


void visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE)  visit(v);
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(void){
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  tt=0;
  for(u=0;u<n;u++) if(color[u]==WHITE) visit(u);
  for(u=0;u<n;u++) printf("%d %d %d\n",u+1,d[u],f[u]);
}



int main(){
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++) for(j=0;j<n;j++) M[i][j]=0;

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();
  return 0;
}



Measured memory_bytes: 2144
/*
------------------------------------------------------
 
    Dilon Mein Tum Apni Betaabiyan Leke Chal Rahe Ho,
    Toh Zinda Ho Tum.
       
    Nazar Mein Khwabon Ki Bijliyan Leke Chal Rahe Ho,
    Toh Zinda Ho Tum.
	
    Hawa Ke Jhokon Ke Jaise Aazad Rehno Sikho,
    Tum Ek Dariya Ke Jaise Lehron Mein Behna Sikho,
    Har Ek lamhe Se Tum Milo Khole Apni Bhaayein,
    Har Ek Pal Ek Naya Samha Dekhen Yeh Nigahaein,
    
    Jo Apni Aankhon Mein Hairaniyan Leke Chal Rahe Ho,
    Toh Zinda Ho Tum.
    
    Dilon Mein Tum Apni Betaabiyan Leke Chal Rahe Ho,
    Toh Zinda Ho Tum.   
 
    - Imran ( Zindagi Na Milegi Dobara )
 
-------------------------------------------------------	                                                                                                
 
	Author :- Gaurang_Kothiya
	Nirma University
 
*/ 
 
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  
 
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007
 
 
 

void Solve()
{	
	int n;
	cin>>n;
	ll ans=1,x;
	ll res=1000000000000000000;
	bool f=true;
	f(i,1,n)
	{
		cin>>x;
		ans *= x;
		if(x==0) f=false;
	}
	if(ans>res || ans<0) cout<<-1;
	else if(ans==0)
	{
		if(f) cout<<-1;
		else cout<<0;
	}
	else cout<<ans;
}
 
 
 
 
signed main() 
{
	speed	
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
} 

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}

ll calc(ll k,P p){
  return (k / p.first)*p.second + k % p.first;
}

ll solve(ll n,vector<P> list){
  //cout << list.size() << endl;
  if(list.size() == 1){
    return calc(n,list[0]);
  }else if(list.size() == 2){
    ll ans = n;
    for(ll i=0; i<=n; i++){
      ll t = n-i;
      ans = max(ans, calc(i,list[0]) + calc(t,list[1]));
    }
    return ans;
  }else{
    ll ans = n;
    for(int i=0; i<=n; i++){
      for(int j=0; j<=n-i; j++){
        int k = n-i-j;
        ans = max(ans, calc(i,list[0]) + calc(j,list[1])+calc(k,list[2]));
      }
    }
    return ans;
  }
}

int main(){
	cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,t;
  cin >> n;
  vector<int> a,b;
  vector<P> fi,se;
  for(int i=0; i<3; i++){
    cin >> t; 
    a.push_back(t);
  }
  for(int i=0; i<3; i++){
    cin >> t; 
    b.push_back(t);
  }
  for(int i=0; i<3; i++){
    if(a[i]<b[i]){
      P tp(a[i],b[i]);
      fi.push_back(tp);
    }else if(a[i]>b[i]){
      P tp(b[i],a[i]);
      se.push_back(tp);
    }
  }
  //cout << n << endl;
  if(fi.size()>0) n = solve(n,fi);
  if(se.size()>0) n = solve(n,se);
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long L,R;
  cin >> L >> R;
  for(int i=1;i<1000000;i++){
    if(L<=2019*i&&2019*i<=R){
      cout << "0" << endl;
      return 0;
    }
  }
  long long ans=2020;
  for(long long i=L;i<R;i++){
    for(long long j=i+1;j<=R;j++){
      long long num=(i*j)%2019;
      ans=min(ans,num);
    }
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int F,G,H,I,J;
	cin >> F >> G >> H >> I >> J;

	int average;
	if(F < 40) F = 40;
	if(G < 40) G = 40;
	if(H < 40) H = 40;
	if(I < 40) I = 40;
	if(J < 40) J = 40;

	average = (F+G+H+I+J) / 5;

	cout << average << endl;


	/*
	int A,B,C,D,E;
	cin >> A >> B >> C >> D >> E;

	int answer;
	if(A < 0){
		answer = -A * C + D + B * E;
	}
	if(A > 0){
		answer = (B - A) * E;
	}
	cout << answer << endl;
	*/

	return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
int a,b;
cin >> a >> b;
cout << a-b+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef long double ldbl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
// constant
const double PI  = acos(-1.0);
const int    MOD = (int)(1e9 + 7);
// DO NOT set INFTY_XXXs constants. They may bring some BUG! Use MAX_XXXs in climit instead.
 
// clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
// debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl


template<typename T>
inline vector<T> cin_vector(const size_t n) {
     vector<T> vec;
    vec.reserve(n);
    REP(i, n) {
        T element; cin >> element;
        vec.push_back(element);
    }
    return vec;
}

template<typename T>
inline vector< vector<T> > cin_matrix(const size_t m, const size_t n) {
    vector< vector<T> > matrix;
    matrix.reserve(m);
    REP(i, m) {
        vector<T> vec = cin_vector<T>(n);
        matrix.push_back(vec);
    }
    return matrix;
}

template<typename T>
inline void cout_vector(const vector<T>& vec) {
    REP(i, SZ(vec)-1) {
       cout << vec[i] << ' ';
    }
    cout << vec[SZ(vec)-1] << endl;
}

template<typename T>
inline void cout_matrix(vector< vector<T> > matrix) {
    for(const vector<T>& vec : matrix) {
         cout_vector<T>(vec);
    }
}


int main() {
    int n, r; cin >> n >> r;
    int ans = (n >= 10 ? r : (r + 100*(10 - n)));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
n, m, k = map(int, input().split())
A = list(accumulate(map(int, input().split())))
B = list(accumulate(map(int, input().split())))
A=[0]+A
B=[0]+B
ans = []
for i in range(n+1):
    c = bisect_right(B, k-A[i])-1
    if c!=-1:
        ans.append(c+i)
print(max(ans))


Measured memory_bytes: 46112
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2639&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
ll solve(){
    ll res = 0;
    ll a,b,c; cin >> a >> b >> c;
    vector<ll> time; for(ll t = 0; t < 10000; t++) time.push_back(60*t+c);
    for(ll t = 0; t <= 100; t++){
        ll from = t*(a+b), to = t*(a+b)+a;
        if(upper_bound(time.begin(),time.end(),to) - lower_bound(time.begin(),time.end(),from)){
            return *lower_bound(time.begin(),time.end(),from);
        }
    }
    return res = -1;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3352
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=jp
#  Stack : python3
#  2018.11.26 yonezawa

from collections import deque
import sys
input = sys.stdin.readline

def calc(q):
    tq = deque()
    for i in range(len(q)):
        op = q.popleft()
#        print ("debug:",op)
        if ( op == '+' ):
            a = tq.pop()
            b = tq.pop()
            tq.append(b+a)
        elif (op == '-' ):
            a = tq.pop()
            b = tq.pop()
            tq.append(b-a)

        elif (op == '*' ):
            a = tq.pop()
            b = tq.pop()
            tq.append(b*a)
        elif (op == '/' ):
            a = tq.pop()
            b = tq.pop()
            tq.append(b//a)
        else:
            tq.append(int(op))
    return tq.pop()

def main():
    q = deque(map(str,input().split()))
    print (calc(q))

if __name__ == '__main__':
    main()


Measured memory_bytes: 6000
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n, q;
	string s;
	cin >> n >> q >> s;
	vector<pair<char, char> > command(q);
	for (int i = 0; i < q; ++i)
		cin >> command[i].first >> command[i].second;

	int ng = -1;
	int ok = n;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		int pos = mid;
		bool left = false;
		for (auto c : command) {
			if (s[pos] == c.first) {
				if (c.second == 'L') --pos;
				else ++pos;
				if (pos < 0) {
					left = true;
					break;
				}
				if (pos >= s.size()) 
					break;
			}
		}
		if (left) ng = mid;
		else ok = mid;
	}
	int left_bound = ok;

	ng = -1;
	ok = n;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		int pos = mid;
		bool right = false;
		for (auto c : command) {
			if (s[pos] == c.first) {
				if (c.second == 'L') --pos;
				else ++pos;
				if (pos < 0)
					break;
				if (pos >= s.size()) {
					right = true;
					break;
				}
			}
		}
		if (right) ok = mid;
		else ng = mid;
	}
	int right_bound = ok;

	cout << right_bound - left_bound << endl;
	return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  if(n==1){
    cout << "Hello World" << endl;
  }
  else{
    ll a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }

}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e3+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }


 int n,x,y,d[N][N];

 mi mp;
 

 
		void solve(){

			cin>>n>>x>>y;
			rep(i,0,n) rep(j,0,n) if(i!=j) d[i][j]=1e18;
			--x;--y;
			rep(i,0,n) {
				 rep(j,0,n) {
					   d[i][j]=min({d[i][j],abs(j-i),abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j)});
					   
					 }
			   }

			 
			 rep(i,0,n) {
				   rep(j,i+1,n) 
					 if(d[i][j]!=1e18) 
					 mp[d[i][j]]++;
				 }
				 
				int cnt=0; 
			 rep(i,1,n) {
				     if(mp[i]==0) cout<<0<<endl;
				     else cout<<mp[i]<<endl;
				 }					     	      		     
		 
		}

int32_t main() {
cool;
int t=1;
//cin>>t;
while(t--)
solve();


return 0;	   
}


Measured memory_bytes: 31744
from collections import Counter
a=int(input())
A=list(map(int,input().split()))
b=[A[i] for i in range(a) if i%2==0]
c=[A[i] for i in range(a) if i%2==1]
if b==c and len(set(b))==1 and len(set(c))==1:
    print(a//2)
else:
    bc=Counter(b).most_common()
    cc=Counter(c).most_common()
    if bc[0][0]==cc[0][0]:
        print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))
    else: print(a-bc[0][1]-cc[0][1])    

Measured memory_bytes: 21084
N = int(input())
TXY = [list(map(int,input().split())) for _ in range(N)]
#print(TXY)
for i in range(N):
  if i == 0:
    dt = TXY[i][0]
    dx = TXY[i][1]
    dy = TXY[i][2]
  else:
    dt = TXY[i][0] - TXY[i-1][0]
    dx = TXY[i][1] - TXY[i-1][1]
    dy = TXY[i][2] - TXY[i-1][2]
  if abs(dx) + abs(dy) > dt or (dx + dy) % 2 != dt % 2:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 27380
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n;
    cin >> n;
    VI a(n), b(n);
    ll A = 0;
    FOR(i, 0, n)cin >> a[i];
    FOR(i, 0, n)cin >> b[i];
    FOR(i, 0, n) {
        if (a[i] < b[i])A += (b[i] - a[i]) / 2;
        else A -= a[i] - b[i];
    }
    cout << (A >= 0 ? "Yes\n" : "No\n");
}



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

int main()
{
  int n;
  string str;

  cin >> n;
  while (n--){
    int res = 0, o_ct = 0, ct = 0;
    while (true){
      cin >> str;
      if (str == "OUT"){
        o_ct++;
        if (o_ct == 3)  break;
      }
      else if (str == "HOMERUN"){
          res += ct + 1;
          ct = 0;
      }
      else {
        if (ct + 1 == 4)  res++;
        else ct++;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1208
def divisor(n):
    i = 1
    T = []
    while i * i <= n:
        if n % i == 0:
            T.append([i, n // i])
        i += 1
    return list(T)

n = int(input())
T = divisor(n)
ans = 10**20
for t in T:
    dist = (t[0] - 1) + (t[1] - 1)
    ans = min(ans, dist)

print(ans)

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

using namespace std;

const int maxn = (int)1e5 + 5;
int a[maxn];
int dp[maxn];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &a[i]);
	}
	dp[0] = 0;
	for(int i = 1; i < n; ++i){
		if(i >= 2)
			dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
		else
			dp[i] = abs(a[i] - a[i - 1]);
	}
	printf("%d\n", dp[n - 1]);
	return 0;
}

Measured memory_bytes: 4620
import java.util.Scanner;

/**
 *
 * @author must
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        String ans;
        if (Math.abs(a-c) <= d){
            ans = "Yes";
        }else if((Math.abs(a-b) <= d) && (Math.abs(b-c) <= d)){
            ans = "Yes";
        }else{
            ans = "No";
        }
        
        System.out.println(ans);
    }
    
}


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

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

  int n, m, p, y, c;
  cin >> n >> m;
  vector<tuple<int, int, int>> pref_year_city(m);
  rep(i, m) {
    cin >> p >> y;
    pref_year_city[i] = make_tuple(p, y, i);
  }
  sort(pref_year_city.begin(), pref_year_city.end());
  vector<int> pref_id(m), cnt_id(m), cnt(n + 1);
  for(auto & pyc : pref_year_city) {
    tie(p, ignore, c) = pyc;
    ++cnt[p];
    pref_id[c] = p;
    cnt_id[c] = cnt[p];
  }
  rep(i, m) {
    cout << setfill('0') << setw(6) << pref_id[i];
    cout << setfill('0') << setw(6) << cnt_id[i] << "\n";
  }
}

Measured memory_bytes: 3840
search = input()

t = []
while(True):
  line = input()
  if (line == "END_OF_TEXT") :
    break
  
  line = [l for l in line.split()]
  
  for l in line:
    t.append(l.lower())

count = 0
for i in t:
  if (i == search):
    count += 1
    
print(count)


Measured memory_bytes: 5568
import Foundation
#if os(OSX) || os(iOS)
    import Darwin
#elseif os(Linux)
    import Glibc
#endif
protocol Scannable {
    static var format: String { get }
    static func scan() -> Self
}
extension Scannable {
    static func scan() -> Self {
        var arg: Self? = nil
        withUnsafeMutablePointer(&arg){withVaList([COpaquePointer($0)]){vscanf(self.format,$0)}}
        return arg!
    }
}
extension Int: Scannable { static var format: String { return "%d" } }
let n = Int.scan(), m = Int.scan()
var sx = UnsafeMutablePointer<Bool>.alloc(n+1)
var xe = UnsafeMutablePointer<Bool>.alloc(n+1)
memset(sx, 0, n+1); memset(xe, 0, n+1)
for i in 0..<m {
    let a = Int.scan(), b = Int.scan()
    if a == 1 {
        sx.advancedBy(b).memory = true
    } else if b == n {
        xe.advancedBy(a).memory = true
    }
}
var ans = "IMPOSSIBLE"
for i in 0..<n {
    if sx.advancedBy(i).memory && xe.advancedBy(i).memory {
        ans = "POSSIBLE"
        break
    }
}
print(ans)
sx.dealloc(n+1); xe.dealloc(n+1)

Measured memory_bytes: 1408
from operator import itemgetter

n, m = map(int, input().split())

e = [[int(i) for i in input().split()] for i in range(n)] 

e = sorted(e, key=itemgetter(0))

money = 0
mcount = m
isend = True

for i in e:
    mcount -= i[1]
    if mcount >= 0:
        money += i[0] * i[1]
    else :
        money += i[0] * (i[1] + mcount) 
        print(money)
        isend = False
        break

if isend == True:
    print(money)




Measured memory_bytes: 23592
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;

int main()
{
	int n , m;
	scanf("%d%d",&n,&m);
	string s[n];
	for(int i  = 0 ; i < n; i++) cin >> s[i];
	
	vector< vector<int> > dp(n,vector<int>(m) ) ;
	dp[0][0] = 1;
	for(int i = 0 ; i < n; i++){
		for(int j = 0 ; j < m ; j++){
			if(s[i][j] == '#') continue ;
			if(i) dp[i][j] = (dp[i-1][j]%mod + dp[i][j]%mod)%mod;
			if(j) dp[i][j] = (dp[i][j-1]%mod + dp[i][j]%mod)%mod;
		}
	}
	
	printf("%d\n",dp[n-1][m-1] );
    return 0;
}


Measured memory_bytes: 5248
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a = na()
b = sorted(a)

ff = b[2]-b[0]
fg = b[2]-b[1]
f = min(ff, fg)
if ff > fg:
    for i in range(f):
        b[0] += 1
        b[1] += 1

    g = b[2] - b[0]
    if g % 2 == 0:
        ans = g // 2
        print(f + ans)
    else:
        ans = g // 2 + 2
        print(f + ans)
elif ff < fg:
    for i in range(f):
        b[0] += 1
        b[1] += 1

    g = b[2] - b[1]
    if g % 2 == 0:
        ans = g // 2
        print(f + ans)
    else:
        ans = g // 2 + 2
        print(f + ans)
else:
    print(f)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int n;
	while(scanf("%d",&n) != EOF){
        int ans = 0;
        if(n % 39 == 0) ans = 39;
        else ans = n % 39;
        printf("3C%02d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1200
n = int(input())
a =[]
for _ in range(n):
    m = int(input())
    a.append([list(map(int, input().split())) for _ in range(m)])
c = 0
for i in range(1 << n):
    Flag = True
    for j in range(n):
        if ((i>>j)&1) == 1:
            for k in a[j]:
                if i>>(k[0]-1)&1 != k[1]:
                    Flag = False
        if Flag == False:break
    else:
        honest = sum([i>>j&1 for j in range(n)])
        c = max(c,honest)
print(c)

Measured memory_bytes: 3064
N = int(input())
s = input()

init = ["SS", "SW", "WS", "WW"]
next_animal = { ("S","o","S"):"S",
                ("S","o","W"):"W",
                ("S","x","S"):"W",
                ("S","x","W"):"S",
                ("W","o","S"):"W",
                ("W","o","W"):"S",
                ("W","x","S"):"S",
                ("W","x","W"):"W"}
for X in init:
    SW = X
    for i in range(1,N):
        SW += next_animal[SW[i],s[i],SW[i-1]]
    ls = len(SW)
    if SW[0] == SW[ls-1] and next_animal[SW[0],s[0],SW[ls-2]] == SW[1]:
        print(SW[:ls-1])
        break
else:
    print(-1) 


Measured memory_bytes: 9340
K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(K[n-1])

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;


void solve(){
  int a, b, t; cin >> a >> b >> t;
  int ans = 0;
  for(int i = a; i <= t; i += a){
    ans += b;
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
#include<stdio.h>
int main (){
/*
参加者N人
初期ポイントK
問題数Q
*/
	/*変数宣言*/
	int N,K,Q;
	int point[100000];//全員分のポイント
	int x;//受け取り用
	int kq;//K-Q用

	/*変数受け取り*/
	scanf("%d %d %d",&N,&K,&Q);
	kq = K - Q;
	for (int i = 1; i <= N; ++i)
	{
		point[i] =kq;
	}

	/*受け取った変数に対応する変数に++*/
	for (int i = 0; i < Q; ++i)
	{
		scanf("%d",&x);
		point[x]++;
	}

	/*出力*/
	for (int i = 1; i <= N; ++i)
	{
		/*printf("%dのポイントは%d\n",i,point[i]);*/
		if (point[i] <= 0)
		{
			printf("No\n");
		}else{
			printf("Yes\n");
		}
	}

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  long x = 0;
  for(int i = 1; i <= N; i++) {
    if(i % 3 != 0 && i % 5 != 0) x += i;
  }
  cout << x << endl;
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		long max = Long.MIN_VALUE;
		max = Math.max(max, 1l * a * c);
		max = Math.max(max, 1l * a * d);
		max = Math.max(max, 1l * b * c);
		max = Math.max(max, 1l * b * d);
		if(a <= 0 && b >= 0)
			max = Math.max(max, 0);
		if(c <= 0 && d >= 0)
			max = Math.max(max, 0);
		pw.println(max);
		pw.flush();
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] array = new Integer[n];
			for (int i = 0; i < n; i++)
				array[i] = new Integer(nextInt());
			return array;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		public double[] nextDoubleArray(int n) throws IOException {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		public static int[] shuffle(int[] a) {
			int n = a.length;
			Random rand = new Random();
			for (int i = 0; i < n; i++) {
				int tmpIdx = rand.nextInt(n);
				int tmp = a[i];
				a[i] = a[tmpIdx];
				a[tmpIdx] = tmp;
			}
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 32932
#include<stdio.h>
int main()
{
    int N,A,B,x;
    while(scanf("%d %d %d",&N,&A,&B)!=EOF)
    {
        x=N*A;
        if(x>=B)
            printf("%d\n",B);
        else
            printf("%d\n",x);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int H,W,dp[301][301], cost[301][301];
string g[300];
ll ans = 0;

int get(int x) {
    F0R(i,H+1) F0R(j,H+1) {
        cost[i][j] = cost[max(i-1,0)][max(j-1,0)];
        if (i == 0 || j == 0) continue;
        cost[i][j] += (g[i-1][x] == g[j-1][x+1]);
    }
    F0R(i,H+1) F0R(j,H+1) {
        if (i == 0 && j == 0) continue;
        dp[i][j] = min(dp[i-1][j],dp[i][j-1]);
        dp[i][j] += cost[i][j];
    }
    return dp[H][H];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> H >> W;
    F0R(i,H) cin >> g[i];
    F0R(j,W-1) ans += get(j);
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

int main(){
    int W, H, x, y, r;
    
    cin >> W >> H >> x >> y >> r;
    
    if(x + r <= W&&x - r >= 0){
        if(y + r <= H&&y - r >= 0){
            cout << "Yes" <<endl;            
        }else{
            cout << "No" <<endl;
        }
    }else{
        cout << "No" <<endl;   
    }
        
return 0;
}


Measured memory_bytes: 3116