akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nmx = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (varN, varM, varX) = (nmx[0], nmx[1], nmx[2]);
        var textBooks = new (int C, int[] A)[varN];
        for (int i = 0; i < textBooks.Length; ++i)
        {
            var ca = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            textBooks[i] = (ca[0], ca);
        }

        var min = Dfs(varX, textBooks, new int[varM], 0);

        Console.WriteLine(min < int.MaxValue ? min : -1);
    }

    static int Dfs(int varX, Span<(int C, int[] A)> textBooks, int[] degrees, int cost)
    {

        if (textBooks.Length < 1)
        {
            Console.Error.WriteLine(string.Join(" ", degrees));
            return degrees.All(x => x >= varX) ? cost : int.MaxValue;
        }

        var book = textBooks[0];
        textBooks = textBooks[1..];

        var t = Dfs(varX, textBooks, degrees, cost);
        for (int i = 1; i < book.A.Length; ++i)
        {
            degrees[i - 1] += book.A[i];
        }
        var s = Dfs(varX, textBooks, degrees, cost + book.C);
        for (int i = 1; i < book.A.Length; ++i)
        {
            degrees[i - 1] -= book.A[i];
        }

        return Math.Min(t, s);
    }
}


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int r;
    cin >> r;
    setpre(10);
    cout << r * 2 * M_PI << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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;
}


Measured memory_bytes: 3784
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
map<long long,long long>p;
map<long long,long long>::iterator it;
int main(){
    int n;
    cin>>n;
    int x;
    long long sum=0;
    for(int i=0;i<n;i++){
        cin>>x;
        sum+=x;
        p[sum]++;
    }
    long long ans=0;
    for(it=p.begin();it!=p.end();it++){
            long long s=it->second;
            if(it->first==0)
                ans+=(s*(s+1)/2);
            else
                ans+=(s*(s-1)/2);
    }
    cout<<ans<<endl;
return 0;}


Measured memory_bytes: 12800
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;


//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}

LL f(int k,int sz){
	if(k-2<sz-1)return 0;
	return dvs(fact[k-2],fact[k-2-(sz-1)]);
}

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n,k;
	cin>>n>>k;
	cmbset(100005);
	vii g(n+1,vi());
	FOR(i,0,n-1){
		int a,b;
		cin>>a>>b;
		g[a].PB(b);
		g[b].PB(a);
	}
	LL ans=k;
	queue<int> q;
	q.push(1);
	int used[101010]={};
	used[1]=1;
	LL t=0;
	if(k>g[1].size())t=dvs(fact[k-1],fact[k-1-g[1].size()]);
	ans=mul(ans,t);
	//cerr<<ans<<endl;
	while(q.size()){
		int nw=q.front();
		q.pop();
		if(nw!=1)ans=mul(ans,f(k,g[nw].size()));
		for(const auto& x:g[nw]){
			if(used[x])continue;
			used[x]=1;
			q.push(x);
		}
		//cerr<<nw<<" "<<ans<<endl;
	}

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


Measured memory_bytes: 7672
#include<iostream>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
ll power(ll a,ll x){
  ll res=1;
  while(x){
    if(x&1) res=res*a%mod;
    a=a*a%mod;
    x>>=1;
  }
  return res;
}
int main(){
  ll n;cin>>n;
  ll ans=power(10,n)-2*power(9,n)+power(8,n);
  ans=(ans+2*mod)%mod;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3644
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();

    let mut no_hand = true;
    let start = s.chars().nth(0).unwrap();
    for c in s
        .chars()
        .enumerate()
        .filter(|&(i, _)| i % 2 == 0)
        .map(|(_, v)| v)
    {
        if start != c {
            no_hand = false;
        }
    }

    let next = s.chars().nth(1).unwrap();
    for c in s
        .chars()
        .enumerate()
        .filter(|&(i, _)| i % 2 == 1)
        .map(|(_, v)| v)
    {
        if next != c {
            no_hand = false;
        }
    }
    if no_hand {
        println!("Second");
        return;
    }

    if s.chars().nth(0) == s.chars().nth(s.len() - 1) {
        if s.len() % 2 == 0 {
            println!("First")
        } else {
            println!("Second")
        }
    } else {
        if s.len() % 2 == 0 {
            println!("Second");
        } else {
            println!("First")
        }
    }
}


Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    // x = 100Ai + 100Bj
    // y = Ck + Dl
    set<int> x, y;
    rep(i, 30){
        rep(j, 30){
            int temp = 100*A*i + 100*B*j;
            if(temp <= F) x.insert(temp);
        }
    }

    rep(i, 3000){
        rep(j, 3000){
            int temp = C*i + D*j;
            if(temp <= F) y.insert(temp);
        }
    }

    /*
    for(auto i : x) cout << i << " ";
    cout << endl;
    for(auto i : y) cout << i << " ";
    cout << endl;
    //*/
    
    /*
    Water = i
    Suger = j
    i + j <= F
    E*i >= 100*j
    maximize j / (i+j)
    answer (i+j, j)
    */
    
    P ans = P(0, 100*A);
    for(auto i : x){
        for(auto j : y){
            if(i + j > F) continue;
            if(i*E < 100*j) continue;
            if(i+j == 0) continue;
            P temp = P(j, (i+j));
            if(temp.se * ans.fi < ans.se * temp.fi){
                ans = temp;
            }
        }
    }
    cout << ans.se << " " << ans.fi << endl;    
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    
    int sum = 0;
    
    for (int i = 0; i < n ; i++) {
        int x, y;
        cin >> x >> y;
        
        sum += y - x + 1;
    }
    
    cout << sum << endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.printf("%d %d %.10f\n", a/b,a%b,(double)a/(double)b);
    }
}



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

int main(void)
{
    int N;
    cin >> N;
    long long int num = 0;
    int i;

    for(i=1;i<=N;i++){
        if(i%3!=0 && i%5!=0){
            num = num + i;
        }
    }

    cout << num << endl;

    return 0;

}

Measured memory_bytes: 3612
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<vector>
#define re register int
#define mod 1000000007
using namespace std;
typedef long long ll;
int read() {
	re x=0,f=1;
	char ch=getchar();
	while(ch<'0' || ch>'9') {
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0' && ch<='9') {
		x=10*x+ch-'0';
		ch=getchar();
	}
	return x*f;
}
inline int add(int x,int y) {
	return x+y>=mod?x+y-mod:x+y;
}
inline int del(int x,int y) {
	return x<y?x-y+mod:x-y;
}
int fpow(int b,int p) {
	int ans=1;
	while(p) {
		if(p&1)	ans=(ll)ans*b%mod;
		b=(ll)b*b%mod;
		p>>=1;
	}
	return ans;
}
const int Size=300005;
const int INF=0x3f3f3f3f;
int n,num,id[Size],d[Size],deep[Size],tot[Size];
struct node {
	int zero;
	int one;
};
vector<node> dp[Size];
int cnt,head[Size];
struct Edge {
	int v,next;
} w[Size<<1];
void AddEdge(int u,int v) {
	w[++cnt].v=v;
	w[cnt].next=head[u];
	head[u]=cnt;
}
int All[Size],Zero[Size],One[Size];
void dfs(int x) {
	int son=n+1,siz=0;
	for(int i=head[x]; i; i=w[i].next) {
		int nxt=w[i].v;
		dfs(nxt);
		if(d[nxt]>d[son]) {
			son=nxt;
		}
		siz++;
	}
	if(son>n) {
		id[x]=++num;
	} else {
		id[x]=id[son];		//继承 
		d[x]=d[son]+1;
	}
	dp[id[x]].push_back((node){1,1});	//这一深度的dp 
	if(siz==1)	return;
	for(re i=0; i<=d[x]; i++) {
		All[i]=Zero[i]=1;
		One[i]=0;
	}
	for(re i=head[x]; i; i=w[i].next) {
		int nxt=w[i].v,sd=d[son]-d[nxt];
		for(re j=0; j<=d[nxt]; j++) {
			int nowd=sd+j;
			node now=dp[id[nxt]][j];
			All[nowd]=(ll)All[nowd]*(now.one+now.zero)%mod;
			Zero[nowd]=(ll)Zero[nowd]*now.zero%mod;
		}
	}
	for(re i=head[x]; i; i=w[i].next) {
		int nxt=w[i].v,sd=d[son]-d[nxt];
		for(re j=0; j<=d[nxt]; j++) {
			int nowd=sd+j;
			node now=dp[id[nxt]][j];
			One[nowd]=add(One[nowd],(ll)Zero[nowd]*fpow(now.zero,mod-2)%mod*now.one%mod);
		}
	}
	for(re i=0; i<d[x]; i++) {
		dp[id[x]][i].zero=del(All[i],One[i]);
		dp[id[x]][i].one=One[i];
	}
}
int main() {
	n=read();
	for(re i=1; i<=n; i++) {
		int fa=read();
		AddEdge(fa,i);
		deep[i]=deep[fa]+1;
		tot[deep[i]]++;
	}
	tot[0]++;
	d[n+1]=-INF;
	dfs(0);
	int ans=0;
	for(re i=0; i<=d[0]; i++) {
		node now=dp[id[0]][i];
		ans=add(ans,(ll)now.one*fpow(2,n+1-tot[d[0]-i])%mod);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 37748
#include <bits/stdc++.h>
using namespace std;
int main(){
	char c;
	cin>>c;
	if(c=='A')cout<<'T'<<endl;
	if(c=='T')cout<<'A'<<endl;
	if(c=='C')cout<<'G'<<endl;
	if(c=='G')cout<<'C'<<endl;
	return 0;
}


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

char s[10];
int main() {
	int A = 0, B = 0, AB = 0, O = 0;
	int n;
	while (scanf("%d,%s", &n, s) != EOF) {
		if (!strcmp(s, "A"))A++;
		else if (!strcmp(s, "B"))B++;
		else if (!strcmp(s, "AB"))AB++;
		else O++;
	}
	cout << A << endl << B << endl << AB << endl << O << endl;
	return 0;
}

Measured memory_bytes: 3168
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


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;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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

int main() {
                 int n, a, b;
                cin >> n >> a >> b;
                 string s;
                cin >> s;
                 int now = 0, kaigai = 0;

                 for(int i =0; i<s.size();i++) {
                                 if(s[ i] == 'a') {
                                                 if (now < a + b) {
                                                                now++;
                                                                cout << "Yes" << endl;
                                                                 continue;
                                                }
                                }
                                 else if (s[i] == 'b'){
                                                 if (now < a + b && kaigai < b) {
                                                                now++;
                                                                kaigai++;
                                                                cout << "Yes" << endl;
                                                                 continue;
                                                }
                                }
                                cout << "No" << endl;
                }
                 return 0;
}


Measured memory_bytes: 896
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

B = [K] * N
for i in range(Q):
    B[A[i]-1] += 1

for i in range(N):
    B[i] -= Q

for i in range(N):
    if B[i] >= 1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 11852
def print_residence(residence):
    for i in range(4):
        for j in range(3):
            print " " +" ".join(map(str, residence[i][j]))
        if i != 3:
            print "####################"

n = int(raw_input())
residence = [[[0] * 10 for i in range(3)] for j in range(4)]
#print_residence(residence)

for i in range(n):
    info = map(int, raw_input().split())
    #print info
    #print residence
    residence[info[0]-1][info[1]-1][info[2]-1] += info[3] 
    #print residence

print_residence(residence)

Measured memory_bytes: 6412
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,ans = 0;
  	cin >> a >> b;
  	vector<int> c(a);
  	for(int i = 0; i < a; i++)
    {
    	cin >> c[i];
    }
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  for(int i = 0; i < b; i++)
  {
  ans += c[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

  int N=0,count=0,num=0;
  scanf("%d",&N);
  
  for(int i=1;i<=N;i++){
    if(i%2==1){
    	for(int j=1;j<=N;j++){
        	if(i%j == 0){
            	count++;
            }
        }
      if(count == 8){
      	num++;
      }
      count=0;
    }
  }
  
  printf("%d",num);

 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e17
    const int N=2e5+6;
    const int MOD=1e9+7;
    
    void solve()
    {
    	int n;
    	cin>>n;
    	int a[n];
    	int flag=0;
    	for(int i=0;i<n;i++)
    	{
    		cin>>a[i];
    		if(a[i]%2==0)
    		{
    			if(a[i]%3==0 || a[i]%5==0)
    			{
    				
    			}
    			else
    			flag=1;
    		}
    	}
    	if(flag)
    	cout<<"DENIED";
    	else
    	cout<<"APPROVED";
    }
	signed main()  
    {
        FAST
        int t=1;
        //cin>>t;
        while(t--){
        	solve();
        }
    }

Measured memory_bytes: 256
#include <stdio.h>
#define INF 1001001001001001001
typedef long long ll;
ll dp[3010][3010][4];
ll s[3010][3010];
ll min(ll x, ll y) {
	return x > y ? y : x;
}
ll max(ll x, ll y) {
	return x < y ? y : x;
}
int main() {
	int r, c, K;
	scanf("%d%d%d", &r, &c, &K);
	for (int i = 0; i <= r; i++) {
		for (int j = 0; j <= c; j++) {
			s[i][j] = -1;
			for (int k = 0; k < 4; k++) {
				dp[i][j][k] = -INF;
			}
		}
	}
	for (int i = 0; i < K; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--;
		b--;
		s[a][b] = c;
	}
	dp[0][0][0] = 0;
	// i列j行k個
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			for (int k = 0; k < 4; k++) {
				if (dp[i][j][k] == -INF)
					continue;
				dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
				dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
				if (s[i][j] != -1 && k != 3) {
					dp[i][j + 1][k + 1] =
						max(dp[i][j + 1][k + 1], dp[i][j][k] + s[i][j]);
					dp[i + 1][j][0] =
						max(dp[i + 1][j][0], dp[i][j][k] + s[i][j]);
				}
			}
		}
	}
	// for (int i = 0; i <= r; i++) {
	// 	for (int j = 0; j <= c; j++) {
	// 		for (int k = 0; k < 4; k++) {
	// 			if (dp[i][j][k] < 0) {
	// 				printf("IN ");
	// 			} else {
	// 				printf("%02lld ", dp[i][j][k]);
	// 			}
	// 		}
	// 		printf("  ");
	// 	}
	// 	printf("\n");
	// }
	ll ans = -INF;
	for (int i = 0; i < 4; i++) {
		ans = max(ans, dp[r][c - 1][i]);
		ans = max(ans, dp[r - 1][c][i]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

set<int> kirai;

bool haraeru(int n) {
  bool res = true;
  string s = to_string(n);
  for (int i = 0; i < s.size(); i++) {
    if (kirai.count(s[i])) res = false;
  }
  return res;
}

// ====================================================================

int main() {
  int n, k;
  cin >> n >> k;
  char a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    kirai.insert(a);
  }

  int ans = n;
  while (!haraeru(n)) {
    n++;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s="",p="";
	while(t--)
	{
		cin>>n>>k;
		rep(i,n)
		{
			s+=to_string(k);
		}
		rep(i,k)
		{
			p+=to_string(n);
		}
		if(s<p)
			cout<<s;
		else cout<<p;

		
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll K, X;
    cin >> K >> X;
    if (500 * K >= X)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return;
}

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


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int N, M, Q;
vector<ll> a, b, c, d;

ll score(const vector<ll>& A) {
	ll res = 0;
	for (int i = 0; i < Q; i++) {
		if (A[b[i]] - A[a[i]] == c[i]) {
			res += d[i];
		}
	}
	return res;
}

ll dfs(vector<ll>& A) {
	if (A.size() == N) {
		return score(A);
	}
	ll res = 0;
	int prev_last = (A.empty() ? 0 : A.back());
	for (int add = prev_last; add < M; add++) {
		A.push_back(add);
		res = max(res, dfs(A));
		A.pop_back();
	}
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	cin >> N >> M >> Q;

	a.resize(Q);
	b.resize(Q);
	c.resize(Q);
	d.resize(Q);

	for (int q = 0; q < Q; q++) {
		cin >> a[q] >> b[q] >> c[q] >> d[q];
		a[q]--; b[q]--;
	}
	
	vector<ll> A;
	cout << dfs(A) << endl;

	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

int main(int argc, char **argv) {
    int p, q, r;
    cin >> p >> q >> r;

    int ans{0};

    priority_queue<int, std::vector<int>, greater<int>> que;
    que.push(p);
    que.push(q);
    que.push(r);

    ans += que.top(); que.pop();
    ans += que.top(); que.pop();

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define    vi       vector<int>
#define    vd       vector<double>
#define    vvi      vector< vector<int> >
#define    vvll      vector< vector<long long> >
#define    vvpi     vector< vector< pair<int,int> > >
#define    vvpll     vector< vector< pair<long long,long long> > >
#define    vvd      vector< vector<double> >
#define    vs       vector<string>
#define    vvs      vector< vector<string> >
#define     vpi        vector< pair<int ,int> >
#define      pi        pair<int ,int>
#define      pll       pair<long long ,long long>
#define     vpd        vector< pair<double ,double> >
#define     vpll        vector< pair<long long ,long long> >
#define    vll       vector<long long>
#define    dqi        deque< int >
#define     si         set<int>
#define     spi        set< pair<int ,int > >
#define     row          vector< ll >
#define     matrix            vector< row >
#define     si         set<int>
#define    oo         900000000000000000
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-10);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
int setBit0(int num, int idx) {return num & ~(1<<idx);}
int flipBit(int num, int idx) {return num ^ (1<<idx);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}

int main()
{
    string num;

    cin>>num;
    ll s=0;
    for(int i=0;i<sz(num);i++)
    {
        int no= num[i]-'0';
        s+=no;
    }
     int n;
     n= atoi(num.c_str());

    if(n%s==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";



}













Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            queue.add(sc.nextInt());
        }
        PriorityQueue<Order> changes = new PriorityQueue<>();
        for (int i = 0; i < m; i++) {
            changes.add(new Order(sc.nextInt(), sc.nextInt()));
        }
        while (changes.size() > 0) {
            Order x = changes.poll();
            for (int i = 0; i < x.count && x.value > queue.peek(); i++) {
                queue.poll();
                queue.add(x.value);
            }
        }
        long total = 0;
        while (queue.size() > 0) {
            total += queue.poll();
        }
        System.out.println(total);
    }
    
    static class Order implements Comparable<Order> {
        int count;
        int value;
        
        public Order(int count, int value) {
            this.count = count;
            this.value = value;
        }
        
        public int compareTo(Order another) {
            return another.value - value;
        }
    }
}

Measured memory_bytes: 96300
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;
int dp[1000005][2];

int main(void){
  string s;
  cin >> s;
  reverse(ALL(s));
  s += '0';
  int n = s.size();
  REP(i, n+1) REP(j, 2) dp[i][j] = INF;
  dp[0][0] = 0;
  REP(i, n+1) REP(j, 2){
    int x = s[i] - '0';
    x += j;
    REP(a, 10){
      int ni = i+1, nj = 0;
      int b = a - x;
      if(b < 0){
        nj = 1;
        b += 10;
      }
      chmin(dp[ni][nj], dp[i][j]+a+b);
    }
  }
  cout << dp[n][0] << endl;
  return 0;
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

bool ismm(char a, char b) {
  if(a == '0') {
    if(b != '0')
      return true;
    else
      return false;
  } else if(a == '1') {
    if(b == '1' || b == '2')
      return true;
    else
      return false;
  } else
    return false;
}

int main() {
  string s;
  cin >> s;
  bool my = ismm(s[0], s[1]);
  bool ym = ismm(s[2], s[3]);
  string ans;
  if(my && ym)
    ans = "AMBIGUOUS";
  else if(my)
    ans = "MMYY";
  else if(ym)
    ans = "YYMM";
  else
    ans = "NA";
  cout << ans << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : HelloWorld.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
typedef long long ll;
using namespace std;
double A,B;
int main() {
	cin>>A>>B;

   if(A>B){
    	cout<<"GREATER"<<endl;
    }else if(A<B){
    	cout<<"LESS"<<endl;
    }else{
    	cout<<"EQUAL"<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

d = defaultdict(int)
ans = 0
n, m = map(int, input().split())
for _ in range(m):
    s, c = map(int, input().split())
    if (n != 1) & ((s == 1) & (c == 0)):
        ans = -1
        break
    if s not in d.keys():
        d[s] = c
    elif (d[s] != c):
        ans = -1
        break
if ans == 0:
    for i in range(1, n + 1):
        if ((i == 1) & (d[i] == 0)) & (n > 1):
            ans += 1 * (10 ** (n - i))
        else:
            ans += d[i] * (10 ** (n - i))
print(ans)

Measured memory_bytes: 3316
table = []

# 提出用のインプット
r, c = map(int, input().split())
for i in range(r):
    line = [int(i) for i in input().split()]
    line.append(sum(line))
    table.append(line)

# # 動作確認用のインプット
# with open(file='input_itp1_7_c_1.txt', mode='r', encoding='utf8') as input:
#     r, c = map(int, next(input).split())
#     for i in range(r):
#         line = [int(i) for i in next(input).split()]
#         line.append(sum(line))
#         table.append(line)

for i in range(r):
    print(' '.join(map(str, table[i])))
for j in range(c + 1):
    out = 0
    for i in range(r):
        out += table[i][j]
    if not j == c:
        print(out, end= ' ')
    else:
        print(out)


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

int main() {
   long long int n;
        int s=0;
        cin>>n;
        while (n>0){
            s=s+n%10;
            n=n/10;
          
        }
  
  if(s==1){cout<<10<<endl;}
  else{
        cout<<s<<endl;
  }
	return 0;
}


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

int main(){
int H,W;
while(1){
  cin >> H >> W;
 if(H==0 && W==0)
   break;
 REP(i,H){
   REP(j,W){
   if(i==0 || i==H-1){
   cout <<"#";
   }
   else{
    if(j==0 || j==W-1)
      cout <<"#";
    else
      cout <<".";
     }
   }
  cout << endl;
 }
 cout << endl;
}
}

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

int main()
{
    int N; cin >> N;
    int A[100005] = {};
    for (int n = 1; n <= N; n++)
    {
        cin >> A[n];
    }

    int cnt[100005] = {};
    for (int n = 1; n <= N; n++)
    {
        int An = A[n];
        cnt[An]++;
    }

    long ans = 1, mod = 1000000007;
    if (N % 2 == 1)
    {
        if (cnt[0] != 1) ans = 0;
        for (int i = 2; i <= N - 1; i += 2)
        {
            if (cnt[i] != 2) ans = 0;
            ans *= 2;
            ans %= mod;
        }
    }
    else // (N % 2 == 0)
    {
        for (int i = 1; i <= N - 1; i += 2)
        {
            if (cnt[i] != 2) ans = 0;
            ans *= 2;
            ans %= mod;
        }
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin>>n;
    vector<int> v(n-1),cnt(n,0);
    for(int &i:v)cin>>i,cnt[i-1]++;
    for(int i:cnt)cout<<i<<endl;
    
}

Measured memory_bytes: 4748
#include <iostream>
#include <vector>
#include <bitset>
using namespace std ;
using ll = long long ;

int main(){
	ll n ; cin >> n ;
	ll mod = 1e+9+7 ;
	vector<ll> a(n+1) ;
	vector<vector<ll>> zero(n+1,vector<ll>(64,0)),one(n+1,vector<ll>(64,0)) ;
	for(int i=1;i<=n;i++){
		cin >> a.at(i) ;
		bitset<64> bit(a.at(i)) ;
		for(int j=0;j<64;j++){
			one.at(i).at(j) = one.at(i-1).at(j)+bit[j] ;
			zero.at(i).at(j) = zero.at(i-1).at(j)+1-bit[j] ;
		}
	}
	ll ans = 0 ;
	for(int i=1;i<=n-1;i++){
//		cout << ans << endl ;
		ll two = 1 ;
		bitset<64> bit(a.at(i)) ;
		for(int j=0;j<64;j++){
			if(bit[j]) ans += (zero.at(n).at(j)-zero.at(i).at(j))*two%mod ;
			else ans += (one.at(n).at(j)-one.at(i).at(j))*two%mod ;
			two = two*2%mod ;
		}
		ans %= mod ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 326016
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vs s(h);
    rep(i, h) {
        cin >> s[i];
    }
    vvi sum(h, vi(w+1));
    rep(i, h){
        rep(j, w) {
            sum[i][j+1] = sum[i][j] + (s[i][j] == '1');
            
        }
    }
    vvi ssum(h+1, vi(w+1));
    rep(i, h) {
        rep(j, w+1) {
            ssum[i+1][j] = ssum[i][j] + sum[i][j];
        }
    }

    int ans = INF;
    int now, iti;
    rep(i, 1<<h-1) {
        int num = 1 + __builtin_popcount(i);
        vi cou;
        i += 1<<h-1;
        rep(j, h) {
            if((i>>j)&1) cou.emplace_back(j);
        }
        i -= 1<<h-1;
        now = 0;
        iti = 0;
        bool x = true;
        //cout << bitset<3>(i) << endl;
        //rep(j, num) cout << cou[j] << (j == num-1?'\n':' ');
        while(iti != w) {
            int a = iti, c = w+1;
            int b;
            while(c-a != 1) {
                b = (a+c)/2;
                bool bin = true;
                rep(i, num) {
                    int ss = 0;
                    ss += ssum[cou[i]+1][b] - ssum[cou[i]+1][iti];
                    if(i) ss -= ssum[cou[i-1]+1][b] - ssum[cou[i-1]+1][iti];
                    //if(i) cout << cou[i-1] << ' ' << cou[i] << ' ' << iti << ' ' << b << ' ' << ss << endl;
                    if(ss > k) {
                        bin = false;
                        break;
                    }
                }
                if(bin) {
                    a = b;
                } else {
                    c = b;
                }
            }
            //cout << a << endl;
            if(iti == a) {
                x = false;
                break;
            }
            iti = a;
            now++;
            //cout << iti << (iti == w ? '\n':' ');
        }
        //if(x) cout << now << ' ' << num << endl;
        //cout << endl;
        if(x) ans = min(ans, now-1 + num-1);
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
typedef long long ll;
int n,m;
int main() {
	scanf("%d%d",&n,&m);
	printf("%d\n",n * (n - 1) / 2 + m * (m - 1) / 2);
}

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

int SelectSort(int elem[], int num)
{
    int i, j;
    int cnt = 0;
    int min;

    for (i = 0; i < num; i++) {
        min = i;
        for (j = i+1; j < num; j++) {
            if (elem[min] > elem[j]) {
                min = j;
            }
        }
        if (min != i) {
            swap(elem[i], elem[min]);
            ++cnt;
        }
    }

    return cnt;
}

int main(void)
{
    int i;
    int num;
    int elem[100];
    int cnt;

    cin >> num;
    for (i = 0; i < num; i++) {
        cin >> elem[i];
    }

    cnt = SelectSort(elem, num);

    cout << elem[0];
    for (i = 1; i < num; i++) {
        cout << " ";
        cout << elem[i];
    }
    cout << endl;
    cout << cnt;
    cout << endl;

    return 0;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan=new Scanner (System.in);
        int a=scan.nextInt();
        int b=scan.nextInt();
        
        System.out.println((a*b)+" "+(a+b)*2);
    }
}


Measured memory_bytes: 26228
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, M);
  vvi s(M);

  rep(i, 0, M) {
    VAR(int, k);
    rep(j, 0, k) {
      VAR(int, ss);
      s[i].push_back(ss);
    }
  }
  VEC(int, p, M);

  ll ans = 0;
  rep(b, 0, 1 << N) {
    int c = 0;

    rep(i, 0, M) {
      int cc = 0;

      rep(j, 0, (int)s[i].size()) {
        if ((b >> (s[i][j] - 1)) & 1) {
          cc++;
        }
      }

      if (cc % 2 == p[i]) {
        c++;
      }
    }

    if (c == M) {
      ans++;
    }
  }

  print(ans);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n-k){
        if(a[i]>=a[k+i]) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3980
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
ans = a[0]
if a.include?(0)
  puts 0
  exit
end
1.upto(n-1) do |i|
  ans = ans * a[i]
  if ans > 10 ** 18
    puts -1
    exit
  end
end
puts ans

Measured memory_bytes: 23428
#include <bits/stdc++.h>
using namespace std;
#define N 3000005
#define MOD 1000000007 
int up=3e6,l1,r1,l2,r2,ans,fc[N],invF[N];
int inv(int x) {return x==1?1:1ll*inv(MOD%x)*(MOD-MOD/x)%MOD;}
int C(int x,int y) {return 1ll*fc[x]*invF[y]%MOD*invF[x-y]%MOD;}
int slv(int n,int m)
{
	int res=0;
	for(int i=1;i<=m;++i) res=(res+C(n+i+1,i+1))%MOD;return (res-m+MOD)%MOD;
}
int main()
{
	scanf("%d %d %d %d",&l1,&l2,&r1,&r2);--l1;--l2;
	fc[0]=invF[0]=1;for(int i=1;i<=up;++i) fc[i]=1ll*fc[i-1]*i%MOD;
	invF[up]=inv(fc[up]);for(int i=up-1;i>=1;--i) invF[i]=1ll*invF[i+1]*(i+1)%MOD;
	printf("%d\n",((slv(r1,r2)-slv(l1,r2)-slv(r1,l2)+slv(l1,l2))%MOD+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 23808
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

def primeFactor(N):  # return prime factors of N as dictionary {prime p:power of p}
    i,n=2,N
    ret={}
    d,sq=2,99
    while i<=sq:
        k=0
        while n%i==0:
            n,k,ret[i]=n//i,k+1,k+1
        if k>0 or i==97:
            sq=int(n**(1/2)+0.5)
        if i<4:
            i=i*2-1
        else:
            i,d=i+d,d^6
    if n>1:
        ret[n]=1
    return ret

def PrimeNumSet(N):  # return the list of prime numbers in [2,N], using eratosthenes sieve
    Max = int(N**0.5)
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList:
        if seachList[0] <= Max:
            break
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

def LCM(b,mo=10**9+7):  # retrun LCM of numbers in list b
    prs=PrimeNumSet(max(b))
    M=dict(zip(prs,[0]*len(prs)))
    for i in b:
        dc=primeFactor(i)
        for j,k in dc.items():
            M[j]=max(M[j],k)
    
    r=1
    for j,k in M.items():
        if k!=0:
            r*=pow(j,k,mo)
            r%=mo
    return r

show_flg=False
show_flg=True


ans=0

n=I()
a=LI()

m=LCM(a)

x=0
for i in a:
    x+=m*pow(i,mo-2,mo)
    x%=mo

print(x)


Measured memory_bytes: 180804
N, M = map(int, input().split())
S = [[0, 0] for _ in range(M)]
for i in range(M):
    S[i][0],S[i][1] = map(int, input().split())
    
num = sorted(S, key=lambda x:x[0])

if(M>0):
    if(num[0][0] == 1 and num[0][1] == 0):
        print(0 if N==1 else -1)
    else:
        ans = (10**(N-num[0][0]))*num[0][1]
        for i in range(1, len(num)):
            if(num[i][0] == num[i-1][0]):
                if(num[i][1] != num[i-1][1]):
                    ans = -1
                    print(ans)
                    quit()
                continue
            ans += (10**(N-num[i][0]))*num[i][1]
        if(len(str(ans)) == N):
            print(ans)
        else:
            print(ans+10**(N-1))
else:
    if(N > 1):
        print(10**(N-1))
    else:
        print(0)

Measured memory_bytes: 3064
n = int(input())
seq=[]
for i in range(n):
    seq.append(int(input()))

import bisect

Lis = [seq[0]]
for i in range(1,n):
    if seq[i] > Lis[-1]:
        Lis.append(seq[i])
    else:
        Lis[bisect.bisect_left(Lis,seq[i])] = seq[i]

print(len(Lis))
        


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

int main() {
  long double a,b,x,n,t,T,N;
  cin>>a>>b>>x;
  n=2*(a*a*b-x)/a/a;
  t= atan(n/a)*180/3.1415926535898;
  N=2*x/a/b;
  T=atan(b/N)*180/3.1415926535898;
  if(x>a*a*b/2){
  cout<<fixed<<setprecision(10)<<t;
  }
  else{
    cout<<fixed<<setprecision(10)<<T;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    while(a[0] != a[1] || a[1] != a[2]){
        sort(a.begin(), a.end());
        if(a[0] == a[1]){
            ++a[0];
            ++a[1];
        }
        else{
            a[0] += 2;
        }
        ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  int a = s.size();
  int b = t.size();
  vector<string> S(a);
  vector<string> T(b);
  rep(i,a) S[i] = s[i];
  rep(i,b) T[i] = t[i];
  sort(S.begin(),S.end());
  sort(T.rbegin(),T.rend());
  if(S<T) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256