akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;
const double pi = acos(-1);

void solve(){
    int n,l;
    cin>>n>>l;
    vector<string>arr(n);
    for(int i=0;i<n;++i) {
        cin>>arr[i];
    }
    sort(all(arr));
    for(string i:arr)cout<<i;
    cout<<"\n";
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    #n=int(input())
    #a=list(map(int,sys.stdin.readline().split(' ')))
    n,k= map(int, sys.stdin.readline().split(' '))
    print(n+(k//2))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3064
#include <stdio.h>

 int main(void)
 {
 double r;
 double m,l;
 double p=3.14159265358979;


scanf("%lf", &r);
 
 
 
 m=r*r*p;
 l=2*r*p;
 
 
 printf("%f %f\n", m,l);


 return 0;
 }

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

a = [int(x) for x in input().split()]
a.sort()
ans = 0
ans += a[2] - a[1]
a[0] += ans
if (a[2] - a[0]) % 2 == 0:
    ans += (a[2] - a[0])//2
    print(ans)
else:
    ans += (a[2] - a[0])//2
    ans += 2
    print(ans)



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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;

class ModInt{
public:
    long long n;
    int p;

    ModInt(){
    }

    //値と割る値を受け取って、オブジェクトを返す
    ModInt(long long _n, int _p){
        p = _p;
        n = _n % _p;

        //負の値を受け取ったときには正の値に戻す
        if(n < 0){
            n += p;
        }
    }

    ModInt operator+(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n += a.n;

        if(tmp.n > tmp.p){
            tmp.n -= tmp.p;
        }
        
        return tmp;
    }

    ModInt operator-(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n -= a.n;

        if(tmp.n < 0){
            tmp.n += tmp.p;
        }

        return tmp;
    }

    ModInt operator*(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = (tmp.n * a.n) % tmp.p;

        return tmp;
    }

    int modpow(int b, int k){
        if(k == 0){
            return 1;
        }else if(k % 2 == 1){
            long long tmp = b;
            tmp = tmp * modpow(b, k - 1) % p;
            
            return tmp;
        }else{
            long long tmp = modpow(b, k / 2);
            return tmp * tmp % p;
        }
    }

    int modinv(int b){
        return modpow(b, p - 2);
    }

    ModInt operator/(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = tmp.n * modinv(a.n) % tmp.p;
        return tmp;
    }
};

ModInt mypow(ModInt a, int k){
    if(k == 0) return ModInt(1, MODN);

    if(k % 2 == 1){
        ModInt tmp = mypow(a, (k - 1) / 2);
        return tmp * tmp * a;
    }else{
        ModInt tmp = mypow(a, k / 2);
        return tmp * tmp;
    }
}

int main(){

    int n, a, b;
    cin >> n >> a >> b;

    vector<ModInt> combi(min(n + 1, 2 * 100000 + 1), ModInt(1, MODN));

    for(int i = 1; i < combi.size(); i++){
        combi[i] = combi[i - 1] * ModInt(n + 1 - i, MODN) / ModInt(i, MODN);
    }

    cerr << combi[a].n << " " << combi[b].n << endl;

    cout << (mypow(ModInt(2, MODN), n) - ModInt(1, MODN) - combi[a] - combi[b]).n << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int a,b,c;

int compare(int i, int j){
    return i -j;
}

int main(void){
    scanf("%d" ,&a);
    scanf("%d" ,&b);
    scanf("%d" ,&c);

    if(compare(a,c)>0){
        int tmp = a;
        a = c;
        c = tmp;
    }

    if(compare(a,b)>0){
        int tmp = a;
        a = b;
        b = tmp;
    }

    if(compare(b,c)>0){
        int tmp = b;
        b = c;
        c = tmp;
    }

    int sum;
    sum = (b-a) + (c-b);

    printf("%d\n" , sum);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int cnt=0,i,j,k,n,r=0,g=0,b=0;
    string ptr;
    cin>>n>>ptr;

    for(i=0; i<n; i++)
    {
        if(ptr[i]=='R')
            r++;
        if(ptr[i]=='G')
            g++;
        if(ptr[i]=='B')
            b++;
    }
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(ptr[i]!=ptr[j])
            {
                if(2*j-i>=n)
                    break;
                if(ptr[2*j-i]!=ptr[i]&&ptr[2*j-i]!=ptr[j])
                    cnt++;
            }
        }
    }
cout<<(r*g*b)-cnt<<endl;
}


Measured memory_bytes: 3616
N, T = gets.split.map{|i|i.to_i}
t = gets.split.map{|i|i.to_i}
x = 0
s = 0
e = 0
t.each{|i| 
    if e < i 
        x += e - s
        s = i
    end 
    e = i + T
}
x += e - s
puts x


Measured memory_bytes: 16004
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    long long a,b,c,cnt =0;
    cin >> a >> b >> c;

    if((a%c)==0){
        cout << b/c - a/c +1 << endl;
    }else{
        cout << b/c -a/c << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long n, a[200], mi = 0, ma = 1000000001;
    cin >> n;
    for(long long i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] < ma)
            ma = a[i];
        if(a[i] > mi)
            mi = a[i];
    }
    cout << mi - ma;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll ans = 0;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n-1; i++) {
		if (a[i] > a[i + 1]) {
			ans += a[i] - a[i + 1];
			a[i + 1] = a[i];
		}
	}
	cout << ans << endl;
}


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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long long toLL(string s) {long long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const long INF = 1000001;
const LL MOD=100007;

long dp1[1000003],dp2[1000003];
int main(){
	LL t=1;
	vector<LL>poll,odd;
	LL n=1;
	while(t<=1000000){
		t=n*(n+1)*(n+2)/6LL;
		poll.PB(t);
		if(t%2)odd.PB(t);
		n++;
	}
	REP(i,1000002){
		dp1[i]=dp2[i]=INF;
	}
	dp1[0]=dp2[0]=0;
	dp1[1]=dp2[1]=1;
	FOR(i,2,1000001){
		auto itr1=upper_bound(ALL(poll),i);
		auto itr2=upper_bound(ALL(odd),i);
		//itr1--;itr2--;
		for(auto itr=poll.begin();itr!=itr1;itr++)dp1[i]=min(dp1[i],dp1[i-*itr]+1);
		for(auto itr=odd.begin();itr!=itr2;itr++)dp2[i]=min(dp2[i],dp2[i-*itr]+1);
	}
	long tt;
	while(cin>>tt&&tt!=0){
		cout<<dp1[tt]<<" "<<dp2[tt]<<endl;
	}
	return 0;
}

Measured memory_bytes: 16844
#include <iostream>

using namespace std;

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

    int n;
    cin >> n;
    int s[n];
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        s[i] = c == 'R' ? 0 : c == 'G' ? 1 : 2;
    }

    int ss[n][3];
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < 3; j++) {
            ss[i][j] = i == n - 1 ? 0 : ss[i+1][j];
        }
        if (i != n - 1) {
            ss[i][s[i+1]]++;
        }
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (s[i] != s[j]) {
                ans += ss[j][3-s[i]-s[j]];

                int t = 2 * j - i;
                if (t < n && s[t] == 3 - s[i] - s[j]) {
                    ans--;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define ll long long
#define dot cout<< setprecision(20)<<endl;
#define vsor(x) sort(x.begin(),x.end());
#define vrev(x) reverse(x.begin(),x.end());
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define bit(b,n) for(int b=0;b<(1<<(ll)(n));b++)
 
 using namespace std;
 int main(){
   int l,r,d;
   cin>>l>>r>>d;
   int ans=0;
   for(int i=l;i<=r;i++){
       if(i%d==0)ans++;
   }
   cout<<ans<<endl;
 }

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

char b, x;

int main() {
	cin >> b;
	
	if(b == 'A') { x = 'T'; }
	if(b == 'T') { x = 'A'; }
	if(b == 'C') { x = 'G'; }
	if(b == 'G') { x = 'C'; }
	
	cout << x << endl;
	
	return 0;
}


Measured memory_bytes: 764
#include <stdio.h>

int main(void) {
	char a[11], b[11], c[11];
	int len_a, len_b;

	scanf("%s%n ", a, &len_a);
	scanf("%s%n ", b, &len_b);
	scanf("%s", c);

	puts(a[len_a - 1] == b[0] && b[len_b - 1] == c[0] ? "YES" : "NO");

	return 0;
}


Measured memory_bytes: 128
a = sorted(map(int, input().split()), reverse=True)

diff1 = a[0] - a[1]
diff2 = a[0] - a[2]
cnt1 = diff1 // 2
cnt2 = diff2 // 2
result = sum([cnt1, cnt2])

diff1 -= cnt1 * 2
diff2 -= cnt2 * 2

s = sum([diff1, diff2])
if s & 1:
  print(result + 2)
else:
  print(result + s // 2)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	int n , m ; cin >> n >> m ;
	int l = 1 , r = n ;
	int l1 , r1 ;
	for(int i = 0 ; i < m ; i++){
		cin >> l1 >> r1 ;
		l = max(l , l1) ;
		r = min(r1 , r) ;
	}
	cout << max(0 , r - l + 1) << endl ;
	return 0;
}


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

int main(){
    int A[3],ans=0,swap;
    cin >> A[0] >> A[1] >> A[2];
    sort(A,A+3);
    ans+=A[1]-A[0];
    ans+=A[2]-A[1];
    cout << ans;
}

Measured memory_bytes: 512
import scala.io.StdIn.{readInt,readLine}

object Main {
  val alist = List(1,3,5,7,9,11,15,17,19,21,23,25)
  val blist = 0 to 25
  val invs = for{
    i<-alist
    j<-1 to 25 by 2
    if (i*j) % 26 == 1
  } yield (i,j)
  def encode(c:Int,a:Int,b:Int) = (((a*(c-97)+b) % 26)+97).toChar
  def decode(c:Int,a:Int,b:Int) = ((a*(c-97-b+26) % 26)+97).toChar

  def main(args:Array[String]) = {
    val n = readInt
    (0 until n).foreach { _ =>
      val l = readLine
      val (a,b) = {for(i<-alist;j<-blist) yield (i,j)}.find{ case (i,j) =>
            l.contains("that".map{encode(_,i,j)}) || l.contains("this".map{encode(_,i,j)})
      }.get
      println( l.map { c=> if(c>=97 && c<=122) decode(c,invs.find(s => s._1 == a).get._2,b) else c })
    }
  }
}

Measured memory_bytes: 45316
#include <stdio.h>
#include <algorithm>
using namespace std;

int ball[200050];
int main(void)
{
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        int temp;
        scanf("%d", &temp);
        ball[temp]++;
    }
    sort(ball, ball + n);
    for (int i = n - 1; i >= 0 && k > 0; i--, k--)
        n -= ball[i];
    printf("%d\n", n);

    return 0;
}


Measured memory_bytes: 896
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 * 
 * https://atcoder.jp/contests/abc107/submissions/14509241 にも参考
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = new int[n];
			int right = IntStream.range(0, n).map(i -> a[i] = scanner.nextInt()).max().getAsInt();
			int left = Arrays.stream(a).min().getAsInt();
			long mLength = n * (n + 1L) / 2;
			int answer = -1;
			while (left <= right) {
				int middle = (left + right) / 2;
				if (calcNonLessNumber(a, middle) >= (mLength + 1) / 2) {
					answer = middle;
					left = middle + 1;
				} else {
					right = middle - 1;
				}
			}
			System.out.println(answer);
		}
	}

	/**
	 * a の連続部分列 a[l, r] (1 ≤ l ≤ r ≤ N) のうち，(A の個数) ≤ (B の個数) を満たすものは何通りかを計算する
	 * 
	 * 
	 * @param a     配列
	 * @param value 基準となるvalue
	 * @return a の連続部分列 a[l, r] (1 ≤ l ≤ r ≤ n) のうち，(A の個数) ≤ (B の個数) を満たすものは何通りか
	 */
	private static long calcNonLessNumber(int[] a, int value) {
		int[] sum = new int[a.length + 1];
		sum[0] = 0;
		IntStream.rangeClosed(1, a.length).forEach(i -> sum[i] = sum[i - 1] + ((a[i - 1] >= value) ? 1 : -1));
		return calcNonInversionNumber(sum, 0, sum.length - 1);
	}

	/**
	 * 配列の転倒していない数を計算
	 * 
	 * @param a    配列
	 * @param from 開始インデックス
	 * @param to   終了インデックス
	 * @return 配列の転倒していない数
	 */
	private static long calcNonInversionNumber(int[] a, int from, int to) {
		if (from == to) {
			return 0L;
		}
		int middle = (from + to) / 2;
		long result = calcNonInversionNumber(a, from, middle) + calcNonInversionNumber(a, middle + 1, to);
		int[] sorted = new int[to - from + 1];
		int left = from, right = middle + 1, sortedIndex = 0;
		while ((left != middle + 1) || (right != to + 1)) {
			if ((right == to + 1) || ((left != middle + 1) && (a[left] <= a[right]))) {
				result += to - right + 1;
				sorted[sortedIndex++] = a[left++];
			} else {
				sorted[sortedIndex++] = a[right++];
			}
		}
		IntStream.rangeClosed(from, to).forEach(i -> a[i] = sorted[i - from]);
		return result;
	}
}


Measured memory_bytes: 60768
#include <cstdio>
#include <algorithm>
#define mod (long)(1e9+7)

using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    long dp[101][4][4][4] = {{{{0}}}}; //T0 A1 G2 C3とした4進数
    dp[0][0][0][0] = 1;
    for (int i=0; i<N; i++) {
        for (int j=0; j<4; j++) {
            for (int k=0; k<4; k++) {
                for (int l=0; l<4; l++) {
                    dp[i+1][k][l][0] = (dp[i+1][k][l][0] + dp[i][j][k][l]) % mod; //T
                    dp[i+1][k][l][1] = (dp[i+1][k][l][1] + dp[i][j][k][l]) % mod; //A
                    if (k != 1 || l != 3) //ACG
                        dp[i+1][k][l][2] = (dp[i+1][k][l][2] + dp[i][j][k][l]) % mod; //G
                    if ((l != 2 || (j != 1 && k != 1)) && (k != 2 || (j != 1 && l != 1)))
                        dp[i+1][k][l][3] = (dp[i+1][k][l][3] + dp[i][j][k][l]) % mod; //C
                }
            }
        }
    }
    long sum=0;
    for (int j=0; j<4; j++) {
        for (int k=0; k<4; k++) {
            for (int l=0; l<4; l++) {
                sum = (sum + dp[N][j][k][l]) % mod;
            }
        }
    }
    printf("%ld\n", sum);
    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int r; cin >> r;
    cout << r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int L[100011], R[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d%d", L+i, R+i);

    LL ans = 0;
    priority_queue<LL> Ls;
    priority_queue<LL, vector<LL>, greater<LL> > Rs;
    Ls.push(L[0]);
    Rs.push(L[0]);
    LL Roffset = 0, Loffset = 0;

    REP (i, N-1) {

	Roffset += R[i] - L[i];
	Loffset -= R[i+1] - L[i+1];

	LL pos = L[i+1];
	if (Rs.top()+Roffset < pos) {
	    LL x = Rs.top() + Roffset;
	    Rs.pop();
	    Rs.push(pos-Roffset);
	    Rs.push(pos-Roffset);
	    ans += pos - x;
	    Ls.push(x - Loffset);
	} else if (Ls.top()+Loffset > pos) {
	    LL x = Ls.top() + Loffset;
	    Ls.pop();
	    Ls.push(pos-Loffset);
	    Ls.push(pos-Loffset);
	    ans += x - pos;
	    Rs.push(x - Roffset);
	} else {
	    Rs.push(pos-Roffset);
	    Ls.push(pos-Loffset);
	}
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2804
#include<stdio.h>
int main() {
	int x, y ,a;
	while (1) {
		scanf("%d%d", &x, &y);

		if (x == 0 && y == 0) {
			break;
		}
		else if (x > y) {
			a = x;
			x = y;
			y = a;
			printf("%d %d\n", x, y);
		}
		else {
			printf("%d %d\n", x, y);
		}
	}
	return 0;
}

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

N, X = map(int, input().split())
L = [int(v) for v in input().split()]
L.sort()

ans = 0
for i in range(N):
    a = L[i]
    
    if X >= a:
        X -= a
        ans += 1

if ans == N and X > 0:
    ans -= 1
    
print(ans)

Measured memory_bytes: 3064
import java.util.*;
class Main{
    int p,q,a,n;
    void run(){
	Scanner sc=new Scanner(System.in);
	while(true){
	    p=sc.nextInt();
	    q=sc.nextInt();
	    a=sc.nextInt();
	    n=sc.nextInt();
	    if(q==0)break;
	    System.out.println(DFS(0,1,1,0));
	}
    }
    int DFS(int num,int den,int x,int step){
	if(p*den==num*q)return 1;
	if(p*den<num*q)return 0;
	if(step>=n)return 0;
     
	int sum=0;
	for(int i=x;i*den<=a;i++){
	    int newNum=num*i+1*den;
	    int newDen=den*i;
	   sum+=DFS(newNum,newDen,i,step+1);
	}
	return sum;
    }

    public static void main(String[] args){
	new Main().run();
    }
}

Measured memory_bytes: 12000
from math import gcd

# = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
mA = max(A)
counter = [0 for _ in range(mA+1)]

primenum = [2]
sgn = [-1 for _ in range(int(mA**0.5)+1)]
k = 3
while k**2 <= mA:
  if sgn[k] == -1:
    primenum.append(k)
    add = k*k
    ok = k
    while ok**2 <= mA:
      sgn[ok] = 1
      ok += add
  k += 2
#prime_num が用意されているとき
def factorization(n):
  M = n
  for p in primenum:
    if p**2 > M:
      break
    else:
      if M%p == 0:
        if counter[p] == 0:
          counter[p] = 1
        else:
          return False
        while M%p == 0:
          M //= p

  if M > 1:
    if counter[M] == 0:
      counter[M] = 1
    else:
      return False
  return True



g = A[0]
flag = True
for k in range(N):
  a = A[k]
  g = gcd(g, a)
  if flag:
    flag = factorization(a)
  if flag == False:
    if g == 1:
      break


if flag:
  print('pairwise coprime')
  exit()
if g == 1:
  print('setwise coprime')
else:
  print('not coprime')


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

int main(){
    int N;
    cin >> N;
    
    if(N == 1){
        cout << "Hello World" << endl;
        return 0;
    }

    else{
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
        return 0;
    }
}


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

using namespace std;
using ll = long long;

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    int a, b;
    cin>>a>>b;
    cout<<max({a+b, a-b, a*b})<<endl;

    return 0;
}

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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
const int MOD=1e9+7;
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int solve(vi& a) {
	int n=sz(a);
	int cnt=0,ret=0;
	for(int i = n-1; i >= 0; i--) {
		if(a[i]==1) ret+=cnt;
		else cnt++;
	}
	return ret;
}
signed main(void)
{
	IOS;
	string s; cin>>s;
	int n=s.length();
	int found=0,ans=0;
	vi ar;
	for(int i = 0; i < n; i++) {
		// cout<<i<<" "<<found<<endl;
		if(s[i]=='A') {
			if(found) ar.pb(1);
			else {
				ar.clear();
				ar.pb(1);
				found=1;
			}
			continue;
		}
		if(s[i]=='B') {
			if(i+1>=n) continue;
			if(s[i+1]=='C') {
				if(found) ar.pb(2);
				else {
					ar.clear();
					ar.pb(2);
					found=1;
				}
				i++;
			} else {
				ans += solve(ar);
				ar.clear();
				found=0;
			}
			continue;
		}
		if(s[i]=='C') {
			if(found) {
				ans += solve(ar);
				ar.clear();
				found=0;
			}
		}
	}
	// for(int i: ar) cout<<i<<" ";
	// 	cout<<endl;

	if(found && sz(ar)) ans += solve(ar);
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000
const int MAX = 10000000;
ll fac[MAX], finv[MAX], inv[MAX];
const int mod = 1e9 + 7;
bool is_prime(int n) {
	for(int i = 2; i * i <= n; i++) {
		if(n % i == 0) return false;
	}
	return n != 1;
}

vector<int> divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

map<ll, ll> prime_factor(int n) {
	map<ll, ll> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int eratosthenes(int n) {
	bool is_prime[n + 1];
	memset(is_prime, true, sizeof(is_prime));
	// prime[n];

	is_prime[0] = is_prime[1] = false;
	int ans = 0;
	rep(i, 2, n + 1) {
		if(is_prime[i]) {
			// prime[ans++] = i;
			ans++;
			for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return ans;
}


void comInit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rep(i, 2, MAX) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

ll comb(ll n, ll k) {
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	comInit();
	int N, M;
	cin >> N >> M;
	map<ll, ll> m = prime_factor(M);
	ll rsl = 1;
	for(map<ll, ll>::iterator it = m.begin(); it != m.end(); it++) {
		rsl *= (comb(N + it->second - 1, it->second) % mod);
		rsl %= mod;
	}
		
	cout << rsl << endl;
}


Measured memory_bytes: 234624
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S, W = map(int, read().split())

if W >= S:
    print("unsafe")
else:
    print("safe")



Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(c<a+b) puts("No");
    else if((c-a-b)*(c-a-b)>4*a*b) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

string s, t;
int n, m;
const int R = 256;
const int INF = 1e9;
vector<vector<int>> dfa;
vector<int> match;
vector<int> L;

void kmp() {
  dfa.resize(R, vector<int>(m+1));
  dfa[t[0]][0] = 1;
  for(int x = 0, j = 1; j <= m; j++) {
    for(int c = 0; c < R; c++) {
      dfa[c][j] = dfa[c][x];
    }
    dfa[t[j]][j] = (j+1)%(m+1);
    x = dfa[t[j]][x];
  }
}

vector<int> used;
int pathLength(int i) {
  if(!match[i]) return 0;
  if(L[i] != -1) return L[i];
  if(used[i]) return INF;

  used[i] = 1;
  return L[i] = min(INF, pathLength((i+m)%n) + 1);
}

int main () {
  cin >> s >> t;
  n = s.size(), m = t.size();
  match.resize(n);
  L.resize(n, -1);

  kmp();
  for(int i = 0, j = 0; i < n + m - 1; i++) {
    j = dfa[s[i%n]][j];
    if(j == m) match[i-m+1] = 1;
  }

  used.resize(n, 0);
  int ans = 0;
  rep(i,n) {
    if(match[i]) ans = max(ans, pathLength(i));
  }

  cout << (ans == INF ? -1 : ans) << endl;

  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	cin >> n;
	vll b(n),ans;
	rep(i,n) cin >> b[i];
	while(!b.empty()){
		bool found=false;
		for(ll i=SIZE(b)-1;i>=0;i--){
			if(b[i]==i+1){
				ans.pb(i+1);
				b.erase(b.begin()+i);
				found=true;
				break;
			}
		}
		if(!found){
			cout << -1 << endl;
			return 0;
		}
	}
	reverse(all(ans));
	for(auto&& e:ans) cout << e << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define N 1024
#define inf (1 << 27)
pair <int, int> v[N];
int d[N * 10];
int h, n, i, mn, j;

int main()
{
    cin >> h >> n;
    for (i = 0; i < n; ++i)
        cin >> v[i].first >> v[i].second;
    d[0] = 0;
    ++h;
    for (i = 1; i < h; ++i){
        mn = inf;
        for (j = 0; j < n; ++j){
            if (i - v[j].first > -1)
                mn = min(mn, d[i - v[j].first] + v[j].second);
            else
                mn = min(mn, v[j].second);
        }
        d[i] = mn;
    }
    cout << d[h - 1];
    return 0;
}


Measured memory_bytes: 256
import sys

def main():
    n = input()
    tree = MyBinaryTree(n)
    for i in range(n):
        cmd = map(str,raw_input().split())
        if cmd[0] == "insert":
            insert(tree,MyNode(int(cmd[1])))
        elif cmd[0] == "print":
            tree.inorder(tree.root)
            print ""
            tree.preorder(tree.root)
            print ""
        elif cmd[0] == "find":
            find(tree,int(cmd[1]))
    
    
class MyBinaryTree():
    def __init__(self,num_nodes):
        self.root = None

    def preorder(self,node):
        sys.stdout.write(" {}".format(node.key))
        l = node.left
        r = node.right
        if l is not None:
            self.preorder(l)
        if r is not None:
            self.preorder(r)    

    def inorder(self,node):
        l = node.left
        r = node.right
        if l is not None:
            self.inorder(l)
        sys.stdout.write(" {}".format(node.key))
        if r is not None:
            self.inorder(r)


def insert(T,z):
    y = None
    x = T.root
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y

    if y is None:
        T.root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z


def find(T,key):
    x = T.root
    while x is not None and key != x.key:
        if key < x.key:
            x = x.left
        else:
            x = x.right

    if x is not None:
        print "yes"
    else:
        print "no"

        
class MyNode():
    def __init__(self,key):
        self.key =key
        self.parent = None
        self.left = None
        self.right = None


if __name__ == "__main__":
    main()

Measured memory_bytes: 174472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   ll n;
   cin>>n;
   if (n%2)
   {
      cout<<0;
   }
   else
   {
      n/=2;
      ll k=5;
      ll ans=0;
      while (k<=n)
      {
         ans+=n/k;
         k*=5;
      }
      cout<<ans;
   }

}


Measured memory_bytes: 256
N, T = map(int, input().rstrip().split())
n = sorted([list(map(int, input().rstrip().split())) for i in range(N)], key=lambda x: x[1])
INF = float("inf")
cost = INF
for cn, tn in n:
    if T >= tn:
        cost = min(cost, cn)
    else:
        break

if cost == INF:
    print("TLE")
else:
    print(cost)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int const N=1e5+5,M=20;
ll n,sum[N][M+1],ans;
int x,m,nex[N][M+1];
void init(){
	 for(int i=0;i<m;++i){
        nex[i][0]=(ll)i*i%m;
        sum[i][0]=nex[i][0];
    }
}
int main(){
    cin>>n>>x>>m;
	ll ans=x;
	init();
    for(int i=1;i<=M;++i){
        for(int j=0;j<m;++j){
            nex[j][i]=nex[nex[j][i-1]][i-1];
            sum[j][i]=sum[j][i-1]+sum[nex[j][i-1]][i-1];
        }
    }
    n-=1;
    ll a=n/(1<<M),b=n%(1<<M);
	int now=x;
    for(int i=1;i<=a;++i){
        ans+=sum[now][M];
        now=nex[now][M];
    }
    for(int j=M-1;j>=0;--j) if(b>>j&1){
            ans+=sum[now][j];
            now=nex[now][j];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 28196
//   __      __       .__           .____________                   __________        __ ________   __                 
//  /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
//  \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//   \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//    \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//         \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define PI 3.14159265358979323846

using namespace std;

void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    ll inf = 1e18;
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    if(a[0] == 0)
    {
        cout << 0 << endl;
        return;
    }
    ll ans = a[0];
    for(ll i = 1; i < n; i++)
    {
        if((ld)(inf) / ans < a[i])
        {
            cout << -1 << endl;
            return;
        }
        ans *= a[i];
    }
    cout << ans << endl;
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

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

int main(){
int N;
  int c=0;
  int a=0;
  cin>>N;
  for(int i=1;i<=N;i++){
  for(int j=1;j<=i;j++){
  if(i%j==0) a++ ;
  }
  if(a==8 && i%2==1) c++;
    a=0;
  }
cout<<c<<endl;
return 0;}

Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

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

    int ans[55555];
    for(int i=0;i<5555;i++){
        ans[i] = 0;
    }

    int isprime[55555];
    for(int i=0;i<55555;i++){
        isprime[i] = 1;
    }
    isprime[0] = 0;
    isprime[1] = 0;
    for(int i=2;i<=(int)sqrt(55555)+1;i++){
        if(isprime[i]==1){
            for(int j=i*2;j<55555;j+=i){
                isprime[j] = 0;
            }
        }
    }

    int i = 0;
    int count = 0;
    int tmp_sum = 0;

    while(i<=55555){
        i++;
        if(isprime[i]==1 && i % 5 == 1){
            ans[count] = i;
            count++;
            if(count == N){
                for(int j=0;j<N-1;j++){
                    cout << ans[j] << ' ';
                }
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b == c || b + c == a || a + c == b) printf("Yes");
  else printf("No");
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,K,Q; cin >> N >> K >> Q;
    VI A(Q); REP(i,Q) cin >> A[i];
    VI n(N,0); REP(i,Q) n[A[i]-1]++;
    REP(i,N){
        if(K-(Q-n[i]) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>

char c;
long cnt, res;

int main() {
    while (scanf("%c", &c) != '\0') {
        if (c == 'B') {
            ++cnt;
        } else if ( c == 'W') {
            res += cnt;
        } else {
            printf("%ld\n", res);
            break;
        }
    }
    return 0;
}


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

int main(){

    char input[5];
    cin >> input;
    if (input[2] == input[3] && input[4] == input[5]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int getgcd(int n, int m) {
    int r;
    if (n > m) {
        int t = m;
        m = n;
        n = t;
    }
    while ((r = m % n) != 0) {
        m = n;
        n = r;
    }
    return n;
}

void solve(long long K){
    long long sum = 0;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                sum += getgcd(getgcd(i, j), k);
            }
        }
    }

    cout << sum << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(ll i=(n);i<(x);++i)
#define SORT(x) sort(x.begin(),x.end())
using ll = long long;

int main() {
	ll n, k; cin >> n >> k;
	vector<ll> a(n); rep(i, 0, n) cin >> a[i];

	map<ll, ll> mp; rep(i, 0, n) mp[a[i]]++;
	priority_queue<ll, vector<ll>, greater<ll>> num;
	for (auto x : mp) num.push(x.second);
	ll ans = 0, dif = mp.size() - k;
	while (dif > 0) {
		ans += num.top();
      	num.pop();
		dif--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 16500
#include<iostream>
#include<string>
using namespace std;
struct dice{
    int a[6];
    void b(char c){
        int d;
        if(c=='N'){
            d=a[0];
            a[0]=a[1];
            a[1]=a[5];
            a[5]=a[4];
            a[4]=d;
        }
        if(c=='W'){
            d=a[0];
            a[0]=a[2];
            a[2]=a[5];
            a[5]=a[3];
            a[3]=d;
        }
        if(c=='E'){
            d=a[0];
            a[0]=a[3];
            a[3]=a[5];
            a[5]=a[2];
            a[2]=d;
        }
        if(c=='S'){
            d=a[0];
            a[0]=a[4];
            a[4]=a[5];
            a[5]=a[1];
            a[1]=d;
        }
        if(c=='R'){
            d=a[1];
            a[1]=a[2];
            a[2]=a[4];
            a[4]=a[3];
            a[3]=d;
        }
    }
    int top(){
        return a[0];
    }
    int right(){
        return a[2];
    }
    int left(){
        return a[3];
    }
    int front(){
        return a[1];
    }
};
bool same(dice a1,dice a2){
    for(int i=0;i<6;i++) if(a1.a[i]!=a2.a[i]) return false;
    return true;
}
int main(){
    dice e[100];
    int n;cin  >> n;
    for(int j=0;j<n;j++)
        for(int i=0;i<6;i++)
            cin >> e[j].a[i];
        
        
    bool ff=true;
    bool f=false;
    for(int k=0;k<n-1;k++){
        for(int l=k+1;l<n;l++){
            bool f=false;
            for(int i=0;i<4;i++){
        e[l].b('R');
        for(int j=0;j<4;j++){
            e[l].b('N');
            if(same(e[k],e[l])) f=true;
        }
            }
            e[l].b('E');
            for(int j=0;j<4;j++){
        e[l].b('N');
        if(same(e[k],e[l])) f=true;
            }
            
            e[l].b('W');
            e[l].b('W');
            for(int j=0;j<4;j++){
        e[l].b('N');
        if(same(e[k],e[l])) f=true;
            }
            if(f) ff=false;
        }
    }
    
    cout << (ff?"Yes":"No") << endl;
    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  int n,k,count,a,ans,sum,t;
  cin>>n;
  sum=0;
  rep(i,n){
    sum+=i;
    if(sum>=n){
      t=i;
      break;
    } 
  }
  //cout<<t;
  while(n>0){
    cout<<t<<endl;
    n-=t;
    t=min(t-1,n);
  }

}

Measured memory_bytes: 256