akhauriyash/Code-Regression huggingface dataset:
use std::io;

fn main() {
  let mut word = String::new();
  io::stdin().read_line(&mut word).ok();
  let vec: Vec<&str> = word.split_whitespace().collect();
  let A: i32 = vec[0].trim().parse().ok().unwrap();
  let B: i32 = vec[1].trim().parse().ok().unwrap();
  let ans = A * B;
  println!("{}", ans);
}

Measured memory_bytes: 2128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
 
namespace INPUT{
	const int L=1<<15;
	char _buf[L],*S,*T,c;
	char _gc(){
		if(S==T){
			T=(S=_buf)+fread(_buf,1,L,stdin);
			if(S==T) return EOF;
		}
		return *S++;
	}
	void readi(int &X){
		register bool flag;
		for(c=_gc();(c<'0'||c>'9')&&c!='-';c=_gc());
		if(c=='-') X=0,flag=true; else X=c&15,flag=false;
		for(c=_gc();c>='0'&&c<='9';X=X*10+(c&15),c=_gc());
		if(flag) X=-X;
	}
}
using INPUT::readi;
 
const int Maxn=2E5+5;
 
int N,M,K,V;
int a[Maxn];
int F[Maxn<<1],G[Maxn<<1];
int L[25][Maxn],R[25][Maxn];
char Ans[50],_1[50]={"Possible"},_2[50]={"Impossible"};
//int nxt[Maxn];
 
inline void MIN(int &x,int y){if(x>y)x=y;}
inline void MAX(int &x,int y){if(x<y)x=y;}
 
int main(){
	readi(N),readi(V);
	while(V>>M) ++M;
	for(int i=1;i<=N;++i) readi(a[i]);
	for(int i=0;i<=M;++i){
		L[i][1]=1;
		for(int j=2;j<=N;++j)
			if(a[j]-a[j-1]>(V>>i)) L[i][j]=j;
		for(int j=2;j<=N;++j)
			if(L[i][j]==0) L[i][j]=L[i][j-1];
		
		R[i][N]=N;
		for(int j=N-1;j>=1;--j)
			if(a[j+1]-a[j]>(V>>i)) R[i][j]=j;
		for(int j=N-1;j>=1;--j)
			if(R[i][j]==0) R[i][j]=R[i][j+1];
	}
	G[0]=N+1;
	for(int i=1;i<(1<<M);++i){
		G[i]=N+1;
		for(int j=0;j<M;++j)
			if((i>>j)&1)
				MAX(F[i],R[M-j][min(F[i-(1<<j)]+1,N)]),
				MIN(G[i],L[M-j][max(G[i-(1<<j)]-1,1)]);
	}
	for(int i=1;i<=N;++i)
		K+=(L[0][i]!=L[0][i-1]);
	if(K>20){
		for(int i=1;i<=N;++i)
			puts("Impossible");
		return 0;
	}
	for(int i=1,j;i<=N;++i)
		if(L[0][i]!=L[0][i-1]){
			for(j=0;j<(1<<M);++j)
				if(F[j]>=L[0][i]-1 && G[(1<<M)-1-j]<=R[0][i]+1)
					{memcpy(Ans,_1,sizeof(_1)); break ;}
			if(j==1<<M) memcpy(Ans,_2,sizeof(_2));
			printf("%s\n",Ans);
		}else printf("%s\n",Ans);
/*	memset(nxt,-1,sizeof(nxt));
	for(int i=0;i<(1<<M);++i) MAX(nxt[G[(1<<M)-1-i]],F[i]);
	for(int i=1;i<=N+1;++i) MAX(nxt[i],nxt[i-1]);
	for(int i=1;i<=N;++i)
		if(nxt[R[0][i]+1]>=L[0][i]-1)
			puts("Possible");
		else
			puts("Impossible");*/
	return 0;
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,n,x=0;cin>>N;
  for(int i=0;i<N;i++){
    cin>>n;if(n%2==1)x++;
  }
  if(x%2==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import numpy as np
 
mod = 10**9 + 7
max_digit = 60
N = int(input())
A = np.array(list(map(int, input().split())))

result = 0
base = 1
for _ in range(max_digit + 1):
  a = A % 2
  c = np.count_nonzero(a == 0)
  result = (result + (base*(N - c)*c) % mod) % mod
  A = A >> 1
  base *= 2

print(result)

Measured memory_bytes: 48804
use std::cmp;

fn main() {
    let s: String = read();
    let k: i32 = read();

    //let mut a = s.chars().collect::<Vec<char>>();
    let mut v: Vec<&str> = (0..s.chars().count()).map(|x| {&s[x..]}).collect();
    v.sort();
    let mut v: Vec<&str> = v[0..cmp::min(k as usize, s.chars().count())].to_vec();

    let mut vv: Vec<&str> = Vec::new();

    for i in v {
        let mut v1: Vec<&str> = (0..i.chars().count()).map(|x| {&i[..(x+1)]}).collect();
        vv.append(&mut v1);
    }

    vv.sort();
    vv.dedup();

    println!("{}", vv[(k-1) as usize]);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  vector<int> x(4);
  vector<int> y(4);
  cin >> x[0] >> y[0] >> x[1] >> y[1];

  int dx = (x[1] - x[0]);
  int dy = (y[1] - y[0]);

  cout << x[1] - dy << " " << y[1] + dx << " ";
  cout << x[1] - dy - dx << " " << y[1] + dx - dy << endl;


	return 0;
}



Measured memory_bytes: 3620
#include <stdio.h>
 
int main()
{
    double left, right;
    int la, ra, lb, rb, lc, rc, ld, rd;
     
    la = ra = lb = rb = lc = rc = ld = rd = 0;
    while (scanf("%lf%lf", &left, &right) != EOF) {
        if (left >= 1.1) la++;
        else if (0.6 <= left && left < 1.1) lb++;
        else if (0.2 <= left && left < 0.6) lc++;
        else ld++;
         
        if (right >= 1.1) ra++;
        else if (0.6 <= right && right < 1.1) rb++;
        else if (0.2 <= right && right < 0.6) rc++;
        else rd++;
    }
    printf("%d %d\n%d %d\n%d %d\n%d %d\n", la, ra, lb, rb, lc, rc, ld, rd);
    return 0;
}

Measured memory_bytes: 2680
using System;

namespace ITP1_6_A{
    class Sample{
        static void Main(string[] args){
            int len = int.Parse(Console.ReadLine());
            string[] str = new string[len];
            str = Console.ReadLine().Split(' ');
            for(int i=len-1; i>=0; i--){
                Console.Write("{0}",int.Parse(str[i]));
                if(!(i==0)) Console.Write(" "); 
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 15912
S = int(input())
M = 10 ** 9

# x1, y1は0に固定
# x2 = 1, x3 = 10 ** 9 に固定

def triArea(y2, y3):
  return abs(y3-y2*M)

f = 0
t = M+1
while f + 1 < t:
  y2 = f + (t - f) // 2
  maxArea = triArea(y2, 0)
  minArea = triArea(y2, M)
  if S < minArea:
    t = y2
  elif S > maxArea:
    f = y2
  else:
    f = y2
    break
y2 = f

f = 0
t = M+1
while f + 1 < t:
  y3 = f + (t - f) // 2
  area = triArea(y2, y3)
  if S <= area:
    f = y3
  else:
    t = y3
y3 = f
print(0, 0, 1, y2, M, y3)

Measured memory_bytes: 3316
N = int(input())
P = [int(p) for p in input().split()]
A = [(N + 1) * (i + 1) for i in range(N)]
B = [(N + 1) * (N - i) for i in range(N)]
for i in range(N): B[P[i] - 1] += i + 1
print(" ".join(map(str, A)))
print(" ".join(map(str, B)))


Measured memory_bytes: 7232
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    string s, t;
    cin >> s >> t;

    int mx = 0;
    rep(i, s.size() - t.size() + 1) {
        int cnt = 0;
        rep(j, t.size()) {
            if (s[i + j] == t[j]) cnt++;
        }
        mx = max(mx, cnt);
    }
    cout << t.size() - mx << endl;
    return 0;
}


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

int main(){
    int h,w; cin>>h>>w;
    char s[h][w];
    rep(i,h){
        rep(j,w) cin>>s[i][j];
    }
    string ans="Yes"; bool flag=true;
    int dx[4]={0,-1,0,1},dy[4]={1,0,-1,0};
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                flag=true;
                rep(k,4){
                    if(0<=i+dx[k] and i+dx[k]<h and 0<=j+dy[k] and j+dy[k]<w){
                        if(s[i+dx[k]][j+dy[k]]=='#') flag=false;
                    }
                }
                if(flag) ans="No";
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// -*- mode: cpp; coding=utf-8-unix; -*-
// vim: filetype=cpp fileencoding=utf-8 fileformat=unix
#include <bits/stdc++.h>
// #include <vector>
// #include <list>
// #include <string>
// #include <iostream>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;
int N;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;

    cout << std::setprecision(8);
	if (N%2==0) {
		cout << 0.5 << endl;
	}
	else {
		cout << (double)(N/2 + 1)/((double)N) << endl;
	}

	return 0;
}




Measured memory_bytes: 256
using System;

namespace ConsoleApp2
{
    class Program
    {
        const string endWord = "END_OF_TEXT";
        static void Main(string[] args)
        {
            string targetWord = Console.ReadLine();
            string[] line;
            bool End = false;
            int count = 0;
            while (!End)
            {
                line = Console.ReadLine().Split();
                for (int i = 0; i < line.Length; i++)
                {
                    if (line[i] == endWord)
                    {
                        End = true;
                        break;
                    }
                    if (line[i].ToUpper() == targetWord|| line[i].ToLower() == targetWord)
                    {
                        count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 15848
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1,0,1,0 }; const int dy[] = { 0,1,0,-1 };

int main() {
	string s;
	int x, y;
	cin >> s >> x >> y;
	vi mrx;
	vi mry;
	bool xax = true;
	int a = 0;
	REP(i, s.length()) {
		if (s[i] == 'T') {
			if (a == 0) {
				xax = !xax;
			}
			else {
				if (xax)
					mrx.push_back(a);
				else
					mry.push_back(a);
				xax = !xax;
				a = 0;
			}
		}
		else {
			a++;
			if (i == s.length() - 1) {
				if (xax)
					mrx.push_back(a);
				else
					mry.push_back(a);
			}
		}
	}
	set<int> six;
	six.insert(0);
	REP(i, mrx.size()) {
		set<int> news;
		for (auto x : six) {
			news.insert(x + mrx[i]);
			if (!(i == 0 && s[0] == 'F'))
				news.insert(x - mrx[i]);
		}
		six = news;
	}
	set<int> siy;
	siy.insert(0);
	REP(i, mry.size()) {

		set<int> news;
		for (auto x : siy) {
			news.insert(x + mry[i]);
			news.insert(x - mry[i]);
		}
		siy = news;
	}
	if ((six.find(x) != six.end()) && (siy.find(y) != siy.end()))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

public class Main {

    static long mod = (long) (1e9 + 7);

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        int[][] a = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = in.nextInt();
            }
        }

        long[] dp = new long[1 << n];
        dp[0] = 1;
        for (int mask = 0; mask < (1 << n) - 1; mask++) {
            int j = countSetBits(mask);
            for (int k = 0; k < n; k++) {
                if (((mask) & (1 << k)) == 0 && a[j][k] == 1) {
                    int mask2 = mask ^ (1 << k);
                    dp[mask2] = (dp[mask2] + dp[mask]) % mod;
                }
            }
        }
        out.println(dp[(1 << n) - 1]);
        out.close();
    }

    static int countSetBits(int n) {
        int count = 0;
        while (n > 0) {
            count += n & 1;
            n >>= 1;
        }
        return count;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}

Measured memory_bytes: 40276
# bit全探索
# d = 4
# for mask in range(1 << d):  # 2のd乗になる
#     print("mask =", mask)
#     for i in range(d):
#         print("(mask >>", i, ") & 1 = ", (mask >> i) & 1)
#         # 1のビットが立つかどうかでT/F判断した方が個人的に分かりやすいから(mask >> i) & 1と書いている


# まずスイッチの状態を全て表す方針で行く
N, M = map(int, input().split())  # N個スイッチとM個の電球

connect_infos = []
# それぞれの電球が繋がっているスイッチの情報が与えられる
for i in range(M):
    k, *S = list(map(lambda x: int(x)-1, input().split()))
    connect_infos.append(S)

# print(connect_info)
# 電球が灯されるかの判断材料
P = list(map(int, input().split()))
# print(P)


switches_status = [[] for _ in range(1 << N)]
# print(switches_status)
for mask in range((1 << N)):  # 2のN乗になる
    for i in range(N):
        switches_status[mask].append((mask >> i) & 1)

# print(switches_status)

ans = 0
# 全てのスイッチの状態ついてループを回す
for status in switches_status:
    shine = 0
    # statusは1次元リスト
    for i, connect_info in enumerate(connect_infos):
        # connect_infoにはそれぞれの電球がどのスイッチに接続されているかの情報がある
        on_count = 0
        for j in connect_info:
            on_count += status[j]
        # 接続しているスイッチのon状態を個数を獲得できた
        if on_count % 2 == P[i]:
            shine += 1
    if shine == M:  # 光っている電球の数 と 電球の個数Mが等しいならansをインクリメントする
        ans += 1

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	
	vector<int> x(N + 1);
	vector<int> y(M + 1);
	
	cin >> x[0] >> y[0];
	
	for (int i = 0; i < N; i++)
	{
		cin >> x[i + 1];
	}
	for (int i = 0; i < M; i++)
	{
		cin >> y[i + 1];
	}
	
	bool isWar = true;
	for (int z = -100; z <= 100; z++)
	{	
		bool isNoWar = true;
		for (int i = 0; i < x.size(); i++)
		{
			// xがz以上の場合戦争へ
			if (x[i] >= z)
			{
				isNoWar = false;
			}
		}
		
		for (int i = 0; i < y.size(); i++)
		{
			// yがzより小さい場合戦争へ
			if (y[i] < z)
			{
				isNoWar = false;
			}
		}
		
		// この時点において、戦争を回避
		if (isNoWar)
		{
			isWar = false;
		}
	}
	
	
	if (isWar)
	{
		cout << "War" << endl;
	}
	else {
		cout << "No War" << endl;
	}
	
	return 0;
}

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

int main() {
  int a,b,total = 0;
  cin >> a >> b;
  for (int i = a; i < b+1; i++) {
    string str = to_string(i);
    if (str.at(0) == str.at(4) && str.at(1) == str.at(3)) {
      total++;
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

int main()
{
	INT n;
	cin >> n;
	vector<INT> a(n);
	INT r = 0, l = 10000;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
		r = max(r, a[i]);
		l = min(l, a[i]);
	}
	cout << r - l << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
using namespace std;

int F[100][10];
int P[100][11];

int overlap(int i, int bit_set){
    int ans = 0;
    for(int j = 0; j < 10; j++){
        if(F[i][j] == 1 && ((bit_set >> j) & 1) == 1){
            ans ++;
        }
    }
    return ans;
}
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            cin >> F[i][j];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 11; j++){
            cin >> P[i][j];
        }
    }

    long long ans = LLONG_MIN;
    for(int bit_set = 1; bit_set < (1 << 10); bit_set++){
        long long tmp_profit = 0;
        for(int i = 0; i < N; i++){
            tmp_profit += P[i][overlap(i, bit_set)];
        }
        ans = max(ans, tmp_profit);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    ll a;
    cin >> a;
    cout << a + a * a + a * a * a << "\n";

    return 0;
}

Measured memory_bytes: 3608
x, n = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
else:
    p = list(map(int, input().split()))
list_ = [i for i in range(-1, max(p) + 2)]
res = -1
for i in list_:
    if i in p:
        pass
    else:
        if abs(i - x) < abs(res - x):
            res = i
print(res)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;

int main()
{
    s64 a, b, c, d;
    cin >> a >> b >> c >> d;

    vector<s64> v;
    v.push_back(a * c);
    v.push_back(a * d);
    v.push_back(b * c);
    v.push_back(b * d);

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

    cout << v[3] << endl;

    return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, n; cin >> h >> n;
    int sum = 0, c;
    for (int i = 0; i < n; i++) {
        cin >> c; sum += c;
    }
    if (sum < h) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    vector<P> v;
    rep(i,n){
        int a; cin >> a;
        v.push_back(P(a, i+1));
    }
    sort(v.begin(), v.end());

    rep(i,n){
        cout << v[i].second << ' ';
    }
    cout << endl;
    return 0;
}
 
 


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  if (a <= b/k*k) puts("OK");
  else puts("NG");
  return(0);
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int a = in(), b = in();
  string s;
  cin >> s;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl

int l,ol;
int n,m=1;
int x[66],y[66],w[66];

int main()
{
	SPEED;
	cin>>l;
	ol=l;
	int in=0;
	int d[33]={0};
	while(l>0)
	{
		d[in++]=(l&1);
		l>>=1;
	}
	n=in;
	for(int i=1;i<n;i++)
	{
		x[m]=i;
		y[m]=i+1;
		w[m]=0;
		m++;
		x[m]=i;
		y[m]=i+1;
		w[m]=(1<<(n-i-1));
		m++;
	}
	for(int i=0;i<in-1;i++)
	{
		if(d[i])
		{
			ol^=(1<<i);
			x[m]=1;
			y[m]=n-i;
			w[m]=ol;
			m++;
		}
	}
	cout<<n<<" "<<m-1<<endl;
	for(int i=1;i<m;i++)
		cout<<x[i]<<" "<<y[i]<<" "<<w[i]<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());
            Console.WriteLine((a + b) * h / 2);
        }
    }
}

Measured memory_bytes: 13140
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	n,r=map(int,input().split())
	print(r+100*(10-min(10,n)))
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
N,M=map(int,input().split())
AC=[0]*N
WA=[0]*N
wa=0
for i in range(M):
  p,s=input().split()
  p=int(p)-1
  if AC[p]==0 and s=="AC":
  	AC[p]=1
  	wa+=WA[p]
  WA[p]+=1
print(sum(AC),wa) 


Measured memory_bytes: 51544
s=input()
if s=="SUN":
    print(7)
if s=="MON":
    print(6)
if s=="TUE":
    print(5)
if s=="WED":
    print(4)
if s=="THU":
    print(3)
if s=="FRI":
    print(2)
if s=="SAT":
    print(1)


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

map<ll,ll> ma;

int main(void) {

    ll n,m;
    cin>>n>>m;
    vll v(n);
    rep(i,n)cin>>v[i];
    rep(i,m){
        int a,b;
        cin>>a>>b;
        ma[b]+=a;
    }
    rep(i,n){
        ma[v[i]]++;
    }
    vector<pair<ll,ll>> p;
    for(auto it=ma.begin();it!=ma.end();it++){
        p.push_back(mp(it->first,it->second));
    }
    Rort(p);
    ll ans=0;
    int pos=0;
    // rep(i,p.size())cout<<p[i].first<<" "<<p[i].second<<endl;
    while(n>0){
        if(n>=p[pos].second){
            // cout<<"AAA:"<<p[pos].first*p[pos].second<<endl;
            ans+=p[pos].first*p[pos].second;
            n-=p[pos].second;
            pos++;
            // cout<<"n"<<n<<endl;
        } else {
            // cout<<"BBB:"<<p[pos].first*n<<endl;
            ans+=p[pos].first*n;
            break;
        }
    }
    fin(ans);
}


Measured memory_bytes: 19184
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N = iIn()
P = tuple(iInLH())
Q = tuple(iInLH())

lst = list(itertools.permutations(range(1, N+1)))

for i in range(len(lst)):
    if lst[i] == P:
        idx_p = i
    if lst[i] == Q:
        idx_q = i

ans = abs(idx_p - idx_q)
print(ans)

Measured memory_bytes: 79888
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  const int N = 1e9;
  int n;
  cin >> n;
  int a[n + 1], b[n + 1], s[n + 1];
  int p[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    s[p[i]] = N - (n + 1 - i);
  }
  a[1] = 1;
  b[1] = s[1] - a[1];
  for (int i = 2; i <= n; i++) {
    if (s[i - 1] < s[i]) {
      b[i] = b[i - 1] - 1;
      a[i] = s[i] - b[i];
    } else {
      a[i] = a[i - 1] + 1;
      b[i] = s[i] - a[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  cout << "\n";
  for (int i = 1; i <= n; i++) {
    cout << b[i] << " ";
  }
  cout << "\n";
}



Measured memory_bytes: 1280
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int num(int n) {
  string s = to_string(n);
  int cnt = 0;
  rep(i, s.size()) {
    cnt += s[i] - '0';
  }
  return cnt;
}

int main() {
  int n, a, b, cnt = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    if (a <= num(i) && num(i) <= b) cnt += i;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>

using namespace std;


int main() {

	int n, l;
	cin >> n >> l;

	string s[n];

	for (int i = 0; i < n; i++) {
		cin >> s[i];
		}

	sort(s, s+n);

	for (int i = 0; i < n; i++)cout << s[i];




	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    int A,B,N,ans = 1;
    cin >> A >> B;
    int a = A;
    if(B < 2){
        cout << 0 << endl;
        return 0;
    }
    while(a < B){
        a += A-1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=998244353;
ll quick_pow(ll x,ll a)
{
	ll ans=1;
	while(a)
	{
		if(a&1)ans=ans*x%MOD;
		x=x*x%MOD;
		a>>=1;
	}
	return ans;
}
int n,cnt[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int v;
		scanf("%d",&v);
		if(i==1&&v!=0)
		{
			printf("0\n");
			return 0;
		}
		cnt[v]++;
	}
	if(cnt[0]!=1)
	{
		printf("0\n");
		return 0;
	}
	while(cnt[n]==0)n--;
	ll ans=1;
	for(int i=1;i<=n;i++)ans=ans*quick_pow(cnt[i-1],cnt[i])%MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
from sys import stdin
class UnionFind:
    def __init__(self, n):
        # par[x]: x が根のときは x を含むグループのサイズ (の -1 倍)、そうでないときは親ノード
        self.par = [-1 for i in range(n + 1)]

    # 親ノードの検索
    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    # 併合
    # x と y を同じグループにする, 計算量はならし O(α(n))
    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x

    # x と y が同じグループにいるか, 計算量はならし O(α(n))
    def issame(self, x, y):
        return self.root(x) == self.root(y)

    # size(x): x を含むグループの所属メンバー数
    def size(self, x):
        return -self.par[self.root(x)]


if __name__ == '__main__':
    N, M = list(map(int, input().split()))
    # print(Town.par)
    Island = UnionFind(N)
    A = [None]*M
    B = [None]*M
    cntlist = [0]*M
    cnt = N*(N-1)//2
    for i in range(M):
        A[i],B[i] = map(int,stdin.readline().rstrip('\n').split())
    # print(A,B)
    for i in range(M-1,0,-1):
        if Island.root(A[i]) == Island.root(B[i]):
            cntlist[i] = cnt
            continue
        else:
            cnt -= (Island.size(A[i]))*(Island.size(B[i]))
            Island.union(A[i],B[i])
        # for i in range(N+1):
        #     print(Island.size(i),end=',')
        # print()
        # print(cnt)
            cntlist[i] = cnt

    # print(Island.par)
    for i in range(1,M):
        print(cntlist[i])
    print(N*(N-1)//2)

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

signed main () {
	string s;
	cin >> s;
	int n = s.size();
	vector < int > tens_a(n + 1, 1), tens_b(n + 1, 1);
	for (int i = 1; i <= n; ++i) {
		tens_a[i] = (tens_a[i - 1] * 10) % 3;
		tens_b[i] = (tens_b[i - 1] * 10) % 673;
	}
	vector < int > pref_a(n + 1, 0), pref_b(n + 1, 0);
	vector < int > gay_a(n + 1, 0), gay_b(n + 1, 0);
	for (int i = 1; i <= n; ++i) {
		pref_a[i] = ((pref_a[i - 1] * 10) + int(s[i - 1] - '0')) % 3;
		gay_a[i] = (pref_a[i] * tens_a[n - i]) % 3;
		pref_b[i] = ((pref_b[i - 1] * 10) + int(s[i - 1] - '0')) % 673;
		gay_b[i] = (pref_b[i] * tens_b[n - i]) % 673;
	}
	map < pair < int, int >, int > cnt;
	long long ans = 0;
	for (int i = 0; i <= n; ++i) {
		pair < int, int > slut = make_pair(gay_a[i], gay_b[i]);
		ans += cnt[slut];
		++cnt[slut];
	}
	cout << ans << '\n';
}


Measured memory_bytes: 8340
$<.each_line do |l|
  x1, y1, x2, y2, xq, yq = l.split(?,).map(&:to_f)
  u = (x2 - x1) + (y2 - y1) * 1i
  v = (xq - x1) + (yq - y1) * 1i
  r = xq + yq * 1i - 2 * (v - (v.real * u.real + v.imag * u.imag) / (u.abs**2) * u)
  puts '%.4f %.4f' % [r.real, r.imag]
end

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

int main() {
  int N;
  vector<double> x(N);
  vector<string> u(N);
  
  cin >> N;
  
  for(int i = 0; i < N; i++) {
    cin >> x.at(i) >> u.at(i);
  }
  
  double ans = 0.0;
  for(int i = 0; i < N; i++) {
    if(u.at(i) == "BTC") {
      ans += x.at(i) * 380000.0;
    }
    else {
      ans += x.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
# C - Grid Repainting 2
from collections import deque

H, W = map(int, input().split())
grid = [[''] * W for _ in range(H)]
for i in range(H):
    grid[i] = list(str(input()))

d = deque()
ans = 'Yes'
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            continue
        d.append((i, j))
        grid[i][j] = '.'
        tmp = 1
        while d:
            p, q = d.popleft()
            for x, y in ((0, 1), (1, 0), (-1, 0), (0, -1)):
                nx = p+x
                ny = q+y
                if nx < 0 or nx >= H or ny < 0 or ny >= W:
                    continue
                if grid[nx][ny] == '.':
                    continue
                d.append((nx, ny))
                grid[nx][ny] = '.'
                tmp += 1
        if tmp == 1:
            ans = 'No'
            break
    else:
        continue
    break
print(ans)

Measured memory_bytes: 9468
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll power(ll p,ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
int main()
{
ll x,a,b;
cin>>a>>b;
x=max(a+b,a-b);
cout<<max(a*b,x)<<"\n";
return 0;
}

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

int n,a[200010],cnt1[200010],cnt2[200010];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",a+i);
		if(i&1)++cnt1[a[i]];
		else ++cnt2[a[i]];
	}
	int maxn1=0,maxn2=0,ans=0,maxid1,maxid2;
	for(int i=1;i<=100000;++i)
	{
		if(cnt1[i]>maxn1)
		{
			maxid1=i;
			maxn1=cnt1[i];
		}
		if(cnt2[i]>maxn2)
		{
			maxid2=i;
			maxn2=cnt2[i];
		}
	}
	int maxval1=0,maxval2=0;
	if(maxid1==maxid2)
	{
		for(int i=1;i<=100000;++i)
		{
			if(i!=maxid1)
			{
				maxval1=max(maxval1,cnt1[i]);
				maxval2=max(maxval2,cnt2[i]);
			}
		}
		printf("%d\n",min(n-maxval1-maxn2,n-maxn1-maxval2));
	}
	else
	{
		printf("%d\n",n-maxn1-maxn2);
	}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod2 998244353
#pragma GCC optimize("-O2")
#define mod3 127
#define mod 1000000007
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector<vector<int>>
#define v4096 vector<vector<lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli, lli>
#define m32 map<int, int>
#define m64it map<lli, lli>::iterator
#define m32it map<int, int>::iterator
#define fastio                    \
ios_base::sync_with_stdio(0); \
cin.tie(0);                   \
cout.tie(0)
#define ist insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define p_q priority_queue
#define min_p_q priority_queue<int, vt<int>, greater<int>>
using namespace std;
using namespace __gnu_pbds;
lli tmod(lli x, lli y)
{
    return (x % y + y) % y;
}
template <typename T>
void DEBUG_ARR(vt<T> a)
{
    f(i, 0, a.size()) cout << a[i] << " ";
    cout << "\n";
}
lli power(lli x, lli y) 
{
    lli res = 1;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;
    }
    if(res<0)res+=mod;
    return res; 
}
lli p10[15];
lli dp[200005];
int main()
{
    fastio;
    p10[0]=1;
    f(i,1,15)p10[i]=10*p10[i-1];
    lli n;
    cin>>n;
    string s=to_string(n);
    lli temp;
    temp=n-p10[s.size()-1]*(s[0]-'0');
    temp/=10;
    temp++;
    dp[0]=0;
    f(i,1,n+1){
        dp[i]=dp[i-1];
        string inum=to_string(i);
        // cout<<inum.back()<<"\n";
        if(inum.back()=='0')continue;
        if(inum.back()<s[0]){
            dp[i]+=(p10[s.size()-1]-1)/9;
            if(inum.back()==inum[0]){
                dp[i]++;
            }
        }
        else if(inum.back()>s[0]){
            if(s.size()>1)
            dp[i]+=(p10[s.size()-2]-1)/9;
            if(inum.back()==inum[0]){
                dp[i]++;
            }
        }
        else{
            if(inum[0]<=s.back()){
                dp[i]+=temp;
            }
            else dp[i]+=temp-1;
            if(s.size()>1){
                dp[i]+=(p10[s.size()-2]-1)/9;
            }
            if(inum.back()==inum[0]){
                dp[i]++;
            }
        }
        // cout<<i<<" "<<dp[i]-dp[i-1]<<"\n";
    }
    if(s.size()==1)dp[n]--;
    cout<<dp[n]<<"\n";
    return 0;
}


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

int main()
{
  int n, l, r, sum = 0;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}

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

int main() {
  string s;
  cin >> s;
  if (s == "SSS") cout << 0 << endl;
  if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") cout << 1 << endl;
  if (s == "RRS" || s == "SRR") cout << 2 <<endl;
  if (s == "RRR") cout << 3 << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int h,w;cin>>h>>w,h|w;){
		vs field(h);
		rep(i,h)
			cin>>field[i];
		vvi hist(h,vi(w));
		rep(i,w)
			if(field[0][i]=='.')
				hist[0][i]=1;
		repi(i,1,h)
			rep(j,w)
				if(field[i][j]=='.')
					hist[i][j]=hist[i-1][j]+1;
		int res=0;
		rep(i,h){
			hist[i].push_back(0);
			stack<pii> s;	// pos,height
			rep(j,hist[i].size()){
				int left=j;
				while(s.size() && s.top().second>hist[i][j]){
					left=s.top().first;
					res=max(res,s.top().second*(j-s.top().first));
					s.pop();
				}
				s.push(mp(left,hist[i][j]));
			}
		}
		cout<<res<<endl;
	}
	
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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 dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};


int main() {
    cout<<fixed<<setprecision(10);

    string s,t; cin>>s>>t;
    ll ans = 0;
    rep(i,s.size()){
        if(s[i] != t[i]) ans++;
    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3916
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

int main() {
	ll n,p;
	cin >> n >> p;
	ll ans = -1;
	if (n == 1) {
		ans = p;
	} else if (p == 1) {
		ans = 1;
	} else {
		ll num=0;
		double a = 1.0 / (double)n;
		for (int i = 1; i<= pow(p,a)+1; i++) {
			num = (ll)pow(i, n);
			if (p%num == 0) ans = i;
			else if (p < num)break;
		}
		if (ans == -1) ans = 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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


int main(void){
    string s;

    cin >> s;

    int y = atoi(s.substr(0, 4).c_str());
    int m = atoi(s.substr(5, 2).c_str());
    int d = atoi(s.substr(8, 2).c_str());

    if(d <= 2019 && m <= 4 && d <= 30){
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
   int N; cin>>N;
   i64 cnt[5]; REP(i,5) cnt[i]=0;
   string S;
   char march[5] = {'M','A','R','C','H'};
   REP(i,N) {
       cin>>S;
       REP(i,5) if (S[0]==march[i]) cnt[i]++;
   }
   i64 ans = 0;
   int comb = (1<<3)-1;
   while (comb<1<<5) {
       i64 tmp = 1;
       REP(i,5) if (comb&(1<<i)) tmp *= cnt[i];
       ans += tmp;
       int x = comb&-comb, y = comb+x;
       comb = (((comb&~y)/x)>>1)|y;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    val d = readLine()!!.split(" ").map(String::first)
    val result = (n..99999).first { i ->
        i.toString().all { c -> !d.contains(c) }
    }
    println(result)
}


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

using namespace std;
typedef long long int ll;

void solve()
{
	int n;
	cin >> n;
	if(n >= 30) cout << "Yes\n";
	else cout << "No";
}

int main()
{
//	cin.sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3608