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

int main() {
	string s;
    getline(cin,s);
    if(s.at(0)!=s.at(1) && s.at(1)!=s.at(2) && s.at(2)!=s.at(3)){
      cout << "Good" << endl;
    }
    else{
      cout << "Bad" << endl;
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int counter[(1<<15)+1];

int main() {
  FOR(i, 1, 182) {
    counter[i*i]++;
    FOR(j, i, 182) {
      if (i*i+j*j > 1<<15) break;
      counter[i*i+j*j]++;
      FOR(k, j, 182) {
        if (i*i+j*j+k*k > 1<<15) break;
        counter[i*i+j*j+k*k]++;
        FOR(l, k, 182) {
          if (i*i+j*j+k*k+l*l > 1<<15) break;
          counter[i*i+j*j+k*k+l*l]++;
        }
      }
    }
  }

  while (1) {
    int n; scanf("%d", &n);
    if (not n) break;
    printf("%d\n", counter[n]);
  }
  return 0;
}

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

int func(int A, int B, int C) {
    if (A%2 or B%2 or C%2) return 0;
    if (A == B and A == C) return -1;
    return func((B+C)/2, (A+C)/2, (A+B)/2) + 1;
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << func(A, B, C) << endl;
}


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

int H,A[MAX+1];

void maxHeapify(int i)
{
    int l,r,largest;
    l=2*i;
    r=2*i+1;

    if(l<=H && A[l]>A[i])largest=l;
    else largest =i;
    if(r<=H && A[r]>A[largest])largest=r;

    if(largest!=i)
    {
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }
}



int main()
{
    cin >> H;
    for(int i=1;i<=H;i++)
    {
        cin >> A[i];
    }

    for(int i=H/2; i>=1;i--)
    {
        maxHeapify(i);
    }

    for(int i=1;i<=H;i++)
    {
        cout << " " << A[i];
    }
    cout << endl;
    return 0;

}



Measured memory_bytes: 4948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
    int h, w;
    cin >> h >> w;
    int cx, cy, dx, dy;
    cin >> cy >> cx >> dy >> dx;
    cy--;cx--;dy--;dx--;
    bool board[1000][1000];
    int d[1000][1000];
    rep(i, 1000) rep(j, 1000) d[i][j] = INF;
    rep(i, h){
        rep(j, w){
            char c;
            cin>>c;
            board[i][j] = (c == '.');
        }
    }
    deque<P> q;
    q.push_front(P(cy, cx));
    d[cy][cx] = 0;
    int cnt = 0;
    while(!q.empty()){
        int x = q.front().second, y = q.front().first;
        q.pop_front();
        for(int i = -2; i < 3; i++){
            for(int j = -2; j < 3; j++){
                if(i == 0 && j == 0) continue;
                if(x + i < 0 || x + i >= w || y + j < 0 || y + j >= h) continue;
                if(!board[y + j][x + i]) continue;
                if(d[y + j][x + i] <= d[y][x]) continue;
                if((i == 1 && j == 0) ||(i == 0 && j == 1) ||(i == 0 && j == -1) ||(i == -1 && j == 0)){
                    d[y + j][x + i] = d[y][x];
                    q.push_front(P(y + j, x + i));
                }else{
                    if(d[y + j][x + i] <= d[y][x]+1) continue;
                    d[y + j][x + i] = d[y][x] + 1;
                    q.push_back(P(y + j, x + i));
                }
                
                cnt++;
                //printf("%d :: x : %d, y : %d\n", cnt, x+i, y+j);
            }
        }
    }
    if(d[dy][dx] == INF) cout << -1 << endl;
    else cout << d[dy][dx] << endl;
    
/*     rep(i, h){
        rep(j, w){
            cout << d[i][j] << " ";
        }
        cout <<endl;
    } */
}



Measured memory_bytes: 8600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e6 + 5;

int main(void) {
	int n; cin >> n;
	int a[n];
	bool b[N];
	memset(b, 0, sizeof(b));

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

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

			for (int j = 1; a[i] * j <= 1e6; ++j) {
				b[a[i] * j] = true;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5400
import math
 
a = []
N = int(input())
for i in range(5):
  a.append(int(input()))

m = a[0]
for i in range(5):
        if a[i] < m:
                m = a[i]
        else:
                a[i] = m


s = 4 + int(math.ceil(N / a[4]))

print(s)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        int bs[10];
        for(int j=0;j<10;++j){
            cin>>bs[j];
        }
        int l=bs[0],r=0;
        bool flg=true;
        for(int k=1;k<10;++k){
            if(l<bs[k])l=bs[k];
            else if(r<bs[k])r=bs[k];
            else flg=false;
        }
        if(flg)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

ll dp[1010][100010];//dp[index][weight]

int main(){
  int n,W;
  cin >> n >> W;
  ll w[n],v[n];
  rep(i,n)cin >> w[i] >> v[i];
  rep(i,n+1){
    rep(j,W+1){
      if(j-w[i]>=0){
        dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      }
      else{
        dp[i+1][j]=dp[i][j];
      }
    }
  }
  cout << dp[n][W] << endl;
return 0;}

Measured memory_bytes: 79360
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define puts(s) cout<<s<<endl
#define inf (1000000007)
#define nil -1

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	if ((a<=b&&b<=a+w)||(a<=b+w&&b+w<=a+w)) {
		puts(0);
	}else puts(min(abs(b+w-a),abs(a+w-b)));

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		String s = scan.next();

		if(n %2 == 0) {
			// sを2で割って０~M     M+1~N比較
			if(s.substring(0, n/2).equals(s.substring(n/2, s.length()))){
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}else {
			System.out.println("No");
		}


	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
vpii g[N];
int ans[N];
void dfs(int a, int p, int c){
	DEBUG("(%d, %d, %d)\n", a, p, c);
	int x = 0;
	for(auto &e : g[a]){
		if(e.first == p) continue;
		do x++; while(x == c);
		ans[e.second] = x;
		dfs(e.first, a, x);
	}
}

int main(){
	int n; scanf("%d", &n);
	REP(i, n-1){
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		g[a].EB(b, i);
		g[b].EB(a, i);
	}
	int c = 0;
	REP(i, n){
		if(g[c].size() < g[i].size()) c = i;
	}
	dfs(c, -1, -1);
	printf("%d\n", (int)g[c].size());
	REP(i, n-1){
		printf("%d\n", ans[i]);
	}
}


Measured memory_bytes: 8704
using System;
using System.Collections.Generic;
using static AtCoderer.Exter;
using static System.Console;
using System.Linq;

namespace AtCoderer
{

    public class App
    {
        public static void Main(string[] args)
        {
            var s = ReadLine();
            bool a = 0 < int.Parse(string.Join("", s.Take(2))) && int.Parse(string.Join("", s.Take(2))) < 13;
            bool b = 0 < int.Parse(string.Join("", s.Skip(2))) && int.Parse(string.Join("", s.Skip(2))) < 13;
            if (a && b)
                cout = "AMBIGUOUS";
            if (a && !b)
                cout = "MMYY";
            if (!a && b)
                cout = "YYMM";
            if (!a && !b)
                cout = "NA";
            Console.ReadKey();
        }
    }
    public static class Exter
    {
        public static void rep(int loop, Action<int> act)
        {
            for (int i = 0; i < loop; i++)
                act(i);
        }
        public static int ToInt(this string v) => int.Parse(v);
        public static int Max(params int[] p) => p.Max();
        public static long Max(params long[] p) => p.Max();
        public static int Min(params int[] p) => p.Min();
        public static long Min(params long[] p) => p.Min();
        public static int Gcd(int a, int b) => a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
        private static int GcdRecursive(int a, int b) => b == 0 ? a : GcdRecursive(b, a % b);
        public static object cout
        {
            set
            {
                Console.Write(value.ToString());
                Console.WriteLine();

            }
        }
        public static void ToCout<t>(this IEnumerable<t> v)
        {
            cout = string.Join(",", v);
        }
        public static int[] readarr
        {
            get
            {
                preadarr = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
                return preadarr;
            }
        }
        public static int[] preadarr;
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll h, w;
    cin >> h >> w;

    vvl dp(h+1, vl(w+1));  // dp[i][j] : (i,j)への経路の数(未確定のとき-1)
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '.') {
                dp[i+1][j+1] = -1;
            }
        }
    }

    dp[1][1] = 1;
    exrep(i, 1, h) {
        exrep(j, 1, w) {
            if(dp[i][j] == -1) {
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] %= mod;
            }
        }
    }

    out(dp[h][w]);
    re0;
}

Measured memory_bytes: 11004
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	if(n/100==7||(n/10)%10==7||n%10==7)
	{
		printf("Yes\n");
	 } 
	 else
	 {
	 	printf("No\n");
	 }
}

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

int main() {
	long long int k, s[200050] = {},left,right,memo=0;
	scanf("%lld", &k);
	for (int i = 1; i <= k; i++) {
		scanf("%lld", &s[i]);
	}
	if (s[k]!=2) { printf("-1"); return 0; }
	left = 2;
	right = 2;
	for (int i = k - 1; i > 0; i--) {
      
		left = (((left-1) / s[i]) + 1)*s[i];
		right = (((right+s[i+1]-1) / s[i]))*s[i];
      if(right<left){printf("-1"); return 0;}
	}
	printf("%lld %lld", left, right + s[1] - 1);
}

Measured memory_bytes: 1664
s = input()

cnt = 0
max_cnt = 0
for elem in s:
    if elem == 'A' or elem == 'C' or elem == 'G' or elem == 'T':
        cnt += 1
    else:
        if max_cnt < cnt:
            max_cnt = cnt
        cnt = 0
if max_cnt < cnt:
    max_cnt = cnt
print(max_cnt)


Measured memory_bytes: 2940
#include <bits/stdc++.h> 
using namespace std; 
int main() { 
  long long A, B; 
  cin >> A >> B; 
  if(A % 2 != B % 2) { 
    cout << "IMPOSSIBLE" << endl; 
  }
  else { 
    cout << (A + B) / 2 << endl; 
  } 
  return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int mid = s.length()/2;
    string a = s;
    string c1, c2;
    rep(i, mid){
        c1 += s[i];
    }
    for(int i = mid+1; i < s.length(); i++){
        c2 += s[i];
    }
    string b1 = c1;
    string b2 = c2;
    reverse(c1.begin(), c1.end());
    reverse(c2.begin(), c2.end());
    reverse(a.begin(), a.end());
    if(c1 == b1 and c2 == b2 and s == a){
        cout << "Yes" << endl;
    }
    else {cout << "No" << endl;}
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n; string s;
    cin>>n>>s;
    int x=s.length();
    int ans=0;
    int cnt=0;
    rep(i,1000){
        string ss=to_string(i);
        if(ss.length()==1){
            ss="00"+ss;
        }
        else if(ss.length()==2){
            ss="0"+ss;
        }
        cnt=0;
        rep(j,x){
            if(s[j]==ss[cnt]){
                cnt++;
            }
            if(cnt==3){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n = int(inp()); a = read(); b = read()
	ans = 0
	for i in range(n):
		ans += max(0, a[i]-b[i])
	print(ans)

	





		

if __name__ == "__main__":
	solve()

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

int main(){
  int n[5];
  for(int i=1; i<5; i++){
    char c;
    cin >> c;
    n[i] = c - '0';
  }
  if(n[1]+n[2]+n[3]+n[4]==7)cout<<n[1]<<'+'<<n[2]<<'+'<<n[3]<<'+'<<n[4];
  else if(n[1]-n[2]+n[3]+n[4]==7)cout<<n[1]<<'-'<<n[2]<<'+'<<n[3]<<'+'<<n[4];
  else if(n[1]+n[2]-n[3]+n[4]==7)cout<<n[1]<<'+'<<n[2]<<'-'<<n[3]<<'+'<<n[4];
  else if(n[1]-n[2]-n[3]+n[4]==7)cout<<n[1]<<'-'<<n[2]<<'-'<<n[3]<<'+'<<n[4];
  else if(n[1]+n[2]+n[3]-n[4]==7)cout<<n[1]<<'+'<<n[2]<<'+'<<n[3]<<'-'<<n[4];
  else if(n[1]-n[2]+n[3]-n[4]==7)cout<<n[1]<<'-'<<n[2]<<'+'<<n[3]<<'-'<<n[4];
  else if(n[1]+n[2]-n[3]-n[4]==7)cout<<n[1]<<'+'<<n[2]<<'-'<<n[3]<<'-'<<n[4];
  else if(n[1]-n[2]-n[3]-n[4]==7)cout<<n[1]<<'-'<<n[2]<<'-'<<n[3]<<'-'<<n[4];
  cout << "=7";
  return 0;
}

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

using namespace std;

int main() {
    int n,k,q,a[100005]={},x,st=1;
    cin>>n>>k>>q;
    for(int i=1;i<=q;i++){
        cin>>x;
        a[x]++;
    }
    if(q<k){
        for(int i=1;i<=n;i++){
            cout<<"Yes\n";
        }
    }
    else{
        for(int i=1;i<=n;i++){
            if(k-q+a[i]>0)
                cout<<"Yes\n";
            else
                cout<<"No\n";
        }
        
    }
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);

  const int M = 1e9 + 7;

  int K;
  cin >> K;

  string S;
  cin >> S;

  int N = S.size();

  vector<int> fac(N + K + 1, 1); {
    for (int i = 1; i < fac.size(); ++i) {
      fac[i] = (int64_t) fac[i - 1] * i % M;
    }
  }

  auto powm = [M](int v, int p) {
    int r = 1;
    for (; p; p >>= 1) {
      if (p & 1) r = (int64_t) r * v % M;
      v = (int64_t) v * v % M;
    }
    return r;
  };

  vector<int> ifac(N + K + 1); {
    ifac.back() = powm(fac.back(), M - 2);
    for (int i = ifac.size() - 1; i; --i) {
      ifac[i - 1] = (int64_t) ifac[i] * i % M;
    }
    assert(ifac[0] == 1);
  }

  int res = 0;
  for (int i = N; i <= N + K; ++i) {
    auto choose = [&](int n, int m) { return (int64_t) fac[n] * ifac[m] % M * ifac[n - m] % M; };
    (res += (int64_t) powm(25, i - N) * powm(26, N + K - i) % M * choose(i - 1, N - 1) % M) %= M;
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 19900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,a[100005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1]<<endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  string s; cin >> s;
  int q; cin >> q;
  bool inv = false;
  while(q) {
    q--;
    int t; cin >> t;
    if(t == 1) {
      inv = !inv;
    } else {
      int f; char c; cin >> f >> c;
      f--;
      if(inv ^ f) {
        s.push_back(c);
      } else {
        s.insert(s.begin(), c);
      }
    }
  }

  if(inv) reverse(s.begin(), s.end());
  cout << s << endl;

}


Measured memory_bytes: 912
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dp[100010];//i文字目まで作成可能
int main()
{
    string S;
    cin >> S;
    string A[4] = {"dream", "dreamer", "erase", "eraser"};
    int N = S.size();
    rep(i, 5) dp[i] = 0;
    dp[0] = 1;
    rep2(i, 5, N+1)
    {
        //cout << S << endl;
        if(i-5 >= 0 && dp[i-5])
        {
            auto x = S.substr(i-5, 5);
            if(x == A[0] || x == A[2]){ 
                dp[i] = 1;
            }
        }
        if(i-6 >= 0 && dp[i-6])
        {
            auto x = S.substr(i-6, 6);
            if(x == A[3]){
                 dp[i] = 1;
            }
        }
        if(i-7 >= 0 && dp[i-7])
        {
            auto x = S.substr(i-7, 7);
            if(x == A[1])
            {
                dp[i] = 1;
            } 
        }
    }
    if(dp[N]) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 4124
#include <bits/stdc++.h>
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define ALL(x) x.begin(), x.end()
using namespace std;
using ll=long long;
signed main()
{
	ll x; cin >> x;
	ll ok,ng,mid;
	ok = x; ng = 0; mid = (ok+ng)/2;
	auto is_ok = [](auto a, ll x) {
		if (a % 2 == 0) {
			ll score = a / 2 * 6 + a  / 2 * 5 ;
			return score >= x;
		} else {
			ll score = a / 2 * 6 + a  / 2 * 5 + 6;
			return score >= x;
		}
	};
	while (abs(ok-ng)>1) {
		if (is_ok(mid, x) ) 
		{
			ok = mid;
		} else ng = mid;
		mid = (ok+ng)/2;
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll ma(ll x, ll y){
    if(x>y)return x;
    return y;
}

struct hoge
{
    int num, p;
    char str[11];
};
int compare_int(const void *a, const void *b){
    //void*型を引数にして、用いたいポインタ型にキャスト
	struct hoge *A = (struct hoge *)a;
	struct hoge *B = (struct hoge *)b;
    //文字列の時はstrcmpが値を返してくれる
	int sc = strcmp(A->str,B->str);
    //ここでは文字列でソート、同じときはpで降順
	if(sc!=0)return sc;
    return (B->p) - (A->p);
}
struct hoge re[100];
int main(void){
    int n;
    scanf("%d", &n);
    for(int i = 0;i < n;i++){
        scanf("%s %d", &re[i].str, &re[i].p);
        re[i].num = i+1;
    }
    qsort(re, n, sizeof(struct hoge), compare_int);
    for(int i = 0;i < n;i++){
        printf("%d\n", re[i].num);
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    point = sum(b)

    for i in range(1,n):
        if a[i-1] +1 == a[i]:
            point += c[a[i-1]-1]


    print(point)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9132
import math as m
import fractions as fr

def is_prime(n): #素数かどうか判定
    if n == 1: return False
    for k in range(2, int(m.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table   

a, b = map(int, input().split())
g = fr.gcd(a,b)
tb = divisor(g)

count = 1
for i in tb:
    if is_prime(i):
        count += 1

print(count)

Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  int AB = A + B;
  int XY = min(X, Y);
  
  X -= XY;
  Y -= XY;
  C *= 2; 
  
  int res = min(AB, C) * XY;
  
  if(X) res += min(A, C) * X;
  if(Y) res += min(B, C) * Y;
 
  cout << res << endl;
  
}

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

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};

// 二分探索
// llrep(i,N){
//     b = B[i];
//     auto cntA = lower_bound(A.begin(), A.end(), b);//イテレータなのでそのままllに変換とかはできない
//     auto cntC = upper_bound(C.begin(), C.end(), b);
//     ll cntA_ll = distance(A.begin(), cntA);
//     ll cntC_ll = C.size() - distance(C.begin(), cntC);
//     cnt += (cntA_ll * cntC_ll);
// }


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

    int cnt=0;
    if (S.size()==2){
        if (S[0]==S[1]) cout << "1 2" << endl;
        else cout << "-1 -1" << endl;
        return 0;
    }
    rep(i,S.size()-2){
        cnt=0;
        if (S[i]==S[i+1]) cnt++;
        if (S[i]==S[i+2]) cnt++;
        if (S[i+1]==S[i+2]) cnt++;
        if(cnt>=1){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;


    return 0;
}


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

int main() {
	int N,L;
	cin >> N>>L;
	string S[110],sum;
	for (int i = 0; i < N; i++)cin >> S[i];
	sort(S, S + N);

	for (int i = 0; i < N; i++) sum += S[i];
	cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static int n[][] = {{1,1},{0,1},{-1,1},{1,0},{-1,0},{0,-1}};
	public static void main(String[] args) {
			Scanner scan =  new Scanner(System.in);
			int n = scan.nextInt();
			int m = scan.nextInt();
			System.out.println(n*m);
	}
}


Measured memory_bytes: 27004
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];
int main(){
    ll r, d, x;
    cin >> r >> d >> x;
    rep(i, 10){
        x= r*x-d;
        cout << x << endl;;
    }
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	ll sum = 0;
	ll mn = INF;
	int c = 0;
	rep(i,n) {
		ll a = v[i];
		mn = min(mn, abs(a));
		sum += abs(a);
		if (a < 0) c++;
	}
	if (c % 2 == 0) {
		cout << sum << endl;
	} else {
		cout << sum - 2 * mn << endl;
	}
}

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

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

int main() {
	int n; cin >> n;
	vector<bool> v(1000000000, false);
	int a;
	rep(i, n) {
		cin >> a;
		a--;
		if (v[a]) {
			cout << "NO" << endl;
			return 0;
		}
		else {
			v[a] = true;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 122368
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  const double  pi=3.1415926535; 
  struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//cout<<pow(2,12)<<endl;
	ll n,m,k;cin>>n>>m>>k;
	vector<string> v(n);
	ll i,j;
	for(i=0;i<n;i++){
		cin>>v[i];
		//cout<<v[i]<<endl;
	}
	ll n1=1<<n,m1=1<<m;
	ll ans=0;
	for(i=0;i<n1;i++){
		for(j=0;j<m1;j++){
			vector<string> s1=v;
			for(ll i1=0;i1<n;i1++){
				if((i>>i1)&1)
					for(ll j1=0;j1<m;j1++)
						s1[i1][j1]='?';
			}
			for(ll i1=0;i1<m;i1++){
				if((j>>i1)&1)
					for(ll j1=0;j1<n;j1++)
						s1[j1][i1]='?';

			}
			ll cc=0;
			for(ll i1=0;i1<n;i1++){
				
					for(ll j1=0;j1<m;j1++)
						if(s1[i1][j1]=='#')
							cc++;

			}
			if(cc==k)
				ans++;

		}
	}
	cout<<ans;

	return 0;
} 

Measured memory_bytes: 3664
n, m = map(int, input().split())
a = [0] * (n+1) #その問題で既に AC が出たか
b = [0] * (n+1) #その問題で WA が出た回数

WA = 0

for i in range(m):

    s = input().split()

    if a[int(s[0])] == 0:
        if s[1] == "AC":
            a[int(s[0])] = 1
            WA += b[int(s[0])]
        else:
            b[int(s[0])] += 1

print(sum(a), WA)


Measured memory_bytes: 4596
#include<iostream>
using namespace std;
int main(){
    int numC=0;
    int place;
    int judge = 1;
    string str;
    cin >> str;
    if(str[0] != 'A'){
        judge = 0;
    }else{
        str[0] = 'a';
    }
    for(int i = 0;i<str.size();i++){
        if(str[i]=='C'){
            if(i<2||i>=str.size()-1){
                judge = 0;
                break;
            }
            numC++;
            str[i] = 'c';
        }
        if(isupper(str[i])) { // cが大文字のとき
            judge = 0;
            break;
        }
    }
    if(numC!=1){
        judge = 0;
    }
    if(judge == 0){
        cout << "WA"<< endl;
    }else{
        cout << "AC"<< endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
def resolve():
    from collections import defaultdict
    N = int(input())
    A = [int(input()) for _ in range(N)]
    c = defaultdict(int)
    for a in A:
        c[a] += 1
    ans = 0
    for v in c.values():
        if v % 2 == 1:
            ans += 1
    print(ans)


resolve()


Measured memory_bytes: 16640
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;

int main(void){
	scanf("%d%d",&n,&m);
	if((n+m)%2==0){
		if(n!=m){
			printf("0\n");
		}else{
			ll res=1;
			for(ll i=1;i<=n;i++){
				res=res*i%MOD;
			}
			for(ll i=1;i<=n;i++){
				res=res*i%MOD;
			}
			res=res*2LL%MOD;
			printf("%lld\n",res);
		}
	}else{
		if(abs(n-m)==1){
			ll res=1;
			for(ll i=1;i<=n;i++){
				res=res*i%MOD;
			}
			for(ll i=1;i<=m;i++){
				res=res*i%MOD;
			}
			printf("%lld\n",res);
		}else{
			printf("0\n");
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n = 0, sto[3050];
int fir[3050], nxt[6050], to[6050];
bool win[3050], ans[6050];
bool dfs(int x, int fa)
{
	win[x] = false;
	for(int i = fir[x]; i; i = nxt[i])
	{
		int t = to[i];
		if(t == fa) continue;
		if(not dfs(t, x) and sto[x] > sto[t])
			win[x] = true;
	}
	return win[x];
}
signed main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &sto[i]);
	for(int i = 1, j = 0; i < n; i++)
	{
		int a = 0, b = 0;
		scanf("%d%d", &a, &b);
		j++, nxt[j] = fir[a], fir[a] = j, to[j] = b;
		j++, nxt[j] = fir[b], fir[b] = j, to[j] = a;
	}
	for(int i = 1; i <= n; i++)
		ans[i] = dfs(i, 0);
	for(int i = 1; i <= n; i++)
		if(ans[i]) printf("%d ", i);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  long long ans=0;
  for(int bit=0;bit < (1 << s.size()-1);++bit){
    int ind=0;
    for(int i=0;i<s.size();++i){
      if(bit & (1 << i)){
        ans+=stoll(s.substr(ind,i-ind+1));
        ind = i+1;
      }
      if(i == s.size()-1){
	       ans += stoll(s.substr(ind, s.size() - ind));
      }
      //cout << ans << endl;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = (n) - 1; i >= 0; i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define sz(x) ((long long)x.size())
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
 
auto clk=clock();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll INF = 1e18L+5;
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
 
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<int> vint;
typedef vector<string> vs;
typedef vector<vi> vvi;

const int N_MAX = 2005;
ll dp[N_MAX][N_MAX];

ll combi(ll n, ll r){
    if(r==0||r==n)
        return 1;
    if(dp[n][r]!=-1)
        return dp[n][r];
    ll a = combi(n-1,r-1);
    ll b = combi(n-1,r);
    dp[n][r] = (a+b)%MOD;
    return dp[n][r];
}

ll modexp(ll base,ll power){
    if(base==0)
        return 0ll;
    if(power==0)
        return 1ll;
    ll res=1;
    while(power){
        if(power&1)
            res = (res*base)%MOD;
        base = (base*base)%MOD;
        power /= 2;
    }
    return res;    
}
 
void solve(){
    int x;
    cin>>x;
    int ans = x^1;
    cout<<ans;
}
    
 
int main () 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(11);
    memset(dp,-1,sizeof(dp));
    ll t = 1;
    // cin>>t;
    while(t--)
        solve();
 
    // cout<<endl<<endl<<"Time elapsed: "<<((double)(clock()-clk)/CLOCKS_PER_SEC)*1000<<"ms"<<endl;
    return 0;
}

Measured memory_bytes: 35048
// 2011/08/09 Tazoe

#include<iostream>
using namespace std;

bool DFS(int brd[102][102], int x, int y, int xg, int yg, int c)
{
	if(brd[y][x]!=c)
		return false;

	if(x==xg&&y==yg)
		return true;

	brd[y][x] = 9;		// ツつキツづづ可訪ツづェツつス

	if(DFS(brd, x+1, y, xg, yg, c))
		return true;
	if(DFS(brd, x, y+1, xg, yg, c))
		return true;
	if(DFS(brd, x-1, y, xg, yg, c))
		return true;
	if(DFS(brd, x, y-1, xg, yg, c))
		return true;

	return false;
}

int main()
{
	while(true){
		int w, h;
		cin >> w >> h;
		if(w==0&&h==0)
			break;

		int brd[102][102];
		for(int y=0; y<=h+1; y++)
			for(int x=0; x<=w+1; x++)
				brd[y][x] = 0;

		int xs, ys, xg, yg;
		cin >> xs >> ys;
		cin >> xg >> yg;

		int n;
		cin >> n;

		for(int i=0; i<n; i++){
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			brd[y  ][x  ] = c;
			brd[y  ][x+1] = c;
			brd[y+1][x  ] = c;
			brd[y+1][x+1] = c;
			if(d==0){
				brd[y  ][x+2] = c;
				brd[y  ][x+3] = c;
				brd[y+1][x+2] = c;
				brd[y+1][x+3] = c;
			}
			else{
				brd[y+2][x  ] = c;
				brd[y+2][x+1] = c;
				brd[y+3][x  ] = c;
				brd[y+3][x+1] = c;
			}
		}

		if(brd[ys][xs]==0||brd[yg][xg]==0||brd[ys][xs]!=brd[yg][xg]){
			cout << "NG" << endl;
			continue;
		}

		if(DFS(brd, xs, ys, xg, yg, brd[ys][xs]))
			cout << "OK" << endl;
		else
			cout << "NG" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdio>
#include <algorithm>
using namespace std;
int arr[101];

int main() {
    int sw, N;
    for (; ;) {
        scanf("%d", &N);
        if (N == 0) break;
        for (int i = 0; i < N; i++) scanf("%d", &arr[i]);
        bool flag = true; sw = 0;
        for (int i = 0; flag; i++) {
            flag = false;
            for (int j = N-1; j >= i+1; j--) {
                if (arr[j] < arr[j-1]) {
                    swap(arr[j], arr[j-1]);
                    sw++;
                    flag = true;
                }
            }
        }
        std::printf("%d\n", sw);
    }
    return 0;
}


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

#define Bye return 0
#define ll long long
const int MAX = 1e9+7;
const int SIZE = 1e5+1;

void solve(){
    int n; cin>>n;
    
    int a[n+1];
    memset(a, 0, sizeof a);
    bool no_solution = false; 
    for (int i=1; i<=n; i++){
        int e; cin>>e; a[e]++;
    }

    int counter = (n%2 == 0) ? n/2 : (n-1)/2;

    int res = 1;
    for (int i=1; i<=counter; i++)
        res = (res*2)%MAX;

    if(n%2 == 0){
        for (int i=1; i<=n-1; i+=2)
            if(a[i]^2) {res = 0; break;}
    } else 
        for (int i=2; i<n; i+=2)
            if(a[i]^2) {res = 0; break;}
    
    cout<<res<<endl;
}

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

Measured memory_bytes: 3996
ss = list(input())
n = len(ss)

def main(ss, n):
	ans = []
	ss.append('R')
	r = -1
	l = -1
	ln = 0

	for i in range(n):
		ln += 1
		if ss[i] == 'R' and ss[i + 1] == 'L':
			r = ln - 1
			l = ln
		if ss[i] == 'L' and ss[i + 1] == 'R':
			ans.extend([0 for _ in range(r)])
			if r % 2 == 1:
				ans.extend([ln // 2, (ln + 1) // 2])
			else:
				ans.extend([(ln + 1) // 2, ln // 2])
			ans.extend([0 for _ in range(ln - l - 1)])
			ln = 0

	return ans

print(" ".join([str(i) for i in main(ss, n)]))

Measured memory_bytes: 11288
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<int,pi>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2,
 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    go;

int k;
cin>>k;
cout<<a[k];
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int r,g;
	cin >> r;
	cin >> g;
	cout << 2*g-r << endl;

	return 0;
}

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

typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int K=1e5+5;
int a[K];

int main()
{
	//freopen("1.in","r",stdin);
	int k;
	cin>>k;
	rep(i,1,k)scanf("%d",a+i);
	ll l=2,r=2;
	per(i,k,1)
	{
		l=((l-1)/a[i]+1)*a[i];
		r=(r/a[i])*a[i]+a[i]-1;
	}
	if(l>r)puts("-1");
	else printf("%lld %lld\n",l,r);
}


Measured memory_bytes: 768
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long A = 1;
    long B = N;
    
    for (long i = 1;i<=Math.sqrt(N);i++) {
      if(N%i==0) { 
       A = i;
       B = N/i;
        if(A>=B){
          break;
        }
       }
      }
   
     System.out.println(A+B-2);
    
    }
  }

Measured memory_bytes: 25172
//FIRST THINK THEN CODE.

  #include <bits/stdc++.h>


  using namespace std;

  typedef long long ll;

  #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 vld vector<ld>
  #define vvi vector<vector<int>>
  #define vvl vector<vector<long long>>
  #define vvld vector<vector<ld>>
  #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 pf push_front
  #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 rev(p) reverse(p.begin(),p.end());
  #define endl "\n"
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define popcount(x) __builtin_popcountll(x)
  #define sz(x) ((ll)x.size())
  const ll M=1000000007;
  const ll MM=998244353;
  ll begtime = clock();
  #define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
  //#define _Find_next 
  //#define _Find_first 



  ll newmod(ll a,ll b)
  {
  return ((a%b)+b)%b;
  }


  ll powM(ll a,ll b,ll m )
  { 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  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;
  }

string tostring(ll x){
  stringstream sss;
  sss<<x;
  string ans=sss.str();
  return ans;
}


  const ll N=1e6+5;


//ll val[3005][3005][5];
ll dp[3005][3005][5];
  int main()
  { 

    IOS;

ll r,c;
cin>>r>>c;
ll k;
cin>>k;

vvl val(r+1,vl(c+1));

while(k--){
  ll r1,c1,v;
  cin>>r1>>c1>>v;
  val[r1][c1]=v;
}

for(ll i=1;i<=r;i++){
  for(ll j=1;j<=c;j++){
    if(!val[i][j]){
      for(ll p=0;p<=3;p++){
        chmax(dp[i][j][0],dp[i-1][j][p]);
         chmax(dp[i][j][p],dp[i][j-1][p]);   
      }
    }else{
      for(ll p=0;p<=3;p++){
        chmax(dp[i][j][0],dp[i-1][j][p]);
        chmax(dp[i][j][p],dp[i][j-1][p]);
        chmax(dp[i][j][1],dp[i-1][j][p]+val[i][j]);
        if(p)chmax(dp[i][j][p],dp[i][j-1][p-1]+val[i][j]);  
      }
    }
  }
}

ll ans=0;

FOR(i,4){
  chmax(ans,dp[r][c][i]);
}



cout<<ans<<endl;




  return 0;

  }

Measured memory_bytes: 425828
import sys
input = sys.stdin.readline

N=int(input())
E=[[] for i in range(N+1)]

for i in range(N-1):
    a,b=map(int,input().split())
    E[a].append(b)
    E[b].append(a)

mod=10**9+7

FACT=[1]
for i in range(1,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0

Q=[1]
SORTED=[1]
USE=[0]*(N+1)
USE[1]=1
P=[-1]*(N+1)

while Q:
    x=Q.pop()

    for to in E[x]:
        if USE[to]==0:
            USE[to]=1
            SORTED.append(to)
            Q.append(to)
            P[to]=x

FROM1=[-1]*(N+1)
FROM2=[-1]*(N+1)

for x in SORTED[::-1]:
    if len(E[x])==1 and x!=1:
        FROM1[x]=1
        FROM2[x]=1
    else:
        L=[]
        SUML=0
        A=1
        for to in E[x]:
            if to==P[x]:
                continue
            L.append(FROM1[to])
            SUML+=FROM1[to]
            A=A*FROM2[to]%mod
        #print(x,L)
        FROM1[x]=SUML+1
        S=SUML

        for l in L:
            A=A*Combi(S,l)%mod
            S-=l
        FROM2[x]=A

TO1=[-1]*(N+1)
TO2=[-1]*(N+1)
TO2[1]=1

for x in SORTED:
    if x!=1 and len(E[x])==1:
        continue
    
    SS=1
    L=[]
    SUML=0
    for to in E[x]:
        if to==P[x]:
            continue
        
        SS=SS*FROM2[to]%mod
        L.append(FROM1[to])
        SUML+=FROM1[to]

    L.append(N-1-SUML)
    SUML+=N-1-SUML
    A=1
    S=SUML
    for l in L:
        A=A*Combi(S,l)%mod
        S-=l

    for to in E[x]:
        if to==P[x]:
            continue
        
        B=A*SS*pow(FROM2[to],mod-2,mod)*TO2[x]%mod

        TO2[to]=B*pow(Combi(SUML,FROM1[to]),mod-2,mod)%mod

for i in range(1,N+1):
    ANS=TO2[i]

    L=[]
    SUML=0

    for to in E[i]:
        if to==P[i]:
            continue
        ANS=ANS*FROM2[to]%mod
        L.append(FROM1[to])
        SUML+=FROM1[to]

    L.append(N-1-SUML)
    SUML+=N-1-SUML
    S=SUML
    for l in L:
        ANS=ANS*Combi(S,l)%mod
        S-=l
    print(ANS%mod)

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

using namespace std;

int main()
{
    vector<int> x(5, 0);

    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

    for(int i = 0; i < 5; ++i)    
    {
        if(x[i] == 0)
        {
            cout << (i+1) << endl;
        }
    }

    return 0;    
}

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

ll cntDiv[10000005];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int ni = i;
    while (ni <= n) {
      cntDiv[ni]++;
      ni += i;
    }
  }
  ll ans = 0;
  for (ll i = 1; i <= n; ++i) {
    ans += i*cntDiv[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81760
N=int(input())
A=list(map(int,input().split()))

X0=0

for i in range(N):
  if i%2==0:
    X0+=A[i]
  else:
    X0-=A[i]

ans=[X0]

for i in A:
  ans.append((i-ans[-1]//2)*2)
print(*ans[:-1])

Measured memory_bytes: 20684
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include <utility>
#include <functional>
#include <tuple>
#include<map>
#define T long long
T pow5(T n){
	return n*n*n*n*n;
}

int main(){
	int n;
	std::cin >> n;
	std::vector<int> a;
	a.resize(n);
	for(int i=0;i<n;i++){
		int ai;
		std::cin >> ai;
		a[i]=ai;
	}
	std::map<int,int> table;
	for(int i=0;i<n;i++){
		table[i+a[i]]++;
	}
	T result =0;
	for(int i=n-1;i>0;i--){
		result += table[i-a[i]];
	}
	std::cout << result << std::endl;
}


Measured memory_bytes: 21052
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;//10^18
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll ok[123456];
signed main() {
    ll n, a, b, ans = 0; cin >> n;
    map<ll, map<ll, ll>> m;
    vector<vector<ll> > G(123456);
    vector<ll> aa(n), bb(n);
    for (int h = 1; h < n; h++) {
        cin >> a >> b; aa[h] = a; bb[h] = b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<ll> que, mae, iro;
    for (ll i = 0; i < G[1].size(); i++) {
        que.push(G[1][i]); mae.push(1); iro.push(i + 1); ans = max(ans, i + 1);
        m[1][G[1][i]] = i + 1; m[G[1][i]][1] = i + 1;
    }
    while (que.size()) {
        ll iro9 = 1;
        for (int i = 0; i < G[que.front()].size(); i++) {
            if (G[que.front()][i] != mae.front()) {
                que.push(G[que.front()][i]); mae.push(que.front());
                if (iro9 == iro.front()) { iro9++; }
                iro.push(iro9);
                m[que.front()][G[que.front()][i]] = iro9;
                m[G[que.front()][i]][que.front()] = iro9;
                ans = max(ans, iro9); iro9++;
            }
        }
        que.pop(); mae.pop(); iro.pop();
    }
    cout << ans << endl;
    for (int h = 1; h < n; h++) {
        cout << m[aa[h]][bb[h]] << endl;
    }
	return 0;
}

Measured memory_bytes: 30592
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, Q = map(int, readline().split())

# 1～Mまでの数を複数回用いて、長さNの要素の部分列返す
#（combinations：複数使用なし、combinations_with_replacement：複数使用あり）
A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))

n = len(A) # 組合せ総数
score = np.zeros(n, np.int32) # [0,0,...,0] :0が n個のaraay

m = map(int, read().split())
for a, b, c, d in zip(m, m, m, m):
    cond = A[:, b - 1] - A[:, a - 1] == c
    score += d * cond

print(score.max())

Measured memory_bytes: 46648