akhauriyash/Code-Regression huggingface dataset:
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))


(defparameter *front* (list 1 2 3 4 5 6 7 8 9))
(defparameter *back* (last *front*))


(defun get-front()
  (let ((res (car *front*)))
    (setf *front* (cdr *front*))
    (unless (zerop (mod res 10))
      (setf (cdr *back*) (cons (+ (* res 10) (1- (mod res 10))) nil))
      (setf *back* (cdr *back*)))
    (setf (cdr *back*) (cons (+ (* res 10) (mod res 10)) nil))
    (setf *back* (cdr *back*))
    (when (< (mod res 10) 9)
      (setf (cdr *back*) (cons (+ (* res 10) (1+ (mod res 10))) nil))
      (setf *back* (cdr *back*)))
    res))

(defun main(n)
  (dotimes (i (1- n))
    (get-front))
  (get-front))

(princ (main (read)))


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

int compare (const void *a, const void *b){

	const int *x = a, *y = b;
	
	return *x < *y ? 1:*x > *y ? -1:0;
		
}


int main(){

	int i, n, k, sum = 0;
	
	scanf("%d%d", &n, &k);
	int t[n];
	for (i = 0; i < n; i++)
		scanf("%d", &t[i]);
	qsort(t, n, sizeof(t[0]), compare);
	for (i = 0; i < k; i++)
		sum += t[i];
	printf("%d\n", sum);

	return 0;
}


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

using namespace std;

int main(int argc, char*argv[]) {
  int a, b, k;
  cin >> a >> b >> k;
  int count = 0;
  int m = min(a, b);
  for(int i=m; i>=1; i--) {
    if(a % i == 0 && b % i == 0) {
      count ++;
    }

    if(count == k) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}

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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int turn = 1;
    while (a > 0 && c > 0) {
        if (turn == 1) {
            c -= b;
        } else {
            a -= d;
        }
        turn ^= 1;
    }
    if (a <= 0) {
        cout << "No";
    } else {
        cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 3548
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    x,y = inpm()
    if 2*x <= y and y <= 4*x and y%2 == 0:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 77244
n = int(input())
w = [input() for i in range(n)]
c = 0

if len(set(w)) != n:
  c = 101
else:
  for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
      c += 1

print("Yes" if c == n-1 else "No")

Measured memory_bytes: 3060
def gcd(a: int, b: int) -> int:
    """
    ユークリッドの互除法を用いて二数の最大公約数を求める。
    (関数名は"greatest common divisor"の略。)

    Parameters
    ----------
    a, b : 最大公約数を求めたい数。

    Returns
    -------
    b : 最大公約数
    """
    while a % b != 0:
        r = a % b
        a = b
        b = r
    return b


def lcm(a: int, b: int) -> int:
    """
    gcd関数を用いて二数の最小公倍数を求める。
    (関数名は"least common multiple"の略。)

    Parameters
    ----------
    a, b : 最小公倍数を求めたい数。

    Returns
    -------
    最小公倍数を返す。
    """
    return int(a * b / gcd(a, b))


A, B, C, D = map(int, input().split())

div = lcm(C, D)
ct_1 = B // div - A // div
ct_1 += 0 if A % div else 1

div = C
ct_2 = B // div - A // div
ct_2 += 0 if A % div else 1

div = D
ct_3 = B // div - A // div
ct_3 += 0 if A % div else 1

ct_sum = ct_2 + ct_3 - ct_1

ans = B - A + 1 - ct_sum

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(void)
{
  int n,a[10],b;
  for(;;){
    scanf("%d",&n); if(!n)break;
    memset(a,0,sizeof(a));
    while(n--){
      scanf("%d",&b);
      a[b]++;
    }
    for(n=0;n<10;n++){
      if(a[n])
        for(b=0;b<a[n];b++)
          printf("*");
      else
        printf("-");
      puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
int member[3];
  scanf("%d%d%d",&member[0],&member[1],&member[2]);
  int or=(member[0]==member[1]||member[1]==member[2]||member[0]==member[2])?1:0;
  int and=(member[0]==member[1]&&member[1]==member[2]&&member[0]==member[2])?1:0;
  if(or && !and){printf("Yes\n");}
  else{printf("No\n");}
  return 0;
}

Measured memory_bytes: 128
const Main = (input) => {
  const tmp = input.trim().toString().split('')

  const exist = tmp.indexOf('7')

  let result = ''
  if (exist === -1) {
    result = 'No'
  } else {
    result = 'Yes'
  }

  console.log(result)
  return result
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 29608
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  int x=100000;
  int sum=0;
  for(int i=0;i<n;i++) sum+=s[i];
  for(int i=0;i<n;i++){
    if(s[i]%10) x=min(x,s[i]);
  }
  if(sum%10){
    cout<<sum<<endl;
    return 0;
  }
  if(x==100000) cout<<0<<endl;
  else cout<<sum-x<<endl;
  return 0;
}


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

int main()
{
    int n, m, count;
    cin >> n >> m;
    vector<int> r(2 * m);
    for (int i = 0; i < 2 * m; i++)
    {
        cin >> r.at(i);
    }

    for (int i = 1; i <= n; i++)
    {
        count = 0;
        for (int j = 0; j < 2 * m; j++)
        {
            if (r.at(j) == i)
            {
                count++;
            }
        }
        cout << count << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <bitset>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define RPA(i,s,e) for(int i=s; i<=e; i++)
#define RPD(i,s,e) for(int i=s; i>=e; i--)
#define PB(a) push_back(a)
#define MP(i,s) make_pair(i,s)
#define ALL(a) (a).begin(), (a).end()
#define PRT(a) cout << (a) << endl

struct P {
	string msg;
	string fore;
	string back;
};

int m,n;
string a,b,c;
vector<P> F;
vector<P> A;

bool match(string x, string y) {
	if(x.size() != y.size()) return false;

	REP(i,x.size()) {
		if(x[i] != '?' && y[i] != '?' && x[i] != y[i]) {
			return false;
		}
	}
	return true;
}

bool solve() {
	RPD(k,m-1,0) {
		if(F[k].msg == "permit" && match(F[k].fore, a) && match(F[k].back, b)) {
			return true;
		}

		if(F[k].msg == "deny" && match(F[k].fore, a) && match(F[k].back, b)) {
			return false;
		}
	}
	return false;
}

//#define _LOCAL_TEST

int main() {
#ifdef _LOCAL_TEST
	freopen("a.in", "r", stdin);
#endif

	while(scanf("%d%d", &m, &n) != EOF) {
		if(m == 0 && n == 0) break;

		F.clear();
		A.clear();
		REP(i,m) {
			cin >> a >> b >> c;
			if(a == "permit") {
				P p = {a, b, c};
				F.PB(p);
			} else {
				P p = {a, b, c};
				F.PB(p);
			}
		}

		REP(i,n) {
			cin>>a>>b>>c;
			if(solve()) {
				P p = {c, a, b};
				A.PB(p);
			}
		}

		PRT(A.size());
		REP(i,A.size()) {
			cout << A[i].fore << " " << A[i].back << " " << A[i].msg << endl;
		}
	}
}

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

int main() {
  string O, E;
  cin >> O >> E;
  for (int i=0; i<E.size(); i++)
    cout << O.at(i) << E.at(i);
  if ((O.size() - E.size()) == 1)
    cout << O.at(O.size()-1) << endl;
  else
    cout << endl;
}
  

Measured memory_bytes: 256
// Problem : 
// 			A - Rainy Season
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    string s; cin >> s;
    int cnt = 0 , n = s.size() , mx = 0;
	rep(i,0,n){
		cnt = 0;
		while(s[i]=='R'){cnt++,++i;}
		mx = max(mx, cnt);
	}
	
	cout << mx;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3628
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define val(x) cout << #x << ": " << (x) << endl;
#define log(x) cout << (x) << endl;
#define sz(x) (int)(x.size())

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

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

    vi v;
    int x;
    for(int i = 0; i < 3; i++){
        cin>>x;
        v.pb(x);
    }

    int cost =0;

    sort(all(v));

    cost += abs(v[1] - v[0]);
    cost += abs(v[2] - v[1]);


    log(cost);

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]

ans = [0] * m

for i in range(n):
    for j in range(1, l[i][0]+1):
        ans[l[i][j]-1] += 1

print(ans.count(n))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long int MOD = 1000000007;
const long long  INF = 1LL << 60;

int main(void){
    int A, B; cin >> A >> B;
    
    int ans = -1;
    for(int i = 1; i <= 1100; i++){
        int tax_A = i * 0.08;
        int tax_B = i * 0.10;
        // cout << tax_A << ' ' << tax_B << endl;
        if (tax_A == A and tax_B == B){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
int visit[10][10][10];

signed main(){
	int h,w;
	cin>>h>>w;
	int dp[10][10];
	rep(i,10)rep(j,10)cin>>dp[i][j];

	rep(k,10)rep(i,10)rep(j,10){
		chmin(dp[i][j],dp[i][k]+dp[k][j]);
	}

	int ans=0;
	rep(i,h*w){
		int a;
		cin>>a;
		if(a==-1)continue;
		ans+=dp[a][1];
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
int a[N],b[N],num[N];
int x[100][100];
int n,m,k;
struct Node
{
    int voice,text;
} c[N];
int judge(int x1,int y1,int x2,int y2)
{
    if(x1==x1&&y1==y2)
        return 0;
    int temp=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    if(temp*temp==(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
        return 1;
    else
        return 0;
}
int main()
{


    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
            scanf("%d",&x[i][j]);
    }
    int ans=0;
    for(int c=1; c<=n; c++)
    {
        for(int r=c+1; r<=n; r++)
        {
            int temp=0;
            for(int i=1; i<=m; i++)
            {
                temp+=(x[c][i]-x[r][i])*(x[c][i]-x[r][i]);
            }
            if((int)(sqrt(temp))*(int)(sqrt(temp))==temp) 
            	ans++;
        }
    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <utility>
#include <ctime>
#include <cassert>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii > vii;
typedef vector<pair<int, pair<int, int> > > viii;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<vii> vvii;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define MEM(a,b) memset(a,(b),sizeof(a))
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(a) a.begin(),a.end()
#define loop(x,a,b) for(int (x) = (a);(x)<(b);(x)++)
#define rep(x,n)   for(int (x)=0;(x)<(n);(x)++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ain(a,n) int ((a)[(n)]); for(int i=0; i<(n); i++) cin>>((a)[i])  
#define md 1000000007
#define MAXN 200005

int main()
{   
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    ain(a,n);
    ain(b,n);
    ain(c,n);
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    ll ans = 0;
    rep(i,n)
      ans += 1LL*(n-(upper_bound(c,c+n,b[i])-c))*(lower_bound(a,a+n,b[i])-a);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

class P{
public:
	int x,y,cost;

	P(int _x,int _y,int _cost){
		x = _x;
		y = _y;
		cost = _cost;
	}
};

int h,w,n;
char t[1002][1002];
bool closed[1002][1002];
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};

P minDist(int x,int y,char to){
	queue<P> open;
	memset(closed,0,sizeof(closed));

	open.push(P(x,y,0));

	while(!open.empty()){
		P p = open.front(); open.pop();
		if(closed[p.x][p.y]) continue;
		closed[p.x][p.y] = true;

		if(t[p.y][p.x] == to){
			return p;
		}

		for(int i=0;i<4;i++){
			int nx = p.x + dx[i];
			int ny = p.y + dy[i];

			if(nx>=0 && nx<w && ny>=0 && ny<h && t[ny][nx]!='X'){
				open.push(P(nx,ny,p.cost+1));
			}
		}
	}
}

int main(void){
	cin>>h>>w>>n;

	int x,y;
	for(int i=0;i<h;i++){
		cin>>t[i];
		for(int j=0;j<w;j++){
			if(t[i][j] == 'S'){
				t[i][j] = '.';
				x = j;
				y = i;
			}
		}
	}

	int ans = 0;
	for(int i=1;i<=n;i++){
		P res = minDist(x,y,'0'+i);
		ans += res.cost;
		x = res.x;
		y = res.y;
	}
	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

vector <int> adj[300000];
vector <int> vis(300000);

void dfs(int u){
	vis[u] = 1;
  for (int v: adj[u]){
  	if (!vis[v]) dfs(v);
  }
  return;
}

int main(){
	
  	int n; cin >> n;
  	int m; cin >> m;
  for(int i = 1;i<=m;i++){
  	int u, v; cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  
  int numTree = 0;
  for (int i=1;i<=n;i++){
  	if (!vis[i]){
    	numTree++;	
      dfs(i);
    }
  }
  
  cout << numTree - 1 << "\n";  
	return 0;
}

Measured memory_bytes: 15076
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())

K=read()

a="ACL"
print(a*K)

Measured memory_bytes: 67948
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef vector<int> vec;
typedef vector<vec> vvec;
typedef vector<vvec> vvvec;
typedef vector<vvvec> vvvvec;

struct state {
    int x, y;
    int front, right, down;
};

const int INF = 1145141919;
int h, w;

bool inRange(int x, int y) {
    return 0 <= x && x < h && 0 <= y && y < w;
}

int main() {
    cin >> h >> w;
    vector<string> ban(h);
    for (int i = 0; i < h; i++)cin >> ban[i];

    vvvvec dis(h, vvvec(w, vvec(7, vec(7, INF))));
    dis[0][0][2][3] = 0;
    queue<state> que;
    que.push({0, 0, 2, 3, 6});
    while (!que.empty()) {
        auto now = que.front();
        que.pop();
        int cost = dis[now.x][now.y][now.front][now.right] + 1;

        if (inRange(now.x - 1, now.y)) {
            state after = {now.x - 1, now.y, now.down, now.right, 7 - now.front};
            if (ban[after.x][after.y] - '0' == after.down && dis[after.x][after.y][after.front][after.right] > cost) {
                dis[after.x][after.y][after.front][after.right] = cost;
                que.push(after);
            }
        }
        if (inRange(now.x + 1, now.y)) {
            state after = {now.x + 1, now.y, 7 - now.down, now.right, now.front};
            if (ban[after.x][after.y] - '0' == after.down && dis[after.x][after.y][after.front][after.right] > cost) {
                dis[after.x][after.y][after.front][after.right] = cost;
                que.push(after);
            }
        }
        if (inRange(now.x, now.y - 1)) {
            state after = {now.x, now.y - 1, now.front, now.down, 7 - now.right};
            if (ban[after.x][after.y] - '0' == after.down && dis[after.x][after.y][after.front][after.right] > cost) {
                dis[after.x][after.y][after.front][after.right] = cost;
                que.push(after);
            }
        }
        if (inRange(now.x, now.y + 1)) {
            state after = {now.x, now.y + 1, now.front, 7 - now.down, now.right};
            if (ban[after.x][after.y] - '0' == after.down && dis[after.x][after.y][after.front][after.right] > cost) {
                dis[after.x][after.y][after.front][after.right] = cost;
                que.push(after);
            }
        }
    }

    bool ret = false;
    for (int i = 0; i <= 6; i++) {
        for (int j = 0; j <= 6; j++) {
            if (dis[h - 1][w - 1][i][j] < INF)ret = true;
        }
    }

    cout << (ret ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 8392
#include <iostream>
using namespace std;
int t[300005];
int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    for ( int i = 1; i <= n-1; i++ )
    {
        if ( s[i] == 'E' )
        {
            t[0]++;
        }
    }
    for ( int i = 1; i <= n-1; i++ )
    {
        t[i] = t[i-1];
        if ( s[i-1] == 'W' )
        {
            t[i]++;
        }
        if ( s[i] == 'E' )
        {
            t[i]--;
        }
    }
    int min = t[0];
    for ( int i = 0; i <= n-1; i++ )
    {
        if ( t[i] < min )
        {
            min = t[i];
        }
    }
    cout << min;
}

Measured memory_bytes: 1796
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct P {
	int x, y;

	P(int x, int y) : x(x) , y(y) { }
	P() { this -> x = this -> y = 0; }
};

int main() {
	int W, H; cin >> W >> H;
	int ans = 0;

	bool wall[102][102] = {0};
	for (int y = 1; y <= H; ++y)
		for (int x = 1; x <= W; ++x) {
			int f; cin >> f;
			wall[y][x] = f;
		}

	bool used[102][102] = {0};

	queue<P> que;
	que.push( P(0, 0) );
	while ( !que.empty() ) {
		P p = que.front(); que.pop();

		if (p.x < 0 || p.x >= W+2 || p.y < 0 || p.y >= H+2) continue;
		if (wall[p.y][p.x]) {
			++ans;
			continue;
		}
		if (used[p.y][p.x]) continue;

		used[p.y][p.x] = true;

		if (p.y % 2) {
			que.push( P(p.x,   p.y-1) );
			que.push( P(p.x-1, p.y)   );
			que.push( P(p.x,   p.y+1) );
			que.push( P(p.x+1, p.y+1) );
			que.push( P(p.x+1, p.y)   );
			que.push( P(p.x+1, p.y-1) );
		}
		else {
			que.push( P(p.x-1, p.y-1) );
			que.push( P(p.x-1, p.y)   );
			que.push( P(p.x-1, p.y+1) );
			que.push( P(p.x,   p.y+1) );
			que.push( P(p.x+1, p.y)   );
			que.push( P(p.x,   p.y-1) );
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 0
N = int(input())
S = input()

answer = ['.' for i in range(N)]
diff = 0
for i in range(N):
    if S[i] != answer[i]:
        diff += 1

counts = [diff]

for i in range(1, N+1):
    v = answer[-i] 
    if v == S[-i]:
        diff += 1
    else:
        diff -= 1
    answer[-i] = '.' if v == '#' else '#'
    counts.append(diff)

print(min(counts))


Measured memory_bytes: 13060
#include<stdio.h>
#define MAX 100
#define INFTY 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

int prim(void);

int prim(void){
  int u, minv;
  int d[MAX], p[MAX], color[MAX];
  int i, j, sum = 0;

  for(i=0; i<n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(i=0; i<n; i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
        if(u == -1) break;
    color[u] = BLACK;
    for(j=0; j<n; j++){
      if(color[j] != BLACK && M[u][j] != INFTY){
        if(d[j] > M[u][j]){
          d[j] = M[u][j];
          p[j] = u;
          color[j] = GRAY;
        }
      }
    }
  }
  for(i=0; i<n; i++){
    if(p[i] != -1) sum += M[i][p[i]];
  }

  return sum;
}

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

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      scanf("%d", &e);
      if(e == -1) M[i][j] = INFTY;
      else M[i][j] = e;
    }
  }

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

  return 0;
}


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

typedef long long LL;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(x) (x).begin(), (x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9 + 7;

bool check(int x) {
    bool p = false;
    bool res = true;
    for(;x;) {
        bool q = p;
        p = x&1 == 1;
        res = res && !(p&&q);
        x = x>>1;
    }
    return res;
}

int main() {
    LL H, W, K;
    cin >> H >> W >> K;
    vector<vector<LL>> dp(H + 1, vector<LL>(W, 0));
    dp[0][0] = 1;
    FOR(i, 1, H + 1) {
        REP(j, W) {
            // k のxビット目が立っている <=> 縦棒x,x+1間が繋がっている
            REP(k, 1<<(W - 1)) {
                bool p = check(k);
                if(p) {
                    int left = k&(1<<(j - 1));
                    int right = k&(1<<j);

                    if(j + 1 < W && right) {
                        dp[i][j] = (dp[i][j] + dp[i - 1][j + 1])%mod;
                    }else if(0 <= j - 1 && left){
                        dp[i][j] = (dp[i][j] + dp[i - 1][j - 1])%mod;
                    }else if((j == 0 || left == 0) && (j == W - 1 || right == 0)) {
                        dp[i][j] = (dp[i][j] + dp[i - 1][j])%mod;
                    }
                }
            }
        }
    }
    cout << dp[H][K - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=1e4+4;
ll A[M],B[M],dp[M],val[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll H,N;
	cin>>H>>N;
	for(ll i=1;i<=N;i++)
	{
		cin>>A[i]>>B[i];
	}
	dp[0]=0;
	for(ll i=1;i<M;i++)
		dp[i]=1e18;
	for(ll i=1;i<=H;i++)
	{
		for(ll j=1;j<=N;j++)
		{
			if(i-A[j]<=0)
				dp[i]=min(dp[i],B[j]);
			else
				dp[i]=min(dp[i],B[j]+dp[i-A[j]]);
		}
	}
	cout<<dp[H]<<"\n";
	return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;

    int cnt[N + 1];
    // i文字目までにWがいくつあるか

    cnt[0] = 0;
    for (int i = 0; i < N; ++i) {
        cnt[i + 1] = cnt[i];
        if (S[i] == 'W') ++cnt[i + 1];
    }

    int ans = N;
    for (int i = 1; i <= N; ++i) {
        // 自分より西にいて西を向いている人が
        //  cnt[i-1]人
        // 自分より東にいて東を向いている人が
        //  (N-i)-(cnt[N]-cnt[i])人
        ans = min(ans, cnt[i - 1] + (N - i) - (cnt[N] - cnt[i]));
    }
    cout << ans << endl;
    return 0;
}


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

const int N = 200005;

int n;
long long k;

int a[N];
int vis[N];

int main() {
  scanf("%d %lld", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    vis[i] = -1;
    --a[i];
  }

  int cur = 0;
  int len = 0;
  while (vis[cur] == -1) {
    vis[cur] = len++;
    cur = a[cur];
  }

  if (k >= len) k = (k - vis[cur]) % (len - vis[cur]) + vis[cur];
  for (int i = 0; i < n; ++i) {
    if (vis[i] == k) printf("%d\n", i+1);
  }

  return 0;
}


Measured memory_bytes: 5376
n = int(input())
a = list(map(int,input().split()))
d = {}
count = 0
for i in range(n):
    if not a[i] in d.keys() and (n-count)>=a[i]:
        ac = a.count(a[i])
        d.update({a[i]:ac})
        count += ac
ans = 0
for i in sorted(d.keys()):
    if i <= d[i]:
        ans += d[i]-i
    else:
        ans += d[i]

print(ans + n-count)

Measured memory_bytes: 63856
#include<stdio.h>

int main(void){
int n,i,m[10000];
int min,max;
long sum;
max=-1000000;
min=1000000;
sum=0;

scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&m[i]);
if(m[i]>max)max=m[i];
if(m[i]<min)min=m[i];
sum=sum+m[i];
}
printf("%d %d %ld\n",min,max,sum);
return 0;
}

Measured memory_bytes: 1856
<?php 
fscanf(STDIN, "%d", $N);
$songs = array();
$dur = array();

for($i=0;$i<=$N;$i++){
  fscanf(STDIN, "%s %d", $songs[$i], $dur[$i]);
}

$last_song = $songs[count($songs)-1];

foreach($songs as $key => $val){
 if($last_song == $val){
  $ans = $key;
   break;
 }
}
  
$sum = 0;

 for($i = $ans + 1; $i < $N; $i++){
  $sum += $dur[$i]; 
 }
  echo $sum;
  ?>

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define pb push_back



using namespace std;
using ll = long long;
const ll mod = 1000000007;
const double PI = acos(-1);
const ll INF = 1e9;




int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,k,numneg=0,num=1;
    cin >> n >> k;
    vector<pair<ll ,bool>> a(n);
    bool flag = true;
    if(n == k){
        rep(i,n){
            ll x;
            cin >> x;
            num = num*x%mod;
        }
        if(num < 0)num += mod;
        cout << num << endl;
        return 0;
    }
    rep(i,n){
        ll x;
        cin >> x;
        if(x >= 0){
            a[i].first = x;
            a[i].second = true;
            flag = false;
        }else{
            a[i].first = -x;
            a[i].second = false;
            numneg ++;
        }
    }

    sort(a.begin(),a.end());
    if(flag){
        if(k%2 == 1){
        rep(i,k){
            num = -num*a[i].first%mod;
        }
        num += mod;
        cout << num << endl;
        return 0;
        }else{
            rep(i,k){
                num = num*a[n-i-1].first%mod;
            }
            cout << num << endl;
            return 0;
        }
    }

    numneg = 0;
    ll pos=INF,neg=INF,numpos=0;
    rep(i,k){
        if(a[n-i-1].second){
            pos = n-i-1;
            numpos ++;
        }else{
            numneg ++;
            neg = n-i-1;
        }
    }
    if(numneg%2 == 0){
        rep(i,k){
            num = num*a[n-i-1].first%mod;
        }
        cout << num << endl;
        return 0;
    }
    ll pchan=-INF,nchan=-INF;
    for(ll i=n-k-1;i >= 0; i--){
        if(a[i].second && pchan == -INF){
            pchan = a[i].first;
        }else if(!a[i].second && nchan == -INF){
            nchan = a[i].first;
        }
    }
    if(!numpos){
        rep(i,k){
            if(n-i-1 != neg){
                num = num*a[n-i-1].first%mod;   
            }
        }
        num = num*pchan%mod;
        cout << num << endl;
        return 0;
    }
    if(pchan*a[pos].first >= nchan*a[neg].first){
        rep(i,k){
            if(n-i-1 != neg){
                num = num*a[n-i-1].first%mod;
            }
        }
        num = num*pchan%mod;
        cout << num << endl;
        return 0;
    }else{
        rep(i,k){
            if(n-i-1 != pos){
                num = num*a[n-i-1].first%mod;
            }
        }
        num = num*nchan%mod;
        cout << num << endl;
        return 0;
    }

    return 0;


}


Measured memory_bytes: 6364
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

    long long sum=0;
    long long s=0;
    while(1){
        for(int i=0 ; i<N ; i++){
            s=(long long)(a[i]/N);
            a[i]=a[i]%N;
            sum+=s;
            if(s==0)continue;
            for(int j=0 ; j<N ; j++){
                if(i==j)continue;
                a[j]+=s;
            }
        }
        sort(a.begin(),a.end());
        if(a[N-1]<N)break;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n,x,t;
    cin >> n >> x >>t;
    if(n%x==0){
        ll ans = n/x*t;
        cout<<ans<<endl;
    }
    else{
        ll ans = n/x*t+t;
        cout<<ans<<endl;
    }
}
    



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

using namespace std;

struct Puzzle {
    int x;
    string s;
};

int vx[] = {1, -1, 4, -4};
map<string, int> res;

void solve() {

    queue<Puzzle> q;

    q.push((Puzzle){0, "01234567"});

    while(!q.empty()) {

        Puzzle now = q.front(); q.pop();

        for(int i = 0; i < 4; ++i) {
            if(now.x + vx[i] >= 0 && now.x + vx[i] < 8 && !(now.x == 3 && i == 0) && !(now.x == 4 && i == 1)) {

                Puzzle next = now;
                next.x = now.x + vx[i];
                swap(next.s[now.x], next.s[next.x]);

                if(!res[next.s]) {
                    q.push(next);
                    res[next.s] = res[now.s] + 1;
                }

            }
        }

    }

}

int main() {

    res["01234567"] = 1;

    solve();

    while(1) {

        char num;
        string start;

        for(int i = 0; i < 8; ++i) {
            if(!(cin >> num)) return 0;
            start += num;
        }

        cout << res[start] - 1 << endl;

    }

}

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

//apple i taste=L+i-1 could be <0
//therere N apples but ate 1 so N-1 apples
// apple pi N vs apple pi N-1 min abs(NvsN-1)
//N=>2
// so eat abs|L|=0 
//input Number Ludiclulors
//taste=L+i-1 -> mins(abs(taste))->sum(taste)=?

int main(){
  // K_rocks in -100k~+100k are blackend X is blackend
//1<=k<=100 amounts K
//0<=x<=100 black_point X
//X+K<100  X-K ~ X+K 3,7 3-7 3+7
//X>abs|X-K| X<abs|X+K| cout x-k ~ x+k 
//0-4 = -4 dont need abs
//0-4 = -4<X(-3)    X(3)<4=0+4
//k,x
//X-K+1<POINT start    POINT<X+K-1 end
int cnt=0;
int K,X;
cin>>K>>X;
//cout<<K<<X;
int R,L;
//k3x7
L=X-K+1;
R=X+K-1;
int N=R-L+1;
int i;
for(i=L;i<=R;i++){
    cout<<i<<" ";
}

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int in = 0; in < n; ++in)
	{
		int y,m,d;
		cin>>y>>m>>d;
		int cnt=0;
		bool big=false,ok=false;;
		for(int i = 1; i < 1000; ++i)
		{
			if(i%3==0) big=true;
			else big=false;
			bool mbig=false;
			for(int j = 1; j < 11; ++j)
			{
				if(j%2==0) mbig=false;
				else mbig=true;
				for(int k = 1;; ++k)
				{
					cnt++;
					if(y==i&&m==j&&d==k)
					{
						ok=true;
						break;
					}

					if(big&&k==20) break;
					if(!big&&mbig&&k==20) break;
					if(!big&&!mbig&&k==19) break;
				}
				if(ok) break;
			}
			if(ok) break;
		}
		cout<<196471-cnt<<endl;
	}
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define int long long
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
void solve(){
	string s,t;cin>>s>>t;
	int m=s.length();
	int n=t.length();
	int dp[m+1][n+1];
	dp[0][0]=0;
	for(int i=1;i<=n;i++) dp[0][i]=0;
	for(int i=1;i<=m;i++) dp[i][0]=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
		}
	}
	int len=dp[m][n];
//	cout<<len;
	int i=m;int j=n;string ans="";
	while(i>=1&&j>=1){
		if(s[i-1]==t[j-1]){
			ans=ans+s[i-1];
			i--;j--;
		}
		else if(dp[i-1][j]>dp[i][j-1]) i--;
		else j--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

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

struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll A, B;
        in >> A >> B;
        out << ((A%3==0||B%3==0||(A+B)%3==0)?"Possible":"Impossible") << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}

#include <fstream>
#include <iostream>

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int num=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())num=(num<<3)+(num<<1)+c-48;
	return num*f;
}
int a,b,k;
bool f[1000000010]={0};
inline void init()
{
	a=read();b=read();k=read();
	for(int i=a;i<=min(a+k-1,b);++i)
	f[i]=1;
	for(int i=max(b-k+1,a);i<=b;++i)
	f[i]=1;
	for(int i=a;i<=b;++i)
	{
		if(f[i])cout<<i<<endl;
	}
}
void work()
{
	
}
int main()
{
	init();
	work();
	return 0;
}

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

#define f(i,x,y)			for(int i=x; i<y; i++)
#define ll 					long long 
#define mp 					make_pair
#define F 					first
#define S 					second
#define N 					100005
#define inf 				1e9+1

int main()
{
	
	int n;
	cin>>n;
	double h[n+1], t[n+1];
	f(i,1,n+1)
	{
		cin>>h[i];
		t[i] = 1-h[i];
	}
	double dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;

	f(i,1,n+1)
		dp[i][0] = dp[i-1][0]*t[i];

	f(i,1,n+1)
		f(j,1,n+1)
		{
			if(j<=i)
			{
				dp[i][j] = h[i]*dp[i-1][j-1]+t[i]*dp[i-1][j];
			}
		}
double ans = 0.0;
int st = (n+2)/2;
f(i,st,n+1)
	ans += dp[n][i];

	cout<<setprecision(10)<<ans<<endl;

	return 0;
}

Measured memory_bytes: 70656
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
    to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
    print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

    # 入力を整数に変換して受け取る
    def input_int(): return int(input())

    def map_int_input(): return map(int, input())

    MII = map_int_input

    def MII_split(): return map(int, input().split())

    def MII_to_index(): return map(to_index, input())

    def MII_split_to_index(): return map(to_index, input().split())

    # 入力全てを整数に変換したものの配列を受け取る
    def list_int_inputs(): return list(map(int, input()))

    LII = list_int_inputs

    def LII_split(): return list(map(int, input().split()))

    # 2次元リスト化
    def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

    N = input_int()
    A_list = LII_split()

    if 0 in A_list:
        print(0)
        return

    ans = A_list[0]
    for A in A_list[1:]:
        ans *= A
        # print(ans)
        if ans > 1e18:
            ans = -1
            break
    print(ans)
    
resolve()

Measured memory_bytes: 22520
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

static const int MOD = 1000000007;
static int dp[5001][5001];

int main(){
	ios_base::sync_with_stdio(false);
	int n, l;
	cin >> n >> l;
	vector<int> x(n), a(n);
	for(int i = 0; i < n; ++i){ cin >> x[i]; }
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	memset(dp, 0, sizeof(dp));
	dp[n][l] = 1;
	for(int i = n - 1; i >= 0; --i){
		int sum = dp[i + 1][l];
		for(int j = l - 1; j >= x[i]; --j){
			if(a[i] == 0){
				if(j == x[i]){ dp[i][j] = (dp[i][j] + sum) % MOD; }
			}else if((j - x[i]) % a[i] == 0){
				dp[i][j] = (dp[i][j] + sum) % MOD;
			}
			sum = (sum + dp[i + 1][j]) % MOD;
		}
	}
	int answer = 0;
	for(int i = 0; i <= l; ++i){
		answer = (answer + dp[0][i]) % MOD;
	}
	cout << answer << endl;
	return 0;
}

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

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

int main() {
    int n,m,c;cin>>n>>m>>c;
    int b[m],a[m];
    int ans = 0;
    rep(i,m)cin>>b[i];
    
    rep(i,n){
        int tmp = c;
        rep(j,m){
            cin>>a[j];
            tmp+=a[j]*b[j];
        }
        if(tmp>0)++ans;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert( B <= A && A <= C)

#define MP make_pair
#define FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 100001
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
const double pi=acos(-1.0);

typedef pair<int, int> PII;

typedef vector<int> VI;

typedef vector<string> VS;

typedef vector<PII> VII;

typedef vector<VI> VVI;

typedef map<int,int> MPII;

typedef set<int> SETI;

typedef multiset<int> MSETI;

typedef long int li;

typedef unsigned long int uli;

typedef long long int ll;

typedef unsigned long long int  ull;

bool isPowerOfTwo (int x)
{
  /* First x in the below expression is
    for the case when x is 0 */
  return x && (!(x&(x-1)));
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}

// Returns nCr % p using Fermat's little
// theorem.
ll ncr(ll n, ll r,ll p)
{
   // Base case
   if (r==0)
      return 1;

    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r
    ll fac[n+1];
    fac[0] = 1;
    for (ll i=1 ; i<=n; i++)
        fac[i] = fac[i-1]*i%p;

    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}

vector<int> v[max1];

void dfs(int ans[],bool x[],int cnt[],int j,int c){
    x[j]=true;
  for(int i=0;i<v[j].size();i++){
        if(cnt[v[j][i]]>=c){ans[v[j][i]]=j;cnt[v[j][i]]=c;}
    if(x[v[j][i]]==false){
        ans[v[j][i]]=j;
        cnt[v[j][i]]=c;
        dfs(ans,x,cnt,v[j][i],c+1);
    }
  }
}
#define deg_to_rad(deg) (((deg) / 360) * 2 * PI)
int main(){
int a,b;
cin>>a>>b;
cout<<a*b;

}



Measured memory_bytes: 5968
n,c=map(int,input().split())
d=[list(map(int,input().split()))for _ in range(c)]
cc=[list(map(int,input().split()))for _ in range(n)]
ans=10**15
cnt=[[0]*c for _ in range(3)]
for i in range(n):
	for j in range(n):
		cnt[(i+j)%3][cc[i][j]-1]+=1
for i in range(c):
	for j in range(c):
		for k in range(c):
			pre_ans=0
			if i==j or j==k or k==i:
				continue
			for l in range(3):
				for m in range(c):
					if l%3==0 and m!=i:
						pre_ans+=cnt[l][m]*d[m][i]
					elif l%3==1 and m!=j:
						pre_ans+=cnt[l][m]*d[m][j]
					elif l%3==2 and m!=k:
						pre_ans+=cnt[l][m]*d[m][k]
			ans=min(ans,pre_ans)
print(ans)

Measured memory_bytes: 5620
import bisect
A, B, Q = map(int, input().split())
inf = 10**18
lisS = [-inf] + [int(input()) for x in range(A)] + [inf]
lisT = [-inf] + [int(input()) for x in range(B)] + [inf]
for _ in range(Q):
  x = int(input())
  i = bisect.bisect_right(lisS, x)
  j = bisect.bisect_right(lisT, x)
  res = inf
  for S in [lisS[i - 1], lisS[i]]:
    for T in [lisT[j - 1], lisT[j]]:
      r1 = abs(S - x) + abs(S - T)
      r2 = abs(T - x) + abs(S - T)
      res = min(res, r1, r2)
  print(res)

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  vector<char> a(0);
  for(int i=0;i<s.size();i++){
    if(s[i]=='B'){
      if(a.size())a.erase(a.begin()+a.size()-1);
    }
    else a.push_back(s[i]);
  }
  for(int i=0;i<a.size();i++)cout<<a[i];
  cout<<endl;
}

Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)
using namespace std;
int main(){
    int a,b,c,ab,bb,cb,ans=0;
    cin>>a>>b>>c;
    ab=a;
    bb=b;
    cb=c;
    while(1){
        if(a%2==1 or b%2==1 or c%2==1){
        cout<<ans<<endl;
        return 0;
        }
        ans++;
        ab=a;
        bb=b;
        cb=c;
        a=(bb+cb)/2;
        b=(ab+cb)/2;
        c=(ab+bb)/2;

        if(a==b and b==c and a==c){
        cout<<-1<<endl;
        return 0;
        }
    }
    

};


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <cstdio>
#define vec vector
#define pb push_back
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define EPS 1e-9
#define fst first

using namespace std;

#define LT(x, y) ((x) - (y) <= -EPS) // x < y
typedef double Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst) : src(src),dst(dst) {}
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vec<Edge> Edges;
typedef vec<Edges> Graph;



#define MAXN 100
int n;

Weight x[MAXN],y[MAXN],z[MAXN],r[MAXN];

pair<Weight, Edges> minimumSpanningTree(const Graph &g, int r = 0) {
  int n = g.size();
  Edges T;
  Weight total = 0;

  vector<bool> visited(n);
  priority_queue<Edge> Q;
  Q.push( Edge(-1, r, 0) );
  while (!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (visited[e.dst]) continue;
    T.push_back(e);
    total += e.weight;
    visited[e.dst] = true;
    FOR(f, g[e.dst]) if (!visited[f->dst]) Q.push(*f);
  }
  return pair<Weight, Edges>(total, T);
}


double solve() {
  Graph g;
  for(int i=0;i<n;i++) {
    Edges es, es2;
    for(int j=0;j<n;j++) {
      if(i==j) {es.pb(Edge(i,j,0)); es2.pb(Edge(j,i,0));continue; }
      double ldis = sqrt(pow(x[i]-x[j],2.0)+pow(y[i]-y[j],2.0)+pow(z[i]-z[j],2.0));
      ldis = ldis - (r[i]+r[j]);
      //printf("ldis=%lf\n",ldis);
      if(LT(0, ldis)) { //0 < ldis
	es.pb(Edge(i,j,ldis)); es2.pb(Edge(j,i,ldis));
      } else { es.pb(Edge(i,j,0)); es2.pb(Edge(j,i,0)); }
    }
    g.pb(es);
  }
  pair<Weight,Edges> ans;
  ans = minimumSpanningTree(g);
  return ans.fst;
}

main() {
  while(cin>>n,n) {
    REP(j,n) {
      cin>>x[j]>>y[j]>>z[j]>>r[j];
    }
    printf("%.3lf\n",solve());
  }
}

Measured memory_bytes: 1372