akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        List<Integer> list = new ArrayList<Integer>(); 
        for(int i=1; i<=N; i++) {
            list.add(sc.nextInt());
        }
        
        Boolean flag = true;
        Boolean minus = false;
        int onceDesc = -1;
        int left = list.get(0);
        int max = 0;
        for(int i=1; i <N; i++) {
            
            if(list.get(i) > max) {
                max = list.get(i); 
            }
            if(max - list.get(i) > 1) {
                flag = false;
                break;
            }
            if( list.get(i) >= left) {
//                System.out.println(list.get(i));
                left = list.get(i);
            }
            if(list.get(i) < left) {
//                System.out.println("i:"+list.get(i));
//                System.out.println("left:"+left);
                if(left - list.get(i) > 1) {
                    flag = false;
                    break;
                }
                if(left - list.get(i) ==1) {

                    left -= 1;

//                        System.out.println("true");
//                        System.out.println("i:"+list.get(i));
//                        System.out.println("left:"+left);
                    
                }
            }
            
        }
        
        System.out.println(flag? "Yes":"No");
        
    }
}

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

#define pb push_back
#define mp make_pair
#define sqr(a) ((a) * (a)) 
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define co() cout.precision(10); 
#define F for(li i=0;i<n;i++)

typedef long long li;
typedef long double ld;

const li mod = 1000000007;
 
 
li mul(li a,li b) {
    return (1LL * a * b) % mod;
}
 
li add(li a,li b) {
    li s = (a+b);
    if (s>=mod) s-=mod;
    return s;
}
 
li sub(li a,li b) {
    li s = (a+mod-b);
    if (s>=mod) s-=mod;
    return s;
}
 
li po(li a,li deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    li t = po(a, deg/2);
    return mul(t, t);
}
 
li inv(li n)
{
    return po(n,mod-2);
}

int main()
{
    io();
    int t,cs=1;
    string s,st;
    cin>>s>>st;
    for(li i=0;i<s.length();i++)
    {
        if(s[i]!=st[i])
        {
            cout<<"No";
            return 0;
        }
    }
    if(st.length()-1==s.length())
    {
        if(st[st.length()-1]>=97 && st[st.length()-1]<=122)
        cout<<"Yes";
        else
        cout<<"No";
    }
    else
    cout<<"No";
}
/*
      ███        ▄▄▄▄███▄▄▄▄   
▀█████████▄  ▄██▀▀▀███▀▀▀██▄ 
   ▀███▀▀██  ███   ███   ███ 
    ███   ▀  ███   ███   ███ 
    ███      ███   ███   ███ 
    ███      ███   ███   ███ 
    ███      ███   ███   ███ 
   ▄████▀     ▀█   ███   █▀  
   
   
   
   
 */

Measured memory_bytes: 3616
def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = [[(j, i), (-1, -1)] for i, j in enumerate(a)]
    ans = 0
    for i in range(1, 2**n):
        (t1, t2), (t3, t4) = d[i]
        for j in range(n):
            (t5, t6), (t7, t8) = d[i & ~(1 << j)]
            if t6 not in [t2, t4]:
                if t5 > t1:
                    t1, t2, t3, t4 = t5, t6, t1, t2
                elif t5 > t3:
                    t3, t4 = t5, t6
            if t8 not in [t2, t4]:
                if t7 > t3:
                    t3, t4 = t7, t8
        d[i] = [(t1, t2), (t3, t4)]
        ans = max(ans, t1+t3)
        print(ans)


main()

Measured memory_bytes: 131020
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
long long int n=0,k=0;
string s;
int main(){
  cin >> n >> k >> s;
  s[k-1] = s[k-1]-('A'-'a');
  cout << s << endl;
}


Measured memory_bytes: 256
// D - Five, Five Everywhere
#include <bits/stdc++.h>
using namespace std;

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

int main(){
	int N; cin>>N;
	for(int n=0,p=11; p<=55555 && n<N; p+=10)
		if(isprime(p) && p%5==1){ cout<<p<<" "; n++; }
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
)
 
func main() {
	var n int
	fmt.Scan(&n)
	sum := 0
	x := n
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	if x%sum == 0 {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

Measured memory_bytes: 512
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
broken = []
for i in range(0, M):
  broken.append(int(input()))

memo = [1]
cnt = 1
while cnt <= N:
  if len(broken) > 0 and cnt == broken[0]:
    del broken[0]
    memo.append(0)
  elif cnt == 1:
    memo.append(1)
  else:
    memo.append((memo[-1] + memo[-2])%MOD)
  cnt += 1
  
print(memo[-1])

Measured memory_bytes: 7080
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

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

		int haveNum = scan.nextInt();
		int selectNum = scan.nextInt();
		int answer = 0;

		ArrayList<Integer> list = new ArrayList<Integer>();

		for(int i = 0; i < haveNum; i++) {
			list.add(scan.nextInt());
		}

		Collections.sort(list, Comparator.reverseOrder());

		for(int i = 0; i < selectNum; i++) {
			answer += list.get(i);
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define int long long
#define endl '\n'

const int N = 100005;
int n, k;
string s;
int a[N];
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	cin >> s;
	if(n == 1) cout << 0;
	else if(n == 2) cout << 1;
	else{
		char prev = 'X';
		vector<int> v;
		for(char c: s) 
			if(c != prev){
				prev = c;
				v.push_back((c == 'L'));
			}
		int proc = (v.size() % 2 == 0 ? (v.size()/2) - 1: (v.size()/2));
		int ans = 0;
		for(int i = 1 ; i < s.size() ; i ++)
			if(s[i] == s[i - 1]) ans ++;
		if(proc < k) cout << min(n - 1, ans + proc*2 + (k - proc));
		else cout << min(n - 1, ans + k*2);
	}
}


Measured memory_bytes: 1480
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main () {
	int n;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++)
	{
	for(int j=0;j<3;j++)
	{
			cin>>a[i][j];
	}
	}
	int dp[n][3]={-1};
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(j!=k)
				{
					dp[i][j]=max(dp[i][j],a[i][j]+dp[i-1][k]);
				}
			}
		}
	}
	int ans=INT_MIN;
	for(int i=0;i<3;i++)
	{
		ans=max(ans,dp[n-1][i]);
	}
	cout<<ans;
}
	


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

int main(void) {
    string s;
    cin >> s;
    if (s.length() == 2) {
        cout << s << endl;
    } else {
        for (int i = 2; i >= 0; --i) {
            cout << s[i];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, p;
    cin >> n >> p;
    map<ll, int> fs;
    for(int i = 2; i <= sqrt(p); i++){
        while(p % i == 0){
            fs[i]++;
            p /= i;
        }
    }
    if(p > 1){
        fs[p]++;
    }

    ll ans = 1;
    for(auto& p : fs){
        ans *= pow(p.first, p.second / n);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 1<<18;
const int MAX_L = 1<<17;

vector<int> V(MAX_V, 0), W(MAX_V, 0);
int dp[1<<9][MAX_L];

void dfs(int i){
    rep(j, MAX_L){
        dp[i][j] = dp[i/2][j];
        if(j >= W[i]) chmax(dp[i][j], dp[i/2][j-W[i]]+V[i]);
    }
}

int query(int j, int L){
    vector<pii> check;
    check.pb(pii(0, 0));
    while(j >= (1<<9)){
        int n = sz(check);
        rep(i, n){
            pii p = pii(check[i].first+W[j], check[i].second+V[j]);
            check.pb(p);
        }
        j >>= 1;
    }
    int ret = 0;
    for(auto &e: check){
        if(L < e.first) continue;
        chmax(ret, dp[j][L-e.first]+e.second);
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    rep2(i, 1, N) cin >> V[i] >> W[i];
    fill(dp[0], dp[0]+(1<<9), 0);
    rep(i, 1<<9) dfs(i);
    int Q;
    cin >> Q;
    rep(i, Q){
        int j, L;
        cin >> j >> L;
        cout << query(j, L) << endl;
    }
}

Measured memory_bytes: 267500
#include <iostream>

using namespace std;

int main() {
    int64_t N, x;
    cin >> N >> x;
    int64_t ans = N;

    N = N-x;

    int d = 0;
    while (x >= 1LL) {
        ans += 2*x*(N/x);
        int64_t t = N;

        if ((N%x == 0)) ans -=x ;

        N = x;
        x = t % x;
        d = 1-d;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  float N;
  cin>>N;
  vector<float> v(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  float result;
  for(int i=0;i<N;i++){
    if(i==0){
      result=v[i];
    }else{
      result=(result+v[i])/2;
    }
  }
  cout<<result;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll r;cin>>r;
  lfs<<2*r*acos(-1)<<endl;
  return 0;
}

Measured memory_bytes: 3772
/**"I am not an authorized coder"**/
#include <bits/stdc++.h>
#define FOR(i, s, e)    for(int i=s; i<e; i++)
#define loop(i, n)      FOR(i, 0, n)
#define sf              scanf
#define pf              printf
#define pb              push_back
#define MP              make_pair
#define fr              first
#define sc              second
#define lli             long long
#define dd              double
#define all(v)          v.begin(), v.end()
#define PI              2*acos(0.0)
#define mem(ara, value) memset(ara, value, sizeof(ara))
#define paii            pair<int, int>
#define pall            pair<ll, ll>
#define SZ(a)           int(a.size())
#define open()          freopen("input.txt", "r", stdin)
#define show()          freopen("output.txt", "w", stdout)
#define read(a)         scanf("%d",&a)
#define read2(a,b)      scanf("%d%d",&a,&b)
#define read3(a,b,c)    scanf("%d%d%d",&a,&b,&c)
#define read4(a,b,c,d)  scanf("%d%d%d%d",&a,&b,&c,&d)
#define readI1(a)       scanf("%lld",&a)
#define readI2(a,b)     scanf("%lld %lld",&a,&b)
#define readI3(a,b,c)   scanf("%lld %lld %lld",&a,&b,&c)
#define readI4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define BOUNDARY(i, j)  ((i >= 0 && i < w) && (j >= 0 && j < h))
#define Mx 100009
#define EPS 1e-10
#define sq(x) ((x)*(x))
#define sq_dist(a,b)    (sqrt(sq(a.x-b.x)+sq(a.y-b.y)));
#define cross(o,a,b)    ((a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x))
using namespace std;
struct point
{
	int x,y;
};
struct Line
{
	double a,b,c;
};
void pointTOline(point p1,point p2,Line &l)
{
	if(fabs(p1.x-p2.x)<EPS)
	{
		l.a=1.0; l.b=0.0; l.c=-p1.x;
	}
	else{
		l.a=-(double)(p1.y-p2.y)/(p1.x-p2.x);
		l.b= 1.0;
		l.c = -(double) (l.a*p1.x)-p1.y;
	}
}
int  main()
{
	point p1,p2,p;
	read4(p1.x,p1.y,p2.x,p2.y);
	int n;
	read(n);

	Line l;

	pointTOline(p1,p2,l);

	for(int i=0;i<n;i++)
	{
		read2(p.x,p.y);
		double d=l.b,e=-l.a;
		double f=-d*p.x - e*p.y;
		double nx= (l.b*f-l.c*e)/(l.a*e-l.b*d);
		double ny = (l.c*d-l.a*f)/(l.a*e-l.b*d);

		double px = nx+(nx-p.x);
		double py = ny+(ny-p.y);
		if(px==-0.000000000) {px=fabs(px);}
		if(py==-0.000000000) py=fabs(py);
		printf("%.9f %.9f\n",px,py);

	}
}

Measured memory_bytes: 3204
open System

[<EntryPoint>]
let main _ =
    let line = Console.ReadLine().Split()
    let answer =
        if line.[1] = "+" then
            Int32.Parse line.[0] + Int32.Parse line.[2]
        else
            Int32.Parse line.[0] - Int32.Parse line.[2]

    printfn "%d" answer
    0


Measured memory_bytes: 13916
n = int(input())
h = [int(num) for num in input().split()]
a = h[0]
ans = 'Yes'
for i in range(1,n):
    if h[i] >= a:
        a = h[i]
    elif h[i] < a-1:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 63984
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        int max = 0;
        int cnt = 0;

        for(int i=0; i<N; i++){
            int tmp = scanner.nextInt();

            if(max < tmp){
                cnt += tmp - max;
                max = tmp;
            }

            if(tmp < max){
                max = tmp;
            }
        }

        System.out.println(cnt);

    }
}


Measured memory_bytes: 23380
#include <stdio.h>

int a, b, c, k;

int main(){
    scanf("%d %d %d", &a, &b, &c);
    scanf("%d", &k);
    if(a > b && a > c){
        for(int i=0; i<k; i++)
            a*=2;
    } else if( b > a && b > c){
        for(int i=0; i<k; i++)
            b*=2;
    } else {
        for(int i=0; i<k; i++)
            c*=2;
    }
    printf("%d\n", a+b+c);

}



Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


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

    vector<string> a;
    for(int i = 0; i < h; i++){
        string tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    vector<int> delindexH;

    for(int i = 0; i < h; i++){
        bool candel = true;
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#'){
                candel = false;
                break;
            }
        }
        if(candel){
            // cout << i << endl;
           delindexH.push_back(i);
        }
    }

    vector<int> delindexW;

    for(int i = 0; i < w; i++){
        bool candel = true;
        for(int j = 0; j < h; j++){
            if(a[j][i] == '#'){
                candel = false;
                break;
            }
        }
        if(candel){
            // cout << i << endl;
            delindexW.push_back(i);
        }
    }

   

    for(int i = 0; i < h; i++){
        bool okH = true;
        bool showed = false;
        for(int j = 0; j < delindexH.size(); j++){
            if(i == delindexH[j]){
                okH = false;
                break;
            }
        }

        for(int j = 0; j < w; j++){
            bool okW = true;
            for(int k = 0; k < delindexW.size(); k++){
                
                if(j == delindexW[k]){
                    okW = false;
                    break;
                }
            }

            if(okH && okW){
                cout << a[i][j];
                showed = true;
            }
        }

        if(showed)cout << endl;

    }



}



Measured memory_bytes: 384
S = input()
T = input()
N = len(S)
M = len(T)
Ss = [0]*(N+1)
Ts = [0]*(M+1)
for i in range(N):
  if S[i] == "A":
    temp = 1
  else:
    temp = -1
  Ss[i+1] = Ss[i] + temp
for i in range(M):
  if T[i] == "A":
    temp = 1
  else:
    temp = -1
  Ts[i+1] = Ts[i] + temp
Q = int(input())
for i in range(Q):
  a, b, c, d = (int(i) for i in input().split())
  if (Ss[b] - Ss[a-1] - Ts[d] + Ts[c-1])%3==0:
    print("YES")
  else:
    print("NO")
      

Measured memory_bytes: 11540
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


K = I()
A = LI()
A.reverse()

m,M = 2,2  # 最小値、最大値
for i in range(K):
    a = A[i]
    if (m+(a-1))//a > M//a:
        print(-1)
        exit()
    else:
        m = a*((m+(a-1))//a)
        M = a*(M//a)+(a-1)

print(m,M)


Measured memory_bytes: 85696
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int ballNumber = sc.nextInt();
		int color = sc.nextInt();
		int paint = 1;

		for (int i = 0; i < ballNumber; i++) {
			if (ballNumber == 1) {
				paint = color;
				break;
			}
			if (i == 0) {
				paint *= color;
			} else {
				paint *= (color -1);
			}
		}
		System.out.println(paint);
		sc.close();
	}
}


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] bill1 = new int[3, 10];
            int[,] bill2 = new int[3, 10];
            int[,] bill3 = new int[3, 10];
            int[,] bill4 = new int[3, 10];

           string s = Console.ReadLine();
           int inputnum = int.Parse(s);

           for (int i = 0; i < inputnum; i++) 
           {
               string[] ss = Console.ReadLine().Split(' ');
               int floor =int.Parse(ss[1]);
               int room = int.Parse(ss[2]);
               int n = int.Parse(ss[3]);

               switch(ss[0])
               {
                   case "1":
                       bill1[floor-1,room-1] += n;
                       break;

                   case "2":
                       bill2[floor-1,room-1] += n;
                       break;

                   case "3":
                       bill3[floor-1,room-1] += n;
                       break;

                   case "4":
                       
                       bill4[floor-1,room-1] += n;
                       break;
               }

           }

           for (int kai = 0; kai < 3; kai++)
           {
               for (int num = 0; num < 10; num++)
               {
                   Console.Write(" " + bill1[kai, num]);

               }
               Console.WriteLine();
           }
           Console.WriteLine("####################");

           for (int kai = 0; kai < 3; kai++)
           {
               for (int num = 0; num < 10; num++)
               {
                   Console.Write(" " + bill2[kai, num]);

               }
               Console.WriteLine();
           }
           Console.WriteLine("####################");
           for (int kai = 0; kai < 3; kai++)
           {
               for (int num = 0; num < 10; num++)
               {
                   Console.Write(" " + bill3[kai, num]);

               }
               Console.WriteLine();
           }
           Console.WriteLine("####################");
           for (int kai = 0; kai < 3; kai++)
           {
               for (int num = 0; num < 10; num++)
               {
                   Console.Write(" " + bill4[kai, num]);

               }
               Console.WriteLine();
           }
        
          
        }
    }
}

Measured memory_bytes: 5756
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i]=='L'){
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			if(s[i]=='R'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long int64;
static const int MAXN = 52;
static const int MAXA = 50 * 52;

int n, a, x_i;
int64 ways[MAXN][MAXA] = {{ 1, 0 }};

int main()
{
    scanf("%d%d", &n, &a);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &x_i);
        for (int j = i; j >= 0; --j)
            for (int k = MAXA - x_i; k >= 0; --k)
                ways[j + 1][k + x_i] += ways[j][k];
    }

    int64 ans = 0;
    for (int i = 1; i <= n; ++i) ans += ways[i][i * a];
    printf("%lld\n", ans);

    return 0;
}


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

typedef long long LL;

int main() {
  LL n;
  scanf("%lld", &n);
  for (LL i = 1; i <= 3500; i ++)
    for (LL j = i; j <= 3500; j ++) {
      LL down = n * i * j;
      LL up = i * j * 4 - n * i - n * j;
      if (up > 0 && down % up == 0) {
	printf("%lld %lld %lld\n", i, j, down / up);
	return 0;
      }
    }
}


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

using namespace std;

int main()
{
   int n,m;
   cin>>n>>m;
   vector<int> v(n),p(n);
   string s;
   int a;
   int k=0;
   int sum1=0;
   rep(i,m) 
   {  cin>>a;
      cin>>s;
      a--;
      if(v[a]) continue;
       if(s=="AC"){
         v[a]=1;
        }
       else {
           p[a]++;
       }
   }
   rep(i,n){
       k=k+v[i];
       if(v[i]) sum1=sum1+p[i];
   }
   cout<<k<<" "<<sum1<<endl;
   return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100
void solve(){
	int n, a, b;
	cin>>n>>a>>b;
	cout<< (n-a)%b<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
n=int(input())
S=[input() for _ in range(n)]
m=int(input())
T=[input() for _ in range(m)]
li=[]
for word in S:
  s=S.count(word)
  t=T.count(word)
  li.append(s-t)
if max(li) < 0:print(0)
else:print(max(li))  


Measured memory_bytes: 3060
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	int d = n / 2 - 1;
	if (n % 2 == 0)
	{
		rep(i, m)
		{
			if (i % 2 == 0)
			{
				cout << i / 2 + 1 << " " << (i + 1) / 2 + d + 1 << endl;
			}
			else
			{
				cout << n - (i + 1) / 2 << " " << n - ((i + 1) / 2 + d) << endl;
			}
			--d;
		}

	}
	else
	{
		int l = n / 2;
		int r = n / 2 + 1;
		rep(i, m)
		{
			cout << l << " " << r << endl;
			--l; ++r;
		}
	}
}

Measured memory_bytes: 3640
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	int n;cin>>n;
	
	ll maxv=0,ans=0;
	
	for(int i=0;i<n;i++)
	{
		int x;cin>>x;
		
		if(x>=maxv)maxv=x;
		else ans+=(maxv-x);
	}
	
	cout<<ans;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c =sc.nextInt();
		if(a%2==1 && b%2==1 && c%2==1)
		System.out.println(Math.min((long) a*b, Math.min((long) b*c, (long) a*c)));
		else
			System.out.println(0);
	}
}


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

using namespace std;

#define ll long long
#define pb() push_back()


void solve() {
    ll n, mx = 0;
    cin >> n;
    ll c = n - 1;
    ll a, sum = 0;
    cin >> a;
    mx = a;
    while(c--) {
        ll b;
        cin >> b;
        if (b < mx) {
            sum += mx - b;
        } else if (b > mx) {
            mx = b;
        }
    }
    cout << sum;
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;

int get(int n){
    vint v(n);
    rep(i,n)cin>>v[i];
    sort(v.rbegin(),v.rend());
    return accumulate(v.begin(),v.begin()+n-1,0);
}

signed main(){
    int a=get(4);
    int b=get(2);
    cout<<a+b<<endl;
    return 0;
}

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

#define scd second;
#define fst first;
#define mkp make_pair
#define pb push_back
#define pf push_front

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;

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

	string str;
	cin>>str;
	if(str[1]=='B') str[1]='R';
	else str[1]='B';
	cout<<str<<endl;
}

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

signed main() {
  int n,k,keta,x; cin>>n>>k;
  keta=1; x=k-1;
  while(x<n){
    x+=(x+1)*(k-1);
    keta++;
  }
  cout<<keta<<endl;
}

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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,a[200005];
bool check(int mid){
	map<int,int>mp;
	for(int i=1;i<=n;++i){
		if(a[i]<=a[i-1]){
			if(mid==1)return 0;
			while(mp.size()&&mp.rbegin()->fst>a[i]){
				map<int,int>::iterator it=mp.end();
				mp.erase(--it);
			}
			for(int j=a[i];j>=0;--j){
				if(!j)return 0;
				mp[j]++;
				if(mp[j]==mid)mp[j]=0;
				else break;
			}
		}
	}
	return 1;
}
int main() {
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	int l=1,r=n;while(l<r){
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	string s, ans;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		ans += s[i];
		if (s[i] == 'B') {
			ans.pop_back();
			if (!(ans.empty())) {
				ans.pop_back();
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  vector<ll> a(n),b(n);
  rep(i,n) cin >> a[i] >> b[i];
  if(a==b) {
    pr(0);
    return;
  }
  ll ans=MAX,sum=0;
  rep(i,n) {
    if(a[i]>b[i]) ans=min(ans,b[i]);
    sum+=a[i];
  }
  pr(sum-ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 640
s = input().split()
for j in range(len(s)):
  for k in range(j-1,-1,-1):
    if s[k] >= s[k+1]:
      s[k],s[k+1] = s[k+1],s[k]
if s[1] == s[0]:
  if s[2] == s[3]:
    print("yes")
  else:
    print("no")
else:
  print("no")


Measured memory_bytes: 5564
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	char c;
	cin >> c;
	if (c == 'A') {
		cout << 'T' << endl;
	}
	if (c == 'T') {
		cout << 'A' << endl;
	}
	if (c == 'C') {
		cout << 'G' << endl;
	}
	if (c == 'G') {
		cout << 'C' << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int a,b;
    cin >> a >> b;
    vector<int> v(a);
    REP(i,a){cin >> v[i];}
    sort(v.begin(), v.end());
    int result=0;
    a--;
    REP(i,b){
        result += v[a - i];
    }
    cout << result << endl;
    return 0;
}

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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int X;
	cin >> X;

	int ret = 0;
	int num = 0;
	int sum = 0;
	while (sum < X) {
		num++;
		sum += num;
	}

	cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	if(c=='-')f=-1,c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll k,phi;
ll qp(ll a,ll b,ll p){
	ll ans=1;
	while(b){
		if(b&1)ans=ans*a%p;
		a=a*a%p;
		b/=2;
	}
	return ans;
}
ll wws,ak;
int main(){
	k=d,ak=k;
	if(k%7==0)k/=7;
	if(k%2==0||k%5==0){
		cout<<-1;
		return 0;
	}
	if(k==1){
		cout<<1;
		return 0;
	}
	while(ak)ak/=10,wws++;
	ll kk=phi=k;
	for(int i=2;i*i<=k;i++)
		if(k%i==0){
			while(k%i==0)k/=i;
			phi=phi*(i-1)/i;
		}
	if(k!=1)phi=phi*(k-1)/k;
	ll cnt=0,now=0;
	while(1){
		cnt++;
		if(cnt<phi)now+=qp(10,cnt%phi,kk);
		else now+=qp(10,cnt%phi+phi,kk);
		if(now%kk==0&&cnt>=wws)break;
	}
	printf("%lld",cnt);
	return 0;
}


Measured memory_bytes: 3756
h,w = map(int,input().split())
s = [['.'] * (w+2)]
for i in range(h):
    li_tmp = ['.']
    s_tmp = list(input())
    li_tmp += s_tmp 
    li_tmp += ['.']
    s.append(li_tmp)
s.append(['.'] * (w+2))

for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == '#':
            if s[i-1][j] == '#' or s[i][j+1] == '#' or s[i+1][j] == '#' or s[i][j-1] == '#':
                pass
            else:
                print('No')
                quit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
#define FAST           ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007

ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
{
  ll ans=0;
  if(i>=n)
    return 0;

  if(dp[i][k]!=-1)
    return dp[i][k];


  if(k!=0)
  ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
  else
  ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

  return dp[i][k]=ans;

}

//ll t[400008];
// void build(vector<ll>& a, int v, int tl, int tr) {
//     if (tl == tr) {
//         t[v] = a[tl];
//     } else {
//         int tm = (tl + tr) / 2;
//         build(a, v*2, tl, tm);
//         build(a, v*2+1, tm+1, tr);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }

// ll maxi(int v, int tl, int tr, int l, int r) {
//     if (l > r) 
//         return 0;
//     if (l == tl && r == tr) {
//         return t[v];
//     }
//     int tm = (tl + tr) / 2;
//     return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
// }



// void update(int v, int tl, int tr, int pos, ll new_val) {
//     if (tl == tr) {
//         t[v] = new_val;
//     } else {
//         int tm = (tl + tr) / 2;
//         if (pos <= tm)
//             update(v*2, tl, tm, pos, new_val);
//         else
//             update(v*2+1, tm+1, tr, pos, new_val);
//         t[v] = max(t[v*2] ,t[v*2+1]);
//     }
// }


struct hash_pair {
   template <class T1, class T2>
   size_t operator()(const pair<T1, T2>& p) const{
      auto hash1 = hash<T1>{}(p.first);
      auto hash2 = hash<T2>{}(p.second);
      return hash1 ^ hash2;
   }
};

ll rec(ll a[],ll first,ll last,int n)
{
  if(first>last)
    return 0;

  ll temp=1000000000;
  ll ind=0;
  for(ll i=first;i<=last;i++)
   {
    if(temp>a[i])
    {
      temp=a[i];
      ind=i;
    }
   }
   for(ll i=first;i<=last;i++)
    a[i]-=temp;


return min(last-first+1,(rec(a,first,ind-1,n)+rec(a,ind+1,last,n)+temp));

}


void dfs(vector<vector<int> >& g,vector<bool>& visited,int& c,int i)
{
  visited[i]=true;
  c++;
  for(auto x:g[i])
  {
    if(visited[x]==false)
    {
      dfs(g,visited,c,x);
    }
  }
}

int main() { 
int n,m,x,y;
cin>>n>>m;

vector<vector<int> > g(n+1);
vector<bool> visited(n+1,false);

for(int i=0;i<m;i++)
{ cin>>x>>y;
  g[x].pb(y);
  g[y].pb(x);
}

int ans=0;
int c=0;
for(int i=1;i<=n;i++)
if(!visited[i])
{
  c=0;
  dfs(g,visited,c,i);
  ans=max(ans,c);
}

cout<<ans;
return 0;
}


Measured memory_bytes: 26688
import * as fs from 'fs';

namespace AtCoder.abc119 {

    export class Program {
        /**
         * in
         2
         10000 JPY
         0.10000000 BTC

         * out
         48000.0
         */
        static main(inp: string): void {
            const n: number = parseInt(inp.split('\n')[0], 10);
            let ans: number = 0;

            for (let i: number = 1; i < n + 1; i++) {
                const x: number = parseFloat(inp.split('\n')[i].split(' ')[0]);
                const y: string = inp.split('\n')[i].split(' ')[1];

                if (y === 'JPY') {
                    ans += x;
                }
                if (y === 'BTC') {
                    ans += x * 380000.0;
                }
            }

            console.log(ans);
        }
    }
}

AtCoder.abc119.Program.main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100100;
int x,k,q,r[maxn],mx[maxn],mi[maxn],c[maxn];
int main()
{
	scanf("%d%d",&x,&k);
	for(int i=1;i<=k;i++)
		scanf("%d",&r[i]);
	mx[0]=x;
	r[0]=mi[0]=c[0]=0;
	for(int i=1;i<=k;i++)
	{
		mx[i]=mx[i-1];mi[i]=mi[i-1];
		if(i&1)
		{
			mi[i]=max(mi[i],min(r[i]-r[i-1]-c[i-1],mx[i]));
			c[i]=max(c[i-1]+mi[i-1]-r[i]+r[i-1],0)-mi[i];
		}
		else
		{
			mx[i]=min(mx[i],max(x-r[i]+r[i-1]-c[i-1],mi[i]));
			c[i]=min(c[i-1]+mx[i-1]+r[i]-r[i-1],x)-mx[i];
		}
		//cout<<mi[i]<<' '<<mx[i]<<' '<<c[i]<<endl;	
	}		
	
	scanf("%d",&q);
	for(int i=1;i<=q;i++)	
	{
		int t,a;
		scanf("%d%d",&t,&a);
		int pl=upper_bound(r+1,r+k+1,t)-r-1,ans=c[pl];
		//cout<<"pl:"<<pl<<endl;
		if(a<=mi[pl]) ans+=mi[pl];
		else if(a>=mx[pl]) ans+=mx[pl];
		else ans+=a;
		if(pl&1) ans=min(x,ans+t-r[pl]);
		else ans=max(0,ans-t+r[pl]);
		printf("%d\n",ans);		
	}	
	return 0;
} 

Measured memory_bytes: 2816
#include<stdio.h>
int main(void)
{
	int a,s,d,f,g[31],h,i,j;
	scanf("%d",&a);
	scanf("%d",&s);
	for(i=1;i<=a;i++){
		g[i]=i;
	}
	for(i=1;i<=s;i++){
		scanf("%d,%d",&d,&f);
		h=g[d];
		g[d]=g[f];
		g[f]=h;
	}
	for(i=1;i<=a;i++){
		printf("%d\n",g[i]);
	}
	return 0;
}

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

int main() {
		int N, L;
   		cin >> N >> L;
    	vector<string> A(N);
        for (int i=0; i<N; i++){
          	cin >> A[i];
        }
  		sort (A.begin(), A.end());
        for (int i=0; i<N; i++){
          	cout << A[i];
        }
  		cout << endl;
}

Measured memory_bytes: 3696
#include <stdio.h>
#include <string.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#define P pair<int,int>
#define int long long 
using namespace std;

int ans[10];
signed main() {
	int a, b, c; cin >> a >> b >> c;
	ans[0] += (a - 2)*(b - 2);
	unordered_map<int, unordered_map<int, bool>>U;
	for (int d = 0; d < c; d++) {
		int e, f; scanf("%lld%lld", &e, &f); e--; f--;
		for (int i = -1; i < 2; i++) {
			for (int j = -1; j < 2; j++) {
				int sum = 0;
				int n = e + i, m = f + j;
				for (int x = -1; x < 2; x++) {
					for (int y = -1; y < 2; y++) {
						if (n + x < 0 || n + x >= a || m + y < 0 || m + y >= b)goto l;
						if (U[n + x][ m + y])sum++;
					}
				}
				ans[sum]--;
				ans[sum + 1]++;
			l:;
			}
		}
		U[e][f] = true;
	}
	for (int i = 0; i < 10; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 186404
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(n<=k) {
            System.out.println(x*n);
        }else {
            System.out.println(x*k+y*(n-k));
        }
    }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
int main(){
   ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    cout.tie(0);
    lli n,i,k=0,l=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        if(a[i]!=i+1){
            k++;
        }
        l=l+a[i]-i-1;
    }
    if(k>2){
        cout<<"NO";
    }
    else{
        if(l==0){
            cout<<"YES\n";
        }
        else{
            cout<<"NO\n";
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    rep(i, 0, H) cin >> a[i];
    rep(i, 0, H + 2)
    {
        rep(j, 0, W + 2)
        {
            if (i - 1 >= 0 && i - 1 < H && j - 1 >= 0 && j - 1 < W)
            {
                cout << a[i - 1][j - 1];
            }
            else
            {
                cout << '#';
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= m; i++) {
        for(int j = 2; j <= d; j++) {
            if ((j/10) <= 1 || (j%10) <= 1)
                continue;
            if ((j/10) * (j%10) == i)
                ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256