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

#include<map>

int main(){
    string s, t;
    cin >> s >> t;
    map<string, int> maps, mapt;
    for(size_t i = 0; i < s.length(); i++)
    {
        maps[s.substr(i,1)] += 1;
        mapt[t.substr(i,1)] += 1;
    }
    vector<int> vecs, vect;
    for(auto it = maps.begin(); it != maps.end(); it = next(it, 1)){
        vecs.push_back(it->second);
    }
    for(auto it = mapt.begin(); it != mapt.end(); it = next(it, 1)){
        vect.push_back(it->second);
    }
    sort(vecs.begin(), vecs.end());
    sort(vect.begin(), vect.end());
    if (vecs == vect){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int a = (A==B);
    int b = (B==C);
    int c = (C==A);
    if(a+b+c == 1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int a, b;
  cin >> a >> b;
  auto eat = [](int x){return x <= 8;};
  cout << (eat(a) && eat(b) ? "Yay!" : ":(") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long i,a[101]={0,1,2,2,4,4,4,4,8,8,8,8,8,8,8,8,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64};
     cin>>i;
     cout<<a[i]<<endl;
     return 0;
}

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

int main() {
	int H, W;
	cin >> H >> W;
	while (!(H == 0 && W == 0)) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
	return 0;
}

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

using namespace std;

#define int long long

main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ans = 0, n, x;
    vector < int > a;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        a.push_back(x);
    }
    for (int i = 1; i < n; ++i) {
        int x = min(a[i], a[i - 1]);
        if ((a[i - 1] - x) % 2 == 1 && x > 0) x--;
        ans += x;
        a[i] -= x;
        a[i - 1] -= x;
        ans += a[i - 1] / 2;
    }
    cout << ans + a.back() / 2 << '\n';
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n , m;
  scanf("%d%d",&n,&m);
  int t = 0 , ans = 0;
  for(int i = 0 ; i < n ; i++)
  {
    int te;scanf("%d",&te);
    t += te;
    if(t <= m) ans++;
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())

if H==1 or W == 1:
  ans = 1
elif (H*W) % 2 == 0:
  ans = (H*W)//2
elif (H*W) % 2 == 1:
  ans = (H*W)//2 + 1

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>	
#include <utility>
#include <cinttypes>
using namespace std;
int main(){
    int64_t a,b,answer;
    scanf("%" PRId64 " %" PRId64 ,&a,&b);
    if (a%2==0){
        answer = b-(b-a)%4;
        for( int64_t i = b-(b-a)%4 + 1 ; i<=b ; i++ ) {
            answer = answer ^ i;
        }
    } else {
        answer = a;
        for( int64_t i = b-(b-(a+1))%4  ; i<=b ; i++ ) {
            answer = answer ^ i;
        }
    }
    printf("%" PRId64 ,answer);
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	int a[5], k;
	bool flag = true;
	REP(i, 5) {
		cin >> a[i];
	}
	cin >> k;
	if (a[4] - a[0] <= k)cout << "Yay!";
	else cout << ":(";
	return(0);
}

Measured memory_bytes: 256
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
x = a[0]
for  i in range(1,n):
    x = x * a[i] // gcd(x,a[i])
ans = 0
for i in range(n):
    ans += x//a[i]
print(ans%1000000007)

Measured memory_bytes: 6200
a=[ list(map(int,input().split())) for j in range(3)]
n=int(input())
kk=101
for i in range(n):
  s=int(input())
  for j in range(3):
    for k in range(3):
      if s==a[j][k]:
        a[j][k]=kk
count=0
ans=0
for j in range(3):
  count=0
  for k in range(3):
    if a[j][k]==kk:
      count+=1
  if count==3:
    ans=1
    break
    
for j in range(3):
  count=0
  for k in range(3):
    if a[k][j]==kk:
      count+=1
  if count==3:
    ans=1
    break
if a[0][0]==kk and a[1][1]==kk and a[2][2]==kk:
  ans=1
if a[0][2]==kk and a[1][1]==kk and a[2][0]==kk:
  ans=1
if ans==1:
  print("Yes")
else:
  print("No")

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

const int MOD = 1e9 + 7;
int n, m;
int memo[(int)1e5 + 1], tag[(int)1e5 + 1];

int f(int pos){
	if(tag[pos]) return 0;
	if(pos > n) return 0;
	if(pos == n) return 1;
	if(memo[pos] != -1) return memo[pos];
	int w = 0;
	w += f(pos + 1) + f(pos + 2);
	if(w >= MOD) w -= MOD;
	memo[pos] = w;
	return memo[pos];
}


int main() {
	memset(memo, -1, sizeof(memo));
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a;
		cin >> a;
		tag[a]++;
	}
	cout << f(0) << "\n";
	return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define Si size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define Em empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define Fi first
#define Se second
#define Pi acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);








int main()
{
//    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int n,a[5];
    cin >> n;
    if(n <= 111)
    {
        P("111");
    }
    else if(n <= 222)
    {
        P("222");
    }
    else if(n <= 333)
    {
        P("333");
    }
    else if(n <= 444)
    {
        P("444");
    }
    else if(n <= 555)
    {
        P("555");
    }
    else if(n <= 666)
    {
        P("666");
    }
    else if(n <= 777)
    {
        P("777");
    }
    else if(n <= 888)
    {
        P("888");
    }
    else
    {
        P("999");
    }
    return 0;
}







LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


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

int main(void){
    int n;
    cin >> n;
    int p[n];
    for(int i = 0;i < n;i++)cin >> p[i];
    sort(p,p+n,greater<int>());
    int sum = p[0]/2;
    for(int i = 1;i < n;i++)sum += p[i];
    cout << sum;
}

Measured memory_bytes: 256
from statistics import median

N=int(input())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
median_a=median(A)
median_b=median(B)
if N%2==0:
    print(int((median_b-median_a)*2)+1)
else:
    print(int(median_b-median_a)+1)

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef int ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 1e6 + 100;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

ll p[MAX],cont[MAX];

int main(){
	p[1] = 1;
	f(i,2,MAX){
		if(p[i] == 0){
			rep(j,i,MAX,i) p[j] = i;
		}
	}
	fastio;
	ll n,g = 0,x;
	cin >> n;
	f(i,0,n){
		cin >> x;
		g = __gcd(g,x);
		while(x>1){
			ll aux = p[x];
			while(x%aux == 0) x/=aux;
			cont[aux]++; 
		}
	}
	bool go = true;
	f(i,1,MAX) if(cont[i]>1) go = false;
	if(go) cout << "pairwise coprime\n";
	else if(g == 1) cout << "setwise coprime\n";
	else cout << "not coprime\n";

	return 0;
}

Measured memory_bytes: 11464
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,d;
int x[21][21];

bool C(int v){
	int l=0,r=v+1;
	while(l+1<r){
		int mi=(l+r)/2;
		if(mi*mi<=v)l=mi;
		else{
			r=mi;
		}
	}
	if(l*l==v)return true;
	return false;
}

int main(void){
	scanf("%d%d",&n,&d);
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			scanf("%d",&x[i][j]);
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int sum=0;
			for(int k=0;k<d;k++){
				sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			if(C(sum))ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void func(long &a, long &b){
  swap(a, b);
  b += a;
}
int main() {
  int N;
  cin >> N;
  long a = 2, b = 1;
 for(int i = 0; i < N; i++){
   func(a, b);
 }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

int main() {
	int a, b, n;
	while(cin >> a >> b >> n) {
		int ret = 0;
		a %= b;
		rep(i,0,n) {
			a *= 10;
			ret += a / b;
			a %= b;
		}
		cout << ret << endl;
	}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  ll n, p; cin >> n >> p;
  int isOdd = 0;
  ll a[n]; for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i] % 2 == 1) isOdd = 1;
  }
  if(isOdd == 0) {
    if(p==0) cout << (ll)pow(2, n) << endl;
    else cout << 0 << endl;
  } else {
    cout << (ll)pow(2, n-1) << endl;
  }

  return 0;
}

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

int main() {
	ll N, K;
	cin >> N >> K;

	long double ans = 0;
	for (ll i = 1; i <= N; i++) {
		long double prob = 1.0 / N;
		ll value = i;
		while (value < K) {
			prob *= 0.5;
			value *= 2;
		}
		ans += prob;
	}

	cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
signed main() {
	char a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	if (a == f && b == e && c == d)puts("YES");
	else puts("NO");
	ll
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		long ans = Math.max(Math.max(a*c,a*d), Math.max(b*c,b*d));
		System.out.println(ans);
		
		sc.close();
	}
}



Measured memory_bytes: 27076
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String r = sc.next();
        String g = sc.next();
        String b = sc.next();
        StringBuilder sb = new StringBuilder();
        sb.append(r);
        sb.append(g);
        sb.append(b);
        int n = Integer.parseInt(sb.toString());
        if (n%4==0) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
	}
}


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

int main(void){
    //int n;
    string s;
    cin >> s;
    
    string answer;
    
    if (s[s.length() - 1] == 's') {
        answer = s + "es";
    } else {
        answer = s + "s";
    }
    
    cout << answer;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main()
{
    int n,m,i,k,j;
    int sum[100] = {0};
    
    scanf("%d %d", &n,&m);
    
    int a[n][m];
    int xb[m];
    
    //行列A
    for(i=0; i<n; i++)
    {
        for(k=0; k<m; k++)
        {
            scanf("%d ", &a[i][k]);
        }
    }
    
    //行列b
    for(i=0; i<m; i++)
    {
        scanf("%d", &xb[i]);
    }
    
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            sum[i] += a[i][j] * xb[j];
        }
        printf("%d\n", sum[i]);
    }
    
    return 0;
}






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

int main(){
    int n,m;
    int a,b;
    cin>>n>>m;
    long long ans=0,cnt=0;
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }

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

    for(int i=0;i<n;i++){
        if(cnt+v[i].second<m){
            ans+=(long long)v[i].first * v[i].second;
        }
        else {
            ans+=(long long)v[i].first * (m-cnt);
            break;
        }
        cnt+=v[i].second;

    }

    cout<<ans;

}

Measured memory_bytes: 1400
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n;
	int sum1[4001];
	int sum2[4001];
	int i, j, k;
	
	memset(sum1, 0, sizeof(sum1));
	memset(sum2, 0, sizeof(sum1));
	
	for (j = 0; j <= 1000; j++){
		sum1[j] = 1;
	}
//printf("<%d>", sum1[2]);
	for (i = 0; i < 3; i++){
		for (j = 0; j <= 1000; j++){
			for (k = 0; k <= 4000; k++){
				if (k + j <= 4000){
//printf("<%d>", sum1[2]);
					sum2[k + j] += sum1[k];
//if (k + j == 2)printf("[%d+%d:%d->%d]", j, k, sum1[k], sum2[k + j] );
				}
			}
//printf("[%d->%d]", j, sum2[2] );
		}
		memcpy(sum1, sum2, sizeof(sum1));
		memset(sum2, 0, sizeof(sum2));
	}
	
	while (scanf("%d", &n) != EOF){
		printf("%d\n", sum1[n]);
	}
	
	return (0);
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

int main() {
  int N, K;
  long long ans = 0;

  cin >> N >> K;
  vector<long long> HN(N);
  REP(n,N) cin >> HN.at(n);
  if(N <= K){
    ans = 0;
  }else{
    sort(HN.begin(), HN.end());
    REP(i,N-K) ans += HN.at(i);
  }

  cout << ans << endl;
}

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

int main() {

	int n; cin >> n;
	bool even = true;
	for (int i = 0; i < n; i++) {
		ll a; cin >> a;
		if (a % 2 != 0) {
			even = false;
		}
	}
	if (even) cout << "second" << endl;
	else cout << "first" << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

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

		int K = sc.nextInt();
		double R = (double) sc.nextInt();
		double L = (double) sc.nextInt();

		double P = sc.nextDouble();
		double E = sc.nextDouble();
		double T = sc.nextDouble();

		sc.close();

		Deque<Seek> deque = new ArrayDeque<Seek>();
		deque.add(new Seek(R, L, 1.0, 0));

		double ans = 0;
		while (!deque.isEmpty()) {
			Seek seek = deque.poll();
			if (T - E <= seek.r && seek.l <= T + E) {
				ans += seek.p;
				continue;
			}
			if (seek.l <= T - E || T + E <= seek.r) {
				continue;
			}

			double h = (seek.r + seek.l) / 2;
			if (seek.k == K) {
				if (T - E <= h && h <= T + E) {
					ans += seek.p;
				}
				continue;
			}
			if (Math.abs(seek.l - T) >= Math.abs(seek.r - T)) {
				deque.add(new Seek(seek.r, h, (1 - P) * seek.p, seek.k + 1));
				deque.add(new Seek(h, seek.l, P * seek.p, seek.k + 1));
			} else {
				deque.add(new Seek(seek.r, h, P * seek.p, seek.k + 1));
				deque.add(new Seek(h, seek.l, (1 - P) * seek.p, seek.k + 1));
			}

		}

		// 小数第6位まで表示
		BigDecimal bd = new BigDecimal(String.valueOf(ans));
		System.out.println(bd.setScale(6, BigDecimal.ROUND_HALF_UP));

	}
}

class Seek {
	double r, l, p;
	int k;

	public Seek(double r, double l, double p, int k) {
		this.r = r;
		this.l = l;
		this.p = p;
		this.k = k;
	}
}

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

int main(){
    int M, D;
    cin >> M >> D;
    int ans = 0;
    for(int i=1; i<=M; i++) for(int j=1; j<=D; j++){
        int d1 = j/10, d2 = j%10;
        if(d1 >= 2 && d2 >= 2 && d1*d2 == i) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S,T;
    cin >> S >> T;
    vector<int> dpS(S.size()+1,0);
    for(int i=0; i<S.size(); i++){
        dpS[i+1] = dpS[i] + "12"[S[i]=='B'] - '0';
    }
    vector<int> dpT(T.size()+1,0);
    for(int i=0; i<T.size(); i++){
        dpT[i+1] = dpT[i] + "12"[T[i]=='B'] - '0';
    }
    int Q;
    cin >> Q;
    for(int i=0; i<Q; i++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;b--;c--;d--;
        if((dpS[b+1]-dpS[a])%3 == (dpT[d+1]-dpT[c])%3){
            cout << "YES\n";
        }else{
            cout << "NO\n";
        }
    }
    return 0;
}

Measured memory_bytes: 4252
#include<iostream>
#include<cstdio>
#include<cassert>
using namespace std;
#define rep(i,n) for ( int i = 0; i < n; i++ )
#define MAX 20

static const int T[6] = {10, 5, 3, 6, 12, 9};
int G[MAX][MAX], H, W, ncell, vcell, V[MAX][MAX];

bool eq(int a, int i, int b, int j){
    return ((a & (1<<i)) > 0) == ((b & (1<<j)) > 0);
}

void dfs(int i, int j){
    V[i][j] = true;
    vcell++;
    static int di[4] = {0, -1, 0, 1};
    static int dj[4] = {1, 0, -1, 0};

    rep(s, 4){
	int ni = i + di[s];
	int nj = j + dj[s];
	if ((G[i][j] & (1<<s)) && !V[ni][nj]) dfs(ni, nj);
    }
}

bool rec(int pos){
    if ( pos == H*W ) {
	vcell = 0;
	rep(i, H) rep(j, W) V[i][j] = false;
	rep(i, H) rep(j, W){
	    if ( G[i][j] == 0 ) continue;
	    dfs(i, j);
	    return ncell == vcell;
	}
	return false;
    }
    int i = pos/W;
    int j = pos%W;
    if ( G[i][j] == 0 ){
	int v = 0;
	if ( j && !eq( G[i][j-1], 0, v, 2 ) )  return false;
	if ( i && !eq( G[i-1][j], 3, v, 1 ) )   return false;
	if ( rec(pos+1) ) return true ;
    } else {
	rep(t, 6){
	    int v = T[t];
	    if ( j && !eq( G[i][j-1], 0, v, 2 ) ) continue;
	    if ( i && !eq( G[i-1][j], 3, v, 1 ) ) continue;
	    if ( i == 0 && (v&(1<<1)) ) continue;
	    if ( i == H-1 && (v&(1<<3)) ) continue;
	    if ( j == 0 && (v&(1<<2)) ) continue;
	    if ( j == W-1 && (v&1) ) continue;
	    G[i][j] = v;
	    if ( rec(pos+1) ) return true;
	}
    }
    return false;
}

main(){
    while(1){
      cin >> W >> H;
      //      assert( W <= 7 && H <= 7 );
	if ( H == 0 && W == 0 ) break;
	ncell = 0;
	rep(i, H) rep(j, W){ 
	    cin >> G[i][j];
	    if ( !G[i][j] ) ncell++;
	    G[i][j] = (G[i][j] ? 0 : 1); 
	}

	bool r = rec(0);
	if (r){
	  cout << "Yes" << endl;
	} else{
	  cout << "No" << endl;
	}
    }
}

Measured memory_bytes: 856
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var S = Read().ToList();
            var K = ReadLong();

            if (S.Count == 1 || K == 1 || (S.Count > 1 && S[0] != '1'))
            {
                Println(S[0]);
            }
            else if (S.Count(x => x != '1') == 0 || S.FindIndex(x => x != '1') + 1 > K)
            {
                Println(1);
            }
            else
            {
                Println(S[S.FindIndex(x => x != '1')]);
            }
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13140
A, B, M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(M)]

nouse = min(a) + min(b)
ans = []
ans.append(nouse)
for x in X:
    re, de, c = x
    ans.append(a[re-1] + b[de-1] - c)

print(min(ans))


Measured memory_bytes: 88172
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
bool is_prime[300020];
void prime(){
    for(int i=0;i<=300010;i++) is_prime[i]=true;
    for(int i=6;i<=300010;i++){
        if(is_prime[i] && ((i%7==1) || (i%7==6))){
            //if(i<100) cout<<i<<endl;
            for(int j=2*i;j<=300010;j+=i) is_prime[j]=false;
        }
    }
}
int main(){
    vector<vector<int>> ans;
    prime();
    while(1){
        int n;
        cin>>n;
        if(n==1){
            for(int i=0;i<ans.size();i++){
                //cout<<ans[i].size()<<endl;
                for(int j=0;j<ans[i].size();j++){
                    if(j==0) cout<<ans[i][j]<<":";
                    else cout<<" "<<ans[i][j];
                }
                cout<<endl;
            }
            return 0;
        }
        int cnt=0;
        vector<int> now;
        now.push_back(n);
        for(int i=6;i<=n;i++){
            if(is_prime[i]==true && ((i%7==1) || (i%7==6)) && n%i==0) now.push_back(i);
        }
        ans.push_back(now);
    }
    return 0;
}


Measured memory_bytes: 3436
#include <stdio.h>

int main(){
    int i, k, n;
    const int MAX_V = 999999;
    int prime[MAX_V+1];
    int sum[MAX_V+1];
    for(i = 2; i <= MAX_V; i++) prime[i] = 1;
    for(i = 2; i <= MAX_V; i++){
        if(prime[i]){
            for(k = 2 * i; k <= MAX_V; k += i){
                prime[k] = 0;
            }
        }
    }
    sum[1]=0;
    for(i = 2; i <= MAX_V; i++) sum[i] = sum[i-1]+prime[i];
    while(scanf("%d", &n) != EOF) printf("%d\n",sum[n]);
    return 0;
}

Measured memory_bytes: 9524
import sys
sys.setrecursionlimit(10**6)

n, a, b = map(int, input().split())
def pop_count(x):
	res = 0
	for i in range(17):
		res += ((x>>i)%2 == 1)
	return res
if (pop_count(a^b)) % 2 == 0:
	print("NO")
else:
	print("YES")
	def f(m, x, y):
		if m == 1:
			if x == 0:
				return [0, 1]
			else:
				return [1, 0]

		res = [x]
		for i in range(m):
			if (x>>i) % 2  != (y>>i) % 2:
				diff = i
				break
		s = (x % (2**diff)) + (((x // (2**(diff+1))) * 2**(diff+1)) >> 1)
		t = (y % (2**diff)) + (((y // (2**(diff+1))) * 2**(diff+1)) >> 1)
		#return s, t
		u = s^1
		left = f(m-1, s, u)
		right = f(m-1, u, t)
		#print(left, right)
		x_bit, y_bit = (x>>diff) % 2, (y>>diff) % 2
		left = [l % (2**diff) + (2**diff * x_bit) + (((l // (2**diff)) * 2**diff) << 1) for l in left]
		right = [r % (2**diff) + (2**diff * y_bit) + (((r // (2**diff)) * 2**diff) << 1) for r in right]
		return left + right
	print(*f(n, a, b))

Measured memory_bytes: 72536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int k = sc.nextInt();
		
		int res = 0;
		
		for(int i = 1; i < k; i++) {
			for(int j = i+1; j < k; j++) {
				if(i % 2 == 0 && j % 2 != 0) res++;
				if(i % 2 != 0 && j % 2 == 0) res++;
			}
		}
		
		out.println(res + k/2);

		out.flush();
	}

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

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> array(3);

    cin>>array[0]>>array[1]>>array[2];
    sort(array.begin(),array.end());

    if(*max_element(array.begin(),array.end())==array[1]){
        cout<<*min_element(array.begin(),array.end())<<endl;
    }else{
        cout<<*max_element(array.begin(),array.end())<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
 
using namespace std;
 
int main()
{
    int n, m;
    int vote;
    int cost[1001], pt[1001] = {0};
 
    scanf("%d %d", &n, &m);
 
    for (int i = 0; i < n; i++){
        scanf("%d", &cost[i]);
    }
 
    for (int i = 0; i < m; i++){
        scanf("%d", &vote);
        for (int j = 0; j < n; j++){
            if (cost[j] <= vote){
                pt[j]++;
                break;
            }
        }
    }
 
    int max = 0;
 
    for (int i = 0; i < n; i++){
        if (pt[max] < pt[i]){
            max = i;
        }
    }
 
    cout << max + 1 << endl;
 
    return (0);
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 3e5 + 7;
int n, sz;
int a[4][N], inv[2], flip[2];
int tr[N];
int lowbit(int x) { return x & -x;}
void modify(int x, int y) { for(int i = x; i <= sz; i += lowbit(i)) tr[i] += y;}
int query(int x){ 
	int res = 0;
	for(int i = x; i; i -= lowbit(i)) res += tr[i];
	return res;
}
int main() {
#ifdef fwat
#endif
	n = gi(), sz = n * 3;
	rep(i, 1, 3)
	rep(j, 1, n) a[i][j] = gi();
	
	rep(j, 1, n) {
		int mi = min(a[1][j], min(a[2][j], a[3][j]));
		if(a[1][j] == mi) {
			if(!(a[2][j] == mi + 1 && a[3][j] == mi + 2)) return puts("No"), 0;
		}else if(a[3][j] == mi) {
			flip[j & 1] ^= 1;
			if(!(a[2][j] == mi + 1 && a[1][j] == mi + 2)) return puts("No"), 0;
		}else return puts("No"), 0;
		if(j % 2 == 1 && mi % 6 != 1) return puts("No"), 0;
		if(j % 2 == 0 && mi % 3 != 1) return puts("No"), 0;
	}
	for(int j = 1; j <= n; j += 2) {
		inv[1] ^= query(sz) - query(a[2][j]) & 1;
		modify(a[2][j], 1);
	}
	re(tr);
	for(int j = 2; j <= n; j += 2) {
		inv[0] ^= query(sz) - query(a[2][j]) & 1;
		modify(a[2][j], 1);
	}
	puts(flip[0] == inv[1] && flip[1] == inv[0] ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3840
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd

sys.setrecursionlimit(10**7)
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

#S.sort()
T.sort()
setS = set(S)

cnt = 0
for t in T:
    if t in setS:
        cnt += 1
print(cnt)



Measured memory_bytes: 16624
def tanri(a, y, r, c):
    o = 0
    for i in range(y):
        o += int((a-i*c)*r)
    o += a-y*c
    return o


def fukuri(a, y, r, c):
    o = a
    for i in range(y):
        o = int(o*(1+r))-c
    return o


m = int(input())
for _ in range(m):
    a = int(input())
    y = int(input())
    n = int(input())
    b = []
    for i in range(n):
        t,r,c = input().split()
        r = float(r)
        c = int(c)
        if t == '0':
            b.append(tanri(a, y, r, c))
        else:
            b.append(fukuri(a, y, r, c))
    print(max(b))


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

const int MAX = 3510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll f(ll r, ll c) {
    ll res = COM(r + c + 2, r + 1) % MOD;
    res--;
    if (res < 0) res += MOD;
    return res;
}

void Main() {
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    COMinit();
    ll ans = f(r2, c2);
    ans -= f(r2, c1 - 1);
    ans %= MOD;
    if (ans < 0) ans += MOD;
    ans -= f(r1 - 1, c2);
    ans %= MOD;
    if (ans < 0) ans += MOD;
    ans += f(r1 - 1, c1 - 1);
    ans %= MOD;
    cout << ans << '\n';
}

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


Measured memory_bytes: 82560
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,m,dp[1009][1009];
string a[1009];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>a[i];
	dp[0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(a[i][j]=='.') {
				if(i-1>=0) dp[i][j]=dp[i-1][j];
				if(j-1>=0) dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
			}
	cout<<dp[n-1][m-1]<<endl;
	return 0;
}

Measured memory_bytes: 5248
#include <iostream>

int main() {

    int a, b, c, k;
    std::cin >> a >> b >> c >> k;

    if (k <= a) std::cout << k << std::endl;
    else if (k <= a + b) std::cout << a << std::endl;
    else std::cout << a - (k - a - b) << std::endl;

    return 0;
}

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

int main () {
  int N, M;
  cin >> N >> M;
  vector <bool> tower(N);
  vector <int> h(N);
  for (int i = 0; i < N; i++) cin >> h.at(i);
  int ans = 0;
  for (int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    if (h.at(a-1) >= h.at(b-1)) tower.at(b-1) = true; 
    if (h.at(a-1) <= h.at(b-1)) tower.at(a-1) = true;
  }
  for (int i = 0; i < N; i++){
    if (!tower.at(i)) ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3784
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = [list(map(lambda x: int(x) - 1, readline().split())) for _ in range(n)]
q = list(range(n))
for cnt in range(1, n ** 2):
    qq = set()
    for x in q:
        if a[a[x][0]][0] == x:
            qq.add(x)
            qq.add(a[x][0])
    if qq:
        q = []
        for x in qq:
            a[x].pop(0)
            if a[x]:
                q.append(x)
    else:
        print(-1)
        break
    if not q:
        print(cnt)
        break


Measured memory_bytes: 35060
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

const int nax=1e6+10;
vector<int> isp(nax,-1);
void fill(){
    isp[1]=1;
    for(ll i=2;i<nax;i+=2)isp[i]=2;
    for(ll i=3;i<nax;i+=2){
        if(isp[i]==-1)isp[i]=i;
        for(ll j=i*i;j<nax;j+=i){
            if(isp[j]==-1)isp[j]=i;
        }
    }
}

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

int main(){
    fill();
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    //check for pw cp
    int g=a[0];
    bool okay=true;
    vector<int> cnt(nax);
    for(int i=0;i<n;i++){
        cnt[a[i]]++;
    }
    for(ll i=2;i<nax;i++){
        int s=0;
        for(ll j=i;j<nax;j+=i){
            s+=cnt[j];
        }
        if(s>1){
            okay=false;
            break;
        }
    }
    if(okay){
        cout<<"pairwise coprime\n";
        return 0;
    }
    g=a[0];
    for(int i=0;i<n;i++){
        g=gcd(g,a[i]);
        if(g==1)break;
    }
    if(g==1){
        cout<<"setwise coprime\n";
    }
    else{
        cout<<"not coprime\n";
    }
    return 0;
}


Measured memory_bytes: 14880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    ll m = 1;
    for(int i=0; i<n; i++){
        if(a[i]==m)m++;
    }
    if(m==1)cout<<-1;
    else cout<<n-m+1;
    return 0;
}

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

const int64_t MOD = 1e9 + 7;

void combination(int64_t n, int target_size, /*int64_t v[]*/std::vector<int64_t> v) {
    vector<int> indices(target_size);
    const int seed_size = n;
    int start_index = 0;
    int size = 0;

    int64_t ans = 0;
    while (size >= 0) {
        // for (int i = start_index; i < n; ++i) {
        repb(i, start_index, n) {
            indices[size++] = i;
            if (size == target_size) {
                vector<int64_t> comb(target_size);
                for (int x = 0; x < target_size; ++x) {
                    comb[x] = indices[x];
                }
                // if (callback(comb)) return;
                int n = comb.size();
                int64_t num = 1;
                for (int i=0; i<n; ++i) {
                    // cout << comb[i] << " ";
                    num *= (v[comb[i]]%MOD);
                }
                ans += num;
                // cout << endl;
                break;
            }
        }
        --size;
        if (size < 0) break;
        start_index = indices[size] + 1;
    }
    cout << ans%MOD << endl;
}

int main() {
    int64_t n;
    cin >> n;
    std::vector<int64_t> a(n);
    // int64_t a[n];
    int64_t sum = 0;
    rep(i, n) {
        cin >> a[i];
        // a[i] %= MOD;
        sum += a[i];
        sum %= MOD;
    }

    int64_t ans = 0;
    rep(i, n-1) {
        sum -= a[i];
        if (sum < 0) sum += MOD;
        ans += a[i]*sum;
        ans %= MOD;
    }
    cout << ans%MOD << endl;
    return 0;
    // combination(n, 2, a);
}


Measured memory_bytes: 4800
def check(n):
    min_len = 1 << 60
    for i in range(1, int(n**.5 + 1)):
        if n % i == 0:
            a= i
            b= n//i
            min_len = min(min_len, max(len(str(a)), len(str(b))))
    return min_len


n = int(input())
res = check(n)
print(res)

Measured memory_bytes: 9312
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
num = [a,b,c,d,e]
def rou(num):
    return math.ceil(num/10) * 10
RR = list(map(rou, num))
def ama(num):
    t = num % 10
    if t == 0:
        return 10
    else:
        return t
tmp = list(map(ama, num))
ind = tmp.index(min(tmp))
RR.remove(RR[ind])
print(num[ind] + sum(RR))


Measured memory_bytes: 3064
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}
fn main() {
    input!{ n: i32 }
    let ret = false;
    for i in 0..25+1 {
        for j in 0..14+1 {
            if 4*i+7*j == n {
                println!("Yes");
                return;
            } else {
            }
        }
    }
    println!("No");
}

Measured memory_bytes: 4352