akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<long long int> adj[200001];
bool vis[200001];
#define ll long long int
#define ull unsigned long long int
#define MAX 1000000007
#define MOD 998244353

#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));

ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=ans*a;
        b/=2;
        a=a*a;
    }
    return(ans);
}

int main(){
    IO
    ll N,A;
    cin>>N>>A;
    ll x[N+1],sum=0;
    for(ll i=1;i<=N;i++) {cin>>x[i];sum+=x[i];}
    ll tot_choose=sum/N;
    ll dp[N+1][N+1][sum+1];
    for(ll i=0;i<=N;i++){
        for(ll j=0;j<=N;j++){
            for(ll k=0;k<=sum;k++){
                if(i==0 && j==0 && k==0) dp[i][j][k]=1;
                else if(i>=1 && k<x[i]) dp[i][j][k]=dp[i-1][j][k];
                else if(i>=1 && j>=1 && k>=x[i]) dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
                else dp[i][j][k]=0;
            }
        }
    }
    ll ans=0;
    for(ll j=1;j<=N&&j*A<=sum;j++) ans+=dp[N][j][j*A];
    cout<<ans;
    return(0);
}

Measured memory_bytes: 55808
# -*- coding: utf-8 -*-
s_a = [s for s in raw_input() if s != 'a']
s_b = [s for s in raw_input() if s != 'b']
s_c = [s for s in raw_input() if s != 'c']

x = 0
y = 0
z = 0
next_turn = 'A'

while x <= len(s_a) and y <= len(s_b) and z <= len(s_c):
    try:
        if next_turn == 'A':
            next_turn = s_a[x].upper()
            x += 1
        elif next_turn == 'B':
            next_turn = s_b[y].upper()
            y += 1
        else:
            next_turn = s_c[z].upper()
            z += 1
    except IndexError:
        print next_turn
        break

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

int main(){
	int n;
	cin>>n;
	int a[n], b[n-1];
	for(int i=0;i<n-1;i++)
		cin>>b[i];
	int mx = 0;
	for(int i=0;i<n-1;i++){
		if(i==0)
			a[i] = a[i+1] = b[i];
		else{
			if(b[i] >= mx){
				a[i+1] = b[i];
			}
			else{
				a[i] = a[i+1] = b[i];
			}
		}
		mx = b[i];
	}
	int sum = accumulate(a,a+n,0);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
string s1, s2;
int main(void) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        vector<int> ans;
        cin >> s1;
        cin >> s2;
        int size1 = s1.size();
        int size2 = s2.size();
        if (size2 > size1) {
            swap(size1, size2);
            swap(s1, s2);
        }
        size1++;
        reverse(s1.begin(), s1.end()); reverse(s2.begin(), s2.end());
        s1 += "0";
        for (int i = 0; i + size2 < size1; i++) {
            s2 += "0";
        }
        //    cout << s1 << endl;
        //    cout << s2 << endl;
        int old = 0;
        for (int i = 0; i < size1; i++) {
            int tmp = (s1[i]-'0') + (s2[i]-'0') + old;
            //        cout << tmp << endl;
            ans.push_back(tmp % 10);
            old = tmp / 10;
        }
        if (ans[size1-1] == 0) size1--;
        if (size1 > 80) {
            cout << "overflow" << endl;
            continue;
        }
        for (int i = size1-1; i >= 0; i--) {
            cout << ans[i];
        }
        cout << endl;
    }
    return 0;
} 

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for(int i=0;i<x;++i){
        cin >> a[i];
    }
    for(int i=0;i<y;++i){
        cin >> b[i];
    }
    for(int i=0;i<z;++i){
        cin >> c[i];
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());

    ll ok = 0, ng = (1LL << 35);
    while(ng-ok > 1LL) {
        ll mid = (ok+ng) / 2LL; // mid 以上の和を持つ選び方が k 通り以上あるかな？
        int count = 0;
        for(int i=0;i<x;++i){
            if(a[i]+b[0]+c[0] < mid) break;
            for(int j=0;j<y;++j) {
                if(a[i]+b[j]+c[0] < mid) break;
                for(int l=0;l<z;++l) {
                    if(a[i]+b[j]+c[l] < mid) break;
                    ++count;
                    if(count == k) {
                        i = x; j = y; l = z;
                    }
                }
            }
        }

        if(count == k) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    vector<ll> ans;
    for(int i=0;i<x;++i){
        if(a[i]+b[0]+c[0] < ok) break;
        for(int j=0;j<y;++j) {
            if(a[i]+b[j]+c[0] < ok) break;
            for(int l=0;l<z;++l) {
                if(a[i]+b[j]+c[l] < ok) break;
                ans.push_back(a[i]+b[j]+c[l]);
            }
        }
    }
    sort(ans.rbegin(), ans.rend());
    for(int i=0;i<k;++i){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 133472
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {
	unsigned char s[100005];
	cin >> s;
	int n = 0;
	for(int i=0;i<100005;i++){
		if (s[i] != '0' && s[i] != '1') {
			n = i;
			break;
		}
	}

	unsigned int *l=new unsigned int[n];
	int size = 0;
	{
		int p = -1;
		unsigned char pre = 'a';
		for (int i = 0; i < n; i++) {
			if (s[i] != pre) {
				size++;
				pre = s[i];

				p++;
				l[p]=1;
			}
			else {
				l[p]++;
			}
		}
	}

	int a = 0,b = n;
	int M = n;
	for (int i = 0; i < size; i++) {
		int t = (a < b) ? b : a;
		if (t < M) {
			M = t;
		}
		a += l[i];
		b -= l[i];
	}

	delete[] l;

	cout << M << endl;
	return 0;
}

Measured memory_bytes: 512
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <limits.h>
#include <complex>
#include <assert.h>
#include <set>
using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef complex<ld> Point;
vector<int> P;

void solve() {
	int N;
	cin >> N;
	P.resize(N);
	for (int n = 0; n < N; n++)cin >> P[n];
	int ans = 0;
	for (int n = 1; n < N-1; n++) {
		if (min({ P[n - 1],P[n],P[n + 1] }) != P[n] && max({ P[n - 1],P[n],P[n + 1] }) != P[n])ans++;
	}
	cout << ans << endl;
	return;
}

Measured memory_bytes: 256
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint h, w, t;

llint gcd(llint a, llint b)
{
  if(b == 0) return a;
  return gcd(b, a%b);
}

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
  cin >> h >> w >> t;

  llint H = h/gcd(h, t), W = w/gcd(w, t);
  llint ans = modpow(2, gcd(H, W));
  ans += modpow(2, H) + modpow(2, W), ans %= mod;
  ans += mod-3, ans %= mod;
  ans = modpow(ans, gcd(h, t) * gcd(w, t) % (mod-1));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N, K = read_int_list()
    H = read_int_list()
    res = 0
    if K < N:
      H0 = sorted(H, reverse=True)
      del H0[0:K]
      res = sum(H0)
    print(res)

main()


Measured memory_bytes: 26276
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
//#define sz(x) int((x).size())
// lcm = a*(b/gcd) least common multiple
// gcd: greatest common divisor 
//
int gcd(int a, int b) {
  if(a < b) gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
  }


int main() {
  int N, K;
  cin >>N >> K;
  long long p=0.;
  int m[N+1];
  m[0] = 0;
  for(int i=1; i <= N; i++){
    if(i >= K){
      m[i]=0. ;
    }
    else{
      int rb=17;
      int lb=0;
      int tmp = 0;
      while(rb - lb >1){
	tmp = (rb+lb)/2;	
	if(pow(2,tmp) < (((double) K)/((double) i)) ){
	  lb = tmp;
	}
	else{
	  rb = tmp;
	}
      }
      m[i] = rb;
      //      cout << lb << "  " << rb << endl;
      //      p = p + 1./((long long) pow(2,rb));
      //      cout << p << endl;
    }
  }
  sort(m, m+N+1);
  long long bunbo=0;
  for(int i=1; i<=N; i++){
    bunbo += pow(2. ,m[N] - m[i]);
  }
  long long bunshi = pow(2,m[N]);
  //  cout << bunbo << " " << bunshi << " " << endl;


  cout <<  setprecision(12) <<((double) bunbo)/ ((double )bunshi) / ((double) N) << endl;



}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.TreeMap;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			long n = sc.nextLong();
			long m = sc.nextLong();
			
			char[] s = sc.next().toCharArray();
			char[] t = sc.next().toCharArray();
			
			long l = lcm(n,m);
			
			TreeMap<Long,Character> x = new TreeMap<Long,Character>();
			
			
			for(int i=0;i<=(n-1);i++) {
				x.put((i*l/n), s[i]);
			}
			
			
			
			for(int i=0;i<=(m-1);i++) {
				if(x.containsKey((i*l/m)) && x.get((i*l/m))!=t[i]) {
					System.out.println(-1);
					return;
				}
			}
			
			System.out.println(l);
			
			
		}
		
		static long lcm (long a, long b) {
			long temp;
			long c = a;
			c *= b;
			while((temp = a%b)!=0) {
				a = b;
				b = temp;
			}
			return (c/b);
		}
		
	}


Measured memory_bytes: 47380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
const int inf=0x3f3f3f3f;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    long double L; cin>>L;
    cout<<fixed;
    cout.precision(20);
    cout<<(L/3)*(L/3)*(L/3);
    return 0;
}

Measured memory_bytes: 256
n = input()
n = int(n)
a = input().split()
b = input().split()
c = input().split()
a = [int(i) for i in a]
b = [int(i) for i in b]
c = [int(i) for i in c]

d = 0
for i in b:
  d += i

for i in range(n):
  if i + 1 < n:
    if a[i] +1  == a[i+1]:
      p = a[i]-1
      d += c[p]
  
print(d)

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

signed main() {
    int H,W;
    cin>>H>>W;
    vector<string> s(H);
    cin>>s;

    queue<pii> A,B;
    auto check=[&](int i,int j) {
        if(s[i][j]=='.') return false;
        int cnt=0;
        REP(d,8) {
            int ii=i+DY[d];
            int jj=j+DX[d];
            if(s[ii][jj]=='.') cnt++;
        }
        if(s[i][j]-'0'<=cnt) {
            return true;
        } else {
            return false;
        }
    };
    int ans=0;
    REP(i,H) {
        REP(j,W) {
            if(check(i,j)) {
                A.push({i,j});
            }
        }
    }
    while(1) {
        if(A.empty()) break;
        ans++;
        // dump(ans,SZ(A));
        while(!A.empty()) {
            int y=A.front().first;
            int x=A.front().second;
            A.pop();
            s[y][x]='.';
            B.push({y,x});
        }
        set<pii> next;
        while(!B.empty()) {
            int y=B.front().first;
            int x=B.front().second;
            B.pop();
            REP(d,8) {
                int yy=y+DY[d];
                int xx=x+DX[d];
                if(check(yy,xx)) {
                    next.insert({yy,xx});
                }
            }
        }
        FORE(x,next) A.push(x);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4100
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
a = []
for i in range(n):
    b = v[i] - c[i]
    a.append(b)
d = 0
for j in range(n):
    if a[j] > 0:
        d += a[j]
print(d)

Measured memory_bytes: 9020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    if(a > b) printf("0\n");
    else if(a == b) printf("1\n");
    else{
        if(n < 2) printf("0\n");
        else{
            ll minn, maxx;
            minn = maxx = a + b;
            n -= 2;
            for(int i = 0; i < n; i++) minn += a;
            for(int i = 0; i < n; i++) maxx += b;
            printf("%lld\n",maxx-minn+1);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int a[5];
    int k;

    for(int i = 0; i < 5; i++)
        cin >> a[i];
    cin >> k;

    bool f = false;
    for(int i = 0; i < 5; i++)
    {
        for(int j = i; j < 5; j++)
        {
            int sub = a[j] - a[i];
            if(sub <= k)
                f = true;
            else
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    if(f)
        cout << "Yay!" << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Buffer(make([]byte, 0), 1e6)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	ans := BArr{
		init: []byte(sc.Text()),
		head: make([]byte, 0, 100000),
		tail: make([]byte, 0, 100000),
	}

	sc.Scan()
	Q, _ := strconv.Atoi(sc.Text())

	for i := 0; i < Q; i++ {
		sc.Scan()
		T, _ := strconv.Atoi(sc.Text())

		switch T {
		case 1:
			ans.swap = !ans.swap
		case 2:
			sc.Scan()
			F, _ := strconv.Atoi(sc.Text())
			sc.Scan()
			C := []byte(sc.Text())
			switch F {
			case 1:
				if ans.swap {
					ans.addTail(C)
				} else {
					ans.addHead(C)
				}
			case 2:
				if ans.swap {
					ans.addHead(C)
				} else {
					ans.addTail(C)
				}
			default:
				panic("invalid")
			}
		default:
			panic("invalid")
		}
	}
	fmt.Println(ans.string())
}

type BArr struct {
	init []byte
	head []byte
	tail []byte
	swap bool
}

func (b *BArr) addHead(a []byte) {
	b.head = append(b.head, a...)
}

func (b *BArr) addTail(a []byte) {
	b.tail = append(b.tail, a...)
}

func (b *BArr) string() string {
	if b.swap {
		swap(b.init)
		swap(b.tail)
		return string(b.tail) + string(b.init) + string(b.head)
	}
	swap(b.head)
	return string(b.head) + string(b.init) + string(b.tail)
}

func swap(arr []byte) {
	for i := 0; i < len(arr)/2; i++ {
		arr[i], arr[len(arr)-1-i] = arr[len(arr)-1-i], arr[i]
	}
}


Measured memory_bytes: 3328
n = int(input())
H = list(map(int,input().split()))
flag = False
ans = 0
for i in range(n):
    if flag:
        if m >= H[i]:
            m = H[i]
            cnt += 1
        else:
            ans = max(ans,cnt)
            m = H[i]
            cnt = 0
    else:
        m = H[i]
        flag = True
        cnt = 0
print(max(ans,cnt))

Measured memory_bytes: 14224
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int A, B, C, D;
  ci(A, B, C, D);
  co(max(A * B, C * D));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define Unique(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e8
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------



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

  int n,p; cin >> n >> p;
  vector<int> a(n);
  bool flag = true;
  rep(i,n){
    cin >> a[i];
    if(a[i]%2==1) flag = false;
  }

  if(flag){
    if(p==0) cout << (ll)pow(2,n) << endl;
    else cout << 0 << endl;
  }else{
    cout << (ll)pow(2,n-1) << endl;
  }

  return 0;

}


Measured memory_bytes: 256
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N, M = MI()

if 2 * N <= M:
    ans = N + (M - 2 * N) // 4
    
else:
    ans = M // 2
    
print(ans)

Measured memory_bytes: 79912
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,ans=0;
int main(){
    cin>>a>>b>>c>>n;
    for (int i=0;i<=a;i++){
     for (int j=0;j<=b;j++){
      if ((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50)){
       ans++;
   } 
  }
      
 }
     
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll h,w;
    std::cin >> h>>w;
    if(h==1||w==1){
        std::cout << 1 << std::endl;
        return 0;
    }
    if(h%2==0||w%2==0){
        std::cout << h*w/2 << std::endl;
    }else{
        std::cout << (h-1)/2*(w-1)+(h-1)/2+(w-1)/2+1 << std::endl;
    }
}


Measured memory_bytes: 256
def print_list(lst) :
	a = ' '.join(list(map(str, lst)))
	print(" " + a)

n = int(input())
lst = [[[0 for w in range(10)] for q in range(3)] for e in range(4)]
for _ in range(n):
	b,f,r,v = list(map(int, input().split()))
	lst[b-1][f-1][r-1] += v 
for i in range(4):
	if (i != 0):
		print("#" * 20)
	for j in range(3):
		print_list(lst[i][j])

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

long long countn[5]={0,0,0,0,0};
int N;

void read(){
  char S[15];
  scanf("%s",S);
  if(S[0]=='M')countn[0]++;
  if(S[0]=='A')countn[1]++;
  if(S[0]=='C')countn[2]++;
  if(S[0]=='R')countn[3]++;
  if(S[0]=='H')countn[4]++;
}

int main(){
  int i,j,k;
  long long ans;
  scanf("%d",&N);
  for(i=0;i<N;i++)read();

  for(i=0;i<=2;i++){
    for(j=i+1;j<=3;j++){
      for(k=j+1;k<=4;k++){
	//	printf("%d %d %d %d %d %d\n",i,j,k,countn[i],countn[j],countn[k]);
	ans += countn[i]*countn[j]*countn[k];
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;

const int INF = 1000000;

int main()
{
    int n, m;
    cin >> n >> m;
    int u[100002], v[100002];
    vector<int> g[100002], r[100002];
    for(int i = 0; i < m; i++){
        cin >> u[i] >> v[i];
        g[u[i]].push_back(v[i]);
        r[v[i]].push_back(u[i]);
    }
    int s, t;
    cin >> s >> t;
    int d[100002];
    fill(d, d + n + 1, INF);
    d[s] = 0;
    queue<int> que;
    que.push(s);
    while(que.size()){
        int now = que.front();
        que.pop();
        for(int next : g[now]){
            if(d[next] > d[now] + 1){
                d[next] = d[now] + 1;
                que.push(next);
            }
        }
    }
    if(d[t] == INF){
        cout << -1 << endl;
        return 0;
    }
    int ans = INF;
    int used[100002][3];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j < 3; j++){
            used[i][j] = INF;
        }
    }
    used[t][0] = 0;
    queue<P> q;
    q.push(P(t, 0));
    while(q.size()){
        P now = q.front();
        q.pop();
        if((d[now.first] + now.second) % 3 == 0){
            ans = min(ans, d[now.first] + now.second);
        }
        for(int next : r[now.first]){
            if(used[next][(now.second + 1) % 3] > used[now.first][now.second % 3] + 1){
                used[next][(now.second + 1) % 3] = used[now.first][now.second % 3] + 1;
                q.push(P(next, now.second + 1));
            }
        }
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans / 3 << endl;
}

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

class Cube{
	public:
  	int f[6];
  	Cube(){}
  	void roll_z(){roll(1,2,4,3);}//横にまわす。
  	void roll_y(){roll(0,2,5,3);}
  	void roll_x(){roll(0,1,5,4);}
  	void roll(int i,int j,int k,int l){
    int t=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=t;
    }
};
  int getRight(Cube c1, int f0, int f1){
  	for(int i=0;i<6;i++){
    	for(int j=0;j<4;j++){
          if(c1.f[0]==f0 && c1.f[1]==f1){
          	return c1.f[2];
          }else{
          	c1.roll_z();
          }
    }
      
          if(i%2==0){
          	c1.roll_y();
          }else{
          	c1.roll_x();
          }
  }
       return -1;
  }
int main(){
  Cube c;
  int n,f0,f1;
  for (int i=0;i<6;i++) cin>>c.f[i];
  cin>>n;
  for (int i=0;i<n;i++){
  	cin>>f0>>f1;
    cout<<getRight(c,f0,f1)<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int s;
    cin >> s;
    //
    vector<int> a(1e6+1);
    a[0]=0;
    a[1]=s;
    for(int i=2;i<=1e6;i++){
        if(a[i-1]%2==0){
            a[i]=a[i-1]/2;
        }
        else{
            a[i]= 3*a[i-1] + 1;
        }
    }
    int min_m = 1e6;
    //

    /*
    for(int n=1;n<1e6;n++){
        for(int m=n+1;m<=1e6;m++){
            if(a[n]==a[m]){
                if(min_m > m){
                    min_m =m;
                }
                break;
            }
        }
    }
    */   // m を先に書けばもっと高速化できる
    bool frg = false;
    for(int m=2;m<=1e6;m++){
        for(int n=1;n<m;n++){
            if(a[n]==a[m]){
                min_m=m;
                frg = true;
                break;
            }
        }
        if(frg){
            break;
        }
    }
    cout << min_m << endl;

}
// これだと終わらない、ではどうするか..?

Measured memory_bytes: 7164
import java.util.*;
class Rest{
	String[] name = new String[200];
	int[] point = new int[200];
}
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		Rest rest = new Rest();
		Rest restans = new Rest();
		String[] data = new String[n];
		int[] ans = new int[n];

		for (int i = 0;i<n ;i++ ) {
			rest.name[i] = sc.next();
			rest.point[i] = sc.nextInt();
			data[i] = rest.name[i];
		}

		Arrays.sort(data);

		for (int i = 0;i<n ;i++ ) {
			for (int j = 0;j<n ;j++ ) {
				if (data[i] == rest.name[j]) {
					restans.point[i] = rest.point[j];
					restans.name[i] = data[i];
				}
			}
		}

		for (int i = 0;i<n ;i++ ) {
			for (int j = i+1;j<n ;j++ ) {
				if (restans.name[i].equals(restans.name[j])) {
					if (restans.point[i]<restans.point[j]) {
						int temp = restans.point[i];
						restans.point[i] = restans.point[j];
						restans.point[j] = temp;
					}
				}
			}
		}

		for (int i = 0;i<n ;i++ ) {
			for (int j = 0;j<n ;j++ ) {
				if (restans.name[i].equals(rest.name[j])) {
					if (restans.point[i]==rest.point[j]) {
						ans[i]=j+1;
						break;
					}
				}
			}
		}

		for (int i = 0;i<n ;i++ ) {
			System.out.println(ans[i]);
		}



	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    
    if(N/10 % 111 == 0){
        cout << "Yes" << endl;
    }
    else if (N % 1000 % 111 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
}

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

int main()
{
	int n;
	cin >> n;
	int p[n];
	int cnt = 0;
	for (int i = 0; i < n; i++){
		cin >> p[i];
		if (p[i] != i+1) cnt++;
	}
	if (cnt == 0 or cnt == 2) cout << "YES" << endl;
	else cout << "NO" << endl;
}




Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<ll, ll> P;
#define fs first
#define sc second

int main(){
    ll N, D, A;
    cin >> N >> D >> A;
    ll x[N], h[N];
    P p[N];
    for(int i = 0; i < N; i++){
        cin >> x[i] >> h[i];
        p[i].fs = x[i];
        p[i].sc = h[i];
    }

    sort(x, x + N);
    sort(p, p + N);

    int pos[N]; //iのモンスターの体力を減らした時に被害を被むらない最も左のモンスターのid
    for(int i = 0; i < N; i++){
        pos[i] = upper_bound(x, x + N, x[i] + 2 * D) - x;
    }

    ll z[N + 1]; //減らした体力の量
    fill(z, z + N, 0);

    ll ans = 0;
    for(int i = 0; i < N; i++){
        if(i != 0){
            z[i] += z[i - 1];
        }

        if(z[i] < p[i].sc){
            ll d = p[i].sc - z[i];
            ll c = (d + A - 1) / A;
            ans += c;
            z[i] += c * A;
            z[pos[i]] -= c * A;
        }
    }

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

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

int main() {
    long long int s = 0;
    char c;
    while(std::cin >> c, !std::cin.eof()){
        s += (c-'0');
    }
    std::cout << ((s%9==0)?"Yes":"No") << '\n';
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
int a[100005],n,vis[100005],tb,tmp;
set<int>al;
map<int,int>mp;
map<int,int>::iterator it,it2; 
set<int>::iterator its;
void sel(int p)
{
	printf("%d ",p);
	al.erase(p);
	vis[p]=0;
	if(mp.find(p)!=mp.end())mp.erase(p);
	it=mp.find(a[p]);
	if(it!=mp.end())
	{
		it->second--;
		if(it->second==0)mp.erase(it);
	}
	tb=a[p];
}
bool chk(int p)
{
	if((int)mp.size()>2)return false;
	for(it=mp.begin();it!=mp.end();++it)if(it->second==p)return true;
	return false;
}
int main()
{
	scanf("%d",&n);
	if(n==2)
	{
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n;i++)vis[i]=1,al.insert(i);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),mp[a[i]]++;		 
	tb=0;
	for(int i=1;i<=n;i++)
	{
		if(chk(n-i))
		{
			for(it=mp.begin();it!=mp.end();it++)
			{
				if(it->second==n-i)
				{
					sel(it->first);
					break;
				}
			}
			continue;
		}
		if(i==n-2&&(int)mp.size()==2&&a[a[mp.begin()->first]]==mp.begin()->first)
		{
			it2=it=mp.begin();
			it2++;
			if(tb==it->first)sel(it2->first);
			else if(tb==it2->first||it->first<it2->first)sel(it->first);
			else sel(it2->first);
			continue;
		}
		its=al.begin();
		if(*its==tb)its++;
		sel(*its);
	}
	return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);
    ll n;
    cin >> n;
    vector<ll> h(n + 2);
    h[n + 1] = INF;
    h[0]     = 0;
    rep1(i, n) { cin >> h[i]; }

    bool flg = false;
    for (int i = n; i >= 1; i--) {
        if (h[i - 1] - h[i] > 1) {
            flg = false;
            break;
        }
        if (h[i - 1] - h[i] == 1) {
            h[i - 1]--;
        }
        flg = true;
    }

    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int n;
	char s[51][51];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	char ans[51];
	int point=0;
	int tmp=0;
	for(char i='a';i!='{';){
		for(int j=0;j<n;j++){
			for(int k=0;s[j][k]!='\0';k++){
				if(s[j][k]==i){
					s[j][k]='1';
					tmp=1;
					break;
				}
			}
			if(tmp==1){
				tmp=0;
			}
			else{
				break;
			}
			if(j==n-1){
				tmp=1;
			}
		}
		if(tmp==1){
			ans[point]=i;
			point++;
		}
		else{
			i++;
		}
		tmp=0;
	}
	if(point==0){
		return 0;
	}
	for(int i=0;i<point;i++){
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
l=[]
for i in range(h):
    l.append(list(input()))
s=[]
for i in range(h):
    for j in range(w):
        if l[i][j]=='.':
            s.append([i,j])
def solve(s):
    v=[[0 for i in range(w)] for j in range(h)]       
    v[s[0]][s[1]]=1
    mc=0
    q=[[s,0]]
    while len(q):
        p=q.pop(0)
        x=p[0][0]
        y=p[0][1]
        c=p[1]
        k=[[0,1],[0,-1],[1,0],[-1,0]]
        for j in k:
            nx=x+j[0]
            ny=y+j[1]
            if 0<=nx<h and 0<=ny<w and l[nx][ny]=='.' and v[nx][ny]==0:
                v[nx][ny]=1
                q.append([[nx,ny],c+1])
                if mc<=c+1:
                    mc=c+1
                    # ms=[nx,ny]
    return mc 
ans=0
for i in s:
    ans=max(ans,solve(i))
print(ans)
exit()

v=[[0 for i in range(w)] for j in range(h)]       
v[ms[0]][ms[1]]=1
ans=0
q=[[ms,0]]
while len(q):
    p=q.pop(0)
    x=p[0][0]
    y=p[0][1]
    c=p[1]
    k=[[0,1],[0,-1],[1,0],[-1,0]]
    for j in k:
        nx=x+j[0]
        ny=y+j[1]
        if 0<=nx<h and 0<=ny<w and l[nx][ny]=='.' and v[nx][ny]==0:
            v[nx][ny]=1
            q.append([[nx,ny],c+1])
            ans=max(ans,c+1)
                #ms=[nx,ny]
print(ans)


Measured memory_bytes: 43500
//
//  main.cpp
//  E - Red and Green Apples
//
//  Created by Hashizo on 2020/03/28.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll ans = 0;
	
	
	ll x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	
	vector<ll> red(a);
	REP(i, a) {
		cin >> red[i];
	}

	SORT(red);
	REVERSE(red);
	
	vector<ll> blue(b);
	REP(i, b) {
		cin >> blue[i];
	}

	SORT(blue);
	REVERSE(blue);
	
	vector<ll> clean(c);
	REP(i, c) {
		cin >> clean[i];
	}

	
	SORT(clean);
	REVERSE(clean);

	
	vector<ll> eats;
	
	REP(i, x) {
		eats.push_back(red[i]);
	}

	REP(i, y) {
		eats.push_back(blue[i]);
	}

	ll n;
	if((x+y) > c) {
		n = c;
	}
	else {
		n = (x+y);
	}
	
	REP(i, n) {
		eats.push_back(clean[i]);
	}
	
	SORT(eats);
	REVERSE(eats);

	REP(i, (x+y)) {
		ans += eats[i];
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8432
n = int(input())
a = list(map(int, input().split()))

uv = [[] for _ in range(n)]
for _ in range(n-1):
    i, j = map(int, input().split())
    uv[i-1].append(j-1)
    uv[j-1].append(i-1)

# DFS
# 頂点iが未探索の時、ans[i] = -1
ans = [-1 for _ in range(n)]
ans[0] = 1
# dp[i] = 長さi+1のLISの最後尾の最小値
dp = [a[0]]
# history[(i, j)]のとき、変更前はdp[i] = j
# stackとして使用
history = []
# 頂点parents[i] = iの親
parents = [-1 for _ in range(n)]

todo = []
for i in uv[0]:
    todo.append(i)
    parents[i] = 0

while True:
    i = todo.pop(-1)
    
    # ans[i]を求める
    if dp[-1] < a[i]:
        dp.append(a[i])
        history.append((-1, 0))
    else:
        # dpの変更点を二分探索
        start = 0
        stop = len(dp) - 1
        flag = True
        while start < stop:
            center = (start + stop) // 2
            if dp[center] < a[i]:
                start = center + 1
            elif dp[center] > a[i]:
                stop = center
            else:
                flag = False
                break
        if flag and dp[start] > a[i]:
            history.append((start, dp[start]))
            dp[start] = a[i]
        else:
            history.append((-2, 0))
    ans[i] = len(dp)

    # todoに追加
    for j in uv[i]:
        if ans[j] == -1:
            todo.append(j)
            parents[j] = i

    if len(todo) == 0:
        break

    # back
    j = i
    while parents[todo[-1]] != j:
        k = history.pop(-1)
        if k[0] == -2:
            None
        elif k[0] == -1:
            dp.pop(-1)
        else:
            dp[k[0]] = k[1]
        j = parents[j]

for i in ans:
    print(i)

Measured memory_bytes: 156148
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define pii pair < int, int >
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second

const int inf = (int)3e6;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

int n;
ll a[200200];
ll pr[200200], d[200200];

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        pr[i] = pr[i - 1] + a[i];
        d[i] = d[i - 1] ^ a[i];
    }
    ll ans = 0;
    for(int i = 1; i <= n; ++i){
        int l = 0, r = i;
        int res = i;
        while(r >= l){
            int mid = (l + r) >> 1;
            if(pr[i] - pr[mid] == (d[i] ^ d[mid])){
                r = mid - 1;
                res = mid;
            }else{
                l = mid + 1;
            }
        }
        ans += i - res;
    }
    cout << ans << endl;
}


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

int main() {
	int a,b,c,d;
  	cin >> a >>b>>c>>d;
  	if( (abs(a-b)<=d && abs(b-c)<=d))cout <<"Yes" << endl;
  	else if( abs(a-c)<=d) cout<<"Yes"<<endl;
  	else cout <<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

int main() {
	string s;
	bool flgA = false, flgB = false;

	std::cin >> s;
    if(s.size()%2==1){
      std::cout<<"No"<<endl;
      return 0;
    }
	rep(i, 0, s.size()) {
        if(s[i]!='h'|| s[i+1]!='i'){
          std::cout<<"No"<<endl;
          return 0;
        }
        i++;
    }
    std::cout<<"Yes"<<endl;
	return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
long long a[100010];


int main()
{
	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++)
		scanf("%lld", &(a[i]));
		
	for (int i = 0 ; i < n ; i++)
		if (a[i] == 0) {
			printf("0\n");
			return 0;
		}
		
	long long ans = 1;
	double realAns = 1.0;

	for (int i = 0 ; i < n ; i++) {
		ans = ans * a[i];
		realAns = realAns * a[i];
		if ((ans > 1000000000000000000) || (realAns > 1000000000000000000)) {
			printf("-1\n");	//overflow
			return 0;
		}
	}
	
	printf("%lld\n", ans);
		
	return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;

    char C[H][W];
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> C[i][j];
        }
    }

    char D[2*H][W];
    for(int i = 0; i < 2*H; i++) {
        for(int j = 0; j < W; j++) {
            D[i][j] = C[i/2][j];
        }
    }

    for(int i = 0; i < 2*H; i++) {
        for(int j = 0; j < W; j++) {
             cout << D[i][j];
        }
        cout << "\n";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main() {
    std::string out = "No";
    std::string s, t;
    cin >> s >> t;

    int size = s.size() ;
    
  
    if (t.compare(0,size, s) == 0){
      out = "Yes";
    }
    cout << out << "\n";

}


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

#define M1 1000000007
#define M2 1000000009
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define f0(i, n) for (int i = 0; i < (int)(n); ++i)
#define f1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fc0(i,l,r) for(int i = (int)(l); i<(int)(r); ++i)
#define fc1(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define fr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
 
void init()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
      freopen("error.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
}
 
signed main()
{
    init();

    int n;
    cin>>n;
    string s;
    map<string,int> m;
    m.insert(pair<string,int>("AC",0));
    m.insert(pair<string,int>("WA",0));
    m.insert(pair<string,int>("TLE",0));
    m.insert(pair<string,int>("RE",0));
    while(n--)
    {
      cin>>s;
      m[s]++;
    }
    cout<<"AC"<<" x "<<m["AC"]<<endl;
    cout<<"WA"<<" x "<<m["WA"]<<endl;
    cout<<"TLE"<<" x "<<m["TLE"]<<endl;
    cout<<"RE"<<" x "<<m["RE"]<<endl;

    cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}

Measured memory_bytes: 3860
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for i in range(m):
    x,y,c=map(int,input().split())
    x-=1
    y-=1
    cnt=A[x]+B[y]-c
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 18648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> data(M,vector<int>(N+1));
    vector<int> p(M),counter(M);
    int k = 0,answer=0;
    for (int i = 0; i < M; i++) {
        cin >> k;
        for (int j = 0; j < k; j++) {
            cin >> data.at(i).at(j);
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> p.at(i);
    }

    for (int bit = 0; bit < (1 << N); ++bit) {
        
        fill(counter.begin(), counter.end(), 0);
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) { 
                for (int j = 0; j < M; j++) {
                    auto itr = find(data.at(j).begin(), data.at(j).end(), i+1);
                    if (itr != data.at(j).end())counter.at(j)++;
                }
            }
        }

        for (int i = 0; i < M; i++) {
            if (counter.at(i) % 2 != p.at(i))break;
            if (i == M-1)answer++;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
const int MOD=1000000007;
int main(){
  long long N,K;
  cin>>N>>K;
  long long res=0;
  for(long long k=K;k<=N+1;++k){
    long long first=k*(k-1)/2;
    long long final=(N*2-k+1)*k/2;
    long long add=final-first+1;
    res=(res+add)%MOD;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
struct Node{
    int key;
    Node *left;
    Node *right;
    Node *parent;
};
Node *NIL;
Node *root = NIL;
void insert(int key){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = new Node;
    z -> key = key;
    z -> left = NIL;
    z ->right = NIL;
    while(x!=NIL){
        y = x;
        if(z -> key < x ->key){
            x = x->left;
        }else{
            x = x->right;
        }
        z -> parent = y;
    }
    if(y==NIL){
        root = z ;
    }else if(z -> key < y -> key){
        y -> left = z;
    }else{
        y->right = z;
    }
}
void inorder(Node *p){
    if(p==NIL){
        return;
    }
    inorder(p->left);
    cout << ' ' << p->key;
    inorder(p->right);
}
void preorder(Node *p){
    if(p==NIL){
        return;
    }
    cout << ' ' << p -> key;
    preorder(p->left);
    preorder(p->right);
}
void print(void){
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
}
int main(void){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string command;
        cin >> command;
        if(command[0]=='i'){
            int key;
            cin >> key;
            //cout << key << endl;; 
            insert(key);
        }else{
            print();
        }
    }
    return 0;
}


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

using ll = long long;
// #define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << "\n"
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << "\n"
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
struct UnionFind {
  vector<int> parent;
  UnionFind(int n) : parent(n) {
    for(int i = 0; i < n; ++i) parent[i] = i;
  }
  int GetRoot(int x) {
    if(parent[x] == x) return x;
    return parent[x] = GetRoot(parent[x]); // 経路圧縮も行う
  }
  void Merge(int x, int y) {
    int rx = GetRoot(x);
    int ry = GetRoot(y);
    if(rx == ry) return;
    parent[rx] = ry;
  }
  bool AreSame(int x, int y) {
    return GetRoot(x) == GetRoot(y);
  }
};
/***** MAIN *****/
signed main() {
  int n, m; cin >> n >> m;
  int a, b;
  UnionFind tree(n);
  for(int i = 0; i < m; ++i) {
    cin >> a >> b;  --a;  --b;
    tree.Merge(a,b);
  }
  int ans = 0;
  unordered_map<int, int> root_count;
  for(int i = 0; i < n; ++i) {
    ans = max(ans, ++root_count[tree.GetRoot(i)]);
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/

Measured memory_bytes: 12020