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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    int a, b, q , w;
    cin >> a >> b;
    double x, y;
    for (int i = 0; i <= 1250; i++) {
        x = i * 1.0 * 0.08;
        y = i * 1.0 * 0.1;
        q = floor(x);
        w = floor(y);
        if (q == a && w == b) {
            printf("%d\n", i);
            return;
        }
    }
    puts("-1");
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	double x[100];
	char u[100];
	
	int i=0;
	double sum=0;
	
	while(i<n){
		scanf("%lf %c%c%c",&(x[i]),&(u[i*3]),&(u[i*3+1]),&(u[i*3+2]));
		
		if(u[i*3]=='J'){
			sum=sum+x[i];
		}else{
			sum=sum+(x[i]*380000);
		}
		
		i++;
		
	}
	
	printf("%f\n",sum);
	
	return 0;
}
		

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int nowti = 0;
		int[] x = new int[n+1];
		int[] y = new int[n+1];
		for(int i = 1;i <= n;i++){
			int t = saori.saori_hayami();
			x[i] = saori.saori_hayami();
			y[i] = saori.saori_hayami();
			int move = Math.abs(x[i] - x[i-1]) + Math.abs(y[i] - y[i-1]);
			int dt = t - nowti;
			if(move > dt || dt%2 != move % 2){
				System.out.println("No");
				return;
			}
			nowti = t;
		}
		System.out.println("Yes");
		 
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23252
package main

import (
	"fmt"
)

func main() {
	var total, sum, n, a, b int
	fmt.Scan(&n, &a, &b)

	for i := 1; i <= n; i++ {
		sum = 0
		for e := i; e > 0; e /= 10 {
			sum += e % 10
		}
		if sum >= a && sum <= b {
			total += i
		}
	}

	fmt.Println(total)
}

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

using namespace std;

const int N = 100;

int num[N];

void swap(int &a, int &b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int bubbleSort(int num[], int n) {//???????????? 
	int cnt = 0; //?????蔵?測???属 
	for (int i=0; i<n; ++i) {
		for (int j=n-1; j>i; --j) {
			if (num[j-1] > num[j]) {
				++cnt;
				swap(num[j-1], num[j]);
			}
		}
	}
	return cnt; 
}

int main() {
	int n;
	while (scanf("%d", &n) != EOF) {
		for (int i=0; i<n; ++i) scanf ("%d", &num[i]);
		int cnt = bubbleSort(num, n);
		for (int i=0; i<n; ++i) {
			if (i) putchar(' ');
			printf ("%d", num[i]);
		}
		printf ("\n%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
// https://www.irohabook.com/exp-2
// 1e9（10桁） は 2^26乗～2^27乗 であり、int(正負の2^16乗まで)では不可

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int D, T, S;

int main()
{
	cin >> D >> T >> S;

	cout << (S * T >= D ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;
char a;

int main(){
	IOS
	cin >> a;
	if(a<97){
		cout << 'A' << '\n';
	}
	else{
		cout << 'a' << '\n';
	}
}


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

int main(void) {
  string S;
  cin >> S;
  vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  cout << 7 - (find(days.begin(), days.end(), S) - days.begin()) << endl;
  return 0;
}

Measured memory_bytes: 256
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
int main() 
{ 
	turbo();
	ll s,n,m,ans=0;
	cin>>n>>m;
	ans=min(n*2,m-m%2)/2;
	m-=ans*2;
	ans+=(m/4);
	cout<<ans<<"\n";
    return 0; 
} 

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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int n,d;
	int ans=0;
	double tmp;
	
	cin >> n >> d;
	
	int x[n][d];
	
	for(int i=0; i<n; i++){
		for(int j=0; j<d; j++){
			cin >> x[i][j];
		}
	}
	
	
	for(int i=0; i<n-1; i++){
		for(int j=i+1; j<n; j++){
			tmp=0;
			
			for(int k=0; k<d; k++){
				tmp+=pow((x[i][k]-x[j][k]),2);
			}
			
			tmp=pow(tmp,0.5);
			
			if(ceil(tmp)==floor(tmp))	ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		var k=s.nextLong();
		var a=new int[n];
		var b=new long[n];
		Arrays.setAll(a,i->s.nextInt()-1);

		var i=0;
		for(int t=1;k >= 0;--k,++t,i=a[i]){
			if(b[i]>0)
				k%=t-b[i];
			b[i]=t;

			if(k==0L){
				System.out.println(i+1);
				return;
			}
		}
	}
}


Measured memory_bytes: 61568
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
use std::cmp::*;
//use std::num;

fn main() {
    input! {
        n:u64
    }
    // root n 以下の約数の列aを求める。
    // 各a[i]について、Fを計算する。
    // …しても良いけど、n以下で最大になるxを求めれば良いはず。
    // というか
    let mut ans = 10;
    let r: u64 = (n as f64).sqrt() as u64 + 1;
    for i in (1..(r + 1)).rev() {
        if n % i == 0 {
            ans = min(ans, max(getKeta(i), getKeta(n / i)));
        }
    }
    println!("{}", ans);
}
fn getKeta(i: u64) -> u64 {
    if i < 10 {
        1
    } else {
        getKeta(i / 10) + 1
    }
}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N,K;
	cin >> N >> K;
	VLL A(N);
	VLL check(N, -1);
	check[0] = 0;
	VLL back(N, 0);
	for (LL n = 0; n < N; n++) {
		cin >> A[n];
		A[n]--;
		back[A[n]] = n;
	}
	LL cur = A[0];
	LL prev = 0;
	while (check[cur] == -1) {
		check[cur] = check[prev] + 1;
		prev = cur;
		cur = A[cur];
	}
	if (check[cur] >= K) {
		for (LL n = 0; n < N; n++) {
			if (check[n] == K) {
				cout << n + 1 << "\n";
				return 0;
			}
		}
	}
	else {
		LL D = check[prev] - check[cur] + 1;
		LL old = check[cur];
		K -= old;
		for (LL n = 0; n < N; n++) {
			check[n] -= old;
			if (check[n] >= 0) {
				if (check[n] == K % D) {
					cout << n + 1 << "\n";
					return 0;
				}
			}
		}

	}
	return 0;
}

Measured memory_bytes: 7672
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  set<int> s;
  s.insert(a); s.insert(b); s.insert(c);
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int x;
    cin >> x;

    int ans = 0;
    ans += x / 11 * 2;
    int cur = x / 11 * 11;
    if (cur < x) {
        cur += 6;
        ans++;
        if (cur < x) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

int n, l, q, a, b, s, x[N], d[25][N];
int main()
{
	int i, j;
	cin >> n;
	for (i = 1; i <= n; i++) scanf("%d", &x[i]);
	cin >> l;
	for (i = 1; i < n; i++) d[0][i] = upper_bound(x + 1, x + n + 1, x[i] + l) - x - 1;
	for (i = 1; i < 17; i++) for (j = 1; j <= n; j++) d[i][j] = d[i - 1][d[i - 1][j]];
	cin >> q;
	while (q--) {
		s = 0;
		scanf("%d %d", &a, &b);
		if (a > b) swap(a, b);
		for (i = 17; i >= 0; i--) {
			if (d[i][a] == 0) continue;
			if (d[i][a] < b) a = d[i][a], s += 1 << i;
			else if (d[i][a] == b) {i--; break;}
		}
		s += 1 << (i + 1);
		printf("%d\n", s);
	}
    return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int a, b, m, ans = 0;
    cin >> a >> b >> m;
    vector<int> d(a), e(b);
    for(int i = 0; i < a; i++){
        cin >> d[i];
    }
    for(int i = 0; i < b; i++){
        cin >> e[i];
    }
    ans = *min_element(begin(d), end(d)) + *min_element(begin(e), end(e));
    for(int i = 0; i < m; i++){
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans, d[x] + e[y] - c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if(map.containsKey(a)) {
        map.put(a, map.get(a) + 1);
      } else {
        map.put(a, 1);
      }
    }
    int ans = 0;
    for(int key : map.keySet()) {
      if((map.get(key) % 2) == 1) ans++;
    }
    System.out.println(ans);
  }
}

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

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  
  set<int> S;
  
  S.insert(a);
  S.insert(b);
  S.insert(c);
  
  cout << S.size() << endl;  
  
return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
//#define int long long
int32_t main(){
    
    string s;
    cin >> s;
    int sum = 0;
    for(auto &c : s){
    	sum += c-'0';
    }
    if(sum%9 == 0){
    	cout << "Yes\n";
    } else {
    	cout << "No\n";
    }
}


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

struct card
{
	int size;
	int noFrom;
	int noTo;
};

vector<card> cardList;
bool cmp(const card& a, const card& b)
{
	return a.size < b.size;
}

int main()
{
	// N - card数、M - gate数
	int N, M;
	cin >> N >> M;

	cardList.resize(M);
	card c;
	for (int i = 0; i < M; i++)
	{
		int L, R;
		cin >> L;
		cin >> R;
			
		c.size = R - L;
		c.noFrom = L;
		c.noTo = R;

		cardList[i] = c;
	}

	sort(cardList.begin(), cardList.end(), cmp);

	int noFrom, noTo;
	noFrom = cardList[0].noFrom;
	noTo = cardList[0].noTo;

	for (int i = 1; i < M; i++)
	{
		if (cardList[i].noFrom > noFrom)
		{
			noFrom = cardList[i].noFrom;
		}

		if (cardList[i].noTo < noTo)
		{
			noTo = cardList[i].noTo;
		}
	}

	if (noTo < noFrom)
	{
		cout << 0 << endl;
		return 0;
	}

	cout << noTo - noFrom + 1 << endl;

	return 0;
}

Measured memory_bytes: 1408
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += B_list[i] if A_list[i]-B_list[i]>=0 else A_list[i]
    tmp = min(B_list[i], A_list[i])
    B_list[i]-= tmp
    A_list[i]-= tmp
    if B_list[i]>0:
        ans += B_list[i] if A_list[i+1]-B_list[i]>=0 else A_list[i+1]
        A_list[i+1]-= min(B_list[i], A_list[i+1])
print(ans)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[7]={1,3,5,7,8,10,12};
    int b[4]={4,6,9,11};
    int c[1]={2};

    int x,y;
    cin>>x>>y;
    int f=0,d=0,e=0;
    for(int i=0;i<7;i++){
        if(x==a[i])f++;
        if(y==a[i])f++;
    }
    for(int i=0;i<4;i++){
        if(x==b[i])d++;
        if(y==b[i])d++;
    }
    if(x==c[0]||y==c[0])e++;
    if(f==2||d==2)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var opes string
	fmt.Scan(&opes)

	num := 0
	for i := 0; i < len(opes); i++ {
		if opes[i:i+1] == "+" {
			num++
		} else {
			num--
		}
	}

	fmt.Println(num)
	return
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int k = sc.nextInt();

        long[] dp = new long[n + k];
        int[] h = new int[n + k];

        long INF = Long.MAX_VALUE;

        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        sc.close();

        for (int i = 0; i < n + k; i++) {
            dp[i] = INF;
        }

        dp[0] = 0;

        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= k; j++) {
                dp[i + j] = Math.min(dp[i + j], dp[i] + Math.abs(h[i] - h[i + j]));
            }
        }
        System.out.println(dp[n - 1]);
    }

}

Measured memory_bytes: 63848
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long D = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < N; i++)
			if(Math.pow(sc.nextInt(), 2) + Math.pow(sc.nextInt(), 2) <= D * D)
				ans++;
		System.out.println(ans);
	}

}

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

typedef long long ll;

string T;
int main() {
  cin >> T;
  for (ll i = 0; i < T.size(); ++i) {
    if (T[i] == '?') T[i] = 'D';
  }
  cout << T << endl;
  return 0;
}


Measured memory_bytes: 3720
#include <stdio.h>
#include <math.h>

int main(){
  int a, b, d, r;
  double f;
  scanf("%d %d", &a, &b);

  d = a / b;
  r = a % b;
  f = ((double) a) / b;

  printf("%d %d %f\n",d, r, f);



  return 0;
}



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

now = [0, 0]
for i in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x - now[0]) + abs(y - now[1])
    if dist <= t and (t - dist) % 2 == 0:
        continue
    print('No')
    quit()
 
print('Yes')

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

const int MOD = 1e9 + 7; int f[1000003] , N;

int main(){
	cin >> N; f[0] = f[1] = 1; int sum = 2 , ans = 0;
	for(int i = 2 ; i <= N - 1 ; ++i){f[i] = (sum - f[i - 2] + MOD) % MOD; sum = (sum + f[i]) % MOD;}
	ans = 1ll * f[N - 1] * N % MOD;
	for(int i = N - 2 ; ~i ; --i) ans = (ans + 1ll * f[i] * (1ll * (N - 1) * (N - 1) % MOD + min(N - 1 , i + 2))) % MOD;
	cout << ans; return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int sum = 0;
  rep(i, s.size()) {
    sum += s[i]-'0';
    sum %= 9;
  }
  if (sum)
    cout << "No\n";
  else
    cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>
#include <math.h>

int main(void){
	int a,b;
	scanf("%d %d", &a,&b);
	if(a+b==15){
		printf("+\n");
	}else if(a*b==15){
		printf("*\n");
	}else{
		printf("x\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;

struct node
{
    int key;
    node *parent,*left,*right;
    node():key(-1),parent(NULL),left(NULL),right(NULL) {}
};
node *root,*nil;

node* newnode()
{
    return new node();
}

void insert(int num)
{
    node* x=root;
    node* y=nil;
    node* z=newnode();
    z->key=num;
    while(x!=nil)
    {
        y=x;
        if(num>=x->key)
            x=x->right;
        else
            x=x->left;
    }
    if(y==nil) root=z;
    else
    {
        z->parent=y;
        if(num<y->key)
            y->left=z;
        else
            y->right=z;
    }
}

node* find(node* u,int num)
{
    while(u!=nil&&num!=u->key)
    {
        if(num< u->key) u=u->left;
        else u=u->right;
    }
    return u;
}

node* minele(node* u)
{
    while(u->left!=nil)
        u=u->left;
    return u;
}

node* nextpos(node* u)
{
//	node* y=nil;
//	if(u->right!=nil) y=minele(u->right);
//	else 														//?¬¬????????\???????????????????????°?????¶???????°±???u??????????????????
//	{
//		y=u->parent;
//		while(y!=nil&&y->right==u)
//		{
//			u=y;
//			y=y->parent;
//		}
//	}
//	return y;
    return minele(u->right);
}

void Delete(node* u)
{
    node* y;
    node* x;
    if(u->left==nil||u->right==nil) y=u;
    else y=nextpos(u);
    if(y->left!=nil) x=y->left;
    else x=y->right;

    if(x!=nil) x->parent=y->parent;

    if(y->parent==nil) root=x;
    else
    {
        if(y==y->parent->left) y->parent->left=x;
        else y->parent->right=x;
    }
    if(y!=u)
        u->key=y->key;
    delete y;
}

void inorder(node* u)
{
    if(u->left!=nil) inorder(u->left);
    printf(" %d",u->key);
    if(u->right!=nil) inorder(u->right);
    return;
}

void preorder(node* u)
{
    printf(" %d",u->key);
    if(u->left!=nil) preorder(u->left);
    if(u->right!=nil) preorder(u->right);
    return;
}

int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        char s[11];
        scanf("%s",s);
        if(s[0]=='i')
        {
            int x;
            scanf("%d",&x);
            insert(x);
        }
        else if(s[0]=='f')
        {
            int x;
            scanf("%d",&x);
            node* u=(find(root,x));
            if(u!=nil)
                printf("yes\n");
            else
                printf("no\n");
        }
        else if(s[0]=='d')
        {
            int x;
            scanf("%d",&x);
            Delete(find(root,x));
        }
        else if(s[0]=='p')
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 21840
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;

     signed main(){
     int h,w,m;
     cin>>h>>w>>m;
     int x[m],y[m];
     pair<int,int>p[h],q[w];
     for(int i=0;i<h;i++)p[i]={0,i};
     for(int i=0;i<w;i++)q[i]={0,i};
     for(int i=0;i<m;i++){
         cin>>x[i]>>y[i];x[i]--;y[i]--;
         p[x[i]].first++;
         q[y[i]].first++;
     }
     sort(p,p+h);sort(q,q+w);

    int a=0,b=0;
    for(int i=h-1;i>=0&&p[i].first==p[h-1].first;i--){a++;}
    for(int i=w-1;i>=0&&q[i].first==q[w-1].first;i--)b++;
    if(a*b>m){
        cout<<p[h-1].first+q[w-1].first<<endl;
        return 0;
    }
 
    set<pair<int,int>> st;
    for(int i=0;i<a;i++)for(int j=0;j<b;j++){st.insert({p[h-1-i].second,q[w-1-j].second});}


    for(int i=0;i<m;i++)st.erase({x[i],y[i]});
    if(st.empty())cout<<p[h-1].first+q[w-1].first-1<<endl;
    else cout<<p[h-1].first+q[w-1].first<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 36428
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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; }

int inf=1E9;

int main(){
    int h,w,k,mn=inf;
    cin >> h >> w >> k;
    vector<string> v(h);
    rep(i,h) cin >> v[i];

    for(int i=0, mx=(0x1 << (h-1)); i<mx; ++i){
        int cut=0, tmp=0;
        vector<string> vs;
        vs.push_back(v[0]);
        for(int j=0; j<h-1; ++j){
            if(i&(0x1<<j)){
                ++cut; ++tmp;
                vs.push_back(v[1+j]);
            }
            else{
                rep(k,w){
                    vs[tmp][k] += v[1+j][k] - '0';
                }
            }
        }

        vector<int> sum(vs.size());
        rep(j,w){
            for(int i=0, sz=vs.size(); i<sz; ++i){
                if(vs[i][j]-'0' > k){
                    cut = inf;
                    break;
                }
                sum[i] += vs[i][j] - '0';
                if(sum[i] > k) {
                    ++cut; --j;
                    vector<int> a(vs.size());
                    sum.swap(a);
                    break;
                }
            }
        }
        chmin(mn,cut);
    }
    cout << mn << endl;

    return 0;
}


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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define REPR(i,n) for (int i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORE(x,xs) for (auto& x : xs)
#define MP make_pair
#define POSSIBLE "POSSIBLE"
#define IMPOSSIBLE "IMPOSSIBLE"

const int MAX = 1010;
const int MAX_X = 5050;
int N;
vi child[MAX];
int X[MAX];
bool dp[MAX_X][2];

ii dfs(int n) {
    int xn = X[n];
    if (child[n].size() == 0) return MP(0, xn);

    int S = 0;
    vii temps;
    FORE (v, child[n]) temps.push_back(dfs(v));

    REP (i, MAX_X) dp[i][0] = false;
    dp[0][0] = true;
    FORE (temp, temps) {
        int a = temp.first, b = temp.second;
        S += a + b;

        REP (i, MAX_X) dp[i][1] = false;
        REPR (i, xn+1) if (dp[i][0]) {
            if (i+a <= xn) dp[i+a][1] = true;
            if (i+b <= xn) dp[i+b][1] = true;
        }
        REP (i, MAX_X) dp[i][0] = dp[i][1];
    }

    int value = -1;
    REP (i, xn+1) if (dp[i][0]) value = i;

    if (value == -1) {
        cout << IMPOSSIBLE << endl;
        exit(0);
    }
    return MP(xn, S-value);
}

int main () {
    cin >> N;
    FOR (i, 2, N+1) {
        int p;
        cin >> p;
        child[p].push_back(i);
    }
    FOR (i, 1, N+1) cin >> X[i];

    dfs(1);
    cout << POSSIBLE << endl;
}

Measured memory_bytes: 384
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;
const int maxn = 1E5 + 5;

bitset<maxn> isPrime;
vector<int> valid(maxn, 0), prefix(maxn, 0);

void precal() {
    isPrime.set();
    isPrime[0] = isPrime[1] = 0;
    for (int i = 2; i < maxn; ++i) {
        if (isPrime[i]) {
            for (int j = i*i; j < maxn; j += i) isPrime[j] = 0;
        }
    }
    
    for (int i = 1; i < maxn; ++i) valid[i] = isPrime[i] & isPrime[(i + 1) / 2];
    for (int i = 1; i < maxn; ++i) prefix[i] = prefix[i - 1] + valid[i];
}

int32_t main() {
    fastIO();
    precal();
    
    int q, l, r;
    cin >> q;
    
    while (q--) {
        cin >> l >> r;
        cout << prefix[r] - prefix[l - 1] << "\n";
    }
    
    return 0;
}

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

long long solve(int L, int R){

    long long min_mod = 2018;
    long long mod;

    for(long long i = L; i < R; i++){
        for(long long j = i + 1; j <= R; j++){

            mod = (i*j)%2019;

            //cout << "i = " << i << " j = " << j << " mod = " << mod << endl;

            if(mod < min_mod){
                min_mod = mod;
            }
        }
    }

    return min_mod;
}

int main(){

    long long L,R;
    cin >> L;
    cin >> R;

    long long ans;

    if(L%2019 == 0 || L/2019 != R/2019){
        ans  = 0;
    }else{
        ans = solve(L,R);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int ok=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length();++i)
		if(s[i]=='9') ok=1;
	ok?cout<<"Yes"<<endl:cout<<"No"<<endl;  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

void dfs1(int n, mat &G, vec &ord){
    int k(0);
    vector<int> iter(n, -1);
    stack<int> sta;
    rep(i, n) {
        if(iter[i] < 0) sta.push(i);
        while (!sta.empty()) {
            int v = sta.top();
            if ((++iter[v]) == G[v].size()) {
                ord[k++] = v;
                sta.pop();
            } else {
                int to = G[v][iter[v]];
                if(iter[to] < 0) sta.push(to);
            }
        }
    }
}
void dfs2(int n, mat &G, vec &ord, mat &res){
    int k(0);
    vector<bool> used(n, false);
    stack<int> sta;
    Rrep(i, n){
        int s = ord[i];
        if(!used[s]){
            used[s] = true;
            sta.push(s);
            while(!sta.empty()){
                int v = sta.top(); sta.pop();
                res[k].push_back(v);
                for(int to : G[v]) {
                    if(!used[to]) {
                        used[to] = true;
                        sta.push(to);
                    }
                }
            }
            ++k;
        }
    }
    res.resize(k);
}

void scc(mat &G, mat &res){
    int n = G.size();
    mat G_rev(n, vec(0));
    rep(u, n) for(int v : G[u]) G_rev[v].push_back(u);
    vec ord(n);
    dfs1(n, G, ord);
    dfs2(n, G_rev, ord, res);
}

void input(mat &G){
    rep(i,M){
        int a, b;
        scanf("%d%d", &a, &b);
        G[a].push_back(b);
    }
}

void output(mat &scc_list){
    printf("%d\n", (int)scc_list.size());
    for(vec v : scc_list){
        int n = v.size();
        printf("%d ", n);
        rep(i, n) printf("%lld%c", v[i], " \n"[i == n - 1]);
    }
}
int main() {
    cin >> N >> M;
    mat G(N, vec(0)), scc_list(N, vec(0));
    input(G);
    scc(G, scc_list);
    output(scc_list);
}



Measured memory_bytes: 79204
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

const long long PRIME = 1000000007;
const double mpi = 3.14159265358979323846;

using namespace std;

struct segtree {
    int N, dat[800001];
    segtree() {}
    segtree(int n) {
        N = 1;
        while(N < n) N *= 2;
        for(int i = 0; i < 2*N-1; i++)
            dat[i] = 0;
    }
    // update k th element
    void update(int k, int a) {
        k += N-1; // leaf
        dat[k] = a;
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a, int b) { return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return 0;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

class Tate {
public:
  long long x, y;
  Tate(long long _, long long __) {
    x = _;
    y = __;
  }
  bool operator<(const Tate &rhs) const {
    return this->x < rhs.x;
  }
  bool operator>(const Tate &rhs) const {
    return this->x > rhs.x;
  }
};

class Yoko {
public:
  int i;
  long long x, y;
  Yoko(long long _, long long __, int id) {
    x = _;
    y = __;
    i = id;
  }
  bool operator<(const Yoko &rhs) const {
    return this->y < rhs.y;
  }
  bool operator>(const Yoko &rhs) const {
    return this->y > rhs.y;
  }
};

int main() {
  pair<long long, long long> s, e;
  cin >> s.first >> s.second >> e.first >> e.second;
  int n;
  cin >> n;
  vector<pair<long long, long long>> p(n);
  for(int i = 0; i < n; i++) cin >> p[i].first >> p[i].second;
  if(s.first > e.first) {
    s.first = -s.first;
    e.first = -e.first;
    for(int i = 0; i < n; i++) p[i].first = -p[i].first;
  }
  if(s.second > e.second) {
    s.second = -s.second;
    e.second = -e.second;
    for(int i = 0; i < n; i++) p[i].second = -p[i].second;
  }
  vector<pair<long long, long long>> fp;
  for(int i = 0; i < n; i++) {
    if(s.first <= p[i].first && p[i].first <= e.first && s.second <= p[i].second && p[i].second <= e.second ) {
      fp.push_back(p[i]);
    }
  }
  int m = fp.size();
  vector<Tate> t;
  for(int i = 0; i < m; i++) {
    t.push_back(Tate(fp[i].first, fp[i].second));
  }
  sort(t.begin(), t.end());
  vector<Yoko> y;
  for(int i = 0; i < m; i++) {
    y.push_back(Yoko(t[i].x, t[i].y, i));
  }
  sort(y.begin(), y.end());
  segtree seg(m);
  for(int i = 0; i < m; i++) {
    int mi = seg.query(0, y[i].i);
    seg.update(y[i].i, mi - 1);
  }
  int cnt = -seg.query(0, m);
  double ans = (e.first - s.first + e.second - s.second) * 100;
  if(cnt - 1 == min(e.first - s.first, e.second - s.second)) {
    ans -= 20 * cnt;
    ans += 10 * mpi;
    ans += 5 * mpi * (cnt - 1);
  } else {
    ans -= 20 * cnt;
    ans += 5 * mpi * cnt;
  }
  printf("%.15lf\n", ans);

  return 0;
}


Measured memory_bytes: 22508
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    cin >> n >> x;
    if(x == 1 || x == 2*n-1){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    if(n == 2){
        rep(i,3){
            cout << i+1 << "\n";
        }
    }else{
        if(x == 2*n-2){
            vector<int> vec;
            vector<int> v(4);
            srep(i,1,2*n){
                if(i != x-2 && (abs(i-x) > 1)){
                    vec.pb(i);
                }
            }
            v[0] = x-1,v[1] = x,v[2] = x+1,v[3] = x-2;
            int id = 0;
            int id2 = 0;
            rep(i,2*n-1){
                if(n-2 <= i && i <= n+1){
                    cout << v[id2++] << "\n";
                }else{
                    cout << vec[id++] << "\n";
                }
            }
        }else{
            vector<int> vec;
            vector<int> v(4);
            srep(i,1,2*n){
                if(i != x+2 && (abs(i-x) > 1)){
                    vec.pb(i);
                }
            }
            v[0] = x+1,v[1] = x,v[2] = x-1,v[3] = x+2;
            int id = 0;
            int id2 = 0;
            rep(i,2*n-1){
                if(n-2 <= i && i <= n+1){
                    cout << v[id2++] << "\n";
                }else{
                    cout << vec[id++] << "\n";
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
using ll=long long;

using namespace std;
using P=pair<int,int>;
int main(){
    ll n;
    cin>>n;
    map<int,int> m;
    int s=sqrt(n);
    for(int i=2;i<=s;i++){
        if(n%i==0){
            n/=i;
            m[i]++;
            i--;
        }
    }
    if(n!=1)m[n]++;
    int ret=0;
    for(P x:m){
        int t=sqrt(x.second*2);
        if(t*(t+1)<=x.second*2)ret+=t;
        else ret+=t-1;
    }
    cout<<ret<<endl;
}



Measured memory_bytes: 3724
//https://atcoder.jp/contests/abc137/tasks/abc137_f
#include<bits/stdc++.h>

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};

const int INF = 1000000007;

const int MAXP = 3002;
int N, P, res[MAXP];
int coeff[MAXP][MAXP]; //[i][j] gives coefficient for x^j when multiplying x(x-1)...(x-i)

int main()
{
    cin >> P;
    //precompute x(x-1)(x-2)...(x-p+1)
    coeff[0][1] = 1;
    for(int i=1; i<P; i++)
    {
        for(int j=0; j<=P; j++)
        {
            if(!j)
            {
                coeff[i][j] = (coeff[i-1][j]*(P-i)%P);
            }
            else
            {
                coeff[i][j] = ((coeff[i-1][j]*(P-i)%P)+coeff[i-1][j-1])%P;
            }
        }
    }

//    for(int i=0; i<=P; i++)
//    {
//        cout << coeff[P-1][i] << " ";
//    }

    for(int i=0; i<P; i++)
    {
        int val;
        cin >> val;
        if(val == 1)
        {
            int add = 0;
            for(int j=P; j>=0; j--)
            {
                add = (add * i + coeff[P-1][j])%P;
                if(j)
                {
                    res[j-1] = (res[j-1] + (P-1)*add)%P;
                }
            }
        }
    }

    for(int i=0; i<P-1; i++)
    {
        cout << res[i] << " ";
    }
    cout << res[P-1] << "\n";
    return 0;
}


Measured memory_bytes: 35456
let () =
  Scanf.scanf "%1s%1s%1s" (fun a b c ->
      let rec calc li o =
        match li with
        | [] -> o
        | x :: xs when x = "o" -> calc xs (o + 1)
        | x :: xs -> calc xs o
      in
      (calc [a; b; c] 0 * 100) + 700 |> Printf.printf "%d\n" )


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LL long long
#define dob complex<double>
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
const int l1 = 10000000;
const int l2 = 25500000;
const int yzh = 1e9+7;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void print(int x) {if (x > 9) print(x/10); putchar(x%10+48); }
void write(int x) {if (x < 0) putchar('-'); print(Abs(x)); }

int s, f[l2+5];

int quick_pow(int a, int b) {
    int ans = 1;
    while (b) {
    if (b&1) ans = 1ll*ans*a%yzh;
    a = 1ll*a*a%yzh, b >>= 1;
    }
    return ans;
}
int count1(int n) {
    int ans = 0, r = 0, cnt = 0;
    for (int i = 1; i < l1; i++) {
    cnt -= f[i-1];
    while (cnt+f[r+1] <= s && r < l2) cnt += f[++r];
    if (cnt == s) ++ans;
    if (r == l2) break;
    }
    return ans;
}
int count2(int n) {
    int lim = n/8, ans = lim;
    for (int t = 1; t <= lim; t++)
    if (n%t == 0) {
        int len = n/t;
        (ans += (1ll*quick_pow(10, len-1)*9%yzh-t)%yzh) %= yzh;
    }
    return ans;
}
void work() {
    for (int i = 1, r = 10, cnt = 1; i < l1; i++, i = r, r = r*10, cnt++)
    for (int j = i; j < r; j++) f[j] = cnt;
    for (int i = l1; i <= l2; i++) f[i] = 8;
    read(s);
    writeln(((count1(s)+count2(s))%yzh+yzh)%yzh);
}
int main() {
    work();
    return 0;
}


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

int main() {
  string A, B;
  cin >> A >> B;
  if (A.size()>B.size()) cout << "GREATER" << endl;
  else if(A.size()<B.size()) cout << "LESS" << endl;
  else if(A.size()==B.size()){
    rep(i, A.size()){
      int x = A.at(i)-'0';
      int y = B.at(i)-'0';
      if (x>y){
        cout << "GREATER" << endl;
        break;
      }
      else if (x<y){
        cout << "LESS" << endl;
        break;
      }
      else if (x==y && i==A.size()-1){
        cout << "EQUAL" << endl;
        break;
      }
    }
  }
 }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int house[5][4][11];

int main( void ) {
    int n, b, f, r, v;
    cin >> n;
    for( int i = 0; i < n; ++i ) {
        cin >> b >> f >> r >> v;
        house[b][f][r] += v;
    }
    for( int i = 1; i <= 4; ++i ) {
        if( i > 1 ) {
            for( int j = 0; j < 20; ++j ) cout << '#';
            cout << '\n';
        }
        for( int j = 1; j <= 3; ++j ) {
            for( int k = 1; k <= 10; ++k ) {
                cout << ' ' << house[i][j][k];
            }
            cout << '\n';
        }
    }
    return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int  MAXN = 15000; //本机运行时修改数值 
const int IFNTY = 1 << 20;


void show(pair<int, int> p);
void dijkstra(vector< pair<int, int> > adj_list[], int n, int u, int dis[]);

int main()
{

	vector< pair<int,int> > adj_list[MAXN];
	
	int n;
	cin >> n;
	
	int u, k, v, c;;	
	for (int i = 0; i < n; i++)
	{
		cin >> u >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> v >> c;
			adj_list[u].push_back(make_pair(v,c));
		}		
	}
	
//	for (int i = 0; i < n; i++)
//	{
//		cout << i << "   ";
//		for_each (adj_list[i].begin(), adj_list[i].end(), show);
//		cout << endl;
//	}

	
	int dis[MAXN];
	
	dijkstra(adj_list, n, 0, dis);
	
	for (int i = 0; i < n; i++)
	{
		cout << i << ' ' << dis[i] << endl;
	}

}


void show(pair<int, int> p)
{
	cout << p.first << ' ' << p.second << ' ';
}


void dijkstra(vector< pair<int, int> > adj_list[], int n, int u, int dis[])
{
	int visited[MAXN] = {0};
	priority_queue< pair<int, int> > pri_queue;
	
	for (int v = 0; v < n; v++)
 		dis[v] = IFNTY;
 		
	dis[u] = 0;
	pri_queue.push(pair<int, int>(0, u));
	
	while (!pri_queue.empty())
	{
		pair<int, int> p = pri_queue.top();
		pri_queue.pop();
		
		visited[p.second] = true;
		
		if (dis[p.second] < p.first * -1) continue; //如果是已经更新过的结点则跳过
		
		for (int i = 0; i < adj_list[p.second].size(); i++)
		{
			pair<int, int> v = adj_list[p.second][i];
//			if(visited[v.first]) continue;
			if (dis[v.first] > dis[p.second] + v.second)
			{
				dis[v.first] = dis[p.second] + v.second;
				pri_queue.push(pair<int, int>(dis[v.first] * -1, v.first));
			}
		} 
	} 
	
	
}


Measured memory_bytes: 8184
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

const int N=10000005;

int n,m;
int a[N];

void solve(int n){
	int i,s;
	if (!n) return;
	for (i=1;i<=n;i++){
		s=n-i;
		if (1ll*s<=1ll*i*(i-1)/2){
			a[++m]=i;
			solve(n-i);
			return;
		}
	}
}

int main(){
	int i,j,s;
	scanf("%d",&n);
	solve(n);
	for (i=m;i;i--) printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
int main(){
    ll k,a,b;cin>>k>>a>>b;
    if(b<=a+2)cout<<1+k;
    else{
        if(k<a-1)cout<<1+k;
        else{
            k-=a-1;
            cout<<a+(b-a)*(k/2)+k%2;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define INF 2000000000
#define N 30
using namespace std;
void bfs();
int w,h,data[N][N][4];//0:left,1:up,2:right,3:down
int main(){
  int l,in;
  while(1){
    cin >> w >> h;
    if(w==0&&h==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
    for(int k=0;k<4;k++){
      data[i][j][k]=1;
    }
      }
    }
    for(int i=0,l=0;i<2*h-1;i++){
      if(i%2==0){
    for(int j=0;j<w-1;j++){
      cin >> in;
      if(in==0) data[l][j][2]=data[l][j+1][0]=0;
    }
      }else{
    for(int j=0;j<w;j++){
      cin >> in;
      if(in==0) data[l][j][3]=data[l+1][j][1]=0;
    }
    l++;
      }
    }
    bfs();
  }
  return 0;
}
void bfs(){
  int d[h][w];
  queue<pair<int,int> > Q;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      d[i][j]=INF;
    }
  }
  d[0][0]=1;
  Q.push(make_pair(0,0));
  while(!Q.empty()){
    pair<int,int> u=Q.front();
    Q.pop();
    if(data[u.first][u.second][0]==0){
      if(d[u.first][u.second-1]>d[u.first][u.second]+1){
    d[u.first][u.second-1]=d[u.first][u.second]+1;
    Q.push(make_pair(u.first,u.second-1));
      }
    }
    if(data[u.first][u.second][1]==0){
      if(d[u.first-1][u.second]>d[u.first][u.second]+1){
    d[u.first-1][u.second]=d[u.first][u.second]+1;
    Q.push(make_pair(u.first-1,u.second));
      }
    }
    if(data[u.first][u.second][2]==0){
      if(d[u.first][u.second+1]>d[u.first][u.second]+1){
    d[u.first][u.second+1]=d[u.first][u.second]+1;
    Q.push(make_pair(u.first,u.second+1));
      }
    }
    if(data[u.first][u.second][3]==0){
      if(d[u.first+1][u.second]>d[u.first][u.second]+1){
    d[u.first+1][u.second]=d[u.first][u.second]+1;
    Q.push(make_pair(u.first+1,u.second));
      }
    }
  }
  if(d[h-1][w-1]!=INF) cout << d[h-1][w-1] << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
//const ll P=1000000007;
const long long P=998244353;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


int main(){
  ll n; 
  cin>>n;
  ll ans=1;
  long double anss=0;
  rep(i, n){
    ll a;
    cin>>a;
    if(a==0){
      ans=0;
      anss=0;
      break;
    }else{
    ans*=a;
    anss+=log10(a);
    }
  }
  if(anss>18.5){
    ans=-1;
  }else{
    if(ans>1000000000000000000){
     ans=-1;
    }
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 4240