akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut hs: Vec<usize> = (0..n).map(|_| sc.cin()).collect();
    let mut ok = true;
    for i in (0..n-1).rev() {
        if hs[i] > hs[i+1] {
            hs[i] -= 1;
            if hs[i] > hs[i+1] { ok = false; }
        }
    }
    put!(if ok { "Yes" } else { "No" });
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

vector<int> to[200005];
vector<int> ans;

void dfs(int v,int p=-1){
    for(int u: to[v]){
        if(u==p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main(){
    int n,q;cin>>n>>q;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);                                                      }
    ans.resize(n);
    rep(i,q){
        int p,x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
  int a,b,c,n;
  cin >>a>>b>>c>>n;
  int max;
  if(a >=b && a>=c){
    for(int i=0;i<n;i++){
      a=a*2;
    }
  }
  if(b >=a && b>=c){
    for(int i=0;i<n;i++){
      b=b*2;
    }
      }
  if(c >=b && c>=a){
    for(int i=0;i<n;i++){
      c=c*2;
    }
          }
  if(a==b &&b==c){
    for(int i=0;i<n;i++){
      a=a/2;
      b=b/2;
      c=c/2;
    }
  }
  cout << a+b+c <<endl;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;

#define eps 1e-8
#define pb push_back
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define clr(a,b) memset(a,b,sizeof(a)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

int main(){
    FAST_IO;
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=1;i<=k;i++){
        if(i%2){
            b+=a/2;
            a/=2;
        }
        else{
            a+=b/2;
            b/=2;
        }
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
#define V vector<ll>
signed main(){
  ll N,M,ans=0;cin>>N>>M;
  if(N<M){
    ll i;V X(M);
    REP(i,M)cin>>X.at(i);
    sort(ALL(X));V D(M-1);
    REP(i,M-1)D.at(i)=X.at(i+1)-X.at(i);
    sort(ALL(D));
    REP(i,M-N)ans+=D.at(i);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var m = Console.ReadLine().Split(' ').Select(int.Parse).Distinct().Count();

            var ans = m - (n - m) % 2;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 19040
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    A, B ,N = read_values()
    print((A * min(N, B - 1)) // B)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9820
#include<cstdio>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;

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

struct state{ int x,y,face,dir; };

int main(){
	// table[i][j] := ( 底面が i で方向 j に転がったとき, 次に底面になる面の番号 )
	// 問題文の図で上(or下)の方向を方向 0 として, 反時計回りに方向 1, 2 を定めている.
	// 方向は正二十面体の上に定められていて, 座標とは関係ない!!!
	// 正二十面体を実際にグリッド上に置くと, 展開図と面の位置関係が反転するので注意.
	int table[20][3]={
		{ 5, 4, 1},
		{ 6, 0, 2},
		{ 7, 1, 3},
		{ 8, 2, 4},
		{ 9, 3, 0},
		{ 0,11,10},
		{ 1,12,11},
		{ 2,13,12},
		{ 3,14,13},
		{ 4,10,14},
		{15, 9, 5},
		{16, 5, 6},
		{17, 6, 7},
		{18, 7, 8},
		{19, 8, 9},
		{10,16,19},
		{11,17,15},
		{12,18,16},
		{13,19,17},
		{14,15,18}
	};

	// dist[y][x][i][j] := ( 座標が (x,y) で, 底面が i で, 北(or南)が方向 j である状態に達するための最短距離 )
	static int dist[201][201][20][3];
	rep(y,201) rep(x,201) rep(i,20) rep(j,3) dist[y][x][i][j]=INF;
	dist[100][100][0][0]=0;

	static state Q[201*201*20*3];
	int head=0,tail=0;
	Q[tail++]=(state){100,100,0,0};
	while(head<tail){
		state S=Q[head++];
		if(dist[S.y][S.x][S.face][S.dir]==100) continue;

		rep(k,3){
			int xx=S.x+dx[(S.x+S.y)%2][k];
			int yy=S.y+dy[(S.x+S.y)%2][k];
			int ff=table[S.face][(S.dir+k)%3];
			int dd;
			if(S.face<5 || 15<=S.face){
				if     (S.dir==0 && k==0) dd=0;
				else if(S.dir==0 && k==1) dd=1;
				else if(S.dir==0 && k==2) dd=2;
				else if(S.dir==1 && k==0) dd=2;
				else if(S.dir==1 && k==1) dd=0;
				else if(S.dir==1 && k==2) dd=1;
				else if(S.dir==2 && k==0) dd=1;
				else if(S.dir==2 && k==1) dd=2;
				else if(S.dir==2 && k==2) dd=0;
			}
			else{ // 5<=S.face && S.face<15
				if     (S.dir==0 && k==0) dd=0;
				else if(S.dir==0 && k==1) dd=0;
				else if(S.dir==0 && k==2) dd=0;
				else if(S.dir==1 && k==0) dd=1;
				else if(S.dir==1 && k==1) dd=1;
				else if(S.dir==1 && k==2) dd=1;
				else if(S.dir==2 && k==0) dd=2;
				else if(S.dir==2 && k==1) dd=2;
				else if(S.dir==2 && k==2) dd=2;
			}

			if(dist[yy][xx][ff][dd]>dist[S.y][S.x][S.face][S.dir]+1){
				dist[yy][xx][ff][dd]=dist[S.y][S.x][S.face][S.dir]+1;
				Q[tail++]=(state){xx,yy,ff,dd};
			}
		}
	}

	for(int gx,gy,f;scanf("%d%d%d",&gx,&gy,&f),gx||gy||f;){
		gx+=100;
		gy+=100;
		printf("%d\n",min(min(dist[gy][gx][f][0],dist[gy][gx][f][1]),dist[gy][gx][f][2]));
	}

	return 0;
}

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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()

using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

const D EPS = 1e-8;
const D PI = acos(-1);

inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

inline P unit(P p){return p/abs(p);}
inline P norm(P p){return p*P(0,1);}

//for line(segment)
inline int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

//vertexes are in the counter-clockwise order.
inline Poly convex_cut(Poly p,L l){
  Poly res;
  rep(i,p.sz){
    int nxt = (i+1)%p.sz;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

inline bool check(D dis, const Poly &p){
  Poly U(4);
  U[0] = P(-1e6, -1e6);
  U[1] = P(+1e6, -1e6);
  U[2] = P(+1e6, +1e6);
  U[3] = P(-1e6, +1e6);

  int n = p.size();
  for(int i=0;i<n;i++){
    L l = L(p[i],p[(i+1)%n]);
    P move = dis*unit(norm(l.sc-l.fs));
    l.fs += move; l.sc += move;
    U = convex_cut(U,l);
  }
  return !U.empty();
}

int main(){
  int n;
  while(scanf("%d",&n),n){
    Poly p(n);
    for(int i=0;i<n;i++){
      D x,y;
      scanf("%lf%lf",&x,&y);
      p[i] = P(x,y);
    }

    D l = 0, r = 1e6;
    for(int i=0;i<50;i++){
      D mid = (l+r)/2;
      if(check(mid,p))l = mid;
      else r = mid;
    }
    printf("%.9lf\n",l);
  }
}

Measured memory_bytes: 1260
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int A[110];

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

	cin >> N;
	int sum = 0;
	rep(i, 0, N)
	{
		cin >> A[i];
		sum += A[i];
		A[i] *= N;
	}

	int md = INF;
	int mi = -1;

	rep(i, 0, N)
	{
		if (chmin(md, abs(A[i] - sum)))
		{
			mi = i;
		}
	}

	cout << mi << endl;

	return 0;
}

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

int main(){
    int n;
    cin>>n;
    string str;
    set<string> dict;
    for(int i=0;i<n;++i){
        cin>>str;
        if(str=="insert"){
            cin>>str;
            dict.insert(str);
        }
        else if(str=="find"){
            cin>>str;
            if(dict.count(str)){
                cout<<"yes\n";
            }
            else{
                cout<<"no\n";
            }
        }
    }
}

Measured memory_bytes: 32612
from collections import deque
h,w = [int(i) for i in input().split()]

grid = [input() for _ in range(h)]

ans = 0

for i in range(h):
    for j in range(w):
        visited = [[-1] * w for _ in range(h)]
        visited[i][j] = 0
        if grid[i][j] == '#':
            continue
        queue = deque([[i,j]])
        while queue:
            x,y = queue.popleft()
            for k,l in ([-1,0],[1,0],[0,-1],[0,1]):
                nx,ny = x+k,y+l
                if nx < 0 or ny < 0 or nx >= h or ny >= w:
                    continue
                if grid[nx][ny] == '.' and visited[nx][ny] == -1:
                    visited[nx][ny] = visited[x][y] + 1
                    ans = max(ans,visited[nx][ny])
                    queue.append([nx,ny])
                    
print(ans)


Measured memory_bytes: 3316
import sys
input=sys.stdin.readline
D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
    sub=list(map(int,input().split()))
    s.append(sub)

last=[-1]*26

t=[]

for i in range(D):
    m=-10**9
    change=-1
    for j in range(26):
        temp=0
        temp+=s[i][j]
        for k in range(26):
            if k!=j:
                temp-=c[k]*(i-last[k])
        if temp>m:
            m=temp
            change=j
    t.append(change+1)

m=1000000
import random
for _ in range(m):
    h=0
    d=random.randint(1,D)
    q=random.randint(1,26)
    h+=s[d-1][q-1]-s[d-1][t[d-1]-1]
    o=t[d-1]

    pre=1
    for i in range(d-2,-1,-1):
        if t[i]==o:
            break
        pre+=1
    post=1
    for j in range(d,D):
        if t[j]==o:
            break
        post+=1
    h-=c[o-1]*pre*post

    pre = 1
    for i in range(d - 2, -1, -1):
        if t[i] == q:
            break
        pre += 1
    post = 1
    for j in range(d, D):
        if t[j] == q:
            break
        post += 1
    h += c[q - 1] * pre * post

    if h>0:
        t[d-1]=q

for i in t:
    print(i)

Measured memory_bytes: 82936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int R;
    cin >> R;
    if(R < 1200)
        cout << "ABC";
    else if(R < 2800)
        cout << "ARC";
    else
        cout << "AGC";

    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
	val cin = Scanner(System.`in`)
	val ans = mutableListOf<String>()

	while (true) {
		val H = cin.nextInt()
		val W = cin.nextInt()
		if (H + W == 0) break

		for (h in 0 until H) {
			ans.add("")
			val last = ans.lastIndex
			if (h % 2 != 0) ans[last] += "."
			ans[last] += "#.".repeat(W)
			ans[last] = ans[last].slice(0 until W)
		}
		ans.add("")
	}
	println(ans.joinToString("\n"))
}




Measured memory_bytes: 29896
N=input()
N=int(N)

flag=True
#時間経過
tk=0
#現在座標
xk=0
yk=0

for i in range(N):
    txy=input()
    #時間　x座標　y 座標
    t,x,y=txy.split()
    t=int(t)
    x=int(x)
    y=int(y)
    #時間に余裕があるか
    if abs(t-tk) >= abs(x-xk)+abs(y-yk):
        #偶数　奇数
        if (abs(t-tk)+abs(x-xk)+abs(y-yk))%2==0:
            flag=True
        else:
            flag=False
    else:
        flag=False
    
    tk=t
    xk=x
    yk=y
    
    if not flag:
        print('No')
        break

if flag:
    print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int a,b;
  cin >> a >> b;
  int x=b+a*pow(10,1+floor(log10(b)));
  cout << (x==ceil(sqrt(x))*ceil(sqrt(x))?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int list[81], n;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            list[(i-1)*9+(j-1)] = i*j;
        }
    }

    cin >> n;
    bool exist = false;
    for(int i = 0; i < 81; i++){
        if(n == list[i]) {
            exist = true;
            break;
        }
    }

    if(exist) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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


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

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int main(void) {

	int n, count = 0;
	cin >> n;

	map<string, int> m;



	for (int i = 0; i < n; i++) {
		string a;
		cin >> a;
		m[a]++;
		count = max(m[a], count);
	}

	for (auto i = m.begin(); i != m.end(); i++) {
		if (i->second == count) {
			cout << i->first << endl;
		}
	}

	return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int gcd(int a, int b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return a * b / __gcd(a, b); }

ll gcd_arr(vector<ll> &a) {
  ll n = a.size();
  for (ll i = n - 2; i >= 0; i--) {
    a[i] = gcd(a[i], a[i + 1]);
  }
  return a.front();
}

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N, X;
  scanf("%lld %lld", &N, &X);

  vector<ll> x_list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);

    x_list.emplace_back(abs(v - X));
  }

  ll ans = gcd_arr(x_list);

  cout << ans << endl;
}


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


int main() {
  int n, w, h, x, y, s, t;

  while (cin >> n, n) {
    cin >> w >> h;
    Z.resize(w);
    rep (i, w) Z[i].resize(h);
    rep (i, w) fill(Z[i].begin(), Z[i].end(), 0);

    rep (i, n) {
      cin >> x >> y;
      Z[x-1][y-1] = 1;
    }

    cin >> s >> t;
    int ans = 0;

    rep (i, w-s+1) {
      rep (j, h-t+1) {
        int ans_ = 0;
        rep (a, s) rep (b, t) ans_ += Z[i+a][j+b];
        ans = max(ans, ans_);
      }
    }

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

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int count(string s){
  int siz = s.size();
  int res = 0, combo = 1;
  REP(i, siz){
    if(i==0) continue;
    if(s[i] == s[i-1]) combo++;
    else{
      res += combo/2; combo = 1;
    }
  }
  res += combo/2;
  return res;
}

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

  string S; int K; cin >> S >> K;
  const int siz = S.size();
  if(S == string(siz, S[0])){
    cout << siz*K/2 << endl;
    return 0;
  }
  if(S[0] != S[S.size()-1]){
    cout << count(S) * K << endl;
  } else{
    char c = S[0];
    int prev = 0, next = 0;
    REP(i, siz){
      if(S[i] != c) break;
      prev++;
    }
    RREP(i, siz){
      if(S[i] != c) break;
      next++;
    }
    string tmp = S.substr(0, prev);
    S.erase(S.begin(), S.begin()+prev);
    S += tmp;
    string T = "";
    REP(i, siz){
      if(S[i] == c) break;
      T += S[i];
    }
    cout << prev/2 + count(S)*(K-1) + count(T) + next/2 << endl;
  }
}

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

using namespace std;

int main() {
	int n;
	string str;
	cin >> n;
	cin >> str;
	char aux = str[0];
	int ans = 1;
	for(int i = 1; i < str.size(); i++) {
		if(str[i] != aux) {
			ans++;
			aux = str[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
L_yoko = [list(map(int,input().split())) for _ in range(3)]


L_tate = list(zip(*L_yoko))

L_naname = []
L_naname.append([L_yoko[0][0],L_yoko[1][1],L_yoko[2][2]])
L_naname.append([L_yoko[0][2],L_yoko[1][1],L_yoko[2][0]])

n = int(input())
ans = [int(input()) for _ in range(n)]

a = int(0)
for z in L_tate:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_yoko:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_naname:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break


if a == 0:
    print("No")
else:
    print("Yes")


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    bool flag = false;
    int cnt = 0;
    rep(i,n){
        int a, b;
        cin >> a >> b;
        if(a == b) cnt++;
        else cnt = 0;
        if(cnt == 3) flag = true;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

    int ans = 0, N = S.size();
    for (int i = 2; i < N; i += 2) {
        int x = N - i;
        string str = S.substr(0, x);
        if (str.substr(0, x / 2) == str.substr(x / 2)) {
            ans = x;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

s = input()
n = len(s)
que = deque()
for i in range(n):
    if s[i] == 'S':
        que.append(s[i])
    else:
        if len(que) == 0:
            que.append(s[i])
        elif que[-1] == 'T':
            que.append(s[i])
        else:
            que.pop()
    
print(len(que))

Measured memory_bytes: 5088
N = int(input())
A = []
for i in range(N):
  A.append([])
  A_tmp = int(input())
  for j in range(A_tmp):
    XY = [int(k) for k in input().split()]
    XY[0]-=1
    A[i].append(XY)

ans = 0


for i in range(2**N):
  bin_i_list = [int(x) for x in '{:0=15b}'.format(i)]
  bin_i_list.reverse()
  bin_i_list = bin_i_list[:N]
  judge = True
  #Judge
  for j in range(len(A)):
    if bin_i_list[j] != 0:
      for XY in A[j]:
        X =XY[0]
        Y =XY[1]
        if bin_i_list[X] != Y:
          judge = False
          break
  if judge:
    ans = max(ans,bin_i_list.count(1))

print(ans)


Measured memory_bytes: 3064
A, B, C, K = map(int,input().split())
ans = 0
if K == A:
    print(A)
elif K < A:
    print(K)
else:
    ans += A
    K -= A
    if K > B:
        K -= B
        if K > C or K == C:
            ans -= C
            print(ans)
        else:
            ans -= K
            print(ans)
    else:
        print(ans)

Measured memory_bytes: 9196
N = int(input())

ABC = []
for _ in range(N):
    ABC.append(list(map(int, input().split())))


def chmax(i, j):
    diff = max([dp[i-1][x] for x in {0, 1, 2}-{j}])
    if dp[i][j] < ABC[i][j] + diff:
        dp[i][j] = ABC[i][j] + diff
        return True
    return False


dp = [[0, 0, 0] for _ in range(N)]
dp[0][0] = ABC[0][0]
dp[0][1] = ABC[0][1]
dp[0][2] = ABC[0][2]


for i in range(N-1):
    for j in range(3):
        chmax(i+1, j)
    # dp[i+1][0] = ABC[i+1][0] + max(dp[i][1], dp[i][2])
    # dp[i+1][1] = ABC[i+1][1] + max(dp[i][0], dp[i][2])
    # dp[i+1][2] = ABC[i+1][2] + max(dp[i][0], dp[i][1])
print(max(dp[N-1][0], dp[N-1][1], dp[N-1][2]))

Measured memory_bytes: 76120
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();

        int Amin = (A * 25 + 1) / 2;
        int Amax = ((A + 1) * 25 + 1) / 2 - 1;
        int Bmin = (B * 10);
        int Bmax = ((B + 1) * 10) - 1;

        if (Amin <= Bmin && Bmin <= Amax) {
            System.out.println(Bmin);
        } else if (Bmin <= Amin && Amin <= Bmax) {
            System.out.println(Amin);
        } else {
            System.out.println(-1);
        }
    }
}


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

int main(){
    char c[2][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<2; j++)
        cin >> c[j][i];
    }
    if(c[0][0]==c[1][2] && c[0][1]==c[1][1] && c[0][2]==c[1][0])
    puts("YES");
    else
    puts("NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int main(){
	string s; cin >> s;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		char cp=s[i];
		while(cp==s[i]){
			i++;
		}
		i--;
		cnt++;
	}
	cout << cnt-1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
#define all(obj) (obj).begin(), (obj).end()
#define int long long
signed main () {
  int n;cin >> n;
  vector<int> a(n+1,0);rep(i,n) cin>>a[i+1];
  bool ans=true;
  fo(i,1,n+1){
    if (a[i-1]<a[i]) a[i]-=1;
    else if (a[i-1]>a[i]) ans=false;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 4032
#include<iostream>
using namespace std;
   
int main(void){
   
  int h[10];
  int a = 0;
   

    for(int i=0; i<10; i++){
      cin >> h[i]; 
    }
   
  for(int j=0; j<3; j++){
    for(int i=0; i<10; i++){
        if(h[a]<h[i]) a = i;
    }
    cout << h[a] << endl; 
    h[a] = 0;
  }  
   
  return 0;
}

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

using namespace std;
int main()
{

  int a,b,d,c,i,j,k,l=0;
 vector<int>v;
map<int,int>m;
cin>>a;
for(i=1;i<=a;i++)
{
 cin>>b;
        if(b>100000){l++;}else{
    m[b]++;
if(m[b]==1)v.push_back(b);}
 }
for(i=0;i<v.size();i++)
{
 k=v[i];
 if(k==m[k])
 {
 }
 else if(k>m[k])l+=m[k];
 else if(k<m[k])l+=(m[k]-k);
}
cout<<l<<endl;
}

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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    string n;
    cin >> n;

    int m = n.size();
    if(n[m-1] == '3'){
        cout << "bon";
    } else if(n[m-1] == '0' || n[m-1] == '1' || n[m-1] == '6' || n[m-1] == '8'){
        cout << "pon";
    } else cout << "hon";

}

void solve_B(){
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();

    if(n <= k) cout << s;
    else{
        for(int i = 0; i < k; i++){
            cout << s[i];
        }
        cout << "...";
    }
}

void solve_C(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double kakudo = (double) fabs(30 * h - 5.5 * m);
    //double kakudo = (double) fabs((6.5 * h + 30 * m - 360) + 360);
    double ans = a * a + b * b - 2 * a * b * cos(kakudo * PI / 180);
    printf("%.11f\n", sqrt(ans));
}

int main(void){
    solve_C();
    
    return 0;
}

Measured memory_bytes: 4236
k=int(input())
cnt=0
queue=['1','2','3','4','5','6','7','8','9']
while len(queue)>0:
  if cnt==k:
    print(queue[-1][:-1])
    exit()
  now=queue.pop(0)
  if now[-1]=='9':
    queue.append(now+'8')
    queue.append(now+'9')
  elif now[-1]=='0':
    queue.append(now+'0')
    queue.append(now+'1')
  else:
    queue.append(now+str(int(now[-1])-1))
    queue.append(now+str(int(now[-1])))
    queue.append(now+str(int(now[-1])+1))
  cnt+=1

Measured memory_bytes: 22316
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include<unordered_map>
#define ll long long
// #define pb push_back
// #define pop pop_back
#define in(i,n) for(i=0;i<n;i++)
#define pi pair<long long ,long long>
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))

#define inf 10000000001
#define d1(a) cout<<a<<" "<<endl
#define d2(a,b) cout<<a<<" "<<b<<endl
#define d3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll MOD = 1e9+7;
int main(){
    jaldi
    #ifndef ONLINE_JUDGE
    TakeInput
    #endif

    ll i,j,k,n,m;
    ll t;
    
    cin>>n;
    ll a[n];
    ll suf[n];

    for(i=0;i<n;i++){
        cin>>a[i];
    }
    suf[n-1] = a[n-1];
    for(i=n-2;i>=0;i--){
        suf[i] = suf[i+1]+a[i];
    }
    ll sum = 0; 
    for(i=0;i<n-1;i++)
    {
        sum += ((a[i]%MOD)*(suf[i+1]%MOD))%MOD;
        sum%=MOD;
    }

    d1(sum);
    
}


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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  int a[2][n];
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    int tmp = 0;
    for(int j=0;j<n;j++){
      if(j<i){
        tmp+=a[0][j];
      }else if(j==i){
        tmp+=a[0][j];
        tmp+=a[1][j];
      }else{
        tmp+=a[1][j];
      }
    }
    ans=max(ans, tmp);
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 256
N = int(input())

XY = [tuple(map(int,input().split())) for i in range(N)]
from itertools import permutations
from math import hypot
sm = k = 0
for ptn in permutations(XY):
    k += 1
    for (x1,y1),(x2,y2) in zip(ptn,ptn[1:]):
        sm += hypot(x1-x2, y1-y2)
print(sm/k)

Measured memory_bytes: 3064
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#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 fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;

int main(){
    fastio
int x,y,z;
cin>>x>>y>>z;
cout<<(int)(y*x)/2<<endl;
    return 0 ;
}

Measured memory_bytes: 256
using System;

public class AtCoderFourAdjacent 
{
    public static void Main(String[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int numDivisibleByFour = 0;
        int numOdd = 0;
        foreach (var e in arr)
        {
            if (e % 2 != 0)
            {
                numOdd++;
            }
            else if (e % 4 == 0)
            {
                numDivisibleByFour++;
            }
        }

        if (numDivisibleByFour >= numOdd)
        {
            Console.WriteLine("Yes");
        }
        else if (numDivisibleByFour == (numOdd - 1) &&
                numDivisibleByFour + numOdd == n)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 18400
int main(){
	int W,H,x,y,r,a;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if (W>=x+r && 0<=x-r && H>=y+r && 0<=y-r) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 584
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum = 0


for i in range(n):
  if b[i] >= a[i]:
    s = b[i] - a[i]
    sum += a[i]
    if a[i+1] >= s:
      a[i+1] = a[i+1] - s
      sum += s
    elif s > a[i+1]:
      sum += a[i+1]
      a[i+1] = 0
  else:
    sum += b[i]

print(sum)

Measured memory_bytes: 18624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
//#include <stdio.h>

using namespace std;

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

    double count = 0.0;

    int N;

    cin >> N;

    for(int i = 0; i < N; i++){
        double x;
        string u;

        cin >> x >> u;

        if(u == "JPY"){
            count += x;
        }else
        {
            x *= 380000.0;
            count += x;
        }
    }

    cout << count;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod



signed main(){

    int A, B, K; cin >> A >> B >> K;
    IFOR(i, 1, 1000){
        if(A % i == 0 && B % i == 0) K--;
        if(K == 0){
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//↑templete
signed main(){

	int H, W, N;
	cin>>H>>W>>N;
	int a=max(H, W);
	cout<<(N+a-1)/a<<endl;

	return 0;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  rep(i, n) sort(s[i].begin(), s[i].end());
  sort(s.begin(), s.end());
  
  ll ans = 0;
  for(int i = 0; i < n-1;){
    ll same = 0;
    int j = i+1;
    for(; j < n; ++j){
      if(s[i] != s[j]) break;
    }
    same = j - i;
    i = j;
    ans += same * (same - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n;
	//ll m;
	//ll x, y;
	//ll a, b, c;
	//ll k;
	//string s;
	ull ans = 0;
	//float ans = 0;
	//string ans;

	cin >> n;
	vector<ull> a(n);
	bool is0 = false;
	rep(i, n) {
		cin >> a[i];
		if (a[i] == 0) is0 = true;
	}

	if (is0) {
		cout << "0\n";
		return;
	}

	sort(RALL(a));

	ans = 1;
	rep(i, n) {
		if (log10l(ans) + log10l(a[i]) > 18) {
			cout << "-1\n";
			return;
		}
		ans *= a[i];
		if (ans > 1000000000000000000) {
			cout << "-1\n";
			return;
		}
	}

	cout << ans << "\n";
}

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

	solve_abc_b();

	return 0;
}


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

int main(){

    int a,b,c;

    cin >> a >> b >> c;

    map<int,int> mp;

    mp[a]++;
    mp[b]++;
    mp[c]++;

    if(mp[5]==2&&mp[7]==1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp
x = 0
ans = []
for i in 0..n-1
  if s[i] == "I"
    x += 1
    ans << x
  else
    x -= 1
    ans << x
  end
end

if ans.max < 0
  puts 0
else
  puts ans.max
end

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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=100+3;

int n,w,a,v;
ll f[100003],ans;

int main(){
	cin>>n>>w;
	For(i,n){
		cin>>a>>v;
		for (int j=w;j>0;j--){
			if (j>=a){
				f[j]=max(f[j],f[j-a]+v);
			}
		}
	}
	For(i,w){
		ans=max(ans,f[i]);
	}
	cout<<ans<<endl;
	re 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    
    byte A[][] = new byte[N][N];
    byte B[][] = new byte[M][M];
    
    String input;
    for (int i = 0; i < N; i++) {
      input = sc.next();
      for (int j = 0; j < N; j++) {
        if (input.charAt(j) == '#') {
          A[i][j] = 1;
        } else {
          A[i][j] = 0;
        }
      }
    }
    for (int i = 0; i < M; i++) {
      input = sc.next();
      for (int j = 0; j < M; j++) {
        if (input.charAt(j) == '#') {
          B[i][j] = 1;
        } else {
          B[i][j] = 0;
        }
      }
    }
    boolean flag = true;
    for (int i = 0; i <= N - M; i++) {
      for (int j = 0; j <= N - M; j++) {
        if (B[0][0] == A[i][j]) {
          flag = true;
          for (int k = 0; k < M; k++) {
            for (int l = 0; l < M; l++) {
              if (B[k][l] != A[i + k][j + l]) {
                flag = false;
                break;
              }
            }
            if (!flag) {
              break;
            }
          }
          if (flag) {
            System.out.println("Yes");
            return;
          }
        }
      }
    }
    
    System.out.println("No");
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;

constexpr int MaxN = 100000 + 10;
int s, t;
int S[MaxN], T[MaxN];
int ssum[MaxN + 1], tsum[MaxN + 1];

bool Solve(int a, int b, int c, int d) {
    return (ssum[b + 1] - ssum[a]) % 3 == (tsum[d + 1] - tsum[c]) % 3;
}

int main() {
    string str;

    cin >> str;
    for (size_t i = 0; i < str.length(); i++) {
        S[i] = (str[i] != 'A') + 1;
        ssum[i + 1] = ssum[i] + S[i];
    }

    cin >> str;
    for (size_t i = 0; i < str.length(); i++) {
        T[i] = (str[i] != 'A') + 1;
        tsum[i + 1] = tsum[i] + T[i];
    }

    int q;
    cin >> q;

    for (size_t _ = 0; _ < q; _++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;
        bool ans = Solve(a, b, c, d);
        cout << (ans ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N, minus = 0, B = 0; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) {
  	cin >> A[i];
    if (A[i] < 0) {
      minus++;
      A[i] *= -1;
    }
    B += A[i];
  }
  if ((minus % 2 == 1) && (notFound(A, 0))) {
  	vsort(A);
    B -= A[0] * 2;
  }
  cout << B << endl;
}

Measured memory_bytes: 1024
/*
* author: pavveu
*/

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

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int,int>;
using graph = vector<vi>;

#define FOR(name__, upper__) for (int name__ = 0; name__ < (upper__); ++name__)
#define all(x) begin(x), end(x)
#define mp make_pair
#define mt make_tuple

template<class T>
void initialize_matrix(vector<vector<T>>& matrix, int rows, int cols, T value) {
	assert(matrix.empty());
	FOR (row, rows) 
		matrix.emplace_back(cols, value);
}

const ll mod = 1e9 + 7;

void go() {
	int n; cin >> n;
	vi dp(n + 1, 0);
	dp[0] = 1;

	for (int i = 1; i <= n; i++) {
		for (int j = i - 3; j >= 0; j--) {
			dp[i] = (dp[i] + dp[j]) % mod;
		}
	}

	cout << dp[n] << endl;
}

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

	go();

	return 0;
}


Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys


def solve(W: int, H: int, x: int, y: int):
    result1 = W*H * 0.5
    if W*y == H*x and W*y == -H*x+H*W:
        result2 = 1
    else:
        result2 = 0
    print(result1, result2)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    W = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int
    solve(W, H, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;


//=============prime_factor============================
vector<ll> prime_factor(ll N)
{
  vector<ll> res;
  for (ll i = 2; i * i <= N; ++i) {
    if (N % i == 0) {
      ll cnt = 0;
      while (N % i == 0) {
        N /= i;
        cnt += 1;
      }
      res.push_back(i);
    }
  }
  if (N != 1) {
    res.push_back(N);
  }
  return res;
}
//=================================================


int main()
{
  ll N;
  cin >> N;
  ll rev_ans = 0;
  vector<ll> factor = prime_factor(N);
  ll f_size = factor.size();
  ll I = pow(2, f_size);
  for (ll i = 1; i < I; ++i) {
    bitset<11> bs(i);
    ll temp = 1;
    for (ll j = 0; j < f_size; ++j) {
      if (bs[j]) {
        temp *= factor.at(j);
      }
    }
    if (__builtin_popcountll(i) % 2 == 1) {
      rev_ans += N / temp;
    }
    else {
      rev_ans -= N / temp;
    }
  }
  cout << N - rev_ans << endl;
}



Measured memory_bytes: 3312