akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX (100001)

using namespace std;

typedef long long ll;

ll q, l[MAX], r[MAX];
/* 素数であるかのフラグ */
bool isPrime[MAX];
/* 2017に似た数の累積和 */
ll primeCount[MAX];

int main() {
    fill(isPrime, isPrime + MAX, false);
    
    FOR(i, 2, MAX) {
        if(!isPrime[i]) {
            for (int j = 2 * i; j <= MAX - 1; j += i) {
                isPrime[j] = true;
            }
        }
    }
    
    primeCount[2] = 0;
    for(ll i = 3; i <= MAX; i += 2) {
        if (!isPrime[i] && !isPrime[(i + 1) / 2]) {
            primeCount[i]++;
        }
    }
    
    FOR(i, 3, MAX) {
        primeCount[i] += primeCount[i - 1];
    }
    
    cin >> q;
    
    REP(i, q) {
        cin >> l[i] >> r[i];
    }
    
    REP(i, q) {
        cout << primeCount[r[i]] - primeCount[l[i] - 1] << endl;
    }
}


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

int main() {
    bool c = false;
    int n, q, ans = 0;
    cin >> n;
    vector<int> S(n);
    for(int i = 0; i < n; i++) {
        cin >> S.at(i);
    }
    cin >> q;
    vector<int> T(q);
    for(int i = 0; i < q; i++) {
        cin >> T.at(i);
    }
    for(int i = 0; i < q; i++) {
        for(int j = 0; j < n; j++) {
            if(T.at(i) == S.at(j)) c = true;
        }
    if(c) ans++;
    c = false;
    }
    cout << ans << endl;
}


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

int main()
{
    double r;
    cin >> r;
    double ans = 2*r*3.14;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    long long x, k, d;
    cin >> x >> k >> d;
    if (x < 0) x = -x;
    long long temp;
    if (x % d == 0) temp = x / d;
    else temp = x / d + 1;
    if (k < temp) {
        printf("%lld\n", x - k * d);
        return 0;
    }
    k -= temp;
    x -= (temp * d);
    if (k % 2 == 0) printf("%lld\n", abs(x));
    else {
        printf("%lld\n", abs(x + d));
    }
    return 0;
}


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

int main()
{
  int64_t X;
  cin >> X;
  for (int64_t a = 0; a <= 1000; a++)
  {
    for (int64_t b = -1000; b <= 1000; b++)
    {
      int64_t a5 = 1, b5 = 1;
      for (int i = 0; i < 5; i++)
        a5 *= a;
      for (int i = 0; i < 5; i++)
        b5 *= b;
      if (a5 - b5 == X)
      {
        cout << a << ' ' << b << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

struct UnionFind
{
    vector<ll> r, p;
    UnionFind(){}
    UnionFind(ll& size){init(size);}
    void init (ll& size)
    {
        r.resize(size,0);
        p.resize(size,0);
        fill(r.begin(), r.end(), 1);
        iota(p.begin(), p.end(), 0);
    }
    ll find(ll & x)
    {
        return (x==p[x] ? x : p[x] = find(p[x]));
    }
    bool same (ll& x, ll& y)
    {
        return find(x) == find(y);
    }
    void unite(ll&x, ll&y)
    {
        x = find(x); y = find(y);
        if (x == y) return;
        if (r[x] < r[y]) swap(x,y);
        r[x] += r[y];
        p[y] = x;
    }
};

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

    ll n, q;
    cin >> n >> q;
    UnionFind uf(n);
    for(ll i=0; i<q; i++)
    { 
        ll c, x, y;
        cin >> c >> x >> y;
        if (c) cout << uf.same(x,y) << endl;
        else uf.unite(x,y);
    }

    return 0;
}



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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

double ki(double a){
    int su = 0;
    for(int i = 1; i <= a; i++) su += i;
    return su / a;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    REP(i, N) cin >> p[i];
    double ans = 0;
    if(N == 1) {
        ans = ki(p[0]);
        cout << fixed << setprecision(10) << ans << endl;
        return 0;
    }
    ll sum = 0;
    REP(i, K){
        sum += p[i];
    }
    ll now = sum;
    int pos = 0;

    for(int i = 1; i + (K - 1) < N; i++){
    now -= p[i - 1];
    now += p[i + (K - 1)];
    if(sum < now) pos = i;
    sum = max(sum, now);
    }
     for(int i = pos; i <= pos + (K - 1); i++){
         ans += ki(p[i]);
     }
     cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int n,T,s,dp[3001],t[3000],v[3000],ans;

int main(){
	scanf("%d%d%d",&n,&T,&s);
	rep(i,n) scanf("%d%d",&v[i],&t[i]);
	rep(i,n){
		for(int j = T; j >= 0; j--){
			if((j<s&&j+t[i]>s)||j+t[i]>T)continue;
			dp[j+t[i]]=max(dp[j+t[i]],dp[j]+v[i]);
		}
	}
	rep(i,T+1)ans=max(ans,dp[i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 1060
import sys
input = sys.stdin.readline
def main():
    A, B, M = map( int, input().split())
    a = list( map( int, input().split()))
    b = list( map( int, input().split()))
    X = [ tuple( map( int, input().split())) for _ in range(M)]
    ans = min(a) + min(b)
    for x, y, c in X:
        if a[x-1] + b[y-1] - c < ans:
            ans = a[x-1] + b[y-1] - c
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 29508
<?php
//error_reporting(0);
list($N,$K) =  explode(" ",trim(fgets(STDIN)));
$S = trim(fgets(STDIN));
//$H=explode(" ",trim(fgets(STDIN)));
$len = strlen($S);
$now = 1;
$cnt = 0;
$Nums = array();
for($i=0;$i<$N;$i++) {
  if ($S[$i]==$now?"1":"0") {
    $cnt++;
  }
  else {
    $Nums[]=$cnt;
    $now = 1 - $now;;
    $cnt=1;
  }
}
if ($cnt != 0) {
  $Nums[]=$cnt;
}
if ((count($Nums)%2)==0){
  $Nums[]=0;
}
$Add = 2 * $K + 1;
$sum = array_fill(0,count($Nums)+1,0);
for($i=0;$i<count($Nums);$i++) {
  $sum[$i+1]=$sum[$i]+$Nums[$i];
}
$ans = 0;
for($i=0;$i<count($Nums);$i+=2)
{
  $left = $i;
  $right = min($i + $Add,count($Nums));
  $tmp = $sum[$right]-$sum[$left];
  $ans = max($tmp,$ans);
}
printf("%d\n",$ans);


Measured memory_bytes: 12788
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * node;

#define NIL NULL

void insert(int);
void inorder(node );
void preorder(node );
void treeDelete(node );

node treeSearch(node , int );
node treeMinimum(node );
node treeMaximum(node );
node treeSuccessor(node );

node T;

int main(){
  int n;
  char read[8];
  int k;
  int i;
  int x;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    if(scanf("%s",read)==EOF)break;
    if(read[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    if(read[0]=='p'){
      inorder(T);
      printf("\n");
      preorder(T);
      printf("\n");
    }
    if ( read[0] == 'f' ){
      scanf("%d", &x);
      node t = treeSearch(T, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    if ( read[0] == 'd' ){
      scanf("%d", &x);
      node t = treeSearch(T, x);
      treeDelete(t);
    }
  }
  return 0;
}

void insert(int k){

  node y = NIL;
  node x = T;
  node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;


  
 
  y=NIL;
  x=T;
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;

  }
  z->p=y;
  if(y==NIL){
    T=z;
  }
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  
	       
}
void preorder(node u){

  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

node treeSearch(node u, int k){
  if(u==NIL){
    return u;
  }
  if(u->key==k){
    return u;
  }
  if(u->key>k){
    treeSearch(u->left,k);
  }
  else  treeSearch(u->right,k);
}

node treeMinimum(node x){
  while(x->left!=NIL){
     x=x->left;
  }
  return x;
}

node treeMaximum(node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;
}

node treeSuccessor(node x){
  node y;
  if(x->right!=NIL) return treeMinimum(x->right);
  y=x->p;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->p;
  }
  return y;
}

void treeDelete(node z){
  node x,y;
  if(z->left==NIL||z->right==NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;
  
  if(x!=NIL) x->p=y->p;

  if(y->p==NIL) T=x;
  else if(y==y->p->left) y->p->left=x;
  else y->p->right=x;
 
  if(y!=z) z->key=y->key;
}


Measured memory_bytes: 20440
#include <iostream>
using namespace std;
    int main(void){
        int H, W, h, w;
        const char sharp = '#';
        const char space = '.';

        cin >> H >> W;
        while( H != 0 || W != 0 ){
            for( h = 0; h < H; h++ ){
                for( w = 0; w < W; w++ ){
                    if( h == 0 || w == 0 || h == H-1 || w == W-1 ){
                        cout << sharp; 
                    }
                    else{
                        cout << space;
                    }
                }
                cout << endl;
            }
        cout << endl;
        cin >> H >> W;
        }
    }


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	vector<string> c(3);
	string ans;
	for (int i = 0; i < 3; i++) cin >> c[i];
	for (int i = 0; i < 3; i++) {
		ans.push_back(c[i][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
A, B, C, X = 4.times.map { gets.to_i }
count = 0

(0..A).each do |i|
  (0..B).each do |j|
    (0..C).each do |k|
      count += 1 if 500*i + 100*j + 50*k == X
    end
  end
end

puts count

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    string S; cin>>S;
    int a[4];
    rep(i,4){
        a[i]=S[i]-'0';
    }    
    rep(bit,1<<3){
        int ans=a[0];
        char c[3]={'+','+','+'};
        rep(i,3){
            if(bit&(1<<i)){
                ans+=a[i+1];
            }
            else {
                ans-=a[i+1];
                c[i]='-';
            }
        }
        if(ans==7){
            rep(i,3){
                cout<<S[i]<<c[i];
            }
            cout<<S[3]<<"=7"<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <ctype.h>

char data[8][2][33] = {
	{"\',.?CDFHIKLOSTW"," -ABEGJMNPQRUVXYZ"},
	{" \',-?ABDGJLMNOQRSTUVWXYZ",".CEFHIKP"},
	{"\',-.?ABCDEFGHJMNQRUVWXYZ"," IKLOPST"},
	{"\',.?FHKLORW","-ABCDGIJMNQSTUVXYZ"},
	{"\'-.?AHLSXYZ",",BFGJMNOQTUVW"},
	{"\'-BGHJMWXYZ",",.?ANQUV"},
	{"-JMUVZ","BGNQXY"},
	{"BJNUXZ","-GMQVY"},
};

char data2[7] = " .,-\'?";

int main(){
	int i,j,k,l,p,tmp;
	char str[101];

	while(gets(str) != NULL){
		p = 0;
		tmp = 0;
		for(i = 0;str[i] != '\0';i++){
			for(j = 0;j < 8;j++){
				for(k = 0;k < 2;k++){
					for(l = 0;data[j][k][l] != '\0';l++){
						if(data[j][k][l] == str[i]){
							tmp *= 2;
							tmp += k;
							p++;
							if(p == 5){
								if(tmp < 26){
									putchar(tmp+'A');
								}else{
									putchar(data2[tmp-26]);
								}
								p = 0;
								tmp = 0;
							}
							goto ok;
						}
					}
				}
				ok:;
			}
		}
		if(p){
			for(i = p;i < 5;i++){
				tmp *= 2;
				tmp += 0;
			}
			if(tmp < 26){
				putchar(tmp+'A');
			}else{
				putchar(data2[tmp-26]);
			}
		}
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 524
let i=readLine()!.characters.split(" ").map{Int(String($0))!},H=i[0],W=i[1],a=(0..<H).map{_ in readLine()!.characters.map{String($0)}}
var r=(0..<H).map{_ in false},c=(0..<W).map{_ in false}
for i in 0..<H{for j in 0..<W{if a[i][j]=="#"{r[i]=true;c[j]=true}}}
for i in 0..<H{if r[i]{for j in 0..<W{if c[j]{print(a[i][j],terminator: "")}};print()}}

Measured memory_bytes: 1408
///-----Bismillahir Rahmanir Rahim-----///

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

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
///vector
typedef vector<int> vi;
typedef vector<ll> vl;
///pair
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        int ans;
        for(int i=1;i<=5;i++)
        {
            int x;
            cin>>x;
            if(x==0) ans=i;
        }
        cout<<ans<<endl;

    }
    return 0;
}


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

int main(){
int N,K;
  cin>>N>>K;
  vector<int>x(N);
  for(int i=0; i<N; i++){
   cin>>x[i]; }
  
  int sum=0;
  for(int i=0; i<N; i++){
   if(abs(x[i]-K)<x[i]){sum+=abs(x[i]-K)*2;}
   else{sum+=x[i]*2;}
  }
  
  cout<<sum;
}

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

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

  int n;
  cin >> n;
  map<string, int> strings;
  int max_called = 0;
  rep(i, n) {
    string s;
    cin >> s;
    strings[s]++;
    max_called = max(max_called, strings[s]);
  }

  vector<string> answers;
  for(auto itr = strings.begin(); itr != strings.end(); ++itr) {
    if(itr->second == max_called) {
      answers.push_back(itr->first);
    }
  }

  sort(answers.begin(), answers.end());
  rep(i, answers.size()) {
    cout << answers[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 25840
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);

	public static void main(String[] $){
		int[]a=new int[11];
		while(true){
			int n=s.nextInt();
			if(n==0)
				return;
			int r=0;
			for(int i=0;i*i<n;++i) {
				for(int j=i;i*i+j*j<n;++j) {
					for(int k=j;i*i+j*j+k*k<n;++k) {
						for(int l=k;i*i+j*j+k*k+l*l<=n;++l) {
							if(i*i+j*j+k*k+l*l==n) {
								++r;
								break;
							}
						}
					}
				}
			}
			System.out.println(r);
		}
	}
}


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

using namespace std;

template<typename T> class union_find {
    private:
    vector<T> par, _size;
    public:
    union_find(T n): par(n), _size(n,1) {
        for(T i=0;i<n;++i) {
            par[i] = i;
        }
    }

    T root(T x) {
        if (par[x] == x) {
            return x;
        }
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(T x, T y) {
        x = root(x);
        y = root(y);
        if(x==y) return;

        if (size(x)<size(y)) swap(x,y);

        par[y] = x;
        _size[x] += _size[y];
    }
    
    bool same(T x, T y) {
        return root(x) == root(y);
    }

    T size(T x) {
        x = root(x);
        return _size[x];
    }

    void explain() {
        for(T i=0;i<par.size();++i) {
            cout << i << " " << root(i) << " " << size(i) << endl;
        }
    }
};

int main(int argc, char const *argv[])
{
    int n, m; cin >> n >> m;
    union_find<int> uf(n);
    vector<int> a(m), b(m);
    for(int j=0;j<m;++j) {
        cin >> a[j] >> b[j];
        --a[j]; --b[j];
    }
    vector<unsigned long long> ans(m);
    ans[m-1] = (n*(n-1uLL))/2uLL;
    for(int j=m-2;j>=0;--j) {
        if (uf.same(a[j+1], b[j+1])) {
            ans[j] = ans[j+1];
        } else {
            ans[j] = ans[j+1] - uf.size(a[j+1]) * uf.size(b[j+1]);
            uf.unite(a[j+1], b[j+1]);
        }
    }

    for(int j=0;j<m;++j) {
        cout << ans[j] << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int a, b, c, ans;
	cin >> a >> b >> c;
	ans = min(c, b / a);
	cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		long a = 1;
		long b = 1;

		for (int i = 0; i < N; i++) {
			String[] S = sc.nextLine().split(" ");
			int x = Integer.parseInt(S[0]);
			int y = Integer.parseInt(S[1]);

			long n = Math.max(((a + x - 1) / x), ((b + y - 1) / y));

			a = x * n;
			b = y * n;

		}

		long ans = a + b;
		System.out.println(ans);
	}
}

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

long long ara[12],fck[12],sck[12];

int main()
{

    long long n,m,a,b,c,d,e,i,j,p=1,fr=0,sc=0;  ara[0]=1;

    for(i=1;i<=9;i++)
    {
        p=p*i;  ara[i]=p;

    }

    scanf("%lld",&n);

    b=n;

    for(i=1;i<=n;i++)
    {
        scanf("%lld",&a);

        if(i<n)
        {
            e=0;

            for(j=1;j<=n;j++)
            {
                if(fck[j]==0)e++;

                if(a==j){ fck[j]=1; break; }
            }

            c=ara[b]/b;  b--;
            d=c*(e-1);
            if(fr==0)fr=d+1;
            else
                fr=fr+d;


        }


    }

    b=n;

     for(i=1;i<=n;i++)
    {
        scanf("%lld",&a);

        if(i<n)
        {
            e=0;

            for(j=1;j<=n;j++)
            {
                if(sck[j]==0)e++;

                if(a==j){  sck[j]=1; break; }
            }

             c=ara[b]/b;  b--;
            d=c*(e-1);
            if(sc==0)sc=d+1;
            else
                sc=sc+d;


        }


    }



    printf("%lld\n",abs(fr-sc));



    return 0;
}


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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
    int n,m;cin>>n>>m;
    int arr[n];
    ll total_votes = 0;
    frepi(0,n-1,1)
    {
    	cin>>arr[i];
    	total_votes+=arr[i];
    }
    double req = ((double)total_votes/((double)m*(4.0)));
    sort(arr,arr+n,greater<int>());
    int count = 0;
    for(int i=0;i<n;++i)
    {
    	if(arr[i]>=req)
    	{
    		count++;
    	}
    }
    if(count>=m)
    	cout<<"Yes\n";
    else
    	cout<<"No\n";
    
}

int main()
{
	#ifndef ONLINE_JUDGE
    	freopen("/home/suryakant/input.txt","r",stdin);
        freopen("/home/suryakant/output.txt","w",stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 1 && b % 2 == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define p 1000000007
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans;
int a[200010],qz[200010],inv[200010];
int main(){
	n=r;inv[0]=inv[1]=1;
	for(rt i=1;i<=n;i++)a[i]=r;
	for(rt i=2;i<=n;i++)inv[i]=1ll*inv[p%i]*(p-p/i)%p;
	for(rt i=2;i<=n;i++)(inv[i]+=inv[i-1])%=p;
	for(rt i=1;i<=n;i++)(ans+=1ll*a[i]*(inv[i]+inv[n-i+1]-1)%p)%=p;
	for(rt i=2;i<=n;i++)ans=1ll*ans*i%p;cout<<ans; 
	return 0;
}


Measured memory_bytes: 1024
from collections import Counter
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=[0]*n
s[0]=a[0]%m
for i in range(1,n):
    s[i]=(s[i-1]+a[i])%m
S=Counter(s)
ans=0
for i in S.values():
    ans+=i*(i-1)//2
print(ans if 0 not in S.keys() else ans+S[0])


Measured memory_bytes: 62576
#include<bits/stdc++.h>
using namespace std;
int cnt_digits(long long n){
  int digits = 0;
  while(n > 0){
    n /= 10;
    digits++;
  }
  return digits;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  int res = cnt_digits(n);
  for(long long A = 1LL; A*A <= n; A++){
    if(n%A != 0) continue;
    long long B = n/A;
    int cur = max(cnt_digits(A), cnt_digits(B));
    res = min(cur, res);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{ 
    ll n,i;
    cin >> n;
    ll h[n],dp[n];
    for(i=0;i<n;i++) cin >> h[i];
    dp[0]=0; dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++) dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    cout << dp[n-1] << "\n";
}

 
int main()
{
    opt;
    solve();
    return 0;
}       

Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>

using namespace std;

int n, mochi[105];

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &mochi[i]);
    }

    sort(mochi, mochi+n);
    int last = mochi[0];
    int ly = 1;
    for(int i=1; i<n; i++){
        if(mochi[i] > last){
            ly +=1;
            last = mochi[i];
        }
    }

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


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n, c;
    cin >> n >> c;
    vector<vector<int>> xs(c, vector<int>((int)1e5 + 1));
    for (int i = 0; i < n; ++i) {
        int s, t, c;
        cin >> s >> t >> c;
        --c;
        ++xs[c][s];
        --xs[c][t];
    }
    for (int ci = 0; ci < c; ++ci) {
        for (int xi = 1; xi < xs[ci].size(); ++xi) {
            xs[ci][xi] += xs[ci][xi - 1];
        }
    }
    for (int ci = 0; ci < c; ++ci) {
        for (int xi = 1; xi < xs[ci].size(); ++xi) {
            if (xs[ci][xi - 1] == 0 && xs[ci][xi] == 1)
                xs[ci][xi - 1] = 1;
        }
    }
    int ans = 0;
    for (int xi = 0; xi < xs[0].size(); ++xi) {
        int s = 0;
        for (int ci = 0; ci < c; ++ci) {
            s += xs[ci][xi];
        }
        ans = max(ans, s);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12416
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

string a, b, c;

int main() {
	cin >> a;
	cin >> b;
	for (int i = 0;; i++) {
		c += a[i];
		c += b[i];
		if (a[i] == char{} || (b[i] == char{} && a[i + 1] == char{})) {
			break;
		}
	}
	cout << c.data() << endl;
	return 0;
}

Measured memory_bytes: 256
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll N;
vl A;
vl B;
vl C;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    A = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    B = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> B[i];
    }
    C = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> C[i];
    }
    solve();
}

// 1 <= N <= 10^5
// 1 <= A_i <= 10^9(1<= i<= N)
// 1 <= B_i <= 10^9(1<= i<= N)
// 1 <= C_i <= 10^9(1<= i<= N)
// 入力は全て整数である

// ll N, vl A, vl B, vl C
// りんごさんが作ることのできる祭壇の種類数を出力せよ。
void solve(){
    sort(all(A));
    sort(all(B));
    sort(all(C));

    ll ans=0;
    rep(i,N){
        ll a=lower_bound(all(A),B[i])-A.begin();
        ll c=C.end()-upper_bound(all(C),B[i]);
        ans+=a*c;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int l, r, d;

int main() {
	fastio; cin >> l >> r >> d;
  cout << (r/d) - ((l-1)/d);
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
using namespace std;
const int oo = 1000000005;

int main() {
  int n, k;
  while ( cin >> n >> k ) {
    k = min(n, k);
    vector<int> nums(n), dp(n, oo);
    for ( auto& i : nums ) cin >> i;
    for ( int i = 0; i < k; ++i ) dp[i] = abs(nums[i] - nums[0]);

    for ( int i = k; i < n; ++i ) {
      for ( int j = 1; j <= k; ++j ) {
        dp[i] = min(dp[i], dp[i - j] + abs(nums[i] - nums[i - j]));
      }
    }
    cout << dp[n - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
def main():
    """
    2 <=  N <= 10^3
    2 <= ai <= 10^5

    非負整数 m に対して
    f(m) = (m mod a1) + (m mod a2) + (m mod aN)
    f_max

    mの制約は問題文中には直接記述されていない
    """
    N = int(input())
    *A, = map(int, input().split())

    ans = f(N, A)
    print(ans)


def f(N, A):
    """
    直感: 最小公倍数,最大公約数
        最小公倍数のm ならすべてのaで割り切れる
        つまり最小公倍数-1 ならすべてのaについて m mod ai = ai - 1

    m=a_MAX-1, (m mod a_MAX) が最大
    ただし他のa=a_MAX-1 の場合、f(m)は小さくなってしまう
    aiに対して1 <= m <= a_Max-1 をすべて試す: 10^5 * 3 * 10^3 => TLE
    """
    try:
        # py3.5
        from math import gcd
    except:
        from fractions import gcd

    def lcm(x, y):
        return x * y // gcd(x, y)

    m1 = lcm(A[0], A[1])
    for a in A[2:]:
        m1 = lcm(m1, a)

    m = m1 - 1
    ans = sum(m % a for a in A)

    return ans


def WA(N, A):
    ans = 0
    m_max = max(A) * 2 - 1
    for m in range(1, m_max):
        mods = [m % a for a in A]
        tmp = sum(mods)
        print(*(mods + [tmp]), sep="\t")
        ans = max(ans, tmp)

    return ans


if __name__ == '__main__':
    main()


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

int main(){
  int n,m;
  cin>>n>>m;
  bool s=false;
  for(int i=0;i<=n;i++){
    if(2*i+4*(n-i)==m) s=true;
  }
  if(s) cout <<"Yes"<<endl;
  else cout <<"No" <<endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    int a , b , c;

    cin >> a >> b>> c;

    if (a >=1 && a<=100 && b >=1 && b<=100 & c >=1 && c<=100){

        if ( a+b == c || c+b ==a || a+c == b)

        cout << "Yes";

        else
        cout << "No";
    }
    return 0;
}

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

int main() {
  int ans=0, A, B;
  cin >> A >> B;
  
  for (int i=A; i<=B; i++) {
    string str = to_string(i);
    
    int l=str.length(),num=1;
    
    rep(i ,l) if(str[i] != str[l-i-1]) {
      num=0;
      break;
    }
    
    ans += num;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h;
  while (cin >> h, h) {
    vector<vector<int>> a(5, vector<int>(2 * h));
    for (int i = h; i--; ) {
      for (int j = 0; j < 5; ++j) {
        cin >> a[j][i];
      }
    }
    int res = 0;
    while (true) {
      bool any = false;
      for (int i = h; i--; ) {
        if (a[2][i] == 0) {
          continue;
        }
        int l = 2, r = 2;
        while (l and a[l - 1][i] == a[2][i]) {
          --l;
        }
        while (r < 4 and a[r + 1][i] == a[2][i]) {
          ++r;
        }
        if (r - l >= 2) {
          any = true;
          res += a[2][i] * (r - l + 1);
          for (int j = l; j <= r; ++j) {
            a[j].erase(begin(a[j]) + i);
          }
        }
      }
      if (not any) {
        break;
      }
    }
    cout << res << '\n';
  }
}



Measured memory_bytes: 3132
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

void solve() {
    int N, M;
    cin >> N >> M;
    vector<bool>AC(N + 1, 0);
    vector<int>WA(N + 1, 0);
    int numAC = 0, numWA = 0;

    for (int i = 0; i < M; i++) {
        int p;
        string S;
        cin >> p >> S;
        if (AC[p] == false && S == "AC") {
            AC[p] = true;
            numAC++;
            numWA += WA[p];
        }
        else if (AC[p] == false && S == "WA") {
            WA[p]++;
        }
    }

    cout << numAC << " " << numWA;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 640
local PairingHeap={}

PairingHeap.merge=function(self,a,b)
    if not a then
        return b
    elseif not b then
        return a
    elseif a[1]<b[1] then
        b[4]=a[3]
        a[3]=b
        return a
    else
        a[4]=b[3]
        b[3]=a
        return b
    end
end

PairingHeap.twopassmerge=function(self,a)
    local b=a and a[4]
    if b then
        local newnode=b[4]
        a[4]=false
        b[4]=false
        return self:merge(self:merge(a,b),self:twopassmerge(newnode))
    else
        return a
    end
end

PairingHeap.empty=function(self)
    return not self.root
end

PairingHeap.pop=function(self)
    local root=self.root
    local value=root[2]
    self.root=self:twopassmerge(root[3])
    for i=1,4 do
        root[i]=false
    end
    table.insert(self,root)
    return value
end

PairingHeap.push=function(self,key,value)
    local root=self.root
    if root and root[1]<key then
        root[3]={
            key,
            value,
            false,
            root[3],
        }
    else
        self.root={
            key,
            value,
            root,
            false,
        }
    end
end

PairingHeap.join=function(self,other)
    local a=self.root
    local b=other.root
    if a[1]<b[1]then
        b[4]=a[3]
        a[3]=b
    else
        a[4]=b[3]
        b[3]=a
        self.root=b
    end
    return self
end

PairingHeap.new=function(self)
    local obj={}
    setmetatable(obj,{__index=PairingHeap})
    return obj
end

----------

local xyz={io.read("n","n","n")}
local k=io.read("n")
local abc={}
for i=1,3 do
    abc[i]={}
    for j=1,xyz[i] do
        abc[i][j]=io.read("n")
    end
    table.sort(abc[i],function(a,b)
        return a>b
    end)
end

local pq=PairingHeap:new()
local map={}

local frstky=abc[1][1]+abc[2][1]+abc[3][1]
pq:push(-frstky,{1,1,1,frstky})

for i=1,k do
    local pop=pq:pop()
    print(pop[4])
    for j=1,3 do
        if pop[j]<xyz[j] then
            local key=pop[4]-abc[j][pop[j]]+abc[j][pop[j]+1]
            local val={pop[1],pop[2],pop[3],key}
            val[j]=val[j]+1
            local mapkey=table.concat(val," ")
            if not map[mapkey] then
                map[mapkey]=true
                pq:push(-key,val)
            end
        end
    end
end

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

typedef long long ll;
#define MOD 1000000007
int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<char>> arr(n, vector<char>(m));
	vector<vector<int>> dp_arr(n+1, vector<int>(m+1,0));
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
		}
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(i == 1 && j == 1)
				dp_arr[i][j] = 1;
			else if(arr[i-1][j-1] == '#')
				dp_arr[i][j] = 0;
			else
			{
				dp_arr[i][j] = (dp_arr[i-1][j] + dp_arr[i][j-1])%MOD;
			}
			// cout << dp_arr[i][j] << endl;
		}
	}
	cout << dp_arr[n][m] << endl;
	return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) {
        a--;
    } else {
        b--;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define erep(i,l,r) for((i)=(l);(i)<=(r);(i)++)
#define drep(i,l,r) for((i)=(l);(i)>=(r);(i)--)
#define MOD 1000000007
#define ll long long
#define MAX(a,b) ((a)>(b)?(a):(b))
using namespace std;
int main(){
    int n,i,j;
    cin>>n;
    int a[n],b[n],c[n],ans=0;
    
    rep(i,0,n)cin>>a[i];
    rep(i,0,n)cin>>b[i];
    rep(i,0,n)cin>>c[i];
    
    rep(i,0,n){
        ans+=b[a[i]-1];
        if(i<n-1&&a[i]==a[i+1]-1)ans+=c[a[i]-1];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int k, n;
   cin >> k >> n;
   vector<int> a(n);
   rep(i, 0, n) cin >> a[i];
   int mx = a[0] + k - a[n - 1];
   rep(i, 0, n) {
      mx = max({mx, a[(i + 1) % n] - a[i], a[(i - 1) % n] - a[i]});
   }
   ll ans = k - mx;
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin>>a.at(i);
    a.at(i)--;
  }

  set<int> already;
  bool ok=false;
  int ans=0;
  int now=0;
  int size=0;
  while(true){
    already.insert(now);
    int presize=already.size();
    if(now==1){
      ok=true;
      break;
    }
    if(size==presize){
      break;
    }else{
      size=presize;
    }
    now=a.at(now);
    ans++;
  }
  if(ok){
    cout<<ans<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 5376
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
  
fn main() {
	let x: i32 = read();
    let a: i32 = read();
    
    if x < a {
    	println!(0);
    } else {
    	println!(10);
    }
}


Measured memory_bytes: 4352
n = input()
#隙間の数
a = len(n)-1
for i in range(2**a):
  l = ["-"]*a
  for j in range(a):
    if ((i>>j)&1):
      l[a-1-j] = "+"
#上記で全てのパターンできた。
  f = ""
  for aa,bb in zip(n,l+[""]):
    f  += (aa+bb)
  if eval(f)==7:
    print(f+'=7')
    break

#qiitaのbit全探索見ながらやった

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
char s[1<<20];
void GG()
{
	puts("No");
	exit(0);
}
int main()
{
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	scanf("%s",s+1);
	for(int i=a;i<b;i++)
		if(s[i]=='#'&&s[i+1]=='#')GG();
	for(int i=c;i<d;i++)
		if(s[i]=='#'&&s[i+1]=='#')GG();
	if(c>d){
		for(int i=b;i<=d;i++)
			if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
				puts("Yes");
				return 0;
			}
		GG();
	}
	else puts("Yes");
	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABallDistribution solver = new ABallDistribution();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABallDistribution {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();

            int leastBalls = 1;
            int allbutone = leastBalls * (k - 1);
            int most = n - allbutone;

            out.println(k == 1 ? 0 : Math.abs(most - leastBalls));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define ppb push_back
typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;
typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;
typedef vector<vector<int>> vvi; typedef vector<vbool> vvb;

const ll N = 200010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int lps[N];

void computeLPS(vll &pat, int n) {
	int len = 0;
	lps[0] = 0;
	int i = 1; 
	while(i < n) {
		if (pat[i] == pat[len]) {
			++len;
			lps[i] = len;
			++i;
		} else {
			if (len != 0) 
				len = lps[len-1];
			else
				lps[i++] = 0;
		}
	}
}

vint KMP(vll &pat, vll &txt, int n) {
	vint ans;
	computeLPS(pat, n);
	int i = 0, j = 0;
	while(i < 2*n-1) {
		if (pat[j] == txt[i]) {
			i++; j++;
		}
		if (j == n) {
			ans.push_back((n-i+j)%n);
			j = lps[j-1];
	//		cerr << "found i: " << i << ", j: " << j << nl;
		} else if (i < 2*n && pat[j] != txt[i]) {
			if (j != 0) 
				j = lps[j-1];
			else 
				i++;
		}
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vll a(n), b(n);
	fori(n) cin >> a[i];
	fori(n) cin >> b[i];

	vll c(n), d(2*n); //XOR arrays
	fori(n) {
		c[i] = a[i] ^ a[(i+1)%n];
		d[i] = d[i+n] = b[i] ^ b[(i+1)%n];
	}

	//fori(n) cerr << " " << c[i]; cerr << nl;
	//fori(2*n) cerr << " " << d[i]; cerr << nl;
	vint ans = KMP(c, d, n);
	vector<pii> real_ans;
	fori(ans.size()) {
		ll x = b[0] ^ a[ans[i]%n];
		real_ans.push_back({ans[i], x});
	}
	sort(real_ans.begin(), real_ans.end());
	fori(ans.size())
		cout << real_ans[i].first << " " << real_ans[i].second << nl;

	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 14576
n = int(input())

if n == 1:
	G = [1]
else:
	G = [g for g in [1, 4, 10, 23, 57, 132, 301, 701] if g < n]
	while True:
		g = int(2.25 * G[-1])
		if g > n:
			break
		G.append(g)
	G.reverse()

A = [int(input()) for _ in range(n)]
cnt = 0
for g in G:
	for j, v in enumerate(A[g:]):
		while j >= 0 and A[j] > v:
			A[j+g] = A[j]
			j -= g
			cnt += 1
		A[j+g] = v

print(len(G))
print(*G)
print(cnt)
for a in A:
	print(a)


Measured memory_bytes: 53004
import java.math.BigInteger;
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int i = 0;

        if(s.substring(2,3).equals(s.substring(3,4))){
            i++;
        }
        if(s.substring(4,5).equals(s.substring(5,6))){
            i++;
        }
        if(i==2){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        } 
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int n, k; cin >> n >> k;
  map<int, int> m;
  rep(i, n){
    int a; cin >> a;
    m[a]++;
  }
  
  vector<int> a;
  for(auto p : m){
    a.push_back(p.second);
  }
  sort(all(a));

  int l = m.size() - k;
  int sum = 0;
  rep(i, l) sum += a[i];

  cout << sum << endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  
  for(long long &i: A)
    cin >> i;
  
  long long x = 0;
  long long y = accumulate(A.begin(), A.end(), 0LL);
  long long min_ = pow(10, 15);
  
  for(int i = 0; i < N - 1; i++){
    x += A.at(i);
    y -= A.at(i);
    long long dif = abs(x - y);
    if(dif < min_)
      min_ = dif;
  }
  
  cout << min_ << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define Max 100005
using namespace std;
typedef long long LL;
const LL Mod = 1000000007;
char s[Max];
LL dp[4][Max];///0 '?' 1 'A' 2 'B' 3 'C'
int a,b,Q = 1;
int main() {
    scanf("%s",s + 1);
    dp[0][0] = 1;
    for(int i = 1;i <= strlen(s + 1);i ++) {
        for(int j = 0;j <= 3;j ++) {
            dp[j][i] = dp[j][i - 1];
            if(s[i] == '?')dp[j][i] = (dp[j][i] * 3) % Mod;
            if(j && (s[i] == '?' || s[i] - 'A' + 1 == j)) {
                dp[j][i] = (dp[j][i] + dp[j - 1][i - 1]) % Mod;
            }
        }
    }
    printf("%lld",dp[3][strlen(s + 1)]);
}


Measured memory_bytes: 3456
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
  int num = 1;
   Scanner sc= new Scanner(System.in);
   int s = sc.nextInt();
  for (int i= 0; i < 3; i++){
      num *= s;
  }
        
System.out.println(num);
    }
    
    
}


Measured memory_bytes: 26288
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string input1st;
  string input2nd;
  string input3rd;
  
  cin >> input1st >> input2nd >> input3rd;
  
  cout << input1st.at(0);
  cout << input2nd.at(0);
  cout << input3rd.at(0) << endl;
  
}

Measured memory_bytes: 256