akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 //     String[] sn=sc.nextLine().split(" ");
//int num=Integer.parseInt(sn[0]);
//int num2=Integer.parseInt(sn[1]);

      String sn=sc.nextLine();
int num=Integer.parseInt(sn);


double a=0;
double b=0;


if(num%2==0){
a=1;
b=2;
System.out.println(a/b);

}else{
a=num/2 +1;
b=(double)num;
System.out.println(a/b);

}

	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define MX 2000000
#define P 1000000007
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
lnt fac[MX+5], inv[MX+5];
int X1, X2, X3, X4, X5, X6;
int Y1, Y2, Y3, Y4, Y5, Y6;
void init() {
	fac[0] = inv[0] = inv[1] = 1;
	for (int i = 1; i <= MX; i++) fac[i] = fac[i-1]*i%P;
	for (int i = 2; i <= MX; i++) inv[i] = (P-P/i*inv[P%i]%P)%P;
	for (int i = 2; i <= MX; i++) inv[i] = inv[i]*inv[i-1]%P;
}
lnt F(int n, int m) {return fac[n+m]*inv[n]%P*inv[m]%P;}
lnt calc(int sx, int sy, int tx, int ty) {
	lnt ret = 0;
	for (int x = X3, y = Y3; x <= X4; x++)
		ret = (ret+1LL*(P-x-y)*F(x-sx, y-sy-1)%P*F(tx-x, ty-y)%P)%P;
	for (int x = X3, y = Y3; y <= Y4; y++)
		ret = (ret+1LL*(P-x-y)*F(x-sx-1, y-sy)%P*F(tx-x, ty-y)%P)%P;
	for (int x = X3, y = Y4; x <= X4; x++)
		ret = (ret+1LL*(x+y+1)*F(x-sx, y-sy)%P*F(tx-x, ty-y-1)%P)%P;
	for (int x = X4, y = Y3; y <= Y4; y++)
		ret = (ret+1LL*(x+y+1)*F(x-sx, y-sy)%P*F(tx-x-1, ty-y)%P)%P;
	return ret;
}
int main() {
	init(); lnt ans = 0;
	read(X1), read(X2), read(X3), read(X4), read(X5), read(X6);
	read(Y1), read(Y2), read(Y3), read(Y4), read(Y5), read(Y6);
	ans = (ans+calc(X1-1, Y1-1, X5, Y5))%P;
	ans = (ans+calc(X1-1, Y1-1, X6+1, Y6+1))%P;
	ans = (ans-calc(X1-1, Y1-1, X5, Y6+1)+P)%P;
	ans = (ans-calc(X1-1, Y1-1, X6+1, Y5)+P)%P;
	ans = (ans+calc(X2, Y2, X5, Y5))%P;
	ans = (ans+calc(X2, Y2, X6+1, Y6+1))%P;
	ans = (ans-calc(X2, Y2, X5, Y6+1)+P)%P;
	ans = (ans-calc(X2, Y2, X6+1, Y5)+P)%P;
	ans = (ans-calc(X1-1, Y2, X5, Y5)+P)%P;
	ans = (ans-calc(X1-1, Y2, X6+1, Y6+1)+P)%P;
	ans = (ans+calc(X1-1, Y2, X5, Y6+1))%P;
	ans = (ans+calc(X1-1, Y2, X6+1, Y5))%P;
	ans = (ans-calc(X2, Y1-1, X5, Y5)+P)%P;
	ans = (ans-calc(X2, Y1-1, X6+1, Y6+1)+P)%P;
	ans = (ans+calc(X2, Y1-1, X5, Y6+1))%P;
	ans = (ans+calc(X2, Y1-1, X6+1, Y5))%P;
	return printf("%lld\n", ans), 0;
}

Measured memory_bytes: 31488
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int N; cin >> N;
  vector <double> A(N);
  double sum = 0;
  for (int i = 0; i < N; i++){
    cin >> A[i]; sum += A[i];
  }
  double ave = sum / N;
  
  vector < pair<double, int> > ans(N);
  for (int i = 0; i < N; i++){
    ans[i].first = abs(ave - A[i]);
    ans[i].second = i;
  }
  sort(ans.begin(), ans.end());
  cout << ans[0].second << endl;

  return 0;
}


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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    
    int right(0),left(0);
    for(int i=0;i<m;i++){
        int a;  cin >> a;
        if(a<x){
            left++;
        }else{
            right++;
        }
    }
    
    cout << min(right,left) << endl;
    
    return 0;
}


Measured memory_bytes: 3540
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 998244353;

const long long MAX = 1000100;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i = 2;i < MAX;i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll pow_mod(ll a,ll b,int m){
	if(b == 0)return 1;
	else if(b % 2 == 0){
		ll t = pow_mod(a,b/2,m);
		return t * t % m;
	}
	return a  * pow_mod(a,b-1,m) % m;
}

int main(){
	COMinit();
	int n,m,k;
	cin >> n >> m >> k;
	ll ans = 0;

	for(int i = 0;i <= k;i++){
		ll now = m;
		now *= pow_mod((ll)m-1,(ll)n-i-1,MOD);
		now %= MOD;
		now *= COM(n-1,i);
		now %= MOD;
		ans += now;
		ans %= MOD; 
	}

	cout << ans << endl;
}


Measured memory_bytes: 27076
#include <stdio.h>

typedef int keytype;

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main(void){
    int n;
    int a[300000];

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

    int max = 0;
    for(int i = 1; i < n; ++i){
        if(a[max] < a[i]) max = i;
    }
    //printf("%d\n", max);
    quicksort(a, 0, n - 1);

    for(int i = 0; i < n; ++i){
        if(i == max) printf("%d\n", a[n-2]);
        else printf("%d\n", a[n-1]);
    }

    return 0;
}

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

class Main
{
    public static void main(String args[]) throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),k=Integer.parseInt(s[1]);
        s=bu.readLine().split(" ");
        int i,a[]=new int[n];
        for(i=0;i<n;i++)
        a[i]=Integer.parseInt(s[i]);
        Arrays.sort(a);
        long ans=1,M=1000000007;
        ans=maxProduct(a,n,k);
        ans=(ans+M)%M;
        System.out.print(ans);
    }

    static long maxProduct(int A[], int n, int k)
    {
        long product=1,M=1000000007;

        if(A[n-1]==0 && k%2!=0)  return 0;
        if(A[n-1]<=0 && k%2!=0)
        {
            for(int i=n-1; i>=n-k;i--) product=(product*A[i])%M;
            return product;
        }

        int i=0,j=n-1;
        if(k%2!=0)
        {
            product=product*A[j]%M;
            j--;
            k--;
        }
        k>>=1;

        for(int itr=0;itr<k; itr++)
        {
            long left_product=1l*A[i]*A[i+1];
            long right_product=1l*A[j]*A[j-1];

            if(left_product>right_product)
            {
                product=product*(left_product%M)%M;
                product%=M;
                i+=2;
            }
            else
            {
                product=product*(right_product%M)%M;
                product%=M;
                j-=2;
            }
        }
        return product;
    }
}

Measured memory_bytes: 63772
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n;
    cin >> n;
    long double v[n];
    rep(i,n){
        cin >> v[i];
    }
    sort(v,v+n,greater<long double>());
    long double ans = 0;
    long double waru = 2;
    for(int i = 0;i<n;i++){
        if(i==n-1) waru/=2;
        ans+=(v[i]/waru);
        waru*=2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll N;
    cin>>N;
    ll keta=0;
    while(N>0){
        N=N/2;
        keta++;
    }
    ll ans=1;
    rep(i,keta) ans*=2;
    ans--;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n, av, bv, cv = list(map(int, input().split()))
s = []
for i in range(n):
    s.append(input())

v = {'A':av, 'B':bv, 'C':cv}

selection = []
for i in range(n):
    if v[s[i][0]] == 0:
        selection.append(s[i][0])
        v[s[i][0]] += 1
        v[s[i][1]] -= 1
    elif v[s[i][1]] == 0:
        selection.append(s[i][1])
        v[s[i][0]] -= 1
        v[s[i][1]] += 1
    elif v[s[i][0]] == 1 and v[s[i][1]] == 1:
        if i == n-1:
            selection.append(s[i][0])
            v[s[i][0]] += 1
            v[s[i][1]] -= 1       
        else:
            if s[i+1][0] == s[i][0] or s[i+1][1] == s[i][0]:
                selection.append(s[i][0])
                v[s[i][0]] += 1
                v[s[i][1]] -= 1 
            else:
                selection.append(s[i][1])
                v[s[i][0]] -= 1
                v[s[i][1]] += 1
    else:
        if v[s[i][0]] > v[s[i][1]]:
            selection.append(s[i][1])
            v[s[i][0]] -= 1
            v[s[i][1]] += 1
        else:
            selection.append(s[i][0])
            v[s[i][0]] += 1
            v[s[i][1]] -= 1
    
    if v['A'] < 0 or v['B'] < 0 or v['C'] < 0:
        print('No')
        break
else:
    print('Yes')
    for i in range(n):
        print(selection[i])

Measured memory_bytes: 16988
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;   cin >> s;
    if (s == "Sunny")   cout << "Cloudy" << endl;
    if (s == "Cloudy")  cout << "Rainy" << endl;
    if (s == "Rainy")   cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX],H[MAX];
int n;

void print(int u){
  int deg = 0;
  printf("node %d: parent = %d, sibling = %d", u, T[u].p, getSibling(u));
  if(T[u].l != NIL) deg++;
  if(T[u].r != NIL) deg++;
  printf(", degree = %d, depth = %d, height = %d, ", deg, D[u], H[u]);

  if(T[u].p == NIL) printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL) printf("leaf\n");
  else printf("internal node\n");
}

void setDepth(int u, int p){
  if(u == NIL) return;
  D[u] = p;
  if(T[u].r != NIL) setDepth(T[u].r,p+1);
  if(T[u].l != NIL) setDepth(T[u].l,p+1);
}

int setHeight(int u){
  int h1,h2;
  h1 = h2 = 0;
  if(T[u].r != NIL) h1 = setHeight(T[u].r) + 1;
  if(T[u].l != NIL) h2 = setHeight(T[u].l) + 1;

  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].p == NIL) return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL) return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL) return T[T[u].p].r;

  return NIL;
}


int main(){
  int i, j, k;
  int id, le, ri;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d %d", &id, &le, &ri);
    T[id].l = le;
    T[id].r = ri;
    if(le != NIL) T[le].p = id;
    if(ri != NIL) T[ri].p = id;
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  setDepth(root, 0);
  setHeight(root);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
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; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    vector<ll> AS = A;
    sort(AS.begin(), AS.end());
    vector<ll> AR = A;
    sort(AR.rbegin(), AR.rend());

    ll ans = 0;
    ll tmp = 0;
    if (N % 2 == 1){

        ll prev = AS[N/2];

        rep(i,N/2){
            tmp += abs(prev- AS[i]);
            tmp += abs(AS[i]-AR[i]);
            prev = AR[i];            
        }
        ans = max(ans, tmp);
        prev = AS[N/2];
        tmp = 0;
        rep(i,N/2){
            tmp += abs(prev-AR[i]);
            tmp += abs(AR[i]-AS[i]);
            prev = AS[i];
        }
        ans = max(ans, tmp);
    }
    else{
        ll prev = AS[N/2];

        rep(i,N/2-1){
            tmp += abs(prev- AS[i]);
            tmp += abs(AS[i]-AR[i]);
            prev = AR[i];            
        }
        tmp += abs(prev-AS[N/2-1]);
        ans = max(ans, tmp);

        prev = AS[N/2];
        tmp = 0;
        rep(i,N/2-1){
            tmp += abs(prev- AR[i]);
            tmp += abs(AR[i]-AS[i]);
            prev = AS[i];            
        }
        tmp += abs(prev-AS[N/2-1]);
        ans = max(ans, tmp);
    }

    cout << ans << endl;

}


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

class Program {
    static int Main(string[] args) {
        string s = Console.ReadLine();
        string p = Console.ReadLine();

        s += s;
        if (s.Contains(p) == true) {
            Console.WriteLine("Yes");
        }
        else {
            Console.WriteLine("No");
        }

        return 0;
    }
}


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

int main()
{
ll n,i,sum;
cin>>n;
if(n%2==0)
    cout<<-1;
else
{
    sum=0;
    for(i=1;i<=pow(10,6);i++)
    {
        sum=(sum*10+7)%n;
        if(sum==0)
        {
            cout<<i;
            break;
        }
    }
    if(i>pow(10,6))
        cout<<-1;
}
}


Measured memory_bytes: 3608
import javax.print.DocFlavor;
import javax.swing.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        //int[] dp = new int[3];
        int[] dp1 = new int[3];
        while(N>0){
            N--;
            String[] list = reader.readLine().split(" ");
            int a1 = Integer.parseInt(list[0]);
            int a2 = Integer.parseInt(list[1]);
            int a3 = Integer.parseInt(list[2]);
            int dp10 = dp1[0];
            int dp11 = dp1[1];
            int dp12 = dp1[2];
            dp1[0] = Math.max(dp12+a1,dp11+a1);
            dp1[1] = Math.max(dp10+a2,dp12+a2);
            dp1[2] = Math.max(dp10+a3,dp11+a3);
            //dp = dp1;
        }
        int max = dp1[0];
        for(int u=0;u<3;u++){
            if(max<dp1[u]) max = dp1[u];
        }
        System.out.println(max);
    }
}



Measured memory_bytes: 46632
#include<stdio.h>
int main()
{
	int a, b = 0,i;
	for (i = 0; i < 5; i++){
		scanf("%d", &a);
		if (a < 40)
			b += 40;
		else
			b += a;

	}
	printf("%d\n", b/5);
	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
	}
  s << "]";
	return s;
}

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

  int n, k;
  cin >> n >> k;
  vector<int> ps(n);
  for (int i = 0; i < n; i++) {
    cin >> ps[i];
  }

  vector<int> rs(n - 1);
  for (int i = 0; i < n - 1; i++) {
    if (ps[i] > ps[i + 1]) rs[i] = 1;
  }

  vector<int> r_cum(n);
  for (int i = 0; i < n - 1; i++) {
    r_cum[i + 1] = r_cum[i] + rs[i];
  }

  if (DEBUG) cout << "r_cum: " << r_cum << endl;

  vector<int> sorted(n - k + 1);
  int sorted_count = 0;
  for (int i = 0; i + k - 1 < n; i++) {
    if (r_cum[i + k - 1] - r_cum[i] == 0) {
      sorted[i] = 1;
      sorted_count++;
    }
  }

  int ans = n - k + 1 - sorted_count;
  if (sorted_count > 0) ans++;

  if (DEBUG) cout << "sorted_count: " << sorted_count << endl;

  set<int> s;
  for (int i = 0; i < k; i++) {
    s.insert(ps[i]);
  }

  for (int i = 0; i + k < n; i++) {
    // Both are not sorted.

    s.insert(ps[i + k]);

    if (DEBUG) {
      cout << "min: " << *s.begin() << endl;
      cout << "max: " << *s.rbegin() << endl;
    }

    if (!sorted[i] && !sorted[i + 1]) {
      if (ps[i] == *s.begin() && ps[i + k] == *s.rbegin()) {
        ans--;
      }
    }

    s.erase(ps[i]);
  }
  cout << ans << endl;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    int k ;
    cin >> k ;

    int ans = 0 ;
    while ( n )
    {
        n /= k ;
        ans ++ ;
    }

    cout << ans ; line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=1 ; i <= t ; i ++ ) solve ( i ) ;
    return 0;
}


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

int main(){
  string A,B,C;
  cin >> A >> B >> C;
  int a = A.size();
  int b = B.size();
    if(A.at(a-1) == B.at(0) && B.at(b-1) == C.at(0)){
      cout << "YES" << endl;
    }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
Hlist = list(map(int, input().split()))
Hlist.sort(reverse=True)
if K == 0:
  print(sum(Hlist))
else:
  Hlist[0:K] = []
  print(sum(Hlist))
'''
elif K == 1:
  del Hlist[0]
  print(sum(Hlist))
elif K == 2:
  del Hlist[0]
  del Hlist[0]
  print(sum(Hlist))
else:
  del Hlist[0:K-1]
  print(sum(Hlist))
'''

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

using namespace std;

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

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

	if(a==0) cout << 1 << endl;

	if(b==0) cout << 2 << endl;

	if(c==0) cout << 3 << endl;

	if(d==0) cout << 4 << endl;

	if(e==0) cout << 5 << endl;

	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],x[200010];
int main(){
	cin>>n;
	for (int i=0;i<n-1;i++) cin>>a[i];
	for (int i=0;i<n-1;i++) x[a[i]]++;
	for (int i=1;i<=n;i++) cout<<x[i]<<endl;
	return 0;
}

Measured memory_bytes: 5196
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(n: usize, m: usize, lr: [(usize1, usize1); m]);

    let mut acc = vec![0i64; n + 1];
    for i in 0..m {
        let (l, r) = lr[i];
        acc[l] += 1;
        acc[r + 1] -= 1;
    }
    for i in 0..n {
        acc[i + 1] += acc[i];
    }

    let ans = acc.iter().filter(|&&x| x == m as i64).count();
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
#include <time.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++) {
		cout << s[i];
	}
	cout << " ";
	for (int i = 4; i < 12; i++) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> X(N);
  for (int i=0; i<N; i++) cin >> X.at(i);
  sort(X.begin(), X.end());

  vector<int> total(200);
  int c = 0;
  for (int i = X.front(); i < X.back(); i++) {
    for (int k = 0; k < N; k++) {
      total.at(c) += pow(X.at(k)-i, 2);
    }
    c++;
  }
  total.erase(remove(total.begin(), total.end(), 0), total.end());
  int min = *min_element( total.begin(), total.end() );
  cout << min << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,q,l,r;
    string s;
    cin>>n>>q>>s;
    ll ps[n+1]={};
    s+='P';
    for(ll i=0;i<n;i++){
        if(s[i]=='A' && s[i+1]=='C')ps[i+1]=ps[i]+1;
        else ps[i+1]=ps[i];
    }
    while(q--){
        cin>>l>>r;
        cout<<ps[r]-ps[l-1]-(s[r]=='C' && s[r-1]=='A')<<'\n';
    }
    return 0;
}


Measured memory_bytes: 1872
from bisect import bisect_right, bisect_left
A = [ord(t) - ord("a") for t in input()]
n = len(A)
alf = [[] for i in range(26)]
for i, a in enumerate(A):
    alf[a].append(i)
for i in range(26):
    alf[i].append(n+1)

first = [n]
appeard = [0] * 26
cnt = 0
for i in range(n - 1, -1, -1):
    a = A[i]
    if 1 - appeard[a]:
        appeard[a] = 1
        cnt += 1
    if cnt == 26:
        first.append(i)
        cnt = 0
        appeard = [0] * 26

def ntoa(x):
    return chr(ord("a") + x)

first.reverse()
ans = ""

for i in range(26):
    if 1 - appeard[i]:
        ans += ntoa(i)
        if alf[i]:
            last = alf[i][0]
        break
if len(first) == 1:
    print(ans)
    exit()

for j in range(len(first) - 1):
    for i in range(26):
        nxt = alf[i][bisect_right(alf[i], last)]
        if nxt >= first[j+1]:
            ans += ntoa(i)
            last = nxt
            break
print(ans)


Measured memory_bytes: 19768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			int[] arr = new int[s.length()];

			int num1 = 0;
			int num2 = 0;
			int rNum = 0;
			int lNum = 0;
			boolean isR = true;
			for (int i = 0; i < s.length(); i++) {
				char c = s.charAt(i);
				switch(c) {
				case 'R':
					if(isR) {
	 					if(i % 2 == 0) {
							num1++;
						} else {
							num2++;
						}
					} else {
						if(rNum % 2 == 0) {
							arr[rNum] = num1;
							arr[lNum] = num2;
						} else {
							arr[rNum] = num2;
							arr[lNum] = num1;
						}
						num1 = 0;
						num2 = 0;
						isR = true;
	 					if(i % 2 == 0) {
							num1++;
						} else {
							num2++;
						}
					}
					break;
				case 'L':
					if(isR) {
						rNum = i - 1;
						lNum = i;
						isR = false;
					}
 					if(i % 2 == 0) {
						num1++;
					} else {
						num2++;
					}
				}
			}
			if(rNum % 2 == 0) {
				arr[rNum] = num1;
				arr[lNum] = num2;
			} else {
				arr[rNum] = num2;
				arr[lNum] = num1;
			}

			boolean isFirst = true;
			for (int i : arr) {
				if (!isFirst) {
					System.out.print(" ");
				}
				System.out.print(i);
				isFirst = false;
			}
			System.out.println();
		}
	}
}


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

class dice{

public:
  int _1,_2,_3,_4,_5,_6,temp;

  void moveN(){
    temp=_1;
    _1=_2;
    _2=_6;
    _6=_5;
    _5=temp;
  }

  void moveE(){
    temp=_1;
    _1=_4;
    _4=_6;
    _6=_3;
    _3=temp;
  }

  void moveW(){
    temp=_1;
    _1=_3;
    _3=_6;
    _6=_4;
    _4=temp;
  }

  void moveS(){
    temp=_1;
    _1=_5;
    _5=_6;
    _6=_2;
    _2=temp;
  }

  void spin(){
    temp=_2;
    _2=_3;
    _3=_5;
    _5=_4;
    _4=temp;
  }

};

int main(){

  dice d1;
  dice d2;

  int i;

cin>>d1._1>>d1._2>>d1._3>>d1._4>>d1._5>>d1._6;
  cin>>d2._1>>d2._2>>d2._3>>d2._4>>d2._5>>d2._6;

  if(d1._4==d2._1||d1._3==d2._1)d1.moveE();
  for(i=0; i<4; i++){
   if(d2._1==d1._1)break;
   d1.moveN();
    }
  for(i=0; i<4; i++){
    if(d2._2==d1._2)break;
    d1.spin();
  }

  if(d1._1==d2._1 && d1._2==d2._2 && d1._3==d2._3 && d1._4==d2._4 && d1._5==d2._5 && d1._6==d2._6)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}

Measured memory_bytes: 1160
N = int(input())

from collections import defaultdict
res = defaultdict(list)

# 解の候補を生成
# x,y,zそれぞれに対して√10000位までやればよさそう
limit = int(10000**.5)+1
for x in range(1, limit):
    for y in range(1, limit):
        for z in range(1, limit):
            f = x**2 + y**2 + z**2 + x*y + y*z + z*x
            res[f].append((x,y,z))

for i in range(1, N+1):
    # 重複組み合わせは除外する
    print(len(set(res[i])))

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

#define mp              make_pair
#define pb              push_back

#define ff              first
#define ss              second

typedef long long ll;

const int maxN = 3e2+5;
const ll inf = 9e18;

ll A[maxN][maxN];
ll D[maxN][maxN];
int F[maxN][maxN];

int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    
    memset(A, -1, sizeof A);
    memset(D, -1, sizeof D);
    memset(F, -1, sizeof F);
    
    for(int i=0; i<m; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        
        a--;
        b--;
        
        A[a][b] = c;
        A[b][a] = c;
    }
    
    for(int i=0; i<n; ++i)
        A[i][i] = 0;
    
    for(int i=0; i<n; ++i)
        for(int j=0; j<n; ++j)
            D[i][j] = A[i][j];
    
    for(int k=0; k<n; ++k)
        for(int i=0; i<n; ++i)
            for(int j=0; j<n; ++j)
                if(D[i][k] != -1 and D[k][j] != -1)
                {
                    if(D[i][j] != -1)
                        D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
                    else
                        D[i][j] = D[i][k] + D[k][j];
                }
    
    
    /*for(int i=0; i<n; ++i)
        for(int j=0; j<n; ++j)
            cout << i+1 << " " << j+1 << " " << D[i][j] << "\n";*/
    
    for(int i=0; i<n; ++i)
        for(int j=0; j<n; ++j)
            if(D[i][j] <= l and D[i][j] != -1)
                F[i][j] = 0;
    
    for(int k=0; k<n; ++k)
        for(int i=0; i<n; ++i)
            for(int j=0; j<n; ++j)
                if(F[i][k] != -1 and F[k][j] != -1)
                {
                    int f = F[i][k] + F[k][j] + 1;
                    if(D[i][k] + D[k][j] <= l)
                        f--;
                    
                    if(F[i][j] != -1)
                        F[i][j] = min(F[i][j], f);
                    else
                        F[i][j] = f;
                }
    
    /*for(int i=0; i<n; ++i)
        for(int j=0; j<n; ++j)
            cout << i+1 << " " << j+1 << " " << F[i][j] << "\n";*/
    
    int q;
    cin >> q;
    
    for(int i=0; i<q; ++i)
    {
        int s, t;
        cin >> s >> t;
        
        s--;
        t--;
        
        cout << F[s][t] << "\n";
    }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000*1000*1000+7;
const long long MAX = 2000+10;
long long n, dp[MAX];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	dp[0] = 1;
	for(long long i = 3; i <= n; i++)
		for(long long j = 3; j <= i; j++)
			dp[i] = (dp[i] + dp[i - j]) % MOD;

	cout << dp[n] % MOD << "\n";
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.being(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef pair<int, int> pii;
typedef double Double;

inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
const Double EPS = 1e-9;

int N, M;

struct CColor {
	Double l, a, b;
	CColor(Double _l, Double _a, Double _b) : l(_l), a(_a), b(_b) {}
};

Double sqr(Double x) { return x * x; }
Double dist(const CColor& a, const CColor& b) {
	return sqr(a.l - b.l) + sqr(a.a - b.a) + sqr(a.b - b.b);
}

vector< CColor > vc;
Double ans;

Double calc(int S) {
	Double res = 0.0;
	
	for_(i,0,N) {
		if (!(S >> i & 1)) continue;
		for_(j,i+1,N) {
			if (!(S >> j & 1)) continue;
			res += dist(vc[i], vc[j]);
		}
	}
	
	return res;
}

void rec(int i, int S) {
	if (POPCNT(S) == M) {
		ans = max(ans, calc(S));
		return;
	}
	
	if (i == N) return;
	
	rec(i + 1, S);
	rec(i + 1, S | 1 << i);
}

void solve() {
	ans = 0.0;
	rec(0, 0);
	printf("%.9lf\n", ans);
}

int main() {
	cin >> N >> M;
	vc.assign(N, CColor(0,0,0));
	for_(i,0,N) {
		Double l, a, b; cin >> l >> a >> b;
		vc[i] = CColor(l,a,b);
	}
	solve();
	return 0;
}

Measured memory_bytes: 1252
import collections
N = int(input())
A = list(map(int, input().split()))
edge = collections.Counter(A)
a = 0
b = 0
c = 0
for i in sorted(edge.items()):
    if i[1] >= 2:
        if i[0] > a:
            b = a
            a = i[0]
    if i[1] >= 4:
        c = i[0]

if a * b >= c * c:
    answer = a * b
else:
    answer = c * c

print(answer)

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675555555555555555555555555555555555555455555555555555555555555555555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
std::string s;
bool jud=true;
void solve(){
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s.at(i)=='R'||s.at(i)=='U'||s.at(i)=='D'){
        continue;
      }else{
        jud=false;
        break;
      }
    }

    if(i%2==1){
      if(s.at(i)=='L'||s.at(i)=='U'||s.at(i)=='D'){
        continue;
      }else{
        jud=false;
        break;
      }
    }
  }

  if(jud==true){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  

}


int main(){
  cin>>s;

  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mod 1000000007
ll dp[100005]={INT_MAX},cur=0;

int main(){
	ll n;
	cin>>n;
	ll h[n+5];
	for(ll i=0;i<n;i++)
		cin>>h[i];
	cur=0;
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	if(n==2)
		cout<<dp[1];
	else
	{
		for(ll 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];
	}

}

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

int main()
{
	while(true){
		int M, T, P, R;
		cin >> M >> T >> P >> R;

		if(M==0 && T==0 && P==0 && R==0)
			break;

		int CP[50], TT[50], PT[50][10];
		for(int i=0; i<T; i++){
			CP[i] = TT[i] = 0;
			for(int j=0; j<P; j++)
				PT[i][j] = 0;
		}

		for(int i=0; i<R; i++){
			int m, t, p, j;
			cin >> m >> t >> p >> j;

			if(j==0){
				CP[t-1]++;
				TT[t-1] += (m+PT[t-1][p-1]);
			}
			else{
				PT[t-1][p-1] += 20;
			}
		}

		int tnow, tpre = -1;
		bool flg[50];
		for(int i=0; i<T; i++)
			flg[i] = false;

		for(int i=0; i<T; i++){
			tnow = -1;
			for(int j=0; j<T; j++){
				if(flg[j])
					continue;

				if(tnow==-1){
					tnow = j;
				}
				else{
					if(CP[j]>CP[tnow] || (CP[j]==CP[tnow] && TT[j]<=TT[tnow])){
						tnow = j;
					}
				}
			}

			if(tpre!=-1){
				if(CP[tnow]==CP[tpre] && TT[tnow]==TT[tpre])
					cout << '=';
				else
					cout << ',';
			}
			cout << tnow+1;

			flg[tnow] = true;
			tpre = tnow;
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  string ans;
  while (N != 0) {
    N -= 1;
    ans += (char)('a' + N % 26);
    N /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << "\n";
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define x e[i].first
#define y e[i].second
using namespace std;

const int maxn = 10010;
int n;
int vis[maxn], ans[maxn], a[maxn], sum;
pair<int, int> e[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n-1; ++i)
		scanf("%d%d", &x, &y);
	for (int i = 0; i < n; ++i) scanf("%d", a+i), sum+=a[i];
	sort(a, a+n);
	sum -= a[n-1];
	vis[1] = 1;
	ans[1] = a[n-1];
	for (int j = n-2; ~j; --j)
		for (int i = 0; i < n-1; ++i)
			if (vis[x]+vis[y] == 1) {
				ans[vis[x]?y:x] = a[j];
				vis[x] = vis[y] = 1;
				break;
			}
	printf("%d\n", sum);
	for (int i = 1; i <= n; ++i) {
		printf("%d ", ans[i]);
	}
}


Measured memory_bytes: 512
A, B = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
N = gcd(A,B)

def factorize(n):
  b = 2
  fct = []
  while b * b <= n:
    while n % b == 0:
      n //= b
      fct.append(b)
    b = b + 1
  if n > 1:
    fct.append(n)
  return fct

print(len(set(factorize(N)))+1)

Measured memory_bytes: 3060
#include <stdio.h>

long long dp[11][1101];
int main(){
	int n, s, i, j, k;
	dp[0][0] = 1;
	for(i = 0;i <= 100;i++){
		for(j = 9;j >= 0;j--){
			for(k = 0;k <= 1000-i;k++){
				dp[j+1][k+i] += dp[j][k];
			}
		}
	}
	while(1){
		scanf("%d%d", &n, &s);
		if(n+s == 0)break;
		printf("%lld\n", dp[n][s]);
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<char> c(n);
    for(int i = 0; i < n;i++){
        cin >> c[i];
    }
    int count = 0;
    for(int i = 0;i < n;i++){
        if(c[i] == 'R'){
            count++;
        }
    }
    int ans = 0;
    for(int i = 0;i < count;i++){
        if(c[i] == 'W'){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  ll N, M;
  cin >> N >> M;
  ll Asum = 0;
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    Asum += A;
  }
  if (Asum > N) {
    cout << -1 << endl;
  }
  else {
    cout << N-Asum << endl;
  }
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=998244353;


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


int main(){
    int N, S; cin >> N >> S;
    vi A(N);
    for(auto &x : A){
        cin >> x;
    }
    vector<vector<ll>> dp(N+1, vector<ll>(S+1, 0));
    dp[0][0]=modpow(2, N);
    ll x=modpow(2LL, MOD-2);
    for(int i=0; i<N; i++){
        for(int j=0; j<=S; j++){
            if(j >= A[i]){
                dp[i+1][j]=(dp[i][j-A[i]]*x%MOD+dp[i][j]%MOD)%MOD;
            }
            else dp[i+1][j]=dp[i][j]%MOD;
        }
    }
    cout << dp[N][S] << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<vector<int>> f(n,vector<int>(10,0)),
	p(n,vector<int>(11,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<10;j++)
		{
			cin >> f.at(i).at(j);
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<11;j++)
		{
			cin >> p.at(i).at(j);
		}
	}
	int ans = -1000000000;
	for(int i=1;i<1024;i++)
	{
		vector<int> op(10,0);
		for(int j=0;j<10;j++)
		{
			int j1 = pow(2,j+1),
			    j2 = pow(2,j);
			if(i % j1 >= j2)
			{
				op.at(j) = 1;
			}
		}
		int pf = 0;
		int cnt =0;
		for(int j =0;j<n;j++)
		{
			cnt =0;
			for(int k=0;k<10;k++)
			{
				if(op.at(k) == 1 && 
				   f.at(j).at(k) == 1 )
				{
					cnt++;
				}
			}
			pf += p.at(j).at(cnt);
		}
		ans = max(ans,pf);
	}
    cout << ans << endl;
}


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

using namespace std;

int main(){
	int N, D;
	cin >> N >> D;
	
	if (N % (2 * D + 1) == 0) {
		cout << N / (2 * D + 1) << endl;
	} else {
		cout << N / (2 * D + 1) + 1 << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
s=list(input())
k=int(input())
if len(s)==1 or k==1:
    print(int(s[0]))
else:
    for i in range(len(s)):
        if int(s[i])==1 and i!=len(s)-1 and (i+1)<k:
            continue
        else:
            print(int(s[i]))
            break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = n;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) {
      ans = min(ans, max(i, n - i));
    }
  }
 
  cout << ans << endl;
}


Measured memory_bytes: 512
def main():
    n,m = map(int,input().split())
    sa = set()
    sb = set()
    for i in range(m):
        a,b = map(int,input().split())
        if a == 1:
            sb.add(b)
        if b == n:
            sa.add(a)
    if len(sa&sb) > 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()



Measured memory_bytes: 59096
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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 print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

// 素因数を数列で返す。N の数が大きくても大丈夫
// ソートされていないので注意すること
template <class T> vector<T> factring_sequence(T N) {
    vector<T> ans;
    long long i = 2;
    while (i * i <= N) {
        if (N % i == 0) {
            ans.emplace_back(i);
            N /= i;
        } else {
            i++;
        }
    }
    ans.emplace_back(N);
    return ans;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    auto fac = factring_sequence(N);
    SORT(fac);
    cout << N << ": ";
    print(fac);

    return 0;
}


Measured memory_bytes: 3200
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <regex>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	ll t = (A + D - 1) / D;
	ll u = (C + B - 1) / B;

	if (u > t) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3596
N = int(input())
li = list(map(int,input().split()))
app = 0
for i in li:
    if i % 2 == 0 and (i % 3 == 0 or i % 5 == 0):
        pass
    elif i % 2 == 0:
        app += 1
        break
if app == 0:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

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

    for(int i = 1; i <= b; ++i){
        if(a * i % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

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

  int count=0;
  for(int i=0; i<s.length()/2; i++)
    {
      if(s[i]!=s[s.length()-i-1])
	count++;
    }
  
  cout << count << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long n,i,s=0;
	cin>>n;
	for(i=sqrt(n);i>=1;i--)
		if(n%i==0)
		{
			int t=n/i;
			while(t)
			{
				s++;
				t/=10;
			}
			cout<<s;
			return 0;
		}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

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

typedef long long ll;

const int N_MAX = 200000;

int N;
int A[N_MAX];

void solve() {
  ll ans = 0;
  int s = 0;
  int t = 0;
  int f = 0;
  while (s < N) {
    // printf("s: %d, t: %d, f: %d\n", s, t, f);
    while (t < N && !(f & A[t])) {
      f |= A[t++];
      // printf(" s: %d, t: %d, f: %d\n", s, t, f);
    }
    ans += t - s;
    f &= ~A[s++];
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", A + i);
}

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


Measured memory_bytes: 896
N,K = map(int,input().split())
s=input()
if '0' not in s:
    print(len(s))
else:
    s2 = [0]
    count = 0
    for i in range(len(s)-1):
        count += 1
        if s[i] != s[i+1]:
            s2.append(count)
    s2.append(count+1)
    if s[0] == '0':
        s2.insert(0,0)
    ans = 0
    for i in range(0,len(s2)-1,2):
        ans = max(ans,s2[min(len(s2)-1,i+2*K+1)] - s2[i])
    print(ans)

Measured memory_bytes: 7108
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <complex>

#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define rtr(c, i) for (typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); --i)
#define contains(c, x) ((c).find(x) != (c).end())
#define Contains(c, x) (find(all(c), x) != (c).end())
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, (n))
#define To_String to_string< char,std::char_traits<char>,std::allocator<char> >

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	while (cin >> n, n) {
		vector<string> f(n);
		vector<int> w(n), s(n);
		rep(i, n) cin >> f[i] >> w[i] >> s[i];
		vector<int> a(n), res;
		int maxg = 0;
		rep(i, n) a[i] = i;
		do {
			int sw = 0, g = 0;
			bool ok = true;
			rep(i, n) {
				if (sw > s[a[i]]) { ok = false; break; }
				sw += w[a[i]];
				g += (i+1) * w[a[i]];
			}
			if (maxg < g) { maxg = g; res = a; }
		} while (next_permutation(all(a)));
		reverse(all(res));
		rep(i, n) cout << f[res[i]] << endl;
	}
	return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> arr(n);
    rep(i,n) cin >> arr[i];
    int s,l;
    s = 0; l = 0;
    int diff = 99999;
    for(int i = 0; i < n - 1; i++){
        //i以下の数の総和とiより大きい数の総和を求める
        s = 0; l = 0;
        for(int j = i; j >= 0; j--){
            s += arr[j];
        }
        for(int k = i + 1; k < n; k++){
            l += arr[k];
        }
        diff = min(diff,abs(s-l));
    }
    cout << diff;
}

Measured memory_bytes: 256