akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
bool check(map<ll,ll> &m,ll a,ll se){
  if(m[a]>=se){
    if(a==1) return true;
    else {
      m.erase(a);
      m[a-1]++;
      if(check(m,a-1,se))return true;
    }
  }
  return false;
}
int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
bool c=1;
rep(i, n){
  cin >> a[i];
  if(i!=0&&a[i]<=a[i-1])c=0;
}
if(c){cout << 1 << endl;return 0;}
//upperは常に条件を満たすlowerは常に条件を満たさない
//条件を満たす最小のindexを返す
ll lower = 1; //上限のindex
ll upper = n; //上限のindex
ll seenow;
bool ok;
while (true)
{
  seenow = (lower + upper) / 2;

  //todo:seenowに対して処理
  //条件を満たすならok=true;にする 満たさないならok=false;
  map<ll,ll> m;
  ok=true;
  rep(i,n-1){
    if(a[i]==a[i+1]){
      m[a[i+1]]++;
      if(check(m,a[i+1],seenow)){ok=false;break;}
    }
    if(a[i]<a[i+1]){
    }
    if(a[i]>a[i+1]){
      m[a[i+1]]++;
      auto itr=m.find(a[i+1]);
      itr++;
      while(itr!=m.end()){
        itr=m.erase(itr);
      }
      if(check(m,a[i+1],seenow)){ok=false;break;}
    }
  }

  if (ok)
  {
    upper = seenow;
    if (upper == lower + 1)
    {
      ans = seenow;
      break;
    }
  }
  else
  {
    lower = seenow;
    if (upper == lower + 1)
    {
      ans = seenow + 1;
      break;
    }
  }
}
cout << ans << endl;
return 0;
}


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

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!T;r.popFront;}}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  int[int] h;
  foreach (ai; a) h[ai]++;

  auto u = h.keys.sort!"a>b".filter!(ai => h[ai] >= 2).array;

  if (u.length == 0 || u.length == 1 && h[u[0]] < 4)
    writeln(0);
  else if (h[u[0]] >= 4)
    writeln(u[0].to!long^^2);
  else
    writeln(u[0].to!long*u[1]);
}


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

def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 1以上200以下の整数
    """
    # 求解処理
    ans = 0
    for n in range(1, N + 1, 2):
        divisors_count = 0
        for i in range(1, n + 1):
            if n % i == 0:
                divisors_count += 1
        if divisors_count == 8:
            ans += 1

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N = get_input()

    # メイン処理
    main(N)


Measured memory_bytes: 9212
def resolve():
    N = int(input())
    LR = [list(map(int, input().split())) for i in range(N)]
    cnt = 0
    for i in range(N):
        cnt += LR[i][1] - LR[i][0] + 1
    print(cnt)

            

if '__main__' == __name__:
    resolve()

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	int n = 0;
	cin >> n;
	vector<int> time(n);
	REP(i, n)
	{
		cin >> time[i];
	}

	int m = 0;
	cin >> m;
	int ct = 0;
	int a, b = 0;
	REP(i, m)
	{
		cin >> a >> b;
		REP(j, n)
		{
			if (a - 1 == j)
			{
				ct += b;
			}
			else
			{
				ct += time[j];
			}
		}
		COUT(ct);
		ct = 0;
	}


	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
ans = 0
for i in range(K+1,N+1):
    if K==0:
        ans += N
    elif N%i >= K:
        ans += N+1 -((N//i)+1)*K
    else:
        ans += N+1 -(N//i)*K-(N%i) -1
print(ans)

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

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;

int main(){
	setIO();
	int a, b, c, k, sum=0;
	cin>>a>>b>>c>>k;
	sum+=min(a,k);
	k-=min(a,k);
	k-=min(b,k);
	sum-=min(max(0,k),c);
	cout<<sum<<endl;
}

Measured memory_bytes: 3652
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
 
typedef long long ll;
using namespace std;

int main(){
    string S;
    int sum =0;
    cin >> S;
    reverse(S.begin(),S.end());
    int n = S.length();
    ll a[2020];
    ll d = 1;
    a[0] = 1;
    for(int i = 1 ; i < 2020 ; i++){
        a[i] = 0;
    }
    for(ll i = 0 ; i < n ; i++){
        char ltr = S[i];
        sum += (S[i] - '0')*d;
        sum %= 2019;
        d *= 10;
        d %= 2019;
        a[sum]++;
    }
    ll ans=0;
    for(int i = 0 ; i <= 2018 ; i++){
        ans += a[i]*(a[i]-1)/2;
    }
    cout << ans;
    return 0;
}

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

void setV(vector< vector<int> > &v){
  string str, tmp; cin >>str;
  vector<string> nums;
  stringstream ss(str);
  while(getline(ss, tmp, ',')) nums.push_back(tmp);
  int from = atoi(nums[0].c_str()), to = atoi(nums[1].c_str()), cost = atoi(nums[2].c_str());
  v[from][to] = cost;
  v[to][from] = cost;
}

int main() {
  int V;
  while(cin >>V && V){
    int E; cin >>E;
    vector< vector<int> > v(V, vector<int>(V, INF));
    REP(i, E) setV(v);

    priority_queue< P, vector<P>, greater<P> > open;
    open.push(P(100, 0));
    vector<int> closed(V, INF);

    int min_cost = 0;
    while(!open.empty()){
      P now = open.top();
      open.pop();

      if(closed[now.second] != INF) continue;
      closed[now.second] = now.first;
      min_cost += (now.first - 100) / 100;

      REP(i, V){
        if(closed[i] == INF && v[now.second][i] != INF){
          open.push(P(v[now.second][i], i));
        }
      }

    }
    cout <<min_cost <<endl;
  }
  return 0;
}

Measured memory_bytes: 1396
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const double PI=3.14159265358979323846;

double getDiceEV(int n){
  double r = 1.*(n+1) / 2.0;
  return r;
}

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> p(N);
  rep(i,N) cin >> p[i];

  vector<int> s(N+1, 0);
  rep(i,N) s[i+1] = s[i] + p[i];

  ll res = -1e+13;
  int start = 0;
  for(int i = 0; i <= N-K; i++){
    ll val = s[K+i] - s[i];
    if(res < val){
      res = val;
      start = i;
    }
  }
  double ans = 0.;
  for(int i=start; i<start+K; i++)
    ans+=getDiceEV(p[i]);
  printf("%.10f", ans);
}


Measured memory_bytes: 1920
N,Q = map(int, input().split())
S = input()
range_list = [list(map(int, input().split())) for _ in range(Q)]
 
ac_counter = [0]
# acという文字列をカウントしておくlistを作成
for i in range(1,N):
    ac_counter.append(ac_counter[i-1]+1 if S[i-1:i+1] == 'AC' else ac_counter[i-1])
# 上で作ったリストを使い範囲内に何個あるのか確認
for range_list in range_list:
    print(ac_counter[range_list[1]-1] - ac_counter[range_list[0]-1])

Measured memory_bytes: 30672
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>

using namespace std;
using ull = unsigned long long;

int main() {
	int A, B;
	cin >> A >> B;

	if (B % A == 0) {
		cout << A + B << endl;
	} else {
		cout << B - A << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,T;
  cin>>n>>T;
  int count=0;
  int a=1001;
  for(int i=0;i<n;i++){
    int c,t;
    cin>>c>>t;
    if(t>T){
      count++;
    }
    else{
      if(a>c){
        a=c;
      }
    }
  }
  if(count==n){
    cout<<"TLE";
  }
  else{
    cout<<a;
  }
}
      
    


Measured memory_bytes: 3644
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(void){
  int N;
  cin >> N;
  int a[N];
  rep(i, N)
    cin >> a[i];
  //入力終わり

  int ans = 0;

  //既に押したボタンかどうか
  bool pushed[N];
  rep(i, N)
    pushed[i] = false;

  int now = 0;
  while(now != 1){
    //押したボタンに戻ったら無限ループする
    if(pushed[now] == true){
      cout << -1 << endl;
      return 0;
    }
    //押したよマーク
    pushed[now] = true;
    ans++;
    //次のボタンへ
    now = a[now]-1;
  }

  //解答
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define X first
#define Y second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<
#define debug(...) fprintf(stderr, __VA_ARGS__)

int main()
{
  int n; ll t, a, b = 0, r = 0;
  scanf("%d %lld", &n, &t);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a);

    r += a + t - max(a, b);

    b = a + t;//cout<<r<<' '<<b<<endl;
  }
  printf("%lld", r);
  return 0;
}


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

int main() {
  int n,cnt1=0,cnt2=0,cnt3=0;
  cin >> n;
  for (int l = 1; l <= n; l++) {
    cnt1 = 0,cnt2=0;
    //処理
    int m = sqrt(n);
    for (int i = 1; i <= m; i++) {
      for (int j = i; j <= m; j++) {
        for (int k = j; k <= m; k++) {
          if ((i*i+j*j+k*k+i*j+j*k+k*i)==l) {
            cnt1++;
            if (i==j || j==k||k==i) cnt2++;
          }
        }
      }
    }
    cnt3=0;
    bool check = 0;
    for (int i = 1; i < 100; i++) {
      if (l==6*i*i) {
        check=1;
        break;
      }
      if (l<6*i*i) break;
    }
    if (check == 1) cnt3=1;

    //処理　　
    cout << (cnt1-cnt2)*6+(cnt2-cnt3)*3+cnt3 << endl;
  }
}


Measured memory_bytes: 3520
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

ll keta(ll n) {
    ll ret = 0;
    while (n > 9) {
        n /= 10;
        ret++;
    }
    return ret;
}

ll sum(ll n) {
    ll ret = 0;
    while (n > 0) {
        ret += n%10;
        n /= 10;
    }
    return ret;
}

int top(ll n) {
    ll buf = 1;
    while (true) {
        ll bufbuf = n / buf;
        if (bufbuf >= 1 && bufbuf <= 9) return bufbuf;
        else buf *= 10;
    }
}

int main() {
    ll n = 0;
    cin >> n;
    ll one = sum(n);
    ll two = 9*keta(n) + top(n) - 1;
    cout << max(one, two) << endl;
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int ans;
  S.pop_back();
  while(1) {
    if(S.size() % 2 == 0) {
      int mid = S.size() / 2;
      if(S.substr(0, mid) == S.substr(mid)) {
        ans = S.size();
        break;
      }
    }
    S.pop_back();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll ans = 0;
    VVL dp(N+1, VL(N+1, 0));
    for(ll i = N-1; i >= 0; i--){
        for(ll j = N-1; j > i; --j){
            if(S[i] == S[j]) dp[i][j] = max(dp[i][j], dp[i+1][j+1] + 1);
             ans = max(ans, min(dp[i][j], j - i));
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(void)
{

	int n, k;
	cin >> n >> k;
	vector<int> x(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}

	int res = 1000000000;
	for (int i = 1; i <= n - k+1; i++) {
		res = min(res, min(abs(x[i]) + x[i + k - 1] - x[i], abs(x[i+k-1]) + abs(x[i + k - 1] - x[i])));
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rec(n,i) for(int i=0;i<n;i++)
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>h(n);
	rec(n, i) cin >> h[i];
	reverse(h.begin(), h.end());
	string ans = "Yes";
	for (int i = 1; i<n; i++) {
		if (h[i] - 1 == h[i - 1]){
				h[i]--;
		}
		else if (h[i] > h[i - 1])ans = "No";
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <iostream>
using namespace std;

#define INF      2147483647
typedef unsigned int uint;

uint n_array;
uint queries;
vector<uint> D;

void init(uint n_req){
  n_array = 1;
  while( n_array < n_req ){
    n_array *= 2;
  }
  D.resize(2*n_array-1);
  for( uint i = 0 ; i <= 2*n_array-1 ; i++ ){
    D[i] = INF;
  }
}

void update(uint k, uint a){
  k += n_array - 1;
  D[k] = a;
  while( k > 0 ){
    k = (k-1) / 2;
    D[k] = min( D[k*2+1] ,D[k*2+2] );
  }
}

uint query(uint a, uint b, uint k, uint l, uint r) {
  if( r <= a || b <= l ){ // case 1
    return INF;
  }else if( a<= l && r <= b ){ // case 2
    return D[k];
  }
  // case 3
  uint vl = query( a, b, k*2+1, l, (l+r)/2 );
  uint vr = query( a, b, k*2+2, (l+r)/2, r );
  return min( vl, vr );
}

uint findMin(uint a, uint b){
  return query(a, b+1, 0, 0, n_array);
}

void printD(){
  int i = 0;
  for (const auto& e : D) {
     printf("[%d]" ,i); i++;
     std::cout << e << std::endl;
  }
}

int main(){
  uint n_req;
  scanf("%d %d" ,&n_req ,&queries);
  init(n_req);
  for(uint i = 0 ; i < queries ; i++){
    uint com; uint x; uint y;
    scanf("%d %d %d" ,&com ,&x ,&y ); 
    if( com == 0){
      update(x,y);
    }else{
      uint m = findMin(x,y);
      printf("%d\n" ,m);
    }
  }


  return 0;
}



Measured memory_bytes: 3900
import copy
N = int(input())
S = input()
List=list(S)
newO = 0
NewList = copy.deepcopy(List)
res=""
for i in range(len(S)):
  newO = ord(List[i])+N
  if newO >=91:
    newO = newO-26
  NewList[i]=chr(newO)
for i in range(len(S)):
  res+=NewList[i]
print(res)
  

Measured memory_bytes: 9440
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/
typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define ff first
#define ss second
#define gc getchar_unlocked
#define fri(i, j , n) for (auto (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= (n); ++(i))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define pb emplace_back
#define mp make_pair
#define getchar_unlocked getchar
# define TMP template<typename
#ifdef LOCAL 
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
    
    ~debug() { cerr << endl; }
    template < class c > typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return * this; }
    template < class c > typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return * this << range(begin(i), end(i)); }
    template < class c, class b > debug & operator <<(pair < b, c > d) {
        return * this << "(" << d.first << ", " << d.second << ")";
    }
    template < class c > debug & operator <<(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        return * this << "]";
    }};
#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
TMP Arg1>
void __f(const char *name, Arg1 &&arg1)
{cout << name << ": " << arg1 << "\n";}
TMP Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{const char *comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);
}
void in(int &x){
    cin  >> x;
}
#else
inline void in(int &x)
    {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar_unlocked());
    if(c=='-') {neg=1;c=getchar_unlocked();}
    for(;c>47 && c<58;c = getchar_unlocked()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
    }
inline void uin(ulli &n){
    register ulli c=gc();
    n=0;
    while(c<'0'||c>'9')
    c=gc();
    while(c<='9'&&c>='0'){
    n=n*10+c-'0';
    c=gc();}
}
#endif
/*----------check constraints again-------------*/

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
    lli a,b;
    cin >> a >> b;
    lli ans = a-2*b;
    if(ans <0) cout <<  0 ; else cout << ans;
}
















Measured memory_bytes: 256
n = gets.chop.to_i
t = []
x = []
y = []

statement='Yes'
n.times do
  line = gets.strip.split.map(&:to_i)
  t << line.shift
  x << line.shift
  y << line.shift
end
t.unshift(0)
x.unshift(0)
y.unshift(0)
n.times do |i|
  time=t[i+1]-t[i]
  x_dis=(x[i+1].to_i-x[i].to_i).abs
  y_dis=(y[i+1].to_i-y[i].to_i).abs
  distance= x_dis+y_dis
  while time >= distance +2 do
    time = time - 2
  end
  unless distance==time
    statement='No'
  end
end
puts statement

Measured memory_bytes: 4908
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	double ans=1.0*((n+1)/2);
	cout<<fixed<<setprecision(10)<<ans/n;
	return 0;
}


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

using namespace std;

typedef long long ll;

ll solve() {
    ll MAX = pow(10, 18);
    int n; cin >> n;
    vector<ll> nums;
    ll a;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a == 0) {
            return 0;
        }
        nums.push_back(a);
    }
    ll res = 1;
    for (ll num : nums) {
        if (MAX / res >= num)
            res *= num;
        else
            return -1;
    }
    
    return res;
}

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

	cout << solve() << endl;
}


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

const int N = 100;

int selection_sort(int n, int A[]) {
  int sw = 0, min_j;

  for (int i = 0; i < n; i++) {
    min_j = i;
    for (int j = i+1; j < n; j++) {
      if (A[j] < A[min_j]) min_j = j;
    }
    if (min_j != i) {
      sw++;
      int tmp = A[i];
      A[i] = A[min_j];
      A[min_j] = tmp;
    }
  }

  return sw;
}

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

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

  int sw = selection_sort(n, A);

  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
if ( A + B > C + D ) {
  cout << "Left" << endl;
}
  else if ( A + B == C + D ){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
struct Node{
  int keydata;
  struct Node *left,*right,*parent;
};
 
struct Node *root,*NIL;
void insert(int);
 
void preorder(struct Node *);
 
void inorder(struct Node *);

struct Node * find(struct Node * ,int);
int main(){
 
  int n,i,x;
  char P[7];
  struct Node *t;
  
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++)
    {
      scanf("%s",P);
      if(strcmp("insert",P)==0){
    scanf("%d",&x);
    insert(x);
      }
      else if(strcmp("find",P)==0){
	scanf("%d",&x);
	t=find(root,x);
	if(t==NIL)printf("no\n");
	else printf("yes\n");
      }
      else
    {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    }
 
 
  return 0;
}
 
void insert(int a)
{
  struct Node *y=NIL,*x=root;
 
  struct Node *z;
 
  z=(struct Node *)malloc(sizeof(struct Node));
 
  z->keydata=a;
 
  z->left=NIL;
 
  z->right=NIL;
 
  while(x!=NIL)
    {
      y=x;
 
      if(z->keydata < x->keydata) x=x->left;
      else x=x->right;
    }
 
  z->parent=y;
 
  if(y==NIL) root = z;
 
  else{ if(z->keydata < y->keydata) y->left = z;
 
  else y->right = z;
}
}
void preorder(struct Node *u){
  if (u == NIL)
    return ;
  printf(" %d",u->keydata);
  preorder(u->left);
  preorder(u->right);
}
 
void inorder(struct Node *u){
  if (u == NIL)
    return ;
  inorder(u->left);
  printf(" %d",u->keydata);
  inorder(u->right);
}

struct Node * find(struct Node *r, int k){
  while(r!=NIL && k!=r->keydata){
    if(k<r->keydata) r= r->left;
    else r=r->right;
  }
  return r;
}

Measured memory_bytes: 19360
#include<bits/stdc++.h>
#define ll long long
#define inf 1e9
#define pii pair < int, int >
using namespace std;

int main()
{
    int n, m;

    cin >> n >> m;

    cout << ((n * (n - 1)) / 2) + ((m * (m - 1)) / 2) << endl;

    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<string> S(N);
  vector<int> num(26);
  for (int i = 0; i < N; i++)
  {
    cin >> S[i];
  }
  for (int i = 0; i < S[0].size(); i++)
  {
    num[S[0][i] - 97]++;
  }
  for (int i = 1; i < N; i++)
  {
    vector<int> cnt(26);
    for (int j = 0; j < S[i].size(); j++)
    {
      cnt[S[i][j] - 97]++;
    }
    for (int k = 0; k < 26; k++)
    {
      num[k] = min(num[k], cnt[k]);
    }
  }
  vector<char> ans;
  for (int i = 0; i < 26; i++)
  {
    while (num[i] > 0)
    {
      ans.push_back(i + 97);
      num[i]--;
    }
  }
  for (int i = 0; i < ans.size(); i++)
  {
    cout << ans[i];
  }
  cout << endl;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  vector<int> h(N + 1);
  REP1(i, N) cin >> h[i];
  vector<int> dp(N + 1);
  dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);
  for (int i = 3; i <= N; ++i)
    dp[i] =
        min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    int x, a, b; cin >> x >> a >> b;
    if (abs(x-a) < abs(x-b)) cout << 'A' << endl;
    else cout << 'B' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15);
    
  string S,T;cin>>S>>T;
  int ans = 0;
  rep(i,S.size()) if(S[i] != T[i]) ans++;
  out(ans);	
}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

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

ll mod(ll a, ll b) { //a mod b
    if (a >= 0) return a % b;
    else return (b - (-a) % b) % b;
}

ll pow2(ll n) { //(-2)^n
    ll res = 1;
    rep(i, n) res *= -2;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll sum = 0;
    stack<ll> st;

    rep(i, 40) { //(-2)^i の位
        ll div = 1LL << (i + 1);
        ll digit = (mod(mod(n, div) - mod(sum, div), div) == 0 ? 0 : 1);
        sum += digit * pow2(i);
        st.push(digit);
    }

    while (st.top() == 0) st.pop();
    while (!st.empty()) {
        cout << st.top();
        st.pop();
    }
    cout << endl;
    return 0;
}


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

int main()
{
    vector<int> V = {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;
    cin >> K;
    cout << V[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** Problem1227 : 77377 **/
int char_list[26] = {2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9};
vector<string> dic, dic2;
string target;

void solve(int pos, string tmp)
{
	if (pos == target.size()) {
		for (int i=0; i<tmp.size(); i++) {
			if (i!=0) cout << " ";
			cout << dic[tmp[i]-'0'];
		}
		cout << "." << endl;
	}
	
	rep(i, dic2.size()) {
		bool ok = true;
		rep(j, dic2[i].size()) {
			if (dic2[i][j] != target[pos+j]) {
				ok = false;
				break;
			}
		}
		
		if (ok) {
			string t = tmp; t+=i+'0';
			solve(pos+(int)dic2[i].size(), t);
		}
	}
}

int main()
{
	int N;
	while (cin>>N, N) {
		dic.resize(N); dic2.resize(N);
		rep(i, N) {
			cin>>dic[i];
			dic2[i] = dic[i];
			rep(j, dic2[i].size()) {
				dic2[i][j] = '0' + char_list[dic2[i][j]-'a'];
			}
		}
		
		cin >> target;
		solve(0, "");
		cout << "--" << endl;
	}
}

Measured memory_bytes: 1224
import java.util.Scanner;

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

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int N = 1000000;
		boolean[] primes = new boolean[N + 1];
		primes[0] = true;
		primes[1] = true;
		for (int i = 2; i <= Math.sqrt(N); i++) {
			if (!primes[i]) {
				for (int j = i * 2; j <= N; j += i) {
					primes[j] = true;
				}
			}

		}
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int count = 0;
			for (int i = n; i >= n / 2; i--) {
				if (!primes[i] && !primes[n - i]) {
					count++;
				}
			}
			System.out.println(count);
		}

	}
}

Measured memory_bytes: 23232
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
//#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(int a, int b, int mod) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
 
void solve() {
	int r;
	cin>>r;
	cout<<3*r*r<<endl;
}
 
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	fr(i,1,t) {
		solve();
	}
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

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

  if (N < 1000) {
    cout << "ABC" << endl;
  }
  else {
    cout << "ABD" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int >me[100005];
#define visit meeee
int visit[100005];
int parent[100005];
queue<int >qu;
int main(){
	int n,e;
	scanf("%d%d",&n,&e);
	for(int i=1;i<=n;i++)
		parent[i]=-1;
	for(int i=0;i<e;i++){
		int a,b,c;
		scanf("%d%d",&a,&b);
		me[a].push_back(b);
		me[b].push_back(a);
	}
	qu.push(1);
	while(!qu.empty()){
		int a=qu.front();
		visit[a]=1;
		qu.pop();
		for(auto A=me[a].begin();A!=me[a].end();A++){
			if(visit[*A]==0){
				qu.push(*A);
				visit[*A]=1;
				parent[*A]=a;
			}
		}
	}
	for(int i=2;i<=n;i++){
		if(parent[i]==-1)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	for(int i=2;i<=n;i++){
		printf("%d\n",parent[i]);
	}
}


Measured memory_bytes: 10960
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    For(i, s.size()){
        cout << (s[i] == '?' ? 'D' : s[i]);
    }
    Cout();
}




Measured memory_bytes: 3752
n = int(input())
l = list(map(int, input().split()))

result = 0


for i in range(n-2):
    #print("i")
    #print(i)
    for j in range(n-i-1):
        #print("j")
        #print(j)
        j += i+1
        for k in range(n-j-1):
            #print("k")
            #print(k)
            k+= j+1
            if l[i] == l[j] or l[j] == l[k] or l[i] == l[k]:
                pass
            elif max(l[i], l[j], l[k]) < l[i]+l[j]+l[k]-max(l[i], l[j], l[k]):
                result +=1

print(result)

Measured memory_bytes: 9104
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#define N 10
using namespace std;

int main(){
    string inp;
    while(cin >>inp){
        vector<int> vec;
        for(int i = 0; i < N; i++){
            if(inp[i] == '0'){
                vec.push_back(0);
            } else{
                vec.push_back((int)inp[i] - '0');
            }
        }
        while(vec.size() > 1){
            vector<int> tmpvec;
            for(int i = 0; i < vec.size() - 1; i++){
                tmpvec.push_back((vec[i] + vec[i + 1]) % 10);
            }
            vec = tmpvec;
        }
        cout <<vec[0] <<endl;
    }
    return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
H,W,N = map(int,input().split())
count = []
L = 0
for i in range(N):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(max(0,a-2),min(a+1,H-2)):
        for j in range(max(0,b-2),min(b+1,W-2)):
            count.append((i,j))
            L += 1
count.sort()
ans = [0]*10
tmp = 1
for i in range(L-1):
    if count[i] == count[i+1]:
        tmp += 1
    else:
        ans[tmp] += 1
        tmp = 1
if L>=1:
  ans[tmp] += 1
ans[0] = (H-2)*(W-2)-sum(ans)
for i in range(10):
    print(ans[i])

Measured memory_bytes: 109000
#!/usr/bin/env python3
#AGC27 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,x = LI()
a = LI()
a.sort()
ans = 0
for i in range(n):
    if a[i] <= x:
        x -= a[i]
        ans += 1
    else:
        break
if x > 0 and ans == n:
    print(ans-1)
else:
    print(ans)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
const int maxN = 100000 + 10;

int main() {
    int n , k ;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[n];
    }
    cout << (n  + k - 3) / (k - 1);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

d = defaultdict(list)
goal, n = map(int, input().split())
for _ in range(n):
  f, t = map(int, input().split())
  d[f].append(t)
  d[t].append(f)
for current in d[1]:
  if goal in d[current]:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 101208
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
void yoinks(){
std::ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
}
int main(){
    yoinks();
	s ss,dd;
	cin>>ss>>dd;
	int n=(int)ss.size();
	int n1=(int)dd.size();
    if(n==n1){
        for(int i=0;i<n;i++){
            cout<<ss[i]<<dd[i];
        }
    }else if(n>n1){
    for(int i=0;i<n;i++){
        if(i>=n1){
            cout<<ss[i];}
        else {cout<<ss[i]<<dd[i];}
    }
    }else{
    for(int i=0;i<n1;i++){
        if(i>=n){
            cout<<dd[i];
        }
        else {cout<<ss[i]<<dd[i];}
    }}

















return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/




Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a =    sc.nextInt();
		double num = 0;
		for(int i = 0; i < a;i++) {
			int b =    sc.nextInt();
			num += 1.0 /b;
		}
		 num = 1.0 / num;  
       System.out.println(num);
	}
}

Measured memory_bytes: 23508
#include <stdio.h>

int main(void) {

	int h,w,i,j;
	while(1){
		scanf("%d%d",&h,&w);
		if(h==0 && w==0){
			break;
		}
		i=h;
		j=w;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(i==0||i==h-1||j==0||j==w-1){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
# AOJ 0150 Twin Prime
# Python3 2018.6.17 bal4u

MAX = 10001
SQRT = 100     # sqrt(MAX)

prime = [True for i in range(MAX)]
def sieve():
	for i in range(4, MAX, 2):
		prime[i] = False
	for i in range(3, SQRT, 2):
		if prime[i] is True:
			for j in range(i*i, MAX, i):
				prime[j] = False
sieve()
tbl = [0]*MAX
ans = 0
for i in range(5, MAX, 2):
	if prime[i] and prime[i-2]: ans = i
	tbl[i] = ans
	
while True:
	n = int(input())
	if n == 0: break
	if (n & 1) == 0: n -= 1
	print(tbl[n]-2, tbl[n])


Measured memory_bytes: 5716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  map<string, int> s, t;
  vector<string> temp1(n);
  for (int i = 0; i < n; i++) {
    cin >> temp1[i];
    s[temp1[i]]++;
  }

  int m;
  cin >> m;
  vector<string> temp2(m);
  for (int i = 0; i < m; i++) {
    cin >> temp2[i];
    t[temp2[i]]++;
  }

  int max = 0;

  for (auto it = temp1.begin(); it != temp1.end(); it++) {
    max = std::max(max, s[*it] - t[*it]);
  }

  cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();

		long aa = 0;
		long ans =0;

		if(a % x != 0){
			 ans =  b/x -a/x ;
		}else{
			 ans =  b/x -a/x + 1;

		}
			
			System.out.println(ans);

		
	}
}

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

using namespace std;

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

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

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

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

int sum[4][110], sz[4];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	ll n, W, w[110], v[110];
	cin>>n>>W;
	REP(i, n){
		cin>>w[i]>>v[i];
	}
	vl cnt[4];
	cnt[0].push_back(v[0]);
	sz[0]=1;
	REP(i, n-1){
		cnt[w[i+1]-w[0]].push_back(v[i+1]);
		++sz[w[i+1]-w[0]];
	}
	REP(i, 4){
		sort(ALL(cnt[i]), greater<int>());
	}
	REP(i, 4){
		REP(j, sz[i]){
			sum[i][j+1]=sum[i][j]+cnt[i][j];
		}
	}
	int ans=0;
	REP(i, sz[0]+1){
		REP(j, sz[1]+1){
			REP(k, sz[2]+1){
				REP(l, sz[3]+1){
					ll tmp=(i+j+k+l)*w[0]+j+k*2+l*3;
					if(tmp<=W){
						CHMAX(ans, sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l]);
					}
				}
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    a.sort(reverse=True)
    if n%2:
        ans += a[0]
        for i in range(1, n//2):
            ans += a[i]*2
        ans += a[n//2]
    else:
        ans += a[0]
        for i in range(1, n//2):
            ans += a[i]*2
    print(ans)
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 94148