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

constexpr int mod = 1e9 + 7;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<ll>x(n),y(m);
    for(auto &i:x){
        cin>>i;
    }
    for(auto &i:y){
        cin>>i;
    }
    ll xs=0;
    for(int i=1;i<=n;++i){
        xs+=(i-1)*x[i-1]-(n-i)*x[i-1];
        xs%=mod;
    }
    ll ys=0;
    for(int i=1;i<=m;++i){
        ys+=(i-1)*y[i-1]-(m-i)*y[i-1];
        ys%=mod;
    }
    cout<<(xs*ys)%mod<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
ll mod=1e9+7;
long long INF = 1LL<<60;

ll dx, dy;
int main( ){
    cin>>dx>>dy;
    if(dy>dx)swap(dx,dy);
    ll cdx=dx,cdy=dy;
    ll t=dx-dy;
    ll y=(cdy-t)/3,x=y+t;
    if(2*x+y!=dx||x+2*y!=dy||x<0||y<0){
        cout<<0<<endl;
    }
    else {
        ll bunshi=1;
        ll bunbo=1;
        rep(i,1,x+y+1){
            bunshi*=i;
            bunshi%=mod;
            if(bunshi<0)bunshi+=mod;
        }
        rep(i,1,x+1){
            bunbo*=i;
            bunbo%=mod;
            if(bunbo<0)bunbo+=mod;
        }
        rep(i,1,y+1){
            bunbo*=i;
            bunbo%=mod;
            if(bunbo<0)bunbo+=mod;
        }
        ll ans=bunshi*modinv(bunbo,mod)%mod;
        if(ans<0)ans+=mod;
        cout<<ans<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=5001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 

int main()
{
   string s;
   cin>>s;
   map<char,int> mp;
   fo(i,0,sz(s))
   mp[s[i]]++;
   int fg=0;
   if(sz(mp)==2)
   {
    loop(mp)
    if(it->se!=2) fg=1;
   }
   else fg=1;
   if(fg) cout<<"No"<<endl;
   else cout<<"Yes"<<endl;

}

Measured memory_bytes: 256
import math

class Input():
	def readInt(self):
		return int(input())

	def readIntArray(self):
		return [int(x) for x in input().split(" ")]

	def readString(self):
		return input()

	def readStringArray(self):
		return input().split(" ")

	def readFloat(self):
		return float(input())

	def readFloatArray(self):
		return [float(x) for x in input().split(" ")]

def main():
	inp = Input()
	_ = inp.readInt()
	s1, s2 = inp.readStringArray()

	output = ""
	for c1, c2 in zip(s1, s2):
		output += (c1 + c2)

	print(output)


if __name__ == "__main__":
   main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;

int a[22][22];
int n;
int dp[22][1024 * 1024 * 2];
const int mod = 1e9 + 7;

int solve(int i, int mask) {
	if (i == n)
		return 1;
	if (dp[i][mask] != -1)
		return dp[i][mask];
	dp[i][mask] = 0;
	for (int j = 0; j < n; j++) {
		if ((mask & (1 << j)) == 0 && a[i][j]) {
			dp[i][mask] = (dp[i][mask] + solve(i + 1, mask | (1 << j))) % mod;
		}
	}
	return dp[i][mask];
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	memset(dp, -1, sizeof dp);
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	cout << solve(0, 0) << '\n';
}

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

a=list(map(int,input().split()))
count=1
countlist=[]

for i in range(1,N):
  if a[i]==a[i-1]:
    count+=1
    if i==N-1:
      countlist.append(count)
  else:
    countlist.append(count)
    count=1

if countlist==[]:
  print(0)
  exit()

answer=0
for i in range(len(countlist)):
  answer+=(countlist[i])//2
print(answer)


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

using namespace std;

int main(){
    bool flag=true;
    string s;
    cin >> s;

    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1])
            flag = false;
    }

    if(flag)
        cout << "Good\n";
    else
        cout << "Bad\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int d[N];
    REP(i, N) cin >> d[i];

    ll s = 0;
    FOR(i, 0, N - 1) {
        FOR(j, i + 1, N) {
            s += d[i] * d[j];
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

int Count[200];
int Prime(int num){
  fill(Count, Count + 200, 0);
  int now = num;
  for (int i = 2; i <= num; i++){
    while (now % i == 0){
      Count[i]++; now /= i;
    }
  }
  int ans = 1;
  for (int i = 0; i < 200; i++){
    ans *= Count[i] + 1;
  }
  return ans;
}

int main(){
  int N; cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i+=2){
    if (Prime(i) == 8) ans++;
  }
  cout << ans << 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;
typedef long long ll;
const ll mod = 1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string L;
    cin >> L;
    ll sum = 0;
    int count1 = 0;
    vector<ll> two(L.size()+1);
    vector<ll> three(L.size()+1);
    two.at(0) = 1;
    three.at(0) = 1;
    for(int i = 1;i < L.size()+1;i++){
        two.at(i) = two.at(i-1) * 2 % mod;
        three.at(i) = three.at(i-1) * 3 % mod;
    }
    REP(i,L.size()){
        if(L.at(i) == '1'){
            sum = (sum + two.at(count1) * three.at(L.size()-i-1))%mod;
            count1++;
        }
    }
    sum += two.at(count1);
    cout <<sum % mod<< "\n";
}


Measured memory_bytes: 2000
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

import itertools

n = int(input())
l = list(map(int, input().split(" ")))


def is_triangle(a, b, c):
    return a + b > c and a + c > b and c + b > a

res = 0
for a, b, c in itertools.combinations(l, 3):
    if is_triangle(a, b, c) and a != b and b != c and c != a:
       res += 1

print(res)




Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
	     int a= sc.nextInt();
	     int b= sc.nextInt();
	     int x=a*b;
	     int y=a+a+b+b;
	     System.out.println(x+" "+y);

	}
}

Measured memory_bytes: 26316
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
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():
    A=LI()
    A.sort()
    ans = A[0]*A[1]
    for a in A:
        if(a%2==0):
            ans=0
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 5392
package main

import (
	"bufio"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	oddEven := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		oddEven[i], _ = strconv.Atoi(sc.Text())
	}

	boals := make([]int, n)
	for i := n - 1; i >= 0; i-- {
		count := 0
		for j := 2; j*(i+1) <= n; j++ {
			count += boals[j*(i+1)-1]
		}

		if oddEven[i] != count%2 {
			boals[i] = 1
		}
	}

	count := 0
	displayNumbers := make([]int, 0)
	for i, exist := range boals {
		if exist == 0 {
			continue
		}
		count += exist
		displayNumbers = append(displayNumbers, i+1)
	}

	writer := bufio.NewWriter(os.Stdout)

	writer.WriteString(strconv.Itoa(count) + "\n")

	for i, el := range displayNumbers {
		if i != 0 {
			writer.WriteString(" " + strconv.Itoa(el))
		} else {
			writer.WriteString(strconv.Itoa(el))
		}
	}

	if count != 0 {
		writer.WriteString("\n")
	}

	writer.Flush()
}


Measured memory_bytes: 7936
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n, m;
vector<int> edge[100001];
int ans[200001];
int visited[100001];
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    int bt = 100000, tp = 100000, loop;
    ans[bt] = 1;
    visited[1] = 1;
    
    loop = 1;
    while (loop) {
        loop = 0;
        for (int i : edge[ans[bt]]) {
            if (visited[i]) continue;
            loop = 1;
            ans[--bt] = i;
            visited[i] = 1;
            break;
        }
    }
    
    loop = 1;
    while (loop) {
        loop = 0;
        for (int i : edge[ans[tp]]) {
            if (visited[i]) continue;
            loop = 1;
            ans[++tp] = i;
            visited[i] = 1;
            break;
        }
    }
    printf("%d\n", tp - bt + 1);
    for (int i = bt; i <= tp; ++i) {
        printf("%d ", ans[i]);
    }
	return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <set>
#include <math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
using ll = long long;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  cout<<a[n-1]-a[0];
}

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

using namespace std;

typedef long long ll;

const int N = (int)2e5 + 10;

template < typename T >
class FenwickMax {
public:
  int n;
  vector< T > bit;
  FenwickMax(int _n) {
    n = _n;
    bit.resize(n + 1);
  }
  void update(int p, T x) {
    while(p <= n) {
      bit[p] = max(bit[p], x);
      p += (p & (-p));
    }
  }
  T query(int p) {
    T s = 0;
    while(p) {
      s = max(s, bit[p]);
      p -= (p & (-p));
    }
    return s;
  }
};

int main() {
  int n; scanf("%d", &n);
  vector< int > h(n), a(n);
  for(int i = 0; i < n; ++i) {
    scanf("%d", &h[i]);
  }
  for(int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  vector< int > p(n);
  for(int i = 0; i < n; ++i) {
    p[i] = i;
  }
  sort(p.begin(), p.end(), [&](int i, int j) -> bool {
    if(h[i] != h[j]) return h[i] < h[j];
    return a[i] < a[j];
  });
  FenwickMax< ll > dp(n);
  for(int i = 1; i <= n; ++i) {
    int ps = p[i - 1] + 1;
    ll bst = dp.query(ps);
    dp.update(ps, bst + a[ps - 1]);
  }
  printf("%lld\n", dp.query(n));
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 1e3 + 10;
const int maxK = 1e4+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;

int a[10];
int main()
{
	for(int i=1;i<=3;i++)
	{
		cin>>a[i];
	}
	int k;
	cin>>k;
	if(a[2] > a[1] && a[3] > a[2])
	{
		puts("Yes");
	}
	else
	{
		int cnt = 0;
		while(a[2]<=a[1] && cnt<k)
		{
			a[2] *= 2;
			cnt++;
		}
		if(cnt == k && (a[2]>=a[3] || a[1]>=a[2]))
		{
			puts("No");
		}
		else
		{
			while(a[3]<=a[2] && cnt<k)
			{
				a[3] *= 2;
				cnt++;
			}
			if(cnt == k && a[2]>=a[3])
			{
				puts("No");
			}
			else if(a[2] < a[3])
			{
				puts("Yes");
			}
		}
	}
	return 0;
}

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

int main(){

    int a,b;
    cin>>a>>b;
    if(b*10+10<=(100*a+7)/8||(100*a+100)/8<=b*10) cout<<-1<<endl;
    else cout<<max(10*b,(100*a+7)/8)<<endl;



    return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n;cin>>n;

	vector<int> a(n+1);
	vector<int> c(n+1);

	ll ans =0;

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

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

	for(int i=0; i<a.size()-1; i++){
		if(a[i+1]-a[i] ==1){
			ans +=c[a[i]];
		}
	}
	writeln(ans);




}




Measured memory_bytes: 256
/**
 *    author:  math2do
 *    created: 30.08.2020 16:45:21
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  } 
  sort(arr.begin(), arr.end());
  int ans = accumulate(arr.begin(), arr.begin() + k, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll n,T;
    cin>>n>>T;
    vector<ll>t(n);
    for(int i=0;i<n;i++){
        cin>>t.at(i);
    }
    ll ans=0;
    for(int i=1;i<n;i++){
        ans+=min(t.at(i)-t.at(i-1), T);
    }
    cout<<ans+T<<endl;





    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define int long long
#define For(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define Max(x) *max_element(ALL(x))
#define Min(x) *min_element(ALL(x))
#define Lower_bound(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define Upper_bound(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}
int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

signed main() {
  int N = in();
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
  }
  rep(i, N - 1) {
    a[i + 1] += a[i];
  }
  int ans = INF;
  rep(i, N - 1) {
    ans = min(ans, abs(a[i] - (a[N - 1] - a[i])));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int w,a,b;
    cin >> w >> a >> b;
    if(a + w >= b && a <= b + w) cout << 0 << '\n';
    else cout << min(abs(b-(a+w)),abs(a-(b+w))) << '\n';
    return 0;
}


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

using namespace std;

class Graph{
  
  map<int,list<int>> m;
public:
  void addedge(int x,int y){
    m[x].push_back(y);
  }
  int vis[100000]={0},val[100000]={0},res=0,ans=0;
  int dfs(int node){
    if(vis[node]==1)
      return val[node]+1;
    for(auto nbr:m[node]){
      val[node]=max(val[node],dfs(nbr));
      //cout<<node+1<<" "<<nbr+1<<" "<<val[node]<<endl;
    }
    vis[node]=1;
    return val[node]+1;
  }
  
  int func(int n){
    for(auto x:m){
      int node=x.first;
      if(vis[node]==0)
        res=max(res,dfs(node)-1);
    }
    
    return res;
  }
  
};

int main(){
  
  int n,m,x,y;
  cin>>n>>m;
  
  Graph g;
  
  while(m--){
   	cin>>x>>y;
    g.addedge(x-1,y-1);
  }
  
  cout<<g.func(n)<<endl;
  
  return 0;
}

Measured memory_bytes: 11648
n, m = gets.strip.split.map(&:to_i)

done = Array.new(n+1) { 0 }
wa = 0
ac = 0

m.times do
  number, result = gets.strip.split
  number = number.to_i
  if done[number] == 'AC'
    next
  else
    if result == 'AC'
      ac = ac + 1
      wa = wa + done[number]
      done[number] = 'AC'
    elsif result == 'WA'
      done[number] = done[number] + 1
    end
  end
end

puts "#{ac} #{wa}"

Measured memory_bytes: 9468
#組み込み関数頼み
#整数に直さないと2>10
n = int(input())
P = []
for _ in range(n):
    p = list(map(str, input().split( )))
    P.append(p)
for _ in range(n):
    for i in range(2):
        P[_][i] = int(P[_][i])
    P[_][3] = int(P[_][3])
P.sort()
P.sort()
for _ in range(n):
    print(*P[_])



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

typedef long long ll;

const int MOD = 1e9+7;

bool is_prime(int x) {
    if(x<=1) return false;
    for(int i=2;i*i<=x;i++){
        if(x%i==0) return false;
    }
    return true;
}

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

    int n; cin >> n;
    ll ans = 1,cnt;
    for(int i=2;i<=n;i++){
        if(is_prime(i)){
            cnt = 0;
            for(int j=2;j<=n;j++){
                int tmp = j;
                while(tmp>1){
                    if(tmp%i==0) cnt++;
                    else break;
                    tmp /= i;
                }
            }
            ans = (ans * (cnt+1)) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
    int n,a,b,k,sum=0;
    scanf("%d%d",&n,&a);
    k=1;
    for(int i=1;i<n;i++){
        scanf("%d",&b);
        if(a==b)k++;
        else{
            sum+=k/2;
            k=1;
            a=b;
        }
    }
    printf("%d",sum+k/2);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  int tmp;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    if (tmp >= K) {
      ans ++;
    }
  }
  
  cout << ans;
  return 0;
}
  /*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
    //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}









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

  sort (s.begin(),s.end());
  int cnt0=0,cnt1=0;

  rep (i,s.size()){
    if (s[i]=='0') cnt0++;
    if (s[i]=='1') cnt1++;
  }
  cout << min(cnt0,cnt1)*2 << endl;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		int K = sc.nextInt();
		int a[] = new int[N];
		for(int i=0;i<N;i++) {
			a[i] =sc.nextInt();
		}
		Arrays.sort(a);
		int min = Integer.MAX_VALUE;
		for (int i=0;i<=N-K;i++) {
			if (min>a[K-1+i]-a[i]) {
				min = a[K-1+i]-a[i];
			}
		}
		System.out.println(min);
	}
}

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

int insertionSort(vector<int> &A, int N){
  for(int i = 1; i < N; i++){
    int v = A.at(i);
    int j = i - 1;
    while(j >= 0 && A.at(j) > v){
      A.at(j+1) = A.at(j);
      j--;
    }
    A.at(j+1) = v;
    for(int k = 0; k < N-1; k++){
      cout << A.at(k) << " ";
    }
    cout << A.at(N-1) << endl;
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }

  for(int k = 0; k < N-1; k++){
    cout << A.at(k) << " ";
  }
  cout << A.at(N-1) << endl;

  insertionSort(A, N);

  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int N, M, answer = 0;
    string tmp;

    cin >> N;
    vector<string> s(N);
    vector<int> wordCount(N);
    for (int count = 0; count < N; count++)
    {
        cin >> tmp;
        if (count == 0)
        {
            s[0] = tmp;
            wordCount[0] = 1;
        }
        else
        {
            for (int index = 0; index < N; index++)
            {
                if (s[index] == "")
                {
                    s[index] = tmp;
                    wordCount[index] = 1;
                    break;
                }
                else
                {
                    if (tmp == s[index])
                    {
                        wordCount[index]++;
                        break;
                    }
                }
            }
        }
    }

    cin >> M;
    for (int count = 0; count < M; count++)
    {
        cin >> tmp;
        for (int index = 0; index < N; index++)
        {
            if (s[index] == "")
            {
                break;
            }
            else
            {
                if (tmp == s[index])
                {
                    wordCount[index]--;
                    break;
                }
            }
        }
    }

    for (int count = 0; count < wordCount.size(); count++)
    {
        if (wordCount[count] > answer)
        {
            answer = wordCount[count];
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ?
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */

#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int N = 5005, M = 205;
ll d[N], b[M][N], ans, n, m;
int st[M][N], tp[M]; ll t[N]; ll tans[N];
inline void add(int l, int r, ll k) { t[l] += k, t[r+1] -= k; }
int main() {
//	freopen ("hs.in","r",stdin);
	read(n), read(m);
	for (int i = 1;i < n; i++) read(d[i]);
	for (int i = 1;i <= n; i++) 
		for (int j = 1;j <= m; j++)
			read(b[j][i]);
	for (int i = 1;i <= m; i++) 
		st[i][tp[i] = 1] = n + 1, b[i][n + 1] = 1e15;
	for (int i = n;i >= 1; i--) {
		for (int j = 1;j <= m; j++) {
			ll *B = b[j]; int *St = st[j], &T = tp[j]; add(i, i, B[i]);
			while (B[St[T]] <= B[i]) add(St[T], St[T-1]-1, B[i] - B[St[T]]), T--;
			St[++T] = i;
		}
		add(i + 1, n, -d[i]);
		ll res = 0;
		for (int j = i;j <= n; j++)
			res += t[j], t[j] = 0, tans[j] += res, Mx(ans, tans[j]); 
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 11812
#include<iostream>
using namespace std;
int main() {
	char s;
	cin >> s;
	if (s == 'A')cout << 'T' << endl;
	else if (s == 'T')cout << 'A' << endl;
	else if (s == 'C')cout << 'G' << endl;
	else cout << 'C' << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> P(N),Q(N);
    for(auto& in:P) cin >> in;
    for(auto& in:Q) cin >> in;


    vector<ll> order(N);
    iota(order.begin(),order.end(),1);
    ll a,b;
    ll cnt = 1;
    do{
        if(order == P) a = cnt;
        if(order == Q) b = cnt;

        cnt++;
    }while(next_permutation(order.begin(),order.end()));
    res = abs(a-b);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
struct edge{long long to,cost;};
typedef pair<int,int>P;
#define inf 1000000007
string alph("abcdefghijklmnopqrstuvwxyz");
vector<int> es[114514];


signed main(){
    int n;cin>>n;
    int num[114514];
    int sum=0;
    int div=0;
    int d[114514];
    rep(i,0,n){
        cin>>num[i];sum+=num[i];
        div+=i+1;
        if(i>=1)d[i]=num[i]-num[i-1];
    }
    d[0]=num[0]-num[n-1];
    int k=sum/div;
    if(sum%div!=0){
        cout<<"NO"<<endl;
        return 0;
    }
    int count=0;
    rep(i,0,n){
        d[i]-=k;
        count+=abs(d[i])/n;
        if(d[i]%n!=0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(count==k)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 4480
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        int cnt1 = sc.nextInt();
        int cnt2 = sc.nextInt();
        if(sc.next().equals(s1))
        	cnt1--;
        else
        	cnt2--;
        System.out.println(cnt1 + " " + cnt2);
    }
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int start = 0;
		int end = 0;
		String [] lists = s.split("");   ///sを配列に変換する

		for (int i = 0; i < s.length(); i++) {
			if (lists[i].equals("A")) {
				start = i;
				break;
			}
		}
		for (int i = s.length()-1; i >= 0; i--) {
			if (lists[i].equals("Z")) {
				end = i;
				break;
			}
		}
		System.out.println(Math.abs(end - start)+1);
	}
}


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

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


int main()
{
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    REP(i, N-1){
        int A, B;
        cin >> A >> B;
        --A, --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    int K;
    cin >> K;
    vector<int> ans(N, -1);
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
    REP(i, K){
        int V, P;
        cin >> V >> P;
        --V;
        ans[V] = P;
        q.push({P, V});
    }

    while(!q.empty()){
        auto tmp = q.top();
        q.pop();
        int pos = tmp.first;
        int val = tmp.second;
        for(int v: G[val]){
            if(ans[v] == -1){
                ans[v] = pos+1;
                q.push({ans[v], v});
            }else{
                if(abs(ans[v]-pos) != 1){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    REP(i, N) cout << ans[i] << endl;

    return 0;
}



Measured memory_bytes: 7924
//Number of ways:-3*2*2*......................2=(3*(2^N-1)).
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll dp[3][n];
	ll dp_ans[n];
	for(ll e=0;e<n;e++)
	{
		cin>>dp[0][e]>>dp[1][e]>>dp[2][e];
	}
	for(ll e=1;e<n;e++)
	{
		dp[0][e]=dp[0][e]+max(dp[1][e-1],dp[2][e-1]);
		dp[1][e]=dp[1][e]+max(dp[0][e-1],dp[2][e-1]);
		dp[2][e]=dp[2][e]+max(dp[0][e-1],dp[1][e-1]);
	}
	cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));

}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <utility>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
int A[8][8];
int N, M;

int dfs(int idx, vector<bool> visited){
  visited[idx] = true;
  for(int i=0; i< N; i++){
    if (!visited[i]) break;
    if (i==N-1) return 1;
  }
  int ans = 0;
  for(int next=0; next<N; next++){
    if(A[idx][next] && !visited[next]){
      ans += dfs(next, visited);
    }
  }
  
  return ans;
}

int main(){
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  cin >> N >> M;
  for(int i=0; i<M; i++){
    int a, b;
  	cin >> a >> b;
  	a--;b--;
    A[a][b] = 1;
    A[b][a] = 1;
  }
  
  vector<bool> visited(N);
  visited[0] = true;
  int res = dfs(0, visited);
  
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll x,y;
    cin >>x >> y;
    string res = "No";
    rep(i,x+1){
        if(2*i + 4*(x-i) == y) res = "Yes";
    }
    cout << res << endl;
}

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

int main()
{
    int A;
    int B;
    std::cin >> A;
    std::cin >> B;

    for (int i = 1; i <= 3; i++)
    {
        if (i == A | i == B)
        {
            continue;
        }
        else std::cout << i << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 105;

int h1, m1, h2, m2, k, d;

int main() {
scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
d = (h2 - h1) * 60 + (m2 - m1);
printf("%d\n", d - k);
return 0;
}





Measured memory_bytes: 3756
#include <iostream>

using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;

	int ax, bx;

	ax = a - x;
	bx = b - x;

	if (ax < 0) ax = ax*-1;
	if (bx < 0)bx = bx*-1;

	if (ax > bx) cout << "B" << endl;
	else cout << "A" << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 + 7

N = int(readline())
A = np.array(read().split(),np.int64)


answer = 0
for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x
answer %= MOD
print(answer)


Measured memory_bytes: 38672
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    a, b, x = map(int, input().split())
    if (a*a*b/2 <= x):
        print(math.degrees(math.atan((2*(a*a*b-x))/(a*a*a))))
    else:
        print(math.degrees(math.atan((a*b*b)/(2*x))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9 + 7);

constexpr char C = '.';
constexpr char W = '#';

int h, w;
vector<string> field;
vector<vector<ll>> dp;

void f(int i, int j) {
	if (i < h + 1 && j < w + 1 && field[i - 1][j - 1] == C) {
		dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
	}
}


int main(void) {
	cin >> h >> w;
	field = vector<string>(h);
	dp = vector<vector<ll>>(h + 1, vector<ll>(w + 1, 0));
	for (int i = 0; i < h; i++)
		cin >> field[i];
	dp[0][1] = 1;
	dp[1][0] = 0;
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			f(i, j);
		}
	}
	cout << dp[h][w] << endl;
	return 0;
}

Measured memory_bytes: 13332
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>

using namespace std;

#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = 998244353;

int n, k;
int a[N];

void solve() {
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = k + 1; i <= n; ++i) {
        if (a[i] > a[i - k]) cout << "Yes\n";
        else cout << "No\n";
    }
}


int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


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

// SABEDZ
// ZABWZ

int		main()
{
	string s; cin >> s;
	int x = 200003;
	int y = 0;
	int f = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'A')
		{
			x = min(x, i);
			f = 1;
		}
		if (s[i] == 'Z' && f)
		{
			y = max(y, i);
		}
	}
//	cout << y << endl;
//	cout << x << endl;
	cout << y - x + 1 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{

long long int n;
cin>>n;
int q=n%10;
if(q==3)
cout<<"bon"<<endl;
else if(q==0||q==1||q==6||q==8)
cout<<"pon"<<endl;
else
cout<<"hon"<<endl;
}

Measured memory_bytes: 3544
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
ll a[maxn];
ll x,y,z;
int i,j,k,l,t,n,m;
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%lld",&a[i]);
	if (a[n]!=2) {
		printf("-1\n");
		return 0;
	}
	/*mx[n]=mi[n]=2;
	fd(i,n,1){
		if (i==1){
			mx[i-1]=mx[i]+a[1]-1;
			mi[i-1]=mi[i];
			break;
		}
		x=mx[i];
		y=x+a[i]-1;
		y=y/a[i-1]*a[i-1];
		if (y<x){
			printf("-1\n");
			return 0;
		}
		mx[i-1]=y;
		x=mi[i];
		y=x-1;
		y=(y/a[i-1]+1)*a[i-1];
		if (y>x+a[i]-1){
			printf("-1\n");
			return 0;
		}
		mi[i-1]=y;
	}
	if (n==1&&(mx[1]%a[1]!=0||mi[1]%a[1]!=0)){
		printf("-1\n");
		return 0;
	}*/
	x=2;y=3;
	fd(i,n,2){
		z=a[i-1];
		x=(x+z-1)/z*z;
		y=y/z*z+z-1;
	}
	if (x>y) printf("-1\n");else printf("%lld %lld\n",x,y);
	//printf("%lld %lld\n",mi[0],mx[0]);
}

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

using namespace std;

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

    vector<int> plus, minus;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a > 0)plus.push_back(a);
        else minus.push_back(a);
    }
    sort(plus.begin(), plus.end()), sort(minus.begin(), minus.end());

    int ret = 0;
    vector<vector<int>> ope;
    if (plus.size() > 0 && minus.size() > 0) {
        for (int i = 1; i < minus.size(); i++) {
            ope.push_back({plus.front(), minus[i]});
            plus.front() -= minus[i];
        }
        for (int i = 1; i < plus.size(); i++) {
            ope.push_back({minus.front(), plus[i]});
            minus.front() -= plus[i];
        }
        ope.push_back({plus.front(), minus.front()});
        ret = plus.front() - minus.front();
    } else if (plus.size() > 0) {
        for (int i = 2; i < plus.size(); i++) {
            ope.push_back({plus.front(), plus[i]});
            plus.front() -= plus[i];
        }
        ope.push_back({plus[1], plus.front()});
        ret = plus[1] - plus.front();
    } else {
        for (int i = 0; i < minus.size() - 1; i++) {
            ope.push_back({minus.back(), minus[i]});
            minus.back() -= minus[i];
        }
        ret = minus.back();
    }

    cout << ret << endl;
    for (auto x:ope)cout << x[0] << " " << x[1] << endl;
    return 0;
}

Measured memory_bytes: 8300
#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;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--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    bool ok = false;
    int cnt = 0;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        if (a==b) {
            cnt ++;
            if (cnt >= 3) {
                ok = true;
            }
        }else {
            cnt =0;
        }
    }
    if (ok) {
        cout << "Yes" << '\n';
    }else {
        cout << "No" << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3580
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = 0
sub = 99999999
for i in range(len(H)):
    kion = T - (H[i] * 0.006)
    if sub > abs(A - kion):
        sub = abs(A - kion)
        ans = i + 1
print(ans)

Measured memory_bytes: 3064
function Main(s) {
  var s = s.split("\n");
  var n = s[0].split(" ")[0] * 1;
  var k = s[0].split(" ")[1] * 1;
  var a = s[1].split(" ");
  var arr = new Array(n).fill(0);
  a.forEach(e => arr[e - 1]++);
  var ans = 0;
  var v = arr.sort((a, b) => a - b);
  for (var i = 0; i < v.length - k; i++) {
    ans += v[i];
  }
  console.log(ans);
}

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

Measured memory_bytes: 33956
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a, b;
	cin >> a >> b;
	int i, fl=0;
	for(i=0; i<a.size(); i++){
		if (a[i] != b[i]){
			fl = 1;
			break;
		}
	}
	if (fl == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int c = 0;
    int d = 0;
    bool flag = 1;
    if(s[0]!='A')flag = 0;
    for(int i=2;i<n-1;i++){
        if(s[i]=='C')c++;
    }
    for(int i=0;i<n;i++){
        if(islower(s[i]))d++;
    }
    if(c!=1||d!=n-2)flag = 0;
    if(flag){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    return 0;
}

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

int n,m,d,a[1010][1010],c[4];
char ch[]="RYGB";

void work()
{
	scanf("%d %d %d",&n,&m,&d);
	if (d&1)
		{
			for (int i=1; i<=n; i++,puts(""))
				for (int j=1; j<=m; j++)
					a[i][j]=(i+j)&1,putchar((i+j)&1?'Y':'R');
			return;
		}
	int x,y;
	for (int i=1; i<=n; i+=d)
		for (int j=1; j<=m; j+=d)
			{
				x=(i/d+j/d)&1,y=2+x;
				for (int k=0,p=0,q=d; p<q; k++,p++,q--)
					for (int l=p; l<q; l++)
						a[i+k][j+l]=x;
				for (int k=d-1,p=1,q=d-1; p<q; k--,p++,q--)
					for (int l=p; l<q; l++)
						a[i+k][j+l]=x^1;
				for (int k=0,p=1,q=d; p<q; k++,p++,q--)
					for (int l=p; l<q; l++)
						a[i+l][j+k]=y,a[i+l][j+d-k-1]=y^1;
			}
	for (int i=1; i<=n; i++,puts(""))
		for (int j=1; j<=m; j++)
			putchar(ch[a[i][j]]);
}

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


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int b = n - i;
    if (i + b == n && b > 0 && i != b) {
      ans++;
    }
  }
  cout << ans/2 << endl;
  return 0;
}

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

int main(){
  int64_t a,b,c;cin>>a>>b>>c;
  int64_t ans = min(b,c);
  b -= ans;
  c -= ans;
  ans *= 2;
  
  int64_t tmp = min(a,c);
  a -= tmp;
  c -= tmp;
  ans += tmp;
  if (c>0) ++ans;
  if (b>0) ans += b;
  cout<<ans<<endl;
  return 0;
}

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

int	main()
{
	uint64_t	H, W;
	cin >> H >> W;
	if (H == 1 || W == 1)
		cout << 1 << endl;
	else if (H % 2 && W % 2)
		cout << (H + 1)/ 2 * (W + 1) / 2 + (H - 1) / 2 * (W - 1) / 2 << endl;
	else if (!(H % 2))
		cout << (H / 2) * W << endl;
	else
		cout << H * (W / 2) << endl;
}


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

void solve(int n, int k) {
    vector<int> as;
    for (int i = 0; i < 3 * n; i++) {
        as.push_back(k + i);
    }

    long long sum_small = 0;
    long long sum_large = 0;
    for (int i = 0; i < 2 * n; i++) {
        sum_small += as[i];
    }
    for (int i = 2 * n; i < 3 * n; i++) {
        sum_large += as[i];
    }
    if (sum_small > sum_large) {
        cout << -1 << endl;
        return;
    }

    vector<pair<int, int>> ans;
    // if (n & 1) {
    for (int i = 0; i < n / 2; i++) {
        ans.emplace_back(as[i], as[2 * n - n / 2 + i]);
    }
    for (int i = n / 2; i < n; i++) {
        ans.emplace_back(as[i], as[n - n / 2 + i]);
    }
    // }
    sort(ans.begin(), ans.end(), [](auto &a, auto &b) { return a.first + a.second < b.first + b.second; });
    for (int i = 0; i < n; i++) {
        cout << ans[i].first << ' ' << ans[i].second << ' ' << as[2 * n + i] << '\n';
    }
}

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

    int n, k;
    cin >> n >> k;

    solve(n, k);

    // random_device rnd;
    // while (1) {
    //     n = rnd() % 10 + 1;
    //     k = rnd() % 10 + 1;
    //     solve(n, k);
    // }
}


Measured memory_bytes: 5232