akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.Date;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<String> day = new ArrayList<String>();
        String line;
        Calendar cal = Calendar.getInstance();
        int y = 2004;
        while(true) {
            line = sc.nextLine();
            String[] A = line.split(" ");
            int m = Integer.parseInt(A[0]);
            int d = Integer.parseInt(A[1]);
            if(m == 0 && d == 0) { 
                break;
            }
            cal.set(y, m-1, d);
            int num = cal.get(Calendar.DAY_OF_WEEK);
            switch(num) {
                case 2:
                    System.out.println("Monday");
                    break;
                case 3:
                    System.out.println("Tuesday");
                    break;
                case 4:
                    System.out.println("Wednesday");
                    break;
                case 5:
                    System.out.println("Thursday");
                    break;
                case 6:
                    System.out.println("Friday");
                    break;
                case 7:
                    System.out.println("Saturday");
                    break;
                case 1:
                    System.out.println("Sunday");
                    break;
                    
            }
        }
    }
}


Measured memory_bytes: 27168
n=int(input())
import sys
sys.setrecursionlimit(10**6)
s=[[] for _ in range(n)]

for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append((b-1,i))
    s[b-1].append((a-1,i))

l=[0]*(n-1)

def dfs(node,pre_col,par):
    col=1
    for nei,i in s[node]:
        if nei==par:
            continue
        if col==pre_col:
            col+=1
        l[i]=col
        dfs(nei,col,node)
        col+=1
dfs(0,-1,-1)
print(max(l))
for i in l:
    print(i)


Measured memory_bytes: 74684
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void){
    
    int a, b, d, r;

    double f;

    cin >> a >> b;

    d = a / b;

    r = a % b;

    f = (double)a / (double)b;

    cout << d << " " << r << " " ;

    printf("%.8f",f);

return 0;

}

Measured memory_bytes: 1240
N, K = map(int, input().split())
x = input().split()

if N <= K:
    res = 0
else:
    n_num = [int(n_str) for n_str in x]
    n_num_sorted = sorted(n_num, reverse=True)
    res = sum(n_num_sorted[K:])

print(res)

Measured memory_bytes: 29096
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();

        long[][] a = new long[3][n];
        for (int i = 0; i < n; i++) {
            a[0][i] = in.nextLong();
            a[1][i] = in.nextLong();
            a[2][i] = in.nextLong();
        }

        long[][] t = new long[1 << 3][n];
        for (int f = 0; f < n; f++) {

            for (int i = 0; i < 1 << 3; i++) {
                for (int j = 0; j < 3; j++) {
                    if ((1 & i >> j) == 1) {
                        t[i][f] += a[j][f];
                    } else {
                        t[i][f] -= a[j][f];
                    }
                }
            }
        }

        for (int i = 0; i < 1 << 3; i++) {
            Arrays.sort(t[i]);
        }

        long r = 0;
        for (int i = 0; i < 1 << 3; i++) {
            long s = 0;
            for (int j = n - 1; j >= n - m; j--) {
                s += t[i][j];
            }
            r = Math.max(r, s);
        }

        out.println(r);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


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

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


Measured memory_bytes: 3624
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n-1)]
c = list(map(int,input().split()))
c = sorted(c)[::-1]
g = {}
for i in range(1,n+1):
    g[i] = []
for a,b in ab:
    g[a].append(b)
    g[b].append(a)
from collections import deque
q = deque([g[1]])
done = [0]*(n+1)
done[1] = 1
ans = [0]*n
ans[0] = c[0]
cnt = 1
while q:
    v = q.popleft()
    for v_ in v:
        if done[v_]==0:
            done[v_] = 1
            ans[v_-1] = c[cnt]
            cnt += 1
            q.append(g[v_])
print(sum(c[1:]))
for i in ans:
    print(i,end=' ')
print()

Measured memory_bytes: 53720
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline


def dfs(v, par):
    for nv in tree[v]:
        if nv == par:
            continue
        add[nv] += add[v]
        dfs(nv, v)


n, q = map(int, input().split())
tree = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    tree[b].append(a)
    tree[a].append(b)
add = [0] * n
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    add[p] += x
dfs(0, -1)
print(*add)


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
// cin.eof() 入力個数の問題

int main() {
    int n;
    cin >> n;
    int w[n];
    rep(i, n) cin >> w[i];

    int sum[n+1];
    sum[0]=0;
    rep(i,n){
        sum[i+1]=sum[i]+w[i];
    }
    int ans=INF;
for(int i=1;i<n;i++){
    ans=min(ans,abs(sum[i]-(sum[n]-sum[i])));
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3604
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 1/n + 1/h > 4/N:
            continue
        if (4*h*n-N*n-N*h) ==0:
            continue
        val =N*h*n/(4*h*n-N*n-N*h)
        if val == int(val) and val>0:
            print(h,n,int(val))
            exit(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, k, x;
	cin >> n >> k;
	Foz(i, n) cin >> x;
	int ans = 1;
	if (n > k) ans += (n - k - 1) / (k - 1) + 1;
	cout << ans << '\n';
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, t[1000], a[1000];

int main() {
	cin >> n;
	inc(i, n) { cin >> t[i] >> a[i]; }
	
	LL min_t = t[0], min_a = a[0];
	inc(i, n) {
		LL k = max((min_t + t[i] - 1) / t[i], (min_a + a[i] - 1) / a[i]);
		
		min_t = t[i] * k;
		min_a = a[i] * k;
	}
	
	cout << min_t + min_a << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> G;
  int p = -1000000;
  for (int i = 0; i < N; i++){
    if (S[i] == 'o' && i > p + C){
      G.push_back(i);
      p = i;
    }
  }
  int count = G.size();
  /*
  for (int i = 0; i < count; i++){
    cout << G[i] << ' ';
  }
  cout << endl;
  */
  if (count == K){
    vector<int> G2;
    p = 1000000;
    for (int i = N - 1; i >= 0; i--){
      if (S[i] == 'o' && i < p - C){
        G2.push_back(i);
        p = i;
      }
    }
    reverse(G2.begin(), G2.end());
    for (int i = 0; i < count; i++){
      if (G[i] == G2[i]){
        cout << G[i] + 1 << endl;
      }
    }
  }
}

Measured memory_bytes: 3448
N = gets.to_i
V = gets.split(' ').map(&:to_i)
C = gets.split(' ').map(&:to_i)

value = 0
k = 0
i = 0
price = 0
while k < N
  value = V[i] - C[i]
  ( price += value) if value > 0
  k += 1
  i += 1
end

puts price

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void solve() {
    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();
    set<int> se[27];
    rep(i, n) {
        int k = s[i] - 'a';
        se[k].insert(i);
    }
    int j = 0;
    int now = -1, cnt = 0;
    int ans = 0;
    while(j < m) {
        int a = t[j] - 'a';
        auto b = se[a].upper_bound(now);
        if(b == se[a].end()) {
            if(now == -1) {
                cout << -1 << endl;
                return;
            }
            cnt ++;
            ans += n;
            now = -1;
        } else {
            now = *b;
            j ++;
        }
    }
    cout << ans + now + 1 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main () {
  int n;
  cin >> n;
  vector<long long> l(n,0);
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(l[i]+l[j]+l[k]-max(max(l[i],l[j]),l[k])>max(max(l[i],l[j]),l[k])){
          if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]){
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define MOD 1000000007
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int x,y;
	cin>>x>>y;
	if((y-2*x)>=0 &&(4*x - y)>=0&&( 4*x - y)%2 ==0 && (y-2*x)%2 ==0){
		cout<<"Yes\n";
	} else {
		cout<<"No\n";
	}
}

Measured memory_bytes: 3624
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int  main() {
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if(A<=C&&C<=B) {
		printf("Yes\n");
	}else {
		printf("No\n");
	}
}

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

using namespace std;

int main() {
    string s;
    int K;
    cin >> s;
    cin >> K;

    int k = K;

    for(int i=0;i< s.size();i++){
        //上からaに置き換える
        char tmp = (char)('z'-s[i]+1);
        if(tmp != 26 && tmp<=k){
            k -= tmp;
            s[i] = 'a';
        }
        if(k==0)
            break;
    }

    if(k > 26)k=k%26;
    s[s.size()-1] += k;
    if(s[s.size()-1] > 'z'){
        s[s.size()-1]=s[s.size()-1]-'z'-1+'a';
    }

    cout << s;

    return 0;

}

Measured memory_bytes: 512
using System;
using System.Linq;
using static System.Console;

namespace AtCorder
{
	public class Program
	{
		public static void Main()
		{
			var s = ReadLine();
			var k = double.Parse(ReadLine());
			int n = 0;
			foreach(var c in s)
			{
				if (c != '1')
				{
					break;
				}
				n++;
			}
			if(k <= n)
			{
				WriteLine(1);
			}
			else
			{
				k = k - n;
				foreach(var c in s.Skip(n))
				{
					// 5000兆 = 500,000,000,000,000  5 * 10^14;
					if (k <= Math.Pow((double)c, 5) * 100000000000000)
					{
						WriteLine(c);
						return;
					}
				}
			}
		}
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
vi p;
int main() {
    cin>>n;
    p.resize(n);
    REP(i,n) cin>>p[i];

    vi p2(n);
    copy(ALL(p), p2.begin());
    sort(ALL(p2));

    if(p==p2){
        cout << "YES" << endl;
        return 0;
    }

    int cnt=0;
    REP(i,n){
        if(p[i] != p2[i])
            cnt++;
    }

    if(cnt <= 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int main(){
    int n; cin >> n;
    vector<ll> c(n-1),s(n-1),f(n-1);
    rep(i,n-1) cin >> c[i] >> s[i] >> f[i];

    for(ll i=0;i<n-1;i++){
        ll time = 0,t,a;
        time = s[i] + c[i];
        for(ll j=i+1;j<n-1;j++){
            if(time <= s[j]) time = s[j];
            else{
                t = (time - s[j]) / f[j];
                a = (time - s[j]) % f[j];
                if(a != 0) t++;
                time = t * f[j] + s[j];
            }
            time += c[j];
        }
        cout << time << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    long long cot=0;
    long long k=0;
    bool flag=false;
    for(int i=0;i<n;i++)
    {
        long long a;
        scanf("%lld",&a);
        if(i==0&&a!=0)
            flag=true;
        if(a==k) cot+=k;
        else if(a==k+1) cot++,k=a;
        else if(a<k) k=a,cot+=a;
        else if(a>k+1) flag=true;
    }
    if(flag)
        printf("-1\n");
    else printf("%lld\n",cot);
}


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

using namespace std;

int main()
{
    int n, m, a, b, I;
    cin >> n >> m;
    int A[m], B[m], O[n+1], Sp[m];
    if (m % 2 == 1)
    {
        cout << -1;
        return 0;
    }
    vector <pair<int,int>> D[n+1], V;
    vector <int> T;
    int De[n+1], P[n+1];
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
        Sp[i] = 0;
        D[a].push_back({b,i});
        D[b].push_back({a,i});
    }
    int G[n+1];
    for (int i = 0; i <= n; i++)
    {
        G[i] = 1;
        O[i] = 0;
    }
    G[1] = 0;
    P[1] = -1;
    De[1] = 0;
    T.push_back(1);
    for (int i = 0; i < T.size(); i++)
    {
        a = T[i];
        for (int y = 0; y < D[a].size(); y++)
        {
            b = D[a][y].first;
            I = D[a][y].second;
            if (G[b] == 1)
            {
                G[b] = 0;
                T.push_back(b);
                Sp[I] = 1;
                P[b] = I;
                De[b] = De[a] + 1;
                V.push_back({De[b],b});
            }
        }
    }
    for (int i = 0; i < m; i++)
    {
        if (Sp[i] == 0)
        {
            O[A[i]]++;
        }
    }
    sort(V.rbegin(),V.rend());
    for (int i = 0; i < V.size(); i++)
    {
        a = V[i].second;
        I = P[a];
        b = B[I];
        if (a == b)
        {
            b = A[I];
        }
        if (O[a] % 2 == 1)
        {
            A[I] = a;
            B[I] = b;
            O[a]++;
        }
        else
        {
            A[I] = b;
            B[I] = a;
            O[b]++;
        }
    }
    for (int i = 0; i < m; i++)
    {
        cout << A[i] << " " << B[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 11424
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
   if(s[0]==s[1]||s[1]==s[2])
   {
     cout<<"Bad";
   }
 else if(s[2]==s[3])
 {
   cout<<"Bad";}
  else{
    cout<<"Good";}
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		// 計算
		double result = 0;
		double[] a = new double[n+1];
		double prod = 1;
		double sum = 0;

        for(int i = 1; i <= n; i++){
		    result += (double)1/pow(2, count(i, k));
		}
		result = result*1/n;

		// 出力
		System.out.println(result);
	}
	
	static long count(int i, int k){
	    if(i >= k){
	        return 0;
	    }else{
	        return count(i*2, k) + 1;
	    }
	}
	
	public static long pow(long a,long n) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=(res*a);
	        }
	        a=(a*a);
	        n>>=1;
	    }
	    return res;
	}
}

Measured memory_bytes: 20692
#include <iostream>
using namespace std;
int main(){
	int n, m;
	int k;
	int a2[30];
	int a;
	int count = 0;
	for(int i = 0;i < 30;i++){
		a2[i] = 0;
	}
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> k;
		for(int j = 0;j < k;j++){
			cin >> a;
			a2[a - 1]++;
		}
	}
	for(int i = 0;i < m;i++){
		if(a2[i] == n){
			count++;
		}
	}
	cout << count << endl;
}

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

const int T=1000000;

int main(){
    int n,m,a,b;
    scanf("%d %d",&n, &m);
    a=n*(n-1)/2;
    b=m*(m-1)/2;

    printf("%d\n", a+b);
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  int palind = 0;
  int d[5];
  for (int i = A; i <= B; i++){
    d[4] = i / 10000;
    d[3] = (i - d[4] * 10000) / 1000;
    d[2] = (i - d[4] * 10000 - d[3] * 1000) / 100;
    d[1] = (i - d[4] * 10000 - d[3] * 1000 - d[2] * 100) / 10;
    d[0] = i % 10;
    if ((d[4] == d[0]) && (d[3] == d[1])) { palind += 1; }
  }
  cout << palind << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
//#include <fstream>

int main()
{
    const u_int max_point = 16;
    u_int a, b, n, x, y;
    //std::ifstream ifs("515.txt");
    while(1){
        std::cin /*ifs*/ >> a >> b;
        if(a == 0 && b == 0)
            break;
        
        std::array<std::array<u_int, max_point>, max_point> point, count;
        for(u_int i = 0; i < max_point; ++i){
            count[i].fill(0);
            point[i].fill(0);
        }
        std::cin /*ifs*/ >> n;
        for(u_int i = 0; i < n; ++i){
            std::cin /*ifs*/ >> x >> y;
            point[x - 1][y - 1] = 1;
        }
        
        count[0][0] = 1;
        for(u_int i = 0; i < a; ++i){
            for(u_int j = 0; j < b; ++j){
                if(point[i][j] != 1){
                    if(i ==0 && j == 0){
                        count[i][j] = 1;
                    }
                    else if(i == 0){
                        count[i][j] = count[i][j - 1];
                    }
                    else if(j == 0){
                        count[i][j] = count[i - 1][j];
                    }
                    else{
                        count[i][j] = count[i - 1][j] + count[i][j - 1];
                    }
                }
            }
        }
        std::cout << count[a - 1][b - 1] << std::endl;               
    }
    //ifs.close();

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define FF first
#define SS second
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
typedef priority_queue<ut,VI,greater<ut> > PPQ;
const int SIZE=5+1e5;
const LL INF=1<<30;
const LL p=7+(1e9);
LL A[SIZE];
char B[SIZE];
bool isMinus[SIZE];
int main(){
	int N;
	string s;
	cin.tie(0);
	cin >> N;
	LL ans=0;
	cin >> ans;
	REP(i,N-1){
		cin >> B[i];
		cin >> A[i];
		isMinus[i]=B[i]=='-';
	}
	LL freedom=0,needm=0,cost=0;
	REP(j,N-1){
		int i=N-1-j-1;
		if(isMinus[i]){

			cost+=A[i];
			freedom-=A[i];
			needm+=A[i];
			freedom=max(freedom,needm-cost*2);
			cost=0;
		}
		else{
			cost+=A[i];
			needm+=A[i];
			freedom+=A[i];
		}
	}
	cout << freedom+ans << endl;
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
 
#define ll long long
 
int main()
{
  int N, K;
  int A[200000];
  
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
 
	for(int i = K; i < N; i++){
 		cout << ((A[i-K] < A[i]) ? "Yes" : "No") << endl;
	}
  
  return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>

int main(void) {
	int a, b;

	std::cin >> a >> b;

	for (size_t i = 1; i <= 3; i++) {
		if ((a * b * i) % 2 == 1) {
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}
	
	std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  string s;
  cin>>s;
  vector<int> a(26,0);

  for(auto c : s) a[c-'a']++;

  int ans = 0;
  rep(i,26) if(a[i]%2==1) ans++;

  cout << ans/2 << endl;

  return 0;
}

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

int main(){
    int L,R;
    cin >> L >> R;
    int p = R-L+1;
    if(R-L>2019){
        cout << 0 << endl;
        return 0;
    }else{
        vector<int> a(p);
        for(int i=0;i<p;i++){
            a.at(i) = (i + L)%2019;
            //cout << a.at(i) << endl;
        }
        int q = 2019;
        for(int i=0;i<a.size();i++){
            for(int j=i+1;j<a.size();j++){
                int r = (a.at(i) * a.at(j))%2019;
                q = min(q,r);
            }
        }
        cout << q << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

ll memo[100010];



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll x[n];
    rep(i,n) cin  >> x[i];

    memo[0] = 1;
    REP(i,1,100010)
    {
        memo[i] = memo[i-1]*i;
        memo[i] %= MOD;
    }



    ll kitaichi[n-1];
    kitaichi[0] = 1;
    REP(i,1,n-1)
    {
        kitaichi[i] = kitaichi[i-1] * (i+1) + memo[i];
        kitaichi[i] %= MOD;
    }
    // rep(i,n-1)
    // {
    //     cout << kitaichi[i] << endl;
    // }
    ll ans = 0;
    rep(i,n-1)
    {
        ans *= (i+1);
        ans %= MOD;
        ans += kitaichi[i] * (x[i+1]-x[i]);
        ans %= MOD;
    }

    cout << ans << endl;
    
}




Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 2000000;

int main(){
    int R[MAX], n;

    cin >> n;
    for(int i=0;i<n;i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for(int i = 1; i < n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;

}



Measured memory_bytes: 3872
#include <stdio.h>

main(){
    int a,b,x;
    while(1){
        scanf("%d %d",&a,&b);
        if(a==0&&b==0){break;}
        if(a>b){
            x=a;
            a=b;
            b=x;
        }
        printf("%d %d\n",a,b);
    }
}


Measured memory_bytes: 2036
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll h,w,dx[4]={0,1,0,-1},dy[4]={1,0,-1,0},l,r,ans;
string s[400];
bitset<400> u[400];

inline bool c(int x,int y)
{
	if(x<0||y<0||x>=h||y>=w||u[x][y])
		return 0;
	return 1;
}

void dfs(int x,int y)
{
	u[x][y]=1;
	if(s[x][y]=='.')
		r++;
	else
		l++;
	for(int i=0;i<4;i++)
		if(c(x+dx[i],y+dy[i])&&((s[x][y]=='#'&&s[x+dx[i]][y+dy[i]]=='.')||(s[x][y]=='.'&&s[x+dx[i]][y+dy[i]]=='#')))
			dfs(x+dx[i],y+dy[i]);
}

int main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)
		cin>>s[i];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			if(!u[i][j]&&s[i][j]=='#')
				l=r=0,dfs(i,j),ans+=l*r;
	cout << ans<<'\n';
	
}

Measured memory_bytes: 12928
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;
#define N 200010
int has[N];
int long long n;
int main(){
    int n,q,b,c;
    long long sum,a;
    while (scanf("%d",&n)!=EOF) {
        int x=0;
        for (int i=0;i<n;i++)
        {
            scanf("%d",&has[i]);
            x^=has[i];
        }
        for (int i=0;i<n;i++) {
            if (i)
                printf(" ");
            printf("%d",x^has[i]);
        }
        printf("\n");

    }

    return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int masu[2010][2010] = {};
int yoko[2010][2010] = {};
int tate[2010][2010] = {};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    REP(i,H){
        string S; cin >> S;
        REP(j,W){
            if(S[j] == '#') masu[i][j] = 1;
            else masu[i][j] = 2;
        }
    }
    REP(i,H){
        int init = 0;
        REP(j,W){
            if(masu[i][j] != 2){

                FOR(k,init,j) yoko[i][k] = j - init;
                init = j+1;
            }
        }
        FOR(k,init,W) yoko[i][k] = W-init;
    }
    REP(j,W){
        int init = 0;
        REP(i,H){
            if(masu[i][j] != 2){

                FOR(k,init,i) tate[k][j] = i - init;
                init = i+1;
            }
        }
        FOR(k,init,W) tate[k][j] = H-init;
    }
    //REP(i,H) REP(j,W) dump(tate[i][j])
    LL ans = 0;

    REP(i,H) REP(j,W){
        if(masu[i][j] != 2) continue;
        LL tmp = tate[i][j] + yoko[i][j] - 1;
        if(tmp > ans) ans = tmp;
    }
    cout << ans << endl;




}

Measured memory_bytes: 47488
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

map<string, bool> mp;
bool cat(const string &s) {
  if (s == "") return 1;
  if (s.size() <= 2) return 0;
  if (mp.count(s)) return mp[s];
  if (s[0] != 'm' || s[s.size()-1] != 'w') return 0;
  REP(i,s.size()) {
    if (s[i] == 'e') {
      if (cat(s.substr(1,i-1)) && cat(s.substr(i+1, s.size()-(i+1)-1))) return mp[s] = 1;
    }
  }
  return mp[s] = 0;
}

int main() {
  string s;
  cin >> s;
  cout << (cat(s)?"Cat":"Rabbit") << endl;
}

Measured memory_bytes: 4580
#a,b小さいのでこれで可
a,b = map(int, input().split( ))

mn = int(a/(0.1))-5
mx = int(b/0.08)+3

for i in range(mn,mx):
    if int(i*0.08)==a and int(i*0.1)==b:
        print(i)
        exit()

print(-1)


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int A=0,B=0;
  rep(i,N) if (S[i]=='R') A++;
  int ans = A;
  rep(i,N) {
    if (S[i]=='W') B++;
    else A--;
    ans = min(ans,max(A,B));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3724
#include <iostream>
using namespace std;
 
int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  
  int ans =0;
  for(int a=0;a<=A;a++)
    for(int b=0;b<=B;b++)
      for(int c=0;c<=C;c++)
        if(a*500+b*100+c*50==X)
          ans++;
  cout << ans <<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoderContestScheduling
{
    class Program
    {
        static void Main(string[] args)
        {
            const int n_contest = 26;
            int D = GetInt();
            var c = GetIntArray();
            var s = new int[D][];
            for(int i = 0; i < D; i++)
            {
                s[i] = GetIntArray();
            }

            var decrement = new int[n_contest];
            int[] contest = new int[D];
            //int score = 0;
            for(int i = 0; i < D; i++)
            {
                int max_eval = int.MinValue;
                for (int j = 0; j < n_contest; j++)
                {
                    decrement[j] += c[j];
                    if (max_eval < decrement[j] + s[i][j])
                    {
                        max_eval = decrement[j] + s[i][j];
                        contest[i] = j;
                    }
                }
                decrement[contest[i]] = 0;
                
            }
            //Console.WriteLine(score);
            foreach (var item in contest)
            {
                Console.WriteLine(item + 1);
            }

        }
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();

    }
}


Measured memory_bytes: 28912
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int q1,b,c1,c2,q2;
bool check(int x){
	int bb=b;
	bb-=c1*x;
	if(bb<0) return false;
	int xx=bb/c2;
	if(xx+x>=q1){
		return true;
	}
	return false;
}

int bs(int l,int r){
	if(l==r) return l;
	int mid=(l+r+1)/2;
	if(!check(mid)){
		return bs(l,mid-1);
	}
	return bs(mid,r);
}

void mainmain(){
	while(cin>>q1,q1){
		cin>>b>>c1>>c2>>q2;
		int t=bs(1,q2);
		int tt=(b-c1*t)/c2;
		if(t*c1+tt*c2<=b&&t+tt>=q1) cout<<t<<" "<<tt<<endl;
		else cout<<"NA\n";
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define INF 1000000007
#define N 100005
#define PI 3.14159265
bool compare(pair<ll,char> i, pair<ll,char> j) 
{
  return i.S < j.S;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
}
int main()
{
	ios
	double d;
	cin>>d;
	cout.precision(12);
	double vol=(d/3.0)*(d/3.0)*(d/3.0);
	cout<<fixed<<setprecision(12)<<vol;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  // declaration
  int N;  // Number of Mountains
  int *A;  // Array of input
  int *X;  // Array of output

  // set N
  std::cin >> N;

  // allocation
  A = new int[N];
  X = new int[N];

  // input values
  int inputValue;
  for( int n = 0; n < N; n++ ){
    std::cin >> inputValue;
    A[n] = inputValue;
  }

  // calculation output
  for( int ix = 0; ix < N; ix++ ){
    X[ix] = 0;  // initialize X

    if( ix < 2 ){
      for( int i = 0; i < N; i++ ){
        const int ia = ( ix + i + N ) % N;
        const int sign = ( i % 2 == 0 )? +1 : -1;

        X[ix] += sign * A[ia];
      }
    }else{
      X[ix] = 2*( A[ix-2] + A[ix-1] -X[ix-1] ) - X[ix-2];
    }
  }

  // output values
  for( int m = 0; m < N; m++ ){
    std::cout << X[m] << " ";
  }

  return 0;
}


Measured memory_bytes: 2048
#pragma GCC optimize("O0")
#include <stdio.h>

constexpr int buf_size = 5000;
char Input[buf_size];
char* ptr = Input;

inline int getint(void){
    int res = 0; char c; while((c = *ptr++ - '0') >= 0) res = 10 * res + c;
    return res;
}
inline long long int getlong(void){
    long long int res = 0; char c; while((c = *ptr++ - '0') >= 0) res = 10 * res + c;
    return res;
}

char Out[20];

inline void println(long long int a){
    if(a){
      char* t = Out;
      while(a) *t++ = a % 10, a /= 10;
      while(t != Out) putchar_unlocked(*(--t) | '0');
    }
    else putchar_unlocked('0');
    putchar_unlocked('\n');
}

int main(void){
    fread_unlocked(Input, 1, buf_size, stdin);
    int n = getint() - 2; 
    const long long int a = getlong(), b = getlong();
    long long int B = 0; while(n--) B ^= getlong();
    const long long int A = a + b - B;
    const long long int C = A >> 1;
    if(A < 0 or (A & 1) or (B & C) or (a < C)){ puts("-1"); return 0; }
    long long int res = C;
    for(long long int x = 1LL << 40; x ; x >>= 1) if(B & x) if((res | x) <= a) res |= x; 
    if(res) println(a - res); else puts("-1");
    return 0;
}

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

int main(void)
{
    char s[11]={},t[11]={},u[11]={};
    int a=0,b=0;
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    if(strcmp(s,u)==0) a-=1;
    else b-=1;

    printf("%d %d",a,b);
    return 0;
}


Measured memory_bytes: 1696
def f(k):
    cnt = 0
    while k%2 == 0:
        k //= 2
        cnt += 1
        # print(k)
        # print("-----")
    return cnt

n = int(input())
A = list(map(int, input().split()))
ans = 0

for a in A:
    if a%2 == 0:
        ans += f(a)
print(ans)

Measured memory_bytes: 10088
#include<cstdio>
#include<cstring>
using namespace std;
char c[1005];
int n,s,w,e,flag=1;
int main()
{
  scanf("%s",c);
  int len=strlen(c);
  for(int i=0;i<len;i++)
  {
  	if(c[i]=='N')  n++;
  	else if(c[i]=='S')  s++;
  	else if(c[i]=='W')  w++;
  	else  e++;
  }
  if((n>0&&s==0)||(n==0&&s>0))  flag=0;
  if((w>0&&e==0)||(w==0&&e>0))  flag=0;
  if(flag)  printf("Yes\n");
  else  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

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

k = int(input())


import queue
q = queue.Queue()

for i in range(1, 10):
    q.put(i)

if k <= 9:
    print(k)
    exit()

total = 9
while total <= k:
    x = q.get()
    if x % 10 != 0:
        val = x * 10 + x % 10 - 1
        q.put(val)
        total += 1
        if total == k:
            print(val)
            exit()

    val = x * 10 + x % 10
    q.put(val)
    total += 1
    if total == k:
        print(val)
        exit()
    if x % 10 < 9:
        val = x * 10 + x % 10 + 1
        q.put(val)
        total += 1
        if total == k:
            print(val)
            exit()
    
    if total >= k:
        for i in range(total - k):
            q.get()
        print(q.get())
        exit()


Measured memory_bytes: 74748
# input
N = int(input())
a = list(map(int, input().split()))

# 4の倍数, 4の倍数でない偶数, 奇数の数
i, j, k = 0, 0, 0

for n in range(N):
    if a[n] % 4 == 0:
        i += 1
    elif a[n] % 2 == 0:
        j += 1
    else:
        k += 1

if k >= i + 2:
    print('No')
elif k == i + 1 and j >= 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
int main()
{
      ios_base::sync_with_stdio(false);
      long long int t,n,m,a,b=0,c,i;
      cin>>n>>m;
      while(m--){
            cin>>a;
            b+=a;
      }
      if(b<=n) cout<<n-b;
      else cout<<"-1";
      return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

bool compare(string a,string b){
  return a.length()!=b.length()? a.length()<b.length():a<b;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string A,B;cin>>A>>B;
  cout << (A==B? "EQUAL":compare(A,B)? "LESS":"GREATER")<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        int num = k;
        while (!isPrimeNumber(num)) {
            num++;
        }
        System.out.println(num);
    }

    static boolean isPrimeNumber(int n) {
        return IntStream.range(2, n).allMatch(m -> n % m != 0);
    }
}


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

int main()
{
  int a = 0;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < 3; i++)
  {
    if (s[i] == t[i])
      a++;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<climits>
#include<cstring>

using namespace std;

bool start[200100];
bool goal[200100];

int main(){

	int N,M;	

	cin >> N >> M;

	for(int i = 0;i < M;i++){
		int a,b;
		cin >> a >> b;
		if(a == 1){
			start[b] = true;
		}
		if(b==N){
			goal[a] = true;
		}
	}

	for(int i= 2;i <= N-1;i++){
		if(start[i] && goal[i]){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;


	return 0;

}


Measured memory_bytes: 640
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {


	ll n,a,b;
	ll total=0;
	ll x;
	cin>>n>>a>>b;



	for(int i=1; i<n+1; ++i){
		x=0;
		int k=i;
		for(int j=1; j<6; ++j){
			x+=k%10;
			k=k/10;
		}
		if(x<=b&&x>=a){
			total+=i;
		}
	}
	cout<<total<<endl;

	return 0;




}


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

int main() {
    char s;
    cin>>s;
    cout <<(isupper(s)? "A":"a")<<endl;
}


Measured memory_bytes: 3616