akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.math.BigInteger
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlin.math.sqrt

val MOD = 1_000_000_007L

fun factorize(a: Long): List<Pair<Long, Int>> {
  val res = mutableListOf<Pair<Long, Int>>()
  var x = a
  var i = 2L
  while(i * i <= x) {
    var cnt = 0
    while (x % i == 0L) {
      cnt++
      x /= i
    }
    if (cnt > 0) res += Pair(i, cnt)
    i++
  }
  if (x > 1) res += Pair(x, 1)
  return res
}
class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = nl()
    val fac = factorize(N)
    var cnt = 0
    for ((_, size) in fac) {
      debug{"size:$size"}
      var x = size
      var i = 1
      while(i <= x) {
        cnt++
        x -= i++
      }
    }
    out.println(cnt)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  int v[4];
  rep(i, 4) v[i] = (int)(s[i] - '0');

  char ch[] = {'+', '-'};
  rep(i, 2) rep(j, 2) rep(k, 2) {
    int tmp = v[0];
    tmp += (i == 0 ? v[1] : -v[1]);
    tmp += (j == 0 ? v[2] : -v[2]);
    tmp += (k == 0 ? v[3] : -v[3]);
    if (tmp == 7) {
      cout << v[0] << ch[i] << v[1] << ch[j] << v[2] << ch[k] << v[3] << "=7"
           << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};

signed main(){
	int n,T;
	cin>>n>>T;
	vector<int> t(n);
	rep(i,n) cin>>t[i];
	int ans=T,last=T;
	rep(i,1,n){
		if(last-T<=t[i]&&t[i]<last){ 
			ans+=t[i]+T-last;
			last=t[i]+T;
		}
		else if(t[i]<last) continue;
		else{
			ans+=T;
			last=t[i]+T;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  string N;
  cin >> N;

  long N_int;
  N_int = stol(N);

  int N_sum;
  for(int i=0; i < N.length(); ++i){
    N_sum += stoi(N.substr(i,1));
  }

  if(N_int % N_sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

int main(){
int a,b,c;
cin>>a>>b>>c;
int flg=0;
for(int i=0;i<=b;i++){
	if(a*i%b==c)flg=1;
	}
	if(flg)puts("YES");
	else puts("NO");
}


Measured memory_bytes: 256
n=int(input())
wl={}
for i in range(n):
    w=input()
    if w not in wl:
        wl[w]=0
    wl[w]+=1
wm=max(wl.values())
wl3=sorted(wl.items())
for i in range(len(wl3)):
    if wl3[i][1]==wm:
        print(wl3[i][0])

Measured memory_bytes: 139504
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2


int N, A[202020], B[202020];
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> A[i];

	for (int i = N; i >= 1; i--) {
		int other = 0;
		for (int j = 2 * i; j <= N; j += i)other += B[j];
		B[i] = (other%2 != A[i]) ? 1 : 0;
	}

	vector<int>ans;
	for (int i = 1; i <= N; i++)if (B[i])ans.pb(i);
	int M = ans.size();
	puts(M);
	fore(x, ans)cout << x << " ";
	if(ans.size())cout << endl;

	return 0;
}


Measured memory_bytes: 3064
from itertools import accumulate
N, X = map(int, input().split())
P = list(accumulate([1]*(N+1), lambda acc,x: acc*2+1))
A = list(accumulate([1]*(N+1), lambda acc,x: acc*2+3))
ans = 0
for n in range(N-1, -1, -1):
    if X >= 2 * A[n] + 2:
        X -= 2 * A[n] + 2
        ans += 2 * P[n] + 1
    elif X >= A[n] + 2:
        X -= A[n] + 2
        ans += P[n] + 1
    elif X >= A[n] + 1:
        X -= A[n] + 1
        ans += P[n]
    elif X >= 1:
        X -= 1
    else:
        break
print(ans)

Measured memory_bytes: 3064
N = int(input())
P = [float(i) for i in input().split()] 
 
dp = [[0 for i in range(N+1)] for j in range(N+1)]
dp[0][0] = 1
 
for i in range(1,N+1):
    for j in range(0,i+1):
        if j == 0:
            dp[i][j] = dp[i-1][j] * (1-P[i-1])
        elif j == i:
            dp[i][j] = dp[i-1][j-1] * P[i-1]
        else:
            dp[i][j] = dp[i-1][j]*(1-P[i-1]) + dp[i-1][j-1]*P[i-1]
print(sum(dp[-1][N//2 + 1:]))

Measured memory_bytes: 261512
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  auto r = -1;
  foreach (i; 1..11) {
    if (!ask(10L^^i)) {
      r = i;
      break;
    }
  }

  if (r == -1) {
    foreach (i; 1..11) {
      if (ask(10L^^i-1)) {
        writeln("! ", 10L^^(i-1));
        return;
      }
    }
  }

  auto mi = 10L^^(r-1), ma = 10L^^r-1;
  while (ma-mi > 1) {
    auto c = (ma+mi)/2;
    if (ask(c*10)) ma = c;
    else           mi = c;
  }

  writeln("! ", ask(mi*10) ? mi : ma);
}

auto ask(long n)
{
  writeln("? ", n);
  stdout.flush();
  string s; readV(s);
  return s == "Y";
}


Measured memory_bytes: 716
from sys import stdin

N = int(input())

dic = {}
lis = [[0] * 19 for i in range(19)]
ans = 0

for loop in range(N):

    S = stdin.readline()
    S = S[:-1]

    if "." not in S:
        num = int(S) * (10**9)
    else:
        x,y = S.split(".")
        yy = int(y) * (10**(9-len(y)))
        xx = int(x) * 10**9
        num = xx+yy
    #print (num)

    two = 0
    five = 0
    if num == 0:
        continue
    while num % 2 == 0:
        num //= 2
        two += 1
    while num % 5 == 0:
        num //= 5
        five += 1

    for i in range(19):
        for j in range(19):
            if i+two >= 18 and j+five>=18:
                ans += lis[i][j]
    lis[min(18,two)][min(18,five)] += 1
    #lis[two][five] += 1

print (ans)
    
    
    
        


Measured memory_bytes: 68832
M, D = (int(i) for i in input().split())

days = 0

for m in range(1, M+1):
    for d in range(1, D+1):
        d1 = d % 10
        d2 = d // 10
        if d1 >= 2 and d2 >= 2 and d1*d2 == m:
            days += 1

print(days)

Measured memory_bytes: 3060
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l;
ll num,ans,sum,ok,ng;
ll x[500005],y[500005],z[500005];
P table[500005];
char s[500005],t[500005],u[500005];
bool dame,flag;

int main(){
	cin >> n ;
	for(i=0;i<n;i++){
		cin >> a >> b;
		table[i] = P(a+b,a-b);
	}
	sort(table,table+n);
	for(i=n-1;i>=0;i--){
		a = table[i].first;
		b = table[i].second;
		if(num % 2 == 0){
			ans += (a + b) / 2;
		}else{
			ans -= (a - b) / 2;
		}
		num ++;
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 26880
def isDivisor?(val, divNum)
  if val % divNum != 0 then
    return false
  end
  return true

end

a, b, c = gets().chomp.split.map(&:to_i)
con = 0

for i in a..b do
  if isDivisor?(c, i) then
    con += 1
  end
end

puts con


Measured memory_bytes: 8900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main
{

  final static int[] WEIGHT =
  { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready())
    {
      final int num = Integer.parseInt(input.readLine());

      System.out.println(solver(num));
    }

  }

  private static String solver(int num)
  {
    final char[] bitFlag = Integer.toBinaryString(num).toCharArray();
    List<String> stringList = new ArrayList<>(bitFlag.length);

    int count = 0;
    for (int i = bitFlag.length - 1; i >= 0; i--)
    {
      if (bitFlag[i] == '1')
      {
        stringList.add(String.valueOf(WEIGHT[count]));
      }
      count++;
    }
    return String.join(" ", stringList);
  }
}

Measured memory_bytes: 24120
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)





int main() {
	ll n, X,ans;
	in(n);
	in(X);

	vll x(n+1);
	rep(i, 0, n) {
		in(x[i]);
	}
	x[n] = X;

	sort(x.begin(), x.end());

	ans = abs(x[1] - x[0]);
	rep(i, 1, n) {
		ans = gcd(ans, abs(x[i + 1] - x[i]));
	}

	outn(ans);

	return 0;

}


Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline()
def inpl(): return [int(i) for i in input().split()]

N, L, T = inpl()
Ant = []
ctr = 0
for _ in range(N):
    X, W = inpl()
    Ant.append((X + T*(3-2*W))%L)
    ctr += (X + T*(3-2*W))//L
Ant.sort()
ctr %= N
ans = Ant[ctr:] + Ant[:ctr]
for i in ans:
    print(i)

Measured memory_bytes: 8952
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	string s;
	cin>>s;
	int l=s.size();
	int ans;
    ans=l/2;
    string s1,s2;
    
	if (l%2==0){
		s1=s.substr(0,l/2);
		s2=s.substr(l/2,l/2);
		
	//	cout<<s1<<endl<<s2<<endl;
		char c=s2[0];
		for (int i=0;i<l/2;i++){
			if (s2[i]==c&&c==s1[l/2-i-1]) {
				ans++;
			}
			else{
				break;
			}
		}
	
		cout<<ans<<endl;
	}else{
		ans++;
		s1=s.substr(0,l/2);
		s2=s.substr(l/2+1,l/2);
		//cout<<s1<<endl<<s2<<endl;
		
		if (s[l/2]!=s[l/2-1]||s[l/2]!=s[l/2+1]) cout<<ans<<endl;
		else{
			char c=s[l/2];
			for (int i=0;i<l/2;i++){
				if (s2[i]==c&&c==s1[l/2-i-1]) {
					ans++;
				}
				else{
					break;
				}
			}
			
			
			cout<<ans<<endl;
		}
	} 

}


/*
l        k
1        1
2        1

3              111   3
               110   2
			   101   2
			   
			   
1        000     0     000        0
			   
			   
k=l        改不了 
k=l-1      改得了头尾  
k=l-2      改得了头尾，改得了 第二倒二
k=l-3       



*/

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[] arr = new int[3];

		do {
			for(int i = 0; i < 3; i++) {
				arr[i] = sc.nextInt();
			}

			int m = arr[0];
			int f = arr[1];
			int r = arr[2];

			int s = m + f;

			if (m == -1 && f == -1 && r == -1) {
				break;
			} else if (m == -1 || f == -1){
				System.out.println("F");
			} else if (s >= 80){
				System.out.println("A");
			} else if (s >= 65 && s < 80 ){
				System.out.println("B");
			} else if (s >= 50 && s < 65 ){
				System.out.println("C");
			} else if (s >= 30 && s < 50 ){

				if (r >= 50) {
					System.out.println("C");
				} else {
					System.out.println("D");
				}

			} else if ( s < 30 ){
				System.out.println("F");
			}



		}while(true);

		sc.close();
	}

}


Measured memory_bytes: 26304
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    tmp = input.split("\n");
    tmp1 = tmp[0].split(" ");
    N = Number(tmp1[0]);
    K = Number(tmp1[1]);
    h = tmp.slice(1, N+1);
    h = h.map(Number);
    h.sort((n,m)=> n-m);
    min = 10000000000;

    for(i=0 ; i< N-K+1; i++){
        min = Math.min(min, h[i+K-1]-h[i]); 
    }
    console.log(min);
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 28752
N=int(input())
AB=[list(map(int,input().split())) for i in range(N)]
AB.sort(key=lambda x:x[1])
time=0
for i in range(N):
    time+=AB[i][0]
    if time>AB[i][1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 47212
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    if( s.size() < 4 ) cout << "No";
    else {
        if( s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I' ) 
            cout << "Yes";
        else cout << "No";
    }
    cout << endl;
    return 0;
}


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

def binary_search_int(ok, ng, solve):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(mid):
            ok = mid
        else:
            ng = mid
    return ok, ng

##############################################################

def solve(x):
    """ ある点 x を境にして True と False が二分されるような関数"""
    return N - K*x >= 0

N, K = map(int, input().split())

a, b = binary_search_int(0, 10**18, solve)
print(min(abs(N-a*K), abs(N-b*K)))

Measured memory_bytes: 80144
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  ll a;
  string b;
  cin >> a >> b;
  
  int n = b.size();
  
  REP(i,n){
	if(b[i] == '.'){
      b.erase(i,1);
    }
  }
  
  int bi = atoi(b.c_str());
  
  ll c = a * bi / 100;
  cout << c << endl;
  
}


Measured memory_bytes: 3624
n = input()
ls = list(map(int,[ _ for _ in n ]))
if int(n) <= 9:
    print(int(n))
elif sum(ls[1:]) / (len(ls)-1) == 9:
    print(sum(ls))
else:
    print(ls[0]-1 + 9*(len(ls)-1))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>

using namespace std;

void outPut(int Array[],char suit){
    for(int i = 1; i <= 13; i++){
        if(Array[i] == 0) printf("%c %d\n",suit,i);
    }
}

int main(){
    int n, S[14], H[14], D[14], C[14], buf;
    char suit[2];
    cin >> n;
    for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
    for(int i = 0; i < n; i++){
        scanf("%s %d", suit, &buf);
        
        switch (suit[0])
        {
            case 'S':
                S[buf] = 1;
                break;
            case 'H':
                H[buf] = 1;
                break;
            case 'D':
                D[buf] = 1;
                break;
            case 'C':
                C[buf] = 1;
                break;
        }
    } 
    outPut(S,'S');
    outPut(H,'H');
    outPut(C,'C');
    outPut(D,'D');
}


Measured memory_bytes: 3200
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = String.valueOf(n).toCharArray();
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] == '9') {
				arr[i] = '1';
			} else {
				arr[i] = '9';
			}
		}
		System.out.println(Integer.valueOf(new String(arr)));
	}
}

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)q

int dp[114514][3];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b, c;
	cin>>n;
	REP(i, n){
		cin>>a>>b>>c;
		dp[i+1][0]=max(dp[i][1]+a, dp[i][2]+a);
		dp[i+1][1]=max(dp[i][0]+b, dp[i][2]+b);
		dp[i+1][2]=max(dp[i][0]+c, dp[i][1]+c);
	}
	int ans=0;
	REP(i, 3){
		CHMAX(ans, dp[n][i]);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main(void)
{
    int a, b;
    cin >> a >> b;
    if (a % 2 == 1 && b % 2 == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int N, K, h[100000], dp[100000];

int main()
{
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", h + i);
    }
    for (int i = 1; i < N; i++)
    {
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        for (int k = 2; k <= K && i-k >= 0; k++)
        {
            dp[i] = min(dp[i-k] + abs(h[i] - h[i-k]), dp[i]);
        }
    }
    printf("%d\n", dp[N-1]);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main(void)
{
long long N, index, sum;

  scanf("%lld", &N);
  sum = 0;
  for (index = 1; index <= N; ++index) {
    if (index % 3 == 0) continue;
    if (index % 5 == 0) continue;
    sum += index;
  }
  printf("%lld\n", sum);
    
  return 0;
}


Measured memory_bytes: 1720
#include <stdio.h>

int main(void)
{
	int i, n;
	int a[100];

	scanf("%d", &n);

	for (i = 0; i < n; i++)
		scanf("%d", a + i);

	for (i = 0; i < n; i++)
		printf("%s%d", i ? " " : "", a[n - i - 1]);

	printf("\n");

	return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n , ac = 0, wa = 0, tle = 0, re = 0 ;
  cin>>n;
  string C[n];
  for(int i = 0; i < n; i++){
    cin>>C[i];
    if(C[i] == "AC")ac++;
    if(C[i] == "WA")wa++;
    if(C[i] == "TLE")tle++;
    if(C[i] == "RE")re++;

  }
  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 6752
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= b) {
        rep(i,b) cout << a;
        cout << endl;
    } else {
        rep(i,a) cout << b;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;


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

ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}

ll f(ll x, ll C, ll D){
    if(x == 0) return 0;

    return x - (x/C + x/D - x/lcm(C, D));
}

int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << f(B, C, D) - f(A-1, C, D) << endl;
}


Measured memory_bytes: 256
open Str

let read_list f =
  split (regexp " +") (read_line ()) |> List.map f

let print_array a =
  Array.iteri (fun i x -> if i > 0 then print_string " " else (); print_int x) a; print_newline ()
                                                                                    
let () =
  let n = read_int () in
  let ar = read_list int_of_string |> Array.of_list in
  let cnt = ref 0 in
  let merge a left mid right =
    let n1 = mid - left in
    let n2 = right - mid in
    let lar = Array.init (n1+1) (fun i -> if i = n1 then 1000000001 else a.(left + i)) in
    let rar = Array.init (n2+1) (fun i -> if i = n2 then 1000000001 else a.(mid + i)) in
    let rec loop i j k =
      if k = right then ()
      else begin
          incr cnt;
          if lar.(i) <= rar.(j) then begin a.(k) <- lar.(i); loop (i+1) j (k+1) end
          else begin a.(k) <- rar.(j); loop i (j+1) (k+1) end
        end
    in loop 0 0 left
  in
  let rec merge_sort a left right =
    if left + 1 >= right then ()
    else begin
        let mid = (left + right) / 2 in
        merge_sort a left mid;
        merge_sort a mid right;
        merge a left mid right
      end
  in
  merge_sort ar 0 n;
  print_array ar;
  print_endline @@ string_of_int !cnt

Measured memory_bytes: 64532
import sys

S = input()
T = input()

result = sys.maxsize

for i in range(len(S)-len(T)+1): 
  tmp = 0
  for j in range(len(T)): 
    if T[j] != S[i+j]: 
      tmp += 1
  if tmp < result: 
    result = tmp
    
print(result)

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s;
  cin >> s;
  ll y=0,m=0;
  y += (s[0]-'0')*10 + (s[1]-'0');
  m += (s[2]-'0')*10 + (s[3]-'0');
  if(0<y && y<=12 && 0<m && m<=12){
    cout << "AMBIGUOUS" << endl;
    return 0;
  }
  if(0<m && m<=12){
    cout << "YYMM" << endl;
    return 0;
  }
  if(0<y && y<=12){
    cout << "MMYY" << endl;
    return 0;
  }
  cout << "NA" << endl;
  return 0;
}


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

int main() {
  int n,kai = 0;
  double ans = 0;
  cin >> n;
  vector<vector<int>> a(n,vector<int>(2));
  vector<vector<double>> b(n,vector<double>(n,0));
  kai = 1;
  for(int i = 1; i <= n; i++) {
    kai *= i;
  }
  rep(i,n) {
    cin >> a[i][0] >> a[i][1];
  }
  rep(i,n) {
    rep(j,n) {
      int c = (a[i][0]-a[j][0])*(a[i][0]-a[j][0]) + (a[i][1]-a[j][1])*(a[i][1]-a[j][1]);
      b[i][j] = sqrt(c);
    }
  }
  rep(i,n){
    rep(j,n) {
      ans += b[i][j]*kai/n;
    }
  }
  ans = ans/kai;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;
 
int n;
vector<int>G[MAX];
int color[MAX];
 
void dfs(int r, int c) {
    stack<int>S;
    S.push(r);
    color[r] = c;
    while (!S.empty()) {
        int u = S.top(); S.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}
 
void assignColor() {
    int id = 1;
    for (int i = 0; i < n; i++)color[i] = NIL;
    for (int u = 0; u < n; u++) {
        if (color[u] == NIL)dfs(u, id++);
    }
}
int main() {
    int s, t, m, q;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  lli x;
  cin>>x;
  lli y;
  v(p2) a;
  rep(i,200){
      a.pb({i*1ll*i*1ll*i*1ll*i*1ll*i,i});
      a.pb({-1*i*1ll*i*1ll*i*1ll*i*1ll*i,-i});
  }
    rep(i,a.size())
        rep(j,a.size()){
            if(a[i].fi-a[j].fi==x){
                cout<<a[i].se<<" "<<a[j].se<<endl;
               return 0;
            }

        }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <tuple>
using namespace std;
int n, p[200009]; long long sum = 0;
int main() {
	cin >> n; n *= 2; for (int i = 0; i < n; i++)cin >> p[i]; sort(p, p + n);
	for (int i = 0; i < n; i++) {
		sum += 1LL * i*p[i];
	}
	printf("%.15Lf\n", 1.0L*sum / (n - 1));
	return 0;
}

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

using tp = tuple<int,int,int>;

int main() {
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  
  int ans = 0;
  int a1 = v[1] - v[0];
  
  if (a1%2 == 0) ans = a1 / 2;
  else {
    ans = (a1+1) / 2 + 1;
  }
  
  ans += v[2] - v[1];
  
  cout << ans << endl;
}

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

using namespace std;

vector< long > divisor(long n) {
  vector< long > ret;
  for(long 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 main(){
    long N, K;
    cin >> N >> K;
    long A[500];
    long sum = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
    }
    vector<long> v = divisor(sum);
    long ans = 1;
    for(int i = 0; i < v.size(); i++) {
        long m = v[i];
        vector<long> r;
        for(int j = 0; j < N; j++){
            r.push_back(A[j]%m);
        }
        sort(r.begin(), r.end());
        long sum_p = 0;
        long sum_n = 0;
        for(int j = 0; j < N; j++){
            sum_n += r[j];
        }
        if(sum_n <= K){
            ans = m;
            continue;
        }
        for(int j = N-1; j >= 0; j--){
            sum_n -= r[j];
            sum_p += (m-r[j]);
            if(sum_n <= K && sum_p <= K){
                ans = m;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if(m==-1 && f==-1 && r==-1){
                break;
            }

            if(m==-1 || f==-1){
                System.out.printf("F\n");
            }else if(m+f>=80){
                System.out.printf("A\n");
            }else if(m+f>=65){
                System.out.printf("B\n");
            }else if(m+f>=50){
                System.out.printf("C\n");
            }else if(m+f>=30){
                if(r>=50){
                    System.out.printf("C\n");
                }else{
                    System.out.printf("D\n");
                }
            }else{
                System.out.printf("F\n");
            }
        }
    }
}


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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int res = 0;
    for (int i = 0; i < n - 2; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            res++;
        }
    }
    cout << res << "\n";
    return 0;
}


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

multiset<long long> candidate;
long long n, a[300010], pref[300010], suff[300010], ans = -1e18;

int main() {
    scanf("%lld", &n);
    for(int i = 1; i <= 3*n; i++) scanf("%lld", &a[i]);
    for(int i = 1; i <= n; i++) {
        candidate.insert(a[i]);
        pref[n] += a[i];
    }
    for(int i = n+1; i <= 2*n; i++) {
        candidate.insert(a[i]);
        pref[i] = pref[i-1] + a[i] - (*candidate.begin());
        candidate.erase(candidate.begin());
    }
    candidate.clear();
    for(int i = 3*n; i > 2*n; i--) {
        candidate.insert(a[i]);
        suff[2*n+1] += a[i];
    }
    for(int i = 2*n; i > n; i--) {
        candidate.insert(a[i]);
        suff[i] = suff[i+1] + a[i] - (*prev(candidate.end()));
        candidate.erase(prev(candidate.end()));
    }
    for(int i = n; i <= 2*n; i++) ans = max(ans, pref[i] - suff[i+1]);
    printf("%lld", ans);
}


Measured memory_bytes: 10752
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		in.close();
		Map<Integer,Integer> map = new HashMap<>();
		for(int i=2;i<=n;i++) {
			int num = i;
			for(int j=2;j*j<=num;j++) {
				if(j*j==num) {
					map.put(j, map.get(j).intValue()+2);
					num = 1;
				}else {
					while(num%j==0) {
						num /= j;
						if(map.containsKey(j)) {
							map.put(j, map.get(j).intValue()+1);
						}else {
							map.put(j, 1);
						}
					}
				}
			}
			if(num>1) {
				if(map.containsKey(num)) map.put(num, map.get(num).intValue()+1);
				else map.put(num, 1);
			}
		}
		int up74 = 0;
		int up24 = 0;
		int up14 = 0;
		int up4 = 0;
		int up2 = 0;
		for(int key:map.keySet()) {
			int val = map.get(key);
			if(val>=74) up74++;
			if(val>=24) up24++;
			if(val>=14) up14++;
			if(val>=4) up4++;
			if(val>=2) up2++;
		}
		
		int ans = 0;
		ans += up74;
		ans += up24*(up2-1);
		ans += up14*(up4-1);
		ans += (up2-2)*up4*(up4-1)/2;
		System.out.println(ans);
	}

}


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

int main(){

	for(int i = 0;i < 3;i++){
		int a1,b1,c1,a2,b2,c2;
		cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
		int a = a2-a1,b = b2-b1,c = c2-c1;
		if(c < 0)c = 60+c,b--;
		if(b < 0)b = 60+b,a--;
		printf("%d %d %d\n",a,b,c);
	}
	return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdlib>
#include <cmath>
#define endl '\n'
#define ll long long

using namespace std;

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

        int N, K; cin >> N >> K;
        vector<int> vec;
        for(int i = 0; i < N; i++)
        {
                int temp; cin >> temp;
                vec.push_back(temp);
        }
        sort(vec.begin(), vec.end(), greater<int>());
        int acc = 0;
        for(int i = 0; i < K; i++)
                acc += vec[i];
        cout << acc;


        return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] l = new int[n];
		for(int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		
		Arrays.sort(l);
		int ans = 0;
		for(int i = 1; i < n; i++) {
			int b = l[i];
			for(int is = 0; is < i; is++) {
				int a = l[is];
				for(int il = i; il < n; il++) {
					int c = l[il];
					if(a != b && b != c && c != a) {
						if(b > c - a && b < a + c) {
							ans++;
						}
					}
				}
			}
			
		}
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 36468
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

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

  int N; cin >> N;

  bool can = false;
  reps(i,1,10) {
    reps(j, 1, 10) {
      if(i*j == N) can = true;
    }
  }

  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007
#define MAX 1000000000000000000

int main(void)
{
    ll N;
    cin >> N;
    ll ans = 1;

    vector<ll> A(N);
    REP (i, N) {
        cin >> A[i];
        if ( A[i] == 0 ) {
            cout << 0 << endl;
            return 0;
        }
    }

    REP (i, N) {
        if ( ans <= MAX / A[i]) {
            ans *= A[i];
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
    
    return 0;
}


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

int main(){
  int N; cin>>N;
  string S,T;
  cin>>S>>T;
  for(int i=0;i<N-1;i++){
    if(S[i] == '@' || S[i] == '!') continue;
    if(S[i] == S[i+1]){
      S[i] = '@'; // yoko
      S[i+1] = '!'; // tobasu
    }
    else S[i] = '.'; // tate
  }
  if(S[N-1] != '@' && S[N-1] != '!') S[N-1] = '.';
  ll dp[100] = {};
  if(S[0] == '@') dp[0] = 6;
  else dp[0] = 3;
  for(int i=1;i<N;i++){
    if(S[i] == '!') dp[i] = dp[i-1];
    else if(S[i-1] == '.'){
      if(S[i] == '.') dp[i] = dp[i-1] * 2 % MOD;
      else dp[i] = dp[i-1] * 2 % MOD;
    }
    else{
      if(S[i] == '.') dp[i] = dp[i-1];
      else dp[i] = dp[i-1] * 3 % MOD;
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long p[8][8]={{0,300,500,600,700,1350,1650},
{6,0,350,450,600,1150,1500},
{13,7,0,250,400,1000,1350},
{18,12,5,0,250,850,1300},
{23,17,10,5,0,600,1150},
{43,37,30,25,20,0,500},
{58,52,45,40,35,15,0}};
long s,e,hs,ms,he,me,a,b,c;
while(cin>>s){
if(s==0)break;
cin>>hs>>ms>>e>>he>>me;
if(s>e){a=s;s=e;e=a;}
hs*=60;hs+=ms;
he*=60;he+=me;
a=(hs-1050)*(hs-1170);
b=(he-1050)*(he-1170);
if(a<=0||b<=0)c=1;else c=0;
if(p[e-1][s-1]<=40&&c==1)cout<<((p[s-1][e-1]/50+1)/2)*50<<endl;
else cout<<p[s-1][e-1]<<endl;
}
return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c;
cin >> a >> b >> c;
//a += b ;
//a += c;
if(a==b+c || b==a+c || c ==a+b)
    cout << "Yes" << endl;
else cout << "No" << endl;

  }


Measured memory_bytes: 3540
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

ans = []
for i in range(n):
    ans.append(sum(a1[:i]) + a1[i] + a2[i] + sum(a2[i+1:]))
    
print(max(ans))

Measured memory_bytes: 3060
#import <Foundation/Foundation.h>
typedef long long Int;
int compare(const void *a, const void *b){
	return *((Int*)b)-*((Int*)a);
}
int main() {
	int n;
	scanf("%d",&n);
	Int *v=(Int*)malloc(sizeof(Int)*n);
	for(int i=0;i<n;i++){
		scanf("%lld",v+i);
	}
	qsort(v, n, sizeof(Int), compare);
	long double ans=0;
	for(long i=0;i<n;i++){
		ans += ((long double)v[i])/(MIN(2LL<<i,1LL<<(n-1)));
	}
	printf("%.16Lf\n",ans);
}

Measured memory_bytes: 7120
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	int flag=0;
	cin>>s1>>s2;
	for (char ch='a';ch<='z';ch++)
	{
		string temp=s1+ch;
		if (temp==s2)   
		{
			flag=1;
			break;
		}
	}
	if (flag)   cout<<"Yes";
	else   cout<<"No";
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; 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 PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

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; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

struct UnionFind {
	int s, num; // [0, s) の s 個の要素がある。num は非空集合の個数。
	vector<vector<int>> v;
	vector<int> find;
	
	UnionFind() { s = 0; }
	UnionFind(int s) { init(s); }
	void init(int arg_s) {
		num = s = arg_s;
		v.clear();
		find.clear();
		inc(i, s) { v.PB({i}); find.PB(i); }
	}
	bool unite(int x, int y) {
		assert(inID(x, 0, s) && inID(y, 0, s));
		if(find[x] == find[y]) { return false; }
		num--;
		if(v[find[x]].size() > v[find[y]].size()) { swap(x, y); }
		int fx = find[x];
		for(auto && e: v[fx]) { v[find[y]].PB(e); find[e] = find[y]; }
		v[fx].clear();
		return true;
	}
};

// ----

int n, p[100000], m, x[100000], y[100000];

int main() {
	cin >> n >> m;
	inc(i, n) { cin >> p[i]; p[i]--; }
	inc(i, m) { cin >> x[i] >> y[i]; x[i]--; y[i]--; }
	
	UnionFind uf(n);
	inc(i, m) { uf.unite(x[i], y[i]); }
	
	int ans = 0;
	inc(i, n) {
		set<int> se;
		for(auto && e: uf.v[i]) { se.insert(p[e]); }
		for(auto && e: uf.v[i]) { ans += se.count(e); }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 15024
def mul(a, b, n, m)
  c = []
  for i in 0..(n-1)
    ai = a[i]
    c.push(dot(ai, b, m))
  end
  return c
end

def dot(x, y, m)
  dot_xy_array = []
  dot_xy = 0
  for i in 0..(m-1)
    dot_xy_array.push(x[i] * y[i])
  end
  dot_xy = 0
  dot_xy_array.each do |i|
    dot_xy += i
  end
  return dot_xy
end

def mul_matrix(arrayA, arrayB, n, m, l)
  mul_matrix_array = []
  for i in 0..(l-1)
    mul_matrix_array.push(mul(arrayA, arrayB[i], n, m))
  end
  return mul_matrix_array
end

input_nml_array = gets.chomp.split.map(&:to_i)
n = input_nml_array[0]
m = input_nml_array[1]
l = input_nml_array[2]
input_a_arrays = []
n.times do
  input_a_array = gets.chomp.split.map(&:to_i)
  input_a_arrays.push(input_a_array)
end
input_b_arrays = []
m.times do
  input_b_array = gets.chomp.split.map(&:to_i)
  input_b_arrays.push(input_b_array)
end
input_b_column_vector_array = []
for i in 0..(l-1)
  tmp = []
    for j in 0..(m-1)
      tmp.push(input_b_arrays[j][i])
    end
    input_b_column_vector_array.push(tmp)
end

answers = mul_matrix(input_a_arrays, input_b_column_vector_array, n, m, l)
for i in 0..(n-2)
  for j in 0..(l-2)
    print answers[j][i]
    print " "
  end
  print answers[l-1][i]
  print "\n"
end
for i in 0..(l-2)
  print answers[i][n-1]
  print" "
end
  print answers[l-1][n-1]
  print "\n"

Measured memory_bytes: 19228
#include<stdio.h>
int main()
{
    int n,m,b[100],x,y;
    scanf("%d%d",&n,&m);
    int a[100][100];
    for(x=0;x<n;x++)
    {
        for(y=0;y<m;y++)
            scanf("%d",&a[x][y]);
    }
    for(y=0;y<m;y++)
    {
        scanf("%d",&b[y]);
    }
    for(x=0;x<n;x++)
    {
        int sum=0;
        for(y=0;y<m;y++)
        {
            sum+=a[x][y]*b[y];
        }
        printf("%d\n",sum);

    }
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
typedef pair<int,int> P;
typedef vector<int> V;

int main(){
	while( 1 ){
		int a, b, n;
		cin >> a >> b;
		cin >> n;
		if( a == 0 && b == 0 ) break;
		vector< V > map( a, V(b));
		for( int i = 0; i < a; i++ ){
			for( int j = 0; j < b; j++ ){
				map[i][j] = 1;
			}
		}
		//input
		for( int i = 0; i < n; i++ ){
			int x, y;
			cin >> x >> y;
			map[x-1][y-1] = 0;
		}
		/*for( int i = 0; i < a; i++ ){
			for( int j = 0; j< b; j++ ){
				cout << map[i][j];
			}
			cout << endl;
		}*/
		int i, j;
		int way = 0;
		stack< P > st;
		st.push( P(0,0) );
		//search
		while( !st.empty() ){
			if( st.top() == P(a-1,b-1) ){
				way++;
				st.pop();
				if( st.empty() ) break;
			}
			i = st.top().first;
			j = st.top().second;
			st.pop();
			//cout << i << ' ' << j << endl;
			if( i+1 < a && map[i+1][j] == 1 ){
				//cout << i+1 << ' ' << j << endl;
				st.push( P(i+1,j) );
			}
			if( j+1 < b && map[i][j+1] == 1 ){
				//cout << i << ' ' << j+1 << endl;
				st.push( P(i,j+1) );
			}
		}
		//output
		cout << way << endl;
	}
}

Measured memory_bytes: 1220