akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
//----------------------------------------------------------
//Macro
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define inf (1<<30)
#define ins insert
#define maxn 1e6
//----------------------------------------------------------
//TypeDef
typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef vector<int> vi;
//----------------------------------------------------------
//Variables
int n, m, q;
bool a[2002][2002] = {};
int d[2002][2002] = {}, r[2002][2002] = {}, v[2002][2002] = {}; 
//----------------------------------------------------------
void Input ()
{
	cin >> n >> m >> q;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
		{
			char c;
			cin >> c;
			a[i][j] = (c - '0');
			d[i][j] = d[i-1][j] + d[i][j-1] - d[i-1][j-1];
			r[i][j] = r[i-1][j] + r[i][j-1] - r[i-1][j-1];
			v[i][j] = v[i-1][j] + v[i][j-1] - v[i-1][j-1];
			if (a[i][j] and a[i-1][j]) d[i][j] ++;
			if (a[i][j] and a[i][j-1]) r[i][j] ++;
			if (a[i][j]) v[i][j] ++;
		}	
}
void Solve ()
{
	while (q--)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int a = r[x2][y2] - r[x1-1][y2] - r[x2][y1] + r[x1-1][y1],
			b = d[x2][y2] - d[x1][y2] - d[x2][y1-1] + d[x1][y1-1],
			c = v[x2][y2] - v[x1-1][y2] - v[x2][y1-1] + v[x1-1][y1-1];
		//cout << a << ' ' << b << ' ' << c << '\n';
		cout << c - a - b << '\n';
	}
}
//----------------------------------------------------------
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie (NULL);
    cout.tie (NULL);
    Input ();
    Solve ();
}

Measured memory_bytes: 52736
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    seika s;
    cin >> n >> s;
    i64 ans = 0;
    for (int j = 1; j < n - 1; j++)
    {
        akari<int> lc(3), rc(3);
        for (int i = 0; i < j; i++)
        {
            if (s[i] == s[j])
            {
                continue;
            }
            if (s[i] == 'R')
            {
                lc[0]++;
            }
            if (s[i] == 'G')
            {
                lc[1]++;
            }
            if (s[i] == 'B')
            {
                lc[2]++;
            }
        }
        for (int k = j + 1; k < n; k++)
        {
            if (s[k] == s[j])
            {
                continue;
            }
            if (s[k] == 'R')
            {
                rc[0]++;
            }
            if (s[k] == 'G')
            {
                rc[1]++;
            }
            if (s[k] == 'B')
            {
                rc[2]++;
            }
        }
        for (int i = 0; i < 3; i++)
            for (int k = 0; k < 3; k++)
            {
                if (i == k)
                {
                    continue;
                }
                ans += i64(1) * lc[i] * rc[k];
            }
        for (int d = 1; j - d >= 0 && j + d < n; d++)
        {
            if (s[j - d] != s[j] && s[j] != s[j + d] && s[j - d] != s[j + d])
            {
                ans--;
            }
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3612
from collections import Counter

n = int(input())
lst = list(map(int, input().split()))
lst_odd = Counter(lst[::2])
lst_even = Counter(lst[1::2])
odd = sorted(lst_odd.items(), key=lambda x:x[1], reverse=True)
even = sorted(lst_even.items(), key=lambda x:x[1], reverse=True)

if len(odd) == len(even) == 1:
	if odd[0][0] == even[0][0]:
		ans = int(n/2)
	else:
		ans = 0
else:
	if odd[0][0] != even[0][0]:
		ans = n - odd[0][1] - even[0][1]
	else:
		ans = n - max(odd[0][1] + even[1][1], odd[1][1] + even[0][1])

print(ans)

Measured memory_bytes: 21184
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=s.at(s.size()-i-1)){
      ans++;
    }
  }
  cout<<ans/2<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;
 
@SuppressWarnings("unchecked")
public class Main {
  class UnionFind {
    int[] parent;
    int[] size;
    int n;

    UnionFind(int n) {
      this.parent = new int[n];
      this.size = new int[n];
      this.n = n;
      for (int i = 0; i < n; i++) {
        this.parent[i] = i;
        this.size[i] = 1;
      }
    }

    void union(int a, int b) {
      int pa = find(a);
      int pb = find(b);

      if (pa == pb) {
        return;
      }

      if (this.size[pa] > this.size[pb]) {
        this.size[pa] += this.size[pb];
        this.parent[pb] = pa;
      } else {
        this.size[pb] += this.size[pa];
        this.parent[pa] = pb;
      }
    }

    int find(int a) {
      if (this.parent[a] == a) {
        return a;
      } else {
        return find(this.parent[a]);
      }
    }

    @Override
    public String toString() {      
      String ret = "";
      for (int i = 0; i < this.n; i++) {
        ret += this.parent[i] + " ";
      }
      ret += '\n';
      for (int i = 0; i < this.n; i++) {
        ret += this.size[i] + " ";
      }
      return ret;
    }
  }

  class Pair implements Comparable<Pair>{
    int x, y;

    Pair(int x, int y) {
      this.x = x;
      this.y = y;
    }

    @Override
    public int compareTo(Pair o) {
      if (this.x != o.x) {
        return this.x - o.x;
      }
      return this.y - o.y;
    }
  }

  void run() {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int k = sc.nextInt();
    int l = sc.nextInt();

    UnionFind kUnionFind = new UnionFind(n);
    UnionFind lUnionFind = new UnionFind(n);

    for (int i = 0; i < k; i++) {
      int p = sc.nextInt() - 1;
      int q = sc.nextInt() - 1;
      kUnionFind.union(p, q);
    }

    for (int i = 0; i < l; i++) {
      int p = sc.nextInt() - 1;
      int q = sc.nextInt() - 1;
      lUnionFind.union(p, q);
    }

    TreeMap<Pair, Integer> map = new TreeMap();
    for (int i = 0; i < n; i++) {
      int parentK = kUnionFind.find(i);
      int parentL = lUnionFind.find(i);
      Pair pair = new Pair(parentK, parentL);
      if (map.containsKey(pair)) {
        map.put(pair, map.get(pair) + 1);
      } else {
        map.put(pair, 1);
      }
    }

    String tab = "";
    for (int i = 0; i < n; i++) {
      int parentK = kUnionFind.find(i);
      int parentL = lUnionFind.find(i);
      Pair pair = new Pair(parentK, parentL);
      int ans = map.get(pair);
      System.out.print(tab + ans);
      tab = " ";
    }
    System.out.println();
  }
 
  public static void main(String[] args) {
    new Main().run();
  }
}


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

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

    int b[n - 1];
    for(int i = 0; i < n - 1; i++){
        cin >> b[i];
    }

    int ans = 0;
    ans += b[0];
    for(int i = 1; i < n - 1; i++){
        if(b[i] <= b[i - 1]){
            ans += b[i];
        }else{
            ans += b[i - 1];
        }
    }

    ans += b[n - 2];
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
ID: jerrywcy
TASK: AtCoder ABC 100 Problem D
LINK: https://abc100.contest.atcoder.jp/tasks/abc100_d
LANG: C++
*/
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;
 
string gs(char x){
    string s(1,x);
    return s;
}
 
bool comp(long long a,long long b)
{
	return a>b;
}
 
int main()
{
	long long n,m;
	cin>>n>>m;
 
	long long arr[3][n];
	for(long long i=0;i<n;i++)
	{
		cin>>arr[0][i]>>arr[1][i]>>arr[2][i];
	}
 
	long long brr[n],a,b,c;
	long long mmax=INT_MIN;
	long long sum;
	for(long long k=0;k<8;k++)
	{
		a=((1)&k?1:-1);
		b=((1<<1)&k?1:-1);
		c=((1<<2)&k?1:-1);
 
		for(long long i=0;i<n;i++)
		{
			brr[i]=a*arr[0][i]+b*arr[1][i]+c*arr[2][i];
		}
		sort(brr,brr+n,comp);
		sum=0;
		for(long long i=0;i<m;i++)
		{
			sum+=brr[i];
		}
		mmax=max(sum,mmax);
	}
	cout<<mmax;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 500004
#define md 2000000000000000000ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////

int main(){
  int n;
  cin>>n;
  int ar[n+2];
  int num=1;
  for(int i=1;i<=n;i++){
      cin>>ar[i];
      if(ar[i]==num)num++;
  }

  num--;
  if(num==0) cout<<(-1)<<endl;
  else
  cout<<(n-num)<<endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int H,W,N;
int a[201][201];
int A[201][201];

inline int calc(int h,int w,int H,int W){
  return A[H][W]-A[H][w]-A[h][W]+A[h][w];
}

bool solve(int h,int w,int H,int W,int N,int M){
  int res=0,total=calc(h,w,H,W);
  if(N==1)return (total>=M);
  for(int i=h+1;i<H;i++){
    if(calc(h,w,i,W)<M)continue;
    if(solve(i,w,H,W,N-1,M))return true;
    break;
  }
  for(int j=w+1;j<W;j++){
    if(calc(h,w,H,j)<M)continue;
    if(solve(h,j,H,W,N-1,M))return true;
    break;
  }
  for(int i=H-1;i>h;i--){
    if(calc(i,w,H,W)<M)continue;
    if(solve(h,w,i,W,N-1,M))return true;
    break;
  }
  for(int j=W-1;j>w;j--){
    if(calc(h,j,H,W)<M)continue;
    if(solve(h,w,H,j,N-1,M))return true;
    break;
  }
  return res;
}

bool check(int nv,int sv,int M){
  int ev=0,wv=0;
  while(calc(0,0,wv,nv)<M){
    wv++;
    if(wv>=H)return false;
  }
  while(calc(0,nv,ev,W)<M){
    ev++;
    if(ev>=H)return false;
  }
  if(sv<nv)ev=max(ev,wv);
  if(sv>nv)wv=max(ev,wv);
  if(calc(wv,0,H,sv)<M)return false;
  if(calc(ev,sv,H,W)<M)return false;
  return true;
}

bool check(int M){
  if(N==4)
    for(int nv=1;nv<W;nv++)
      for(int sv=1;sv<W;sv++)
        if(check(nv,sv,M))return true;
  return solve(0,0,H,W,N,M);
}

int compute(){
  int L=0,R=200000001,M;
  while(R-L>1){
    M=(L+R)/2;
    if(check(M))L=M;
    else R=M;
  }
  return L;
}

int main(){
  scanf("%d %d %d",&H,&W,&N);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      scanf("%d",&a[i][j]);
      A[i+1][j+1]=a[i][j]+A[i+1][j]+A[i][j+1]-A[i][j];
    }
  }
  int ans=compute();
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3520
"""
iの直前で空のときに、Xi=Xj(i<j)であるようなjまで進むと、空になる
よってnext[i] = j
iの直前に空のときに、次にiの直前で空が回ってくるまでのidxの変化
jump[i] = ? * N or inf
もしjump[i] != infならできるだけこれを回したあとに、愚直にやるだけでよい
もしjump[i] == infならnext[i]に移動して、これを試す
どこかで周期ができるはずなので鳩ノ巣原理よりO(N)で見つかる
"""

#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    A=LI()
    A *= 2 #2周分
    next_ = [-1]*2*N #次同じ数字が現れるidx
    last = defaultdict(lambda : -1) #各数字の現時点での最後尾
    for i,a in enumerate(A):
        if last[a] != -1:
            next_[last[a]] = i
        last[a] = i
    
    now = 0 #今のidx(mod N)
    accumulate_step = 0 #累計
    step_size = 0 #周期サイズ
    last_step = [-1]*2*N #そのidxに来たときのaccumulate_step
    #このwhileでは空の状態で進んでいく
    while accumulate_step + next_[now] - now  < N*K: #ぎりぎりまでnextやstep_sizeでたどる
        if last_step[now]!=-1: #周期があった!
            step_size = accumulate_step - last_step[now]
            remain = N*K - accumulate_step
            accumulate_step += remain//step_size * step_size
            now = accumulate_step%N
            if remain//step_size: #無限ループ回避
                continue
        
        #普通にnext_をたどって1個進む
        last_step[now] = accumulate_step
        before = now 
        now = next_[before] + 1
        accumulate_step += now - before 
        now %= N
    
    #残りはnaiveにやる
    remain = N*K-accumulate_step
    ans = []
    cnt = defaultdict(int)
    for a in A[2*N-remain:]:
        if not cnt[a]:
            ans.append(a)
            cnt[a] += 1
            continue
        while cnt[a]:
            cnt[ans.pop()] -= 1
    print(*ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 122756
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author shangu
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastReader in = new FastReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    FSumDifference solver = new FSumDifference();
    solver.solve(1, in, out);
    out.close();
  }

  static class FSumDifference {
    public void solve(int testNumber, FastReader in, PrintWriter out) {
      long n = in.nextLong(), x = in.nextLong(), d = in.nextLong();
      if (d == 0) {
        if (x == 0) out.println(1);
        else out.println(n + 1);
        return;
      }
      HashMap<Long, ArrayList<Seg>> segments = new HashMap<>();
      for (long i = 0; i <= n; i++) {
        long grp = x * i, offet = (long) Math.floor(grp * 1.0 / d);
        grp = (grp % d + d) % d;
        if (!segments.containsKey(grp)) segments.put(grp, new ArrayList<>());
        ArrayList<Seg> cur = segments.get(grp);
        cur.add(new Seg(offet + i * (i - 1) / 2, -1));
        cur.add(new Seg(offet + (2 * n - 1 - i) * i / 2, 1));
      }
      long ans = 0;
      for (ArrayList<Seg> list : segments.values()) {
        list.sort((a, b) -> (a.v == b.v ? a.t - b.t : Long.compare(a.v, b.v)));
        int cnt = 0;
        long begin = 0;
        for (Seg e : list) {
          if (cnt == 0 && e.t == -1) begin = e.v;
          cnt += e.t;
          if (cnt == 0) ans += e.v - begin + 1;
        }
      }
      out.println(ans);
    }

    private class Seg {
      long v;
      int t;

      public Seg(long _v, int _t) {
        v = _v;
        t = _t;
      }

    }

  }

  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream), 32768);
      st = null;
    }

    public String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

  }
}



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

int main() 
{
    int n,k,y,i,j;
    cin>>n;
    int arr[n][3];
    int dp[n][3];
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>arr[i][j];
            dp[i][j]=0;
        }
    }
    for(i=0;i<3;i++) dp[0][i]=arr[0][i];
    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            int x;
            if(j==0) x= max(dp[i-1][1],dp[i-1][2]);
            else if(j==1) x= max(dp[i-1][0],dp[i-1][2]);
            else x=max(dp[i-1][0],dp[i-1][1]);
            dp[i][j]=arr[i][j]+ x;
            
        }
    }
    int ans=0;
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    
}


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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int a[n+1];
	int b[n+1];
	int c[n];
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=1; i<=n; i++) cin >> b[i];
	for(int i=1; i<=n-1; i++) cin >> c[i];
	int ans = 0;
	int pre = -1;
	for(int i=1; i<=n ;i++){
		int x = a[i];
		ans += b[x];
		if(pre == x-1) ans += c[pre];
		pre = x;
	}
	cout << ans << endl;
	return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,h,A,B,sum,a_max,ans;
vector<int> b;

main() {
    cin >> n >> h;
    rep(i,n) {
        cin >> A >> B;
        a_max = max(A,a_max);
        b.pb(B)
    }
    sort(rall(b));
    rep(i,n) {
        if (a_max < b[i] && sum < h) sum += b[i],ans++;
        else break;
    }
    if (sum < h) ans += (h-sum+a_max-1) / a_max;
    cout << ans << endl;
}



Measured memory_bytes: 1400
while True:
    str_shuffled = input()
    if str_shuffled == '-':
        break
    shuffle_time = int(input())
    for _ in range(shuffle_time):
        num_to_shuffle = int(input())
        str_shuffled = str_shuffled[num_to_shuffle:] + str_shuffled[:num_to_shuffle]
    print(str_shuffled)



Measured memory_bytes: 5592
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void)
{
	int n,k;
	int i = 0;
	int j = 0;
	int *table, *value;
	int newvalue;
	
	scanf("%d",&n);
	scanf("%d",&k);

	table = (int*)malloc(sizeof(int)*n);
	value = (int*)malloc(sizeof(int)*n);

	while(i < n)
	{
		scanf("%d",&table[i]);
		value[i] = 10000000000;
		i++;
	}

	value[0] = 0;
	
	i = 1;
	while(i != n){
		j = i - 1;
		while(j >= i-k && j >= 0)
		{
			newvalue = value[j] + abs(table[i] - table[j]);
			if(value[i] > newvalue){
				value[i] = newvalue;
			}
			j--;
		}
		i++;
	}

	printf("%d",value[n-1]);
	free(table);
	free(value);
	return 0;
}

Measured memory_bytes: 2196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    long long k;
    int n = 50;
    cin >> k;
    vector<long long> a(n,0);
    for(int i = 0;i < n;i++){
        a[i] += k/n;
    }
    for(int i = 0;i < k % n;i++){
        a[i]++;
    }
    for(int i = 0;i < n;i++){
        a[i] += n - 1 - i;
    }
    cout << n << endl;
    for(int i = 0;i < n-1;i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int n; cin>> n;
  vector<ll> A(n);
   for(int i = 0;i<n;++i){
     cin >> A[i];
       if(A[i] == 0){
        cout << 0 << endl;
        return 0;
       }
   }
  
	ll ans = 1, max = 1e18; 
	  for(ll x : A){
	    if(x > max/ans){
	      cout << -1 << endl;
	      return 0;
	    }
	    ans *= x;
	  }
	cout << ans << endl;
  
}

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

int solve(int arr[],int i,int arr1[],int n,int k)
{
if(i>=n)
{
	return 100001;
}
	if(i==n-2)
	{
	 arr1[n-2]  = abs(arr[i]-arr[i+1]);
	 return arr1[n-2];
	}
	if(arr1[i]!=-1)
	{
	return arr1[i];
	}
	int temp;
	int min1 = INT_MAX;
	for(int j=1;j<=k;j++){
	temp = abs(arr[i+j]-arr[i])+solve(arr,i+j,arr1,n,k);
	 min1 = min(min1,temp);
	}
	arr1[i] = min1;
	return arr1[i];
}


int main()
{
	int n,k;
	cin>>n>>k;
	int i=0;
	int arr[n];
	for(i=0;i<n;i++)
	{
      cin>>arr[i];
	}
	int arr1[n];
	memset(arr1,-1,sizeof(arr1));
	arr1[n-1] = 0;
	cout<<solve(arr,0,arr1,n,k)<<endl;
}

Measured memory_bytes: 10368
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    loop {
        let input:Vec<i32> = read_vec();

        match (input.get(0), input.get(1)) {
            (Some(&0), Some(&0)) => break,
            (Some(max), Some(target)) => println!("{}", search(max, target)),
            _ => break
        }
    }
}

fn search(max: &i32, target: &i32) -> i32 {
    let mut ans = 0;

    for x in 1..(*max - 1) {
        for y in x+1..(*max) {
            for z in y+1..(*max + 1) {
               if x + y + z == *target {
                   ans += 1;
               }
            }
        }
    }

    ans
}


Measured memory_bytes: 5032
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


int main() {
  ll n; cin >> n;
  ll a = 1;
  while(a <= n){
    a *= 2;
  }
  cout << a/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
char c;
int main(){
	while(cin>>c&&c!='\n'){
		if(c==',')putchar(' ');
		else putchar(c);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
double a, b, c, d, e, f;
double det;
double x, y;
while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
det = a * e - b * d;
if(det != 0){
x = (e * c - b * f) / det;
y = (a * f - d * c) / det;
x = (x == fabs(x)) ? fabs(x) : x;
y = (y == fabs(y)) ? fabs(y) : y;
printf("%.3f %.3f\n", x , y);
}
}
return 0;
}

Measured memory_bytes: 1080
[A,B,C] = map(int,input().split())
K = int(input())

ans = 'No'
i = 0
for i in range(K+1):
    for j in range(K+1-i):
        h = K-i-j 
        if i > 0 :
            R = A*(2**i)
        else:
            R = A
        if j > 0 :
            G = B*(2**j)
        else :
            G = B
        if h > 0 :           
            Bl = C*(2**h)
        else:
            Bl = C
        if G > R and Bl > G:
            ans = 'Yes'


print(ans)

Measured memory_bytes: 9096
#include <iostream>
#include <climits>


using namespace std;


using ll = long long;


ll schedules[100][10];
ll profits[100][11];
ll N;

ll calc_profit(ll s[])
{
    ll p = 0;
    for (ll i = 0; i < N; i++) {
        ll cnt = 0;
        for (ll j = 0; j < 10; j++) {
            if (s[j] && schedules[i][j]) {
                cnt++;
            }
        }
        /// cout << "cnt: " << cnt << endl;
        p += profits[i][cnt];
    }

    return p;
}


void print_sched(ll s[])
{
    for (int i = 0; i < 10; i++) {
        cout << s[i] << " ";
    }
    cout << endl;
}


ll max_p = LONG_LONG_MIN;
void combination(ll s[], int depth, bool open)
{
    if (depth == 10 && open) {
        // print_sched(s);
        ll p = calc_profit(s);
        max_p = max(max_p, p);
        return;
    } else if (depth == 10 && !open) {
        return;
    }

    s[depth] = 0;
    combination(s, depth + 1, open | false);
    s[depth] = 1;
    combination(s, depth + 1, open | true);
}


int main()
{

    cin >> N;
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < 10; j++) {
            cin >> schedules[i][j];
        }
    }

    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j <= 10; j++) {
            cin >> profits[i][j];
        }
    }
    
    ll s[10] = {0};
    combination(s, 0, false);

    cout << max_p << endl;
}


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

ans = 0
def gcd(x,y):
    while y:
        x, y = y, x % y
    return x

for i in range(1,k+1):
    for j in range(1,k+1):
        for s in range(1,k+1):
            ans += gcd(gcd(i,j),s)

print(ans)

Measured memory_bytes: 68700
h, w = map(int, input().split())
n = int(input())
a_list = list(map(int, input().split()))

result = []


for i in range(1, n + 1):
    a = a_list[i - 1]
    for j in range(a):
       result.append(i)

for i in range(h):
    if i & 1 == 0:
        print(*result[i*w:(i+1)*w])
    else:
        print(*result[i*w:(i+1)*w][::-1])

Measured memory_bytes: 3916
#include <cstdio>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <cmath>

using namespace std;

typedef long long LL;

LL W, H;
vector<pair<int, int> > value;

int main() {
  cin >> W >> H;
  for (int i = 0; i < W; i += 1) {
    int x;
    cin >> x;
    value.push_back({x, 0});
  }
  for (int i = 0; i < H; i += 1) {
    int x;
    cin >> x;
    value.push_back({x, 1});
  }
  sort(value.begin(), value.end());
  LL ans = 0;
  W += 1; H += 1;
  for (auto& v: value) {
    if (v.second == 1) {
      ans += W * v.first;
      H -= 1;
    } else {
      ans += H * v.first;
      W -= 1;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '



signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N; cin >> N;

    int ans = 0;
    times(N, i) {
        int L, R; cin >> L >> R;
        ans += R - L + 1;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
    string s,t; cin >> s >> t;
    if(s == t.substr(0,s.size())) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3620
def search(A):
  B = list(set(A))
  if len(A)-len(B) == 0: return 0 

  a1 = 0
  for n,(i, j) in enumerate(zip(A[0:-1], A[1:])):
    if i == j:
      a1 = i
      break
  del(A[:n+2])

  return a1

N = int(input())
A = map(int, input().split())
A = [a for a in A]
A.sort(reverse=True)
a1 = search(A)
a2 = search(A)
if a1 > 0 and a2 > 0: print(a1*a2)
else: print(0)


Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;

    int y = (s[0] - '0') * 10 + (s[1] - '0');
    int m = (s[2] - '0') * 10 + (s[3] - '0');

    if (1 <= m && m <= 12 && 1 <= y && y <= 12)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (1 <= m && m <= 12)
    {
        cout << "YYMM" << endl;
    }
    else if (1 <= y && y <= 12)
    {
        cout << "MMYY" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;

namespace _180
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(sol());
        }
        public static string sol()
        {
            int input = int.Parse(Console.ReadLine());
            string output = "";
            for (int i = 0; i < input; i++)
            {
                output = output + "ACL";
            }
            return output;
        }
    }
}


Measured memory_bytes: 27244
// kyougi.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <deque>
#include <set>
#include <map>
#include <string>

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

/*



*/

struct st {
	string s;
	int t;
	st(string s_, int t_) {
		s = s_;
		t = t_;

	}
};
signed main()
{
	int N;
	string X;
	string s[50];
	string t[50];

	cin >> N;
	rep(i, N) {
		cin >> s[i];
		cin >> t[i];
	}
	cin >> X;

	typedef deque<st> vec_t;
	vec_t vec;
	rep(i, N) {
		vec.push_front(st(s[i], atoi(t[i].c_str())));
	}
	int sum = 0;
	rep(i, N) {
		if (X == vec[i].s) { break; }
		sum += vec[i].t;
	}


    cout << sum;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;

int main() {
	int h, n;
	cin >> h >> n;
	vector<int>a(n);
	vector<int>b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	/*vector<vector<int>>dp(n + 1, vector<int>(h));
	for (int i = 0; i < n + 1; i++) {
		for (int j = 0; j < h; j++) {
			dp[i][j] = INF;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < h; j++) {
			if(j < a[i]) {
				dp[i + 1][j] = min(dp[i][j], b[i]);
			}
			else {
				dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - a[i]] + b[i]);
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - a[i]] + b[i]);
			}
		}
	}*/
	//auto p = max(a.begin(), a.end());
	vector<int>dp(h + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < h; j++) {
			int nj = min(h, j + a[i]);
			dp[nj] = min(dp[nj], dp[j] + b[i]);	
		}
	}
	cout << dp[h] << endl;
	return 0;
}

Measured memory_bytes: 256
# coding=utf-8

N = int(input())
A = []
for i in range(N):
    query = list(map(int, input().split()))
    if query[0] == 0:
        A.append(query[1])
    elif query[0] == 1:
        print(A[query[1]])
    elif query[0] == 2:
        A.pop()



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

using namespace std;
typedef long long ll;
void solve(int x){
  int f=0;
  int lim = 120;
  for(int a=-lim;a<=lim;a++){
    for(int b=-lim;b<=lim;b++){
      ll A = (ll)pow(a,5);
      ll B = (ll)pow(b,5);
      if(A-B==x){
        cout<<a<<" "<<b<<endl;
        f=1;
        break;
      }
    }
    if(f) break;
  }
}
int main(){
  int x;
  cin>>x;

  solve(x);
  // cout<<res<<"\n";
}

Measured memory_bytes: 4128
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 1;
int n , m , par[N] , cnt[N];
ll a[N] , sum[N];
vector < int > gr[N];
deque < int > dq;
void dfs(int u ,int p = 1){
	par[u] = p;
	cnt[u] = sz(gr[u]) - 1;
	if(u == p)cnt[u]++;
	for(int to : gr[u])
		if(to != p)
			dfs(to , u);
}
main(){
	scanf("%lld" , &n);
	rep(i , 1 , n)
		scanf("%lld" , a + i);
	rep(i , 2 , n){
		int u , v;
		scanf("%lld%lld" , &u , &v);
		gr[u].pb(v);
		gr[v].pb(u);
	}
	int s = 1;
	vector < int > lvs;
	rep(i , 1 , n){
		if(sz(gr[i]) != 1){
			s = i;
		}else lvs.pb(i);
	}
	if(n == 2){
	 	if(a[1] != a[2])ret("NO");
	 	ret("YES");

	}

	dfs(s , s);
	for(int i : lvs){
		sum[par[i]] += a[i];
		cnt[par[i]]--;
		if(a[i] > a[par[i]])ret("NO");
		if(cnt[par[i]] == 0 and par[i] != s)
			dq.pb(par[i]);
	}

	while(sz(dq) != 0){
		int u = dq.front(); dq.pop_front();
		ll ed = 2ll * a[u] - sum[u];
		if(ed < 0 or ed > a[u] or ed > a[par[u]])ret("NO");
        sum[par[u]] += ed;
		cnt[par[u]]--;
		if(par[u] != s and cnt[par[u]] == 0)
			dq.pb(par[u]);
	}
	if(sum[s] != 2ll * a[s])
		ret("NO");
	ret("YES");	
}

Measured memory_bytes: 16000
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<size_t> p(n);
  for (auto& pi: p) scanf("%zu", &pi);

  size_t min = n+1;
  int res = 0;
  for (size_t i = 0; i < n; ++i) {
    if (min > p[i]) {
      ++res;
      min = p[i];
    }
  }
  printf("%d\n", res);
}


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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int MOD = (int)1e9 + 7;
int main() {
    int n;
    while(cin >> n) {
        long long ans = 1;
        rep(i,1,n+1) ans = ans * i % MOD;
        cout << ans % MOD << endl;
    }
    return 0;
}


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

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	int sum, minute, second; sum = a + b + c + d;
	minute = sum / 60; second = sum % 60;
	cout << minute << endl << second << endl;
	return 0;
}


Measured memory_bytes: 3088
#include<iostream>

int n;
const int x = 10000000;
bool prm[x+1];

void eratos(){
	for(int i=2; i<=x; i++)
		prm[i] = true;
	for(int i=2; i*i<x; i++){
		if(prm[i])
			for(int k=i*i; k<=x; k+=i)
				prm[k] = false;
	}
}

int main(){
	eratos();
	while(true){
		std::cin >> n;
		if(!n)
			return 0;
		for(;;n--){
			if(prm[n] && prm[n-2] && prm[n-6] && prm[n-8]){
				std::cout << n << std::endl;
				break;
			}
		}
	}
}

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

int main(){
    float D,T,S;
    cin >> D >> T >> S;
    if(S==0){
        cout << "No" << endl;
    }else if(D/S <= T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3692
#include<stdio.h>
void sort(int* a, int l, int r){
  int i, j, tmp;
  for(i = l; i < r; i++){
    for(j = r; j > i; j--){
      if (a[j - 1] > a[j]){
	tmp = a[j - 1];
	a[j - 1] = a[j];
	a[j] = tmp;
      }
    }
  }
}

int hogehoge(){
  int a = 0, b = 0, c = 0;
  return a + b + c;
}

int average(int a[], int l, int r){
  int i, sum = 0;
  for(i = l; i <= r; i++){
    sum += a[i];
  }

  return sum / (r - l + 1);
}

int main(void){
  int judge, score[100], i;
  while(1){

    scanf("%d", &judge);
    if(judge == 0){
      break;
    }
    for(i = 0; i < judge; i++){
      scanf("%d", &score[i]);
    }

    sort(score, 0, judge - 1);
    /* printf("\n"); */
    /* fflush(stdin); */
    hogehoge();
    printf("%d\n", average(score, 1, judge - 2));
  }

  return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  map<string, ll> mp;
  REP(i,N){
    string S;
    IN(S);
    mp[S]++;
  }

  ll count = 0;
  for(auto itr : mp){
    count = max(count, itr.second);
  }

  for(auto itr : mp){
    if(itr.second == count){
      OUT(itr.first);
    }
  }

  return 0;
}


Measured memory_bytes: 23808
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
0 0 3 4
3
2 5
1 4
0 3

output:
4.2400000000 3.3200000000
3.5600000000 2.0800000000
2.8800000000 0.8400000000
"""

import sys


def solve(_prj_info):
    for point in _prj_info:
        xp, yp = map(int, point)
        p = xp + yp * 1j
        hypo = p - p1
        prj = p1 + base * project(base, hypo)
        ref = p + (prj - p) * 2.0
        print('{0:.10f} {1:.10f}'.format(ref.real, ref.imag))

    return _prj_info


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


# abs(prj)/abs(base)
def project(a, b):
    return dot(a, b) / dot(a, a)


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    base_info = _input[0].split()
    q_num = int(_input[1])
    prj_points = map(lambda x: x.split(), _input[2:])

    x1, y1, x2, y2 = map(int, base_info)
    p1, p2 = x1 + y1 * 1j, x2 + y2 * 1j
    base = p2 - p1
    res = solve(prj_points)

Measured memory_bytes: 7852
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    private static String sentence;
    
    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        sentence = br.readLine();
        
        sentence = sentence.replaceAll("peach","リンゴ");
        sentence = sentence.replaceAll("apple","peach");
        sentence = sentence.replaceAll("リンゴ","apple");
        
        System.out.println(sentence);
    }
}

Measured memory_bytes: 16896
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e5+5;

ll par[N];
ll sz[N];

ll find(ll x){
 if(par[x]==x)return x;
 return par[x]=find(par[x]);
}

void unio(ll a,ll b){
a=find(a),b=find(b);

par[b]=a;
}


int main()
{ 

IOS;


ll n,m;cin>>n>>m;

vl p(n+1);

for(int i=1;i<=n;i++){
  par[i]=i;
  sz[i]=1;
  cin>>p[i];
}


while(m--){
  ll a,b;cin>>a>>b;
  unio(a,b);
}

ll ans=0;


for(int i=1;i<=n;i++){
  if(find(i)==find(p[i]))++ans;
}

cout<<ans<<endl;


return 0;
 
}


Measured memory_bytes: 5556
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 4e18;
const ll MOD = 1000000007LL;

int N;
 
signed main() {
    cin >> N;
    vector<pii> P;

    int mi = INF, ma = 0;
    rep(i,0,N) {
        int X, Y;
        cin >> X >> Y;
        if(X > Y) swap(X, Y);
        chmin(mi, X);
        chmax(ma, Y);
        P.push_back(make_pair(X, Y));
    }
    sort(P.begin(), P.end());

    int ans = INF;
    int R_ma = P[N-1].first, B_mi = INF;
    rep(i,0,N) chmin(B_mi, P[i].second);
    chmin(ans, (ma-B_mi) * (R_ma-mi));

    set<pii> S;
    S.insert(make_pair(P[0].second, INF));
    rep(i,1,N) S.insert(make_pair(P[i].second, i));

    while(1) {
        // printf("A = %lld, B = %lld\n", S.rbegin()->first, S.begin()->first);
        int diff = S.rbegin()->first - S.begin()->first;
        // printf("ma = %lld, mi = %lld, diff = %lld\n", ma, mi, diff);
        chmin(ans, (ma-mi)*diff);
        if(S.rbegin()->second == INF) break;
        pii nxt = make_pair(P[S.rbegin()->second].first, INF);
        S.erase(*S.rbegin());
        S.insert(nxt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16748
#include<bits/stdc++.h>
int n,i,m;
int main(){
	scanf("%d",&n);for(m=1;m<n;m<<=1);
	if(m==n){
		puts("No");
		return 0;
	}
	m>>=1;
	puts("Yes");
	printf("%d %d\n",m,m+1);
	printf("%d %d\n",m+1,1);
	printf("%d %d\n",1,m+n);
	printf("%d %d\n",m+n,m+1+n);
	printf("%d %d\n",m+1+n,1+n);
	for(i=2;i<n;i+=2)if(i!=m){
		printf("%d %d\n",i,1);
		printf("%d %d\n",i+1,1);
		printf("%d %d\n",i+n,i+1);
		printf("%d %d\n",i,i+1+n);
	}
	if(i==n && i>m+1){
		printf("%d %d\n",i,m^i);
		printf("%d %d\n",i+n,m+1);
	}
	return 0;
}

Measured memory_bytes: 2304