akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

const int MOD=10000;

vector < int > A,B; 
int M;
int dp[505][10][3][505][2];

void sub1(vector<int> &q){
    for(int i=q.size()-1; i>=0; --i){
	if(q[i]==0){
	    q[i]=9;
	} else {
	    --q[i];
	    return;
	}
    }
    return;
}

int ZigZag(const vector<int> v,int idx,int prv,int updown,int mod,bool free){
    if(idx==v.size()) return !mod;
    if(~dp[idx][prv][updown][mod][free]) return dp[idx][prv][updown][mod][free];
    int r=(free?9:v[idx]);
    int ret=0;
    for(int i=0; i<=r; ++i,ret%=MOD){
	if(updown==0&&prv<=i) continue;
	if(updown==1&&prv>=i) continue;
	if(updown==2&&prv&&prv==i) continue;
	int u;
	if(updown==2){
	    if(prv==0){
		u=2;
	    } else if(prv>i){
		u=1;
	    } else {
		u=0;
	    }
	} else u=!updown;
	ret+=ZigZag(v,idx+1,i,u,(mod*10+i)%M,free|(i!=v[idx]));
    }
    return dp[idx][prv][updown][mod][free]=ret%MOD;
}

int main(){
    string a,b;
    cin >> a >> b >> M;
    for(int i=0; i<a.size(); ++i) A.push_back(a[i]-'0');
    for(int j=0; j<b.size(); ++j) B.push_back(b[j]-'0');
    sub1(A);
    
    memset(dp,-1,sizeof(dp));
    int ra=ZigZag(A,0,0,2,0,false);
    memset(dp,-1,sizeof(dp));
    int rb=ZigZag(B,0,0,2,0,false);
    
    int ret=(rb-ra+MOD)%MOD;
    cout << ret << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


signed main(){
    vector<int>a(3);
    rep(i,3)cin>>a[i];
    sort(all(a));
    cout<<a[2]*10+a[1]+a[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Aowal
 */

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


class TaskB {
public:
    void solve(std::istream &in, std::ostream &out) {
        int h, w;
        in >> h >> w;
        int a[55][55] = {{0}}, b[55][55] = {{0}};
        char c[h][w];
        char ch;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                in >> ch;
                c[i][j] = ch;
                a[i + 1][j + 1] = (ch == '#');
            }
        }
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (c[i][j] == '.') {
                    b[i + 1][j + 1] =
                            a[i][j] + a[i][j + 1] + a[i][j + 2] + a[i + 1][j] + a[i + 1][j + 2] + a[i + 2][j] +
                            a[i + 2][j + 1] + a[i + 2][j + 2];
                }
            }
        }

        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (c[i][j] == '.') {
                    out << b[i + 1][j + 1];
                } else {
                    out << c[i][j];
                }
            }
            out << endl;
        }

    }
};


int main() {
    TaskB solver;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
eval"N,M,K="+`tr ' ' ,`
f=t=1,*(1..N).map{t=t*_1%Z=998244353}
p M*(0..K).sum{(M-1).pow(j=N+~_1,Z)*f[N-1]*(f[j]*f[_1]).pow(Z-2,Z)}%Z

Measured memory_bytes: 34564
/*選択ソート*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    int count = 0;
    rep(i, n){
        int minv = i;
        for(int j=i; j<n; ++j){
            if(a[minv] > a[j]){
                minv = j;
            }
        }
        if(minv != i){
            count++;
            int tmp = a[minv];
            a[minv] = a[i];
            a[i] = tmp;
        }
    }

    rep(k, n){
        cout << a[k];
        if(k != n-1){
            cout << " ";
        }
    }
    cout << "\n" << count << endl;

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";


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

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            ArrayList<Long> list = new ArrayList<Long>();

            list = perm(String.valueOf(n).length());
            long cnt = 0;
            for (long l : list) {
                if (l <= n) {
                    String str = String.valueOf(l);
                    if (str.contains("3") &&
                            str.contains("5") &&
                            str.contains("7")) {
                        cnt++;
                    }
                }
            }

            out.print(cnt);
        }

        private ArrayList<Long> perm(long n) {
            ArrayList<Long> list;
            if (n == 1) {
                list = new ArrayList<>();
                list.add((long) 3);
                list.add((long) 5);
                list.add((long) 7);
                return list;
            } else {
                list = perm(n - 1);
                ArrayList<Long> copy = new ArrayList<>(list);
                for (long l : perm(n - 1)) {
                    if (String.valueOf(l).length() == n - 1) {
                        copy.add(l * 10 + 3);
                        copy.add(l * 10 + 5);
                        copy.add(l * 10 + 7);
                    }

                }
                return copy;
            }
        }

    }
}



Measured memory_bytes: 29076
# 時計, 針の角度
import math as m

A, B, H, M = map(int, input().split())
radianH = m.radians(H * 30 + M * 30 / 60)
radianM = m.radians(6 * M)

hour = A * complex(m.cos(radianH), m.sin(radianH))
minute = B * complex(m.cos(radianM), m.sin(radianM))

ans = abs(hour - minute)

print(ans)


Measured memory_bytes: 9568
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

class Factor
{
public:
	Factor(ll a);
	void set(ll x);
	ll size;
	map<ll, ll> Prime;
	ll org;
};

Factor::Factor(ll a)
{
	org=a;
	set(a);
}
void Factor::set(ll x)
{
	size = 0;
	ll tmp = x;
	ll i;
	for (i = 2; i * i < tmp; i++)
	{
		while (x % i == 0)
		{
			x /= i;
			size++;
			Prime[i]++;
		}
	}
	if (x == 1)
	{
		return;
	}
	size++;
	Prime[x]++;
	return;
}

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

signed main() {
	ll a,b;
	cin >> a >> b;
	Factor fac(gcd(a, b));
	cout << fac.Prime.size()+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <cassert>
#include <unordered_map>

using namespace std;

struct Traversal {
	uint16_t positions;
	int count;

	Traversal(uint16_t initial, int c) : positions(initial), count(c) {}
	Traversal(uint16_t initial) : Traversal(initial, 0) {}
};

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<bool> is_bright_room = vector<bool>(n + 1, true);
	vector<int> dark_rooms;
	// i??????(i????????????)???????????¨?±???????????±????????????????
	uint16_t initial_state = (1 << m) - 1;
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		is_bright_room[x] = false;
		dark_rooms.push_back(x);
	}

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

	queue<Traversal> queue;
	queue.emplace(initial_state);
	
	vector<int> dp(1 << m, n * n);
	dp[initial_state] = 0;

	while (!queue.empty()) {
		auto state = queue.front();
		auto positions = state.positions;
		queue.pop();

		for (int j = 0; j < k; j++) {
			uint16_t next_positions = 0;
			for (int i = 0; i < dark_rooms.size(); i++) {
				if (positions & (1 << i)) {
					auto next_position = edges[dark_rooms[i]][j];
					for (int ii = 0; ii < m; ii++) {
						if (dark_rooms[ii] == next_position) {
							next_positions = next_positions | (1 << ii);
						}
					}
				}
			}
			if (dp[next_positions] > state.count + 1) {
				dp[next_positions] = state.count + 1;
				queue.emplace(next_positions, state.count + 1);
			}
		}
	}

	cout << dp[0] << endl;
}

Measured memory_bytes: 3448
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define INF 1000000000

int main() {
    int H, W, K, x1, y1, x2, y2;
    cin >> H >> W >> K >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    int cost[H][W];
    REP(i, H) {
        string s;
        cin >> s;
        REP(j, W) cost[i][j] = s[j] == '.' ? INF : -1;
    }

    cost[x1][y1] = 0;
    queue<pii> que; que.push({x1, y1});
    while (!que.empty()) {
        pii f = que.front(); que.pop();
        int h = f.first, w = f.second, nc = cost[h][w];

        FOR(i, h + 1, min(h + K + 1, H)) {
            if (cost[i][w] == INF) {
                que.push({i, w});
                cost[i][w] = nc + 1;
            }
            else if (cost[i][w] < nc) {
                break;
            }
        }
        RFOR(i, h - 1, max(h - K - 1, -1)) {
            if (cost[i][w] == INF) {
                que.push({i, w});
                cost[i][w] = nc + 1;
            }
            else if (cost[i][w] < nc) {
                break;
            }
        }
        FOR(i, w + 1, min(w + K + 1, W)) {
            if (cost[h][i] == INF) {
                que.push({h, i});
                cost[h][i] = nc + 1;
            }
            else if (cost[h][i] < nc) {
                break;
            }
        }
        RFOR(i, w - 1, max(w - K - 1, -1)) {
            if (cost[h][i] == INF) {
                que.push({h, i});
                cost[h][i] = nc + 1;
            }
            else if (cost[h][i] < nc) {
                break;
            }
        }
    }

    if (cost[x2][y2] == INF) cout << -1 << endl;
    else cout << cost[x2][y2] << endl;
    return 0;
}

Measured memory_bytes: 8388
def main():
	n = int(input())
	a = list(map(int, input().split()))

	ans_v1 = 0
	ans_v2 = 0
	a_sum_v1 = 0
	a_sum_v2 = 0

	for i in range(0, n):
		if i % 2 == 0: # 0,2,4...番目までの和を正
			if a_sum_v1 + a[i] < 1:
				ans_v1 += 1 - a_sum_v1 - a[i]
				a_sum_v1 = 1
			else:
				a_sum_v1 += a[i]
		else:          # 1,3,5...番目までの和を負
			if a_sum_v1 + a[i] > -1:
				ans_v1 += 1 + a_sum_v1 + a[i]
				a_sum_v1 = -1
			else:
				a_sum_v1 += a[i]
	
	for i in range(0, n):
		if i % 2 == 0: # 0,2,4...番目までの和を負
			if a_sum_v2 + a[i] > -1:
				ans_v2 += 1 + a_sum_v2 + a[i]
				a_sum_v2 = -1
			else:
				a_sum_v2 += a[i]
		else:          # 1,3,5...番目までの和を正
			if a_sum_v2 + a[i] < 1:
				ans_v2 += 1 - a_sum_v2 - a[i]
				a_sum_v2 = 1
			else:
				a_sum_v2 += a[i]

	print(min(ans_v1, ans_v2))

 
if __name__ == "__main__":
  	main()

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

int main(){
  string str;
  cin>>str;
  stack <int> stk,sstk,h,ans;
  
  int cnt=0,sum=0;
  str+='\\';
  for(int i=0;i<str.size();i++){
    if(str[i]=='\\')stk.push(i);
    if(stk.size()&&str[i]=='/')cnt+=i-stk.top(),stk.pop();
    if(str[i]=='\\'&&cnt){
      sum+=cnt;
      while(h.size()&&h.top()>stk.size())cnt+=sstk.top(),sstk.pop(),h.pop();
      sstk.push(cnt);
      h.push(stk.size());
      cnt=0;
    }
  }
  while(!sstk.empty())ans.push(sstk.top()),sstk.pop();

  cout <<sum<<endl<<ans.size();
  while(!ans.empty())cout <<" "<<ans.top(),ans.pop();
  cout <<endl;
  return 0;
}

Measured memory_bytes: 1312
s = list(input())
t = list(input())
s_len = len(set(s))
t_len = len(set(t))
pare = []
for i,j in zip(s,t):
    pare.append(i+j)

if len(set(pare)) == s_len == t_len:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 19248
#!/usr/bin/env python3
n = int(input())
s = input()
c = 0
for i in range(10):
    a = s.find(str(i))
    if a > -1:
        for j in range(10):
            b = s.find(str(j), a + 1)
            if b > -1:
                c += len(set(s[b + 1:]))
print(c)


Measured memory_bytes: 9252
#include<bits/stdc++.h>
using namespace std;
int main()
{
       ios::sync_with_stdio(false);
       cin.tie(0);
    int n,m;
    cin>>n>>m;
    string arr[n];
    for(int i=0; i<n; i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0; i<n; i++){
        cout<<arr[i];
    }
    return 0;
}


Measured memory_bytes: 3616
n = int(input())

arr = list(map(int, input().split()))

max = 0
begin = arr[0]
dem = 0
for i in arr[1:]:
    if begin >= i:
        begin = i
        dem+=1
        if dem>max:
            max = dem
    else:
        dem = 0
        begin = i
print (max)

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,l;
    cin >> n >> l;
    vector<int32> a(n);
    REP(i,n)cin >> a[i];
    vector<pii> b(n - 1);
    REP(i,n-1){
        b[i] = pii(a[i] + a[i+1], i + 1);
    }
    sort(ALL(b), greater<pii>());
    if(b[0].first < l){
        cout << "Impossible\n";
        return 0;
    }else{
        cout << "Possible\n";
    }
    int32 x = b[0].second;
    for(int32 i = 1; i < x; ++i){
        cout << i << endl;
    }
    for(int32 i = n-1; i >= x; --i){
        cout << i << endl;
    }
    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a;
  d = 0;
  for(int i = 0; i < a; i++) {
    cin >> b;
    cin >> c;
    d += c+1-b;
  }
  cout << d << endl;
}



Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;

	queue<pair<string, char>> ans;
	ans.push({ "a", 'a' });

	rep(i, N - 1) {
		while (ans.front().first.size() == i + 1) {
			auto a = ans.front();
			ans.pop();
			rep(c, a.second - 'a' + 2) {
				ans.push({ a.first + (char)('a' + c), max(a.second,(char)('a' + c)) });
			}
		}
	}

	while (!ans.empty()) {
		cout << ans.front().first << endl;
		ans.pop();
	}

	return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define P pair<ll, ll>
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;


int 
main()
{
  double a, b, x; cin >> a >> b >> x;
  double s = x / a;
  cout << fixed << setprecision(10);
  if(s >= a * b / 2){
    double h = (2 * (a * b - s)) / a;
    cout << atan2(h, a)* 180 / PI << endl;
  } else {
    double h = (2 * s) / b;
    cout << atan2(b, h) * 180 / PI << endl;
  }

}


Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int n;
int a[105];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	double ans = 0;
	for(int i = 1; i <= n; i++) ans += 1.0/a[i];
	ans = 1.0/ans;
	
	printf("%.11f\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,ans;
  char op;

  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+') ans = a+b;
    else if(op=='-') ans = a-b;
    else if(op=='*') ans = a*b;
    else if(op=='/') ans = a/b;
    else break;

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

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

int main(void)
{
	int n, k, u[100];
	char s[11], s1, s2, t[1100];
	scanf("%d", &n);
	scanf("%s", &s);
	u[0] = strlen(s);
	for (int i = 0; i <= u[0]; ++i) t[i]=s[i];
	s2 = s[u[0]-1];
	for (int i = 1; i < n; ++i)
	{
		scanf("%s", &s);
		s1 = s[0];
		if (s1 != s2)
		{
			printf("No\n");;
			return 0;
		}
		u[i] = strlen(s);
		for (int i1 = 0; i1 <= u[i]; ++i1) t[11*i+i1]=s[i1];
		for (int i1 = 0; i1 < i; ++i1)
		{
			for (int i2 = 0; i2 <= u[i1]; ++i2)
			{
				if (t[11*i1+i2] != s[i2])
				{
					break;
				}
				else
				{
					if (i2 == u[i1]) 
					{
						printf("No\n");
						return 0;
					}
				}
			}
		}
		s2 = s[u[i]-1];
	}
	printf("Yes\n");
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;

int32_t main() {
IOS;
string s;
cin>>s;
vector<int> cnt(33,0);
    for (int i = 0; i < s.size(); ++i) {
        cnt[s[i]-'a']++;
    }
    for (int i = 0; i <26   ; ++i) {
        if(cnt[i]>=2)return cout<<"no",0;
    }
    cout<<"yes";
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
    `(let ((it ,expr))
       ,then
       ,else))

(defun func (x)
  (= 8
     (loop for i from 1 to x
           when (zerop (mod x i))
             sum 1)))

(defun main (n)
  (loop for i from 1 to n by 2
        when (func i)
          sum 1))

#-swank
(princ (main (read)))



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

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

using namespace std;
typedef long long ll;

int main() {
	int a, b, c, m;
	int k;
	cin >> a >> b >> c >> k;
	m = max(a, max(b, c));
	int ans = m;
	rep(i, k)ans *= 2;
	ans = ans - m + a + b + c;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define rep(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))



int main(){ FastIO;

int x,n;cin>>x>>n;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
unordered_map<int,int> m;
for(int i=0;i<n;i++) m[a[i]]=1;
if(!m[x]) cout<<x;
else{
	int xl,xr;
	xl=x-1;
	xr=x+1;
	while(1){
		if(!m[xl]){
			cout<<xl;break;
		}
		else if(!m[xr]){
			cout<<xr;break;
		}
		xl--;xr++;
	}
}

return 0;
}

Measured memory_bytes: 3636
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int> > mat;

int main()
{
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  cout << (k % 2 == 0 ? a - b : (-1) * (a - b)) << "\n";
}

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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#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++)


const int mod = 1e9 + 7;

void solve(int n, int d[])
{
    int b, f[13], ans, ansi;
    vector<int> v, w, u;
    fill(f, f + 13, 0);
    ans = 0;


  
    rep(i, n) f[d[i]]++;

  
    if (f[0])
    {
        cout << 0 << endl;
        return;
    }
    if (f[12] >= 2)
    {
        cout << f[13] << endl;
        return;
    }
    if (*max_element(f, f + 13) >= 3)
    {
        cout << 0 << endl;
        return;
    }


  
    v.push_back(0);
    v.push_back(24);
    rep(i, 12)
    {
        if (f[i] == 2)
        {
            v.push_back(i);
            v.push_back(24 - i);
        }
        else if (f[i] == 1)
            w.push_back(i);
    }
    if (f[12])
        v.push_back(12);
    

    rep(i, pow(2, w.size()))
    {
        u = v;
        b = i;
        rep(j, w.size())
        {
            if (b % 2)
                u.push_back(w[j]);
            else
                u.push_back(24 - w[j]);
            b /= 2;
        }
        sort(u.begin(), u.end());


        ansi = 12;
        rep(j, u.size() - 1)
            ansi = min(ansi, u[j+1] - u[j]);
        ans = max(ans, ansi);
        u.clear();
        
    }
    cout << ans << endl;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n;
    cin >> n;
    int d[n];
    rep(i, n) cin >> d[i];
    solve(n, d);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    
    static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();        
        if(n<600) System.out.println(8);
        else if((n>=600)&&(n<800)) System.out.println(7);
        else if((n>=800)&&(n<1000)) System.out.println(6);
        else if((n>=1000)&&(n<1200)) System.out.println(5);
        else if((n>=1200)&&(n<1400)) System.out.println(4);
        else if((n>=1400)&&(n<1600)) System.out.println(3);
        else if((n>=1600)&&(n<1800)) System.out.println(2);
        else if((n>=1800)&&(n<2000)) System.out.println(1);
        sc.close();
    }
    
    public static void main(String args[]) {
        solve();
    }
}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vl a(n+1,0),b(n+2,0);
  rep(i,n+1) cin>> a[i];
  for(int i = n;i>=0;i--) b[i] = b[i+1]+a[i];
  if(a[0] == 1){
    if(n == 0){
      cout<<1<<endl;
    }
    else cout<<-1<<endl;
    return 0;
  }
  if(a[0] != 0){
    cout<<-1<<endl;
    return 0;
  }
  ll ans=1,now = 1;
  for(int i = 1;i<=n;i++){
    now = (now - a[i-1])*2;
    if(now<0 || now<a[i]){
      cout<<-1<<endl;
      return 0;
    }
    mins(now,b[i]);
    ans+=now;
  }

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

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

vector<vector<int>> v;
vector<int> d;

int lx = 1;
void bfs(int x){
  queue<int> q;
  q.push(x);
  d[x] = lx;

  while(!q.empty()){
    int node = q.front();
    q.pop();

    for(int i=0; i<v[node].size(); ++i){
      if(d[v[node][i]] == 0){
         q.push(v[node][i]);
         d[v[node][i]] = lx;
       }
    }
  }
  ++lx;
}

int main(){
  int n, m; cin >> n >> m;

  v.resize(n);
  d.resize(n);

  for(int i=0; i<m; ++i){
    int x, y; cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }

  for(int i=0; i<n; ++i) if(d[i] == 0) bfs(i);

  int q; cin >> q;
  while(q--){
    int x, y; cin >> x >> y;
    if(d[x] == d[y]) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}



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

int x[1000][1000];
int y[1000];

int main() {
	memset(x, 1, sizeof(x));
	memset(y, 1, sizeof(y));
	int n, a, b, c, d;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		for (int i = 0; i < b; i++) {
			cin >> c >> d;
			x[a][c] = d;
		}
	}
	y[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				y[k] = min(y[k], y[j] + x[j][k]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << ' ' << y[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 5076
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<assert.h>
#include<ctime>
using namespace std;
#define LL long long
const int maxn = 1e5+10;
const int maxm = 1e5+10;
double pi = acos(-1.0);

//struct edge{
//    int from, to, cost, next;
//}e[maxn*2];
//int head[maxn], tot;
//inline void add(int a, int b, int c) {
//    e[tot].from = a, e[tot].to = b, e[tot].cost = c, e[tot].next = head[a], head[a] = tot++;
//}
//namespace fastIO {
//    #define BUF_SIZE 100000
//    //fread -> read
//    bool IOerror = 0;
//    inline char nc() {
//        static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE;
//        if(p1 == pend) {
//            p1 = buf;
//            pend = buf + fread(buf, 1, BUF_SIZE, stdin);
//            if(pend == p1) {
//                IOerror = 1;
//                return -1;
//            }
//        }
//        return *p1++;
//    }
//    inline bool blank(char ch) {
//        return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
//    }
//    inline void read(int &x) {
//        char ch;
//        while(blank(ch = nc()));
//        if(IOerror)
//            return;
//        for(x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0');
//    }
//    #undef BUF_SIZE
//};
//using namespace fastIO;
int a[maxn]; int cnt[maxn];
int main(){
    int n;
    while(~scanf("%d", &n)) {
        for(int i = 1; i <= n; i++) {
            scanf("%d", &a[i]);
        }
        int ans = 0;
        for(int i = 1; i <= n; i++) {
            if(a[i] != i) continue;
            int st = i, ed;
            for(ed = st; ed <= n && a[ed] == ed; ed++);
            ed--;
            ans += (ed-st+1)/2+((ed-st+1)&1);
            i = ed;
        }
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int a[N],b[N];
vector<int> ans;
int n;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n;
rep(i,1,n+1)
cin>>a[i];
rep(i,n+1,1)
{
	int cnt=0;
	for(int j=2*i;j<=n;j+=i)
	{
		cnt+=b[j];
	}
	cnt%=2;
	b[i]=cnt^a[i];
	if(b[i])
	ans.push_back(i);
}
cout<<ans.size()<<endl;
for(auto z:ans)
cout<<z<<endl;
}







Measured memory_bytes: 3192
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int ans=0;
	int n,m;
	cin>>n>>m;
	vint v(m);
	rep(i,m){
		cin>>v[i];
	}
	sort(ALL(v));
	rep(i,v.size()-1){
		maxs(ans,v[i+1]-v[i]-1);
	}
	ans=(ans+1)/2;
	// cout<<ans<<endl;
	maxs(ans,v[0]-1);
	maxs(ans,n-v.back());
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3320
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n;
    cin >> n;
    cout << (n-1) * n / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=1;i<=j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int n;
pii p[100005];
int main(void){
	cin>>n;
	REP(i,n){
		int a;
		cin>>a;
		p[i]=mp(a,i);
	}
	sort(p+1,p+n+1);
//	REP(i,n)cout<<p[i].fi<<' '<<p[i].se<<endl;
	int cnt=0;
	REP(i,n){
		if(i%2!=p[i].se%2){
			cnt++;
//			cout<<p[i].fi<<' '<<p[i].se<<' '<<i<<endl;
		}
	}
	cout<<cnt/2;
	return 0;
} 

Measured memory_bytes: 1152
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
abcdn = [tuple(map(int, input().split())) for _ in range(Q)]

print(max([sum(d if AN[b-1] - AN[a-1] == c else 0 for a, b, c, d in abcdn) for AN in combinations_with_replacement(range(1, M+1), N)]))

Measured memory_bytes: 12548
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
vector<ll>q;

ll getAns(ll m){
	ll x=0;
	auto it=upper_bound(all(q),m)-q.begin()-1;
	return it;
}

void solve(){
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<=1e6;i++){
		q.pb(((i+1)*i)/2);
	}
	for(ll i=2;i*i<=n;i++){
		ll cnt=0;
		while(n%i==0){
			cnt++;
			n/=i;
		}
		ans+=getAns(cnt);
	}
	if(n>1)ans++;
	cout<<ans;
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

Measured memory_bytes: 11592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	vector<ll> X(M);
	for (ll i = 0; i < M; ++i) cin >> X[i];
	sort(X.begin(), X.end());
	vector<ll> d(M-1);
	for (ll i = 0; i < M-1; ++i)
	{
		d[i] = abs(X[i+1] - X[i]);
		//		std::cout << d[i] << " ";
	}
	//	std::cout << std::endl;
	sort(d.begin(), d.end());
	ll res{0};
	for (ll i = 0; i < M-N; ++i)
		res += d[i];
	std::cout << res << std::endl;
}


Measured memory_bytes: 1792
from collections import deque
def bfs(n,e,fordfs):
    #点の数、スタートの点、有向グラフ
    W = [-1]*n
    W[e] = 0
    que = deque()
    que.append(e)
    len = [0]*n
    color = [0]*n
    while que:
        now = que.popleft()
        nowv = W[now]
        nowlen = len[now]
        nowcolor = color[now]
        for ne in fordfs[now]:
            if nowv == W[ne]:
                return -1
            elif W[ne] == -1:
                W[ne] = (nowv+1) % 2
                len[ne] = nowlen+1
                if nowcolor==0:
                    color[ne] = 1
                que.append(ne)
    return color[:n//2]
#############################################################
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = []

N = I()
uvw = [LI() for _ in range(N-1)]
g = [[] for i in range(2*N)]

for i in range(N-1):
    x = uvw[i][0] - 1
    y = uvw[i][1] - 1
    if uvw[i][2]%2==1:
        g[x].append(y)
        g[y].append(x)
    else:
        g[x].append(N+x)
        g[N+x].append(y)
        g[y].append(N+y)
        g[N+y].append(x)

ans = bfs(2*N,0,g)

for i in ans:
    print(i)


Measured memory_bytes: 66088
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
int main() {
	int n;
	cin >> n;
	if (n < 1200)cout << "ABC" << endl;
	else if (n < 2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#define M 100000
using namespace std;
typedef long long llong;
llong T[M];
int n, k;

int check(llong p) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong x = 0;
		for (i; x + T[i] <= p; x += T[i++]) if (i == n)return n;
	}
	return i;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> T[i];
	llong left = 0, right = M * M;
	while (right - left > 1) {
		llong mid = (right + left) / 2;
		int x = check(mid);
		if (x >= n)right = mid;
		else left = mid;
	}
	cout << right << endl;
	return 0;
}

Measured memory_bytes: 3792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	bool judge = true;
	s += s;
	rep(i, n) {
		judge = true;
		rep(j, n) {
			if (s[i+j] != t[j])judge = false;
		}
		if (judge) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

MOD = 2019

def solve(S):
    dp = np.zeros(MOD, np.int64)
    temp = np.empty_like(dp)
    pow10 = 1
    answer = 0
    for x in S[::-1]:
        dp[0] += 1
        x = x * pow10 % MOD
        temp[x:] = dp[:-x]
        temp[:x] = dp[-x:]
        dp, temp = temp, dp
        answer += dp[0]
        pow10 *= 10
        pow10 %= MOD
    return answer


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i4[:],)')(solve)
    cc.compile()

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit()
else:
    from my_module import solve

S = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')
print(solve(S))


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

/* Main */
void cubedNum(void)
{
    int inputNum = -1;
    int result = 1;
    
    while(1)
    {
        cin >> inputNum;
        /* input check */
        if( (0 <= inputNum) && (inputNum <= 100) )
        {
            break;
        }
    }
    for(int i=3; i >= 1; --i)
    {
        result *= inputNum;
    }
    cout << result << endl;
    
    return;
}

/* Driver */
int main(void){
    cubedNum();
    return 0;
}

Measured memory_bytes: 3056
function solve(a)
  if minimum(a) == 0
    return 0
  else
    k = 10^18
    m = 1
    for ai in a
      k ÷ m < ai && (m = -1; break)
      m *= ai
    end
    return m
  end
end

n = parse(Int, readline())
a = parse.([Int64], split(readline()))

println(solve(a))

Measured memory_bytes: 233884
import java.util.PriorityQueue

fun solve() {
    val n = readLine()!!.toInt()
    var k = MutableList(n,{_->0})    
    var l = MutableList<Long>(n,{_->0})    
    var r = MutableList<Long>(n,{_->0})    
    for(i in 0 until n){
        val (ktmp,ltmp,rtmp) = readLine()!!.split(" ").map(String::toInt)
        k[i] = ktmp-1
        l[i] = ltmp.toLong()
        r[i] = rtmp.toLong()
    }

    var lvec = MutableList(n,{_->mutableListOf<Long>()})
    var rvec = MutableList(n,{_->mutableListOf<Long>()})
    var ans = 0L
    for(i in 0 until n) {
        if(l[i]<r[i]){
            if(n-2-k[i]>=0) rvec[n-2-k[i]].add(r[i]-l[i])
            ans+=l[i]
        }
        else{
            lvec[k[i]].add(l[i]-r[i])
            ans+=r[i]
        }
    }

    val calc = {vec:MutableList<MutableList<Long>> ->
        val comp = compareBy<Long>({-it})
        var que = PriorityQueue<Long>(comp)
        var res = 0L
        for(i in n-1 downTo 0){
            for(elem in vec[i]) que.add(elem)
            if(!que.isEmpty()){
                val v = que.poll()
                res+=v
            }   
        }
        res
    }
    ans+=calc(lvec)
    ans+=calc(rvec)
    println(ans)
}
fun main() {
    val t = readLine()!!.toInt()
    for(i in 0 until t){
        solve()
    }
}


Measured memory_bytes: 104900
import bisect


class SqrtSet:
    def __init__(self, block_limit=201):
        self.key = []
        self.child = [[]]
        self.block_limit = block_limit

    def search_lower(self, key):
        if key is None:
            return None
        ret = None
        i = bisect.bisect_left(self.key, key)
        if i != 0:
            ret = self.key[i - 1]
        block = self.child[i]
        i = bisect.bisect_left(block, key)
        if i != 0:
            ret = block[i - 1]
        return ret
        
    def search_higher(self, key):
        if key is None:
            return None
        ret = None
        i = bisect.bisect_right(self.key, key)
        if i != len(self.key):
            ret = self.key[i]
        block = self.child[i]
        i = bisect.bisect_right(block, key)
        if i != len(block):
            ret = block[i]
        return ret

    def insert(self, key):
        i = bisect.bisect(self.key, key)
        block = self.child[i]
        bisect.insort(block, key)
        if len(block) == self.block_limit:
            sep = self.block_limit // 2
            self.key.insert(i, block[sep])
            self.child.insert(i + 1, block[sep + 1:])
            self.child[i] = block[:sep]
                
    def dump(self):
        for b in self.child:
            print(len(b), end=" ")
        print("")
            
            
def main():
    n = int(input())
    p = list(map(int, input().split()))
    idx = [0] * n
    for i in range(0, n):
        idx[i] = i
    idx.sort(key=lambda i: -p[i])
    t = SqrtSet()
    t.insert(-10)
    t.insert(n+10)
    ans = 0
    for i in range(n):
        if i==0:
            t.insert(idx[i])
            continue
        ri = t.search_higher(idx[i])
        pri = t.search_higher(ri)
        if pri==None:
            pri=n
            ri=n
        if pri==n+10:
            pri=n
        le = t.search_lower(idx[i])
        ple=t.search_lower(le)
        if ple==None:
            if le==-10:
                le=-1
                ple=-1
        if ple==-10:
            ple=-1
        #print(ple,le,idx[i],ri,pri)
        ans+=(n-i)*((le-ple)*(ri-idx[i])+(pri-ri)*(idx[i]-le))
        #print(n-i,ans)
        t.insert(idx[i])
    print(ans)
main()

Measured memory_bytes: 94700
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
using ll = long long int;

// const int S = 100000;
const int T = 1000010;
int prime[T+10], ans[T+10], rem[T+10];

int main() {
  vector<int> primes;
  for(int i=2; i<=T; i++) prime[i] = true;
  for(int i=2; i<=T; i++) {
    if(prime[i] == 1) {
      primes.push_back(i);
      for(int k=2*i; k<=T; k+=i) {
        prime[k] = false;
      }
    }
  }

  ll l, r; cin >> l >> r;

  ll len = r - l + 1;
  for(int i=0; i<len; i++) {
    rem[i] = i + l;
  }
  
  for(auto x : primes) {
    ll cnt = l / x;
    ll num = cnt * x;
   
    for(; num<=r; num+=x, cnt++) {
      if(num < l) continue;
      // fprintf(stderr, "prime %d, num = %d\n", x, num);
      while(rem[num-l] % x == 0) ans[num-l]++, rem[num-l] /= x;
    }
  }

  ll sum = 0;
  for(int i=0; i<len; i++) {
    // fprintf(stderr, "num = %d, ans = %d\n", i+l, ans[i]);
    if(rem[i] > 1) ans[i]++;
    if(prime[ ans[i] ]) sum++;
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 15100
H, W = map(int,input().split())
s = []
for k in range(H):
    s.append(input())
m1 = float("inf")
M1 = 0
m2 = float("inf")
M2 = 0
for k in range(H):
    for l in range(W):
        if s[k][l] == "B":
            m1 = min(m1,k+l)
            M1 = max(M1,k+l)
            m2 = min(m2,W-1-l+k)
            M2 = max(M2,W-1-l+k)
print(max(M1-m1,M2-m2))



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

int main(){
  int n; cin>>n;
  double ans=0.0;
  for(int i=0; i<n; ++i){
    double b; cin>>b;
    ans+=1.0/b;
  }
  cout<<setprecision(10)<<1.0/ans<<endl;
}


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

using namespace std;
int main() {
    int N;
    cin >> N;

    long A, B;
    vector<vector<long>> values;
    for(int i = 0; i < N; i++){
        cin >> A >> B;
        values.push_back({A+B, A, B});
    }

    std::sort(values.begin(), values.end(), [](vector<long> a, vector<long> b){return a[0] > b[0]; });

    int p = 1;
    long tTotal = 0;
    long aTotal = 0;
    for(int i = 0 ; i < N; i ++){
        if(p == 1){
            tTotal += values[i][1];
        }
        else{
            aTotal += values[i][2];
        }
        p *= -1;
    }

    cout << tTotal - aTotal;

    return 0;
}

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

int main(){
    vector<int> vec(3);
    for (int i =0 ; i < 3 ; i++){
        cin >> vec.at(i) ;
    }
    sort(vec.begin(),vec.end());
    cout << vec.at(0)+vec.at(1) <<endl;
}

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


void solve(){
  int n; cin >> n;
  int i;
  for(i = 1; i < 100000; i++){
    if(i * i > n) break;
  }
  cout << (i - 1) * (i - 1) << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int former = stoi(s.substr(0,2));
    int latter = stoi(s.substr(2,2));
    if (1 <= former && former <= 12) {
        if (1 <= latter && latter <= 12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if (1 <= latter && latter <= 12) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}



Measured memory_bytes: 256
#include<stdio.h> 
int main(void) 
{ 
int a,b,i,j; 
while(1) 
{ 
scanf("%d%d",&a,&b); 
if(a==0&&b==0){break;
} 
for(i=1;i<=a;i++) 
{ 
for(j=1;j<=b;j++) 
{ 
if(j%2==1) 
{ 
if(i%2==1)printf("#"); 
else printf(".");
} 
else 
{ 
if(i%2==1)printf("."); 
else printf("#"); 
} 
} 
printf("\n");
} 
printf("\n"); 
} 
return 0; 
} 


Measured memory_bytes: 2140