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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
ll A[100100];
std::vector<ll> buckets[64];

int msb(ll n){
    if(n == 0){
        return 63;
    }
    return 63 - __builtin_clzll(n);
}

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

  std::cin >> N;

  ll S = 0;

  for(int i=0;i<N;++i){
      std::cin >> A[i];
      S ^= A[i];
  }

  for(int i=0;i<N;++i){
      A[i] &= (~S);
      buckets[msb(A[i])].emplace_back(A[i]);
  }

  std::vector<ll> v;

  for(int i=60;i>=0;--i){
      unless(buckets[i].empty()){
          v.emplace_back(buckets[i][0]);
          
          int size = buckets[i].size();

          for(int j=1;j<size;++j){
              ll n = buckets[i][j] ^ buckets[i][0];
              buckets[msb(n)].emplace_back(n);
          }
      }
  }

  ll res = 0, m = 0;
  for(ll n : v){
      if(res < (res ^ n) && m < N - 1){
          res = (res ^ n);
          m += 1;
      }
  }

  res *= 2;
  res += S;

  std::cout << res << std::endl;
}


Measured memory_bytes: 26148
import bisect
from itertools import permutations
lol=list(permutations(range(1,int(input())+1)))
#print(lol)
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
#print(a,b)
m=bisect.bisect(lol,a)
n=bisect.bisect(lol,b)
print(abs(m-n))

Measured memory_bytes: 40560
N, M, C = map(int, input().split())
B = [int(x) for x in input().split()]

cnt = 0
for _ in range(N):
    A = [int(x) for x in input().split()]
    x = C
    for a, b in zip(A, B):
        x += a * b
    if x > 0:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<pair<string ,int>> s(n+1);
	int pena = 0;
	rep(i,m)
	{
		int a;
		string b;
		cin >> a >> b;
		if(s[a].first=="AC")continue;

		if(b=="AC")
		{
			s[a].first=b;
		}
		else
		{
			s[a].first = b;
			s[a].second++;
		}
	}
	int ac = 0;
	rep(i,n+1)if(s[i].first=="AC")ac ++,pena+=s[i].second;
	cout<<ac<<' '<<pena<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  int N; cin >> N;
  vector<double> p(N),q(N+1);
  rep(i,N) cin >> p[i];
  rep(i,N+1) cin >> q[i];

  vector<vector<double>> dp(N+1, vector<double>(N+1,INF)); 
  vector<vector<int>> key(N+1, vector<int>(N+1));
  rep(i,N+1) {
    dp[i][i] = q[i];
    key[i][i] = i;
  }
  vector<double> sumw(N+2),sump(N+1);
  rep(i,N+1) {
    if (i == 0) {
      sumw[1] = q[0];
      sump[1] = p[0];
    } else {
      sumw[i+1] = sumw[i] + q[i];
      if (i != N)sump[i+1] = sump[i] + p[i];
    }
  }

  for (int k = 1; k < N+1; k++) {
    for (int i = 0; i < N+1-k; i++) {
      for (int j = key[i][i+k-1]; j <= min(key[i+1][i+k],N-1); j++) {
        if (chmin(dp[i][i+k],dp[i][j] + dp[j+1][i+k])) key[i][i+k] = j;
      }
      dp[i][i+k] += (sumw[i+k+1] - sumw[i] + sump[i+k] - sump[i]);
    }
  }
  
  cout << fixed << setprecision(10) << dp[0][N] << endl;
}


Measured memory_bytes: 5828
n,m = map(int,input().split())
k = []
for i in range(m):
        tmp = list(map(int,input().split()))
        k.append(tmp[1:])
p = list(map(int,input().split()))

res = 0
for i in range(2 ** n):
        l = []
        for j in range(n):
                l.append(int((i & (2 ** j)) == 0))
        flag = True

        for ll, j in enumerate(k):
                cnt = 0
                for q in j:
                        cnt += l[q - 1]
                if cnt % 2 != p[ll]:
                        flag = False

        if flag:
                res += 1
print(res)

Measured memory_bytes: 3064
#include<stdio.h>
int f(int a,int b){
int u,c=1;
for(u=0;u<b;u++)c*=a;
return c;
}
int main(){
int x,i,j,ans=1,y=0;
scanf("%d",&x);
for(i=2;i*i<=x;i++){
for(j=2;y<x;j++){
y=f(i,j);
if(y<=x&&y>ans)ans=y;
}
y=0;
}
printf("%d",ans);
return 0;

}

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

long long x, y, a, b, c;
vector<long long> p, q, r;
priority_queue<long long> pq;

long long solve();

int main() {
  cin >> x >> y >> a >> b >> c;
  p.resize(a);
  q.resize(b);
  r.resize(c);
  for(int i = 0; i < a; ++i) cin >> p[i];
  for(int i = 0; i < b; ++i) cin >> q[i];
  for(int i = 0; i < c; ++i) cin >> r[i];
  sort(p.begin(), p.end(), greater<long long>());
  sort(q.begin(), q.end(), greater<long long>());
  sort(r.begin(), r.end(), greater<long long>());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  while(p.size() != x) p.pop_back();
  while(q.size() != y) q.pop_back();
  for(auto t : p) pq.push(t);
  for(auto t : q) pq.push(t);
  for(auto t : r) pq.push(t);

  for(int i = 0; i < (x + y); ++i) {
    res += pq.top();
    pq.pop();
  }
  return res;
}

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

int main(void) {
	int n, k; cin >> n >> k;
	int i, a = 1;
	for (i = 0; i < n; i++) {
		if (a < k) { a *= 2; }
		else { a += k; }
	}

	cout << a << endl;

	return 0;
}



Measured memory_bytes: 256
// ABC056A - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	char a, b;
	cin >> a >> b;

	if ((a == 'H')&&(b == 'H')) {
		cout << 'H' << endl;
	} else if ((a == 'H')&&(b == 'D')) {
		cout << 'D' << endl;
	} else if ((a == 'D')&&(b == 'H')) {
		cout << 'D' << endl;
	} else if ((a == 'D')&&(b == 'D')) {
		cout << 'H' << endl;
	} else {
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int n,flg;   
    while(cin >> n){
        flg=0;
        for(int i=1;n>0;i*=2){
            if(n&1){
                if(flg>0)cout<<' ';
                cout<<i;
                flg=1;
            }
            n=n>>1;
        }
    cout<<endl;
    }
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int K; cin>>K;
    string S; cin>>S;
    if(S.size()<=K)cout<<S<<endl;
    else{
        rep(i,K)cout<<S.at(i);
        cout<<"..."<<endl;
    }
    
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 100100;
const int NONE = -1, WHITE = 0, BLACK = 1;

struct Node{ 
    int v; int w;

    Node() {}

    // コンストラクタ
    Node(int _v, int _w){
        v = _v;
        w = _w;
    }
};

vector<Node> to[MAX_N];
int color[MAX_N];
int n;

void init(){
    rep(i,MAX_N){
        color[i] = NONE;
    }
}

bool dfs(int u, int cur = WHITE){
    color[u] = cur;
    for(Node node: to[u]){
        // 隣接頂点の色がすでに確定していた場合
        if(color[node.v] != NONE){
            if((color[node.v] == cur && node.w % 2 == 1) || (color[node.v] != cur && node.w % 2 == 0)) return false;
            continue;
        }
        // 辺の重みを2で割った値に合わせて隣接頂点に色を塗る
        if(node.w % 2 == 1) if(!dfs(node.v, 1-cur)) return false;
        if(node.w % 2 == 0) if(!dfs(node.v, cur)) return false;
    }
    return true;
}

int main()
{
    cin >> n;   
    init();     // 初期化
    rep(_,n-1){
        int u, v, w; cin >> u >> v >> w;
        --u; --v;
        Node node1(v, w);
        Node node2(u, w);
        to[u].push_back(node1);
        to[v].push_back(node2);
    }
    if(dfs(0)){
        rep(i,n){
            cout << color[i] << endl;
        }
    }
    // cout << to[0][0].v << "," << to[0][0].w << endl;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N;
	cin >> N;
	int V[100];
	rep(i, N) cin >> V[i];
	sort(V, V + N);

	double kotae = V[0];
	rep1(i, N - 1) {
		kotae = (kotae + V[i]) / 2;
	}
	cout << setprecision(12) << kotae << endl;


	Would you please return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict


sys.setrecursionlimit(10**6)


def pair2index(i, j, N):
    return N * i + j


def main():
    N = int(input())
    adj = defaultdict(list)
    for i in range(N):
        A = list(map(lambda x: int(x) - 1, input().split(' ')))
        for j in range(1, N - 1):
            a = A[j - 1]
            from_index = pair2index(min(i, a), max(i, a), N)
            a = A[j]
            to_index = pair2index(min(i, a), max(i, a), N)
            adj[from_index].append(to_index)

    temp_visited = [0 for _ in range(N**2)]
    max_depth = [0 for _ in range(N**2)]

    def dfs(n):
        if temp_visited[n] == 1:
            # 閉路あり
            max_depth[n] = -1
            return -1
        elif max_depth[n] != 0:
            return max_depth[n]
        else:   # max_depth[n] == 0 (未探索)
            temp_visited[n] = 1
            max_d = 0
            for next_n in adj[n]:
                d = dfs(next_n)
                if d == -1:
                    return d
                max_d = max(max_d, d)
            temp_visited[n] = 0
            max_depth[n] = max_d + 1
            return max_d + 1

    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            node = pair2index(i, j, N)
            depth = dfs(node)
            if depth == -1:
                print(-1)
                return
            ans = max(ans, depth)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 260100
#include<stdio.h>
int main()
{
    int n,A,x;

    scanf("%d %d",&n, &A);

    if(n < 500)
    {
        if(n <= A)
            printf("Yes\n");
        else
            printf("No\n");
    }

    else if(n >= 500)
    {
        x = n % 500;
        if(x <= A)
            printf("Yes\n");
        else
            printf("No\n");
    }

    return 0;
}



Measured memory_bytes: 1608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

    string S;
    cin >> S;

    int rcnt = 0;
    int bcnt = 0;

    for(int i = 0; i < N; i++)
    {
        if(S[i] == 'R') rcnt++;
        else bcnt++;
    }

    if(rcnt > bcnt) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define MP make_pair
#define PB push_back
typedef long long LL;
const LL MOD = 998244353;
const int N = 2.5e6+10;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,m;
LL fac[N],ifac[N];

LL pw(LL x,int n){
	LL res = 1;
	for(;n;n>>=1,x=x*x%MOD)if(n&1)res=res*x%MOD;
	return res;
}

LL C(int n,int x){
	return fac[n] * ifac[x] % MOD * ifac[n-x] % MOD;
}

int main(){
	//freopen("test.in","r",stdin);
	cin>>n>>m;
	fac[0] = 1;
	rep(i,1,N-1)fac[i]=fac[i-1]*i%MOD;
	ifac[N-1] = pw(fac[N-1],MOD-2);
	rrep(i,N-2,0)ifac[i]=ifac[i+1]*(i+1)%MOD;
	//cout<<fac[1]*ifac[1]%MOD<<" "<<fac[2]*ifac[2]%MOD<<" "<<fac[3]*ifac[3]%MOD<<endl;
	int s = 3*m;
	LL num = C(s+n-1,n-1);
	LL sub1 = n * C(n+m-2, n-1) % MOD, sub2 = 0;
	for(int i=m+2;i<=min(3*m,n);i+=2){
		int s1 = (s-i)/2;
		sub2 = (sub2 + C(n, i) * C(s1+n-1, n-1)) % MOD;
	}
	cout<<(num - sub1 - sub2 + MOD * 2) % MOD<<endl;
	return 0;
}

Measured memory_bytes: 39296
#include <iostream>
using namespace std;
int main(void){
  int H,W,i,j,n;
  cin >> H;
  cin >> W;
   
  while(H != 0 && W != 0){
      for(i = 0; i < H; i++){
          for(j = 0; j < W; j++){
              if((i + j) % 2 == 0){
                  cout << "#";
              }
              else{
                  cout << ".";
              }
          }
          cout << endl;
      }
      cin >> H;
      cin >> W;
      cout << endl;
  }
}


Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	char a,b;
	cin>>a>>b;
	if(a=='H'&&b=='H')
	cout<<"H";
	if(a=='D'&&b=='D')
	cout<<"H";
	if(a=='H'&&b=='D')
	cout<<"D";
	if(a=='D'&&b=='H')
	cout<<"D";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	if((b-a)&1) puts("IMPOSSIBLE");
	else printf("%d\n",(a+b)/2); 
	return 0;
}

Measured memory_bytes: 256
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val sc = new FastScanner(System.in)
  val array = ArrayBuffer[Int]()
  val hashMap = mutable.HashMap[Int, Int]()
  val N: Int = sc.nextInt()
  1.to(N).foreach { _ =>
    val a = sc.nextInt()
    array.addOne(a)
    val count = hashMap.getOrElse(a, 0)
    hashMap.update(a, count + 1)
  }
  val patterns = (count: Long) => (count * (count - 1)) / 2
  val sum = hashMap.values.map { count => patterns(count) }.sum
  val cache = mutable.HashMap[Int, Long]()
  0.until(N).foreach { i =>
    val key = array(i)
    val result = cache.getOrElseUpdate(key,
      sum - patterns(hashMap(key)) + patterns(hashMap(key) - 1))
    println(result)
  }

  class FastScanner(in: java.io.InputStream) {
    val buffer = new Array[Byte](1024)
    var length = 0
    var p = 0

    def hasNextByte: Boolean =
      if (p < length) true
      else {
        p = 0
        length = in.read(buffer)
        if (length == 0) false else true
      }

    def readByte: Int = if (hasNextByte) buffer({ p += 1; p - 1 }) else -1

    def isPrintable(n: Int): Boolean = 33 <= n && n <= 126

    def skip(): Unit = while (hasNextByte && !isPrintable(buffer(p))) p += 1

    def hasNext: Boolean = {
      skip()
      hasNextByte
    }

    def next(): String = {
      if (!hasNext) throw new NoSuchElementException
      val sb = new java.lang.StringBuilder
      var temp = readByte
      while (isPrintable(temp)) {
        sb.appendCodePoint(temp)
        temp = readByte
      }
      sb.toString
    }

    def nextInt(): Int = Math.toIntExact(nextLong())

    def nextInts(n: Int): Array[Int] = {
      val ar = new Array[Int](n)
      for (i <- 0 until n) ar(i) = nextInt()
      ar
    }

    def nextLong(): Int = {
      if (!hasNext) throw new NoSuchElementException
      var minus = false
      var temp = readByte
      if (temp == '-') {
        minus = true
        temp = readByte
      }
      if (temp < '0' || '9' < temp) throw new NumberFormatException
      var n = 0
      while (isPrintable(temp)) {
        if ('0' <= temp && temp <= '9') {
          n *= 10
          n += temp - '0'
        }
        temp = readByte
      }
      if (minus) -n else n
    }
  }

}


Measured memory_bytes: 94364
import sys

n=0
sodd=""
seven=""
while True:
	c=sys.stdin.read(1)
	if c=="\n":
		break
	if n % 2 == 0:
		seven=seven+c
	else:
		sodd=sodd+c
	n=n+1

#010101...
nflip=seven.count('1')
nflip=nflip+sodd.count('0')

#101010...
nflip2=seven.count('0')
nflip2=nflip2+sodd.count('1')

print(min((nflip, nflip2)))



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {

            string input = Console.ReadLine();
            int r = int.Parse(input);


            r = 3 * (int)Math.Pow(r, 2);
            Console.WriteLine(r);

            return;
        }



    }
}


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

public class Main{
	public static void main(String[] args) throws Exception{
		PrintWriter pw=new PrintWriter(System.out);
		MScanner sc = new MScanner(System.in);
		HashSet<String>set=new HashSet<>();
		int h1=sc.nextInt(),a1=sc.nextInt();
		int h2=sc.nextInt(),a2=sc.nextInt();
		
		int t1=(h2+a1-1)/a1,t2=(h1+a2-1)/a2;
		pw.println(t1<=t2?"Yes":"No");
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static String arrToString(int[]x) {
		return Arrays.toString(x);
	}
	static String arrToString(long[]x) {
		return Arrays.toString(x);
	}
	static String arrToString(Integer[]x) {
		return Arrays.toString(x);
	}
	static String arrToString(Long[]x) {
		return Arrays.toString(x);
	}
}

Measured memory_bytes: 32832
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
 
long long MOD = 1000000007;

int main() {
    
    int Q;
    cin >> Q;
    vector<long long> A(Q);
    for ( int i = 0; i < Q; i++ ) {
        long long a,b,c,d;
        cin >> a >> b;
        c = a*b-1;
        d = static_cast<long long>(sqrt(c));

        long long x = max( d-2, 1LL );
        for ( ; x <= c/x ; x++ ) {}
        x--;
        long long ans = x*2;

        if ( ans == 0 ) { A[i] = 0; continue; }

        if ( x == c/x ) { ans--; }

        if ( x >= a ) { ans--; }
        if ( x >= b ) { ans--; }

        A[i] = ans;

    }
    for ( int i = 0; i < Q; i++ ) {
        cout << A[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

//int dx[] = {-1, 0, 1, 0},                  dy[] = {0, 1, 0, -1};                  // 4 Direction
//int dx[] = {-1, 0, 1, 0, -1, 1, 1, -1},    dy[] = {0, 1, 0, -1, -1, 1, -1, 1};    // 8 Direction

inline ll power(ll a, ll p){
    ll res = 1, x = a;
    while (p){
        if (p & 1) res = (res * x);
        x = (x * x), p >>= 1;
    }
    return res;
}
inline ll big_mod(ll a, ll p, ll m){
    ll res = 1 % m, x = a % m;
    while (p){
        if (p & 1) res = (res * x) % m;
        x = (x * x) % m, p >>= 1;
    }
    return res;
}

const ll INF = 1e15;

int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    int a, b;
    cin >> a >> b;
    if (a > b){
        swap(a, b);
    }
    if (a == 1 && b == 2){
        cout << 3 << endl;
    }
    else if (a == 2 && b == 3){
        cout << 1 << endl;
    }
    else {
        cout << 2 << endl;
    }
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int>h(n);
  for(int i=0;i<n;i++) cin>>h[i];
  vector<int>dp(n);
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for(int i=2;i<n;i++) dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Online Judge: Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define EMPP emplace_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n;
	cin >> n;
	vii a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] % 2 != 0)
			continue;
		else
		{
			while (a[i] % 2 == 0)
			{
				ans++;
				a[i] /= 2;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline
  import math
  n,k=map(int,input().split())
  ans=0
  for i in range(1,n+1):
    ans+=1/pow(2,max(int(math.ceil(math.log2(k/i))),0))         
  print(ans/n)
if __name__=='__main__':
  main()

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] b1 = new int[n][n];
        int[][] b2 = new int[n][n];
        for(int i=0; i<n; i++){
            String s = sc.next();
            for(int j=0; j<n; j++){
                b1[i][j] = s.charAt(j);
            }
        }
        int ans = 0;
        for(int i=0; i<n; i++){
            b2 = move(b1, n, i);
            if(check(b2, n)) ans += n;
        }
        System.out.println(ans);
    }

    public static int[][] move(int[][] b, int n, int m){
        int[][] ret = new int[n][n];
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(i+m < n){
                    ret[i][j] = b[i+m][j];
                }else{
                    ret[i][j] = b[i+m-n][j];
                }
            }
        }
        return ret;
    }

    public static boolean check(int[][] b, int n){
        for(int i=0; i<n-1; i++){
            for(int j=i+1; j<n; j++){
                if(b[i][j] != b[j][i]) return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 65076
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        string str;
        StringBuilder sb = new StringBuilder();
        while ((str = Console.ReadLine()) != "0 0") 
        {
            int[] arr = str.Split().Select(int.Parse).OrderBy(x => x).ToArray();
            sb.AppendLine($"{arr[0]} {arr[1]}");
        }
        Console.Write(sb);
    }
}


Measured memory_bytes: 16472
import math
n = int(input())
a = list(map(int,input().split()))
length = n
ans=0
for i in range(n):
    x = length-i-1
    tmp1 = length-i
    tmp2 = tmp1*2
    while tmp2 <= n:
        if a[tmp2-1]%2==1:
            a[x]+=1
        tmp2 += tmp1
    if a[x]%2==1:
        ans+=1
print(ans)
for i in range(n):
    if a[i]%2 == 1:
        print(i+1,end=" ")

Measured memory_bytes: 7276
//
// Created on 2020/02/22.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

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

const ll MAX =  1000000;//nCkのn,kの取りうるMAX
const int MOD = 1000000007;




long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//aのmod.mでの逆元を求める
long long modinv(long long a,long long m){
    long long b = m,u=1,v=0;
    while(b){
        long long t = a / b;
        a -= t * b ;
        swap(a,b);
        u -= t * v;
        swap(u,v);
    }
    u %= m;
    if (u < 0)u += m;
    return u;
}

//a / b mod. MOD を計算
long long div_mod(long long a,long long b){
    const int MOD = 1000000007;

    //aをMODで割ってからbの逆元をかける
    a %= MOD;
    return a * modinv(b,MOD)% MOD;
}

int main() {
    ll ans = 0;
    ll n;
    ll a;
    ll b;
    cin>>n>>a>>b;


    ans = modpow(2,n,MOD);
    ans --;

    vector<ll>com(max(a,b)+1);
    com[0]=1;
    ll k = 1;
    while (k <= max(a,b)){
        com[k] = div_mod(com[k-1]*(n+1-k),k);
        k+=1;
    }


    ans = mod(((ans%MOD)-(com[a]%MOD)),MOD);
    ans = mod(((ans%MOD)-(com[b]%MOD)),MOD);


    cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;

long gcd(long a, long b){
  if(a==0) return b;
  else return gcd(b%a, a);
}
long lcm(long c, long d){
  return c*d/gcd(c,d);
}


int main(){
  	long N;
    long M;
    cin >> N >> M;
    long a;
    long b[N];

    for(long i=0;i<N;i++){
      cin >> a;
      b[i] = a/2;
    }

    long r = 1;
    while(b[0]%2==0){
      r *= 2;
      b[0] /= 2;
    }

    for(long i=1;i<N;i++){
      if((b[i]%r)!=0){
        cout << 0 <<endl;
        return 0;
      }
      b[i] /= r;
      if(b[i]%2==0){
        cout << 0 <<endl;
        return 0;
      }
    }

    long l = b[0];
    for(long i=1;i<N;i++){
      l = lcm(l, b[i]); 
    }


    cout << (M/(l*r)+1)/2 <<endl;
    
  	return 0;
}


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

using namespace std;

bool check(string s, string t) {
  if (s == "") return true;
  int tt = 0, sz = s.size(), tz = t.size();
  for (int i = 0; i < sz; i++, tt++) {
    while (tt < tz && t[tt] != s[i]) tt++;
    if (tt == tz) break;
    if (i == sz - 1) return true;
  }
  return false;
}

int main(void) {
  string s, t;
  cin >> s >> t;

  int sz = s.size();
  bool yes = false;
  string p = "", q = "";
  for (int i = 0; i < sz; i++) {
    if (i & 1) q += s[i];
    else p += s[i];
  }
  yes |= check(p, t) || check(q, t);

  cout << (yes ? "Yes" : "No") << endl;

  return 0;
}


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

	class Program
	{
		static void Main(string[] args)
		{
			string[] values = Console.ReadLine().Split(' ');
			int x = int.Parse(values[0]);
			int a = int.Parse(values[1]);
			int solution = 0;
			if (x < a)
			{
				solution = 0;
			}
			else
			{
				solution = 10;
			}

			Console.WriteLine(solution.ToString());
	}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int factorial_modulo(int n)
{
	int result = 1;
	rep(i, 1, n)
	{
		result = result * i % mod;
		result = result % mod;
	}
	return result % mod;
}

int dp1[1000002], dp2[1000002];
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int x, y;
	cin >> x >> y;
	if (x < y / 2)
	{
		//cout << "n" << en;
		cout << 0 << en;
	}
	else if (y < x / 2)
	{
		//cout << "o" << en;
		cout << 0 << en;
	}
	else if ((x + y) % 3)
	{
		//cout << "t" << en;
		cout << 0 << en;
	}
	else
	{
		int m = (2 * x - y) / 3;
		int n = (2 * y - x) / 3;
		//cout << m << en << n << en;
		int q = (factorial_modulo(m) % mod * factorial_modulo(n) % mod) % mod;
		int m1 = factorial_modulo(m) % mod;
		int n1 = factorial_modulo(n) % mod;
		// cout << "m1 " << m1 << en;
		// cout << "n1 " << n1 << en;
		q = (m1 * n1) % mod;
		q = q % mod;
		int q1 = BE(q, mod - 2, mod);
		int p = factorial_modulo(m + n);
		// cout << p << en;
		//cout << q << en;
		int ans = (p % mod * q1 % mod) % mod;
		cout << ans % mod << en;
	}


	return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
string str;
int a,b,state;
int main() {
	cin>>str;
	a=(str[0]-'0')*10+str[1]-'0';
	b=(str[2]-'0')*10+str[3]-'0';
	if(a<=12 && a>0) {
		state+=1;
	}
	if(b<=12 && b>0) {
		state+=2;
	}
	//cout<<state<<endl;
	if(!state) {
		cout<<"NA"<<endl;
	} else {
		if(state==1) {
			cout<<"MMYY"<<endl;
		}
		if(state==2) {
			cout<<"YYMM"<<endl;
		}
		if(state==3) {
			cout<<"AMBIGUOUS"<<endl;
		}
	}
	return 0;
}

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

using namespace std;
#define ll long long

const int INF = 1e9+5;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+2;j++){
            if(j<n){
                dp[j]=min(dp[j],dp[i]+abs(ar[i]-ar[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024
n, y = map(int, input().split())
a = 0
b = 0
for a in range(n+1):
  for b in range(n-a+1):
    c = n - a - b
    if a * 10000 + b * 5000 + c * 1000 == y:
      print("{} {} {}".format(a, b, c))
      exit()
print("-1 -1 -1")

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;

  vector<ll> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i] ;
  }
  sort(A.rbegin(), A.rend());

  int index = 0;
  bool flg = true;
  ll ans = 0;
  for(int i = 0; i < N; i++){
    if(i == 0) continue;
    if(i == 1) {
      ans += A[0];
      index++;
    } else { 
      if(flg){
        ans += A[index];
        flg = false;
      } else { 
        ans += A[index];
        flg = true;
        index++;
      }
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll a,b;
cin>>a>>b;
if(a>=13)
cout<<b;
else if(a<6)
cout<<"0";
else
cout<<b/2;
}


Measured memory_bytes: 256
local a = io.read("*l")
local b = {}
for i = 1, string.len(a) do
    table.insert(b,string.sub(a,i,i))
end

local total = 0

if #b >= 3 then
    local numA = 0
    local i = 0
    while i < #b do
        if b[i] == 'A' then
            numA = numA + 1
        elseif (b[i] == 'B' and b[i + 1] == 'C') then
            total = total + numA
            i = i + 1
        else
            numA = 0
        end

        i = i + 1
    end
end

print(total)

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    priority_queue<double, vector<double>, greater<double> > q;
    rep(i,n) {
        double a; cin >> a;
        q.push(a);
    }
    rep(i,n-1){
        double a = q.top();
        q.pop();
        double b = q.top();
        q.pop();
        q.push((a+b)/2);
    }
    cout << fixed << setprecision(10) << q.top() << endl;   
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(x) for x in input().split()]

dict = {}
ans = 0
count = 0
for i in range(N):
    if not( a[i]//400 in dict.keys() ):
        dict[a[i]//400] = 1
    else:
        dict[a[i]//400] += 1
for key in dict.keys():
    if key < 8:
        ans += 1
    else:
        count += dict[key]
if ans == 0:
    print(1, count)
else:
    print(ans, ans+count)

Measured memory_bytes: 3064
#!/usr/bin/python3

import sys
from bisect import bisect_left
from collections import defaultdict

sys.setrecursionlimit(1000000)

n = int(input())
a = [int(i) for i in input().split()]

nbs = [ [] for _ in range(n) ]

for _ in range(n - 1):
    (u, v) = map(int, input().split())
    nbs[u - 1].append(v - 1)
    nbs[v - 1].append(u - 1)


mlen = defaultdict(int)

def getmlen(cur, p):
    for ch in nbs[cur]:
        if ch == p:
            continue

        if a[ch] > dp[-1]:
            dp.append(a[ch])
            mlen[ch] = len(dp)
            getmlen(ch, cur)
            dp.pop(-1)
        else:
            idx = bisect_left(dp, a[ch])
            ov = dp[idx]
            dp[idx] = a[ch]
            mlen[ch] = len(dp)
            getmlen(ch, cur)
            dp[idx] = ov
            

dp = []
dp.append(a[0])
mlen[0] = 1
getmlen(0, -1)

for i in range(n):
    print(mlen[i])


Measured memory_bytes: 378040
#include<bits/stdc++.h>
#define sz 1234567
using namespace std;
typedef long long ll;
long double dis(int x1,int y1,int x2,int y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
    int n;
    cin>>n;
    string s;
    for(int i=1;i<=n;i++) s+=i+'0';
    int x[n+10],y[n+10];
    for(int i=1;i<=n;i++) cin>>x[i]>>y[i];
    int total=0;
    long double sum=0.0;
    do {
        for(int i=0;i<s.size()-1;i++)
        {
            int x1=x[s[i]-'0'];
            int y1=y[s[i]-'0'];
            int x2=x[s[i+1]-'0'];
            int y2=y[s[i+1]-'0'];
            sum+=dis(x1,y1,x2,y2);
        }
        total++;
    }
    while(next_permutation(s.begin(),s.end()));
    long double ans=sum/(total*1.0);
    cout<<setprecision(14)<<ans<<endl;
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
        }
     return 0;   
}

Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(10**9)

n = int(input())

def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)

num = factorial(n)

ans = 1
for i in range(2, n+1):
    count = 0
    while num % i == 0:
        count += 1
        num = num // i
    ans *= (count + 1)

print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3700
ceildiv a b = div (a + b - 1) b

main = do
    [n, m] <- map read . words <$> getLine :: IO [Int]
    a <- map read . words <$> getLine :: IO [Int]
    putStrLn $ if (length . filter (>= ((sum a) `ceildiv` (4 * m)))) a >= m
                then "Yes"
                else "No"


Measured memory_bytes: 892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.DecimalFormat;

public class Main {
	public static void main(String[] args) {
		print();
	}

	private static void print() {
		DecimalFormat format = new DecimalFormat("#.#");
        format.setMinimumFractionDigits(3);
        format.setMaximumFractionDigits(3);

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String str = br.readLine();

			while (str != null) {

				String[] nums = str.split(" ", 0);

				BigDecimal a = new BigDecimal(Integer.parseInt(nums[0]));
				BigDecimal b = new BigDecimal(Integer.parseInt(nums[1]));
				BigDecimal c = new BigDecimal(Integer.parseInt(nums[2]));
				BigDecimal d = new BigDecimal(Integer.parseInt(nums[3]));
				BigDecimal e = new BigDecimal(Integer.parseInt(nums[4]));
				BigDecimal f = new BigDecimal(Integer.parseInt(nums[5]));

				BigDecimal xTemp = c.divide(a, 3, BigDecimal.ROUND_HALF_UP);
				BigDecimal xTemp2 = b.divide(a, 3, BigDecimal.ROUND_HALF_UP);
				BigDecimal x = new BigDecimal(0.000);
				BigDecimal y = new BigDecimal(0.000);
				y = f.subtract((c.multiply(d).divide(a,  3, BigDecimal.ROUND_HALF_UP)))
							.divide(e.subtract((b.multiply(d).divide(a,  3, BigDecimal.ROUND_HALF_UP))));
				x = (c.subtract(b.multiply(y))).divide(a,  3, BigDecimal.ROUND_HALF_UP);


				System.out.println(format.format(x) + " " + format.format(y));
				str = br.readLine();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 26060
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
    string s,t;
    cin>>s>>t;
    i64 n=s.size();
    for(i64 i=0;i<n;i++){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    int n, k;
    cin >> n >> k;

    vi a(n);
    rep(i, 0, n) { cin >> a[i]; }

    vi dp(k + 1, 0);
    dp[0] = -1;

    rep(i, 1, k + 1) {
        rep(j, 0, n) {
            if (i - a[j] >= 0 && dp[i - a[j]] == -1) {
                dp[i] = 1;
                break;
            }
        }
        if (dp[i] == 0) { dp[i] = -1; }
    }

    cout << (dp[k] == 1 ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		if(S.equals("Sunny"))
			System.out.println("Cloudy");
		if(S.equals("Cloudy"))
			System.out.println("Rainy");
		if(S.equals("Rainy"))
			System.out.println("Sunny");
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

ll calc(ll X) {
  ll ret = 0;
  ll st = X / 4 * 4;
  for (ll i = st; i <= X; i++) {
    ret ^= i;
  }
  return ret;
}

int main() {
  ll A, B;
  cin >> A >> B;
  cout << (calc(A - 1) ^ calc(B)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
//#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
//#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;


void P(auto a){
    REP(i,a.size()){
        if(i){
            cout << " ";
        }
        cout << a[i];
    }
    cout << "\n";
}


signed main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int q;
    cin >> n >> q;
    vector<stack<int>> a(n);
    REP(i,q){
        int tmp;
        cin >> tmp;
        switch (tmp)
        {
        case 0:
            int t,x;
            cin >> t >> x;
            a[t].push(x);
            break;
        case 1:
            cin >> t;
            if(a[t].size()!=0) print(a[t].top());
            break;
        default:
            cin >> t;
            if(a[t].size()!=0) a[t].pop();
            break;
        }
    }

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 4436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int s_length = s.length();
		String s_start = s.charAt(0) + "";
		String s_end = s.charAt(s_length - 1)+ "";
		int x = s_length - 2;
		System.out.println(s_start + x + s_end);
	}
}

Measured memory_bytes: 23124
import sys
read = sys.stdin.read

n = int(input())
A = list(map(int, read().split()))
if A[0] != 0:
  print(-1)
else:
  ans = 0
  A += [0]
  for i in range(n):
    if A[i+1] - A[i] > 1:
      print(-1)
      exit()
    if A[i]+1 != A[i+1]:
      ans += A[i]
  print(ans)

Measured memory_bytes: 25152
def i1():
    return int(input())
def i2():
     return [int(i) for i in input().split()]

n=i1()
def a():
    for i in range(1,3501):
     for j in range(1,3501):
            x=4*i*j-i*n-j*n
            if x>0 and (n*j*i)%x==0:
                print(i,j,int((n*j*i)/x))
                return 0
a()

Measured memory_bytes: 39024
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }

int main() {
    long long n, m; cin >> n >> m;
    string s, t; cin >> s >> t;
    long long g = gcd(n, m);
    for (int i = 0; i < g; i++) {
        if (s[n / g * i] != t[m / g * i]) return !(cout << -1 << endl);
    }
    cout << n / g * m << endl;
    return 0;
}


Measured memory_bytes: 512