akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
    // 整数の入力
    int a;
  	bool flag = true;
    cin >> a ;
    // 出力
 	for(int i=1;i<10;i++){
      for(int j=1;j<10;j++){
     	if(i*j == a){
          flag = false;
          break;
     	 }
       }
    }
    if(flag){
		cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
 
    return 0;
}

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

int main(){
    int n;
    int A[3000];

    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    
    int sum=0;

    for(int i=0;i<n;i++){
        sum+=A[i]-1;

    }

    cout<<sum<<endl;

    return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> P;

const int INF = 1e5;

int main() {
  int N;
  while (cin >> N and N) {
    vector<P> tiles(N);
    tiles[0] = make_pair(0, 0);
    for (int i = 1; i < N; i++) {
      int n, d;
      cin >> n >> d;
      int x = tiles[n].X, y = tiles[n].Y;
      if (d == 0) { x--; }
      if (d == 1) { y--; }
      if (d == 2) { x++; }
      if (d == 3) { y++; }

      tiles[i] = make_pair(x, y);
    }

    int minx = INF, maxx = -INF, miny = INF, maxy = -INF;
    for (P tile : tiles) {
      minx = min(minx, tile.X);
      maxx = max(maxx, tile.X);
      miny = min(miny, tile.Y);
      maxy = max(maxy, tile.Y);
    }

    cout << maxx - minx + 1 << " " << maxy - miny + 1 << endl;
  }
}

Measured memory_bytes: 1196
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	vector< int > S(N + 1, 0);
	rep(i, N) S[i + 1] = S[i] + A[i];
	int l = 1, r = 3;
	int ans = LINF;
	for (int m = 2; m < N - 1; m++) {
		while (r <= m)
			++r;
		while (l < m - 1 && abs(S[m] - S[l] - S[l]) > abs(S[m] - S[l + 1] - S[l + 1])) {
			++l;
		}
		while (r < N && abs(S[N] - S[r] - S[r] + S[m]) > abs(S[N] - S[r + 1] - S[r + 1] + S[m])) {
			++r;
		}
		int MAX = max(max(S[l], S[m] - S[l]), max(S[r] - S[m], S[N] - S[r]));
		int MIN = min(min(S[l], S[m] - S[l]), min(S[r] - S[m], S[N] - S[r]));
		chmin(ans, MAX - MIN);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }

template<class T, class Func = function<T(T,T)>>
class CumulativeSum{
public:
    vector<T>sum;
    T e;
    CumulativeSum(const vector<T>v,T e,const Func& f = [](T a, T b){return a + b;}) : sum(v.size()),e(e){
        copy(v.begin(),v.end(),sum.begin());
        T past = 0;
        for(auto & itr : sum){
            itr = f(itr,past);
            past = itr;
        }
    }
    //[l,r)
    auto query(Int l, Int r, const Func& f = [](T a,T b){return a - b;}){
        if(r > 0) return f(sum[r - 1],(l == 0 ? 0 : sum[l - 1]));
        else return e;
        
    }
};
signed main(){
    constexpr Int inf = (1LL << 60);
    Int N; cin >> N;
    vector<Int>v(N);
    for(auto&e : v)  cin >> e;
    CumulativeSum<Int> csum(v,0LL);
    auto dp = vectors(N + 1,N + 1,inf);
    for(Int i = 0; i < v.size(); ++i){
        dp[i][i+1] = 0;
    }
    function<Int(Int,Int)>solve = [&](Int l, Int r) {
        
        if(dp[l][r] != inf) return dp[l][r] + csum.query(l,r);
        Int minans = inf;
        for(Int i = l + 1; i < r; ++i){
            minans = min(minans, solve(l,i) + solve(i,r));
        }
        dp[l][r] = minans;
        
        return minans + csum.query(l,r);
    };
    cout << solve(0,v.size())  - accumulate(v.begin(),v.end(),0LL) << endl;
}


Measured memory_bytes: 1536
s = input()
s = s[::-1]
i = 0
while i < len(s):
  if s[i:i+5] in ['maerd','esare']:
    i += 5
  elif s[i:i+6] == 'resare':
    i += 6
  elif s[i:i+7] == 'remaerd':
    i += 7
  else:
    print('NO')
    exit()
print('YES')


Measured memory_bytes: 40432
#include <stdio.h>

int main(void){
  int a[3][10][4] = {0};
  int i, j, k;
  int n, p;
  int b, f, r, v; /* b棟f階r番目の部屋にv人 [階][部屋][棟] */

  scanf("%d", &n);
  for(i=0; i<n; i++){
      scanf("%d%d%d%d", &b, &f, &r, &v);

      a[f-1][r-1][b-1] += v;
    }

  for(k=0; k<4; k++){
    for(i=0; i<3; i++){
      for(j=0; j<10; j++){
        if(a[i][j][k] == 0){
          printf(" 0");
        }else{
          printf(" %d", a[i][j][k]);
        }
      }
      printf("\n");
    }
    if(k != 3){
      printf("####################\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer n = sc.nextInt();
		Integer maxC = n / 4;
		Integer maxD = n / 7;
		String answer = "No";

		for(int ic = 0; ic <= maxC; ic ++) {
			for(int id = 0; id <= maxD; id ++) {
					int total = ic * 4 + id * 7;
					if(total == n) {
						answer = "Yes";
					}
				}
			}
		System.out.println(answer);
	}
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,m,s,t,ans[100000],now;
vector<int> v[100000];
bool visited[100000][4];
queue<int> que;

int kr(int res, int j, queue<int>& q) {
    if (res==0) {
        if (!visited[j][res]) {
            visited[j][res] = true;
            q.push(j);
        }
        return 0;
    }
    rep(i,v[j].size()) {
        if (!visited[v[j][i]][res]) {
            visited[v[j][i]][res] = true;
            kr(res-1, v[j][i], q);
        }
    }
}

signed main() {
    cin >> n >> m;
    rep(i,m) {
        int a,b;
        cin >> a >> b,--a,--b;
        v[a].pb(b);
    }
    cin >> s >> t;--s,--t;
    kr(3,s,que);
    while(que.size()) {
        queue<int> tmp;
        now++;
        while(que.size()) {
            int qf = que.front();que.pop();
            ans[qf] = now;
            if (qf == t) {
                cout << now << endl;
                return 0;
            }
            kr(3,qf,tmp);
        }
        que = tmp;
    }
    cout << -1 << endl;
}



Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define ll long long
 
 
int main(){
  int h,w,k;
  cin>>h>>w>>k;
  
  vector<string> s(h);
  for(int i=0; i<h; i++){
    cin>>s[i];
  }
  
  int ans=0;
  for(int is=0; is<(1<<h); is++){
    for(int js=0; js<(1<<w); js++){
      int cnt=0;
      for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
          if (is>>i&1) continue;
          if (js>>j&1) continue;
          if (s[i][j]=='#') cnt++;
      }}
      if (cnt==k) ans++;
  }}
  cout<<ans<<endl;
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();

		int count = 0;
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) != t.charAt(i)){
				count++;
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 31920
//  Copyright 2020 Nikita Golikov

#include <bits/stdc++.h>

using namespace std;

using i64 = int64_t;
using ui64 = uint64_t;

template <class A, class B>
bool smin(A &x, B &&y) {
  if (y < x) {
    x = y;
    return true;
  }
  return false;
}

template <class A, class B>
bool smax(A &x, B &&y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
#ifdef GOLIKOV
  assert(freopen("in", "rt", stdin));
  auto _clock_start = chrono::high_resolution_clock::now();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  i64 x, k, d;
  cin >> x >> k >> d;
  i64 sign = x > 0 ? 1 : -1;
  auto need_zero = abs(x) / d;
  smin(need_zero, k);
  x += (-sign) * need_zero * d;
  k -= need_zero;
  k %= 2;
  if (k) {
    x += (-sign) * d;
  }
  cout << abs(x) << '\n';

#ifdef GOLIKOV
  cerr << "Executed in " << chrono::duration_cast<chrono::milliseconds>(
      chrono::high_resolution_clock::now()
          - _clock_start).count() << "ms." << endl;
#endif
  return 0;
}


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

struct edge{
	int v;
	string cost;
	edge(int v_, string cost_){
		v = v_; cost = cost_;
	}
};
bool operator<(const edge& a, const edge& b){
	return a.cost > b.cost;
}
const int MAX_V = 40;
const int MAX_E = 400;
// dp[v][l] := テヲツ慊?・ツセツ古」ツ?ォティツィツェテ」ツつ古」ツ?淌ゥツ?づァツつケテ」ツ??v テ」ツ?ァテゥツ閉キテ」ツ?陛」ツ??l テ」ツ?ョテヲツ鳴?・ツュツ療・ツ按療」ツ?ョテヲツ慊?・ツーツ湘」ツ?ョテヲツ鳴?・ツュツ療・ツ按?
string dp[MAX_V][500];
vector<edge> G[MAX_V];
int n, a, s, g;

void add_edge(int u, int v, string cost){
	G[u].push_back( edge(v, cost) );
}

void dfs(int v, vector<bool>& visited){
	visited[v] = true;
	for(int i=0 ; i < G[v].size() ; i++ ){
		int to = G[v][i].v;
		if( !visited[to] ){
			dfs(to, visited);
		}
	}
}

bool is_exist(){
	// テ」ツつエテ」ツδシテ」ツδォテ」ツ?ォテ・ツ按ーテゥツ?氾・ツ渉ッティツδステ」ツ?凝」ツ?ゥテ」ツ??」ツ??
	vector<bool> visited(n, false);
	dfs(s, visited);
	if( !visited[g] ) return false;
	
	return true;
}

string solve(){
	for(int i=0 ; i < MAX_V ; i++ ){
		fill(dp[i], dp[i] + 500, "~");
	}
	// テ」ツδォテ」ツδシテ」ツδ療」ツ?療」ツ?ェテ」ツ??」ツ?ィテ」ツ?催」ツ?ョテ・ツ堕ェテヲツ鳴?」ツ?ョテヲツ慊?・ツ、ツァテゥツ閉キ
	int N = 6 * (n-1); 
	dp[s][0] = "";
	priority_queue<edge> q;
	q.push( edge(s, "") );
	
	string res = "~";
	while( !q.empty() ){
		int v = q.top().v;
		string cost = q.top().cost;
		int l = cost.size();
		q.pop();
		
		if( v == g ){
			res = min(res, cost);
			break;
		}
		
		for(int i=0 ; i < G[v].size() ; i++ ){
			int to = G[v][i].v;
			string add_cost = G[v][i].cost;
			string next_cost = cost + add_cost;
			int l_ = next_cost.size();
			if( 500 <= next_cost.size() ){
				continue;
			}
			if( next_cost < dp[to][l_] ){
				dp[to][l_] = next_cost;
				q.push( edge(to, dp[to][l_]) );
			}
		}
	}
	for(int i=N ; i < 500 ; i++ ){
		if( dp[g][i].size() == i ) return "~";
	}
	return res;
}

int main(){
	while( cin >> n >> a >> s >> g, n ){
		// テ・ツ按敕ヲツ慊淌・ツ個?
		for(int i=0 ; i < MAX_V ; i++ ) G[i].clear();	
		
		for(int i=0 ; i < a ; i++ ){
			int x, y;
			string lab;
			cin >> x >> y >> lab;
			add_edge(x, y, lab);
		}
		if( !is_exist() ){
			cout << "NO" << endl;
		}else{
			string ans = solve();
			if( ans == "~" ) ans = "NO";
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 21348
#include<stdio.h>
#include<string.h>
#define MAX 2000000
#define INFTY 1000000000

int H,A[MAX+1];

void maxHeapify(int i){
    int l = 2 * i;
    int r = 2 * i  +1;
    int largest,t;

    if(l<=H && A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H && A[r]>A[largest]) largest=r;

    if(largest != i){
        t=A[i];
        A[i]=A[largest];
        A[largest]=t;
        maxHeapify(largest);
    }
}


int extract(){
    int maxv;
    if(H<1) return -INFTY;
    maxv = A[1];
    A[1]=A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key) {
    if ( key < A[i] ) return;
    int tmp;
     A[i] = key;
    while ( i > 1 && A[i / 2] < A[i] ) {
        tmp = A[i];
        A[i]=A[i/2];
        A[i/2]=tmp;

        i = i / 2;
         }
     }

void insert(int key) {
  H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main(){
int key;
 char com[10];

 while ( 1 ) {
     scanf("%s", com);
     if ( com[0] == 'e' && com[1] == 'n' ) break;
     if ( com[0] == 'i' ) {
         scanf("%d",&key);
         insert(key);
     }else{
       
         printf("%d\n",extract());
     }
 }
    return 0;
}



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
inline int read()
{
	rg int res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n,d,x[15][15],ans;
inline int Dis(int a,int b)
{
	rg int res=0;
	for(int i=1;i<=d;i++)
		res+=(x[a][i]-x[b][i])*(x[a][i]-x[b][i]);
	return res;
}
int main()
{
	rg int tmp,sq;
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=d;j++)
			scanf("%d",&x[i][j]);
		for(int j=1;j<i;j++)
		{
			tmp=Dis(i,j);
			sq=sqrt(tmp);
			if(sq*sq==tmp)
				ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

def main():
    N = int(input())
    
    if N&1:
        print(0)
    else:
        num = 10
        ans = 0
        tmp = N // num
        while tmp > 0:
            ans += tmp
            num *= 5
            tmp = N // num
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#
import sys
import math
import numpy as np
import itertools

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
m = list(input())

if m[0]=='S':
    if m[1]=='U':
        print("7")
    else:
        print("1")
elif m[0]=='M':
    print("6")
elif m[0]=='T':
    if m[1]=='U':
        print("5")
    else:
        print("3")
elif m[0]=='W':
    print("4")
elif m[0]=='F' :
    print("2")



Measured memory_bytes: 22016
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string S;
    cin>>S;
    int N=S.size();
    vector<char> first_white(N);
    vector<char> first_black(N);
    rep(i,N) {
        if(i%2==0) {
            first_white.at(i)='1';
            first_black.at(i)='0';
        }
        else {
            first_white.at(i)='0';
            first_black.at(i)='1';
        }
    }
    int w=0,b=0;
    rep(i,N) {
        if(first_white.at(i)!=S.at(i)) w++;
        if(first_black.at(i)!=S.at(i)) b++;
    }
    cout<<min(w,b)<<endl;
}

Measured memory_bytes: 512
def perpro(q,p):
    res=[-1]*len(p)
    for i in range(len(p)):
        res[i]=q[p[i]]
    return res

def inverse(p):
    res=[-1]*len(p)
    for i in range(len(p)):
        res[p[i]]=i
    return res

N,K=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

ide_ele=[i for i in range(N)]

for i in range(N):
    p[i]-=1
    q[i]-=1

invp=[-1]*N
for i in range(N):
    invp[p[i]]=i

invq=[-1]*N
for i in range(N):
    invq[q[i]]=i

A=perpro(q,perpro(invp,perpro(invq,p)))

kthA=[A]
for i in range(30):
    kthA.append(perpro(kthA[-1],kthA[-1]))

def _nthA(n):
    res=ide_ele
    for i in range(30):
        if n>>i&1==1:
            res=perpro(res,kthA[i])
    return res

def ntha(n):
    qqq=n//4
    r=n%4
    if r==0:
        return _nthA(qqq)
    elif r==1:
        return perpro(_nthA(qqq),q)
    elif r==2:
        return perpro(_nthA(qqq),perpro(q,invp))
    else:
        return perpro(_nthA(qqq),perpro(q,perpro(invp,invq)))

Q=(K-1)//3
r=(K-1)%3
ans=[]
if Q==0:
    if K==1:
        ans=p
    elif K==2:
        ans=q
    else:
        ans=perpro(q,invp)
else:
    if Q%2==0:
        if r==0:
            mid=p
            a=ntha(2*Q-1)
            ans=perpro(a,perpro(mid,inverse(a)))
        elif r==1:
            mid=q
            a=ntha(2*Q)
            ans=perpro(a,perpro(mid,inverse(a)))
        else:
            mid=perpro(q,invp)
            a=ntha(2*Q)
            ans=perpro(a,perpro(mid,inverse(a)))
    else:
        if r==0:
            mid=invp
            a=ntha(2*Q-1)
            ans=perpro(a,perpro(mid,inverse(a)))
        elif r==1:
            mid=invq
            a=ntha(2*Q)
            ans=perpro(a,perpro(mid,inverse(a)))
        else:
            mid=perpro(invq,p)
            a=ntha(2*Q)
            ans=perpro(a,perpro(mid,inverse(a)))

for i in range(N):
    ans[i]+=1

print(*ans)

Measured memory_bytes: 140136
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_set>

int main()
{
    int n;
    std::cin >> n;

    std::unordered_set<std::string> usedWords;
    std::string str;
    char last = ' ';
    for (int i = 0; i < n; ++i) {
        std::cin >> str;
        if (i != 0) {
            if (usedWords.count(str) != 0 || str[0] != last) {
                std::cout << "No" << std::endl;
                return 0;
            }
        }

        usedWords.insert(str);
        last = str[str.size() - 1];
    }

    std::cout << "Yes" << std::endl;

    return 0;
}

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

int main() {
  #define int long long
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int mul = 1;
  bool can = true;
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (mul == 0) {
      cout << 0 << endl;
      can = false;
      break;
    }
    else if (1000000000000000000 / mul < v.at(i)) {
      cout << -1 << endl;
      can = false;
      break;
    }
    else {
      mul *= v.at(i);
    }
  }
  if (can) {
    cout << mul << endl;
  }
}

Measured memory_bytes: 4048
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	char blo[2];
	int n;
	int num[4] = {0};
	int i;
	
	while (scanf("%d,%s", &n, blo) != EOF){
		if (strcmp(blo, "A") == 0){
			num[0]++;
		}
		else if (strcmp(blo, "B") == 0){
			num[1]++;
		}
		else if (strcmp(blo, "AB") == 0){
			num[2]++;
		}
		else if (strcmp(blo, "O") == 0){
			num[3]++;
		}
	}
	
	for (i = 0; i < 4; i++){
		printf("%d\n", num[i]);
	}
	
	return (0);
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPyramid solver = new CPyramid();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPyramid {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            long[] x = new long[n];
            long[] y = new long[n];
            long[] h = new long[n];
            for (int i = 0; i < n; i++) {
                x[i] = sc.nextInt();
                y[i] = sc.nextInt();
                h[i] = sc.nextInt();
            }
            for (int cx = 0; cx < 101; cx++) {
                loop:
                for (int cy = 0; cy < 101; cy++) {
                    long infto = Integer.MAX_VALUE;
                    for (int i = 0; i < n; i++) {
                        if (h[i] == 0) {
                            infto = Math.min(infto, Math.abs(cx - x[i]) + Math.abs(cy - y[i]));
                        }
                    }
                    long poss = -1;
                    for (int i = 0; i < n; i++) {
                        long sum = Math.abs(cx - x[i]) + Math.abs(cy - y[i]);
                        if (poss == -1) {
                            if (h[i] == 0) {
                                continue;
                            }
                            poss = h[i] + sum;
                        } else {
                            if (h[i] == 0) {
                                continue;
                            }
                            if (h[i] + sum != poss) {
                                continue loop;
                            }
                        }
                    }
                    if (poss <= infto) {
                        out.println(cx + " " + cy + " " + Math.max(0, poss));
                        return;
                    }
                }
            }
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22996
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define SZ(container) ((int)container.size())

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


typedef vector<ll> Array;
typedef vector<Array> Matrix;
Matrix mul(const Matrix &a,const Matrix &b,const ll MOD){
	Matrix res(a.size(),Array(b[0].size()));
	REP(i,a.size()){
		REP(j,b[0].size()){
			REP(k,a[0].size()){
				res[i][j]=(res[i][j]+a[i][k]*b[k][j])%MOD;
			}
		}
	}
	return res;
}
Matrix pow(const Matrix &a,ll b, const ll MOD){
	if(b==0){
		Matrix res(a.size(),Array(a.size()));
		REP(i,a.size())res[i][i]=1;
		return res;
	}
	Matrix res=pow(mul(a,a,MOD),b/2,MOD);
	if(b&1)res=mul(res,a,MOD);
	return res;
}
int n,M,a,b,c,t;


main(){
	int i,j;
	while(scanf("%d%d%d%d%d%d", &n, &M, &a, &b, &c, &t), n){
		Matrix m(n, Array(n));
		Matrix arr(n, Array(1));
		REP(i, n){
			scanf("%d", &arr[i][0]);
			if(i) m[i][i-1] = a;
			m[i][i] = b;
			if(i+1<n) m[i][i+1] = c;
		}
		arr = mul(pow(m, t, M), arr, M);
		REP(i, n) printf("%d%s", arr[i][0], i==n-1?"\n":" ");
	}
	return 0;
}

Measured memory_bytes: 1912
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    H, W, M = in_nn()

    hcnt = [0] * H
    wcnt = [0] * W

    hw = []

    for i in range(M):
        h, w = in_nn()
        h, w = h - 1, w - 1
        hw.append((h, w))

    for i in range(M):
        h, w = hw[i]
        hcnt[h] += 1
        wcnt[w] += 1

    max_h = max(hcnt)
    max_w = max(wcnt)

    ans = max_h + max_w - 1

    h_index = []
    w_index = []

    for i in range(H):
        if hcnt[i] == max_h:
            h_index.append(i)

    for i in range(W):
        if wcnt[i] == max_w:
            w_index.append(i)

    hw_set = set(hw)
    # print(h_index)
    # print(w_index)

    hn = len(h_index)
    wn = len(w_index)

    f = False
    for i in range(hn):
        for j in range(wn):
            if (h_index[i], w_index[j]) not in hw_set:
                f = True

        if f or wn * i > 10**6:
            ans += 1
            break

    print(ans)


if __name__ == '__main__':
    main()


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

const long long INF = 1LL << 62;

int main() {
    int N, W;
    cin >> N >> W;
    int w[N], v[N];
    for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];

    long long dp[100001];  // dp[j] = 価値がちょうど j となるように選んだときの重さの最小値(配列再利用をするので i 番目という情報は入っていない)
    for (int j = 0; j < 100001; ++j) dp[j] = INF;
    dp[0] = 0;

    for (int i = 1; i <= N; ++i) {
        for (int j = 100000; j >= 0; --j) {
            if (j - v[i - 1] >= 0) dp[j] = min(dp[j], dp[j - v[i - 1]] + w[i - 1]);  // i 番目の商品を入れるか入れないか
        }
    }

    long long ans;
    for (int j = 0; j < 100001; ++j) {
        if (dp[j] <= W) ans = j;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i,n) for (long long i=0; i<(long long)(n); i++)
using Graph = vector<vector<int>>;
using ll = long long;


int main() {
    ll a,b,n;
    cin>>a>>b>>n;
    if(n<b){
        ll x=n;
        ll ans=ll(a*n/b)-a*ll(n/b);
        cout<<ans<<endl;
        return 0;
    }
    else if(n>=b){
        ll x=b-1;
        ll ans=ll(a*x/b)-a*ll(x/b);
        cout<<ans<<endl;
        return 0;
    }
}

Measured memory_bytes: 3588
a,b,c=map(int, input().split())
d=int(input())
ans="No"
k=0
for i in range(d+1):
    b2=b*(2**(d-k))
    c2=c*(2**(k))
    if(a<b2<c2):
        ans="Yes"
    k+=1
print(ans)

Measured memory_bytes: 9028
#include <bits/stdc++.h>
#define Rep(i,j,n) for(int i=j; i<n; i++)
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n,q; cin >> n >> q;
    ll ans=(ll)(n-2)*(n-2);
    vector<int> pl(n+1,n-2),vl(n+1,n-2);
    int cp,cv;
    cp=cv=n;
    rep(i,q){
        int a,b; cin >> a >> b;
        if(a==1){
            if(b<cv){
                ans-=cp-2;
                Rep(j,b,cv) vl[j]=cp-2;
                cv=b;
            }
            else ans-=vl[b];
        }
        else{
            if(b<cp){
                ans-=cv-2;
                Rep(j,b,cp) pl[j]=cv-2;
                cp=b;
            }
            else ans-=pl[b];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n,m;
    string s[110];
    string t[110];
    cin >> n;
    for(int i=0; i<n;i++) cin >> s[i];
    cin >> m;
    for(int i=0; i<m;i++) cin >> t[i];
    map<string, int> result;
    for(int i=0; i<n; i++){
        if(result[s[i]]){
            result[s[i]]++;
        }else{
            result[s[i]] = 1;
        }
    }
    for(int i=0; i<m; i++){
        if(result[t[i]]){
            result[t[i]]--;
        }else{
            result[t[i]] = -1;
        }
    }
    int res=0;
    for(auto itr = result.begin(); itr != result.end(); ++itr){
        if(itr->second > res){
            res = itr->second;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
					
public class Program
{
	public static void Main()
	{
		
		int n = int.Parse(Console.ReadLine());
		long cnt =0;
		
		for(int i = 1 ; i <= n ; i++)
		{
			if((i%3!=0)&&(i%5!=0)){
				cnt = cnt+i;
			}
		}
		
		Console.WriteLine(cnt);
		
	}
}

Measured memory_bytes: 17632
n = int(raw_input())
ar = map(int, raw_input().split())

s = sum(ar)

margin = 9999999999999999999999999999999999999
pos = -7

for i in xrange(n):
    if abs(n * ar[i] - s) < margin:
        margin = abs(n * ar[i] - s)
        pos = i

print pos

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

int n, a, b; vector<int>h;

bool check(int steps) {
	int c = a - b;
	vector<int>t = h;
	for (int i = 0; i < n; i++) {
		t[i] = max(0LL, t[i] - 1LL * steps * b);
	}
	long long req = 0;
	for (int i = 0; i < n; i++) {
		req += (t[i] + c - 1) / c;
	}
	return req <= steps;
}

int main() {
	cin >> n >> a >> b; h.resize(n);
	for (auto&& x : h)cin >> x;
	int L = 0, R = 1e9;
	while (L + 1 < R) {
		int mid = (L + R) >> 1;
		if (check(mid))R = mid; else L = mid;
	}
	cout << R << endl;

	return 0;
}

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

signed main(){
	int n,x[200000],y[200000];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x[i];
		y[i] = x[i];
	}
	sort(y,y + n);
	for(int i = 0;i < n;i++){
		if(x[i] <= y[n / 2 - 1]) cout << y[n / 2] << endl;
		else cout << y[n / 2 - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>a;
	for(int i=0;i<n;i++){int x;cin>>x;a.push_back(x);}
	for(int i=n-1;i>0;i--)cout<<a[i]<<" ";
	cout<<a[0]<<endl;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int K,T;
    cin >> K >> T;
    int maxi = 0;
    rep(i,0,T){
        int a;
        cin >> a;
        maxi = max(maxi, a);
    }
    int rem = K - maxi;
    if(rem + 1 >= maxi){
        cout << 0 << endl;
    }else{
        cout << maxi - rem - 1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1)%LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main()
{
	int elaps = 0, c;

	int i, q;
	P u;
	scanf("%d %d",&n, &q);
	for (i = 1; i <= n; i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	
	head = 1; tail = n + 1;
	
	while( head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if(u.t > 0) enqueue(u);
		else {
			printf("%s %d\n",u.name, elaps);
		}
		
	}
	return 0;
}


Measured memory_bytes: 11888
# E - Red and Green Apples
def main():
    X, Y, *_, = map(int, input().split())
    P = sorted(map(int, input().split()), reverse=True)[:X]
    Q = sorted(map(int, input().split()), reverse=True)[:Y]
    R = list(map(int, input().split()))
    PQR = P + Q + R
    PQR.sort(reverse=True)
    ans = sum(PQR[: X + Y])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22520
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vi> sum(N + 1, vi(N + 1));
    REP(i, M) {
        int l, r;
        cin >> l >> r;
        sum[r][l]++;
    }
    REP(j, N + 1) REP(i, N) {
        sum[i + 1][j] += sum[i][j];
    }
    REP(i, N + 1) REPR(j, N) {
        if (j == 0) break;
        sum[i][j - 1] += sum[i][j];
    }

    REP(i, Q) {
        int l, r;
        cin >> l >> r;
        cout << sum[r][l] << endl;
    }
    return 0;
}



Measured memory_bytes: 2944
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

#define MAX_N 100005

int t;
int ver[4][MAX_N];

void printver(int k);

int main(int argc, const char * argv[]) {
    scanf("%d",&t);
    char ox;
    ver[0][0] = 1;ver[0][1]=1;
    ver[1][0] = 0;ver[1][1]=1;
    ver[2][0] = 1;ver[2][1]=0;
    ver[3][0] = 0;ver[3][1]=0;
    scanf("%c",&ox);
    for(int i=1;i<=t;i++){
        scanf("%c",&ox);
        for(int k=0;k<4;k++){
            if((ver[k][i] == 0 && ox == 'o') || (ver[k][i] == 1 && ox == 'x')){
                ver[k][i+1] = ver[k][i-1] ^ 0x01;
            }else{
                ver[k][i+1] = ver[k][i-1];
            }
        }
    }
    for(int k=0;k<4;k++){
        if(ver[k][t+1] == ver[k][1] && ver[k][t] == ver[k][0]){
            printver(k);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

void printver(int k){
    for(int i=1;i<=t;i++){
        if(ver[k][i] == 1){
            printf("S");
        }else{
            printf("W");
        }
    }
}


Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;


//int nandemo(int a)
//{
//	if (a == 1) {
//		return 2;
//	} else if (a == 2) {
//		return 3;
//	} else {
//		return 1;
//	}
//}
//
//int soreraigai(int a, int b)
//{
//	return 6 - a - b;
//}

int main()
{

	int n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;
	vector<int> t(n);
	for (int i = 0; i < n; i++) {		// グー1点、チョキ2点、パー3点
		char t_in;
		cin >> t_in;
		if (t_in == 'r') {
			t.at(i) = 1;
		} else if (t_in == 's') {
			t.at(i) = 2;
		} else {
			t.at(i) = 3;
		}
	}

	vector<int> tt(n);
	for (int i = 0; i < n; i++) {
		if (t.at(i) == 1) {
			tt.at(i) = 3;
		} else if (t.at(i) == 2) {
			tt.at(i) = 1;
		} else {
			tt.at(i) = 2;
		}
	}

	if (k * 2 < n) {	// 3ブロックに分かれるパターン
		for (int i = k; i <= n - 1 - k; i++) {
			if (tt.at(i) == tt.at(i - k)) {
				if (tt.at(i) == tt.at(i + k)) {
					//tt.at(i) = nandemo(tt.at(i));
					tt.at(i) = -1;
				} else {
					//tt.at(i) = soreraigai(tt.at(i - k), tt.at(i + k));
					tt.at(i) = -1;
				}
			}
		}
		for (int i = n - k; i < n; i++) {
			if (tt.at(i) == tt.at(i - k)) {
				//tt.at(i) = nandemo(tt.at(i));
				tt.at(i) = -1;
			}
		}
	} else {			// 2ブロックに分かれるパターン
		for (int i = k; i < n; i++) {
			if (tt.at(i) == tt.at(i - k)) {
				//tt.at(i) = nandemo(tt.at(i));
				tt.at(i) = -1;
			}
		}
	}

	int64_t ans = 0;
	for (int tt_ele : tt) {
		if (tt_ele == 1) {
			ans += r;
		}else if (tt_ele == 2) {
			ans += s;
		} else if(tt_ele == 3){
			ans += p;
		}
	}

	cout << ans << endl;
	
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;

int main() {
    cin >> n;

    Vi x(9, 0);
    REP(i, n) {
        int a; cin >> a;
        if (a < 400) x[0]++;
        else if (a < 800) x[1]++;
        else if (a < 1200) x[2]++;
        else if (a < 1600) x[3]++;
        else if (a < 2000) x[4]++;
        else if (a < 2400) x[5]++;
        else if (a < 2800) x[6]++;
        else if (a < 3200) x[7]++;
        else x[8]++;
    }

    int c = 0;
    REP(i, 8) if (x[i] > 0) c++;

    if (c == 0) {
        cout << 1 << ' ';
    } else {
        cout << c << ' ';
    }

    cout << c + x[8] << '\n';

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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 k,a,b;

int main(){
    cin >> k >> a >> b;
    ll res = 0;
    if(b-a>2){
        if(k>=a+1){
            k-=a-1;
            res += a;
            ll k2 = k/2;
            k-=k2*2;
            res += (b-a)*k2;
            res += k;
        }else{
            res = 1+k;
        }
    }else{
        res=1+k;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;
static const int MAX = 100000;
static const int INF = (1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s) {
    queue<int> q;
    q.push(s);
    V[s] = true;
    while (!q.empty()){
        int u = q.front(); q.pop();
        out.push_back(u);
        for (int i = 0; i < G[u].size(); i++)
        {
            int v = G[u][i];
            indeg[v]--;
            if (indeg[v] == 0 && !V[v]){
                V[v] = true;
                q.push(v);
            }
        }
    }
}

void topological_sort(){
    for (int i = 0; i < N; i++){
        indeg[i] = 0;
    }
    for (int u = 0; u < N; u++){
        for (int i = 0; i < G[u].size(); i++){
            int v = G[u][i];
            indeg[v]++;
        }   
    }
    for (int u = 0; u < N; u++){
        if (indeg[u] == 0 && !V[u]){
            bfs(u);
        }
    }
    for (list<int>::iterator it = out.begin(); it != out.end(); it++){
        cout << *it << endl;
    }    
}

int main(){
    int s, t, M;
    cin >> N >> M;
    for (int i = 0; i < N; i++){
        V[i] = false;
    }
    for (int i = 0; i < M; i++){
        cin >> s >> t;
        G[s].push_back(t);
    }

    topological_sort();
    
}


Measured memory_bytes: 6276
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1, 1, -1};
int dy[] = {1, 0, -1, 0, 1, 1};
#define INF 100000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX], finv[MAX], inv[MAX];
const int MX = 1000005;

int main(){
    string s;cin>>s;
    int n=s.size();
    int count=0,ans=0;
    for(int i=0;i<n;i++){
        count=0;
        if(s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T') count++;
        else continue;
        for(int j=i+1;j<n;j++){
            if (s[j]=='A' or s[j]=='C' or s[j]=='G' or s[j]=='T') count++;
            else{
                ans=max(ans,count);
                break;
            }
        }
        ans=max(ans,count);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#!python3

# input
Q = int(input())
A, B = [None] * Q, [None] * Q
for i in range(Q):
    A[i], B[i] = sorted(map(int, input().split()))


def solve(a, b):
    w = a * b - 1
    left, right = 0, b - a
    while right - left > 1:
        x = (left + right) // 2
        v = w // (a + x)
        if v < a:
            right = x
        else:
            left = x

    n = left
    left, right = 0, n
    while right - left > 1:
        x = (left + right) // 2
        v = w // (a + x)
        if v < a + x:
            right = x
        else:
            left = x

    return right + (w // (a + right)) - (w // (a + n))


def main():
    for a, b in zip(A, B):
        ans = 2 * (a - 1) + solve(a, b)
        print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

using Number = double;
const Number EPS = 1e-10;

inline int sign(Number x) { return (x < -EPS) ? -1 : (x > EPS) ? +1 : 0; }
inline bool equal(Number a, Number b) { return sign(a - b) == 0; }

class Point {
public:
    Number x, y;

    Point() {}
    Point(Number x, Number y) : x(x), y(y) {}

    Point operator-(const Point &rhs) const {
        return Point(this->x - rhs.x, this->y - rhs.y);
    }
};

inline Number abs_cross(const Point &p1, const Point &p2) {
    return p1.x * p2.y - p1.y * p2.x;
}

class Line : public std::array<Point, 2> {
public:
    Line() {}
    Line(const Point &p1, const Point &p2) {
        (*this)[0] = p1; (*this)[1] = p2;
    }
};
inline bool IsParallel(const Line &l1, const Line &l2) {
    return equal(abs_cross(l1[0] - l1[1], l2[0] - l2[1]), 0.0);
}

int Search(const int i, const int m, vector<int> &idx, const vector<Point> &p) {
    if (i == m - 2) {
        int sum = 0;
        vector<bool> check(m / 2, false);

        for (int j = 0; 2 * j < m; ++j) {
            if (check[j]) continue;

            check[j] = true;
            int num = 1;
            Line l(p[idx[2 * j]], p[idx[2 * j + 1]]);
            for (int k = j + 1; 2 * k < m; ++k)
                if (IsParallel(l, Line(p[idx[2 * k]], p[idx[2 * k + 1]]))) {
                    ++num;
                    check[k] = true;
                }
            sum += num * (num - 1) / 2;
        }
        return sum;
    }

    int res = 0;
    for (int j = i + 1; j < m; ++j) {
        swap(idx[i + 1], idx[j]);
        res = max(res, Search(i + 2, m, idx, p));
        swap(idx[i + 1], idx[j]);
    }

    return res;
}

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

    int m;
    cin >> m;
    vector<Point> p(m);
    for (auto &pp : p) cin >> pp.x >> pp.y;

    vector<int> idx(m);
    iota(idx.begin(), idx.end(), 0);

    cout << Search(0, m, idx, p) << endl;

    return 0;
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[200010], b[1000010], mp[1000010];
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%d",a+i);
            ++mp[a[i]];
        }
        memset(b, -1, sizeof b);
        for(int i=0; i<n; ++i){
            if(b[a[i]]==-1){
            	b[a[i]]=n;
            	for(int j=1; j*j<=a[i]; ++j){
            		if(a[i]%j==0){
            			b[a[i]]-=mp[a[i]/j];
            			if(j!=a[i]/j)
            			b[a[i]]-=mp[j];
            		}
            	}
            }
            if(b[a[i]]==n-1)++ans;
        }
        printf("%lld\n",ans);
    }
  return 0;
}




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

int main(){
  int N,total=1,count1=0,count2=0;
  cin>>N;
  vector<int> P(N),Q(N);
  for(int i=0;i<P.size();i++){
    cin>>P[i];
  }
  for(int i=0;i<N;i++){
    cin>>Q[i];
  }

  for(int i=1;i<=N;i++){
    total*=i;
  }

  while(next_permutation(P.begin(),P.end())){
    count1++;
  }

  while(next_permutation(Q.begin(),Q.end())){
    count2++;
  }
  int a=total-count1;
  int b=total-count2;
  
  cout<<abs(a-b)<<endl;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define UP(i,l,h) for(int i=l;i<h;i++)
#define DOWN(i,h,l) for(int i=h-1;i>=l;i--)
#define W(t) while(t)
#define MEM(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define MAXN 500010
#define COUT(x) cout<<x<<endl
using namespace std;
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
     double ans=0;
//    COUT(ans);
     double ori=1/pow(2,m);
//    COUT(ori);
     double add=ori;
    UP(i,1,1500){
        if(n==m) ans+=add*(i*m*1900);
        else ans+=add*(i*m*1900+100*i*(n-m));
        add*=(1-ori);
//        COUT(add);
    }
    printf("%.f\n",ans);
}


Measured memory_bytes: 512