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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long int
#define mod (long long)(1e9+7)
#define endl '\n'
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi (acos(-1))
#define F first
#define S second

ll fp(ll n , ll p )
{
    if(p==0)
        return 1;
    if(p==1)
        return n ;
    ll res = fp(n,p/2);
    res=((res)*(res)) ;
    if(p%2)
        res=(res*n) ;
    return res ;
}



    int n , q , a , b , ans[200005];
int main()
{
    ENGZ;

    set<int> st;
    map<int,int> mp;
    cin>>n >>q ;
    vector< pair<int,pair<int,int> > > v(n) ;
    for(int i=0 ;i<n ; i++)
    {
        cin>>v[i].S.F >>v[i].S.S >>v[i].F ;
    }
    for(int i=0 ; i<q ; i++)
    {
        cin>>a ;
        st.insert(a);
        mp[a] = i;
    }
    sort(v.begin(),v.end());
    for(int i=0 ; i<n ; i++)
    {
        int l = v[i].S.F - v[i].F ;
        int r = v[i].S.S - v[i].F - 1 ;

        while(1)
        {
            auto it = st.lower_bound(l);
            if(it == st.end())break;

            b = *it ;
            if(b > r)break;

            st.erase(b);
            int tmp = mp[b] ;
            ans[tmp] = v[i].F ;

        }
    }
   // cout<<"-----------------------" <<endl ;
    for(int i=0 ; i<q ; i++)
    {
        if(ans[i] == 0)
            cout<<-1 <<endl ;
        else
        cout<<ans[i] <<endl ;

    }
    return 0;
}


Measured memory_bytes: 24980
using System;

class Atcoder132
{
    public static void Main()
    {
        string input = Console.ReadLine();
        string[] vector = { input[0].ToString(), input[1].ToString(), input[2].ToString(), input[3].ToString() };

        Array.Sort(vector);

        if (vector[0] == vector[1] && vector[2] == vector[3] && vector[1] != vector[2])
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 11360
#include<cstdio>
using namespace std;
int n,k,x,i,a,b;
int main()
{
	x=1;
	scanf("%d%d",&n,&k);
	for (i=1;i<=n;i++)
	{
		a=x+k;
		b=2*x;
		if (a<b) x=a;
		else x=b;
	}
	printf("%d\n",x);
}

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

int main() {
	int h, n, sum;
	scanf("%d %d", &h, &n);
	sum = 0;
	for (int i = 0; i < n; ++ i) {
		int a; scanf("%d", &a);
		sum += a;
	}
	puts(sum >= h ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
import math as m

def judge_prime(num):
    isPrime = [True]*(num+1)
    isPrime[0] = False
    isPrime[1] = False
    border = m.sqrt(num)
    i = 2
    while i <= border:
        if isPrime[i]:
            j = i*2
            while j <= num:
                isPrime[j] = False
                j += i
        i += 1
        
    #prime_list = []
    like2017_list = []
    for prime in range(3,num+1,2):
#        if isPrime[prime]:
#            prime_list.append(prime)
        if isPrime[int(prime)] and isPrime[int((prime+1)/2)]:
            like2017_list.append(prime)
        
    return like2017_list
        
    
    
def main():
    #input
#    Q1 = 1
#    LR1 = [[3,7]]
#    
#    Q2 = 4
#    LR2 = [[13, 13],
#                [7, 11],
#                [7, 11],
#                [2017, 2017]]
#    
#    
#    Q = Q2
#    LR = LR2
    
    Q = int(input())
    LR = []
    for i in range(Q):
        LR.append(list(map(int, input().split())))

    # 1. find 2017-like number
    MAX_Q = 10**5
    
    like2017_list = judge_prime(MAX_Q)

    
    # judge
    csum = [0]*(MAX_Q+1)
    i = 0
    cnt = 0
    for like2017 in like2017_list:
        while i < like2017:
            csum[i] = cnt
            i += 1
        cnt += 1
    for i in range(like2017_list[-1], MAX_Q+1):
        csum[i] = cnt
        
    
    for i in range(Q):
        print(csum[LR[i][1]] - csum[LR[i][0]-1])


    
if __name__ == "__main__":
    main()

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


#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ll long long


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

    int n;

    cin >> n;

    cout << (n % 2 == 0 ? n : (ll)n * 2) << endl;

    return 0;
}


Measured memory_bytes: 256
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a, b = inl()
if a * b % 2 ==0:
    print('Even')
else:print('Odd')



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


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n, Q; cin >> n >> Q;
	vector<LL> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];

	for (int i = 0; i < Q; i++) {
		LL x; cin >> x;

		LL res = 0;

		int right = 0;

		LL sum = 0;

		for (int left = 0; left < n; left++) {
			while (right < n && sum + a[right] <= x) {
				sum += a[right];
				right++;
			}

			res += (right - left);

			if (right == left)++right;
			else sum -= a[left];
		}

		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 3576
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(N: int, A: "List[int]"):
    if len(set(A))==N:
        print(YES)
    else:
        print(NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


string str;
set<vint> se;

int main() {
    se.clear();
    
    int j[4];
    for (int i = 1; i <= 9; ++i) {
        for (j[0] = 1; j[0] <= 16; ++j[0]) {
            for (j[1] = 1; j[1] <= 16; ++j[1]) {
                for (j[2] = 1; j[2] <= 16; ++j[2]) {
                    for (j[3] = 1; j[3] <= 16; ++j[3]) {
                        vint tmp(9, 0);
                        tmp[i-1] = 2;
                        for (int k = 0; k < 4; ++k) {
                            if (j[k] <= 9) tmp[j[k]-1] += 3;
                            else {
                                tmp[j[k]-10]++;
                                tmp[j[k]-9]++;
                                tmp[j[k]-8]++;
                            }
                        }
                        bool check = true;
                        for (int l = 0; l < 9; ++l) if (tmp[l] > 4) check = false;
                        if (check) se.insert(tmp);
                    }
                }
            }
        }
    }
    
    while (cin >> str) {
        vint vec(9, 0);
        for (int i = 0; i < str.size(); ++i) vec[ str[i]-'1' ]++;
        vint res;
        for (int add = 1; add <= 9; ++add) {
            vint tmp = vec;
            tmp[add-1]++;
            if (se.count(tmp)) res.PB(add);
        }
        
        if (res.size() == 0) cout << "0";
        else {
            for (int i = 0; i < res.size(); ++i) {
                cout << res[i];
                if (i != res.size()-1) cout << " ";
            }
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2660
x, y = map(int, input().split())

grp_dict = {
    1: 'A',
    2: 'C',
    3: 'A',
    4: 'B',
    5: 'A',
    6: 'B',
    7: 'A',
    8: 'A',
    9: 'B',
    10: 'A',
    11: 'B',
    12: 'A',
}

print('Yes' if grp_dict[x] == grp_dict[y] else 'No')


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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> red(a);
    for (int i = 0; i < a; i++) {
        cin >> red[i];
    }
    sort(red.begin(), red.end(), greater<int> ());
    vector<int> green(b);
    for (int i = 0; i < b; i++) {
        cin >> green[i];
    }
    sort(green.begin(), green.end(), greater<int> ());
    vector<int> col(c);
    for (int i = 0; i < c; i++) {
        cin >> col[i];
    }
    sort(col.begin(), col.end(), greater<int> ());
    vector<int> ap;
    for (int i = 0; i < x; i++) {
        ap.push_back(red[i]);
    }
    for (int i = 0; i < y; i++) {
        ap.push_back(green[i]);
    }
    for (int i = 0; i < c; i++) {
        ap.push_back(col[i]);
    }
    sort(ap.begin(), ap.end(), greater<int> ());
    long long sum = 0;
    for (int i = 0; i < x + y; i++) {
        sum += 1LL * ap[i];
    }
    cout << sum << '\n';
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

int n;
bool b[500][500];
int blank[500];
int cnt = 0;

int main(){
    I(n);
    bool end = true;
    rep(i,n) rep(j,n){
        char tmp; cin >> tmp;
        if(tmp == '.') b[i][j] = false;
        else b[i][j] = true;
        if(b[i][j]) end = false;
    }
    if(end){
        cout << -1 << endl;
        return 0;
    }
    int ans = INF;
    rep(j,n){
        bool ok = true;
        rep(i,n){
            if(!b[i][j]){
                ok = false;
                break;
            }
        }
        if(!ok){
            blank[j] = 1;
            cnt++;
        }
    }
    rep(i,n){
        int ana = 0;
        rep(j,n){
            if(!b[i][j]){
                ana++;
            }
        }
        if(ana == 0){
            ans = min(ans,cnt);
            continue;
        }
        bool ok = false;
        rep(j,n){
            if(b[j][i]){
                ok = true;
                break;
            }
        }
        if(ok){
            ans = min(ans,ana+cnt);
        } else ans = min(ans,ana+cnt+1);
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
}
































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

public class Main{
	static Scanner sc =  new java.util.Scanner(System.in);

	public static void main(String[] args) {
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
				
		int [] array = new int [] {a,b,c,d,e};
		Arrays.sort(array);
		
		for ( int i = 4; i >= 1 ; i--){
			System.out.print(array[i] + " ");
		}
		System.out.println(array[0]);
		
	}

}

Measured memory_bytes: 26340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
const int inf=1e9+1;
template <class T>
void print(T x){cout << x << '\n';}


const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, std::string S){
  REP(i, A+B+1){
    if(i==A){
      if(S[i]!='-') goto NO;
    }else{
      if(S[i]<'0' || '9'<S[i]) goto NO;
    }
  }

 YES:
  print(YES);
  return;

 NO:
  print(NO);
  return;

}

int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  std::string S;
  std::cin >> S;
  solve(A, B, S);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long T;
  cin >> n >> T;
  vector<long long> t(n);
  for(int i=0;i<n;i++){
    cin >> t[i];
  }
  long long sum=0;
  for(int i=0;i<n-1;i++){
    if(t[i+1]-t[i]>T){
      sum+=T;
    }
    else{
      sum+=t[i+1]-t[i];
    }
  }
  cout << sum+T << endl;
}

Measured memory_bytes: 1792
#include <cstdio>

#define INT unsigned long

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

INT lcm(INT a, INT b)
{
  INT tmp = gcd(a, b);
  /* gcd(a, b) * lcm(a, b) = a * b */
  return tmp ? a * b / tmp : 0;
}

int main(void)
{
  INT a, b;
  
  while (std::scanf("%ld %ld\n", &a, &b) != EOF) {
    std::printf("%ld %ld\n", gcd(a, b), lcm(a, b));
  }

  return 0;
}



Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A[100];
  int n,b,c=0;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> A[i];
  int f = 1;
  while(f) {
    f = 0;
    for(int j = n-1; j >= 1; j--) {
      if(A[j] < A[j-1]) {
        b = A[j];
        A[j] = A[j-1];
        A[j-1] = b;
        c++;
        f = 1;
      }
    }
  }


  for(int i = 0; i < n; i++) {
    cout << A[i];
    if(i == n-1) cout << endl;
    else cout << " ";
  }
    cout << c << endl;
  return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int func(char ch){
	if(ch == 'q' || ch == 'w' || ch == 'e' || ch == 'r' || ch == 't' || ch == 'a' || ch == 's' || ch == 'd' || ch == 'f' || ch == 'g' ||
			ch == 'z' || ch == 'x' || ch == 'c' || ch == 'v' || ch == 'b'){
		return 1;
	}else{
		return 2;
	}
}


int main(){

	int count;
	char pre,buf[33];

	while(true){
		scanf("%s",buf);
		if(buf[0] == '#')break;

		count = 0;
		pre = buf[0];

		for(int i = 1; buf[i] != '\0'; i++){
			if(func(pre) != func(buf[i]))count++;
			pre = buf[i];
		}

		printf("%d\n",count);
	}
}

Measured memory_bytes: 2720
#include <iostream>

using namespace std;

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

    if(a>b){
            d=a;
            a=b;
            b=d;
    }
    if (b>c){
        d=b;
        b=c;
        c=d;
    }
    if(a>b)
    {   d=a;
        a=b;
        b=d;


    } cout << a << " "<< b << " " << c << endl;
    return 0;
}



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

#define rep(i,a,b) for(int i=int(a),nn=int(b);i<=nn;++i) 
#define vep(i,a,b) for(int i=int(a),nn=int(b);i>=nn;--i) 
#define xep(i,b) for(int i=0,nn=int(b);i<nn;++i) 

int main() { 
	int n,m,a[55],b[55],c[55],d[55]; 
	
	cin>>n>>m; 
	
	rep(i,1,n) cin>>a[i]>>b[i];
	rep(i,1,m) cin>>c[i]>>d[i]; 
	
	rep(i,1,n) { int ds=2000000000,as=0; 
		rep(j,1,m) if (abs(c[j]-a[i])+abs(d[j]-b[i])<ds) 
			as=j, ds=abs(c[j]-a[i])+abs(d[j]-b[i]); 
		cout<<as<<endl;
	}
	return 0; 
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			int b;
			for (b = 0; !((i ^ j) & (1 << b)); b++) { }
			cout << b+1 << " \n"[j == N-1];
		}
	}

	return 0;
}


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

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

#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 IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
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<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

int c[505], s[505], f[505];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n-1) cin >> c[i] >> s[i] >> f[i];

  // 駅i→駅i+1 c[i]秒かかる s[i] + k*f[i] 秒目に発車 s[i]%f[i]==0
  REP(i, n) {
    int t = 0;
    FOR(j, i, n-1) {
      // jからj+1に移動
      // t以上で最も早く到達する電車に乗る
      // t >= s[j] && t%f[j] == 0
      int k = max(0.0, ceil((double)(t-s[j])/f[j]));
      t = s[j] + k*f[j];
      t += c[j];
      // cerr << "j:" << j << " " << t << endl;
    }
    cout << t << endl;
  }

  return 0;
}


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


void solve(long long N, std::vector<long long> l, std::vector<long long> r){
  long long acc = 0;

  for(long long i = 0; i < N; i++){
    acc += abs(l[i] - r[i]) + 1;
  }

  cout << acc << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> l(N);
  std::vector<long long> r(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&l[i]);
    scanf("%lld",&r[i]);
  }
    solve(N, std::move(l), std::move(r));
    return 0;
}


Measured memory_bytes: 3704
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	class Pair{
		public int A,B;
		public Pair(int a, int b){
			A = a; 
			B = b;
		}
	}
	
	public void Solve(){
		List<Pair> P = new List<Pair>();
		for(int j=0;j<N;j++){
			P.Add(new Pair(A[j], B[j]));
		}
		P.Sort((p, q) => p.A.CompareTo(q.A));
		
		
		int TT = T + 3010;
		long[] dp = new long[TT + 1];
		for(int i=0;i<TT+1;i++) dp[i] = -1;
		dp[0] = 0;
		for(int i=0;i<N;i++){
			for(int j=TT-1;j>=0;j--){
				if(dp[j] == -1) continue;
				if(j >= T) continue;
				int nj = j + P[i].A;
				dp[nj] = Math.Max(dp[nj], dp[j] + P[i].B);
			}
//Console.WriteLine(String.Join(" ",dp));
		}
		Console.WriteLine(dp.Max());
		
		
		
		
		
	}
	int N,T;
	int[] A,B;
	public Sol(){
		var d = ria();
		N = d[0]; T = d[1];
		A = new int[N];
		B = new int[N];
		for(int i=0;i<N;i++){
			d = ria();
			A[i] = d[0]; B[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13376
s = input()
maxs = 0
cnt = 0
for i, x in enumerate(s):
    if x in ['A', 'C', 'G', 'T']:
        cnt += 1
    else:
        if cnt > 0:
            maxs = max(maxs, cnt)
            cnt = 0
if cnt > 0:
    maxs = max(maxs, cnt)
print(maxs)

Measured memory_bytes: 38384
s = input()
q = int(input())
querys = [list(map(str,input().split())) for _ in range(q)]

direction = 0
mae = ""
ato = ""

for i,query in enumerate(querys):
    if query[0] == "1":
        direction = (direction+1)%2
    else:
        if (int(query[1])-1 + direction)%2 == 0:
            mae += query[2]
        else:
            ato += query[2]

s = mae[::-1] + s
s = s + ato

if direction == 1:
    print(s[::-1])
else:
    print(s)

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

int main() {
    int a, b;  cin >> a >> b;
    if (a <= b)  cout << a << endl;
    else  cout << a-1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main( void )
{
  while( 1 ){
    int n,r,p,c;
    int d[2][55];
    cin >> n >> r;
    if( n == 0 ) break;
    for( int i=0; i<n; i++ ){
      d[0][i] = n-i;
    }
    for( int i=0; i<r; i++ ){
      cin >> p >> c;
      int k = i & 1;
      for( int j=0; j<c; j++ ){
        d[1-k][j] = d[k][j+p-1];
      }
      for( int j=0; j<p-1; j++ ){
        d[1-k][j+c] = d[k][j];
      }
      for( int j=c+p-1; j<n; j++ ){
        d[1-k][j] = d[k][j];
      }
    }
    cout << d[r&1][0] << endl;
  }
}

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

using namespace std;

string shorten(const string &s) {
  string res;
  for (const char i : s) {
    if (res.back() == '(' && i == ')') res.pop_back();
    else res.push_back(i);
  }
  return res;
}

struct brace {
  int left;
  int right;

  brace operator+(const brace &other) {
    int facing = min(this->right, other.left);
    return brace{this->left + other.left - facing, this->right - facing + other.right};
  }
};

bool operator<(const brace a, const brace b) {
  return a.right > b.right;
}

brace toBrace(const string &s) {
  brace res = brace{0, 0};
  for (char i : s) (i == ')' ? res.left : res.right)++;
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<brace> s;
  for (int i = 0; i < n; ++i) {
    string S;
    cin >> S;
    S = shorten(S);
    if (S != "") s.push_back(toBrace(S));
  }
  brace rightOpen{0, 0};
  brace leftOpen{0, 0};
  vector<brace> bothOpen;
  for (const auto &i : s) {
    if (i.left == 0) rightOpen.right += i.right;
    else if (i.right == 0) leftOpen.left += i.left;
    else bothOpen.push_back(i);
  }
  sort(bothOpen.begin(), bothOpen.end());
  int cnt = 0;
  for (int i = 0; i < bothOpen.size(); ++i) {
    if (cnt < i) break;
    for (auto &j : bothOpen) {
      if (j.left <= rightOpen.right) {
        rightOpen = rightOpen + j;
        j.left = 1145141919;
        cnt++;
        break;
      }
    }
  }
  rightOpen = rightOpen + leftOpen;
  puts(cnt == bothOpen.size() && rightOpen.left == 0 && rightOpen.right == 0 ? "Yes" : "No");
}


Measured memory_bytes: 11588
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
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; }

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    for (auto ss : s) {
        cout << ss;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  double p;
  int n;
  cin>>n;
  
  p=((double)n -n/2 )/(double)n;
  
  cout << p << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 256
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 20)

int a[MAXN];
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ret = 0;
	int mmin = MAXN;
	for (int i = 0; i < n; i++) {
		if (mmin > a[i]) {
			ret++;
		}
		mmin = min(mmin, a[i]);
	}
	cout << ret << endl;
	return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n, 100001), b(n-1);
	for(int i = 0; i < n-1; i++){
		cin >> b[i];
	}
	for(int i = 0; i < n-1; i++){
		a[i] = min(a[i], b[i]);
		a[i+1] = min(a[i+1], b[i]);
	}
	int sol = 0;
	for(int i = 0; i < n; i++){
		sol += a[i];
	}
	cout << sol << "\n";
	return 0;
}


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

int n, mn = 205;
string s, t;
int main()
{
    int i, j;
    cin >> n >> s >> t;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (s[i + j] != t[j]) break;
        }
        mn = min(mn, n + n - j);
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
long long int N, K;
vector<long long int> A;
vector<long long int> B;
vector<long long int> Q;
int bit[40] = { 0 };
void input()
{
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		long long int x;
		cin >> x;
		A.push_back(x);
	}
}
void solve()
{
	B = A;
	for (int i = 0; i < 40; i++)
	{
		int a = 0;
		for (int j = 0; j < N; j++)
		{
			if (A[j] % 2 == 1)
			{
				a++;
			}
			A[j] = A[j] / 2;
		}
		if (a < (N + 1) / 2)
		{
			bit[i]++;
		}
	}
	long long int mx = 0;
	for (int i = 39; i >= 0; i--)
	{
		if (mx + bit[i] * pow(2, i) <= K && bit[i]==1)
		{
			long long int res = mx;
			for (int j = i-1; j >= 0; j--)
			{
				res += bit[j] * pow(2, j);
			}
			Q.push_back(res);
			mx = mx + bit[i] * pow(2, i);
		}
	}
Q.push_back(mx);
	long long ans = 0;
	for (int i = 0; i < Q.size(); i++)
	{
		long long int ans1 = 0;
		for (int j = 0; j < B.size(); j++)
		{
			ans1 += B[j] ^ Q[i];
		}
		if (ans1 > ans)
		{
			ans = ans1;
		}
	}
	cout << ans << endl;
}
int main()
{
	input();
	solve();
}


Measured memory_bytes: 1908
# AOJ 1103: Board Arrangements for Concentration Gam...
# Python3 2018.7.14 bal4u

def combi(k):
	global ans
	if k == 9:
		ans += 1
		return
	for y in range(4):
		for x in range(4):
			if arr[y][x]: continue
			arr[y][x] = k
			for i in range(4):
				x2, y2 = x + a[i<<1], y + a[(i<<1)+1]
				if x2 < 0 or x2 >= 4 or y2 < 0 or y2 >= 4 or arr[y2][x2]: continue
				arr[y2][x2] = k
				combi(k+1)
				arr[y2][x2] = 0
			arr[y][x] = 0
			return;

while True:
	a = list(map(int, input().split()))
	if len(a) == 1: break
	arr = [[0 for i in range(4)] for j in range(4)]
	ans = 0
	arr[0][0] = 1
	for i in range(4):
		x, y = a[i<<1], a[(i<<1)+1]
		if x >= 0 and y >= 0:
			arr[y][x] = 1
			combi(2)
			arr[y][x] = 0
	print(ans)



Measured memory_bytes: 5612
using System;
using static System.Console;

namespace abc167
{
    class Program
    {
        static void Main()
        {
            var abck = ReadLine().Split(' ');
            var a = int.Parse(abck[0]);
            var b = int.Parse(abck[1]);
            var c = int.Parse(abck[2]);
            var k = int.Parse(abck[3]);
            var points = 0;
            if (k <= a + b)
            {
                points = Math.Min(k, a);
            }
            else
            {
                points = a - (k - a - b);
            }
            WriteLine(points);
        }
    }
}


Measured memory_bytes: 27464
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}

const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

// coordinate compression
struct X {
  typedef ll T;
  vector<T> d;
  inline void add(T x) { d.pb(x);}
  void init() {
    sort(rng(d));
    d.erase(unique(rng(d)), d.end());
  }
  inline int size() { return sz(d);}
  // inline int operator[](T x) { return lower_bound(rng(d),x)-d.begin();}
  inline int operator[](T x) {
    int res = lower_bound(rng(d),x)-d.begin();
    assert(d[res] == x);
    return res;
  }
};
//

int main() {
  int n, q;
  scanf("%d%d",&n,&q);
  vl as(1,n);
  rep(qi,q) {
    ll a;
    scanf("%lld",&a);
    while (sz(as) && as.back() >= a) as.pop_back();
    as.pb(a);
  }
  set<ll> s;
  s.insert(as.back());
  X xs;
  xs.add(0); xs.add(as.back());
  drep(i,sz(as)-1) {
    ll a = as[i];
    vl sa(1,a);
    while (sz(s)) {
      auto it = s.end(); --it;
      if (*it <= a) break;
      sa.pb(*it%a);
      s.erase(it);
    }
    for (ll na : sa) s.insert(na), xs.add(na);
  }
  xs.init();
  vl d(sz(xs));
  d[xs[as.back()]] = 1;
  int r = sz(d)-1;
  drep(i,sz(as)-1) {
    ll a = as[i];
    while (r >= 0) {
      ll x = xs.d[r];
      if (x <= a) break;
      if (d[r]) {
        d[xs[x%a]] += d[r];
        d[xs[a]] += d[r]*(x/a);
        d[r] = 0;
      }
      --r;
    }
  }
  // cout<<xs.d<<endl;cout<<d<<endl;
  vl ans(n);
  while (r >= 1) {
    ans[xs.d[r]-1] = d[r];
    --r;
  }
  drep(i,n-1) ans[i] += ans[i+1];
  rep(i,n) printf("%lld\n",ans[i]);
  return 0;
}










Measured memory_bytes: 14188
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    cout << (n + 999) / 1000 * 1000 - n;
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	string S;
	cin >> S;
	int Z = S.size();
	int cnt = 0;
	rep(i, Z) {
		if (S[i] == '1') {
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long sum = 0;
		for(int i = 1; i <= N; i++) {
			if(i%3!=0 && i%5!=0)sum += i;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 35768
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
#define MAXN 100000
#define hlq 1000000007

using namespace std;
int a[MAXN+8];
int pow_2_mod(int x)
{
	int ans=1;
	long long t=2;
	while(x)
	{
		if(x&1)
			ans=ans*t%hlq;
		t=t*t%hlq;
		x>>=1;
	}
	return ans;
}
bool chk(int x)
{
	int i;
	if(x&1)
	{
		if(a[1])
			return 0;
		for(i=2;i<=x;i+=2)
			if((a[i]!=i)||(a[i+1]!=i))
				return 0;
		return 1;
	}
	for(i=1;i<=x;i+=2)
		if((a[i]!=i)||(a[i+1]!=i))
			return 0;
	return 1;
}
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",a+i);
	sort(a+1,a+n+1);
	if(chk(n))
		printf("%d",pow_2_mod(n>>1));
	else
		putchar('0');
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static int Calc(int w, List<int[]> xs) {
        var dp = new int[w+1];
        foreach (int[] x in xs) {
            for (int i = 0; i+x[1] <= w; i++) {
                dp[i + x[1]]  = Math.Max(dp[i + x[1]], dp[i] + x[0]);
            }
        }
        return dp.Max();
    }

    static void Main() {
        var nw = ReadInts();
        int n = nw[0], w = nw[1];
        var xs = new List<int[]>();
        for (int i = 0; i < n; i++) {
            xs.Add(ReadInts());
        }

        Console.WriteLine(Calc(w, xs));
    }
}

Measured memory_bytes: 9772
n, k = gets.split.map(&:to_i)

ans = 0

1.upto(n) do |i|
  score = i
  c = 0

  loop do
    break if score >= k
    score *= 2
    c += 1
  end

  p = 0.5 ** c
  ans += p / n
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y,z,ans=1;
  cin>>x>>y>>z;
  while(1){
    if(ans*y+(ans+1)*z > x){
      cout<<(ans-1);
      return 0;
    }
    ans++;
  }
}


Measured memory_bytes: 256
N=int(input())
city=[]
for i in range(N):
    x,y=map(int,input().split())
    city.append((i,x,y))

data=[]
city.sort(key=lambda x:x[1])
for i in range(N-1):
    data.append((city[i][0],city[i+1][0],city[i+1][1]-city[i][1]))
city.sort(key=lambda y:y[2])
for i in range(N-1):
    data.append((city[i][0],city[i+1][0],city[i+1][2]-city[i][2]))
data.sort(key=lambda d:d[2])

idx=[-1]*N
def find(idx,x):
    if idx[x]<0:
        return x
    elif idx[x]>=0:
        idx[x]=find(idx,idx[x])
        return idx[x]

ans=0
for q in range(len(data)):
    i,j,d=data[q]
    iidx=find(idx,i)
    jidx=find(idx,j)
    if iidx==jidx:
        continue
    elif idx[iidx]<=idx[jidx]:
        idx[iidx]+=idx[jidx]
        idx[jidx]=iidx
        ans+=d
    elif idx[iidx]>idx[jidx]:
        idx[jidx]+=idx[iidx]
        idx[iidx]=jidx
        ans+=d
print(ans)

Measured memory_bytes: 46544
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <map>

using namespace std;
using ll = long long int;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	cout << (a + b >= c ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#
import sys
import math
import numpy as np
import itertools
from bisect import bisect_left

# ひとつ入力
n = int(input())

# 空白区切りの数列をリストに代入
l = [int(i) for i in input().split()] 

l=sorted(l)

#print(l)
answer = 0
for i in range(n-1,1,-1):
    for j in range(i-1,0,-1):
        k = bisect_left(l,l[i]-l[j]+1)
        if(l[j]>=l[k]):
            answer += max(j-k,0)
#            print(i,j,k,l[i],l[j],l[k])


print(answer)




Measured memory_bytes: 14400
S = input()
ans = [0] * len(S)

idx = []
for i in range(len(S)-1):
    s1, s2 = S[i], S[i+1]
    if s1 == 'R' and s2 == 'L':
        idx.append(i)
        ans[i] += 1
        ans[i+1] += 1

for i in idx:
    if i != 0:
        counter = 0
        for j in range(i-1,-1,-1):
            if S[j] == 'L':
                break
            counter += 1
        ans[i] += counter//2
        ans[i+1] += counter//2
        ans[i+1] += counter % 2

    if i+1 != len(S) - 1:
        counter = 0
        for j in range(i+2, len(S)):
            if S[j] == 'R':
                break
            counter += 1
        ans[i] += counter//2
        ans[i+1] += counter//2
        ans[i] += counter % 2

print(*ans)

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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int maxn;
    long[] frac,inv;
    long mod = 1000000000+7;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    String solve() throws IOException {
        int[][] a = new int[3][3];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++) a[i][j] = sc.nextInt();
        }
        int n = sc.nextInt();
        boolean[] b = new boolean[105];
        for(int i=0;i<n;i++){
            int t = sc.nextInt();
            b[t] = true;
        }
        // row
        for(int i=0;i<3;i++){
            boolean flag = b[a[i][0]]&&b[a[i][1]]&&b[a[i][2]];
            if(flag) return "Yes";
        }
        // col
        for(int j=0;j<3;j++){
            boolean flag = b[a[0][j]]&&b[a[1][j]]&&b[a[2][j]];
            if(flag) return "Yes";
        }
        // dia
        boolean flag = b[a[0][0]]&&b[a[1][1]]&&b[a[2][2]];
        flag |= b[a[0][2]]&&b[a[1][1]]&&b[a[2][0]];
        return flag?"Yes":"No";

    }
}



Measured memory_bytes: 23764
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=998244353,MAX=1e2+2;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    int a,b,c;
    cin>>a>>b>>c;
    int res=0;
    lp(i,0,100005&&a%2==b%2&&a%2==c%2&&a%2==0){
        int x=b/2+c/2,y=a/2+c/2,z=a/2+b/2;
        a=x,b=y,c=z,res++;
    }
    if(res==100005)
        res=-1;
    cout<<res;
}

Measured memory_bytes: 3612
import sys
input = sys.stdin.readline
from collections import deque


def read():
    N = int(input().strip())
    S = input().strip()
    return N, S


def solve(N, S):
    rank = 0
    q = deque()
    for s in S:
        if rank == 0:
            if s == ")":
                q.appendleft("(")
                q.append(")")
            else:
                q.append("(")
                rank += 1
        else:
            if s == ")":
                q.append(")")
                rank -= 1
            else:
                q.append("(")
                rank += 1
    while rank > 0:
        q.append(")")
        rank -= 1
    return "".join(q)


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 9408
#include<stdio.h>
int main(){
  int i,j,h,w,k,bith,bitw,count=0,sum=0;
  char c[6][6];
  scanf("%d %d %d",&h,&w,&k);
  for(i=0;i<h;i++){
      scanf("%s",c[i]);
  }
  for(bith=0; bith < (1<<h);bith++){
    for(bitw=0; bitw < (1<<w);bitw++){
      count=0;
       for(i=0;i<h;i++){
    	for(j=0;j<w;j++){
     	 if((bith&(1<<i))||(bitw&(1<<j))){}else{
           if(c[i][j]=='#'){count++;}
         }
    	}
	 }
     if(count==k){sum++;}
    }
  }
  printf("%d\n",sum);
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    map<int,int,greater<int>> m;
    rep(i,N) {
        int A;
        cin>>A;
        m[A]++;
    }
    ll a=0,b=0;
    for(auto c : m) {
        if(c.se>=2) {
            a=c.fi;
            m[a]-=2;
            break;
        }
    }
    for(auto c : m) {
        if(c.se>=2) {
            b=c.fi;
            break;
        }
    }
    cout<<a*b<<endl;
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        int N = Integer.parseInt(arr[0]);
        int A = Integer.parseInt(arr[1]);
        int B = Integer.parseInt(arr[2]);
        out.println(Math.min(A, B) + " " + Math.max(A + B - N, 0));
        out.close();
    }
}


Measured memory_bytes: 21332