akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
res = 0
ue = Math.sqrt(n).to_i
a = [*(1..ue)]
com = a.repeated_permutation(3).to_a
res = Array.new(n,0)
com.each do |x,y,z|
  tmp = x**2 + y**2 + z**2 + x*y + y*z + x*z
  if tmp >= 1 && tmp <= n
    res[tmp - 1] += 1
  end
end
puts res

Measured memory_bytes: 67544
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();
		int C = nextInt();
		int D = nextInt();

		String ans =String.valueOf(Math.max(A*B, C*D));
		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22356
#include<stdio.h>
int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h=S / 3600;
    m=(S - h * 3600) / 60;
    s=S - h * 3600 - m * 60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2148
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc;// = new Scanner(System.in);
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int data[] = new int[n];
        for(int i=0; i<n; i++){
            int x = sc.nextInt();
            data[i] = x;
        }
        for(int i=n-1;i>=0;i--){
            System.out.print(data[i]);
            if(i != 0)System.out.print(" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 26244
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

const int MAXN = 200 + 7;

char s[MAXN];

int main() {
	scanf("%s", s  + 1);
	int n = strlen(s + 1);
	int ans = 0;
	rep(i, 1, n / 2) ans += (s[i] != s[n - i + 1]);
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;


void solve() {
    int n, m;
    cin >> n >> m;
    auto divs = [](int n){
        vector<int> res;
        for (int i = 1; i*i <= n; i++) {
            if (n % i == 0) {
                res.emplace_back(i);
                if (i*i != n)
                    res.emplace_back(n/i);
            }
        }
        sort(res.begin(), res.end(), greater<int>());
        return res;
    };
    for (int d: divs(m)) {
        if (m/d >= n) {
            cout << d;
            return;
        }
    }

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n;
	vector<long long> z;
	cin>>n;
	for(int i=0;i!=n;++i){
		long long temp;
		cin>>temp;
		z.push_back(temp);
	}
	long long x,y=0,ans;
	for(int i=0;i!=n;++i)
		y+=z[i];
	x=z[0],y-=z[0];
	ans=abs(x-y);
	for(int i=1;i!=n-1;++i){
		x+=z[i];
		y-=z[i];
		ans=min(ans,abs(x-y));
	}
	cout<<ans;
}

Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
#define ll long long
string s1, s2, s3;
ll n1, n2;
int main()
{
	cin >> s1;
	for(int i = 1; i <= s1.length(); i++) cout << 'x';
	cout << endl;
	return 0;
}

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



int main(){
    int n;
    cin >> n;
    int* a = new int[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i%2==0) sum+=a[i];
        else sum-=a[i];
    }
    cout << sum << " ";
    int prevmountain=sum;
    //得られたsumが山１の雨量であるから
    for(int i=1;i<n;i++){
        prevmountain = 2*a[i-1]-prevmountain;
        cout << prevmountain << " ";
    }
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll N;
  cin>>N;
  ll i=1;
  for(i=1;i<=N;i++)
  {
    if(N%i==0)
    {
      ll TMP1=N/i;
    	ll TMP2=i;
    if(TMP1>=1&&TMP1<=9&&TMP2>=1&&TMP2<=9)
      break;
    }
  }
  if(i>N)
    cout<<"No"<<"\n";
  else
    cout<<"Yes"<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;

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

  int x,y,z;
  cin >> x >> y >> z;
  printf("%d %d %d\n",z,x,y);
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    string S;cin>>S;
    int cnt=1;
    string T;
    T+=S[0];
    for(int i=1;i<S.size();i++){
        string now;
        now+=S[i];
        if(T==now){
            if(i!=S.size()-1){
                now+=S[i+1];
                T=now;
                i++;
                cnt++;
            }
        }else{
            T=now;
            cnt++;
        }
    }
    
    cout<<cnt<<endl;
}




Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int min=999999999,max=0;
        int N = sc.nextInt();
        for(int i=0;i<N;i++){
            int num = sc.nextInt();
            if(max<num) max = num;
            if(min>num) min = num;
        }
        System.out.println(Math.abs(max-min));
    }
}


Measured memory_bytes: 21844
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const ll MOD = 998244353;

int n;
string s;

char rev(char x) {
    if (x == '0') {
        return '1';
    } else {
        return '0';
    }
}

string t;

const int N = 210000;
ll dp[N];

ll ans = 0;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
    cin >> n;
    cin >> s;
    for (int k = 1; k <= n; ++k) {
        if (n % k != 0 || (n / k) % 2 == 0) {
            continue;
        }
        ll go = 0;
        for (int i = 0; i < k; ++i) {
            go = (go * 2 + (s[i] == '1')) % MOD;
        }
        t = "";
        int g = n / k;
        for (int i = 0; i < g; ++i) {
            for (int j = 0; j < k; ++j) {
                if (i % 2 == 0) {
                    t += s[j];
                } else {
                    t += rev(s[j]);
                }
            }
        }
        if (t <= s) {
            go = (go + 1) % MOD;
        }
        dp[k] = (dp[k] + go) % MOD;
        ans = (ans + 2 * k * dp[k]) % MOD;
        for (int i = 2 * k; i <= n; i += k) {
            dp[i] = (dp[i] - dp[k] + MOD) % MOD;
        }
    }
    cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 2452
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int tosi[] = new int[n];
        int M[] = new int[n];
        int D[] = new int[n];
        int i;

        int k;
        int c = 0;

        for (k = 0; k < n; k++) {
            int total = 0;
            int day = 0;
            tosi[k] = sc.nextInt();
            M[k] = sc.nextInt();
            D[k] = sc.nextInt();

            for (i = tosi[k] + 1; i <= 1000; i++) {
                if (i % 3 == 0) {
                    total += 200;
                } else {
                    total += 195;
                }
            }
            if (tosi[k] % 3 == 0) {
                int tuki = (M[k] - 1) * 20;
                day = tuki + D[k] - 6;

            } else {
                if ((M[k] - 1) % 2 == 0) {
                    day = ((M[k] - 1) / 2) * 20 + ((M[k] - 1) / 2) * 19 + D[k] - 1;

                } else {
                    day = ((M[k]) / 2) * 20 + ((M[k] - 1) / 2) * 19 + D[k] - 1;

                }

            }

            total = total - day;
            System.out.println(total);
        }

    }

}



Measured memory_bytes: 26496
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;
const int mod = 1000000007;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main()
{
  string s;
  cin>>s;
  int n=s.size();
  mint dp[n+5][13];
 dp[0][0]=1;
  rep(i,n){
    int c;
    if (s[i]=='?')c=-1;
    else c=s[i]-'0';
    rep(j,10){
      if (c!=-1 and c!=j)continue;
      rep(k,13){
        dp[i+1][(k*10+j)%13]+=dp[i][k];
      }
    }
  }
  mint ans=dp[n][5];
  cout<<ans.x;



}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main(void) {
  ll N, L;
  cin >> N >> L;
  ll i, j;
  ll mi=INF;
  ll id=-1;
  ll ans=0;
  for(i=0; i<N; i++) {
    
    ll t=0;
    for(j=0; j<N; j++) {
      if(j==i) continue;
      t+=L+j;
    }
    ll a=t+L+i;
    ll b=t;
    if(mi>abs(a-b)) {
      mi=abs(a-b);
      id=i;
      ans=b;
    }
    
  }
  
  pt(ans);
  
}












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

s = [0] * (N+1)

for j in range(1, N+1):
    now = j

    for i in range(2, N+1):
        if now==1:
            break
        else:
            while now%i==0:
                now = now//i
                s[i] = s[i]+1
                
s2 = 0
s4 = 0
s14 = 0
s24 = 0
s74 = 0
                
for i in range(N+1):
    if s[i]>=2:
        s2 = s2+1
    if s[i]>=4:
        s4 = s4+1
    if s[i]>=14:
        s14 = s14+1
    if s[i]>=24:
        s24 = s24+1
    if s[i]>=74:
        s74 = s74+1

A = s74
B = max(0, s24*(s2-1))
C = max(0, s14*(s4-1))
D = max(0, s4*(s4-1)*(s2-2)//2)

print(A+B+C+D)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
	mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
	mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
	mint operator+(const mint a) const {mint res(*this); return res+=a;}
	mint operator-(const mint a) const {mint res(*this); return res-=a;}
	mint operator*(const mint a) const {mint res(*this); return res*=a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
 		return a;
	}

	// For prime mod.
	// Do not use if MOD is not prime number !!
	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return (*this) *= a.inv();}
	mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

typedef vector<mint> vm;
typedef vector<vm> vvm;

void solve() {
    ll n, s;
    cin >> n >> s;
    vll a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    vector<vvm> dp(n + 1, vvm(s + 1, vm(3)));
    dp[0][0][0] = 1;
    enum state {NO, L, LR};
    rep(i, n) rep(j, s + 1) rep(pre, 3) rep(nxt, 3) {
        if(pre > nxt) continue;
        dp[i + 1][j][nxt] += dp[i][j][pre];
        if(pre != LR && nxt != NO && j + a[i] <= s) dp[i + 1][j + a[i]][nxt] += dp[i][j][pre];
    }
    cout << dp[n][s][LR].x << endl;
    return;
}

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

Measured memory_bytes: 496012
#include<iostream>
using namespace std;
 
int main(void) {
  string s;
  cin >> s;
  
  if((s.at(0) == s.at(1) && s.at(1) == s.at(2)) || 
     (s.at(1) == s.at(2) && s.at(2) == s.at(3))) {
       cout << "Yes" << endl;
     }
     else cout << "No" << endl;
}

Measured memory_bytes: 256
# ID
n,m=map(int,input().split())
s=[[] for _ in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    s[p-1].append([y,i,''])

for i in range(len(s)):
    s[i].sort()

ans=[]
for i,ss in enumerate(s):
    for j,sss in enumerate(ss):
        if ss:
            if sss:
                id_no=''
                id_no+='0'*(6-len(str(i+1)))+str(i+1)
                id_no+='0'*(6-len(str(j+1)))+str(j+1)
                s[i][j][2]=id_no

for i,ss in enumerate(s):
    for j,sss in enumerate(ss):
        ans.append(s[i][j])
ans.sort(key=lambda x:x[1])
for aa in ans:
    print(aa[2])

Measured memory_bytes: 39332
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long  a,b,c;
    cin>>a>>b>>c;
    long long  res=c;
    for(int i=0;i<10;i++)
    {
        res=res*a-b;
        cout<<res<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
typedef long long ll;
ll inf = 1e9;
using namespace std;
ll dp[100005];
ll h[100005];
int main() {
	ll n;
	cin >> n;
	int k;
	cin >> k;
	
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i < n; i++) {
		dp[i] = inf;
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int j = 2; j < n; j++) {
		for (int i = max(0, j - k); i < j; i++) {
			dp[j] = min(dp[i]+abs(h[j]-h[i]),dp[j]);
		}
	}
	cout << dp[n - 1] << endl;
	return 0;

}

Measured memory_bytes: 1792
import java.util.*;

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

        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        PriorityQueue<Integer> qa = new PriorityQueue<>(Collections.reverseOrder());
        PriorityQueue<Integer> qb = new PriorityQueue<>(Collections.reverseOrder());
        PriorityQueue<Integer> q = new PriorityQueue<>(Collections.reverseOrder());

        for(int i = 0; i < a; i++){
            qa.add(sc.nextInt());
        }
        for(int i = 0; i < b; i++){
            qb.add(sc.nextInt());
        }
        for(int i = 0; i < c; i++){
            q.add(sc.nextInt());
        }
        for(int i = 0; i < x; i++){
            q.add(qa.poll());
        }
        for(int i = 0; i < y; i++){
            q.add(qb.poll());
        }

        long ans = 0;

        for(int i = 0; i < x + y; i++){
            ans += q.poll();
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 102248
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,a,b=map(int,readline().split())
    x=list(map(int,readline().split()))
    y=[0]*(n-1)
    for i in range(n-1):
        y[i]=x[i+1]-x[i]

    ans=0
    for i in range(n-1):
        if a*y[i]<=b:
            ans+=a*y[i]
        else:
            ans+=b

    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 14172
# -*- coding: utf-8 -*-

order= []
for i in range(5):
    order.append(input())
    
min1 = 9
arg_min1 = 0
for i in range(5):
    #print(order[i][len(order[i])-1],len(order[i]),order[i])
    if int(order[i][-1]) < min1 and int(order[i][-1]) > 0:
        #print(int(order[i][-1]))
        min1 = int(order[i][-1])
        arg_min1= i

#print(arg_min1)
for i in range(5):
    order[i]= int(order[i])
        
order_min_sum = 0
for i in range(5):
    if arg_min1 == i:
        order_min_sum += int(order[i])
    else:
        while True:
            if int(order[i]) %10 == 0:
                break
            else:
                #print("are:{}".format(order[i]))
                order[i] = order[i] +1
        order_min_sum += order[i]
    #print("sum,{}".format(order_min_sum))
print(order_min_sum)

Measured memory_bytes: 3064
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
char moji[53][3][2],s[100001][2];
int n,k;
int main()
{
	for(;;){
		scanf("%d",&n);
		if(n==0) return 0;
		for(int i=0;i<n;i++){
			scanf("%s %s", moji[i][0], moji[i][1]);
		}
		scanf("%d",&k);
		for(int i=0;i<k;i++){
			scanf("%s",s[i]);
			for(int j=0;j<n;j++){
				if(s[i][0]==moji[j][0][0]){
					s[i][0]=moji[j][1][0];
					break;
				}
			}
			printf("%c",s[i][0]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1200
#include <cstdio>

inline void swap(char &a, char &b) { char t = a; a = b; b = t; }

int main() {
	int h, w;
	char a = '.', b = '#';
	while(scanf("%d%d", &h, &w) == 2 && (h || w)) {
		for(int i = 1; i <= h; i++) {
			swap(a, b);
			for(int j = 1; j <= w; j++) {
				if(j % 2) putchar(a);
				else putchar(b);
			}
			putchar('\n');
		}
		putchar('\n');
		a = '.'; b = '#';
	}
	return 0;
}


Measured memory_bytes: 2612
#include<stdio.h>

main(){
  int N,M,i,j;
  int DP[100000][2];
  int tmp;
  int ans;
  while(1){
    ans = 0;
    scanf("%d%d",&N,&M);
    
    if(N==0 && M==0)break;
    for(i=0;i<N;i++){
      scanf("%d%d",&DP[i][0],&DP[i][1]);
    }
    for(i=0;i<N;i++){
      for(j=N-1;j>i;j--){
	if(DP[j][1] > DP[j-1][1]){
	  tmp = DP[j][1];
	  DP[j][1] = DP[j-1][1];
	  DP[j-1][1] = tmp;
	  tmp = DP[j][0];
	  DP[j][0] = DP[j-1][0];
	  DP[j-1][0] = tmp;
	}
      }
    }
    for(i=0;i<N;i++){
      for(j=0;j<DP[i][0];j++){
	if(M <= 0){
	  ans += DP[i][1];
	}
	M--;
      }
    }
    //printf("\n");
    printf("%d\n",ans);
  }
 // printf("\n");
  return 0;
}
      

Measured memory_bytes: 684
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>
const int N = 5100;
const int INF = (1 << 30);

int main() {
  vector<int> v(N, INF);
  v[0] = 0;
  for(int i = 0; i < N; i += 100){
    if(v[i] == INF) continue;
    if(i + 200 < N) v[i + 200] = min(v[i + 200], v[i] + 380);
    if(i + 300 < N) v[i + 300] = min(v[i + 300], v[i] + 550);
    if(i + 500 < N) v[i + 500] = min(v[i + 500], v[i] + 850);
    if(i + 1000 < N) v[i + 1000] = min(v[i + 1000], v[i] + 1520);
    if(i + 1200 < N) v[i + 1200] = min(v[i + 1200], v[i] + 1870);
    if(i + 1500 < N) v[i + 1500] = min(v[i + 1500], v[i] + 2244);
  }
  int n;
  while(cin >>n && n) cout <<v[n] <<endl;
}

Measured memory_bytes: 1212
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define MAXN ((int)1e5+5)

int d[3][MAXN];
int dp[3][MAXN];
	
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);

	int n,k;
	cin >> n;
	for (int j = 0; j < n; ++j)
	{
		for (int i = 0; i < 3; ++i)
		{
			cin >> d[i][j];
			dp[i][j] = 0;
		}	
	}


	dp[0][0] = d[0][0];
	dp[1][0] = d[1][0];
	dp[2][0] = d[2][0];

	for (int i = 0; i < n-1; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 3; ++k)
				if(j != k){

					dp[k][i+1] = max(dp[k][i+1] , dp[j][i] + d[k][i+1]);
				}
		}
	}

	cout << max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]) << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007

using namespace std;


int main(){
    string x; cin >> x;
    int a[4];
    for (int i = 0; i < 4; i++)
    {
        a[i] = x[i] - '0';
    }
    
    if(a[0]+a[1]+a[2]+a[3] == 7) printf("%d+%d+%d+%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]-a[1]+a[2]+a[3] == 7) printf("%d-%d+%d+%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]+a[1]-a[2]+a[3] == 7) printf("%d+%d-%d+%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]-a[1]-a[2]+a[3] == 7) printf("%d-%d-%d+%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]+a[1]+a[2]-a[3] == 7) printf("%d+%d+%d-%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]-a[1]+a[2]-a[3] == 7) printf("%d-%d+%d-%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]+a[1]-a[2]-a[3] == 7) printf("%d+%d-%d-%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]-a[1]-a[2]-a[3] == 7) printf("%d-%d-%d-%d=7\n",a[0],a[1],a[2],a[3]);

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] b = new int[m];
        int[][]a = new int[n][m];


        for(int i=0; i<m; i++) {
            b[i] = sc.nextInt();
        }

        for(int i=0; i<n; i++) {
            for(int j=0; j<m; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        int res = 0;

        for(int i=0; i<n; i++) {
            int sum = c;
            for(int j=0; j<m; j++) {
                sum += a[i][j] * b[j];
            }
            if(sum > 0) res++;
        }

        System.out.println(res);

    }

}


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

using namespace std;

int main()
{
    string o="RUD";
    string g="LUD";
    string s;
    cin >> s;
    bool f=false;
    bool l=false;
    bool a=true;
    for(int i=0;i<(int)s.size();i++){
        if(i%2==0){
                if(s[i]=='R'||s[i]=='U'||s[i]=='D'){
                   f=true;
                }
            if(!f)a=false;
            f=false;
        }
         if(i%2==1){
                if(s[i]=='L'||s[i]=='U'||s[i]=='D'){
                   l=true;
                }
            if(!l)a=false;
            l=false;
        }
    }
    if(!a)puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define MAXN 2000000
#define int long long
#define INF (1e9 + 7)
#define MANX MAXN
// #pragma GCC optimize(2)

using namespace std;

inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (c > '9' || c < '0') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') {x = x * 10 + (c ^ 48); c = getchar();}
	return f * x;
}

int n, ans;

signed main()
{
	n = read();
	for (int i = 1; i <= n; i++)
		if (i % 3 != 0 && i % 5 != 0)
			ans += i;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<vector>
using namespace std;
template<typename T>void scan(T &x)
{
	char ch;
	bool f=1;
	x=0;
	ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') f=0,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(f==0) x=-x; 
}
int a,b;
int main()
{
	scan(a),scan(b);
	printf("%d\n",a+b/2);
	return 0;
}

Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,hypot,log
def read_int(): return int(input())
 
def prime(num):
    for n in range(2,int(sqrt(num))):
        if num % n == 0:
            return False
            break
    return True
  
def solution(K):
    while not prime(K):
        K += 1
    return K
    
K = read_int()
print(solution(K))

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K= sc.nextInt();
		int data[] = {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};
		System.out.println(data[K-1]);
			
	}
}
			
	

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'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'};
//vc Alp ={'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'};
//cout<<""<<endl;

int main(){
  int N,K;cin>>N>>K;
  vi p(N);
  rep(i,N)cin>>p[i];
  sort(all(p));
  int tot=0;
  rep(i,K)tot+=p[i];
  cout<<tot<<endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <tuple>
#include <cmath>
#include <array>
using namespace std;

int main(){
    int n, ans=0, temp;
    cin>>n;
    for (int i=1; i<=n; i++){
        cin>>temp;
        ans+=temp-1;
    }
    cout<<ans<<endl;
}


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

signed main(){
  int N,cash=1000;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  int today=A[0];
  for(int i=1;i<N;i++){
    if(A[i]>today){
      int S=cash/today;
      cash+=S*(A[i]-today);
      today=A[i];
    }
    else{
      today=A[i];
    }
  }
  cout<<cash<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(){
  int n,m,a[1010],b[1010],y,i;
  char s[1010][1010];
  while(scanf("%d %d",&n,&m),n){
    for(i=0;i<n;i++)scanf("%s %d %d",s[i],&a[i],&b[i]);
    while(m--){
      scanf("%d",&y);
      for(i=0;i<n;i++){
	if(b[i]-a[i]<y&&y<=b[i])break;
      }
      i-n?printf("%s %d\n",s[i],y-b[i]+a[i]):printf("Unknown\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1612
#include <iostream>

using namespace std;

int main()
{
    int n ;
    cin >> n ;
    int m = 20000;
    int M = 0;
    while(n--){
        int a;
        cin >> a ;
        m = min(a,m);
        M = max(a,M);
    }
    cout << M-m;
    return 0;
}


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
        --a[i];
    }

    int ans = 0;
    int now = 0;
    for(int i=0; i<N; i++) {
        now = a[now];
        ans++;
        if(now == 1) {
            cout << ans << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


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

using namespace std;

int l[100000];
int r[100000];
bool pri[100000];
int sum[100000];

int main()
{
  int Q;
  cin>> Q;
  for(int i=0;i<Q;i++)cin>> l[i]>> r[i];

  int big=0;
  for(int i=0;i<Q;i++)big=max(big,r[i]);
  for(int i=0;i<=big;i++)
  {
    pri[i]=true;
    sum[i]=0;
  }
  pri[0]=false;
  pri[1]=false;
  for(int i=2;i<=sqrt(big);i++)
  {
    if(pri[i])
    {
      for(int j=0;i*(j+2)<=big;j++)pri[i*(j+2)]=false;
    }
  }
  for(int i=0;i<=big;i++)
  {
    if(pri[i]&&pri[(i+1)/2]&&i%2)sum[i]=sum[i-1]+1;
    else sum[i]=sum[i-1];
    cerr<< ":"<< sum[i]<< endl;
  }
  for(int i=0;i<Q;i++)
  {
    cout<< sum[r[i]]-sum[l[i]-1]<< endl;
  }

  return 0;
}


Measured memory_bytes: 1920
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]
 
sys.setrecursionlimit(1000000)
mod = 1000000007
 
def solve():
    a,b,c,k = map(int,input().split())
    ans = 0
    if a+b >= k:
        print(min(k,a))
    else: 
        print(a-(k-a-b))
    return
 
#Solve
if __name__ == "__main__":
    solve()

Measured memory_bytes: 67116
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll n;
  cin >>n;
  vl a(n);
  rep(i,n) {
cin >>a.at(i);
  }

  sort(all(a));
  
  ll x=a.at(n-1);
  
  ll indi=0;
  rep(i,n) {
if(a.at(i)>(double)x/(double)2 ) {
  indi=i;
  break;
}
  }
  
  
  ll c1=a.at(indi-1);
  ll c2=a.at(indi);
  long double z=(double)x/(double)2;
  ll d1=abs(c1-z);
  ll d2=abs(c2-z);
  if(d1<=d2) {
cout<<x<<" "<<c1<<endl;
    return 0;
  }
  else {
    cout<<x<<" "<<c2<<endl;
    return 0;
  }
  
  
}
  
  

Measured memory_bytes: 1024
import java.util.*;

class Main{
  public static final int N = 4;
  public static final int N2 = 16;
  public static final int LIMIT = 100;

  static final int dx[] = {0, -1, 0, 1};
  static final int dy[] = {1, 0 , -1, 0};
  static final char dir[] = {'r', 'u', 'l', 'd'};
  static int MDT[][] = new int[N2][N2];

  static Puzzle state;
  static int limit;
  static int path[] = new int[LIMIT];


  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    for(int i =0; i<N2; i++){
      for(int j = 0; j<N2; j++){
        MDT[i][j] = Math.abs(i/N - j/N) + Math.abs(i%N - j%N);
      }
    }
    Puzzle in = new Puzzle();

    for(int i = 0; i < N2; i++){
      in.f[i] = sc.nextInt();
      if(in.f[i] == 0){
        in.f[i] = N2;
        in.space = i;
      }
    }
    String ans = iterative_deepening(in);
    // System.out.println(ans);
    System.out.println(ans.length());
  }

  static int getAllMD(Puzzle pz){
    int sum = 0;
    for(int i = 0; i<N2; i++){
      if(pz.f[i] == N2)continue;
      sum += MDT[i][pz.f[i] - 1];
    }
    return sum;
  }

  static boolean isSolved(){
    for(int i = 0; i < N2; i++){
      if(state.f[i] != i+1)return false;
    }
    return true;
  }

  static boolean dfs(int depth, int prev){
    if(state.MD == 0) return true;

    if(depth + state.MD > limit)return false;

    int sx = state.space / N;
    int sy = state.space %N;
    Puzzle tmp;

    for(int r = 0; r<4; r++){
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if(tx < 0 || ty <0 || tx>= N || ty >= N)continue;
      if(Math.max(prev, r) - Math.min(prev,r) == 2)continue;
      tmp = new Puzzle();
      tmp.MD = state.MD;
      tmp.space = state.space;
      tmp.f = Arrays.copyOf(state.f, N2);
      // tmp = state;

      state.MD -= MDT[tx * N + ty][state.f[tx * N +ty] - 1];
      state.MD +=MDT[sx * N + sy][state.f[tx* N + ty] -1];
      int tmp2;
      tmp2 = state.f[tx * N + ty];
      state.f[tx * N + ty] = state.f[sx * N +sy];
      state.f[sx * N + sy] = tmp2;

      state.space = tx * N +ty;

      if( dfs(depth +1, r)){
        path[depth] = r;
        return true;
      }
      state.MD = tmp.MD;
      state.space = tmp.space;
      state.f = Arrays.copyOf(tmp.f, N2);
      // state = tmp;
    }
    return false;
  }

  static String iterative_deepening(Puzzle in){
    in.MD = getAllMD(in);

    for(limit = in.MD; limit <= LIMIT; limit++){
      state = in;
      if(dfs(0, -100)){
        String ans = "";
        for(int i = 0; i<limit; i++)ans += dir[path[i]];
        return ans;
      }
    }
    return "unsolvable";
  }
}

class Puzzle{
  int f[];
  int space,MD;
  Puzzle(){
    space = 0;
    MD = 0;
    f = new int[16];
  }
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<pair<int,int>>ab(n); for(auto&i:ab)cin>>i.first>>i.second;
	sort(ab.begin(),ab.end());
	int64_t ans=0;
	for(int i=0;m;++i){
		int mn=min(m,ab.at(i).second);
		ans+=(int64_t)ab.at(i).first*mn;
		m-=mn;
	}
	cout<<ans<<"\n"s;
}

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


int A[110][110],B[110][110];

int main(){
	int n,m,a,b,c,cnt=0;
	cin >> n >> m;
	
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) A[i][j]=1e9;
	
	for(int i=0;i<m;i++){
		cin >> a >> b >> c;
		A[a][b]=A[b][a]=B[a][b]=B[b][a]=c;
	}
	
	for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++)
		A[i][j] = min(A[i][j], A[i][k]+A[k][j]);
	
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) cnt+=A[i][j]<B[i][j];
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 384
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
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;}
// clang-format on

void solve(long long N, std::vector<long long> A) {
  if (find(all(A), 0) != A.end()) {
    ANS(0);
    return;
  }
  ll L = 1e18;
  ll ans = 1;
  rep(i, N) {
    if ((L + 1) / ans < A[i] || A[i] * ans > L) {
      ANS(-1);
      return;
    }
    ans *= A[i];
  }
  ANS(ans);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


int main() {
    string s; cin >> s;
    int k; cin >> k;
    set<string> st;
    vector<int> t;
    int n = sz(s);
    rep(i, n) {
        string tmp = "";
        tmp.push_back(s[i]);
        st.insert(tmp);
        REP(j, i+1, min(n,i+k)) {
            tmp.push_back(s[j]);
            st.insert(tmp);
        }
    }
    int cnt = 0;
    for (auto it=st.begin(); it!=st.end(); it++) {
        cnt++;
        if (cnt < k) continue;
        cout << *it << endl;
        return 0;
    }
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.math.BigDecimal;

public class Main {
    public static void main(String args[]) throws IOException {
        int debt = 100000;
        int nWeeks = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in)).readLine());
        for(int i = 0; i < nWeeks; i++) {
            debt = new BigDecimal(debt * 1.05).setScale(-3, BigDecimal.ROUND_CEILING).intValue();
        }
        System.out.println(debt);

    }
} 

Measured memory_bytes: 17116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define reps(i,s,n) for(int i = (s); i < (n); ++i)
long long gcd(long long x, long long y) {
    return y ? gcd(y, x%y) : x;
}
int main(){

  double n,ans; cin >> n;
  ans = n / 1.08;
  ans = (int)(ans+0.999999);
  if((int)(ans*1.08)!=n) cout << ":(" << endl;
  else cout << ans << endl;
  
  
  
  return 0;
 }

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import os


d = {}
d['S'] = [None for i in range(13)]
d['H'] = [None for i in range(13)]
d['C'] = [None for i in range(13)]
d['D'] = [None for i in range(13)]

N = int(input())
for i in range(N):
    sep = input().split()
    mark = sep[0]
    number = int(sep[1])

    d[mark][number - 1] = True

for mark in ['S', 'H', 'C', 'D']:
    lst = d[mark]
    for i, val in enumerate(lst):
        if val is None:
            print(mark, i + 1)

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

#define int long long
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; }

signed main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << (a[0] == 5 && a[1] == 5 && a[2] == 7 ? "YES" : "NO") << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll a(n);
    rep(i,n) cin>>a[i];
    rep(i,n) a[i]-=i+1;
    sort(all(a));
    ll ans=0;
    rep(i,n/2){
        ans+=a[n-i-1]-a[i];
    }
    cout<<ans<<endl;
    return 0;
}


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


int main()
{
    long long N;
    cin >> N;

    int minDigits = 1e9;
    for (long long i = 1; i * i <= N; i++)
    {
        if(N % i == 0){
            long long opNum = N / i;
            long long maxNum = max(i, opNum);
            int digits = 1;
            while(maxNum >= 10)
            {
                maxNum /= 10;
                digits++;
            }
            minDigits = min(minDigits, digits);
        }
    }
    cout << minDigits << endl;
    return 0;
}

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

int multipulTwo(int a, int b) {
    int result = a;
    for (int i = 0; i < b ; i++) {
        result *= 2;
    }
    return result;
}
int main() {
    int a, b, c;
    int k;
    int num[3];

    cin >> a >> b >> c >> k;

    int max = 0;
    num[0] = multipulTwo(a , k) + b + c;
    num[1] = a + multipulTwo(b , k) + c;
    num[2] = a + b + multipulTwo(c , k);
    

    for (int i = 0; i < 3; i++) {
        if (num[i] > max) max = num[i];
    }
    
    cout << max << endl;

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

const ll maxN = 100100;
ll n, k;
ll p[maxN], d[maxN];
vl ch[maxN];
bool mark[maxN];

void dfs1(ll i) {
	d[i] = d[p[i]] + 1;
	for (ll j: ch[i]) dfs1(j);
}

void dfs2(ll i) {
	if (mark[i]) return;
	mark[i] = true;
	for (ll j: ch[i]) dfs2(j);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> k;
	FOR(i,0,n) cin >> p[i], p[i]--;
	FOR(i,1,n) ch[p[i]].pb(i);
	for (ll j: ch[0]) dfs1(j);
	
	vl q(n);
	FOR(i,0,n) q[i] = i;
	sort(all(q),[&](ll i, ll j) { return d[i] > d[j]; });
	
	ll res = 0;
	for (ll i: q) if (d[i] > k && !mark[i]) {
		ll j = i;
		FOR(t,1,k) j = p[j];
		dfs2(j);
		res++;
	}

	if (p[0]) res++;
	cout << res << endl;

}


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

int main() {
    ios::sync_with_stdio(false);
    int ar[4];
    cin >> ar[0] >> ar[1] >> ar[2] >> ar[3];
    cout << max(ar[0]*ar[1],ar[2]*ar[3]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline void Add(int *fwt,int idx,int v){while(idx<=*fwt){fwt[idx]+=v;idx+=(idx&-idx);}}
static inline int Sum(int *fwt,int x){int v=0;while(x){v+=fwt[x];x-=(x&-x);}return v;}
int main()
{
  int N=IN(),Q=IN(),after[500001],dat[500000],fenwick[500001]={0},id[500001],left[500001],pos[500001]={0},result[500001];
  rep(i,N){dat[i]=IN();}
  rep(i,Q){left[i+1]=IN()-1;int r=IN()-1;after[i+1]=id[r];id[r]=i+1;}
  fenwick[0]=N;
  for(int r=0;r<N;r++)
  {
    if(pos[dat[r]]){Add(fenwick,pos[dat[r]],-1);}
    Add(fenwick,r+1,1);
    for(int i=id[r];i;i=after[i]){result[i]=Sum(fenwick,r+1)-Sum(fenwick,left[i]);}
    pos[dat[r]]=r+1;
  }
  rep(i,Q){OUT(result[i+1]);}
}

Measured memory_bytes: 17312
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
using namespace std;
int main ()
{
	double v;
	while(scanf("%lf",&v)!=EOF)
	{
		double t=v/9.8;
		double y=4.9*t*t;
		double ans=0;
		for(;5*ans-5<y;ans+=1.0);
			cout<<(int)ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228