akhauriyash/Code-Regression huggingface dataset:
/*  -*- coding: utf-8 -*-
 *
 * 2912.cc: Sum of QQ
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_S = 100000;

/* typedef */

/* global variables */

int ps[500], cs[MAX_S + 1];

/* subroutines */

int countp(int k) {
  int c = 0;
  for (int i = 1; ps[i] <= k; i++)
    if ((k - ps[i]) % i == 0) c++;
  return c;
}

/* main */

int main() {
  int s;
  scanf("%d", &s);

  int pn = 1;
  while ((ps[pn] = pn * (pn + 1) / 2) <= s) pn++;
  //printf("pn=%d:", pn);
  //for (int i = 1; i <= pn; i++) printf(" %d", ps[i]); putchar('\n');

  int cnt = 0;
  for (int x = 1; x <= s; x++)
    if (s % x == 0) {
      int y = s / x;
      if (! cs[x]) cs[x] = countp(x);
      if (! cs[y]) cs[y] = countp(y);
      cnt += cs[x] * cs[y];
      //printf("(%d,%d) = %dx%d\n", x, y, cs[x], cs[y]);
    }

  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 3288
n=int(input())
A=list(map(int,input().split()))
A.sort()
ans=0
plus,minus=0,0
for a in A:
    if a>=0:
        plus+=1
    elif a<0:
        minus+=1
if plus==0:
    plus=1
    minus=n-1
elif minus==0:
    minus=1
    plus=n-1
Ans=[]
if plus==1:
    Ans.append((A[-1],A[0]))
    tmp=A[-1]-A[0]
    for i in range(1,n-1):
        Ans.append((tmp,A[i]))
        tmp=tmp-A[i]
else:
    Ans.append((A[0],A[minus]))
    tmp=A[0]-A[minus]
    for i in range(minus+1,n-1):
        Ans.append((tmp,A[i]))
        tmp=tmp-A[i]
    Ans.append((A[-1],tmp))
    tmp=A[-1]-tmp
    for i in range(1,minus):
        Ans.append((tmp,A[i]))
        tmp=tmp-A[i]
print(tmp)
for a,b in Ans:
    print(a,b)

Measured memory_bytes: 63500
import math
(N, M) = map(int, input().split())

MAX_SQRT = int(math.sqrt(M))
prime_flag = [True] * (MAX_SQRT+1)
prime_dic = {}

prime_flag[0] = False
prime_flag[1] = False

for i in range(2, MAX_SQRT+1):
    mul = 2
    while True:
        p = i * mul
        if p > MAX_SQRT:
            break
        prime_flag[p] = False
        mul += 1

TMPM = M
for i in range(2, MAX_SQRT+1):
    if prime_flag[i]:
        while TMPM%i == 0:
            if i in prime_dic:
                prime_dic[i] += 1
            else:
                prime_dic[i] = 1
            TMPM = int(TMPM/i)

if TMPM > 1 or len(prime_dic) == 0:
    prime_dic[TMPM] = 1

max_mul = 1
def Rec(mul, p):
    global max_mul
    if M//mul < N:
        return

    if p >= len(prime_dic):
        if mul > max_mul:
            max_mul = mul
        return

    k = list(prime_dic.keys())[p]
    v = list(prime_dic.values())[p]
    for i in range(v+1):
        Rec(mul*(k**i), p+1)

Rec(1, 0)
print(max_mul)

    


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

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

vector<string> s;

int main() {
  int h, w;
  cin >> h >> w;
  string str;
  int jcount = 0;
  int count = 0;
  for (int i = 0; i < h; ++i) {
    cin >> str;
    jcount = 0;
    for (int j = 0; j != str.size(); ++j) {
      if (str.at(j) == '.') ++jcount;
    }
    if (jcount == str.size()) ++count;
    else s.push_back(str);
  }
  h -= count;

  for (int i = 0; i != s[0].size(); ++i) {
    count = 0;
    for (int j = 0; j < h; ++j) {
      if (s[j][i] == '.') ++count;
      else break;
    }
    if (count == h) {
      for (int j = 0; j < h; ++j) {
        s[j].erase(s[j].begin() + i);
      }
      --i;
    }
  }

  for (int i = 0; i < h; ++i) {
    cout << s[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
using namespace std;

typedef long long ll;
int a[100005];

int main()
{
    ll n;
    cin>>n;
    cout<<(n*(n-1))/2<<endl;
    return 0;
}
///*
//
//4 6 0
//0 1 2
//1 2 2
//1 3 1
//0 2 5
//1 3 3
//0 3 4
//
//
//
//*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);


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

  int n, m;
  cin >> n >> m;
  vector<P> edges;
  set<int> to_n;  // Nに繋がっている島
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    edges.push_back(P(a, b));
    if (b == n) to_n.insert(a);
  }

  bool flag = false;
  for (auto& p : edges) {
    if (p.first != 1) continue;
    if (to_n.count(p.second) != 0) flag = true;
  }

  if (flag) puts("POSSIBLE");
  else puts("IMPOSSIBLE");

  return 0;
}


Measured memory_bytes: 6512
(defun s_sum (s)
  (let ((ref 0))
    (loop for i across s do
          (incf ref (- (char-int i) 48)))
    ref))

(let ((n (read-line)))
  (format t "~A~%" (if (= 0 (rem (parse-integer n) (s_sum n))) "Yes" "No")))


Measured memory_bytes: 14304
#include <iostream>

using namespace std;

int main(void) {
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); ++i) {
		if (str[i] == '1') {
			cout << 9;
		}
		else {
			cout << 1;
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
N,H=map(int,input().split())

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

amax=max(A)
B.sort(reverse=True)

if amax>=B[0]:
    print((H-1+amax)//amax)
    exit()

cnt=0

for i in  range(N):
    if B[i]>amax:
        H-=B[i]
        cnt+=1
        if H<=0:
            print(cnt)
            exit()
    else:
        break

print(cnt+(H-1+amax)//amax)

Measured memory_bytes: 11352
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

const int N=100010;
int a[N];
char s[N];

int main() {
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++) a[i]=s[i]-'0';
	if(a[n]||!a[1]) return puts("-1"),0;
	if(n==2) return printf("1 2\n"),0;
	for(int i=1;i<=n/2;i++) {
		if(a[i]^a[n-i]) return puts("-1"),0;
	}
	vector<int> v;
	for(int i=1;i<=n;i++) {
		if(a[i]) v.pb(i);
	}
	for(int i=1;i<(int)v.size();i++) {
		for(int j=v[i]-1;j>v[i-1];j--) {
			printf("%d %d\n",v[i],j);
		}
		printf("%d %d\n",v[i],v[i-1]);
	}
	printf("%d %d\n",n,v.back());
	return 0;
}


Measured memory_bytes: 2424
#include<iostream>
using namespace std;
int main()
{
	int x=1,a,b[10001],c=0;
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		cin>>b[i];
		while(b[i]%2==0)
	    {
		    b[i]/=2; c++;
    	}
	}
	cout<<c;
}

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


int main() {
    long long N; cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
 
    long long ans = 0;
    long long d = 10;
    while (d <= N) {
        ans += N / d;
        d *= 5;
    }

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

Measured memory_bytes: 256
#include<stdio.h>
#include <math.h>

typedef long long ll;

int main() {
	char n[200005];
	scanf("%s", n);
	
	int d_sum = 0;
	for (int i = 0; n[i] != '\0'; i++) {
		d_sum += (n[i] - '0');
		d_sum %= 9;
	}
	if (d_sum == 0) {
		printf("Yes");
	} else {
		printf("No");
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 1928
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	double a[n+1];
	a[0]=0;
	double ans=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]=(a[i]+1)/2;
		a[i]+=a[i-1];
		if(i>=m)
			ans=max(ans,a[i]-a[i-m]);
	}
	cout<<fixed<<setprecision(12)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
s = input()
search = ['dream', 'dreamer', 'erase', 'eraser']
index = len(s)
while index > 0:
  found = False
  for i in search:
    if index < len(i):
      continue
    if s[index-len(i):index] == i:
      found = True
      index -= len(i)
      break
  if not found:
    print('NO')
    exit()
print('YES')

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;
FILE *fp;

//#define MYLOCAL

void init() {
#ifdef MYLOCAL
    fp = freopen("/Users/sekiya9311/Documents/comp_programming/comp_programming/in.txt", "r", stdin);
    if (fp == NULL) assert(false);
#endif
    
}

void last() {
#ifdef MYLOCAL
    fclose(fp);
#endif
    exit(0);
}

const int MAX = 1010;
int k[MAX];
string M[MAX];
vector<int> graph[MAX];
char strbuf[55];
void dfs(int now, int cnt) {
    M[now] = string(cnt, '.') + M[now];
    printf("%s\n", M[now].c_str());
    for (auto &&e : graph[now]) {
        dfs(e, cnt + 1);
    }
}
void solve(int n) {
    for (int i = 0; i < n; i++) {
        scanf("%d", k + i);
        k[i]--;
        scanf("%s", strbuf);
        M[i] = strbuf;
    }
    for (int i = 0; i < n; i++) {
        if (k[i] == -1) continue;
        graph[k[i]].emplace_back(i);
    }
    dfs(0, 0);
    last();
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    init();
    while (cin >> n, n) {
        solve(n);
        //return 0;
    }
    last();
}

Measured memory_bytes: 4256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int r = stdIn.nextInt();
        //int k = stdIn.nextInt();
        //int b = stdIn.nextInt();
        //int num[] = new int[3];
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //boolean flag = true;
        
        if(r < 1200){
            System.out.println("ABC");
        }else if(r < 2800){
            System.out.println("ARC");
        }else{
            System.out.println("AGC");
        }
        
        //System.out.println();
        //System.out.print();
    }
}


Measured memory_bytes: 21844
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b,k = map(int, input().split())
    for i in range(min(a,b), 0, -1):
        if a%i==0 and b%i==0:
            k -= 1
        if k==0:
            print(i)
            exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
from heapq import*
n,k=map(int,input().split())
*v,=map(int,input().split())
motimono=[]
ans=[]
if k>=n:
    k-=n
    heapify(v)
    ans.append(sum(v))
    for i in range(k):
        if len(v)>0:
            heappop(v)
        ans.append(sum(v))
    print(max(ans))
else:
    v*=2
    for j in range(1,k+1):
        for i in range(n-j,n+1):
            motimono=v[i:i+j]
            ans.append(sum(motimono))
            heapify(motimono)
            for i in range(k-j):
                if len(motimono)>0:
                    heappop(motimono)
                ans.append(sum(motimono))
    print(max(ans))

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



int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(){

ios::sync_with_stdio(false);
cin.tie(0);

string s;
cin>>s;
int le=(int)s.size();
int flag=0;
for(int i=0;i<(le-1)/2;i++){
if(s[i]!=s[le-i-1]){
flag=1;
}
}

int le2=(le-1)/2;
int flag2=0;
for(int i=0;i<(le2)/2;i++){
if(s[i]!=s[le2-i-1]){
flag2=1;
}
}

int flag3=0;
int count=0;

//int beg=(le+3)/2;
//int ens=(le+3)/2+(le-((le+3)/2))/2;

for(int i=(le+3)/2-1;i<le;i++){
//cout << i <<" "<< le-(count)-1<<endl;
if(s[i]!=s[le-(count)-1]){
flag3=1;
}
count++;
}
//cout <<flag<<flag2<<flag3<<endl;

flag+=flag2;
flag+=flag3;

if(flag==0)
cout <<"Yes"<<endl;
else
cout <<"No"<<endl;




}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 19 10:03:26 2017

@author: kotania
"""
from collections import Counter

N = int(input())
 
AList = []
 
count = 0
        
for n in range(0,N):
    AList.append(input())
    
countDict = Counter(AList)
countDictValues = countDict.values()

count = 0

for c in countDictValues:
    if c % 2 == 1 :
        count += 1

print(count)

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

int cnt(int n){
    string s = to_string(n) ;
    int res = 0 ;
    for(int i=0;i<s.size();i++) res += s.at(i)-'0' ;
    return res ;
}

int main(){
    int n,a,b ;
    cin >> n >> a >> b ;
    int ans = 0 ;
    for(int i=1;i<=n;i++) if(a<=cnt(i)&&cnt(i)<=b) ans += i ;
    cout << ans << endl ;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

// 素数判定
bool is_prime(ll n) {
	if (n == 1) return false;
	for (int i = 2; i * i <= n; ++i) {
		if (n % i == 0) return false;
	}
	return true;
}

void solve_abc() {
	ll q;

	cin >> q;

	V L(q), R(q);
	rep(i, q) {
		cin >> L[i] >> R[i];
	}

	V d;
	// O(nlog2n)
	rep2(i, 2, 1000001) {
		if (is_prime(i)) {
			if (is_prime((i + 1) / 2)) {
				d.push_back(i);
			}
		}
	}

	V ans(q, 0);
	// O(n)
	rep(i, q) {
		// O(log2n)
		auto begin = lower_bound(ALL(d), L[i]);
		auto end = upper_bound(ALL(d), R[i]);
		// O(n)
		ans[i] += (ll)(end - begin);
	}

	rep(i, q) {
		cout << ans[i] << "\n";
	}
}

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

	solve_abc();

	return 0;
}

Measured memory_bytes: 3072
a_e = [int(input()) for i in range(5)]
# 1の位を0にする
next_time_ae = [(x + 9)//10 * 10 for x in a_e]
# next_time_ae = [ x - x % 10 + 10 if x % 10 != 0 else x for x in a_e]
diff = [(b - a) for a, b in zip(a_e, next_time_ae)]

print(sum(next_time_ae)-max(diff))

Measured memory_bytes: 2940
#include <stdio.h>
int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b)
    {
        puts("a < b");
    }
    else if (a > b)
    {
        puts("a > b");
    }
    else

    {
        puts("a == b");
    }
    return 0;
}


Measured memory_bytes: 2612
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<complex<double>> in(n);
  for (int i = 0; i < n; i++) {
    double x, y;
    cin >> x >> y;
    in[i].real(x);
    in[i].imag(y);
  }
  sort(in.begin(), in.end(), [] (complex<double> a, complex<double> b) {return arg(a) < arg(b);});
  double ans = 0;
  for (int i = 0; i < n; i++) {
    for (int len = 1; len <= n; len++) {
      double x = 0, y = 0;
      for (int j = 0; j < len; j++) {
        x += in[(i + j) % n].real();
        y += in[(i + j) % n].imag();
      }
      ans = max(ans, hypot(x, y));
    }
  }
  cout << setprecision(20) << fixed << ans << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
$v=explode(" ",trim(fgets(STDIN)));
if($n==2){
  echo ($v[0]+$v[1])/2;
}else{
  $i=1;
  while($i<$n){
    sort($v);
    $p=$v[0];
    $v[1]=sprintf("%f",($p+$v[1])/2);
    unset($v[0]);
    ++$i;
  }
  printf("%f",$v[1]);
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

// 愚直計算による二項係数計算
mint com(long long n, long long r) {
mint res = 1;
for (long long i = 0; i < r; ++i) {
res *= (n-i);
res /= (i+1);
}
return res;
}

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

ll H,W,K;
cin >> H >> W >> K;

mint col = (H-1) * H * (H+1) / 6 * W * W;
mint row = (W-1) * W * (W+1) / 6 * H * H;
mint ans = (col + row) * com(H*W-2, K-2);
cout << ans << endl;
return 0;
}

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

int main() {
  int N;
  cin >> N;
  int n = N;
  int sum = 0;
  while (n != 0){
  	int a = n % 10;
    n = (n - a) / 10;
    sum = sum + a;
  }
   if (N % sum == 0){
     cout << "Yes" << endl;
   }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3672
#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 100
using namespace std;
int main(){
  int n,w,v[N],cnt[N];
  bool used[N];
  while(1){
    cin>>n>>w;
    if(!n&&!w) break;
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v,v+n);
    for(int i=0;i<N;i++) cnt[i]=0,used[i]=false;
    int m=0;
    for(int i=w-1,l=0;i<300;i+=w,l++){
      int flag=0;
      for(int j=0;j<n;j++){
	if(v[j]<=i&&used[j]==false){
	  used[j]=true;
	  cnt[l]++;
	  if(j==n-1){
	    flag=1;
	    m=l;
	    break;
	  }
	}
      }
      if(flag) break;
    }
    int maxv=0;
    for(int i=0;i<=m;i++) maxv=max(maxv,cnt[i]);
    double k=1,ans=0;
    for(int i=0;i<=m;i++){
      ans+=k*cnt[i]/maxv;
      k-=1.0*1/m;
    }
    printf("%.10f\n",ans+0.01);
  }
  return 0;
}

Measured memory_bytes: 1200
class node:
    def __init__(self,key=None):
        self.left=None
        self.right=None
        self.parent=None
        self.key=key

def insert(T,z):
    x=T
    y=None
    while isinstance(x,node):
        y=x
        if z.key<x.key:
            x=x.left
        else:
            x=x.right
    z.parent=y
    if y is None:
        T=z
    elif z.key<y.key:
        y.left=z
    else:
        y.right=z
    return T

def find(T,z):
    if T is None:
        print("no")
    else:
        y=None
        x=T
        while 1:
            y=x
            if x is None:
                print('no')
                return
            elif z.key==x.key:
                print('yes')
                return 
            elif z.key<x.key:
                x=x.left
            else:
                x=x.right                
    
def preorder(u):
    if not isinstance(u,node):
        return
    pripre.append(str(u.key))
    preorder(u.left)
    preorder(u.right)

def inorder(u):
    if not isinstance(u,node):
        return
    inorder(u.left)
    priin.append(str(u.key))
    inorder(u.right)

m=input()
root=None
for i in xrange(m):
    cmd=map(str,raw_input().split())
    if cmd[0]=="print":
        pripre=[]
        priin=[]
        preorder(root)
        inorder(root)
        print(' '+' '.join(priin))
        print(' '+' '.join(pripre))
    elif cmd[0]=="find":
        key=int(cmd[1])
        z=node(key)
        find(root,z)
    else:
        key=int(cmd[1])
        z=node(key)
        root=insert(root,z)

Measured memory_bytes: 209508
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define W first
#define V second
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

class SegmentTree{
  int n;
  vector<ll> node;
public:
  SegmentTree(vector<ll> a){
    int n_ = a.size();
    n=1;
    while(n<n_)n*=2;
    node.resize(2*n-1, 1e18);
    for(int i=0;i<n_;i++)node[n-1+i] = a[i];
    for(int i=n-2;i>=0;i--)node[i] = min(node[2*i+1], node[2*i+2]);
  }

  //return maximum value in [a,b). ( [l,r) is interval in which k is.)
  ll RMQ(int a,int b,int k=0,int l=0,int r=0){
    if(l>=r)r = n;
    if(r<=a || b<=l)return 1e18;
    if(a<=l && r<=b)return node[k];
    ll vl = RMQ(a,b,2*k+1,l,(l+r)/2);
    ll vr = RMQ(a,b,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
};

int main(){
  ll n,d;
  cin >> n >> d;

  ll sumw = 0, sumv = 0;
  vector<ll> w(n), v(n);
  rep(i,n){
    cin >> w[i] >> v[i];
    sumw += w[i];
    sumv += v[i];
  }

  ll p = n/2, s = n-p;
  vector<pll> pre, suf;

  ll P = pow(3,p);
  rep(bit,P){
    pll cur(0,0);
    ll tmp = bit;
    rep(i,p){
      if( tmp%3 == 0 ){
	cur.W += 2*w[i];
	cur.V += 2*v[i];
      }else if( tmp%3 == 1){
	cur.W += w[i];
	cur.V += v[i];
      }
      tmp/=3;
    }
    pre.push_back(cur);
  }

  ll S = pow(3,s);
  rep(bit,S){
    pll cur(0,0);
    ll tmp = bit;
    rep(i,s){
      if( tmp%3 == 0 ){
	cur.W += 2*w[p+i];
	cur.V += 2*v[p+i];
      }else if( tmp%3 == 1){
	cur.W += w[p+i];
	cur.V += v[p+i];
      }
      tmp/=3;
    }
    suf.push_back(cur);
  }

  sort(all(suf));
  vector<ll> val(S);
  rep(i,S)val[i] = suf[i].V;
  SegmentTree st(val);

  ll res = 1e18;
  rep(i,P){
    ll X = pre[i].W, Y = pre[i].V;
    ll lval = sumw-d-X, rval = sumw+d-X+1;
    int lpos = lower_bound(all(suf),pll(lval,0)) - suf.begin();
    int rpos = lower_bound(all(suf),pll(rval,0)) - suf.begin();

    if(lpos < rpos){
      res = min(res, Y + st.RMQ(lpos,rpos));
    }
  }

  cout << sumv-res << endl;
}

Measured memory_bytes: 940000
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int ans;
int n;
int sTakahashi, sAoki;
int aoki[100000];
vector<int> t[100000];

void createAoki(int cur, int dist) {
  aoki[cur] = dist;
  for (int i = 0; i < t[cur].size(); i++) {
    int next = t[cur][i];
    if (aoki[next] == -1) {
      createAoki(next, dist + 1);
    }
  }
}

void solve(int cur, int pre, int dist) {
  if (aoki[cur] >= dist) {
    if (dist % 2 == aoki[cur] % 2) {
      ans = max(ans, dist);
      cerr<<"1ans<-"<<dist<<endl;
    } else {
      ans = max(ans, dist - 1);
      cerr<<"2ans<-"<<dist-1<<endl;
    }
  }
  cerr<<":"<<cur<<","<<dist<<endl;
  if (aoki[cur] <= dist) {
    return;
  }
  if (t[cur].size() == 1) {
    int distCur = aoki[cur];
    int distPre = aoki[t[cur][0]];

    ans = max(ans, distPre);
    cerr<<"3ans<-"<<distPre<<endl;
    cerr<<"::"<<distPre<<","<<distCur<<endl;
    int diff = distPre - dist;
    if (diff % 2 == 0 && diff >= 1) {
      ans = max(ans, distPre);
      cerr<<"4ans<-"<<distCur<<endl;
      cerr <<":::"<< cur<<":" << diff<<endl;
    }
  }
  ans = max(ans, dist);
  for (int i = 0; i < t[cur].size(); i++) {
    int next = t[cur][i];
    if (pre != next) {
      solve(next, cur, dist + 1);
    }
  }
}

int main() {
  while (cin >> n >> sTakahashi >> sAoki) {
    sTakahashi--;
    sAoki--;
    for (int i = 0; i < 100000; i++) {
      t[i].clear();
    }
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      t[a].push_back(b);
      t[b].push_back(a);
    }

    memset(aoki, -1, sizeof(aoki));
    createAoki(sAoki, 0);

    /*
    for (int i = 0; i < n; i++) {
      cout<<aoki[i]<<",";
    }
    cout<<endl;
    */

    ans = 0;
    solve(sTakahashi, -1, 0);

    cout << ans << endl;
  }
}


Measured memory_bytes: 11264
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>


using namespace std;

struct UnionFind {
  vector<int> f;

  UnionFind(int n) : f(n, -1){}

  int root(int x){
    if(f[x] < 0) return x;

    else return f[x] = root(f[x]);
  }

  void unite(int x,int y) {
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;

    if(size(x) < size(y)) swap(rx,ry);
    f[rx] += f[ry];
    f[ry] = rx;
  }


  int size(int x) {
        return -f[root(x)];
    }
};



int main(void){
  int N,M,a,b;

  cin >> N >> M;

  int A[M],B[M];

  for(int i = 0;i < M;i++){
    cin >> A[i] >> B[i];
  }

  UnionFind uf(N);

  for(int i = 0;i < M; i++){
    a = A[i]-1, b = B[i]-1;
    uf.unite(a,b);
  }

  int ans = 0;

  for(int i = 0;i < N;i++){
    ans = max(ans,uf.size(i));
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int c[4][4];
int main() {
    for(int i=1;i<4;i++)for(int j=1;j<4;j++)cin>>c[i][j];
    puts((c[1][1]+c[2][2]+c[3][3]==c[1][2]+c[2][3]+c[3][1])&&c[1][1]+c[2][2]+c[3][3]==c[1][3]+c[2][1]+c[3][2]?"Yes":"No");
};


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top,a[1000];
void push(int x){
    a[++top]=x;
}
int pop(){
    top--;
    return a[top+1];
}
int main(){
    int a,b;
    char c[100];
    top=0;
    while(scanf("%s",c)!=EOF){
        if(c[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(c[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
        }
        else if(c[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else {
            push(atoi(c));
        }
        }
        printf("%d\n",pop());
        return 0;
    }
    
    


Measured memory_bytes: 2108
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int main()
{
	int k, s;
	cin >> k >> s;

	ll res = 0;
	for (int i = 0; i <= k; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			if (i + j <= s && i + j + k >= s)
			{
				res++;
			}
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var A, B, C int
  fmt.Scan(&A, &B, &C)
  
  var c int
  for i := 1; i*A <= B; i++ {
    c++
    if c == C {
      break
    }
  }
  fmt.Println(c)
}

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

const double PI = 3.141592653589793238;

double radian(const double &degree) {
  return degree/360*2*PI;
}

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  
  double H_angle = H / 12 * 360 + M * 360 / (60 * 12);
  double M_angle = M / 60 * 360;
  
  double angle = H_angle - M_angle;
  if (angle < 0) {
    angle = -angle;
  }
  
  if (angle > 180) {
    angle = 360 - angle;
  }
  
  //cerr << angle << endl;
  
  double answer;
  if (angle <= 90) {
    angle = radian(angle);
    //cerr << A*sin(angle) << ' ' << A*cos(angle) << endl;
    //cerr << pow(A*sin(angle),2)+pow(B-A*cos(angle),2) << endl;
    answer = sqrt(pow(A*sin(angle),2)+pow(B-A*cos(angle),2));
  } else {
    angle = radian(180-angle);
    answer = sqrt(pow(A*sin(angle),2)+pow(B+A*cos(angle),2));
  }
  cout << setprecision(32) << answer << endl;
  
  return 0;
}

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


int main()
{
  int n,a,b;
  cin >> n >> a >> b;
  int o,p,q,r,s,t;
  int sum = 0;
  for(int i = 1;i <= n;i++){
    o = i / 10000 % 10;
    p = i / 1000 % 10;
    q = i / 100 % 10;
    r = i / 10 % 10;
    s = i % 10;
    t = o + p + q + r + s;
    if(t >= a && t <= b) sum += i;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
 int A,B,C,D;
 scanf("%d %d %d %d",&A,&B,&C,&D);
 while(0<B&&0<D){
  C-=B;
  if(C<=0){
   printf("Yes");
   break;
   }
  A-=D;
  if(A<=0){
   printf("No");
   break;
   }
 }
 return 0;
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(a + b - n, 0) << endl;
    return 0;
}

Measured memory_bytes: 3644
import numpy as np
import sys
input = sys.stdin.readline
N, M, Q = map(int, input().split())
T = np.zeros((N, N), dtype=np.int32)
for _ in [0]*M:
    l, r = map(int, input().split())
    T[l-1, r-1] += 1
T = T[::-1].cumsum(axis=0).cumsum(axis=1)[::-1]
for _ in [0]*Q:
    p, q = map(int, input().split())
    print(T[p-1, q-1])

Measured memory_bytes: 31644
#include <stdio.h>
#include <string.h>

int main(void)
{
	char s[11]; scanf("%s",s);
	
	int l=strlen(s);
	int a[11],i,j,c=(1<<(l-1));
	long long sum,t;
	for(i=0;i<l;i++)a[i]=s[i]-'0';
	sum=0;
	for(i=0;i<c;i++){
		t=a[0];
		for(j=0;j<l;j++)
		{
			if(j==l-1||i&1<<j)
			{
				sum+=t;t=0;if(j==l-1)break;
			}
			t*=10;
			t+=a[j+1];
		}
	}
	printf("%lld",sum);
}

Measured memory_bytes: 888
def main():
	n,k=map(int,input().split())
	a=list(map(int,input().split()))
	for i in range(k):
		b=[0]*(n+1)
		for j in range(n):
			b[max(j-a[j],0)]+=1
			b[min(j+a[j]+1,n)]-=1
		for j in range(n):
			b[j+1]+=b[j]
		a=b[:n]
		if min(a)==n:
			break
	print(*a)
if __name__ == '__main__':
	main()

Measured memory_bytes: 169140
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a == b && b == c)System.out.println("Yes");
		else System.out.println("No");
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 21332
#include <stdio.h>
int divisible(int num){
  if(num<3)
	return 0;
  else if(num%10==3)
	return 1;
  else
	divisible(num/10);
	
}
int main(){
  char line[100];
  int num;
  int i;
  int n;
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%d", &num);
	for(i=3; i<=num; ++i){
	  if(i%3==0)
		printf(" %d",i);
	  else 
		if(divisible(i))
		  printf(" %d", i);
	}

	printf("\n");
 

return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string s,t;
    int a,b,ans=0,tmp=1001;
    cin>>s>>t;
    a=s.size();
    b=t.size();
    for(int z=0;z<=a;z++){
        for(int y=0;y<b;y++){
            if(s[z+y]!=t[y]){
                ans++;
                //cout<<s[y]<<" "<<t[y]<<endl;
            }
        }
        //cout<<ans<<endl;
        if(tmp>=ans){
            tmp=ans;
        }
        ans=0;
        if(a<=b+z){
            break;
        }
    }
    cout<<tmp<<endl;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll dist = abs(A - B);
  ll ans = 0;
  if (dist % 2 == 0) {
    ans = dist / 2;
  } else {
    // ちかいほうにぶつける
    ll edge_minl = min(A, B);
    ll edge_minr = min(N + 1 - A, N + 1 - B);
    ll edge_mincount = min(edge_minl, edge_minr);
    ans = edge_mincount - 1;
    //　ぶつけたら1回パスしてdist偶数
    ans++;
    ans += dist / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/


void solve() {
	string s, t; cin >> s >> t;
	int ans = t.length(), n = s.length(), m = t.length();
	for (int i = 0; i <= n - m; i++) {
		string x = s.substr(i, m);
		int cur = 0;
		for (int j = 0; j < m; j++)
			if (x[j] != t[j]) cur++;
		ans = min(ans, cur);
	}
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
#define MORNINGFEE 200
#define AFTERNOONFEE 300

struct Class{
  string name;
  int amin, pmin;
};

Class classes[9];

int main(void){
  for(int i = 0; i < 9; i++){
    cin >> classes[i].name >> classes[i].amin >> classes[i].pmin;
  }
  for(int i = 0; i < 9; i++){
    int in, income;
    in = classes[i].amin + classes[i].pmin;
    income = classes[i].amin * MORNINGFEE + classes[i].pmin * AFTERNOONFEE;
    cout << classes[i].name << " " << in << " " << income << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <list>
#include <deque>
#include <numeric>
#include <set>
#include <climits>
#include <utility>
#include <map>
#include <float.h>
typedef long long ll;
typedef unsigned long long ull;
inline int max( int x, int y ){ return x > y ? x : y ; }
inline int min( int x, int y ){ return x < y ? x : y ; }
inline ll max( ll x, ll y ){ return x > y ? x : y ; }
inline ll min( ll x, ll y ){ return x < y ? x : y ; }
inline ull max( ull x, ull y ){ return x > y ? x : y ; }
inline ull min( ull x, ull y ){ return x < y ? x : y ; }
int GCD( int a, int b ) { return b ? GCD( b , a%b ) : a; }
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PIV 3.14159265358979323846
#define MAXN 100
typedef pair<int, int> P;
const int MAX_V = 400+1;

int main(){
	
	string s;
	
	cin >> s;
	if( s == "Sunny" ) cout << "Cloudy";
	else if( s == "Cloudy" ) cout << "Rainy";
	else cout << "Sunny";
	return 0;
}









Measured memory_bytes: 256
import java.util.Scanner;

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

		double a = scan.nextInt();//短針の長さ
		double b = scan.nextInt();//長針の長さ
		int h = scan.nextInt();//時間
		int m = scan.nextInt();//分
		double a_w = (30 * h) + (0.5 * m);//短針の角度
		double b_w = 6 * m;//長針の角度
		double w = 0;
		double ans = 0;

		if(a_w >= b_w) {
			w = a_w - b_w;
		}else {
			w = b_w - a_w;
		}

		if(w > 180) {
			w = 360 - w;
		}

		ans = Math.sqrt(Math.pow(a , 2) + Math.pow(b , 2) - (2 * a * b * Math.cos(Math.toRadians(w))));

		System.out.printf("%.20f" , ans);
	}
}


Measured memory_bytes: 35920
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<ll> a(n); rep(i,n) cin >> a[i];
  sort(all(a));
  if(a[0] == 0){
    cout << 0;
    return 0;
  }
  ll limit = 1e18;
  rep(i,n){
    limit /= a[i];
    if(limit < 1){
      cout << -1;
      return 0;
    }
  }
  ll ans = 1;
  rep(i,n) ans *= a[i];
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3984
var
 n,m,j,i,d,x,y:longint;
begin
 readln(n,m,d);
 for i:=0 to n-1 do
  begin
   for j:=0 to m-1 do
    begin
     x:=(i+j+m) div d mod 2;
     y:=(i-j+m) div d mod 2;
     case 2*x+y of
      0:write('R');
      1:write('G');
      2:write('B');
      3:write('Y');
     end;
    end;
   writeln;
  end;  
end.

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef long long int ll;
const ll MOD=1000000007;

int main(){
	ll n,k,ans;
	scanf("%lld %lld",&n,&k);
	ans=1;
	for(int i=0;i<n;i++){
		ans*=k;
		ans%=MOD;
	}
	printf("%lld\n",ans);
}


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

char c[101];

int main() {
	bool flag = false;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> c[i];
		if (c[i] == 'Y') {
			flag = true;
		}
	}
	if (flag) {
		cout << "Four" << endl;
	} else {
		cout << "Three" << endl;
	}
}

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


int main() {
  int n = 0 ;
  cin >> n ;
  cout << n*n*n << endl ;
  
  return 0 ; 
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            else{
                for(int i=0; i<H; i++){
                    for(int j=0; j<W; j++){
                        if((i+j)%2 == 0){
                            System.out.print("#");
                        }
                        else{
                            System.out.print(".");
                        }
                    }
                    System.out.println("");
                }
                System.out.println("");
            }
        }
    sc.close();
    }
}


Measured memory_bytes: 35656
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	int res1 = 0, res2 = 0;
	
	for(int i=0; i<s.size(); i++){
		if(i % 2 == 0){
			if(s[i] != '1') res1++;
		}else{
			if(s[i] != '0') res1++;
		}
	}

	for(int i=0; i<s.size(); i++){
		if(i % 2 == 1){
			if(s[i] != '1') res2++;
		}else{
			if(s[i] != '0') res2++;
		}
	}

	cout << min(res1, res2);

	return 0;
}

Measured memory_bytes: 512
// failed to generate code

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


int MOD = 1e9 + 7;
char c[1010][1010];

int dp[1010][1010];
int main(){
    int H,W;
    cin >> H >> W;


    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            cin >> c[i][j];
        }
    }
    dp[0][0] = 1;
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            if( c[i][j] == '#' ) dp[i][j] = 0;
            dp[i][j] %= MOD;

            dp[i+1][j] += dp[i][j];
            dp[i][j+1] += dp[i][j];
        }
    }
    cout << dp[H-1][W-1] % MOD << endl;
}


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

using namespace std;

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

    int ans = 0;
    for(int x = 0; x < 1e5; ++x){
        int l = lower_bound(a.begin(), a.end(), x - 1) - a.begin();
        int r = upper_bound(a.begin(), a.end(), x + 1) - a.begin();
        ans = max(ans, r - l);
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
int ans;
int main(int argc, char* argv[]){
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  scanf("%d",&k);
  printf("%d\n",a[k-1]);
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
  string a,b;
  cin >> a >> b;
  if(a.at(0) == b.at(2) && a.at(2) == b.at(0) && a.at(1) == b.at(1)){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ( a == 1){
    a += 13;
  }
  
  if ( b ==1){
    b += 13;
  }
  
  if ( a > b){
    cout << "Alice" << endl;    
  }
 
  
  else if ( b > a ){
    cout << "Bob" << endl;
  }
  
  else{
    cout << "Draw" << endl;
  }

    
  

  
}

Measured memory_bytes: 256
N = int(input())
A = list(map(lambda x: int(x) - 1, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

bef = -2
sum = 0
for i in A:
	sum += B[i]
	if(bef + 1 == i):
		sum += C[i - 1]
	bef = i

print(sum)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

LL powmod(LL x, LL y){ // pow(x,y)
    if(y == 0) return 1;
    if(y == 1) return x;

    if(y%2 == 0){
        return powmod(x,y/2) * powmod(x,y/2) % MOD;
    }
    else{
        return powmod(x,y-1) * x % MOD;
    }
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();

    int N,M,K; cin >> N >> M >> K;
    LL ans = 0;

    for(LL i = 0; i < N; i++){
        LL wa = (N-i) * (N-i-1) / 2;
        dump(wa)
        ans = (ans + wa * M % MOD * M % MOD * COM(N*M-2, K-2) % MOD) % MOD;
    }
    for(LL i = 0; i < M; i++){
        LL wa = (M-i) * (M-i-1) / 2;
        ans = (ans + wa * N % MOD * N % MOD * COM(N*M-2,K-2) % MOD) % MOD;
    }
    cout << ans << endl;




}


Measured memory_bytes: 12160
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //Search for all i
    for (int i = 0; i < N; i++)
    {
        //Update the values of A[i+1] ... A[N]
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4060