akhauriyash/Code-Regression huggingface dataset:
fun main() {

    val n = readLine()!!.toInt()

    val list = readLine()!!.split(" ").map(String::toLong)

    var ans: Long = 1

    if (list.contains(0)){
        println(0)
        return
    }

    for (i in 0..n-1){
        if (list[i]<=1000000000000000000/ans){
            ans *= list[i]
        } else {
            ans = -1
        }
    }

    println(ans)

}

Measured memory_bytes: 61628
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

struct RollingHash{
    static const int C = 31, C2 = 29, P = 1000000007, P2 = 1000000009;
    int _n;
    vector<long long> pw, pw2, hs, hs2;

    RollingHash(){}
    RollingHash(const string &st)
        :_n((int)st.size()), pw(_n+1),pw2(_n+1),hs(_n+1),hs2(_n+1)
    {
        pw[0] = pw2[0] = 1;
        for(int i = 0; i < _n; ++i){
            pw[i+1] = (pw[i]*C)%P;
            pw2[i+1] = (pw2[i]*C2)%P2;
            hs[i+1] = (C*hs[i]+st[i])%P;
            hs2[i+1] = (C2*hs2[i]+st[i])%P2;
        }
    }

    // [l, r)
    pii getHash(int l, int r){
        int res, res2;
        res = (hs[r] - hs[l] * pw[r - l]) % P;
        res2 = (hs2[r] - hs2[l]*pw2[r-l])%P2;
        if(res < 0)res += P;
        if(res2 < 0)res2 += P2;
        return make_pair(res, res2);
    }
};

string nstr(){
    static const int MAX_LEN = 500001;
    static char res_[MAX_LEN];
    scanf("%s",res_);
    return string(res_);
}

vector<vector<int>> divisorsAll(int n){
    vector<vector<int>> res(n + 1);
    for(int i = 1; i <= n; ++i){
        for(int j = i; j <= n; j+=i){
            res[j].push_back(i);
        }
    }
    return res;
}

RollingHash rh;
vector<vector<int>> di;

int f(int l, int r){
    int len = r - l;
    rep(i, sz(di[len]) - 1){
        int d = di[len][i];
        if(rh.getHash(l, r - d) == rh.getHash(l + d, r)){
            return 0;
        }
    }
    return 1;
}

int main(){
    string S = nstr();
    int N = sz(S);
    if(count(all(S), S[0]) == N){
        printf("%d\n%d\n", N, 1);
        return 0;
    }
    rh = RollingHash(S);
    di = divisorsAll(N);
    if(f(0, N)){
        printf("%d\n%d\n", 1, 1);
        return 0;
    }

    int ans = 0;
    for(int x = 1; x < N; ++x){
        if(f(0, x) && f(x, N)){
            ans++;
        }
    }
    printf("%d\n%d\n", 2, ans);
}

Measured memory_bytes: 72448
#include<bits/stdc++.h>
using namespace  std;
typedef long long ll;
const int maxx=1e5+2;
struct S{
    int to;
    ll val;
};
vector<S> a[maxx];
ll d[maxx];
int n,m,cnt[maxx];
bool vis[maxx];
int ok[maxx];
bool spfa(){
    for(int i=1;i<=n;i++){
        d[i]=1000000000;
        vis[i]=0;
        cnt[i]=0;
    }
    d[1]=0;vis[1]=1;
    queue<int> q;
    while(!q.empty()) q.pop();
    q.push(1);
    while((!q.empty())){
        int t=q.front();q.pop();
        //cout<<t<<endl;
        vis[t]=0;
        if(cnt[t]>=n+1000) return 1;
        for(int i=0;i<a[t].size();i++){
            S k=a[t][i];
            if(!ok[k.to]) continue;
            if(d[k.to]>d[t]+k.val){
                d[k.to]=d[t]+k.val;
                cnt[k.to]++;
                if(cnt[k.to]>=n+1000) return 1;
                if(!vis[k.to]){
                    vis[k.to]=1;
                    q.push(k.to);

                }
            }
        }
    }
    return 0;

}
vector<int> b[maxx];
int book[maxx];
int main(){
    int p;
    cin>>n>>m>>p;
    //for(int i=1;i<=n;i++) a[i].clear();
    for(int i=1;i<=m;i++){
        int x,y,z;
        cin>>x>>y>>z;
        b[y].push_back(x);
        z-=p;
        a[x].push_back(S{y,1ll*(-z)});
    }
    queue<int> q;
    q.push(n); book[n]=1; ok[n]=1;
    while(!q.empty()){
        int x=q.front(); q.pop();
        for(auto t:b[x]){
            if(book[t])  continue;
            q.push(t);
            book[t]=1;
            ok[t]=1;
        }
    }
    if(spfa()) return 0*puts("-1");
    ll ans=-d[n];
    cout<<max(0ll,ans)<<endl;

}
/*
2 2 1
1 2 3
1 2 4
*/


Measured memory_bytes: 6784
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
vector<ll>prime,sfac;
void sieve(int n)
{
    prime.assign(n+1,1);
    sfac.assign(n+1,1);
    for(ll i=2;i<=n;i++)
    {
        if(!prime[i])
            continue;
        sfac[i]=i;
        for(ll j=i*i;j<=n;j+=i)
        {
            prime[j]=0;
            sfac[j]=i;
        }
    }
}
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sieve(1000000);
    vector<int>fc(1000001,0);
    for(int i=0;i<n;i++)
    {
        ll no=a[i];
        while(no>1)
        {
            fc[sfac[no]]++;
            ll x=sfac[no];
            while(no%x==0)
                no=no/x;
        }
    }
    int fl=0;
    for(int i=2;i<=1000000;i++)
    {
        if(fc[i]>1)
        {
            fl=1;
            break;
        }
    }
    if(!fl)
    {
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    fl=0;
     for(int i=2;i<=1000000;i++)
    {
        if(fc[i]>=n)
        {
            fl=1;
            break;
        }
    }
    if(!fl)
    {
        cout<<"setwise coprime"<<endl;
        return 0;
    }
    cout<<"not coprime"<<endl;
}

Measured memory_bytes: 30700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int N,M;
vector<int> G[101010];
vector<ll> dp[101010];
ll ans[101010];

ll solve(int v,int p){
  ll res=1;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i];
    if(u==p) continue;
    dp[v][i]=solve(u,v);
    (res*=(dp[v][i]+1))%=M;
  }
  return res;
}

void solve2(int v,int p,ll tot){
  int siz=G[v].size();
  rep(i,siz){
    if(G[v][i]==p) dp[v][i]=tot;
  }
  vector<ll> L(siz),R(siz);
  L[0]=1;
  for(int i=1;i<siz;i++){
    L[i]=L[i-1]*(dp[v][i-1]+1)%M;
  }
  R[siz-1]=1;
  for(int i=siz-2;i>=0;i--){
    R[i]=R[i+1]*(dp[v][i+1]+1)%M;
  }
  rep(i,siz){
    if(G[v][i]==p) continue;
    ll tmp=L[i]*R[i]%M;
    solve2(G[v][i],v,tmp);
  }
}

int main(){
  cin>>N>>M;
  if(N==1){
    cout<<1<<endl;
    return 0;
  }
  rep(i,N-1){
    int x,y; cin>>x>>y; x--,y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  rep(i,N) dp[i].resize(G[i].size());
  solve(0,-1);
  solve2(0,-1,0);
  rep(i,N){
    ll res=1;
    for(ll d:dp[i]) (res*=(d+1))%=M;
    cout<<res<<endl;
  }
  return 0;
}


Measured memory_bytes: 22272
from collections import Counter


n = int(input())

if n == 1:
    print(0)
    exit()


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


ans = 0
for v in Counter(prime_factorize(n)).values():
    i = 1
    while v >= i:
        v -= i
        ans += 1
        i += 1

print(ans)


Measured memory_bytes: 9420
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    S, T = input().split()

    st = []

    for i in range(N):
        st.append(S[i])
        st.append(T[i])
    
    print(''.join(st))


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define tez ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
int main(){
    tez;
    int a[] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    int in;
    cin>>in;
    cout<<a[in-1];
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = INT_MAX;
const ll LLINF = LLONG_MAX;
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
typedef tuple<int,int,int> tiii;
#define mt make_tuple
ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if(n&1==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

int main(){
  int i; cin >> i;
  if(i % 10 == 9 || i / 10 == 9)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

bool match(char x, char y) {
  if (x == '?' || y == '?') return true;
  return x == y;
}
signed main() {
  string A, B, C;
  cin >> A >> B >> C;
  vector<bool> ab(4010, true), bc(4010, true), ac(4010, true);
  const int off = 2005;
  rep(i, -sz(B), sz(A)) {
    rep(j, 0, sz(B)) {
      int p = i + j;
      if (!inseg(0, p, sz(A))) continue;
      if (!match(A[p], B[j])) ab[i + off] = false;
    }
  }
  rep(i, -sz(C), sz(A)) {
    rep(j, 0, sz(C)) {
      int p = i + j;
      if (!inseg(0, p, sz(A))) continue;
      if (!match(A[p], C[j])) ac[i + off] = false;
    }
  }
  rep(i, -sz(C), sz(B)) {
    rep(j, 0, sz(C)) {
      int p = i + j;
      if (!inseg(0, p, sz(B))) continue;
      if (!match(B[p], C[j])) bc[i + off] = false;
    }
  }
  int ans = INF;
  rep(i, -4010, 4010) {
    rep(j, -4010, 4010) {
      // A-B match
      if (i + sz(B) > 0 && i < 0 + sz(A)) {
        if (!(ab[i + off])) continue;
      }
      // A-C match
      if (j + sz(C) > 0 && j < 0 + sz(A)) {
        if (!(ac[j + off])) continue;
      }
      // B-C match
      if (j + sz(C) > i && j < i + sz(B)) {
        if (!(bc[j - i + off])) continue;
      }
      int l = min({0LL, i, j});
      int r = max({0 + sz(A), i + sz(B), j + sz(C)});
      chmin(ans, r - l);
    }
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n, m, i, j, a[1000], b[1000], c[1000] = { 0 }, s, k;
    cin >> n >> m;
    for (i = 0; i < n; i++)
        cin >> a[i];
    for (j = 0; j < m; j++)
        cin >> b[j];
    for (j = 0; j < m; j++) {
        for (i = 0; i < n; i++) {
            if (a[i] <= b[j]) {
                c[i] += 1;
                break;
            }
        }
    }
    s = c[0];
    k = 1;
    for (i = 1; i < n; i++) {
        if (s < c[i]) {
            s = c[i];
            k = i + 1;
        }
    }
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
//const int INF = 0x3f3f3f3f;
//map<int,int> rr;
int main()
{
	long long n, a, b, c, d, e;
	cin >> n >> a >> b;
	c = n / (a + b);
	//cout << "c=" << c << endl;
	d = c * a;
	//cout << "d=" << d << endl;
	e = n % (a + b);
	//cout << "e=" << e << endl;
	if(e<a)
		cout << d + e << endl;
	else
		cout << d + a << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n =sc.nextInt();
		int[] jousi = new int[n + 1];
		for(int i = 1; i < n; i++) {
			int num = sc.nextInt();
			jousi[num]++;
		}
		for(int i = 1; i <= n; i++) {
			out.println(jousi[i]);
		}
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}




Measured memory_bytes: 49400
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string s;
    cin>>s;
    int n = s.size();
    vector<int> next(n);
    rep(i,n){
        if(s[i]=='R')next[i]=i+1;
        else next[i]=i-1;
    }
    rep(i,100){
        vector<int> nn(n);
        rep(i,n){
            nn[i]=next[next[i]];
        }
        nn.swap(next);
    }
    vector<int> ans(n);
    rep(i,n)ans[next[i]]++;
    rep(i,n)cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1392
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int i,j,a,n,m;
  int h[1500],p[1500],q[1500];

  while(1){

    cin >> n >> m >> a;
    if(n == 0 && m == 0 && a == 0)break;
    
    
    for(i=0;i<m;i++)cin >> h[i] >> p[i] >> q[i];
    
    
    for(i=1010;i>=1;i--){
      for(j=0;j<m;j++){
	if(h[j] == i && a == p[j]){
	  a=q[j];
	  break;
	}
	else if(h[j] == i && a == q[j]){
	  a=p[j];
	  break;
	}
      }
    }
    
    cout  << a << endl;
    
  }
  
  
    
  return 0;
}

Measured memory_bytes: 0
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
for i in range(0,N):
  p.append(0)
for i in range(0,M):
  count=list(map(int, input().split()))
  p[count[0]-1]+=1
  p[count[1]-1]+=1
for i in range(0,M):
  if p[i]%2==1:
    print("NO")
    sys.exit()
print("YES")

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

int main()
{
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  int ans=0;
  cin>>s;
  rep(i,s.size() ){
    if(s[i]=='2') ans++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main(){
	var H , W int
	for{
		fmt.Scan(&H, &W)
		if H == 0 && W == 0{
			os.Exit(0)
		}
		for i := 0 ; i < H ; i++{
			if i == 0 || i == H - 1{
				for j := 0; j < W  ; j++{
					fmt.Print("#")
				}
				fmt.Print("\n")
			}else{
				fmt.Print("#")
				for k := 2 ; k < W; k++{
					fmt.Print(".")
				}
				fmt.Println("#")
				
			}
		}
		fmt.Print("\n")
	}
}



Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int n,sum=0;
	std::cin >> n;
	rep(i,n+1)sum+=i;
	std::cout << sum << std::endl;
}

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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    string ans;

    while(1){
        A-=D;
        C-=B;
        if(C<=0){
            ans="Yes";
            break;
        }else if(A<=0){
            ans="No";
            break;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int sol = 0;
    while (n)
    {
        n /= k;
        sol++;
    }
    cout << max(sol, 1);
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

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

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    char x, y;
    cin >> x >> y;

    // cout << x << " " << y << endl;
    if (x > y)
        cout << ">" << endl;
    else if (x < y)
        cout << "<" << endl;
    else
        cout << "=" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=600+50;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 1000000007
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
    #define N 100000

    int fac[N+100],invfac[N+100];

    int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
    int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
    int mul(int x,int y) {return 1ll*x*y%maxd;}
    ll qpow(ll x,int y)
    {
        ll ans=1;
        while (y)
        {
            if (y&1) ans=mul(ans,x);
            x=mul(x,x);y>>=1;
        }
        return ans;
    }
    int getinv(int x) {return qpow(x,maxd-2);}

    int C(int n,int m)
    {
        if ((n<m) || (n<0) || (m<0)) return 0;
        return mul(mul(fac[n],invfac[m]),invfac[n-m]);
    }

    void math_init()
    {
        fac[0]=invfac[0]=1;
        rep(i,1,N) fac[i]=mul(fac[i-1],i);
        invfac[N]=getinv(fac[N]);
        per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
    }
    #undef N
}
using namespace My_Math;

int n,m,to[N],cnt[N],pw[N],f[N][N];

int main()
{
    n=read()*2;m=read();
    rep(i,1,m)
    {
        int u=read(),v=read();
        to[u]=v;to[v]=u;
    }
    int ans=0;pw[0]=1;
    for (int i=2;i<=n;i+=2) pw[i]=mul(pw[i-2],i-1);
    rep(i,1,n)
    {
        for (int j=i+1;j<=n;j+=2)
        {
            int cnt=j-i+1,ok=1;
            rep(k,i,j)
            {
                if (!to[k]) continue;
                cnt--;
                if ((to[k]<i) || (to[k]>j)) {ok=0;break;}
            }
            if (!ok) continue;
            f[i][j]=pw[cnt];int cnt2=0;
            per(k,j,i+1)
            {
                if (!to[k]) cnt2++;
                f[i][j]=dec(f[i][j],mul(f[i][k-1],pw[cnt2]));
            }
            ans=add(ans,mul(f[i][j],pw[n-m*2-cnt]));
        }   
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 5104
X = int(input())

max = 1
temp = 1
for i in range(2,11,1): #指数部分
    for j in range(1,33,1):#整数部分

        temp = j**i
        if temp > 1000:
            break
        elif X >= temp and temp > max:
            max = temp

print(max)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
	int A,B,C,D,area1,area2;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	area1=A*B;
	area2=C*D;
	if(area1>area2)
		printf("%d",area1);
		else
		printf("%d",area2);
	
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, a, b, s = 0;
    cin >> n >> a >> b;
    int x[n];
    cin >> x[0];
    for (int i = 1; i < n; i++)
    {
        cin >> x[i];
        s += min((x[i] - x[i - 1]) * a, b);
    }
    cout << s;
}

Measured memory_bytes: 3976
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
A = nl()

colors = set()
overs = 0
for a in A:
    if a <= 399:
        colors.add(1)
    elif a <= 799:
        colors.add(2)
    elif a <= 1199:
        colors.add(3)
    elif a <= 1599:
        colors.add(4)
    elif a <= 1999:
        colors.add(5)
    elif a <= 2399:
        colors.add(6)
    elif a <= 2799:
        colors.add(7)
    elif a <= 3199:
        colors.add(8)
    else:
        overs += 1

if len(colors) > 0:
    print(len(colors), len(colors) + overs)
else:
    print(1, overs)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////

void solve() {
	vector<string>A = {"Christmas Eve Eve Eve",
	"Christmas Eve Eve","Christmas Eve","Christmas"};
	int D;
	cin >> D;
	cout << A[D - 22] << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	char we[5];
	cin >> we;
	int ans, max;
	ans = max = 0;

	for (int i = 0; i < 3; i++) {
		if (we[i] == 'R') {
			max++;
		} else {
			if (ans < max)ans = max;
			max = 0;
		}
	}
	if (ans < max)ans = max;

	printf("%d", ans);

	return 0;
}


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

int main(){

 
  ll N,K;
  cin>>N>>K;
  
  map<int,int> mp;
  
  rep(i,N+1)mp[i]=0;
  
  rep(j,K){

    int d;
    cin>>d;
    rep(i,d){

      int h;
      cin>>h;
      mp[h]++;
      
    }

  }
  
  int count=0;
  for(int i=1;i<N+1;i++){
  
    
    if(mp[i]==0)count++;
  
  }
  
  cout<<count<<endl;
  

}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double mm = h + (m / 60.0) ;
        double cc = Math.cos((5 * mm - m) * Math.PI / 30.0);
        double z = Math.sqrt(a * a * 1.0 + b * b - 2.0 * a * b * cc);
        System.out.println(z);
        sc.close();
    }
}

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

string s;
int len;

// get rightmost of repeat
int get_rightmost(int from) {
    char c = s.at(from);
    for (; from < len; from++) {
	if (s.at(from) != c) {
	    return from - 1;
	}
    }
    return (from - 1);
}

int main() {
    cin >> s;
    len = s.size();
    vector<int> n(len);
    int i = 0;

while (i < len) {
    // run of R
    int leftmost = i;
    int rightmost = get_rightmost(leftmost);
    for (int k = leftmost; k <= rightmost; k++) {
	++n[rightmost + (((rightmost - k) % 2 == 0) ? 0 : 1)];
    }
    // run of L
    rightmost = get_rightmost(leftmost = rightmost + 1);
    for (int k = leftmost; k <= rightmost; k++) {
	++n[leftmost - (((k - leftmost) % 2 == 0) ? 0 : 1)];
    }
    i = rightmost + 1;
}
end:
    for (int i = 0; i < len - 1; i++) {
	cout << n[i] << ' ';
    }
    cout << n[len - 1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define ll   long long
#define ld   long double
#define N    200256
#define M    998244353
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() );

using namespace std;
ll n, l, lv;
vector < ll > g[N];

void dfs( ll v, ll lvl = 1, ll p = 0 )
{
    if( l <= lvl )
    {
        l = lvl;
        lv = v;
    }
    for( ll i:g[v] )
    {
        if( i != p )dfs( i, lvl + 1, v );
    }
}

void solve()
{
    sc( "%I64d", &n );
    for( int i = 1; i < n; i ++ )
    {
        ll x, y;
        sc( "%I64d%I64d", &x, &y );
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1);
    dfs(lv);
    if( l % 3 == 2 )pr( "Second" );
    else pr( "First" );
}

int main()
{
    int tt = 1;
    //sc( "%d", &tt );
    for( int i = 1; i <= tt; i ++ )
        solve();
}












Measured memory_bytes: 20608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 998244353;

struct bracket{
    ll open,close;
    bool operator<(const bracket& rhs) const{
        if (open-close == rhs.open-rhs.close){
            return close < rhs.close;
        }
        return open-close > rhs.open-rhs.close;
    }
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin >> n;
    vector <string> arr(n);
    for (int z=0;z<n;z++){
        cin >> arr[z];
    }
    vector <bracket> lol;
    ll open = 0;
    ll close = 0;
    for (int z=0;z<n;z++){
        ll open1 = 0;
        ll close1 = 0;
        for (int x=0;x<arr[z].size();x++){
            if (arr[z][x] == '(') open1++;
            if (arr[z][x] == ')') {
                if (open1 == 0) close1++;
                else open1--;
            }
        }
        ll open2 = 0;
        ll close2 = 0;
        for (int x=arr[z].size()-1;x>=0;x--){
            if (arr[z][x] == ')') close2++;
            if (arr[z][x] == '('){
                if (close2 == 0) open2++;
                else close2--;
            }
        }
        if (close1 == 0 && open2 == 0) continue;
        else if (close1 == 0){
            open += open2;
        }
        else if (open2 == 0){
            close += close1;
        } else {
            bracket temp;
            temp.open = open2;
            temp.close = close1;
            lol.push_back(temp);
        }
    }
    sort(lol.begin(),lol.end());
    bool ok = true;
    for (int z=0;z<lol.size() && ok;z++){
        open -= lol[z].close;
        if (open < 0) ok = false;
        open += lol[z].open;
    }
    if (open-close != 0) ok = false;
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
} 


Measured memory_bytes: 34300
#include <iostream>
using namespace std;
int main(){
  int n,p,i,stc;
  int hstc[50];

  while(1){
    cin >> n >> p;
    if (n==0&&p==0) break;

    stc = p;
    for (i=0;i<n;i++) hstc[i]=0;
    i=0;
    while(1){
      if (stc >0){
	stc--;
	hstc[i]++;
	if (hstc[i]==p) break;
      }else{
	stc=hstc[i];
	hstc[i]=0;
      }
      i++;
      if (i==n) i=0;
    }
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;


int main() {
	ll k,x;
	cin >> k>>x;
	for (int i = 0; i < 2*k-1; i++) {
		cout << x - k + 1 + i << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

N, M = map(int, input().split())
s = []
c = []
for _ in range(M):
    s1, c1 = map(int, input().split())
    s.append(s1)
    c.append(str(c1))


for i in range(1000):
    st = str(i)
    if N != len(st):
        continue
    for j in range(M):
        if st[s[j]-1] != c[j]:
            break
        if j == M-1: 
            print(i)
            sys.exit()
if N == 1 and M == 0:
    print(0)
elif N == 2 and M == 0:
    print(10)
elif N == 3 and M == 0:
    print(100)
else:
    print(-1)

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

int main(){
int n,q,a[110000];
string s;
cin>>n>>q>>s;
a[0]=0;
for(int i=0;i<n;i++){
  if(i<n-1 && s[i]=='A' && s[i+1]=='C')a[i+1]=a[i]+1;
  else a[i+1]=a[i];
}
int r,l;
for(int i=0;i<q;i++){
  cin>>r>>l;
  cout<<a[l-1]-a[r-1]<<endl;
}


}


Measured memory_bytes: 1536
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n,m=MI() # p, c
ids=[0]*m
pids=[1]*(1+n)
prefs=[]
for i in range(m):
    p,y=MI()
    prefs+=[(y,i,p)]
prefs.sort(key=lambda x:x[0])

for y,i,p in prefs:
    c=pids[p]
    pid='0'*(6-len(str(p)))+str(p)
    cid='0'*(6-len(str(c)))+str(c)
    ids[i]=pid+cid
    pids[p]+=1
    
for iid in ids:
    print(iid)


Measured memory_bytes: 83160
N=int(raw_input())
A=[int(x) for x in raw_input().split()]
o=0
e=0
f=0
for a in A:
    if a%4==0:
        f+=1
    elif a%2==0:
        e+=1
    else:
        o+=1
if o==0 or f>=o or (e==0 and f+1==o):
    print 'Yes'
else:
    print 'No'

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

void solve(){
  ll a,b;
  scanf("%lld",&a);
  b=360;
  while(b%a != 0)
    b+=360;

  printf("%lld\n",b/a);
}
int main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); 
     int t=1; 
     // cin >> t;
     while (t--) solve();
 
     return 0;
}



Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

bool hantei(long long n){
	for(long long i=2; i*i<=n; i++){
		if(n%i==0) return 0;
	}
	return n>1;
}

map<ll,ll> bunkai(ll n){
	map<ll,ll> m;
	if(n==1){
		m[n]++;
		return m;
	}
	int b{2};
	if(hantei(n)) {
		m[n]++;
		return m;
	}
	while(1){
		if(n%b==0){
			m[b]++;
			n/=b;
			if(hantei(n)){
				m[n]++;
				break;
			}
		}
		else b += b%2+1;
	}
	return m;
}

int main(){
	ll n; cin>>n;
	if(hantei(n)){
		cout << 1 << endl;
		return 0;
	}
	else if(n==1){
		cout << 0 << endl;
		return 0;
	}
	auto m = bunkai(n);
	vector<ll> a(10);
	for(int i=1; i<10; i++){
		a.at(i)=a.at(i-1)+i;
	}
	ll ans{};
	for(auto i:m){
		ll e = i.second;
		auto it = upper_bound(a.begin(),a.end(),e);
		ans += it - a.begin()-1;
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 3612
import sys
n,m=(int(i) for i in input().split())
l = [None]*m
r = [None]*m

for i in range(m):
    l[i],r[i]=(int(j) for j in input().split())

rangel=l[0]
ranger=r[0]

for i in range(1,m):
    if rangel < l[i]:
        rangel = l[i]

    if ranger > r[i]:
        ranger = r[i]

    if rangel > ranger:
        ans =0
        print(ans)
        sys.exit()

ans = ranger - rangel +1
print(ans)


Measured memory_bytes: 10868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec t(n+1);
  vec a(n+1);
  for(ll i=0;i<n;i++) {
    cin >> t[i+1];
  }
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  ll ans=1;
  for(ll i=0;i<n;i++) {
    if(t[i]==t[i+1]&&a[i]==a[i+1]) {
      (ans*=min(t[i+1],a[i]))%=mod;
    }
    else {
      if(t[i]!=t[i+1]&&a[i]!=a[i+1]) {
        if(t[i+1]!=a[i]) {
          ans=0;
        }
      }
      else if(t[i]!=t[i+1]&&t[i+1]>a[i]) {
        ans=0;
      }
      else if(a[i]!=a[i+1]&&a[i]>t[i+1]) {
        ans=0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

#define N 1000000
#define INT(X) \
  ( *( (const int *)(X) ) )

int comparator (
  const void  * a,
  const void  * b
  )
{
  return ( INT( a ) - INT( b ) );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    struct
    {
      int score;
      int no;
    } d[ N ];
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      int m1, s1, m2, s2, m3, s3, m4, s4;

      scanf ( "%d%d%d%d%d%d%d%d%d", &d[ i ].no
            , &m1, &s1, &m2, &s2, &m3, &s3, &m4, &s4 );

      d[ i ].score = m1 * 60 + s1
                   + m2 * 60 + s2
                   + m3 * 60 + s3
                   + m4 * 60 + s4;
    }
    qsort ( d, n, sizeof ( d[ 0 ] ), comparator );

    printf ( "%d\n%d\n%d\n"
           , d[ 0 ].no, d[ 1 ].no, d[ n - 2 ].no );
  }

  return ( 0 );
}

Measured memory_bytes: 0
s = input()
alp = 'abcdefghijklmnopqrstuvwxyz'
if len(s) < 26:
    for a in alp:
        if a not in s:
            print(s + a)
            exit()
else:
    for i in range(25, 0, -1):
        if s[i - 1] < s[i]:
            for j in range(i, 26):
                if s[i - 1] < s[j]:
                    c = s[j]
            print(s[:i-1] + c)
            exit()
    print(-1)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, char> P;
typedef long long ll;
const int INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};

int main()
{
	ll n, ans;
	cin >> n;
	ll t = 1;
	for (int i = 0;; i++)
	{
		if (n < t)
		{
			ans = i;
			break;
		}
		t *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>

int main(){
    int A, B;
    std::cin >> A >> B;
    if(A * B * (A + B) % 3 == 0){
        std::cout << "Possible" << std::endl;
    }else{
        std::cout << "Impossible" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long int
const int MAX = 1e18L + 5 ;
int32_t main() {
    int n ,W;
    cin >> n >> W ;
    int v[n] , w[n];
    int total_v = 0;
    for(int i = 0 ; i <n ; i++){
        cin >> w[i] >> v[i] ;
        total_v += v[i];
    }
    vector<int> dp(total_v+1 , MAX );
    //dp formed such that we can find min weight to get that value possible
    dp[0] = 0;
    for(int i = 0 ; i <n ; ++i){
        //j reprsent vale already;
        for(int j = total_v - v[i] ; j >=0 ;--j){
            dp[j+v[i]] = min(dp[j+v[i]],dp[j]+w[i]);
        }
    }
    int ans = 0;
    for(int j = 0 ; j <=total_v ; j++){
        if(dp[j] <= W)ans = max(ans , j);
    }
    cout << ans << endl; 
    return 0;
}

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

using namespace std;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = (int)2e9 + 100;
  for (int i = 0; i <= x || i <= y; ++i) {
    ans = min(ans, 2 * i * c + max(0, x - i) * a + max(0, y - i) * b);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    while(1){
        int H;
        cin>> H;
        if(!H) break;

        int a[H][5];
        for(int i=0; i<H; i++){
            for(int j=0; j<5; j++){
                cin>> a[i][j];
            }
        }

        int f=1, s=0;
        while(f){
            f=0;
            int _s=0;
            for(int i=0; i<H; i++){
                for(int j=0; j+2<5; j++){
                    if(a[i][j]!=0&&a[i][j]==a[i][j+1]&&a[i][j+1]==a[i][j+2]){
                        f++;
                        int d=a[i][j];
                        for(; j<5&&a[i][j]==d; j++){
                            a[i][j]=0;
                            s+=d;
                        }
                    }
                }
            }
            for(int j=0; j<5; j++){
                for(int i=0; i+1<H; i++){
                    if(a[i+1][j]==0){
                        for(int k=i+1; k-1>=0; k--){
                            swap(a[k][j], a[k-1][j]);
                        }
                    }
                }
            }
        }

        cout<< s<< endl;
    }

    return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>

int main(void)
{
  int a,b,c,m=0;
  scanf("%d%d%d",&a,&b,&c);
  if(a<b){m=a; a=b; b=m;}
  if(a<c){m=a; a=c; c=m;}
  if(b<c){m=b; b=c; c=m;}
  printf("%d",b*c/2);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include <string.h>


int main() {
	int i, j, k;
	long long int l = 0;
	int m, g = 0, n, q;
	int f = 0;
	int s[110], c[110], a[6] = { 11,11,11,11,11,11 };


	scanf("%d", &n);
		
	printf("%d", (n+1)/2);


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(int argc, char*argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	//vector<vector<int>> f(n, vector<int>(3));
	int f [n][3];
	int dp[n][3];
	for (int i =0; i< n; i++)
		for (int j= 0; j <3; j++)
			cin >> f[i][j];
	
	dp[n-1][0] = f[n-1][0];
	dp[n-1][1] = f[n-1][1];
	dp[n-1][2] = f[n-1][2];
	for (int i =n-2 ; i>=0; i--)
	{
		dp[i][0] = f[i][0] + max (dp[i+1][1], dp[i+1][2]);
		dp[i][1] = f[i][1] + max (dp[i+1][0], dp[i+1][2]);
		dp[i][2] = f[i][2] + max (dp[i+1][0], dp[i+1][1]);
	}
	
	cout << max(dp[0][0], max(dp[0][1], dp[0][2]));
		
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin >> S>>T;
    sort(S.begin(), S.end());
    sort(T.begin(), T.end());
    reverse(T.begin(), T.end());
    cout<<( S < T ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
from collections import deque

def dfs(x):
    INF = 10**9
    q = deque()
    q.append(x)
    d = [INF] * n
    d[x] = 0
    while q:
        f = q.pop()
        now = d[f]
        for ce in e[f]:
            if d[ce] == INF:
                d[ce] = now + 1
                q.append(ce)
    return d    


n = int(input())
e = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)

    
d0 = dfs(0)
dn = dfs(n-1)
f = 0
for i in range(n):
    if d0[i] <= dn[i]:
        f += 1
s = n - f
print('Fennec') if f > s else print('Snuke')

Measured memory_bytes: 88144
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val sum_min = readLine()!!.split(Regex("""\s+""")).map { it.toInt() }
            .fold(0) { sum, x -> sum + (minOf(x, k - x) * 2) }

    println(sum_min)
}

fun minOf(a: Int, b: Int) = if (a < b) a else b

Measured memory_bytes: 33900
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b)
	{
		cout << c << "\n";
	}
	if (a == c)
	{
		cout << b << "\n";
	}
	if (b == c)
	{
		cout << a << "\n";
	}
}

Measured memory_bytes: 256
n,m,x,y = map(int, input().split())
xl = list(map(int, input().split()))
yl = list(map(int, input().split()))
z = 'War'
for i in range(x+1,y+1):
    if max(xl) < i and i <= min(yl):
        z = 'No War'
        break
print(z)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

template <typename T>
struct LazySegtree {
	private:
		size_t n;
		vector<T> node, lazy;
		T M0, L0;

	public:
		LazySegtree(size_t sz, T m0, T l0) {
			n = 1;
			M0 = m0;
			L0 = l0;
			while (n < sz) { n *= 2; }
			node.assign(2*n - 1, M0);
			lazy.assign(2*n - 1, L0);
		}

		T merge(T a, T b) { return min(a, b); }
		void updateNode(int k, T x) { lazy[k] = min(lazy[k], x); }
		void propagate(int k) { node[k] = min(node[k], lazy[k]); }

		void eval(int k, int l, int r) {
			if (lazy[k] == L0) { return; }
			propagate(k);
			if (r - l > 1) {
				updateNode(2*k + 1, lazy[k]);
				updateNode(2*k + 2, lazy[k]);
			}
			lazy[k] = L0;
		}

		void update(int a, int b, T x, int k=0, int l=0, int r=-1) {
			if (r < 0) { r = n; }
			eval(k, l, r);
			if (r <= a || b <= l) { return; }
			if (a <= l && r <= b) {
				updateNode(k, x);
				eval(k, l, r);
			} else {
				update(a, b, x, 2*k + 1, l, (l + r) / 2);
				update(a, b, x, 2*k + 2, (l + r) / 2, r);
				node[k] = merge(node[2*k + 1], node[2*k + 2]);
			}
		}

		T query(int a, int b, int k=0, int l=0, int r=-1) {
			if (r < 0) { r = n; }
			eval(k, l, r);
			if (r <= a || b <= l) { return M0; }
			if (a <= l && r <= b) { return node[k]; }
			T vl = query(a, b, 2*k + 1, l, (l + r) / 2);
			T vr = query(a, b, 2*k + 2, (l + r) / 2, r);
			return merge(vl, vr);
		}
};

int main() {
	const Int INF = 1e17;
	int N, M;
	cin >> N >> M;
	vector<tuple<int, int, int>> tap;
	for (int i = 0; i < M; ++i) {
		int L, R, C;
		cin >> L >> R >> C;
		tap.emplace_back(L, R, C);
	}
	sort(tap.begin(), tap.end());


	LazySegtree<Int> seg(N + 10, INF, INF);
	seg.update(1, 2, 0);
	for (int i = 0; i < M; ++i) {
		int L = get<0>(tap[i]);
		int R = get<1>(tap[i]);
		int C = get<2>(tap[i]);
		Int cost = min((Int)(seg.query(L, L + 1) + C), INF);
		seg.update(L + 1, R + 1, cost);
	}
	Int ans = seg.query(N, N + 1);
	cout << (ans < INF ? ans : -1) << endl;

	return 0;
}


Measured memory_bytes: 5620