akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    P((a-c)*(b-d));
    return  0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] p = in.nextIntArray(n);
			Arrays.sort(p);

			int ans = 0;
			for (int i = 0; i < n; i++) {
				ans += p[i];
			}

			ans -= p[n-1] / 2;
			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

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

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

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

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21588
inpl = lambda: list(map(int,input().split()))

def gcd(a, b):
    if a < 0: a = -a
    if b < 0: b = -b
    while b > 0:
        (a, b) = (b, a % b)
    return a

import math
def primes(N):
    P = []
    for i in range(2,N):
        sieve = 1
        for p in P:
            if p*p > i:
                break
            elif i % p == 0:
                sieve = 0
                break
        if sieve == 0:
            continue
        else:
            P.append(i)
    return P

def factorize(n, P=None):
    if P is None:
        P = primes(int(math.sqrt(n))+1)
    factor = []
    power = []
    for p in P:
        if p * p > n:
            break
        elif n % p == 0:
            k = 0
            while n % p == 0:
                n //= p
                k += 1
            factor.append(p)
            power.append(k)
    if n > 1:
        factor.append(n)
        power.append(1)
    return factor, power

A, B = inpl()
C = gcd(A,B)
factor, _ = factorize(C)
print(len(factor)+1)

Measured memory_bytes: 44508
#include<stdio.h>
int main(void)
{
  int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  for(a;a<b+1;a++)
    {
      if(c%a==0)d++;
    }
  printf("%d\n",d);
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
using namespace std;
int main()
{
    long long int i, n, sum, input, min, max;
   
    cin >> n >> input;
    sum = input;
    min = input;
    max = input;
    for(i=2; i<=n; i++)
    {
        cin >> input; 
        sum = sum + input;
        if(input > max)
            max = input;
        else if(input < min)
            min = input;
        
    }
    cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;

int main(){
	int n;
	cin>>n;
	
	if(n==3){
		cout<<"2 5 63"<<endl;
		return 0;
	}
	
	if(n==4){
		cout<<"2 5 20 63"<<endl;
		return 0;
	}
	
	if(n==5){
		cout<<"2 5 20 30 63"<<endl;
		return 0;
	}
	
	long long int sum=0;
	
	vector<int> ans;
	int cnt=0;
	for(int i=2;cnt<n;i++){
		if(i%2==0||i%3==0){
			sum+=i;
			ans.push_back(i);
			cnt++;
		}
	}
	
	if(sum%6==2){
		ans[4]=30000;
	}
	if(sum%6==3){
		ans[5]=30000;
	}
	if(sum%6==5){
		ans[4]=29997;
	}
	
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<" ";
	}
	
	cout<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    string s;
    cin>>n>>s>>q;
    vector<set<int>> idxes(26, set<int>({1<<30}));
    rep(i,s.size()) {
        idxes[s[i]-'a'].insert(i);
    }
    rep(i,q) {
        int num;cin>>num;
        if (num==1) {
            int idx;cin>>idx;
            char c;cin>>c;
            idxes[s[--idx]-'a'].erase(idx);
            s[idx] = c;
            idxes[c-'a'].insert(idx);
        }
        else {
            int l,r;cin>>l>>r;
            l--;r--;
            int cnt = 0;
            rep(i,26) {
                if (idxes[i].empty())continue;
                auto from = *idxes[i].lower_bound(l);
                if(from<=r) cnt++;
            }
            cout << cnt << endl;
        }
    } 
    return 0;
}


Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,k;
int main()
{
	cin>>n>>k;
	if(k<=(n+1)/2)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    string s;
    cin>>s;
    if(s == "RRR"){
        cout<<3<<endl;
    }else if(s == "SRR"  or s == "RRS"){
        cout<<2<<endl;
    }else if(s == "SSS"){
        cout<<0<<endl;
    }else{
        cout<<1<<endl;
    }
}

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

using namespace std;


int main(void){
    int N,M;
    scanf("%d%d",&N,&M);
    vector<int> po;
    for(int i=1;i*i<=M;i++){
        if(M%i==0){po.push_back(i);po.push_back(M/i);}
    }
    int ans=1;
    for(int i=0;i<po.size();i++){
        if(M/po[i]>=N&&ans<po[i])ans=po[i];
    }
    printf("%d",ans);
    return 0;
}


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

using namespace std;


#define loop(i,a,n)     for(int i=a;i<n;i++)
#define rloop(i,n,a)    for(int i=n;i>=a;i--)
#define all(v)          v.begin(),v.end()
#define all(v)          v.begin(),v.end()
#define p(a)            cout<<a<<" ";
#define check           cout<<"OOOOOF"<<endl;

int main()
{
    int n;
    cin >> n;
    long long s = 0;
    loop(i,1,n)
    {
        s+=n/i;
        if(n%i==0)s--;
    }

    cout<<s<<endl;
}


Measured memory_bytes: 3628
N, K = map(int, input().split())
A = list(map(int, input().split()))
n = 0
i = 0
first = True
while True:
    if first:
        n += K
    else:
        n += K - 1
    first = False
    i += 1
    if n >= N:
        break
print(i)


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

int main(){
	string N;
	cin >> N;
	if(N[0] - '0' == 1){
		int f = 0;
		for(int i=1; i<N.size(); i++){
			if(N[i] - '0' != 0) f = 1;
		}
		if(!f) cout << 10 << endl;
		else{
			int ans = 1;
			for(int i=1; i<N.size(); i++){
				ans += N[i] - '0';
			}
			cout << ans << endl;
		}
	}else{
		int ans = 0;
		for(int i=0; i<N.size(); i++){
			ans += N[i] - '0';
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans, kurikosi = 0, 0
for i in range(n+1):
    if i != n:
        ans += min(a[i], kurikosi+b[i])
        if a[i]<=kurikosi:
            kurikosi = b[i]
        elif kurikosi < a[i] <= kurikosi+b[i]:
            kurikosi = kurikosi+b[i] - a[i]
        else:
            kurikosi = 0
    else:
        ans += min(kurikosi, a[i])

print(ans)

Measured memory_bytes: 19156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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 ll INF = 1LL << 60;
using Graph = vector<vector<ll>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);

int main(){
    ll x, y, ans = 0;
    cin >> x >> y;
    // 初項: x, 公比: 2 の等比数列
    // 項数は最大でも2桁しかないので間に合う
    while(x <= y){
        ans++;
        x *= 2;
    }
    cout << ans << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n,k;
	cin >> n >> k;
	ll ans = 1;
	for(int i = 0; i < n; i++){
		ans = min(ans+k,ans*2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	    int N=gi();
	    long i=357;
	    int c=0;
	    while(i<=N) {
	    	String s=String.valueOf(i);
	    	if (s.contains("3") && s.contains("5") && s.contains("7")) c++;
	    	StringBuilder sb=new StringBuilder();
	    	boolean f=false;
	    	for (int j=0; j<s.length();j++) {
	    		char a=s.charAt(s.length()-1-j);
	    		if(f) {
	    			sb.append(a);
	    		} else {
	    			if (a=='3') {
	    				sb.append('5');
	    				f=true;
	    			} else if (a=='5') {
	    				sb.append('7');
	    				f=true;
	    			} else {
	    				sb.append('3');
	    			}
	    		}
	    	}
	    	if(!f) sb.append(3);
	    	StringBuffer sb2=new StringBuffer(sb);
	    	i=Long.parseLong(sb2.reverse().toString());
	    }

        System.out.println(c);
//	    if(max>s-max) {
//	    	System.out.println(s-max-1);
//	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 45264
//Bismillahir Rahmanir Rahim
//In the name of Allah the Most Merciful
//Astagfirullahil laji
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long  int
int i,j;
 main()
 {
     string t,s;
    cin>>s>>t;
    int l=t.length();
    if((s+t[l-1])==t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 }


Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int X = sc.nextInt();
        int N = sc.nextInt();
        int[] p = new int[N];
        for (int i=0; i<N; i++) {
            p[i] = sc.nextInt();
        }

        System.out.println(solve(X, N, p));
    }

    private static int solve(int X, int N, int[] p) {
        int count = 0;


        for (int d=0; d<=50; d++) {
            boolean find = false;
            int x = X-d;
            for (int i=0; i<N; i++) {
                if (x == p[i]) {
                    find = true;
                    break;
                }
            }
            if (!find) return x;

            x = X+d;
            find = false;
            for (int i=0; i<N; i++) {
                if (x == p[i]) {
                    find = true;
                    break;
                }
            }
            if (!find) return x;
        }

        return count;
    }
}

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

int main(){
  int N,M,X,Y;
  bool f,s,t;
  cin>>N>>M>>X>>Y;
  vector<int>x(N),y(M);
  for(int i=0;i<N;i++){
    cin>>x.at(i);
  }
  for(int i=0;i<M;i++){
    cin>>y.at(i);
  }
  for(int z=-100;z<=100;z++){
    f=false;
    s=true;
    t=true;
    if(z>X&&z<=Y)f=true;
    for(int j=0;j<N;j++){
      if(z<=x.at(j)){
	s=false;
	break;
      }
    }
    for(int j=0;j<M;j++){
      if(z>y.at(j)){
	t=false;
	break;
      }
    }
    if(f&&s&&t)break;
  }
  if(f&&s&&t)cout<<"No War"<<endl;
  else cout<<"War"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,ans,temp,cur=0,count=1;
	cin>>n;
	vector<long long> x;
	ans=n;
	for(int i=0;i!=n;++i){
		cin>>temp;
		x.push_back(temp);
	}
	sort(x.begin(),x.end());
	for(int i=0;i!=n-1;++i){
		cur+=x[i];
		if(cur*2>=x[i+1]){
			++count;
		}
		else{
			ans-=count;
			count=1;
		}
	}
	cout<<ans<<endl;
}








Measured memory_bytes: 1400
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int n = in.nextInt();

		while (n-- > 0) {
			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();

			if (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 33228
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

mod = 10 ** 9 + 7

N = int(readline())
ans=1
for i in range(1,N+1):
    ans*=i
    ans%=mod
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	int m;
	cin >> m;
	
	cout << 48 - m << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void reverse(int *array, int length) {
	int i;
	int j;
	for(i=0;i<length-1;i++){
		for(j=i+1;j<length;j++){
			if(array[i]<array[j]){
				int temp=array[i];
				array[i]=array[j];
				array[j]=temp;
			}
		}
	}
}

int main() {
	int mountain[10];
	for (int i = 0; i < 10; i++) {
		cin >> mountain[i];
	}
	reverse(mountain, 10);
	for (int i = 0; i < 3; i++) {
		cout << mountain[i] << endl;
	}
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            int[] alphabets = new int[26];
            for (int i = 0; i < alphabets.Length; i++)
            {
                alphabets[i] = 1000;
            }

            for (int i = 0; i < count; i++)
            {
                string temp = Console.ReadLine();
                for (int j = 0; j < alphabets.Length; j++)
                {
                    alphabets[j] = Math.Min(alphabets[j], CountChar(temp, (char)(0x61 + j)));
                }
            }

            for (int i = 0; i < alphabets.Length; i++)
            {
                for (int j = 0; j < alphabets[i]; j++)
                {
                    Console.Write((char)(0x61 + i));
                }
            }
            Console.WriteLine("");
        }

        static int CountChar(string str, char needle)
        {
            int count = 0;
            foreach (var item in str)
            {
                if (item == needle)
                {
                    count++;
                }
            }
            return count;
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;
typedef long long ll;


int main(){
        ll N;
        cin >> N;
        ll Count = 0;
        ll a,b;
        for(ll i=0; i<N; i++){
                cin >> a >> b;
                Count += b-a+1;
        }
        cout << Count;

}


Measured memory_bytes: 256
# coding: utf-8
"""Snuke's Coloring 2 (ABC Edit)

@author: hijiri.n
@modified: 11-19-2016

"""

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


def solve(init, point):
    w, h, N = init
    rect = [0, w, 0, h]

    for p in point:
        x, y, a = p

        if [1, -1][a % 2] * ([x, y][a > 2] - rect[a - 1]) < 0:
            rect[a - 1] = [x, y][a > 2]

        if (rect[1] <= rect[0]) if a <= 2 else (rect[3] <= rect[2]):
            return 0
        
    return (rect[1] - rect[0]) * (rect[3] - rect[2])

# Input init & points data
i_in = data()
p_in = [data() for _ in range(i_in[-1])]
print(solve(i_in, p_in))

Measured memory_bytes: 3064
def main():
    N = int(input())
    a = list(map(int, input().split()))
 
    dp = [0 for i in range(N)]
 
    for i in range(N-1, -1, -1):
        dp[i] = a[i]
        prev = dp[i]
        for j in range(i+1, N):
            right = a[i] - dp[j]
            left = a[j] - prev
            if right > left:
                dp[j] = right
                prev = right
            else:
                dp[j] = left
                prev = left
    print(dp[-1])
 
 
main()

Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

vector<int> edge[216000];
Int cnt[216000][20];
Int val[216000];
Int n, u, v;
void solve(Int x, Int last = -1){
  for(Int to:edge[x]){
    if(to == last)continue;
    solve(to, x);
    for(Int i = 0;i < 20;i++){
      cnt[x][i] += cnt[to][i];
    }
  }
  val[x] = 19;
  while(val[x] > 0 && cnt[x][val[x]] <= 1)val[x]--;
  while(cnt[x][val[x]] > 0)val[x]++;
  for(int i = 0;i < 20;i++){
    cnt[x][i] = !!cnt[x][i];
    if(i < val[x])cnt[x][i] = 0;
  }
  cnt[x][val[x]] = 1;
}

int main(){
  cin >> n;
  for(int i = 0;i < n-1;i++){
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);		   
  }
  solve(1);
  cout << *max_element(val, val + n) << endl;
  return 0;
}

Measured memory_bytes: 32256
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
int n;
char s[200010];
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  scanf("%s",s+1);
  n=strlen(s+1); s[n+1]=s[n+2]='#';
  if(n<3) return puts("0"),0;
  LL res=0; int now=0;
  for(int i=1;i<=n;++i) {
    if(s[i]=='A') ++now;
    else {
      if(s[i]!='B'||s[i+1]!='C') {
        now=0;
        continue;
      }
      res+=now;
      ++i;
    }
  }
  printf("%lld\n",res);
  return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=1e6+5;
int dir[4][2]={0,1,0,-1,1,0,-1,0};
int n,m;
char mmp[500][500];
bool vis[500][500];
void dfs(int i,int j,int tag,ll &x,ll &y)
{
    if(vis[i][j])return;
    vis[i][j]=1;

    if(mmp[i][j]=='#')x++;
    else y++;
    for(int k=0;k<4;k++)
    {
        int di=i+dir[k][0];
        int dj=j+dir[k][1];
        if(di<1||dj<1||di>n||dj>m)continue;
        int t=mmp[di][dj]=='#';
        if(t!=tag)dfs(di,dj,t,x,y);
    }
}
int main()
{
    while(cin>>n>>m)
    {
        memset(vis,0,sizeof(vis));
        for(int i=1;i<=n;i++)
            scanf("%s",mmp[i]+1);
        ll ans=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)if(mmp[i][j]=='#'&&!vis[i][j])
            {
                ll x=0,y=0;
                dfs(i,j,1,x,y);
                ans+=x*y;
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 13184
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1)/ (y))
#define MOD 1000000007ULL

void print_array(u32 *A, u32 N);
u64 selectionSort(u32 *A, u32 N);

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

    u32 n;
    u32 *A;

    cin >> n;

    A = new u32[n];

    rep (i, n)
    {
        cin >> A[i];
    }

    u64 ret = selectionSort(A, n);

    print_array(A, n);
    cout << ret << "\n";

    delete[] A;

    return 0;
}

void print_array(u32 *A, u32 N)
{
    string str;
    rep (i, N)
    {
        str += to_string(A[i]) + ' ';
    }
    str.erase(str.end() - 1);
    str += '\n';
    cout << str;
}

u64 selectionSort(u32 *A, u32 N)
{
    u64 count = 0;

    rep (i, N)
    {
        int minj = i;
        for (int j = i; j < N; ++j)
        {
            if (A[j] < A[minj])
            {
                minj = j;
            }
        }
        if (minj != i)
        {
            swap(A[i], A[minj]);
            ++count;
        }
    }

    return count;
}



Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
    
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    ll n,k; cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    ll sum=0;
    for(ll i=0;i<k;i++) sum+=a[i];
    cout<<sum;
    
    /*------------------Code Ends Here-------------------*/
    
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
  int A,B;
  cin>>A>>B;
  if((A*B%2==0)){
    cout<<"No\n";
  }else{
    cout<<"Yes\n";
  }
}


Measured memory_bytes: 256
from collections import Counter


def solve(V):
    n = len(V)
    ac = Counter(V[::2]).most_common(2)
    bc = Counter(V[1::2]).most_common(2)

    if ac[0][0] != bc[0][0]:
        return n - ac[0][1] - bc[0][1]
    else:
        if len(bc) == 1 or len(ac) == 1:
            return n // 2
        else:
            return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])


if __name__ == "__main__":
    n = int(input())
    l = input()
    print(solve(l.split(" ")))

Measured memory_bytes: 22476
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string S;
	cin >> S;

	for (int i = 0; i < S.length() - 1; i++) {
		if (S[i] == S[i + 1])
		{
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;

	
}

Measured memory_bytes: 3628
import java.util.*

fun main(args : Array<String>) {
    val (n, m, x) = readLine()!!.split(" ").map { it.toInt() }
    val books = Array(n) {
        val ca = readLine()!!.split(" ").map { it.toInt() }
        Pair(ca[0], ca.drop(1))
    }

    val bfs = ArrayDeque<MutableList<Int>>()
    bfs.addLast(mutableListOf(0))
    bfs.addLast(mutableListOf(1))

    var minPrice = Int.MAX_VALUE

    while (bfs.isNotEmpty()) {
        val list = bfs.removeFirst()

        if (list.size == n) {
            var mm = IntArray(m) {0}
            var price = 0

            list.forEachIndexed { idx, b ->
                if (b == 1) {
                    price += books[idx].first
                    for (i in 0 until m) {
                        mm[i] += books[idx].second[i]
                    }
                }
            }
            if (mm.all { it >= x }) {
                minPrice = Math.min(minPrice, price)
            }
            continue
        }

        val cp0 = mutableListOf<Int>()
        cp0.addAll(list)
        cp0.add(0)
        bfs.addLast(cp0)

        val cp1 = mutableListOf<Int>()
        cp1.addAll(list)
        cp1.add(1)
        bfs.addLast(cp1)
    }

    println(if (minPrice == Int.MAX_VALUE) -1 else minPrice)
}

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

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

        static void A()
        {
            var N = ReadInt();
            var S = Read();
            var ans = 1;
            var c = S[0];

            for (int i = 0; i < S.Length; i++)
            {
                if (c != S[i])
                {
                    c = S[i];
                    ans++;
                }
            }

            Println(ans);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

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

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

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

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

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

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

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

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

            return true;
        }

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

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

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

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

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



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

const int INF = 2e9;

int main(){
    int h,n;
    cin >> h >> n;
    vector<int> dp(h+1,INF);
    dp[0] = 0;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        rep(j,h){
            int nj = min(j+a,h);
            dp[nj] = min(dp[nj],dp[j]+b);
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    map<int, int> mp;
    rep(i, n){
        cin >> p[i];
        mp[p[i]] = i;
    }
    multiset<int> st;
    st.insert(-1);
    st.insert(-1);
    st.insert(n);
    st.insert(n);
    LL ans = 0;
    for(LL i=n; i>0; i--){
        int j = mp[i];
        auto itr = st.lower_bound(j);
        LL r = *itr;
        itr++;
        LL R = *itr;
        itr--; itr--;
        LL l = *itr;
        itr--;
        LL L = *itr;
        // cout << L << " " << l << " " << r << " " << R << ":" << j << endl;
        // cout << (r-j)*(l-L) << " " << (j-l)*(R-r) << endl;
        ans += ((r-j)*(l-L) + (j-l)*(R-r)) * i;
        // cout << ans << endl;
        st.insert(j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9984
#include <iostream>

using namespace std;
int main() {
	int A, B;
	int count = 0;

	cin >> A >> B;
	//ボタンを二回押す

	if (A > B) { 
		count += A;
		A = A - 1;
		if (A > B) {
			count = count + A;
			A = A - 1;
			cout << count << endl;
		}
		else{
			count += B;
			cout << count << endl;
		}
		return 0;
	}
	else {
		count += B;
		B = B - 1;
		if (A > B) {
			count = count + A;
			A = A - 1;
			cout << count << endl;
		}
		else if (A <= B) {
			count += B;
			cout << count << endl;
		}
		return 0;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
//const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,-1,0,1,-1,1,-1,1};

class Graph{
	private:
	int n;
	vvp g;
	public:
	vi DIJ(int s){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d;
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
	}
};

const int N=16;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n,m,L,K,A,H;
		cin>>n>>m>>L>>K>>A>>H;
		if(n==0) break;
		m++;
		Graph g(n*m);
		for(int i=0;i<L;i++){
			int v;
			cin>>v;
			for(int j=0;j<m-1;j++) g.add_edge(v*m+j,v*m+j+1,1);
		}
		for(int i=0;i<K;i++){
			int u,v,w;
			cin>>u>>v>>w;
			for(int j=w;j<m;j++) g.add_edge(u*m+j,v*m+j-w,w);
			for(int j=w;j<m;j++) g.add_edge(v*m+j,u*m+j-w,w);
		}
		vi d=g.DIJ(A*m+m-1);
		int res=inf;
		for(int i=0;i<m;i++) res=min(res,d[H*m+i]);
		if(res==inf) cout<<"Help!"<<endl;
		else cout<<res<<endl;
	}
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
        cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,ans=0;
    set<int> b;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(b.find(a)==b.end())
            ans++;
        b.insert(a);
    }
    cout<<ans<<endl;
    return(0);
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(){
	
	string s;
	int n;
	cin>>s>>n;
	
	deque<char> q;
	q.assign(s.begin(), s.end());
	
	int t, f, flag=0;
	char c;
	while(n--)
	{	
		cin>>t;
		if(t==1) flag++;
		else{
			cin>>f>>c;
			if(flag%2==0){
				if(f==1) q.push_front(c);
				else q.push_back(c);					
			}else{
				if(f==1) q.push_back(c);
				else q.push_front(c);		
			}
		}
	}
	if(flag%2){
		deque<char>::iterator it=q.end()-1;
		for(;it!=q.begin()-1;it--)
			printf("%c", *it);
	}else
	{
		deque<char>::iterator it=q.begin();
		for(;it!=q.end();it++)
			printf("%c", *it);		
	}
	return 0;
}



Measured memory_bytes: 896
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    double ans = 0;
    for(int i = 0; i < n; i++){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY"){
            ans += x;
        } else {
            ans += 380000.0 * x;
        }
    }

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

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double n = sc.nextDouble();
		int k = sc.nextInt();
		double ans=0;
		for(int i = 1; i<=n; i++){
			int p=i;
			double q=1;
			while(p<k){
				p*=2;
				q*=2;
			}
			q*=n;
			ans+=1/q;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
fun main(args: Array<String>) {
    val (w, h, n) = readLine()!!.split(' ').map { it.toInt() }
    val field = Array(h) { BooleanArray(w) { true } }
    repeat (n) {
        val (x, y, a) = readLine()!!.split(' ').map { it.toInt() }
        val (xmin, xmax, ymin, ymax) = when (a) {
            1 -> listOf(0, x, 0, h)
            2 -> listOf(x, w, 0, h)
            3 -> listOf(0, w, 0, y)
            4 -> listOf(0, w, y, h)
            else -> listOf()
        }
        for (i in ymin until ymax) {
            for (j in xmin until xmax) {
                field[i][j] = false
            }
        }
    }
    println(field.map{ it.count{ it } }.sum())
}


Measured memory_bytes: 42512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    string s, t;
    std::cin >> n >> s >> t;
    vector<string> S(n);
    vector<string> T(n);
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            S[i].push_back(s[j]);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n-i; j++) {
            T[i].push_back(t[j]);
        }
    }
    int ans = n*2;
    for (int i = 0; i < n; i++) {
        if (S[i] == T[i]) {
            ans = n+i;
            break;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#input
n = int(input())
a = []
for i in range(n):
  a.append(input())

cnt = 0

ba=0
bx=0
xa=0
#print("")
for s in a:
  for i in range(len(s)):
    if i < len(s)-1:
      if s[i]=='A' and s[i+1]=='B':
        cnt+=1
        #print(s)
  if s[0]=='B' and s[-1:]=='A':
    ba += 1
  elif s[0]=='B':
    bx += 1
  elif s[-1:]=='A':
    xa += 1

if ba > 1:
  cnt += ba-1
  ba = 1
babx = min(ba,bx)
#print("min(ba,bx)=({},{})".format(ba,bx))
xaba = min(xa,ba)
#print("min(xa,ba)=({},{})".format(xa,ba))
xaax = min(bx - babx,xa-xaba)
#print("min(bx-babx,xa-xaba)=({},{})".format(bx-babx,xa-xaba))

print(cnt+babx+xaba+xaax)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	

	void solve(){
		

		ini(n);
		ins(x);
		int tmp = 0;
		FOR(i,0,n){
			if(x[i] == 'R'){tmp++;}
		}
		int tmp1 = 0;
		FOR(i,0,tmp){
			if(x[i]!='R')tmp1++;
		}
		out(tmp1);
			
			
			


				
		


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 3720
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			while (true) {
				final int n = Integer.parseInt(input.readLine());
				if (n == 0) {
					break;
				}
				
				final String[] line = input.readLine().split(" ");
				int[] scores = new int[n];
				double average = 0;
				for (int i = 0; i < n; i++) {
					scores[i] = Integer.parseInt(line[i]);
					average += scores[i];
				}
				average /= n;

				double deviation = 0;
				for (int i = 0; i < n; i++) {
					deviation += Math.pow(scores[i] - average, 2);
				}
				deviation = Math.pow(deviation / n, 0.5);
				answer.append(String.valueOf(deviation)).append(lb);
			}
			input.close();
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 19472
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int ans=700;
    string s;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='o')
        ans+=100;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
from itertools import product
h,w,k = map(int,input().split())
c = [input() for _ in range(h)]
row = list(product(range(2), repeat=h))
col = list(product(range(2), repeat=w))
g = "#" * k
cl = []
for i in row:
  for j in col:
    s=""
    for k in range(h):
      for l in range(w):
        if i[k] != 0 and j[l] != 0:
          s += c[k][l]
    cl.append(s)

for i in range(len(cl)):
  cl[i] = cl[i].replace(".","")
  
print(cl.count(g))

Measured memory_bytes: 68496
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

def ans091(N:int, s:list, M:int, t:list):
    test_count=0
    own=list(set(s))
    for i in range(len(own)):
        if test_count<=s.count(own[i])-t.count(own[i]):
            test_count=s.count(own[i])-t.count(own[i])
    if test_count>0:
        return test_count
    else:
        return 0
print(ans091(N,s,M,t))

Measured memory_bytes: 8992