akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline

def calc(A, B):
    if A == B:
        return 1
    for i in range(61, -1, -1):
        if A&(1<<i) and B&(1<<i):
            A ^= 1<<i
            B ^= 1<<i
        if not A&(1<<i) and B&(1<<i):
            break
    
    Bd = B ^ (1<<(B.bit_length())-1)
    BM = ((1<<Bd.bit_length())-1)
    B = B | BM
    C = (1<<(B.bit_length())-1)
    
    res = (B-A+1) + (C-max(BM+1, A))
    return res
A = int(readline())
B = int(readline())
print(calc(A, B))



Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
using namespace std;

int main(void){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll> > ngo(n);
    rep(i,n) cin>>ngo[i].first>>ngo[i].second;
    sort(ngo.begin(),ngo.end());
    ll ans = 0;
    rep(i,n){
        if(m>0){
            if(m-ngo[i].second < 0){
                ans += ngo[i].first*m;
                m = 0;
            }else{
                ans += ngo[i].first*ngo[i].second;
                m -= ngo[i].second;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	Scanner sc;
	
	class Vector{
		public double x, y;
		
		public Vector(double x, double y){
			this.x=x;
			this.y=y;
		}
		
		public double norm(){
			return Math.hypot(x, y);
		}
		
		public double sqrNorm(){
			return x*x+y*y;
		}
		
		public double ip(Vector v){
			return x*v.x+y*v.y;
		}
		
		public Vector add(Vector v){
			return new Vector(x+v.x, y+v.y);
		}
		
		public Vector subtract(Vector v){
			return new Vector(x-v.x, y-v.y);
		}
		
		public Vector multiply(double a){
			return new Vector(x*a, y*a);
		}
		
		public String toString(){
			return String.format("(%5f,%5f)", x, y);
		}
	}
	
	boolean inTriangle(Vector[] v){
		double theta=0;
		for(int i=0;i<3;++i){
			theta+=Math.acos(v[i].ip(v[(i+1)%3])/v[i].norm()/v[(i+1)%3].norm());
		}
		return theta>=Math.PI*2-1e-7;
	}
	
	char solve(Vector[] a, Vector p, double r){
		Vector[] v=new Vector[3], e=new Vector[3];
		r*=r;
		
		boolean isB=true;
		for(int i=0;i<3;++i){
			v[i]=a[i].subtract(p);
			e[i]=a[(i+1)%3].subtract(a[i]);
			isB&=v[i].sqrNorm()<=r;
		}
		if(isB) return 'b';
		
		Vector[] h=new Vector[3];
		boolean isA=true;
		for(int i=0;i<3;++i){
			//点pより三角形の辺と直交するvector
			//hi=vi+(ei・(-vi)/|ei|^2)ei
			h[i]=v[i].subtract(e[i].multiply(e[i].ip(v[i])/e[i].sqrNorm()));
			isA&=h[i].sqrNorm()>=r;
		}
		//debug(h);
		
		if(isA&&inTriangle(v)) return 'a';
		
		boolean isC=false;
		for(int i=0;i<3;++i){
			Vector n=h[i].add(p);
		//	debug(n,n.subtract(a[i]).ip(n.subtract(a[(i+1)%3])));
			if(v[i].sqrNorm()<=r||(n.subtract(a[i]).ip(n.subtract(a[(i+1)%3]))<=0&&h[i].sqrNorm()<=r)){
				isC=true;
			}
		}
		if(isC) return 'c';
		else return 'd';
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in);
		
		while(true){
			int x=ni(),y=ni();
			if(x==0&y==0)break;
			
			Vector[] a=new Vector[3];
			
			for(int i=0;i<3;++i){
				a[i]=new Vector(x, y);
				x=ni(); y=ni();
			}
			Vector p=new Vector(x, y);
			double r=ni();
			
			System.out.println(solve(a,p,r));
		}
	}
	
	void debug(Object...os){
		System.err.println(Arrays.deepToString(os));
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

Measured memory_bytes: 21140
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

struct cmp{
    bool operator() (const pair<int,int>& a, const pair<int,int>& b){
        return min(a.first,a.second)<min(b.first,b.second);
    }
};

void solve(){
    int n;
    cin>>n;
    vector<long long> a(n,0);
    priority_queue<pair<int,int>,vector<pair<int,int>>, cmp> pq;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(rfull(a));
    long long ans=0;
    pq.push({a[0],a[0]});
    for(int i=1;i<n;i++){
        auto tp=pq.top();pq.pop();
        ans+=min(tp.first,tp.second);
        pq.push({a[i],tp.first});
        pq.push({a[i],tp.second});
    }
    cout<<ans<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 6860
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;

int main(){
  int kane;
  int a,i;
  
  while(1){
    a=0;
    cin >> kane;
    if(kane == 0)break;
    kane=1000-kane;
    
    if(kane >= 500){
      kane-=500;
      a++;
    }
    if(kane >= 100){
      i = kane/100;
      a+=i;
      kane-=100*i;
    }
    if(kane >= 50){
      i = kane/50;
      a+=i;
      kane-=50*i;
    }
    if(kane >= 10){
      i = kane/10;
      a+=i;
      kane-=10*i;
    }
    if(kane >= 5){
      i = kane/5;
      a+=i;
      kane-=5*i;
    }
    if(kane != 0){
      a+=kane;
    }
    cout << a <<endl;
  }
}

Measured memory_bytes: 1160
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int M = sc.nextInt();
    	int[] fr = new int[A];
    	int minF = Integer.MAX_VALUE;
    	for (int i = 0; i < A; i++) {
    		fr[i] = sc.nextInt();
    		if (fr[i] < minF) {
    			minF = fr[i];
    		}
    	}
    	int minR = Integer.MAX_VALUE;
    	int[] ra = new int[B];
    	for (int i = 0; i < B; i++) {
    		ra[i] = sc.nextInt();
    		if (ra[i] < minR) {
    			minR = ra[i];
    		}
    	}
    	int ans = minF + minR;
    	List<int[]> cpList = new ArrayList<>();
    	for (int i = 0; i < M; i++) {
    		int[] cp = new int[3];
    		cp[0] = sc.nextInt() - 1;
    		cp[1] = sc.nextInt() - 1;
    		cp[2] = sc.nextInt();
    		cpList.add(cp);
    	}
    	for (int[] cp : cpList) {
    		int val = fr[cp[0]] + ra[cp[1]] - cp[2];
    		if (val < ans) {
    			ans = val;
    		}
    	}
    	System.out.println(ans);

    }
}

Measured memory_bytes: 63896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl



int main() {
    int Q;  cin >> Q;
    vector<int> l(Q);
    vector<int> r(Q);
    rep(i, Q)  cin >> l[i] >> r[i];

    int N = int(pow(10, 5));
    vector<int> prime;
    for (int i=2; i<N; i++) {
        if (i % 2 == 0) continue;
        bool flag = true;
        for (int j=2; j<=sqrt(i); j++) {
            if (i % j == 0) {
                flag = false;
            }
        }
        if (flag) {
            prime.push_back(i);
        }
    }

    vector<int> prime2;
    for (int i=2; i<N; i++) {
        if (i % 2 == 0) continue;
        bool flag = true;
        for (int j=2; j<=sqrt((i+1)/2); j++) {
            if ((i+1)/2 % j == 0) {
                flag = false;
            }
        }
        if (flag) {
            prime2.push_back(i);
        }
    }

    vector<int> primeA;
    rep(i, max(prime.size(), prime2.size())) {
        rep(j, min(prime.size(), prime2.size())) {
            if (prime[i] == prime2[j]) {
                primeA.push_back(prime[i]);
            }
        }
    }

    vector<int> row;
    rep(i, N) {
        bool flag = false;
        rep(j, primeA.size()) {
            if (i == primeA[j]) {
                flag = true;
            }
        }
        if (flag) row.push_back(1);
        else row.push_back(0);
    }

    vector<int> sum(N, 0);
    rep(i, N) {
        if (row[i]) sum[i+1] = sum[i] + 1;
        else sum[i+1] = sum[i];
    }

    rep(i, Q) {
        print(sum[r[i]+1] - sum[l[i]]);
    }

}

Measured memory_bytes: 2424
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()

int main(){
    long n, x; cin>>n>>x;
    long sta, end, ans;
    sta = 1; end = pow(2, n+2)-3; ans = 0;
    long l = n-1;


    while(sta <= end && l >= -1){
        long mid = (sta+end)/2;
        if (x < mid){
            sta++;
            end = mid-1;
        }else if (x == mid){
            ans +=  pow(2, l+1);
            break;
        }
        else{
            ans += pow(2, l+1);
            sta = mid+1;
            end--;
        }
        l--;
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  bool flag = true;
  if (N % 2 == 1) {
    flag = false;
  }
  else {
    for (int i = 0; i < N/2; i++) {
      if (S.at(i) != S.at(i + N/2)) {
        flag = false;
      }
    }
  }
  
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
string S;
	cin >> S;
	map<string, string> K;
	K["Sunny"] = "Cloudy";
	K["Cloudy"] = "Rainy";
	K["Rainy"] = "Sunny";
	ce(K[S])
    return 0;
}



Measured memory_bytes: 256
import sys, os

if __name__=='__main__':
    if 'local' in os.environ :
        sys.stdin = open('./input.txt', 'r')
    
    n = int(input())
    ma = int(1e15)
    for i in range(5):
        ma = min(ma, int(input()))
    
    print(4 + (n +ma-1)//ma)



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
using namespace std;

int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a(n);
	vector<int> b(m);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	string ans = "";
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (int i = -99; i <= 100; i++)
	{
		
		if (x < i&&i <= y)
		{
			int f = 0;
			
				if (a.at(n-1) < i)
				{
					
					f++;
				}
			
			
				if (b.at(0) >= i)
				{
					f++;
					
				}
			
				if (f == 2)
				{
					
					cout << "No War" << endl;
					return 0;
				}
			
		}
		
	}
	cout << "War" << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var boss = new int[n];
            for (var i = 0; i < ai.Length; i++)
            {
                boss[ai[i] - 1]++;
            }

            for (var i = 0; i < boss.Length; i++)
            {
                Console.WriteLine(boss[i]);
            }
        }
    }
}


Measured memory_bytes: 43704
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

int main(){
    int N;
    cin >> N;

    vector<int>B(N-1);
    rep(i,N-1)cin >> B[i];

    reverse(B.begin(),B.end());

    int sum = 0;
    sum += B[0];
    rep(i,N-2){
        sum += min(B[i],B[i+1]);
    }
    sum += B[N-2];

    cout << sum << endl;


}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 1e3 + 17;
ll cnt, ans, lnt, sum, n, l1, x, y, a[N], mx, b[N][N], m;
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;

int main()
{
    cin >> n;
    a[0] = n;
    if(a[0] % 2 == 0)
    {
        a[1] = a[0] / 2;
    }
    else
    {
        a[1] = a[0] * 3 + 1;
    }
    mp[a[0]] ++;
    mp[a[1]] ++;
    for(ll i = 2; ; i ++)
    {
        if(a[i-1] % 2 == 0)
        {
            a[i] = a[i - 1] / 2;
            mp[a[i]] ++;
        }
        if(a[i-1] % 2 == 1)
        {
            a[i] = 3 * a[i-1] + 1;
            mp[a[i]] ++;
        }
        if(mp[a[i]] == 2)
        {
            cout << i + 1;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vl vector<ll>
#define el '\n'
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vpll vector<pll>
#define vvll vector<vector<ll> >
#define vvpll vector< vector<pll> >
#define ff first
#define ss second
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
typedef long long ll;

int main() 
{
    fastio();
    
    ll n,a,b,c;
    cin>>n;
    ll dp[n][3];
    for(ll i=0 ; i<n ; i++)
    {
        cin>>a>>b>>c;
        if(i==0)
        {
            dp[i][0] = a;
            dp[i][1] = b;
            dp[i][2] = c;
        }
        else
        {
            dp[i][0] = a + max(dp[i-1][1], dp[i-1][2]);
            dp[i][1] = b + max(dp[i-1][0], dp[i-1][2]);
            dp[i][2] = c + max(dp[i-1][0], dp[i-1][1]);
        }
    }
    
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	
	return 0;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int k= 1;
        HashMap<String,Integer> hashMap = new HashMap<>();
        hashMap.put("SUN",7);
        hashMap.put("MON",6);
        hashMap.put("TUE",5);
        hashMap.put("WED",4);
        hashMap.put("THU",3);
        hashMap.put("FRI",2);
        hashMap.put("SAT",1);
        String s1;
        String s2;
        int a,b;
        while(k-->0){
            a=s.nextInt();
            b=s.nextInt();
            if((a-2*b)>0)
                System.out.println(a-2*b);
            else
                System.out.println(0);
        }
    }

    private static int binary_search(
            int arr[], int l,
            int h, int x)
    {
        while (l <= h) {
            int mid = (l + h) / 2;
            if (arr[mid] <= x)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }
    static int gcd(int a, int b)
    {
        if(b==0) {
            return a;
        }
        return gcd(b,a%b);
    }
    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 27088
#include <stdio.h>
int main(void){
    int N, K, C;
    int ch, i, j;
    int workday[200000] = {0};

    scanf("%d%d%d%*c", &N, &K, &C);
    for(i = 0; i < N; i++){
        ch = getchar();
        if(ch == 'x')
            workday[i] = -1;
    }

    j = N - 1;
    for(i = K; i >= 1; i--){
        while(workday[j] == -1)
            j--;
        workday[j] = i;
        j -= C + 1;
    }

    j = 0;
    for(i = 1; i <= K; i++){
        while(workday[j] == -1)
            j++;
        if(i == workday[j])
            printf("%d\n", j+1);
        j += C + 1;
    }

    return 0;
}


Measured memory_bytes: 2176
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N + 2, 0);
	for (int i = 0; i < M; ++i) {
		int L, R;
		cin >> L >> R;
		A[L]++;
		A[R + 1]--;
	}
	int ans = 0;

	for (int i = 1; i <= N; ++i) {
		A[i] += A[i - 1];
		if (A[i] == M) {
			++ans;
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

double w,h,x,y;
int main(){
    cin>>w>>h>>x>>y;
    cout<<setprecision(10)<<fixed<<w*h/2<<" ";
    if(x*2==w&&y*2==h) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


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

red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]

red.sort(key=lambda x: x[1], reverse=True)
blue.sort(key=lambda x: x[0])

ans = 0

for b in blue:
    for r in red:
        if r[1] < b[1] and r[0] < b[0]:
            ans += 1
            red.remove(r)
            break

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int count(int x, vector<int> &vec) {
    int ans = 0;
    for(int i = 0; i < vec.size(); i++) {
        ans += x / vec.at(i);
        x = x % vec.at(i);
    }
    return ans;
    
}
int main() {
    int N;
    cin >> N;
  	vector<int> six = {46656, 7776, 1296, 216, 36, 6, 1};
    vector<int> nine = {59049, 6561, 729, 81, 9, 1};
    
    int ans = 1000000000;
    for(int i = 0; i <= N; i++) {
        ans = min(ans, count(i, six) + count(N-i, nine));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d=0;
	cin>>a>>b>>c;
	if(a==b){
		if(b==c)
		d=d+1;
		else 
		d=d+2;
	}
	else if(a!=b){
		if(a==c)
		d=d+2;
		else if(b==c)
		d=d+2;
		else
		d=d+3;
	}
	cout<<d;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    ll H, N;
    cin >> H >> N;
    ll sum = 0;
    rep(i, N) {
        ll a; cin >> a;
        sum += a;
    }
    if (sum >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(long long)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    long long n;
    cin>>n;
    vector<long long> A(n);
    for(long long i=0;i<n;i++)cin>>A[i];
    for(long long i=1;i<n;i++)A[i]+=A[i-1];
    long long res = inf;
    for(long long i=0;i<n-1;i++){
        res=min(res,abs(A[n-1]-2*A[i]));
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin >> N;
   int a,b,c;
   a = N % 10;
   N /= 10;
   b = N % 10;
   N /= 10;
   c = N % 10; 
   if(c == 7 || a == 7 || b == 7) {
      cout << "Yes";
   }else{
      cout << "No";
   }
 return 0;

}

Measured memory_bytes: 3636
import numpy as np
N, K = map(int, input().split())
X = np.array(list(map(int, input().split())))
idx = np.searchsorted(X, 0)
# print('idx', idx)
ans = 10**10
for i in range(N - K + 1):
    l = i
    r = i + K - 1
    d1 = np.abs(X[l]) + np.abs(X[r] - X[l])
    d2 = np.abs(X[r]) + np.abs(X[r] - X[l])
    d = min(d1, d2)
    ans = min(ans, d)
print(ans)


Measured memory_bytes: 23080
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,x,y,t=0;
	cin>>n;
	for(long long i=sqrt(n);i>=1;i--)
		if(n%i==0){x=n/i;break;}
	while(x>0)
	{t++;x/=10;}
	cout<<t<<endl;
	return 0;
} 

Measured memory_bytes: 256
import numpy as np
import sys
x, y = map(int, input().split())

if (x + y) % 3 != 0 or x > 2 * y or y > 2 * x:
    print(0)
    sys.exit()

# 手数
n = (x + y) // 3
x -= n
y -= n

MOD = 10**9 + 7


def prepare(n, MOD):
    nrt = int(n ** 0.5) + 1
    nsq = nrt * nrt
    facts = np.arange(nsq, dtype=np.int64).reshape(nrt, nrt)
    facts[0, 0] = 1
    for i in range(1, nrt):
        facts[:, i] = facts[:, i] * facts[:, i - 1] % MOD
    for i in range(1, nrt):
        facts[i] = facts[i] * facts[i - 1, -1] % MOD
    facts = facts.ravel().tolist()

    invs = np.arange(1, nsq + 1, dtype=np.int64).reshape(nrt, nrt)
    invs[-1, -1] = pow(facts[-1], MOD - 2, MOD)
    for i in range(nrt - 2, -1, -1):
        invs[:, i] = invs[:, i] * invs[:, i + 1] % MOD
    for i in range(nrt - 2, -1, -1):
        invs[i] = invs[i] * invs[i + 1, 0] % MOD
    invs = invs.ravel().tolist()

    return facts, invs


facts, invs = prepare(n, MOD)

print(facts[n] * invs[x] * invs[y] % MOD)

Measured memory_bytes: 70024
#076_C
s_ = list(input())
t = list(input())
ans = []
for i in range(len(s_) - len(t) + 1):
    s = s_.copy()
    flg = True
    for j in range(len(t)):
        if s_[i+j] == '?':
            s[i+j] = t[j]
        elif s_[i+j] == t[j]:
            continue
        else:
            flg = False
    if flg:
        s = ''.join(s).replace('?', 'a')
        ans.append(s)
        
if len(ans) == 0:
    print('UNRESTORABLE')
else:
    ans.sort()
    print(ans[0])

Measured memory_bytes: 3064
//
// Created on 2020/01/19.
//
//#include <bits/stdc++.h>
#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 <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;


pair<int,int> get_p(int n){
    int a = n;
    while (a/10){
        a /= 10;
    }
    return {a,n%10};
}

int main() {
    int n;
    ll ans = 0;
    cin>>n;
    map<pair<int,int>,int>mp;

    for (int k = 1; k <= n; ++k) {
        mp[get_p(k)] ++;
    }
    for (int i = 1; i <= n; ++i) {
        pair<int,int> temp = get_p(i);
        pair<int,int> temp2 = {temp.second,temp.first};
        ans += mp[temp2];
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 4*1e18;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

bool o(string s){
  int n = s.length();
  bool ret = true;
  rep(i,n/2){
    ret = ret && (s[i] == s[n-i-1]);
  }
  return ret;
}

signed main(){
  double l;cin>>l;
  cout << fixed << setprecision(10) << powl(l/3, 3) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

char s[1000];
int n, a, b, sub;

int main()
{
    while(~scanf("%d%s", &n, &s)){
        a=b=sub=0;
        for(int i=0;i<n;i++){
            if(s[i]=='(')a++;
            else if(a)a--;
        }
        for(int i=n-1;i>=0;i--){
            if(s[i]==')')b++;
            else if(b)b--;
        }
        for(int i=0;i<b;i++)putchar('(');
        printf("%s", s);
        for(int i=0;i<a;i++)putchar(')');
        printf("\n");
    }
    return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  VI a(n);
  REP(i, n) cin >> a[i];

  REP(i, n) FOR(j, i+1, n) {
    if(abs(a[i]-a[j])%(n-1) == 0) {
      cout << a[i] << " " << a[j] << endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 3232
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim()
{
  int u, mincost;
  int d[MAX], p[MAX], color[MAX];

  // 初期化
  for (int i = 0; i < n; i++)
  {
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  // 頂点0から始めるため
  d[0] = 0;

  while (true)
  {
    mincost = INFTY;
    u = -1;
    // 初回は頂点0が選ばれる
    // 隣接する頂点を探す処理で、重みdが設定されていれば
    // 最小コストの頂点uが選ばれる
    for (int i = 0; i < n; i++)
    {
      if (mincost > d[i] && color[i] != BLACK)
      {
        u = i;
        mincost = d[i];
      }
    }

    if (u == -1)
    {
      break;
    }

    // 最小全域木の頂点に選ばれた
    color[u] = BLACK;

    for (int v = 0; v < n; v++)
    {
      if (color[v] != BLACK && M[u][v] != INFTY)
      {
        // 最小全域木に選ばれていないかつ、uに対して辺がある頂点v
        if (d[v] > M[u][v])
        {
          // 頂点uとvの辺の重みに更新する
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }

  // 最小全域木の辺の重みの総和
  int sum = 0;
  for (int i = 0; i < n; i++)
  {
    if (p[i] != -1)
    {
      sum += M[i][p[i]];
    }
  }

  return sum;
}

int main()
{
  cin >> n;

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      int e;
      cin >> e;
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }

  cout << prim() << endl;

  return 0;
}


Measured memory_bytes: 3120
class SegmentTree
  ROOT = 1
  private_constant :ROOT

  attr_reader :size

  def initialize(n, x = 0)
    @size = 1
    @size *= 2 while @size < n
    @sum = Array.new(2 * @size){x}
  end

  def update(i, v)
    i += @size
    @sum[i] = v
    until i == ROOT
      i = i / 2
      @sum[i] = @sum[2*i].gcd(@sum[2*i+1])
    end
  end

  def sum(l, r)
    sum_dfs(l, r, ROOT, 0, @size)
  end
  def sum_dfs(a, b, i, l, r)
    return 0       if b <= l || r <= a
    return @sum[i] if a <= l && r <= b
    sum_dfs(a, b, 2*i, l, (l+r)/2).gcd(sum_dfs(a, b, 2*i+1, (l+r)/2, r))
  end
end

N=gets.to_i
A=gets.split.map &:to_i

segtree = SegmentTree.new(N)
A.each.with_index do |a, i|
  segtree.update(i, a)
end
res = 0
N.times do |i|
  l = i.zero? ? 0 : segtree.sum(0, i)
  r = i+1==N  ? 0 : segtree.sum(i+1, N)
  d = l.gcd(r)
  res = [res, d].max
end
p res


Measured memory_bytes: 14860
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(){
 
    string s;
   int N[3];
    
    cin >> s ;
    for(int i = 0;i<=2;i++){
    N[i] = s[i];
    }    
    if(N[0] == N[2]){
    cout << "Yes" << endl;}
    else {cout << "No" << endl;}
    
    return 0;

}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc114

#define SUBMIT

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

int main() {
    int n;
    cin >> n;
    cout << ((n == 3 || n == 5 || n == 7) ? "YES" : "NO") << endl;
    return 0;
}

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

void work()
{
    string s;
    cin >>s;
    for(int i = 0; i < s.size(); i++)
    {
        s[i] = '0' + (10 - (s[i] - '0'));
    }
    cout <<s <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef complex<double> base;
ll mod=1e9+7;
double eps=1e-9;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ll pexp(ll x, ll y){if(y<0) return 0; ll ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll fac[1111111];
ll invfac[1111111];
ll n, ans, add;

ll ncr(ll u, ll v)
{
	if(u<0 || v<0 || u<v) return 0;
	ll ret=fac[u];
	ret=(ret*invfac[v])%mod;
	ret=(ret*invfac[u-v])%mod;
	return ret;
}

int main(void)
{
	cin>>n; fac[0]=1; invfac[0]=1; ll i, j;
	for(i=1 ; i<=n ; i++)
	{
		fac[i]=(i*fac[i-1])%mod;
		invfac[i]=exp(fac[i],mod-2);
	}
	ans+=fac[n-1];
	for(i=1 ; i<=n-1 ; i++)
	{
		add=ncr(n-1,i)-ncr(i-1,n-2-i+1);
		add=(add+mod)%mod;
		add=(add*fac[n-1-i])%mod;
		add=(add*fac[i])%mod;
		ans=(ans+add); if(ans>=mod) ans-=mod;
	}	
	ans%=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 16768
import java.util.Scanner;

public class Main{
  static int n, m;
  static int[][] a;

  static final boolean DEBUG = false;

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

    n = sc.nextInt();
    m = sc.nextInt();
    a = new int[n][m];
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
        a[i][j] = sc.nextInt() - 1;
      }
    }

    int[] count = new int[m];
    for(int i = 0; i < n; i++){
      count[a[i][0]]++;
    }

    int min = 0;
    int maxi = -1;
    for(int i = 0; i < m; i++){
      if(min < count[i]){
        maxi = i;
        min = count[i];
      }
    }

    if(DEBUG){
      System.out.println("min = " + min);
    }

    boolean[][] check = new boolean[n][m];
    for(int i = 0; i < n; i++){
      check[i][0] = true;
    }

    boolean[] removed = new boolean[m];
    for(int i = 0; i < m - 1; i++){
      for(int j = 0; j < n; j++){
        for(int k = 0; k < m; k++){
          if(check[j][k] && a[j][k] == maxi){
            check[j][k] = false;
            boolean renew = false;
            for(int l = k - 1; l >= 0; l--){
              if(!removed[a[j][l]]){
                check[j][l] = true;
                renew = true;
                break;
              }
            }
            if(!renew){
              for(int l = k + 1; l < m; l++){
                if(!removed[a[j][l]]){
                  check[j][l] = true;
                  break;
                }
              }
            }
            break;
          }
        }
      }
      removed[maxi] = true;
      count = new int[m];
      for(int j = 0; j < n; j++){
        for(int k = 0; k < m; k++){
          if(check[j][k]){
            count[a[j][k]]++;
          }
        }
      }
      int lmin = 0;
      maxi = -1;
      for(int j = 0; j < m; j++){
        if(lmin < count[j]){
          maxi = j;
          lmin = count[j];
        }
      }
      if(DEBUG){
        System.out.println("lmin = " + lmin);
      }
      min = Math.min(min, lmin);
    }

    System.out.println(Math.max(1, min));
  }
}

Measured memory_bytes: 50416
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int A[5] = { 0 }, B[5] = { 0 }, C[5] ={0}, a = 0, b = 0,c=0;
	for (int i = 0; i < 5; i++)
	{
		cin >> A[i];
		if (A[i] % 10 != 0)
		{
			B[i] = A[i] / 10 + 1;
			C[i] = A[i] % 10;
		}
		else
		{
			B[i] = A[i] / 10;
			c = c + 1;
		}
	}
	a = C[0];
	for (int i = 0; i < 5; i++)
	{
		if (C[i] != 0) 
		{
			a = min(C[i], a);
		}
	}
	for (int i = 0; i < 5; i++)
	{
		b = B[i] * 10 + b;
	}
	b = b - 10 + a;
	if (c == 5)
	{
		for (int i = 0; i < 5; i++)
		{
			a = a+A[i];
		}
		cout << a;
	}
	else
	{
		cout << b;
	}
}

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

using namespace std;

int main(){
  int N, M, a[51], b[51], ans[51] = {0};

  cin >> N >> M;
  for(int i = 0; i < M; i++) cin >> a[i] >> b[i];

  for(int i = 0; i < M; i++){
    ans[a[i]]++;
    ans[b[i]]++;
  }

  for (int i = 1; i <= N; i++) cout << ans[i] << endl;

	return 0;
}


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

int findSumOfDigits(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;
    for (int i = 1; i <= N; i++) {
        int sum = findSumOfDigits(i);
        if (sum >= A && sum <= B) {
            total += i;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 256
using namespace std;
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define sec setprecision
#define Pair pair<int,int>
#define _CRT_SECURE_NO_WARNINGS
#define veccin(a,n) rip(i,n)cin>>a[i]; 
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x)%mod , n / 2)%mod);
	else
		return (x * pow(x, n - 1))%mod;
}
int main() {
	int n;
	cin >> n;
	vector<ld>a(n);
	veccin(a,n);
	ld ans = 0;
	rip(i, n)ans += 1 / a[i];
	ans = 1 / ans;
	cout << fixed<<sec(15)<<ans << endl;
}

Measured memory_bytes: 3824
# -*- coding: utf-8 -*-
N = int(input())

num_list = [1]

temp = 0
bases = [6,9]
for base in bases:
    for i in range(1,10):
        temp = base ** i
        if temp < 100000:
            num_list.append(temp)
        else:
            break

num_list.sort()
num_list.reverse()

dp = [0 for i in range(N+1)]
for i in range(1,N+1):
    if i == 1:
        dp[i] = 1
    else:
        temp1 = 100000
        for num in num_list:
            if i % num == 0:
                temp1 = i // num
                break

        temp2_list = [100000]
        # for j in range(1,i//2):
        for j in num_list:
            if j < i:
                temp2_list.append( dp[i-j] + dp[j])
        dp[i] = min([temp1,min(temp2_list)])


print(dp[N])


Measured memory_bytes: 3992
/*
   AOJ 1392 Shortest Common Non-Subsequence
   2019.3.27 bal4u
   オートマトンで状態遷移図をつくり、BFSで初期状態を表す頂点
   から、最終状態を表す頂点への最短経路を求める。
   計算量はO(MN)。M、Nはそれぞれの文字列の長さ。
   オートマトンで解く問題が多くないが、0,1だけの文字列等には使える可能性が高い。
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//// 入力処理
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int ins(char *s)  // 文字列の入力　スペース以下の文字で終了
{
	char *p = s;
	do *s = gc();
	while (*s++ > ' ');
	*--s = 0;
	return s - p;
}


//// 本問題関連
#define QMAX 10000000
#define MAX 4005       // 文字列の最大長さ
#define ONE  (1<<30)
#define SFT 12
#define MASK ((1<<12)-1)

typedef struct { int n; int s, t; } QUE;
QUE que[QMAX+5]; int top, end;
char S[MAX], T[MAX];   // それぞれの入力文字列
char ans[MAX];         // 答えを格納する
int vis[MAX][MAX];     // 状態の記録用

void dfs()
{
	int s, t, n, s0, s1, t0, t1;

	que[0].n = que[0].s = que[0].t = 0;
	top = 0, end = 1;
	while (top != end) {
		n = que[top].n, s = que[top].s, t = que[top].t;
		top++;  // if (++top == QMAX) top = 0;

		if (S[s] == 0 && T[t] == 0) break;   // 成功

		s0 = s1 = s, t0 = t1 = t;

		while (S[s0] && S[s0++] == '1');   // S文字列上の、次の 非'1'文字 まで
		while (S[s1] && S[s1++] == '0');   // S文字列上の、次の 非'0'文字 まで
		while (T[t0] && T[t0++] == '1');   // T文字列上の、次の 非'1'文字 まで
		while (T[t1] && T[t1++] == '0');   // T文字列上の、次の 非'0'文字 まで

		// '0'による遷移の記録
		if (!vis[s0][t0]) {
			vis[s0][t0] = (s << SFT) | t;
			que[end].n = n + 1, que[end].s = s0, que[end].t = t0;
			end++;  // if (++end == QMAX) end = 0;
		}

		// '1'による遷移の記録
		if (!vis[s1][t1]) {
			vis[s1][t1] = (s << SFT) | t | ONE;
			que[end].n = n + 1, que[end].s = s1, que[end].t = t1;
			end++;  // if (++end == QMAX) end = 0;
		}
	}

	// 最短遷移のパスを復元し、解答とする。逆順に注意
	ans[n] = 0;
	do {
		int st = vis[s][t];
		s = (st >> SFT) & MASK, t = st & MASK;
		ans[--n] = '0';
		if (st & ONE) ans[n]++;
	} while (s | t);
}

int main()
{
	int w;

	w = ins(S), S[w] = 'X', S[w + 1] = 0;
	w = ins(T), T[w] = 'X', T[w + 1] = 0;
	dfs();
	printf("%s\n", ans);
	return 0;
}


Measured memory_bytes: 97684
K=int(input())
if K%2==0 or K%5==0:
  print(-1)
else:
  s=7
  i=1
  if s%K==0:
    print(i)
  while s%K!=0:
    i+=1
    s = (s%K)*10+7
    if s%K==0:
      print(i)
      exit()

Measured memory_bytes: 9180
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#define ll long long
using namespace std;

int n, t, ans, a[100000];
int mina[100000], maxa;

int main() {
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mina[i] = 1000000005;
		maxa = 0;
	}
	ans = 0;
	mina[0] = a[0];
	for (int i = 1; i < n; i++) {
		mina[i] = min(mina[i-1], a[i]);
		maxa = max(maxa, a[i] - mina[i]);
	}
	for (int i = 0; i < n; i++) {
		if (maxa == a[i] - mina[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    int a, b, c;
    scanf ("%d %d %d", &a, &b, &c);
    printf("%d\n", min(min(a+b, b+c), a+c));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll A, B, C, K;

int main()
{
  //  freopen("test.in","r",stdin);

    cin >> A >> B >> C >> K;
    if (K & 1)
        cout << B - A;
    else
        cout << A - B;


    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 = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int two = 0, one = 0;
    if (S[0] == 'L')
        one++;
    if (S[N - 1] == 'R')
        one++;
    FOR(i, 0, N - 1) {
        if (S[i] == 'R' && S[i + 1] == 'L') {
            two++;
        }
    }

    if (two + one > K) {
        if (K <= two) {
            two = two - K;
        } else {
            K = K - two;
            two = 0;
            one = one - K;
        }
    } else {
        two = 0;
        one = 1;
    }

    cout << N - two * 2 - one << "\n";

    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <map>

using namespace std;

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

static const char *INSERT = "insert";
static const char *FIND = "find";

int main() {
    int n, strMax = 12;
    scanf("%d", &n);
    char action[strMax], key[strMax];

    map<string, bool> data;
    rep(i, n) {
        scanf("%s %s", action, key);
        if (strcmp(INSERT, action) == 0) {
            data[key] = true;
        } else if (strcmp(FIND, action) == 0) {
            if (data[key]) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 47152