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

using Graph = vector<vector<long long> >;
Graph G;

long long n, q;
vector<long long> cnt(200001, 0);
vector<long long> ans(200001 ,0);

void dfs(long long v, long long p){
    if(p != -1) ans[v] += ans[p];
    ans[v] += cnt[v];

    for(auto next : G[v]){
        if(next == p) continue;
        dfs(next, v);
    }
}


int main(){
    cin >> n >> q;
    G.assign(n, vector<long long>());

    for(long long i = 0; i < n-1; i++){
        long long a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for(long long i = 0; i < q; i++){
        long long p, x;
        cin >> p >> x;
        cnt[p-1] += x;
    }

    dfs(0, -1);

    for(long long i = 0; i < n; i++){
        if(i != n-1) printf("%lld ", ans[i]);
        else printf("%lld\n", ans[i]);
    }
    return 0;
}

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

using namespace std;

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

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s,t,u;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    cin >> u;
    if(u == s) {
        cout << a-1 << " " << b << endl;
    } else {
        cout << a << " " << b-1 << endl;
    }
}


Measured memory_bytes: 256
#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 ;


// 解法O(1) https://yamakasa.net/atcoder-abc-158-c/
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    cin >> a >> b;
    for (int i=0; i<1100; i++) {
        int a_tax = i*0.08;
        int b_tax = i*0.1;
        if ( a_tax == a && b_tax == b) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << "-1\n";

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var k int
	fmt.Scan(&k)
	var bs []byte
	fmt.Scan(&bs)
	fmt.Print(string(bs[0:min(k, len(bs))]))
	if len(bs) > k {
		fmt.Print("...")
	}
	fmt.Println()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1816
#!/usr/bin/env python3
# Submit as pypy2


from __future__ import print_function, division, unicode_literals

__metaclass__ = type

try:
    input = raw_input
    range = xrange
except NameError:
    pass


import sys


# Test code requires python3
# from hypothesis import given
# from hypothesis import strategies as st
#
#
# def debug(*args, **kwargs):
#     print(*args, *('{}={}'.format(k, v) for k, v in kwargs.items()),
#           sep='; ', file=sys.stderr)


def main():
    H, W, K = map(int, input().split())
    S = [input() for _ in range(H)]
    ans = [[0] * W for _ in range(H)]
    st_r = 0
    col = 1
    for cur_r in range(H):
        cs = [c for c in range(W) if S[cur_r][c] == '#']
        if not cs:
            continue
        for r in range(st_r, cur_r + 1):
            st_c = 0
            for i, cur_c in enumerate(cs):
                for c in range(st_c, cur_c + 1):
                    ans[r][c] = col + i
                st_c = cur_c + 1
            for c in range(st_c, W):
                ans[r][c] = col + len(cs) - 1
        st_r = cur_r + 1
        col += len(cs)
    for r in range(st_r, H):
        ans[r][:] = ans[st_r - 1]
    for r in range(H):
        print(*ans[r])


if __name__ == "__main__":
    main()


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  long long int n,ans=0;
  cin>>n;
  vector<int> v(3*n);
  rep(i,3*n) cin>>v[i];
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++){
    ans+=v[3*n-2*(i+1)];
  }
  
  cout<<ans<<endl;
  
  
  
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
using namespace std;

const int N = 100100;
int n;
char s[N];

int main()
{
	scanf(" %s ", s);
	n = strlen(s);
	for (int i = 0; i < n - 1; i++)
	{
		if (s[i] == s[i + 1])
		{
			printf("%d %d\n", i + 1, i + 2);
			return 0;
		}
		if (i < n - 2 && s[i] == s[i + 2])
		{
			printf("%d %d\n", i + 1, i + 3);
			return 0;
		}
	}
	printf("-1 -1\n");

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,M;
vector<int>G[100005];
int ans1[100005];
vector<int>lsum[100005],rsum[100005];
int dfs1(int x,int p){
	int cld=1;
	ans1[x]=1;
	for(int i:G[x])if(i!=p){
		int j=dfs1(i,x)+1;
		(ans1[x]*=j)%=M;
		lsum[x].pb(j);
		rsum[x].pb(j);
	}
	rep(i,len(lsum[x])-1){
		(lsum[x][i+1]*=lsum[x][i])%=M;
	}
	for(int i=len(rsum[x])-1;i>0;i--){
		(rsum[x][i-1]*=rsum[x][i])%=M;
	}
	return ans1[x];
}
int ans2[100005];
void dfs2(int x,int p){
	int num=0;
	for(int i:G[x])if(i!=p){
		ans2[i]=ans2[x]*(num?lsum[x][num-1]:1)%M*(num!=len(rsum[x])-1?rsum[x][num+1]:1)%M+1;
		num++;
		dfs2(i,x);
	}
}
signed main(){
	cin>>N>>M;
	rep(i,N-1){
		int a,b;cin>>a>>b;
		a--;b--;
		G[a].pb(b);G[b].pb(a);
	}
	dfs1(0,0);
	ans2[0]=1;
	dfs2(0,0);
	rep(i,N)cout<<ans1[i]*ans2[i]%M<<endl;
}


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

int main(){
  unsigned short *A, *B;
  int i, j, n, C[10001], k = 0;
  scanf("%d", &n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  if(n <= 2000000 && n >= 1){
    for(i = 1; i <= n; i++){
      scanf("%hd", &A[i]);

      if(A[i] > k)
	k = A[i];
    }

    for(i = 0; i <= k; i++){
      C[i] = 0;
    }
    for(j = 1; j <= n; j++){
      C[A[j]]++;
    }
 
    for(i = 1; i <= k; i++){
      C[i] = C[i] + C[i-1];
    }
    for(j = n; j > 0; j--){
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }

    for(i=1; i <= n; i++){
      if(i != n)printf("%d ", B[i]);
      else printf("%d\n", B[i]);
    }
  }
  return 0;
}
  



Measured memory_bytes: 9552
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        double sqrt = Math.sqrt(Double.parseDouble(a+b));

        if (sqrt % 1 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

ll x,y;

int main(){
  cin>>x>>y;
  if(x%y==0){
    cout<<-1<<endl;
  }
  else{
    cout<<x*(y+1)<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a;
	int b;
	int c;
	int x;
	scanf("%d %d %d",&a,&b,&c);
	if(a>=b){
		x=b;
		b=a;
		a=x;}
	if(b>=c){
		x=c;
		c=b;
		b=x;}
	if(a>=b){
		x=b;
		b=a;
		a=x;}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
import scala.io.{StdIn => in}
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock

object Main extends App {

  val n = in.readLine.toInt
  val seq = in.readLine.split(" ").map(_.toInt)

  val p = seq(0)
  val ans = seq.tail./:(1, p, 0) { case ((acc, pre, sign), i) =>
    acc match {
      case acc if (pre == i && 0 == sign) => (acc, i, 0)
      case acc if (pre < i && 0 == sign) => (acc, i, 1)
      case acc if (pre > i && 0 == sign) => (acc, i, -1)
      case acc if (pre == i && 0 < sign) => (acc, i, 1)
      case acc if (pre == i && 0 > sign) => (acc, i, -1)
      case acc if (pre < i && 0 < sign) => (acc, i, 1)
      case acc if (pre > i && 0 > sign) => (acc, i, -1)
      case _ => (acc + 1, i, 0)
    }
  }._1

  println(ans)
}

Measured memory_bytes: 42784
#include <algorithm>
#include <array>
#include <assert.h>
#include <chrono>
#include <bitset>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<pll> vpll;

#ifdef OLBOEB
mt19937 rnd(228 + 1488 + 238 + 24111997 % 322);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

void print_time() {
#ifdef OLBOEB
    cout.flush();
    cerr << "\ntime: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(x) ((ll)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }


vb banned(10);
bool check(ll x) {
    do {
        if (banned[x % 10]) return false;
        x /= 10;
    } while (x);

    return true;
}

int main() {
    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n, k;
    cin >> n >> k;
    for (ll i = 0; i < k; ++i) {
        ll d;
        cin >> d;
        banned[d] = true;
    }
    for (ll i = n;; ++i) {
        if (check(i)) {
            cout << i << endl;
            return 0;
        }
    }

    print_time();
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

//unionfind tree 0-indexedに注意！
struct unionfind{
    vl par,siz;ll group;
    inline unionfind(ll n):par(n),siz(n,1){
        iota(par.begin(), par.end(), 0);
        group=n;
    }
    inline void init(ll n){
        par.resize(n);
        siz.assign(n,1);
        iota(par.begin(), par.end(), 0);
    }
    inline ll root(ll x){
        while(par[x]!=x)x=par[x]=par[par[x]];
        return x;
    }
    inline bool unite(ll x, ll y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(siz[x]<siz[y])swap(x,y);
        par[y]=x;
        siz[x]+=siz[y];
        group--;
        return 1;
    }
    inline bool same(ll x, ll y){
        return root(x)==root(y);
    }
    inline ll size(ll x){
        return siz[root(x)];
    }
    inline ll groups(){
        return group;
    }
};

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> A(M,0);
    vector<ll> B(M,0);
    unionfind tree(N);
    for(ll i=0;i<M;++i)cin>>A[i]>>B[i];
    for(ll i=0;i<M;++i){
        A[i]--;B[i]--;
    }
    for(ll i=0;i<M;++i){
        tree.unite(A[i],B[i]);
    }
    vector<ll> vec(N,0);
    for(ll i=0;i<N;++i){
        vec[tree.root(i)]++;
    }
    ll ans=0;
    for(auto p: vec){
        chmax(ans,p);
    }
    prt(ans);


    return 0;
}



Measured memory_bytes: 11112
#include<stdio.h>

#define max 25

struct node{
  int parent,left,right;
};

struct node T[max];
int T2[max],T3[max];

void depth(int,int);
int high(int);
int sibling(int);
void printtree(int);

void depth(int u,int dep)
{
  if(u == -1)
    return;
  T2[u] = dep;
  depth(T[u].left,dep+1);
  depth(T[u].right,dep+1);
}

int high(int u)
{
  int hl=0,hr=0;
  if(T[u].left != -1)
    hl = high(T[u].left) + 1;
  if(T[u].right != -1)
    hr = high(T[u].right) + 1;
  return T3[u] = (hl > hr ? hl : hr);
}

int sibling(int u)
{
  if(T[u].parent == -1)
    return -1;
  
  if(T[T[u].parent].left != u && T[T[u].parent].left != -1)
    return T[T[u].parent].left;

  if(T[T[u].parent].right != u && T[T[u].parent].right != -1)
    return T[T[u].parent].right;

  return -1;
}

void printtree(int u)
{
  int degree=0;
  
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",sibling(u));
  if(T[u].left != -1)
    degree++;
  if(T[u].right != -1)
    degree++;
  printf("degree = %d, ",degree);
  printf("depth = %d, ",T2[u]);
  printf("height = %d, ",T3[u]);

  if(T[u].parent == -1) {
    printf("root\n");
  }else if(T[u].left == -1 && T[u].right == -1) {
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

  
int main()
{
  int i,n,hi,le,ri;
  int root = 0;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    T[i].parent = -1;

  for(i=0;i<n;i++) {
    scanf("%d%d%d",&hi,&le,&ri);
    T[hi].left = le;
    T[hi].right = ri;
    if(le != -1)
      T[le].parent = hi;
    if(ri != -1)
      T[ri].parent = hi;
  }

  for(i=0;i<n;i++) {
    if(T[i].parent == -1)
      root = i;
  }

  depth(root,0);
  high(root);

  for(i=0;i<n;i++)
    printtree(i);

  return 0;
}
  
  



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

int main(){
string s,t;
 cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
  cout<<"Yes"<<endl;
   }
  else{
  cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int a, b, c, d ;
  cin >> a >> b >> c >> d ;
  
  cout << max(0,min(b,d)-max(a,c)) <<endl;

  return 0 ;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

K, N = [int(x) for x in stdin.readline().rstrip().split()]
A = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
span_list = []

for i in range(N):
    # print(A[i])
    if i < N-1:
        span = A[i+1] - A[i]
        span_list.append(span)
    else:
        span = K - A[i] + A[0]
        span_list.append(span)

span_list.sort()
# print(span_list)
del span_list[-1]
# print(span_list)
print(sum(span_list))

Measured memory_bytes: 26564
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;




int main(){
    LL n,c;cin >> n >> c;
    vector<LL> a(n),b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    vector<vector<LL>> dp(n+1,vector<LL> (c+1,0));
    vector<vector<LL>> dp1(n+1,vector<LL> (c+1,0));
    LL bi = 1;
    for (int i = 0; i < n; i++) {
        dp[i][0] = bi;
        for (LL k = a[i]; k <= b[i]; k++) {
            auto p = dp[i];
            for (int j = 1; j <= c; j++) {
                if(i) p[j] = dp[i-1][j];
                p[j] = (p[j] + p[j-1] * k)%mod;
                dp1[i][j] = (dp1[i][j] + p[j])%mod;
            }
        }
        dp[i] = dp1[i];
        bi = bi * (b[i] - a[i] + 1) % mod;
    }
    cout << dp[n-1][c] << endl;
    return 0;
}


Measured memory_bytes: 2816
#include "bits/stdc++.h"
using namespace std;
 
typedef long long int ll;
 
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int x, n;
	cin >> x >> n;
	set<int> distinct;
	for (int i = 0; i < n ; i++){
		int y;
		cin >> y;
		distinct.insert(y);
	}
	int mini = 0;
	for (int i = 0; i <= 101; i++){
		if (abs(x-i) < abs(x-mini) && distinct.find(i) == distinct.end())
			mini = i;
	}
	cout << mini << '\n';
}

Measured memory_bytes: 3660
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double sum = 0;

    for (int i = 0; i < n; i++) {
      sum += (1.0 / sc.nextInt());
    }
    System.out.println((1 / sum));
  }

}


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

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

using namespace std;

const int INF=1<<29;

int main(){
	int n; scanf("%d",&n);
	int a[100];
	rep(i,n) scanf("%d",&a[i]);

	int ans=INF;
	for(int tar=-100;tar<=100;tar++){
		int cost=0;
		rep(i,n) cost+=(a[i]-tar)*(a[i]-tar);
		ans=min(ans,cost);
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, a, b;
    scanf("%d", &x);
    scanf("%d", &a);
    scanf("%d", &b);
    x -= a;
    int minusDonuts = x/b;
    int addDonuts = b*minusDonuts;
    printf("%d\n", x-addDonuts);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
  ll n, ans = 1;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) ans = 0;
  }

  if (ans == 0)
    cout << 0 << endl;
  else {
    for (int i = 0; i < n; i++) {
      if (ans > (ll)pow(10, 18) / a[i]) {
        cout << -1 << endl;
        return 0;
      } else
        ans *= a[i];
    }

    if (ans > (ll)pow(10, 18))
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
}

Measured memory_bytes: 4052
// ABC090B_2.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	int count=0;

	for(int i=a;i<=b;i++)
	{
			int c = i/10 % 10;
			int d = i/(10 * 10 * 10) % 10;
	
			int e = i % 10;
			int f = i/(10 * 10 * 10 * 10) % 10;
		
			if (c == d && e == f) count++;
	}

	cout << count << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
import           Control.Monad

main :: IO ()
main = do
  [n, x] <- map read . words <$> getLine
  as <- map read . words <$> getLine

  let cost = solve x (mins x as) 0

  print $ sum as - sum (mins x as) + cost
  where
    mins x as = [min x a | a <- as]

solve :: Int -> [Int] -> Int -> Int 
solve _ [_] c = c
solve x (a1: a2: as) c
  | a1 + a2 > x = solve x (x - a1:as) (c + a1 + a2 - x)
  | otherwise = solve x (a2:as) c

Measured memory_bytes: 36220
N = input()
n = len(N)
ans = 0
if n < 3:
    print(0)
    exit()
if n > 3:
    for i in range(3,n):
        ans += 3**i - 3*(2**i) + 3
a = int(N[0])
if a > 3:
    ans += 3**(n-1) - 2*(2**(n-1)) + 1
if a > 5:
    ans += 3**(n-1) - 2*(2**(n-1)) + 1
if a > 7:
    ans += 3**(n-1) - 2*(2**(n-1)) + 1
b = int(N[1])
c = int(N[2])
if a == 3:
    if b > 3:
        ans += 3**(n-2) - 2*(2**(n-2)) + 1
    if b > 5:
        ans += 3**(n-2) - (2**(n-2))
    if b > 7:
        ans += 3**(n-2) - (2**(n-2))
    if b == 3:
        if c > 3:
            ans += 3**(n-3) - 2*(2**(n-3)) + 1
        if c > 5:
            ans += 3**(n-3) - (2**(n-3))
        if c > 7:
            ans += 3**(n-3) - (2**(n-3))
    if b == 5:
        if c > 3:
            ans += 3**(n-3) - (2**(n-3))
        if c > 5:
            ans += 3**(n-3) - (2**(n-3))
        if c > 7:
            ans += 3**(n-3)
    if b == 7:
        if c > 3:
            ans += 3**(n-3) - (2**(n-3))
        if c > 5:
            ans += 3**(n-3)
        if c > 7:
            ans += 3**(n-3) - (2**(n-3))
elif a == 5:
    if b > 3:
        ans += 3**(n-2) - (2**(n-2))
    if b > 5:
        ans += 3**(n-2) - 2*(2**(n-2)) + 1
    if b > 7:
        ans += 3**(n-2) - (2**(n-2))
    if b == 3:
        if c > 3:
            ans += 3**(n-3) - (2**(n-3))
        if c > 5:
            ans += 3**(n-3) - (2**(n-3))
        if c > 7:
            ans += 3**(n-3)
    if b == 5:
        if c > 3:
            ans += 3**(n-3) - (2**(n-3))
        if c > 5:
            ans += 3**(n-3) - 2*(2**(n-3)) + 1
        if c > 7:
            ans += 3**(n-3) - (2**(n-3))
    if b == 7:
        if c > 3:
            ans += 3**(n-3)
        if c > 5:
            ans += 3**(n-3) - (2**(n-3))
        if c > 7:
            ans += 3**(n-3) - (2**(n-3))
elif a == 7:
    if b > 3:
        ans += 3**(n-2) - (2**(n-2))
    if b > 5:
        ans += 3**(n-2) - (2**(n-2))
    if b > 7:
        ans += 3**(n-2) - 2*(2**(n-2)) + 1
    if b == 3:
        if c > 3:
            ans += 3**(n-3) - (2**(n-3))
        if c > 5:
            ans += 3**(n-3)
        if c > 7:
            ans += 3**(n-3) - (2**(n-3))
    if b == 5:
        if c > 3:
            ans += 3**(n-3)
        if c > 5:
            ans += 3**(n-3) - (2**(n-3))
        if c > 7:
            ans += 3**(n-3) - (2**(n-3))
    if b == 7:
        if c > 3:
            ans += 3**(n-3) - (2**(n-3))
        if c > 5:
            ans += 3**(n-3) - (2**(n-3))
        if c > 7:
            ans += 3**(n-3) - 2*(2**(n-3)) + 1
    
if (a == 3 or a == 5 or a == 7) and (b == 3 or b == 5 or b == 7) and (c == 3 or c == 5 or c == 7):
    d = (a*100 + b * 10 + c) * 10**(n-3)
    e = int(N) + 1
    t = {"3","5","7"}
    for i in range(d,e):
        u = set(str(i))
        if u == t:
            ans += 1
print(ans)

Measured memory_bytes: 9276
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b;
    if(a+b>=a*b&&a+b>=a-b)
        c=a+b;
    if(a-b>=a+b&&a-b>=a*b)
        c=a-b;
    if(a*b>=a-b&&a*b>=a+b)
        c=a*b;
    cout<<c;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int N, M;
int P[100001], Y[100001];
vector<int> list[100001];

int main(void) 
{
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> P[i + 1] >> Y[i + 1];
	}

	for (int i = 1; i < M + 1; i++) {
		list[P[i]].push_back(Y[i]);
	}

	for (int i = 1; i < 100001; i++) {
		if (list[i].empty()) {
			continue;
		}
		sort(list[i].begin(), list[i].end());
	}

	for (int i = 1; i < M + 1; i++) {
		int left = 0, right = list[P[i]].size() - 1;
		while (left <= right) {
			int mid = (left + right) / 2;
			if (Y[i] == list[P[i]][mid]) {
				cout << setfill('0') << setw(6) << P[i] << setfill('0') << setw(6) << mid + 1 << endl;
				break;
			}
			else if (Y[i] < list[P[i]][mid]) {
				right = mid - 1;
			}
			else {
				left = mid + 1;
			}
		}
	}

	return 0;
}

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

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

  int a,b; cin >> a >> b;
  int ans = 0;
  for(int i = 0; i < 2; i++){
    ans += max(a,b);
    if(a > b) a--;
    else b--;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# 最大公約数
def gcd(m, n):
    while(n != 0):
        temp = n
        n = m % n
        m = temp
    return m


N = int(input())
T = [int(input()) for _ in range(N)]
ans = 0
for i in range(len(T)):
    if ans == 0:
        ans = T[i]
    else:
        ans = ans // gcd(ans, T[i]) * T[i]
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod  10000007
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
#define mem(a,b) memset(a,b,sizeof(a));
typedef long long ll;
const ll maxn=5000006;
//priority_queue<ll,vector<ll >,greater<ll > >q;
const ll INF=0x3f3f3f3f;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
//__builtin_popcount
//priority_queue

int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
ll kc(ll a,ll b){ll c=1;while(b){if(b&1)c=(c*a)%mod;a=(a*a)%mod;b>>=1;}return c;}
bool cmp(double x,double y){return x>y;}
int read(){int x=0,f=1;char s=getchar();for(; s>'9'||s<'0'; s=getchar()) if(s=='-') f=-1;for(; s>='0'&&s<='9'; s=getchar()) x=x*10+s-'0';return x*f;}
int a[maxn];
int b[maxn];
int c[maxn];
int main()
{
     ios::sync_with_stdio(false);
  int t;
  cin>>t;
  for(int i=1;i<=t;i++)
    cin>>a[i];
    int q=0,qq=0;;
  for(int i=1;i<t;i++)
    if(a[i]>a[i+1])
  {
      if(a[i]-a[i+1]==1&&!qq){qq=1;continue;}
      else q=1;

  }
  else if(a[i+1]>a[i])qq=0;
  if(!q)cout<<"Yes\n";
  else cout<<"No\n";

}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  Graph train(N, vi(N, 0));
  rep(i,M) {
    int L, R;
    cin >> L >> R;
    ++train[L-1][R-1];
  }

  for (int i=1; i<N; ++i) {
    for (int j=0; ; ++j) {
      int k = i+j;
      if (k == N) break;
      train[j][k] += train[j][k-1] + train[j+1][k] - train[j+1][k-1];
    }
  }

  rep(i,Q) {
    int p, q;
    cin >> p >> q;
    cout << train[p-1][q-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	pair<int, int> A[100010] = {}; // (距離, 余り)の組
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que; 
	for(int i = 0; i < N; i++){
		A[i].first = 50; A[i].second = i; 
	}
	A[1].first = 1;
	que.push(A[1]); 
	while(que.size()){
		pair<int, int> c = que.top(); que.pop(); 
		int m = (10 * c.second) % N; int n = (c.second + 1) % N; 
		if(A[m].first > c.first){
			A[m].first = c.first; que.push(A[m]);
		}
		if(A[n].first > c.first + 1){
			A[n].first = c.first + 1; que.push(A[n]);
		}
	}
	cout << A[0].first << endl; 
}

Measured memory_bytes: 1660
#include <stdio.h>

int main(void)
{
	double a, b, c, d, e, f;
	double x, y;
	double A;

	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		A = 1.0 / (a * e - b * d);
		x = e * c - b * f;
		y = a * f - d * c;

		x *= A;
		y *= A;

		x += 0.0001;
		y += 0.0001;

		printf("%.3lf %.3lf\n", x,  y);
	}

	return (0);
}

Measured memory_bytes: 652
N = int(input())

lst = []
for i in range(N):
  N, K = map(int, input().split())
  lst.append((K-N, N, K))

lst.sort()
lst.sort(key=lambda tup: tup[2])
count = 0
for ind, x in enumerate(lst):
  if count > x[0]:
    print("No")
    exit()
  count += x[1]

print("Yes")


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

int main(){
  int x = 1;
  int i = 1;

  while(x != 0){
    cin >> x;
    if(x == 0){break;}
    cout << "Case" << " " << i << ":" << " " << x << endl;
    i++;
  }
  return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> s(m);
	vector<int> c(m);
	rep(i, m)cin >> s[i] >> c[i];

	rep(x, 1000) {
		int keta = 1;
		int nx = x / 10;
		vector<int> d(1, x % 10);
		while (nx) {
			keta++;
			d.push_back(nx % 10);
			nx /= 10;
		}
		if (keta != n)continue;
		bool ok = true;
		reverse(d.begin(), d.end());
		rep(i, m) {
			if (d[s[i] - 1] != c[i]) {
				ok = false;
			}
		}
		if (ok) {
			cout << x << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main(){

	int d, n;
	cin >> d >> n;

	if(d==0){
		if(n==100){
			cout << 101 << endl;
			return 0;
		} else {
			cout << n << endl;
			return 0;
		}
	} else if(d==1){
		if(n==100){
			cout << 10100 << endl;
			return 0;
		} else {
			cout << n*100 << endl;
			return 0;
		}		
	} else {
		if(n==100){
			cout << 1010000 << endl;
			return 0;
		} else {
			cout << n*10000 << endl;
			return 0;
		}		
	}
	return 0;
}


Measured memory_bytes: 256
import math

n,k=map(int,input().split())

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

low=1
high=max(A)

while low!=high:
    mid=(low+high)//2
    s=0
    for i in range(n):
        s+=math.ceil(A[i]/mid)-1
    if s>k:
        low=mid+1
    else:
        high=mid


print(low)

Measured memory_bytes: 31116
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int A[100000];

int main()
{
	int N, pre = -1;
	int cnt = 0, L[2];
	ll ans;

	cin >> N;
	rep(i, N) cin >> A[i];

	sort(A, A + N, greater<int>());

	rep(i, N) {
		if (pre == A[i]) {
			L[cnt] = A[i];
			cnt++;
			pre = -1;
			if (cnt >= 2) break;
		}
		else pre = A[i];
	}

	if (cnt < 2) ans = 0;
	else ans = (ll)L[0] * (ll)L[1];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
/**/
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

long long fact[1010],inv[1010];
long long dp[1010][1010];

int A,B;
int C,D;
int N;

long long pow_mod(long long base,long long power) {
	long long res = 1;
	while(power) {
		if(power&1)
			res = res * base % mod;
		base = base * base % mod;
		power >>= 1;
	}
	return res;
}

long long calc(int N,int G,int i) {
	long long ncri = fact[N];
	ncri = ncri *  pow_mod(inv[G],i) % mod;
	ncri = ncri * inv[i] % mod;
	ncri = ncri * inv[N - i * G] % mod;
	return ncri;
}

long long bt(int G,int N) {
	if(N == 0)
		return 1;
	if(G > B || N < G)
		return 0;
	long long & ref = dp[G][N];
	if(ref != -1)
		return ref;
	ref = bt(G+1,N);
	for(int i = C;i <= D && i * G <= N;i++) {
		ref = (ref + calc(N,G,i) * bt(G+1,N - i * G)) % mod;
	}
	return ref;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	fact[0] = fact[1] = inv[0] = inv[1] = 1;
	for(int i = 2;i < 1010;i++) {
		fact[i] = fact[i-1] * i % mod,inv[i] = pow_mod(fact[i],mod-2);
	}
	
	memset(dp,-1,sizeof dp);
	cin>>N>>A>>B>>C>>D;
	cout<<bt(A,N)<<'\n';
	return 0;
}
/**/


Measured memory_bytes: 8320
// AOJ 0558

import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), W = sc.nextInt(), N = sc.nextInt();
        char[][] town = new char[H][];
        for (int i = 0; i < H; i++) {
            town[i] = sc.next().toCharArray();
        }
        boolean[][] visited = new boolean[H][W];
        ArrayDeque<int[]> queue = new ArrayDeque<int[]>();
        int stamina = 1;
        int[][] move = new int[][] {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (town[i][j] == 'S') {
                    queue.add(new int[] {i, j, 0});
                    visited[i][j] = true;
                }
            }
        }

        while (true) {
            int[] data = queue.poll();
            int i = data[0], j = data[1], time = data[2];
            for (int[] m: move) {
                int ni = i + m[0], nj = j + m[1];
                if (ni < 0 || H <= ni || nj < 0 || W <= nj || visited[ni][nj]) continue;
                if (town[ni][nj] == stamina + '0') {
                    stamina++;
                    if (stamina == N + 1) {
                        System.out.println(time + 1);
                        return;
                    }
                    queue.clear();
                    queue.add(new int[] {ni, nj, time+1});
                    visited = new boolean[H][W];
                    break;
                } else if (town[ni][nj] == 'X') {
                    continue;
                } else {
                    queue.add(new int[] {ni, nj, time+1});
                    visited[ni][nj] = true;
                }
            }
        }
    }
}



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

using namespace std;


void eating_symbols_easy()
{
  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < 4; ++i)
  {
    if (s[i] == '+') ++cnt;
    else --cnt;
  }
  cout << cnt << "\n";
}


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

  if (n % 2 == 0) cout << n << "\n";
  else cout << 2 * n << "\n";
}


void task_scheduling_problem()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

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

  cout << a[2] - a[0] << "\n";
}


void rated_for_me()
{
  int r;
  cin >> r;

  if (r < 1200) cout << "ABC\n";
  else if (r < 2800) cout << "ARC\n";
  else cout << "AGC\n";
}


void atcoder_crackers()
{
  int n, k;
  cin >> n >> k;

  if (n % k == 0) cout << 0 << "\n";
  else cout << 1 << "\n";
}


void garden()
{
  int a, b;
  cin >> a >> b;

  cout << (a - 1) * (b - 1) << "\n";
}


void train()
{
  int n, i;
  cin >> n >> i;

  cout << n - i + 1 << "\n";
}


void Pair()
{
  int k;
  cin >> k;

  if (k % 2 == 0) cout << k / 2 * k / 2 << "\n";
  else cout << k / 2 * (k / 2 + 1) << "\n";
}


void ABC333()
{
  int a, b;
  cin >> a >> b;

  if ((a == 1 && (b == 1 || b == 3)) || (a == 3 && (b == 1 || b == 3))) cout << "Yes\n";
  else cout << "No\n";
}


void maximize_the_formula()
{
  int a, b, c;
  cin >> a >> b >> c;

  int v_max = max({ a,b,c });
  cout << a + b + c + 9 * v_max << "\n";
}


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

  int s = 0, tmp = n;
  while (tmp > 0)
  {
    s += tmp % 10;
    tmp /= 10;
  }
  if (n % s == 0) cout << "Yes\n";
  else cout << "No\n";
}


void maximum_difference()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

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

  cout << a[n - 1] - a[0] << "\n";
}

void string_rotation() 
{
  string s, t;
  cin >> s >> t;

  for (int i = 0; i < s.size(); ++i)
  {
    if (s == t)
    {
      cout << "Yes\n";
      return;
    }
    char c = s.back();
    s.pop_back();
    s = c + s;
  }
  cout << "No\n";
}


void accepted()
{
  string s;
  cin >> s;

  if (s[0] != 'A')
  {
    cout << "WA\n";
    return;
  }

  int cnt = 0;
  for (int i = 1; i < s.size(); ++i)
  {
    if (i >= 2 && i <= s.size() - 2 && s[i] == 'C') ++cnt;
    else if (s[i] < 97)
    {
      cout << "WA\n";
      return;
    }
  }

  if (cnt != 1)
  {
    cout << "WA\n";
    return;
  }

  cout << "AC\n";
}


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

  int flag = 0;
  for (int i = 0; i <= n / 4; ++i)
  {
    for (int j = 0; j <= n / 7; ++j)
    {
      if (i * 4 + j * 7 == n) flag = 1;
    }
  }
  if (flag) cout << "Yes\n";
  else cout << "No\n";
}


int main()
{
  //eating_symbols_easy();
  //multiple_of_2_and_n();
  //task_scheduling_problem();
  //rated_for_me();
  //atcoder_crackers();
  //garden();
  //train();
  //Pair();
  //ABC333();
  //maximize_the_formula();

  //digit_sums();
  //maximum_difference();
  //string_rotation();
  //accepted();
  cakes_and_donuts();
}

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

vector<int> dp;
vector<vector<int>> adj;

int dfs(int i){
   
    if(dp[i] != -1){
        return dp[i];
    }
     if(adj[i].empty()){
        dp[i] = 0;
        return 0;
    }

    for(auto v : adj[i]){
        dp[i] = max(dfs(v)+1,dp[i]);   
    }
    return dp[i];
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n,k,i,x,y,ans;
    cin >> n >> k;
    dp.resize(n+1,-1);
    adj.resize(n+1, vector<int> ());

    for(i = 0;i < k;i++){
        cin >> x >> y;
        adj[x].emplace_back(y);
    }
    ans = 0;

    for(i = 1;i <= n;i++){
        ans = max(ans,dfs(i));
    }
    // for(auto i : dp){
    //     cout << i << " ";
    // }
    cout << ans;
    dp.clear();
    adj.clear();
    return 0;
}


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

int main ()
  {
  string s;
  int n,ans=0;
  cin>>n>>s;
  for(int i=0;i<s.length()-1;i++)
    {
    if(s[i]!=s[i+1])
      ans++;
    }
  cout<<ans+1;
  return 0;
  }


Measured memory_bytes: 512
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0];
    auto K = s[1];

    long[] F;
    for (long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            F ~= N / i;
            F ~= i;
        }
    }
    F = F.sort().uniq().array;

    auto cnt = new long[](F.length);

    foreach (i; 0..F.length.to!int) {
        cnt[i] = powmod(K, (F[i]+1)/2, MOD);
        foreach (j; 0..i) {
            if (F[i] % F[j] == 0) {
                cnt[i] -= cnt[j];
                cnt[i] = (cnt[i] % MOD + MOD) % MOD;
            }
        }
    }

    long ans = 0;
    foreach (i; 0..F.length.to!int) {
        if (F[i] % 2 == 0) {
            ans = (ans + cnt[i] * F[i] / 2 % MOD) % MOD;
        } else {
            ans = (ans + cnt[i] * F[i] % MOD) % MOD;
        }
    }
    ans.writeln;
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}


Measured memory_bytes: 380
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>

using namespace std;

int main()
{
  string S;
  cin >> S;

  bool ans = S[2]==S[3] && S[4]==S[5];

  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}


int main() {
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	
	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

vll G[100100];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vll h(n);
  rep(i,n) cin>>h[i];
  rep(i,m){
    ll a,b; cin>>a>>b; a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  vb visited(n);
  vb ok(n,true);
  rep(i,n){
    queue<ll> q;
    q.emplace(i);
    while(!q.empty()){
      ll v=q.front(); q.pop();
      if(visited[v]) continue;
      visited[v]=true;
      for(auto nv: G[v]){
        if(visited[nv]) continue;
        if(h[v]<h[nv]) ok[v]=false;
        if(h[v]>h[nv]) ok[nv]=false;
        if(h[v]==h[nv]) ok[v]=ok[nv]=false;
        q.emplace(nv);
      }
    }
  }
  ll ans=0;
  rep(i,n) if(ok[i]) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 10152
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

int n;
ll a[300001];
ll l = 0;

bool C(ll x){
  for(int i=0;i<n;i++){
    int left = upper_bound(a+i,a+i+n,a[i+n]-x) - a - 1;
    int right = lower_bound(a+i+n,a+i+2*n,a[i+n]+x) - a;
    if(a[right]-a[left]<=l-x) return true;
  }
  return false;
}

int main(){
  scanf("%d",&n);
  a[0] = 0;
  for(int i=0;i<n;i++){
    scanf("%lld",a+i+1);
    l += a[i+1];
    a[i] = l;
  }
  for(int i=0;i<n;i++){
    a[i+n] = a[i] + l;
    a[i+2*n] = a[i] + 2 * l;
  }
  ll lb = 1, ub = l;
  while(ub-lb>1){
    ll mid = (ub + lb) / 2;
    if(C(mid)) lb = mid;
    else ub = mid;
  }
  printf("%lld\n",lb);
  return 0;
}

Measured memory_bytes: 5088
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int V[]=new int[N];
		int C[]=new int[N];
		int result=0;
		for(int i=0;i<N;i++) {
			V[i]=sc.nextInt();
		}
		for(int j=0;j<N;j++) {
			C[j]=sc.nextInt();
		}
		for(int k=0;k<N;k++) {
			if(V[k]>C[k]) {
				result=result+V[k]-C[k];
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21460
#include <cstdio>
#include <vector>

const int N = 1000 + 10, M = 20 + 10;
const int mod = 1e9 + 7;

int binom[N][N], dp[M][N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  std::vector<int> a(m);
  for (int i = 0; i < m; ++i) scanf("%d", &a[i]);
  for (int i = 0; i <= n; ++i) {
    binom[i][0] = binom[i][i] = 1;
    for (int j = 1; j < i; ++j) {
      binom[i][j] = (binom[i - 1][j] + binom[i - 1][j - 1]) % mod;
    }
  }
  dp[0][0] = 1;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j <= n; ++j) {
      for (int k = 0; j + k <= n && k <= a[i]; ++k) {
        dp[i + 1][j + k] += 1ll * dp[i][j] * binom[n - j][k] % mod * binom[n - k][a[i] - k] % mod;
        if (dp[i + 1][j + k] >= mod) dp[i + 1][j + k] -= mod;
      }
    }
  }
  printf("%d\n", dp[m][n]);
  return 0;
}


Measured memory_bytes: 4352
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    sort(ALL(a),greater<int>());
    int ans=0;
    rep(i,n){
        if(i%2)ans-=a[i];
        else ans+=a[i];
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256