akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
#define _GLIBCXX_DEBUG
     
int main() { //max(ai,ai+1) <= bi
  /*
  a  0 1 2 3 4 5 6
  
  b  0 1 2 3 4 5 
  */
  int n, ans=0;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n-1);
  rep (i, n-1) cin >> b.at(i);
  
  a.at(0) = b.at(0);
  a.at(n-1) = b.at(n-2);
  for (int i=1; i<n-1; ++i) {
    a.at(i) = min(b.at(i), b.at(i-1));
  }
  
  rep (i, n) ans += a.at(i);
  
  cout << ans << endl;
}
    

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}



/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K, Q;
  cin >> N >> K >> Q;
  map<ll, ll> count;
  rep(i, Q){
    ll tmp;
    cin >> tmp;
    tmp--;
    count[tmp] += 1;
  }

  rep(i, N){
    cout << ((K - (Q - count[i])>0)?"Yes":"No")<<endl;
  }
  return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
 
 using namespace std;
 
 #define int long long
 
 const int N = 1e5 + 5;
 int n, ans[N], a[N];
 vector <pair<int, int>> p;
 
 main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	p.push_back(make_pair(0, n + 1));
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		p.push_back(make_pair(a[i], i));
	}
	sort(p.begin(), p.end()); reverse(p.begin(), p.end());
	int cur = p[0].first, mi = p[0].second;
	int pos = 0, cnt = 1;
	while(cur) {
		while(pos + 1 < n && p[pos + 1].first == cur) {
			++pos; ++cnt;
			mi = min(mi, p[pos].second);
		}
		ans[mi] += (cur - p[pos + 1].first) * cnt;
		cur = p[pos + 1].first;
	} 
	for(int i = 1; i <= n; ++i) cout << ans[i] << '\n';
 }
 

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n, m; cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 632
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();

        for(int i = 0; i<10; i++){
            x = r*x-D ;
            System.out.println(x);
        }
        sc.close();

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    int a, b, h = 100, w = 100;
    string s[100];
    char wht = '.', blk = '#';
    cin >> a >> b;
    if(a > b){
        int t = a;
        a = b;
        b = t;
        wht = '#';
        blk = '.';
    }
    for(int i=0;i<h;i++){
        s[i] = string(w, wht);
    }
    for(int i=1;i<h&&b>0;i+=4){
        for(int j=1;j<w&&b>0;j+=4){
            for(int k=-1;k<=1;k++){
                for(int l=-1;l<=1;l++){
                    s[i+k][j+l] = blk;
                }
            }
            b--;
        }
    }
    a--;
    for(int i=1;i<h&&a>0;i+=4){
        for(int j=1;j<w&&a>0;j+=4){
            s[i][j] = wht;
            a--;
        }
    }
    
    cout << h << " " << w << endl;
    for(int i=0;i<h;i++){
        cout << s[i] << endl;
    }
}


Measured memory_bytes: 256
import heapq
n, q = map(int, input().split())
event = []
for _ in range(n):
    s, t, x = map(int, input().split())
    event.append((s-x, 1, x))
    event.append((t-x, -1, x))

event.sort()
heap = []
xs = set([])

d = [int(input()) for _ in range(q)] + [10**9 + 7]
ans = [-1] * q
index = 0
for t, query, x in event:
    while d[index] < t:
        if not xs:
            pass
        else:
            while heap:
                tmp = heapq.heappop(heap)
                if tmp in xs:
                    heapq.heappush(heap, tmp)
                    ans[index] = tmp
                    break
        index += 1

    if query == 1:
        xs.add(x)
        heapq.heappush(heap, x)
    else:
        xs.remove(x)


while index < q:
    while heap:
        tmp = heapq.heappop(heap)
        if tmp in xs:
            heapq.heappush(heap, tmp)
            ans[index] = tmp
            break
    index += 1

print("\n".join(map(str, ans)))





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


int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    vector<int> d;
    rep(i, x) d.push_back(p[i]);
    rep(i, y) d.push_back(q[i]);
    rep(i, c) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    rep(i, x+y) ans += d[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3700
MOD=10**9+7
fac=[1]+[0]*(5*(10**5))
rev_fac=[0]*(5*(10**5)+1)
for i in range(1,len(fac)):
    fac[i]=(fac[i-1]*i)%MOD
rev_fac[-1]=pow(fac[-1],MOD-2,MOD)
for i in range(len(rev_fac)-2,-1,-1):
    rev_fac[i]=(rev_fac[i+1]*(i+1))%MOD
N,M=map(int,input().split())
ans=0
for k in range(N+1):
    ans=(ans+pow(-1,k)*fac[N]*rev_fac[k]*rev_fac[N-k]*fac[M]*rev_fac[M-k]*((fac[M-k]*rev_fac[M-N])**2))%MOD
print(ans)

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

int a, b;

inline void init()
{
	scanf("%d%d", &a, &b);
}

inline void work()
{
	int flag = 0;
	for (int i = a ; i <= b ; i++)
	 if (i < 0)
	  if ( !flag ) flag = 1;
	   else if ( ! (flag ^ 1) ) flag = 0;
	    else ;
	 else if (! i) flag = 2;
	switch( flag ) 
	 {
	  case 0:printf("Positive\n");break;
	  case 1:printf("Negative\n");break;
	  case 2:printf("Zero\n");break;
     }
    return;
}

int main()
{
	init();
	work();
	return 0;
}

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

int dp[30010][4], nxt[30010][10], rec[10];
int main() {
    int N; cin >> N;
    string s; cin >> s;

    fill(nxt[0], nxt[N+5], -1);
    fill(rec, rec + 10, -1);
    for(int i=N-1; i>=0; i--) {
        for(int j=0; j<10; j++) {
            nxt[i+1][j] = rec[j];
        }
        rec[ s[i] - '0' ] = i + 1;
    }
    for(int j=0; j<10; j++) nxt[0][j] = rec[j];

    dp[0][0] = 1;
    for(int i=0; i<N; i++) {
        for(int j=0; j<3; j++) {
            for(int k=0; k<10; k++) {
                if(nxt[i][k] < 0) continue;
                int ni = nxt[i][k];
                dp[ni][j+1] += dp[i][j];
            }
        }
    }

    int ans = 0;
    for(int i=0; i<=N; i++) ans += dp[i][3];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A = 0;
  int B = 0;
  int C = 0;
  int D = 0;
 
  for(int i = 0; i < N; i++){

    string x;
    cin >> x;
 
    if(x == "P") {
      if(A == 0){
        A++;
      }
      else if(A == 1){
        continue;
      }
    }
    
    if(x == "W") {
      if(B == 0){
        B++;
      }
      else if(B == 1){
        continue;
      }
    }
    
     if(x == "G") {
      if(C == 0){
        C++;
      }
      else if(C == 1){
        continue;
      }
    }
    
    if(x == "Y") {
      if(D == 0){
        D++;
      }
      else if(D == 1){
        continue;
      }
    }    
  }
  
  if (A + B + C + D == 3){
    cout << "Three" << endl;
  }
  
  else if (A + B + C + D == 4){
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fit(x) for(auto it=x.begin();it!=x.end();++it)
#define se second
#define mp make_pair
#define ALP "abcdefghijklmnopqrstuvwxyz"
#define nline cout<<"\n"
#define rep(i,x) for(i=0;i<x;++i)
#define repr(i,a,b) for(i=a;i<=b;++i)
#define mi2 500000004
#define mi3 333333336
#define MOD 1000000007
#define N 1000005
#define pll pair<ll,ll>
#define Vll vector<ll>
#define W(t) while(t--)
#define modsum(a,b,M) (a%M + b%M)%M
#define modsub(a,b,M) (a%M - b%M + M)%M
#define modmul(a,b,M) (a%M * b%M)%M
#define moddiv(a,b,M) (a%M * modinv(b,M)%M)%M
using namespace std;
ll powermod(ll x,ll n,ll M)
{
	ll result=1;
	while(n>0)
	{
	  if(n % 2 ==1)
	    result=(result * x)%M;
	  x=(x*x)%M;
	  n=n/2;
	}
	return result;
}
vector<ll> readll() {
	cin>>ws;
	vector<ll> v;
	string input;
	getline(cin, input);
	cout<<input;
	istringstream is(input);
	ll num;
	while(is>>num) v.pb(num);
	return v;
}
ll modinv(ll n,ll p) {
	return powermod(n,p-2,p);
}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[1000005],invf[1000005];
void facmod(ll n,ll M) {
	ll i;
	fact[0]=fact[1]=1;
	for(i=2;i<=n;++i) {
		fact[i]=((fact[i-1])%M * (i%M))%M;
	}
	invf[n]=modinv(fact[n],M);
	for (i=n-1;i>=0;--i){
		invf[i]=invf[i+1]*(i+1);
		invf[i]%=M;
	}
}
/*****
ll T=0;
ll p[200005], d[200005];
ll tin[200005], tout[200005];
vector<ll> g[200005];

void dfs(ll v, ll par = 1, ll dep = 0) {
	p[v] = par;
	d[v] = dep;
	tin[v] = T++;
	for (auto to : g[v]) {
		if (to == par) continue;
		dfs(to, v, dep + 1);
	}
	tout[v] = T++;
}
****/
void solve() {
	ll n,i,a,b;
	cin>>n>>a>>b;
	ll x=a+b;
	ll gr=n/x;
	ll y=n%x;
	cout<<gr*a+(y>=a?a:y);
}
int main() {
  	fastio;
	ll t=1;
	//cin>>t;
	W(t) {
		solve();
	}
	
  	return 0;
}

Measured memory_bytes: 256
import math
length, goal = map(int, input().split(" "))
nums = []
sumall = []
for i in range(length):
    a, b = map(int, input().split(" "))
    nums.append(a)
    sumall.append(a * (i + 1) * 100 + b)
answer = float("inf")
for bit in range(2 ** length):
    temp = []
    for i in range(length - 1, -1, -1):
        if bit & (1 << i):
            temp.append(i)
    temp_length = len(temp)
    for tempbit in range(2 ** temp_length):
        temp_sum = 0
        choosed = 0
        for i in range(temp_length):
            if tempbit & (1 << i):
                temp_sum += sumall[temp[i]]
                choosed += nums[temp[i]]
                if temp_sum >= goal:
                    answer = min(answer, choosed)
                    break
            else:
                if temp_sum + (nums[temp[i]] - 1) * (temp[i] + 1) * 100 >= goal:
                    answer = min(answer, choosed + int(math.ceil((goal - temp_sum) / (100 * (temp[i] + 1)))) )
                    break
                temp_sum += (nums[temp[i]] - 1) * (temp[i] + 1) * 100
                choosed += nums[temp[i]] - 1
        # print(bin(bit), bin(tempbit), temp_sum, choosed, answer)
    # print(answer, bin(bit))
print(answer)


Measured memory_bytes: 3316
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int p[SIZE];
vector<int>pp;
void prime_init(){
    for(int i=2;i<SIZE;i++){
        if(!p[i]){
            pp.PB(i);
            for(int j=i;j<SIZE;j+=i){
                if(!p[j])p[j]=i;
            }
        }
    }
}
bool is_prime(int x){
    return p[x]==x;
}
int main(){
    prime_init();
    int X;
    R(X);
    while(!is_prime(X))X++;
    W(X);
    return 0;
}


Measured memory_bytes: 4732
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin>>x;
    if(x==0) cout<<1;
    else cout<<0;    
    return 0;
}

Measured memory_bytes: 3660
import itertools

import numpy as np


def _run(H, W, K, C):
    input = np.zeros([H, W], dtype=np.int8)
    for h in range(H):
        for w in range(W):
            if C[h][w] == "#":
                input[h, w] = 1

    count = 0
    for r in itertools.product(*[[0, 1] for _ in range(H + W)]):
        copy_input = input.copy()
        for h in range(H):
            if r[h] == 1:
                copy_input[h] = 0
        for w in range(W):
            if r[H + w] == 1:
                copy_input[:, w] = 0

        if np.sum(copy_input) == K:
            count += 1
    print(count)


def _main():
    H, W, K = map(int, input().split())
    C = [str(input()) for _ in range(H)]
    _run(H, W, K, C)


if __name__ == "__main__":
    _main()


Measured memory_bytes: 27292
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int N, W;
  cin >> N >> W;
  vvi dp(N + 1, vi(W + 1));
  vi v(N), w(N);
  rep(i, N) cin >> v[i] >> w[i];
  rep(i, N) rep(j, W + 1) {
    dp[i + 1][j] = dp[i][j];
    if (j >= w[i]) {
      cmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
      cmax(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
    }
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 10728
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, x, n) for (int i = x; i < n; i++)
int main()
{
    int N;
    cin >> N;
    int H[N];
    int ryo = 0;
    int max = 0;
    rep(i, 0, N) { cin >> H[i]; }
    rep(i, 0, N)
    {
        if (H[i] < max)
        {
           
        }
        else if (max < H[i])
        {
            max = H[i];
            ryo++;
        }
        else
        {
            ryo++;
        }
    }
    cout << ryo << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
int l[100000], r[100000];
string s;
int n, q;
void solve(){
    s=s.c_str();
    int t[n+1];
    for(int j=0;j<n;j++){
            if(s[j]=='A'&&s[j+1]=='C'){
                s[j]='a';
            }
        }
    for(int i=1;i<=n;i++){
        if(s[i-1]=='a'){
            t[i]=t[i-1]+1;
        }
        else{
            t[i]=t[i-1];
        }
    }
    for(int i=0;i<q;i++){
        cout<<t[r[i]-1]-t[l[i]-1]<<"\n";
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>q>>s;
    for(int i=0;i<q;i++) {
        cin>>l[i]>>r[i];
        }
    solve();
}

Measured memory_bytes: 2256
<>;$x=$==1,s/( \d+)\1*\b/$x*=$&**($a=$&=~y! !!%3);$=*=$&**(-$a%3)/ge,++$h{$x},$t{$x}=$=for`factor`;$\=!!$h{1};$h{1}=0;$\+=$h{$h{$_}>$h{$t{$_}}?$_:$t{$_}},$h{$_}=$h{$t{$_}}=0for keys%h;print

Measured memory_bytes: 51540
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;

typedef long long int ll;
typedef long double ld;



int main(){
    string a;
    cin >> a;
    if (a=="a" || a=="i" || a=="u" || a=="e" || a=="o"){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
ll dp[MAX];
int modPow(long long a, long long n) {
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  long long t = modPow(a, n / 2);
  return (t * t) % MOD;
}
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=k;i>=1;i--){
        ll tmp=modPow((k/i),n);
        for(int j=2;(ll)j*i<=(ll)k;j++){
            tmp-=dp[j*i];
            if(tmp<0)tmp+=MOD;
            tmp%=MOD;
        }
        dp[i]=tmp;
    }
    ll ans=0;
    for(int i=1;i<=k;i++){
        ans+=(i*dp[i])%MOD;
        ans%=MOD;
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

/* 二項係数 C(n,k) mod p を計算 */
const int MOD = 1000000007;
const int MAX = 1e5+10;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int N, M; cin >> N >> M;

  if(abs(N-M) > 1){
    cout << 0 << endl;
    return 0;
  }

  if(N > M) swap(N,M);
  //以降，N <= M
  COMinit();
  ll ans;
  if(N == M){
    ans = ((2 * fac[M]) % MOD * fac[M]) % MOD;
  }else{
    ans = ((M * fac[M-1]) % MOD * fac[M-1]) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

/*
const int SIZE = 1 << 18;
struct SegmentTree {
  int node[2 * SIZE];
  SegmentTree {
    fill(node, node + 2 * SIZE, 0);
  }
  void update(int k, int x) {
    k += SIZE - 1;
    node[k] += x;
    while(k > 0) {
      k = (k - 1) / 2;
      node[k] = node[2*k+1] + node[2*k+2];
    }
  }
  int query(int a, int b, int l=0, int r=SIZE, int k=0) {
    if(r <= a or b <= l) return 0;
    if(a <= l and r <= b) return node[k];
    int mid = (l + r) / 2;
    int vl = query(a, b, l, mid, 2*k+1);
    int vr = query(a, b, mid, r, 2*k+2);
    return vl + vr;
  }
};
*/

int main() {
  int N, M, Q; cin >> N >> M >> Q;

  list<int> lst;
  for(int i=0; i<N; i++) {
    lst.push_back(i);
  }

  auto itr = lst.begin();
  for(int i=0; i<M; i++) {
    int a; cin >> a;
    if(a % 2 == 0) {
      for(int k=0; k<a; k++) {
        itr = next(itr);
        if(itr == lst.end()) itr = lst.begin();
      }
      itr = lst.erase(itr);
      if(itr == lst.end()) itr = lst.begin();
    }
    else {
      for(int k=0; k<a; k++) {
        if(itr == lst.begin()) itr = prev(lst.end());       
        else itr = prev(itr);
      }
      itr = lst.erase(itr);
      if(itr == lst.end()) itr = lst.begin();
    }
  }

  vector<int> alive(N);
  for(auto e : lst) alive[e] = true;

  for(int i=0; i<Q; i++) {
    int v; cin >> v;
    cout << alive[v] << endl;
  }

  /*
  int idx = 0;
  for(int i=0; i<M; i++) {
    int a; cin >> a;
    a %= (N - i);
    int ub = N, lb = 0;
    while(ub - lb > 1) {
      int mid = (ub + lb) / 2;
      int rem = mid;

      // until ends
      {
        int width = N - a;
        
      }

      // [0, rem)
      {

      }
    }
  }
  */
}



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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;

// integerの各桁を足す
int sum_digits(int num) {
    int rtn = 0;
    string num_str = to_string(num);
    for(int i=0; i<num_str.size(); i++) {
        rtn += num_str[i] - '0';
    } 
    return rtn;
}

int main() {
    long x, y;
    cin >> x >> y;
    int num_gift = 1;
    long current_gift = x; 
    
    while(current_gift * 2 <= y) {
        current_gift *= 2;
        num_gift++;
    }    
    //PRINT_ARRAY(gift);
    cout << num_gift << endl;
    return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    s, t = map(int, input().split())
    g[s].append(t)
    g[t].append(s)

# dfsで連結成分を求める
r = [0]*n
for i in range(n):
    if r[i] == 0:
        l = [i]
        while len(l) > 0:
            u = l.pop(-1)
            r[u] = i+1
            for v in g[u]:
                if r[v] == 0:
                    l.append(v)

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    if r[s] == r[t]:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 26288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll a, b;
  cin >> a >> b;
  ll c = b - a;
  ll sum = 0;
  rep(i,c){
    sum += i;
  }
  ll ans = sum - a;
  print(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ll r,g,b,n;cin>>r>>g>>b>>n;
    ll ans=0;
    rep(i,0,n/r+1){
        rep(j,0,n/g+1){
            ll u=n-i*r-j*g;
            //cout<<u<<" ";
            if(u<0)continue;
            if(u%b!=0)continue;
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

int main() {
    int t;
    int n; cin >>n;
    map<int, int> d;
    for (int i = 0; i < n; i++) {cin >>t; d[t]++;};

    int m; cin >>m;
    string ret = "YES";
    for (int i = 0; i < m; i++) {
        cin >> t;
        if (d[t]>0) {d[t]--;}
        else {ret = "NO";}
    }

    cout << ret << endl;
    return 0;
}

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


int main()
{
	long long l,r;
	cin >> l >> r;

	long long w = r-l-1;
	if(w >= 2019){
		cout << 0 << endl;
	}else{
		long long ans = 2019;
		for(long long i=l;i<r;i++){
			for(long long j=i+1;j<=r;j++){
				ans = min(ans, (i*j)%2019);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;

int main(){
    int a,b;
    cin >> a >> b;
    if ((a+b)%2==0){
        cout << (a+b)/2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

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

long long a[nmax], sum = 0, n, m;
main()
{
    cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 2; i <= n; i++) {
        if(a[i] + a[i-1] > m){
            if(a[i-1] < m) {
                sum += a[i]-(m-a[i-1]);
                a[i] = m-a[i-1];
            }
            else {
                sum += a[i];
                a[i] = 0;
            }
        }
    }
    if(a[1] + a[2] > m) sum += a[1] - m;
    cout << sum;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e3 + 5;
const int inf = 1e7;
int mp[maxn][maxn];
int dist[maxn][maxn];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
deque<pair<int,int>>Q;
int main()
{
    ios::sync_with_stdio(false);
    int n , m; cin >> n >> m;
    pair<int,int> s , e;
    cin >> s.first >> s.second;
    cin >> e.first >> e.second;
    for (int i = 1 ; i <= n ; i++)
        for (int j = 1 ; j <= m ; j++){
            char g ; cin >> g;
            if (g == '.') mp[i][j] = 0;
            else mp[i][j] = 1;
            dist[i][j] = inf;
        }

    dist[s.first][s.second] = 0;
    Q.push_front(s);
    while (Q.size()){
        pair<int,int> now = Q.front(); Q.pop_front();
        int x = now.first , y = now.second;
        for (int i = 0 ; i < 4 ; i++){
            int nx = x + dx[i] , ny = y + dy[i];
            if (nx < 1 || nx > n || ny < 1 || ny > m || mp[nx][ny])
                continue;
            if (dist[nx][ny] > dist[x][y]){
                dist[nx][ny] = dist[x][y];
                Q.push_front(make_pair(nx , ny));
            }
        }
        for (int nx = x - 2 ; nx <= x + 2 ; nx++){
            for (int ny = y - 2 ; ny <= y + 2 ; ny++){
                if (nx < 1 || nx > n || ny < 1 || ny > m || mp[nx][ny])
                    continue;
                if (dist[nx][ny] > dist[x][y] + 1){
                    dist[nx][ny] = dist[x][y] + 1;
                    Q.push_back(make_pair(nx , ny));
                }
            }
        }
    }
    cout << (dist[e.first][e.second] == 1e7 ? -1 : dist[e.first][e.second]) << endl;
    return 0;
}


Measured memory_bytes: 11448
import math
a, b, h, m = map(int, input().split())
t = abs((h+m/60)*math.pi/6 - m*math.pi/30)

t = max(t, 2*math.pi-t)
cc = a*a + b*b - 2*a*b*math.cos(t)
print(cc**(1/2))


Measured memory_bytes: 9520
#include <stdio.h>
int main(void){
  int n,i,t=0,x=0,y=0,nt,nx,ny,dx,dy,u;
  bool ans=true;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d%d%d",&nt,&nx,&ny);
    dx=(nx-x)*((nx>x)? 1:-1);
    dy=(ny-y)*((ny>y)? 1:-1);
    u=dx+dy-nt+t;
    if (u>0||u%2){
      ans=false;
      break;
    }
    t=nt;
    x=nx;
    y=ny;
  }
  printf("%s\n",(ans)? "Yes":"No");
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {



    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        char b = scan.next().charAt(0);

        
        char[] c = new char[128];
        c['A'] = 'T';
        c['C'] = 'G';
        c['G'] = 'C';
        c['T'] = 'A';

        System.out.println(c[b]);
    }
}

Measured memory_bytes: 20560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (sc != null) {
            sc.close();
        }
        int a = (n + 1) / 2;
        System.out.println((double) a / n);
    }

}

Measured memory_bytes: 23636
import java.util.*;

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

        while (true) {
            String line = sc.nextLine();
            char[] chars = line.toCharArray();
            if (chars[0] == '.') {
                break;
            }

            char[] brackets = new char[101];
            brackets[0] = ' ';
            int index = 1;
            for (char c : chars) {
                if (c == '(' || c == '[') {
                    brackets[index] = c;
                    index++;
                } else if (c == ')') {
                    if (brackets[index - 1] == '(') {
                        brackets[index - 1] = ' ';
                        index--;
                    } else {
                        brackets[index] = 'x';
                        break;
                    }
                } else if (c == ']') {
                    if (brackets[index - 1] == '[') {
                        brackets[index - 1] = ' ';
                        index--;
                    } else {
                        brackets[index] = 'x';
                        break;
                    }
                }
            }

            String bracketString = new String(brackets);
            String result = bracketString.trim();

            if (result.equals("")) {
                System.out.println("yes");
            } else {
                System.out.println("no");

            }

        }

        sc.close();
    }

}



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

using namespace std;


int main() {
	long long int N;
	cin >> N;
	if( N ==5 ) {
		vector<long long int>A( N );
		for( size_t i = 0; i < N; i++ ) {
			cin >> A[i];
		}
		long long int x = 1, ans = 0;
		while( true ) {
			vector<long long int>DP( 10, LLONG_MIN / 6 );
			DP[0] = 0;
			long long int maxx = 0;
			for( size_t i = 0; i < N; i++ ) {
				auto dp = DP;
				for( size_t j = 0; j < 10; j++ ) {
					if( dp[j] >= 0 ) {
						long long int next = dp[j] + A[i];
						long long int nextidx = (next / x) % 10;
						DP[nextidx] = max( DP[nextidx], next % (x * 100) );
						maxx = max( nextidx, maxx );
					}
				}
			}
			if( maxx == 0 ) {
				break;
			} else {
				ans += maxx;
			}
			for( size_t i = 0; i < 10; i++ ) {
				//cout << DP[i] << " ";
			}
			//cout << endl;
			x *= 10;
		}
		cout << ans << endl;
		return 0;
	}
	vector<long long int>A( N );
	for( long long int i = 0; i < N; i++ ) {
		cin >> A[i];
	}
	//cout << "!" << endl;
	long long int x = 1LL, ans = 0LL;
	for( long long int i = 0; i < 20; i++ ) {
		vector<long long int>DP( 10, LLONG_MIN / 6 );
		DP[0] = 0;
		long long int maxx = 0;
		for( long long int k = 0; k < N; k++ ) {
			auto dp = DP;
			DP[(A[k] / x) % 10LL] = max( A[k] % x, DP[(A[k] / x) % 10LL] );
			maxx = max( (A[k] / x) % 10LL, maxx );
			for( long long int j = 0; j < 10; j++ ) {
				if( dp[j] >= 0LL ) {
					long long int next = (dp[j] + A[k] % (x * 10LL) + x*j) % (x * 10LL);
					long long int nextidx = (next / x) % 10LL;
					DP[nextidx] = max( dp[nextidx], next % x );
					maxx = max( nextidx, maxx );
				}
			}
		}
		ans += maxx;

		//for( size_t i = 0; i < 10; i++ ) {
		//	cout << DP[i] << " ";
		//}
		//cout << endl;

		//cout << maxx << endl;
		x *= 10LL;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
houses = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]  

n = int(input())

for i in range(n) :
  b,f,r,v = map(int,input().split())
  houses [b - 1][f - 1][r - 1] += v       

for b in range(4):                       
  for f in  houses[b] :                  
    print('',*f)                          
  if b != 3 :                              
    print('#'*20)
  



Measured memory_bytes: 5628
ans=0
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
for i in range(n):
    a=list(map(int,input().split()))
    sum=c
    for j in range(m):
        sum+=a[j]*b[j] 
    if sum > 0:
        ans+=1
print(ans)



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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);



int m=10000000+10;

vec cnt(m,1);

void solve4ts()
{
  
  
  int n;
  cin>>n;

  

  for(int i=2;i<=m;i++){
    for(int j=i;j<=m;j+=i){
        cnt[j]++;
    }
  }

  int ans=0;

  for(int i=1;i<=n;i++){
    ans+=i*cnt[i];
  }

  cout<<ans<<endl;
  
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 85960
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header
typedef struct {
	lli to;
	lli cost;
}edge;
vector<vector<edge>> tree(100010);
vector<lli> dist(100010, 0);
lli K;

void dfs(lli k){
	for(const auto& x : tree[k]){
		if(dist[x.to] > 0 || x.to == K) continue;
		dist[x.to] = dist[k] + x.cost;
		dfs(x.to);
	}
}

int main(){
	lli n, Q;
	cin >> n;
	rep(i,n-1){
		lli a, b, c;
		cin >> a >> b >> c;
		tree[a].push_back({b, c});
		tree[b].push_back({a, c});
	}
	cin >> Q >> K;
	dfs(K);
	rep(i,Q){
		lli x, y;
		cin >> x >> y;
		cout << dist[x]+dist[y] << endl;
	}
	return 0;
}

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

int main() {

  int N;
  int sum = 0;
  cin >> N;
  
  for (int i = 0; i < N;i++) {
    int l,r;
    cin >> l >> r;
    sum = (r-l)+1 + sum;
  }
  cout << sum << endl;
}

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

int main() {
    double n, t, a, ans = 9999, o;
    cin >> n >> t >> a;
    vector<int> h(n);

    rep(i, n) {
        cin >> h[i];
        double b = t - h[i] * 0.006;
        double c = max(a, b) - min(a, b);
        if(ans > c) {
            ans = c;
            o = i + 1;
        }
    }
    cout << o << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int A;
	int B;
	int C;
	
	scanf("%d %d %d",&A,&B,&C);
	if (A==B && B!=C && C!=A) {
		printf("Yes\n");
	}
	else if (A==C && A!=B && C!= B){
		printf("Yes\n");
	}
	else if (B==C && A!=B && C!=A){
		printf ("Yes\n");
	}
	else printf ("No\n");
	return 0;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	char x;
	cin >> x;
	cout << (char)(x+1) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	int n;
	cin>>n;
	int a[n],i;
	long double s=0;
	for(i = 0 ; i < n ; i++ )
	{
		cin >> a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==0)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	s=0;
	for(i=0;i<n;i++)
	{
		s+=log10(a[i]);
	}
	if(s>18.1)
	{
		cout<<-1<<endl;
		return 0;
	}
	int ans=1;
	for(i=0;i<n;i++)
	{
		ans*=a[i];
	}
	if(ans>1000000000000000000)
	{
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  string s[n];
  rep(i,n) {
    R s[i];
    s[i]="#"+s[i]+"#";
  }
  rep(i,m+2) cout << "#";ln;
  rep(i,n) pr(s[i]);
  rep(i,m+2) cout << "#";ln;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll INF = 1e18;

int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans = -INF;

  chmax(ans, a*c);
  chmax(ans, a*d);
  chmax(ans, b*c);
  chmax(ans, b*d);

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3632
use std::io;
use std::io::Read;

fn main() {
    let mut stdin = io::stdin();
    let mut lines_str = String::new();
    let _ = stdin.read_to_string(&mut lines_str);
    let mut lines = lines_str.lines();
    let n :usize = lines.next().expect("").trim().parse().unwrap();
    let mut s :Vec<isize> = Vec::new();
    for _ in 0..n {
        s.push(lines.next().expect("").trim().parse().unwrap());
    }
    let s = s;
    let mut maxofmod :Vec<Vec<isize>> = vec![vec![-1;10];2];
    maxofmod[0][0] = 0;
    maxofmod[1][0] = 0;
    let mut fl :usize = 0;
    for score in &s {
        let fll = fl;
        fl = (1 - fll) as usize;
        let rr = (10 - ((*score) % 10)) as usize;
        for r in 0..10 {
            let oldval = maxofmod[fll][r];
            let newval = maxofmod[fll][(r+rr) % 10] + (*score);
            if maxofmod[fll][(r+rr) % 10] < 0 {
                maxofmod[fl][r] = oldval;                
            } else {
                if newval > maxofmod[fll][r] {
                    maxofmod[fl][r] = newval;
                } else {
                    maxofmod[fl][r] = oldval;
                }
            }
        }
    }
    let mut max = 0;
    for i in 1..10 {
        if maxofmod[fl][i] > max {
            max = maxofmod[fl][i];
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>

int main()
{
	int h, w, total;

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

	return 0;
}


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

#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}

void solve() {
  std::string s;
  std::cin >> s;
  REP(i, (1 << 3)) {
    std::bitset<3> b(i);
    int sum = std::stoll(s.substr(0, 1));
    std::string exp = s.substr(0, 1);
    REP(j, 3) {
      std::string d = s.substr(j+1, 1);
      if (b.test(j)) {
        sum += std::stoll(d);
        exp += "+" + d;
      } else {
        sum -= std::stoll(d);
        exp += "-" + d;
      }
    }
    if (sum == 7) {
      exp += "=7";
      cout(exp);
      return;
    }
  }
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(V) sort((V).begin(),(V).end())
#define pb push_back
#define endl '\n'
#define int long long

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

// 変数定義
int n,k,q;
//

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k >> q;
  vector<int> a(q);
  vector<int> ac(n);
  REP(i, q) {
    cin >> a[i];
    ac[a[i]-1]++; //正解数
  }
  REP(i, n) {
    if(k-q+ac[i] > 0) {
      cout << "Yes" << endl;
    } else { 
      cout << "No" << endl;
    }
  }
}

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

using namespace std;

int main(){
    int tmp;
    vector<int>v(3);

    for(int i = 0; i < 3;i++)
        cin >> v[i];

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

    tmp = abs(v[0]-v[1]);

    cout << tmp + abs(v[1]-v[2]) << endl;


    return 0;
}

Measured memory_bytes: 256