akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll n;
    cin >> n;

    vector<ll> f(n + 1, 2);
    f[0] = 0;
    f[1] = 1;

    for (ll i = 2; i <= sqrt(n); i++) {
        for (ll j = i; i * j <= n; j++) {
            if (i != j) {
                f[i * j] += 2;
            }
            else {
                f[i * j] += 1;
            }
        }
    }

    ll res = 0;
    rep(i, n + 1) {
        res += i * f[i];
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 81468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        long n = nextLong();
        long m = nextLong();
        long res = Math.min(n, m / 2);
        n -= res;
        m -= 2 * res;
        res += m / 4;
        out.println(res);
    }

    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    private void run() throws IOException {
        solve();
        out.close();
    }

}


Measured memory_bytes: 23124
import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit = {
    val s = sc.next


    val bl = s.split("(?<=.)").map{"ATGC".contains(_)}
    val res =
      bl.foldLeft(List.empty[Int]){ case (l, b) =>
        if( l.isEmpty) if(b) List(1) else List(0)
        else if(b) l :+ (l.last + 1) else l :+ 0
      }
    println(res.max)
  }
}

Measured memory_bytes: 27348
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int H, W;
	int h, w;

	while (1) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;
		for (h = 0; h < H; h++) {
			for (w = 0; w < W; w++) {
				putchar(((h&1) ^ (w&1)) == 0 ? '#' : '.');		}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2092
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <map>

class union_find {
  std::vector<intmax_t> tree;

public:
  union_find(size_t n): tree(n, -1) {}

  size_t find(size_t v) {
    if (tree[v] < 0)
      return v;

    return (tree[v] = find(tree[v]));
  }

  bool unite(size_t u, size_t v) {
    u = find(u);
    v = find(v);
    if (u == v)
      return false;

    if (-tree[u] >= -tree[v])
      std::swap(u, v);

    tree[v] += tree[u];
    tree[u] = v;
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

constexpr size_t di[] = {size_t(-1), 0, 1, 0};
constexpr size_t dj[] = {0, size_t(-1), 0, 1};

int main() {
  size_t H, W;
  scanf("%zu %zu", &H, &W);

  std::vector<std::string> S(H);
  for (size_t i = 0; i < H; ++i) {
    char buf[512];
    scanf("%s", buf);
    S[i] = buf;
  }

  auto encode = [=](size_t h, size_t w) {
    return W*h + w;
  };
  auto decode = [=](size_t e)->std::pair<size_t, size_t> {
    size_t w = e % W;
    size_t h = e / W;
    return {h, w};
  };

  union_find uf(H*W);
  for (size_t i = 0; i < H; ++i) {
    for (size_t j = 0; j < W; ++j) {
      for (int k = 0; k < 4; ++k) {
        size_t ni = i + di[k];
        size_t nj = j + dj[k];
        if (!(ni < H && nj < W)) continue;
        if (S[i][j] == S[ni][nj]) continue;

        uf.unite(encode(i, j), encode(ni, nj));
      }
    }
  }

  std::map<size_t, std::pair<intmax_t, intmax_t>> map;
  for (size_t i = 0; i < H; ++i)
    for (size_t j = 0; j < W; ++j) {
      size_t par = uf.find(encode(i, j));
      ++((S[i][j] == '.')? map[par].first:map[par].second);
    }

  intmax_t res = 0;
  for (const auto& p: map)
    res += p.second.first * p.second.second;

  printf("%jd\n", res);
}


Measured memory_bytes: 10240
#include<stdio.h>

int solve(int data[],int size);

int main()
{
    int n,i,j,ans=0,h[110]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&(h[i]));
	}
	ans=solve(h,n);
	printf("%d",ans);
}


int solve(int data[],int size)
{
	/*
	printf("\nsolve:\ndata:");
	int k;
	for(k=0;k<size;k++)printf("%d ",data[k]);
	printf("\ndatasize:%d\n",size);
	*/
	
	if(size==0)return 0;
	else if(size==1)return data[0];
	else
	{
		int i,j,min=1000,kari=0;
		for(i=0;i<size;i++)
		{
			if(min>data[i])min=data[i];
		}
		kari+=min;
		//printf("min:%d\n",min);
		for(i=0;i<size;i++)
		{
			data[i]-=min;
			//printf("bysolve:data:%d\n",data[i]);
		}
		int nexts=0;
		int nextdata[110]={0};
		for(i=0;i<size;i++)
		{
			nextdata[nexts]=data[i];
			if(data[i]==0)
			{
				kari+=solve(nextdata,nexts);
				nexts=0;
			}
			else nexts++;
		}
		kari+=solve(nextdata,nexts);
		//printf("now:%d\n",kari);
		return kari;
	}
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n, c, k;

  scanf("%d %d %d", &n, &c, &k);

  vector<int> v(n);

  REP (i, n) scanf("%d", &v[i]);

  sort(v.begin(), v.end(), greater<int>());

  int i = 0;
  int ans = 0;
  while (i < n) {
    int num = 1;
    while (num < c) {
      if (v[i] - v[i + num] <= k) num++;
      else break;
    }
    ans += 1;
    i += num;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
        }
        
        int sum = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        
        int distance;
        for(int i=0;i<=100;i++){
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        }
        
        Collections.sort(list);
        
        System.out.println(list.get(0));
    }
}


Measured memory_bytes: 35748
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

typedef long long LL;

#ifdef __GNUC__
#define popcount __builtin_popcount
#elif _MSC_VER >= 1400
#include <intrin.h>
#define popcount __popcnt
#else
static inline int popcount(unsigned int b) {
	b = (b & 0x55555555) + (b >> 1 & 0x55555555);
	b = (b & 0x33333333) + (b >> 2 & 0x33333333);
	b = (b & 0x0F0F0F0F) + (b >> 4 & 0x0F0F0F0F);
	b += b >> 8;
	return (b + (b >> 16)) & 0x3F;
}
#endif

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, a, x, y, ans = 0;
		cin >> n;
		if (n < 0) return 0;
		vector<vector<int>> p(n);
		vector<vector<int>> q(n);
		for (int i = 0; i < n; ++i) {
			cin >> a;
			for (int j = 0; j < a; ++j) {
				cin >> x >> y;
				if (y) {
					p[i].push_back(x - 1);
				} else {
					q[i].push_back(x - 1);
				}
			}
		}
		int bm = 1 << n;
		for (int b = 0; b < bm; ++b) {
			bool ok = true;
			for (int i = 0; i < n; ++i) {
				if ((1 << i) & b) {
					for (int j : p[i]) {
						if (((1 << j) & b) == 0) {
							ok = false;
						}
					}
					for (int j : q[i]) {
						if ((1 << j) & b) {
							ok = false;
						}
					}
				}
			}
			if (ok) {
				ans = max(ans, (int)popcount(b));
			}
		}
		cout << ans << endl;

	}
	return 0;
}


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

ans = -1
isEven = True

while isEven:
  list_tmp = []
  for an in a:
    if an % 2 ==0:
      list_tmp.append(an / 2)
    else:
      isEven = False
      break;
  a = list_tmp
  ans += 1

print(ans)


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

#define A first
#define B second

int k = 38;
int n = k*k - k+1;
int p = k-1;

int conv(int x, int y) {
	return 1 + p*x + y;
}
int main() {
	ios_base::sync_with_stdio(0); cout.tie(0);
	cout << n << ' ' << k << "\n";

	for (int i = 0; i < p; ++i)
		for (int j = 0; j < p; ++j) {
			//y = ix + b
			for (int x = 0; x < p; ++x) {
				cout << conv(x, (i*x + j)%p) << ' ';
			}

			cout << 1 + p*p + i << "\n";
		}

	for (int i = 0; i < p; ++i) {
		for (int j = 0; j < p; ++j)
			cout << conv(i, j) << ' ';
		cout << p*p+p+1 << "\n";
	}

	for (int i = p*p; i <= p*p + p; ++i)
		cout << i + 1 << ' ';
	cout << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define per(i,s,t) for(int i=s;i>=t;i--)

using namespace std;

typedef long long LL;
int n,t,la,now,x;
LL ans;

int main(){
	scanf("%d%d",&n,&t);
	now=0; la=0;
	rep(i,1,n){
		scanf("%d",&x);
		now-=x-la; now=max(now,0);
		ans+=(LL)(t-now); now=t;
		la=x;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	if(n<4){
		ll a;
		cin>>a;
		a*=2;
		rep(i,0,n-2){
			ll b; cin>>b;
			a+=b;
		}
		cout<<a<<endl;
		return 0;
	}
	vl v(n-1);
	ll ans=0;
	rep(i,0,n-1){
		ll a; cin>>a;
		v[i]=a;
		if(i==0){
			ans+=v[i];
		}
		else{
			ans+=min(v[i-1],v[i]);
		}
	}
	ans+=v[n-2];
	cout<<ans<<endl;
		
	
	return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	    final int n=sc.nextInt();
	    int i=1;
	    do{
		int x=i;
		if(x%3==0){
		    System.out.print(" "+ i);
			}else{
		    do{
			if(x%10==3){
			    System.out.print(" "+ i);
			    break;
			}
			x/=10;
		    }while(x!=0);
		}
	    }while(++i <=n);
	    System.out.println();
    }
    
}

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

int main(){
	string s;  cin >> s;
	int pable = 0, ans = 0;
	for(int i=0; i<s.size(); i++){
		if(pable > 0){
			if(s[i] == 'g')  ans++;
			pable--;
		}else{
			if(s[i] == 'p')  ans--;
			pable++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

int fun(pair<string ,int> & u ,pair<string , int> & v) {
	if(u.F == v.F) {
		return u.S > v.S;
	}
	else {
		return u.F < v.F;
	}
}

void solve()
{
	int n;
	
	cin >> n;
	
	vector<pair<string , int>> a(n);
	
	map<int , int> id;
	
	for(int i = 0; i < n; ++i) {
		cin >> a[i].F >> a[i].S;
		id[a[i].S] = i+1;
	}
	
	sort(ALL(a) , fun);
	
	for(int i = 0; i < n; ++i) {
		cout << id[a[i].S] << endl;
	}
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
    string str;
    cin >> str;
    int ans = 10000;
    for(int i=0; i<str.size()-2; i++){
        ans = min(ans, abs(753-stoi(str.substr(i, 3))));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    if(a <= b) {
        cout << a;
    }
    else {
        cout << a-1;
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 30
#define NIL -1

typedef struct node{
  int parent;
  int left;
  int right;
}Node;

Node T[MAX];
int Dep[MAX], Hei[MAX];

void print(int u){
  int i, sib, deg = 0;
  int parent = T[u].parent; 
  printf("node %d: parent = %d, ", u, T[u].parent);
  
  if(T[u].parent == NIL) sib = NIL;
  else{
    if(T[parent].right != u) sib = T[parent].right;
    if(T[parent].left != u) sib = T[parent].left;
  }
  printf("sibling = %d, ", sib);

  if(T[u].right != NIL) deg++;
  if(T[u].left != NIL) deg++;
  printf("degree = %d, ",deg);
  
  printf("depth = %d, height = %d, ", Dep[u], Hei[u]);

  if(T[u].parent == NIL) printf("root");
  else if(T[u].left == NIL && T[u].right == NIL) printf("leaf");
  else printf("internal node");
  printf("\n");
}

int calcHeight(int u){
  int h1 = 0, h2 = 0;
  int maxh;
  if(T[u].right != NIL) h1 = calcHeight(T[u].right) + 1;
  if(T[u].left != NIL) h2 = calcHeight(T[u].left) + 1;

  if(h1 > h2) maxh = h1;
  else maxh = h2;
  return maxh;
}

void calcDepth(int u, int p){
  Dep[u] = p;
  if(T[u].right != NIL) calcDepth(T[u].right, p+1);
  if(T[u].left != NIL) calcDepth(T[u].left, p+1);
}

int main(){
  int i, j, n;
  int id, left, right;
  int root = NIL;
  
  scanf("%d",&n);
  for(i=0; i<n; i++){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }

  for(i=0; i<n; i++){
    scanf("%d%d%d",&id,&left,&right);
    T[id].left = left;
    T[id].right = right;
    if(left != NIL) T[left].parent = id;
    if(right != NIL) T[right].parent = id;
  }
  for(i=0; i<n; i++){
    if(T[i].parent == -1) root = i;
  }

  
  calcDepth(root, 0);
  for(i=0; i<n; i++) Hei[i] = calcHeight(i);
  for(i=0; i<n; i++) print(i);
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	long long int n, m, d[200000], t[200000], cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	if (n < m) {
		cout << "NO" << endl;
		return 0;
	}
	sort(d, d + n);
	sort(t, t + m);
	for (int i = 0; i < m; i++) {
		for (int j = cnt; j < n; j++) {
			/*if (n - 1 - j < m - 1 - i) {
				cout << "No" << endl;
				return 0;
			}*/
			if (t[i] == d[j]) {
				if (n - 1 - j < m - 1 - i) {
					cout << "No" << endl;
					return 0;
				}
				t[i] = 0;
				d[j] = 0;
				cnt = j + 1;
				if (i == m - 1) {
					cout << "YES" << endl;
					return 0;
				}
				break;
			}
		}
		if (t[i] != 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

int main(){

  ll n = in();
  string s = stin();
  vector<ll> ds(n+1, 0), cs(n+1, 0);
  REP(i, n){
    ds[i+1] = ds[i];
    cs[i+1] = cs[i];
    if(s[i] == 'D'){
      ds[i+1] += 1;
    } else if(s[i] == 'C'){
      cs[i+1] += 1;
    }
  }
  // cout << ds << endl;
  // cout << cs << endl;
  ll q = in();
  REP(qc, q){
    ll k = in();
    ll ans = 0;
    ll cur = 0;
    REP(i, n){
      // cout << i << " " << cur << endl;
      if(s[i] == 'D'){
        cur += cs[min(n, i+k)] - cs[i];
      } else if(s[i] == 'M'){
        ans += cur;
      } else if(s[i] == 'C'){
        cur -= ds[i] - ds[max(0LL, i-k+1)];
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 17792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;

	int maxv = max(a, max(b, c));

	cout << a + b + c - maxv << endl;
}

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


using namespace std;
typedef long long ll;
ll n,m,a,b;
ll i,j,k;
ll x[100005],y[100005];
char s[100];

bool solve(){
	cin >> n ;
	if(n == 0){
		return false;
	}
	ll ans = 0;
	for(i=0;i<100;i++){
		x[i] = 0;
		y[i] = 0;
	}
	for(i=0;i<n;i++){
		cin >> s;
		m = strlen(s);
		x[i] = m;
	}
	for(i=0;i<n;i++){
		ll sum = 0;
		ll a = 0;
		bool ok = false;
		for(j=i;j<n;j++){
			sum += x[j];
			if(sum == 5)a++;
			if(sum == 12)a++;
			if(sum == 17)a++;
			if(sum == 24)a++;
			if(sum == 31){
				a++;
				if(a == 5){
					ok = true;
					break;
				}else{
					ok = false;
					break;
				}
			}
			if(sum >= 32 && a <= 4){
				ok = false;
				break;
			}
		}
		if(ok){
			cout << i+1 << endl;
			return true;
		}else{
			//cout << "dame" << endl;
		}
	}

}


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


Measured memory_bytes: 3060
#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<int> A(N);
    rep(i,N) cin >> A[i];

    map<int,int> counter;
    rep(i,N){
        counter[A[i]]++;
    }

    ll duplicate_count = 0;
    for(auto c : counter){
        if (c.second > 1){
            duplicate_count += (c.second-1);
        }
    }
    
    ll ans = counter.size();
    if (duplicate_count % 2 == 1) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 8324
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    Res = {}
    N = int(input())
    for i in range(N):
        x=input()
        if x in Res:
            Res[x]+=1
        else:
            Res[x]=1
    M = int(input())
    for i in range(M):
        x=input()
        if x in Res:
            Res[x]-=1
        else:
            Res[x]=-1
    dics = sorted(Res.items(), key=lambda x:x[1], reverse = True)[0]
    print(max(0,dics[1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
long double A,B;
cin>>A>>B;
'A'>=0;
'B'>=0;
if(A>B){
	cout<<"GREATER"<<endl;
}
if(A<B){
	cout<<"LESS"<<endl;
}
if(A==B){
	cout<<"EQUAL"<<endl;
}
return 0;
}

Measured memory_bytes: 256
a = []
b = []
c = []

n, m, l = gets.split.map(&:to_i)

n.times do
  arr = gets.split.map(&:to_i)
  a.push(arr)
end

m.times do
  arr = gets.split.map(&:to_i)
  b.push(arr)
end

n.times do |i|
  arr = []
  l.times do |j|
    sum = 0
    m.times do |k|
      sum += a[i][k] * b [k][j]      
    end
    arr.push(sum)
  end
  c.push(arr)
end

n.times do |i|
  puts c[i]*" "
end



Measured memory_bytes: 7412
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

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

    s = "2018" + s.substr(4);
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, m;   cin >> n >> m;
    vector<pair<long long, long long> > store(n);
    for (int i = 0; i < n; i++)
        cin >> store[i].first >> store[i].second;

    sort(store.begin(), store.end());

    long long ans = 0, tmp = 0;
    int i = 0;

    while (tmp < m) {
        long long b = min(m-tmp, store[i].second);
        ans += b * store[i].first;
        tmp += b;
        i++;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

string tos(ll n) {
	stringstream ss; ss << n;
	string res; ss >> res;
	return res;
}
ll toll(string s) {
	stringstream ss; ss << s;
	ll res; ss >> res;
	return res;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N; cin >> N;
	vector<int> a(N); cin >> a;
	set<int> s;
	REP(t, 10) {
		int x = inf;
		REP(i, N) {
			if (s.count(a[i]) == 0) x = min(x, a[i]);
		}
		s.insert(x);
	}
//	int x = -1; REP(i, N) if (x < 0 || a[i] < a[x]) x = i;
//	int y = -1; REP(i, N) if (i != x && (y < 0 || a[i] < a[y])) y = i;
//	int z = -1; REP(i, N) if (i != x && i != y && (z < 0 || a[i] < a[z])) z = i;
//	vector<int> v = {x, y, z};
	vector<ll> b;
	EACH(i, s) EACH(j, s) {
		if (i != j) b.pb( toll(tos(i) + tos(j)) );
	}
	sort(b.begin(), b.end());
	cout << b[2] << endl;
}

Measured memory_bytes: 3184
#include<cstdio>


int main(){
    int a,b,c,t=0,d=0;
    scanf("%d %d %d",&a,&b,&c);
    while(t < c){
        d++;
        t += a;
        if(d % 7 == 0) t += b;
    }
    printf("%d\n",d);
}




Measured memory_bytes: 2692
from itertools import*
s,k=open(0)
k=int(k)
g=[len(list(v))for _,v in groupby(s)]
print(sum(c//2for c in g)*k+((g[0]*g[-2]%2*s[0]==s[-2])*~-k>>(len(s)-1==g[0])))

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

/**
 * Author: chilli
 * Date: 2019-04-26
 * License: CC0
 * Source: https://cp-algorithms.com/graph/dinic.html
 * Description: Flow algorithm with complexity $O(VE\log U)$ where $U = \max |\text{cap}|$.
 * $O(\min(E^{1/2}, V^{2/3})E)$ if $U = 1$; $O(\sqrt{V}E)$ for bipartite matching.
 * Status: Tested on SPOJ FASTFLOW and SPOJ MATCHING, stress-tested
 */

struct Dinic {
	struct Edge {
		int to, rev;
		ll c, oc;
		ll flow() { return max(oc - c, 0LL); } // if you need flows
	};
	vi lvl, ptr, q;
	vector<vector<Edge>> adj;
	Dinic(int n) : lvl(n), ptr(n), q(n), adj(n) {}
	void addEdge(int a, int b, ll c, int rcap = 0) {
		adj[a].push_back({b, sz(adj[b]), c, c});
		adj[b].push_back({a, sz(adj[a]) - 1, rcap, rcap});
	}
	ll dfs(int v, int t, ll f) {
		if (v == t || !f) return f;
		for (int& i = ptr[v]; i < sz(adj[v]); i++) {
			Edge& e = adj[v][i];
			if (lvl[e.to] == lvl[v] + 1)
				if (ll p = dfs(e.to, t, min(f, e.c))) {
					e.c -= p, adj[e.to][e.rev].c += p;
					return p;
				}
		}
		return 0;
	}
	ll calc(int s, int t) {
		ll flow = 0; q[0] = s;
		rep(L,0,31) do { // 'int L=30' maybe faster for random data
			lvl = ptr = vi(sz(q));
			int qi = 0, qe = lvl[s] = 1;
			while (qi < qe && !lvl[t]) {
				int v = q[qi++];
				for (Edge e : adj[v])
					if (!lvl[e.to] && e.c >> (30 - L))
						q[qe++] = e.to, lvl[e.to] = lvl[v] + 1;
			}
			while (ll p = dfs(s, t, LLONG_MAX)) flow += p;
		} while (lvl[t]);
		return flow;
	}
	bool leftOfMinCut(int a) { return lvl[a] != 0; }
};

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	Dinic dinic(300);
	const int S = 0, T = 1, RED = 100, BLUE = 200;

	int n; cin >> n;
	vector<int> a(n), b(n), c(n), d(n);
	rep(i, 0, n) cin >> a[i] >> b[i];
	rep(i, 0, n) cin >> c[i] >> d[i];

	rep(i, 0, n) dinic.addEdge(S, RED + i, 1);
	rep(i, 0, n) dinic.addEdge(BLUE + i, T, 1);

	rep(i, 0, n) rep(j, 0, n) {
		if (a[i] < c[j] && b[i] < d[j]) dinic.addEdge(RED + i, BLUE + j, 1);
	}

	cout << dinic.calc(S, T) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll pre[200005][2];
void solve(){
	ll n;
	string s;
	cin>>n>>s;
	for(ll i=0;i<n;i++){
		pre[i+1][0]=pre[i][0];
		pre[i+1][1]=pre[i][1];
		if(s[i]=='R')
			pre[i+1][0]++;
		else
			pre[i+1][1]++;
	}
	ll res=pre[n][0];
	for(ll i=1;i<=n;i++){
		ll x=pre[i][1],y=pre[n][0]-pre[i][0];
		res=min(res,max(x,y));
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 7052
n,m,q = gets.to_s.split.map{|t|t.to_i}

abcd = []
$<.read.split.map(&:to_i).each_slice(4) do |a, b, c, d|
    abcd.push [a-1, b-1, c, d]
end

ans = 0
(1..m).to_a.repeated_combination(n) do |cmb|
  cnt = 0
  abcd.each{ |a,b,c,d| cnt += d if cmb[b] - cmb[a] == c }
  ans = cnt if ans < cnt
end

puts ans

Measured memory_bytes: 14648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define inf 2000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			ll n,d;
			cin>>n>>d;

			ll ans=0;
			for(ll i=0;i<n;i++)
			{
				ll a,b;
				cin>>a>>b;


				if((a*a + b*b)<=d*d)
				ans+=1;
			}
			cout<<ans;
			
		
			return 0;
		 }	




Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vecll var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prt3(var1, var2, var3) cout << var1 << " " << var2 << " " << var3 << endl
#define prseq(var, n)    rep(i,n){cout << var[i] << " ";} cout << endl
#define prseql(var, n)   rep(i,n){cout << var[i] << " " << endl;}

//----------------------------------------------------------------

int main(void) {
  ll n, m;
  cin >> n >> m;

  vpairll work(n);
  rep(i,n){
    ll a, b;
    cin >> a >> b;
    work[i] = make_pair(a,b);
  }

  sort(all(work));

  priority_queue<ll> q;
  ll ans=0;

  ll it=0;
  rep(i,m){
    while(it<n && work[it].first<=i+1){
      //prt2("ADD--->", it);
      q.push(work[it].second);
      it++;
    }
    if(q.size()>0){
      //prt3("ANS ADD--->", q.top(), q.size());
      ans += q.top();
      q.pop();
    }
  }

  prt(ans);
}

/* test case
5 3
1 10
1 4
1 7
2 3
2 9
*/


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

using pi = pair<int,int>;
using P = pair<ll,pi>;

struct edge{ int to,cost,time; };

const int N = 50;
const int C = 2525;
const ll INF = LLONG_MAX/3;

vector<edge> G[N];
ll dp[N][C];

int main(){
    int n,m,s;
    cin >>n >>m >>s;
    s = min(s,C-1);

    rep(i,m){
        int u,v,a,b;
        cin >>u >>v >>a >>b;
        --u;
        --v;
        G[u].pb({v,a,b});
        G[v].pb({u,a,b});
    }

    vector<int> c(n),d(n);
    rep(i,n) cin >>c[i] >>d[i];

    rep(i,N)rep(j,C) dp[i][j] = INF;
    dp[0][s] = 0;

    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0,{0,s}});
    while(!pq.empty()){
        P p = pq.top();
        pq.pop();

        int pos = p.se.fi, cur = p.se.se;
        ll now = dp[pos][cur];
        if(p.fi > now) continue;

        // exchange
        int nj = min(cur+c[pos], C-1);
        if(dp[pos][nj] > now+d[pos]){
            dp[pos][nj] = now+d[pos];
            pq.push({dp[pos][nj], {pos,nj}});
        }

        // move
        for(const auto &e:G[pos])if(cur >= e.cost){
            nj = cur - e.cost;
            if(dp[e.to][nj] > now+e.time){
                dp[e.to][nj] = now+e.time;
                pq.push({dp[e.to][nj], {e.to,nj}});
            }
        }
    }

    for(int i=1; i<n; ++i){
        ll ans = INF;
        rep(j,C) ans = min(ans, dp[i][j]);
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 6236
N,M = map(int,input().split())

AC = set()
WA = [0]*N

for i in range(M):
    k,l = input().split()
    k = int(k)
    if l=="WA":
        if not k in AC:
            WA[k-1] += 1
    
    else:
        if not k in AC:
            AC.add(k)

counter = 0
for i in AC:
    counter += WA[i-1]

print("{} {}".format(len(AC),counter))

Measured memory_bytes: 51416
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
def main():
  q=int(input())
  lr=[list(map(int,input().split())) for _ in range(q)]
  all=[lri[0] for lri in lr]
  all[q:q]=[lri[1] for lri in lr]
  all.sort()
  d={}
  c=0
  d[all[0]]=c
  for i in range(2*q-1):
    for j in range(all[i],all[i+1]):
      if is_prime(j) and is_prime((j+1)//2):
        c+=1
    d[all[i+1]]=c
  for l,r in lr:
    a=d[r]-d[l]
    a+=1 if is_prime(r) and is_prime((r+1)//2) else 0
    print(a)
  
if __name__=='__main__':
  main()


Measured memory_bytes: 34696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll x;
	cin>>x;
	if(x>=30)cout<<"Yes";
	else cout<<"No";


    return 0;
}


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

int main()
{
  string s,t,u;
  cin>>s>>t;
  ll a,b;
  cin>>a>>b;
  cin>>u;
  if(u == s)
    a--;
  else
    b--;
  cout<<a<<" "<<b;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
input = sys.stdin.readline

ans = 0
N, S = int(input()), input()
for i in range(1, N-1):
    set_X = set(S[:i])
    set_Y = set(S[i:])
    set_tmp = set_X & set_Y
    ans = max(ans, len(set_tmp))
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main()
{
	int n, i;
	double x[100] = { 0 }, y[100] = { 0 };
	double p1 = 0, p2 = 0, p3 = 0, pm = 0, max = 0;
	cin >> n;

	i = 0;
	while (i < n) {
		cin >> x[i];
		i++;
	}

	i = 0;
	while (i < n) {
		cin >> y[i];
		i++;
	}

	i = 0;
	while (i < n) {
		p1 += fabs(x[i] - y[i]);
		p2 += pow(fabs(x[i] - y[i]), 2);
		p3 += pow(fabs(x[i] - y[i]), 3);
		pm= fabs(x[i] - y[i]);

		if (max < pm) {
			max = pm;
		}
		i++;
	}
	cout << fixed<<setprecision(10) << p1 << endl;
	cout << fixed<<setprecision(10) << sqrt(p2) << endl;
	cout << fixed<<setprecision(10) << cbrt(p3) << endl;
	cout << fixed<<setprecision(10) << max << endl;

    return 0;
}




Measured memory_bytes: 3472
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, k, x, ans;
    vector<int> dist;

    cin >> k >> n;

    for(int i=0; i<n; i++){
        cin >> x;
        dist.push_back(x);
    }

    sort(dist.begin(), dist.end());

    for(int i=0; i<n; i++){

        if(i == 0)
            ans = dist[n-1] - dist[0];
        else{

            int tempAns = (k - dist[i]) + dist[i-1];
            if(ans > tempAns) ans = tempAns;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1400
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

bool dfs(int A, int B, int C, int K) {
  if (K == 0) {
    if (A < B && B < C)
      return true;
    else
      return false;
  }
  if (dfs(A * 2, B, C, K - 1)) return true;
  if (dfs(A, B * 2, C, K - 1)) return true;
  if (dfs(A, B, C * 2, K - 1)) return true;
  return false;
}

int main(void) {
  ios::sync_with_stdio(false);
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  bool answer = dfs(A, B, C, K);
  if (answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3636
a = map(int,raw_input().split())[1:] + map(int,raw_input().split())[1:]
a = sorted(list(set([60*a[i]+a[i+1] for i in xrange(0,len(a),2)])))
print " ".join("%d:%02d"%(ai/60,ai%60) for ai in a)

Measured memory_bytes: 4220
from itertools import permutations
grid = []
for i in range(3):
    grid.append(list(map(int,input().split())))

A = []
B = []
for i in range(3):
    B.append(grid[0][i])
    A.append(grid[i][i]-B[i])

flag = True
for i in range(3):
    for j in range(3):
        if grid[i][j] != A[i] + B[j]:
            flag = False
            break
    if not flag: break

if flag: print('Yes')
else: print('No')

Measured memory_bytes: 3188
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import math

n,d = na()
g = d*2+1

print(math.ceil(n/g))

Measured memory_bytes: 3060
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))
def to_cumsum(arr, pad=True):
    """
    1次元配列を累積和の1次元配列に変換する
    pad: 先頭に0の項を作る場合はTrue
    """
    cumsum = 0
    padding = 1 if pad else 0
    new = [0] * (len(arr) + padding)
    for i, e in enumerate(arr):
        cumsum += e
        new[i + padding] = cumsum
    return new


N, K = MI()
P = LMI()
cum = to_cumsum(P, pad=True)

t = 0
for i in range(N - K + 1):
    m = cum[i + K] - cum[i]
    t = max(t, m)
print((t + K) / 2)

Measured memory_bytes: 71792
long long n[100][21];a[100],i,j;main(N){
for(scanf("%d",&N);i<N;i++)scanf("%d",a+i);
for(n[0][a[0]]=i=1;i<N-1;i++)for(j=0;j<=20;j++){if(0<=j-a[i])n[i][j-a[i]]+=n[i-1][j];if(j+a[i]<=20)n[i][j+a[i]]+=n[i-1][j];}
printf("%lld\n",n[N-2][a[N-1]]);exit(0);}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int a[109]={};
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        cin >> a[i];
        
        if(a[i]%2==0){
            
            if(a[i]%3!=0&&a[i]%5!=0){
                
                cout << "DENIED" << endl;
                return 0;
                
            }
            
        }
        
    }
    
    cout << "APPROVED" << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
D = lines[0][1]

def square?(x)
  y = (x ** 0.5).to_i
  if (y-1) ** 2 == x or y ** 2 == x or (y+1) ** 2 == x then
    return true
  else
    return false
  end
end

ans = 0
for i in 1..N-1 do
  for j in i+1..N do
    dis2 = 0
    for k in 1..D do
      dis2 += (lines[i][k-1] - lines[j][k-1]) ** 2
    end
    if square?(dis2) then
      ans += 1
    end
  end
end

print ans

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int N;
int a[2][105];
int iPlus(int b)
{
	int sum=0;
	for(int i=0;i<=b;i++)
	     sum+=a[0][i];
	for(int i=b;i<N;i++)
	     sum+=a[1][i];
	return sum;
}
int main()
{
	cin>>N;
	for(int i=0;i<2;i++)
	   for(int j=0;j<N;j++)
	       cin>>a[i][j];
	int sum1=0,max1=0;
	for(int i=0;i<N;i++)
	{
		sum1=iPlus(i);
		if(sum1>max1) max1=sum1;
	}
	cout<<max1<<endl;
	return 0;
}

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


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define Filein(N) freopen("N", "r", stdin);
#define Fileout(N) freopen("N", "w", stdout);

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define eps 1.0E-14
#define l length()
#define preci(x) fixed<<setprecision(x)
#define inf LONG_LONG_MAX
#define ninf LONG_LONG_MIN
int N;
char ans[111];

void odd(int n)
    {
    bool b=1;
        int x = sqrt(n);
    for (int i=2 ; i<=x ; ++i)

    {
        if(n%i == 0) {cout << "NO" << sp; b = 0;  break;}
    }
    if (b)
    cout << "Yes" << sp;
    b=1;
    }


void DFS(int cur,int mx){
//    printf("cur = %d\n",cur);
    if(cur==N){
        ans[N]='\0';
        printf("%s\n",ans);
        return;
    }
    for(int i=0;i<=cur;i++){
        ans[cur]='a'+i;
        DFS(cur+1,max(mx,i));
        if(i>mx) break;
    }
}

void work(){
    scanf("%d",&N);
    DFS(0,0);
}

ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main()
{
    init();
    
    string s; cin>>s;
    
    if (s[0] == s[1] && s[1] == s[2]) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
	int n, m;
	vector<vector<int> > f;
	for (;;) {
		scanf("%d %d", &n, &m);
		if (!n && !m) break;
		f = vector<vector<int> >(n + 1);
		rep(i, m) {
			int a, b;
			scanf("%d %d", &a, &b);
			f[a].push_back(b);
			f[b].push_back(a);
		}

		set<int> friends, friends_2;
		friends.insert(1);
		friends_2.insert(1);
		rep(i, f[1].size()) friends.insert(f[1][i]);

		for (auto ff : friends) {
			rep(i, f[ff].size()) friends_2.insert(f[ff][i]);
		}

		printf("%d\n", friends_2.size() - 1);
	}

	return 0;
}

Measured memory_bytes: 3000
# ABC 141 C
import collections
input_list = list(map(int, input().split()))
n = input_list[0]
k = input_list[1]
q = input_list[2]

pointed_player = []
for i in range(q):
    pointed_player.append(int(input())-1)

if q-k < 0:
    for i in range(n):
        print("Yes")
else:
    c = collections.Counter(pointed_player)
    c_sorted = sorted(c.items(), key=lambda x: x[1], reverse=True)
    ans_index = []
    for tup in c_sorted:
        if tup[1] > q - k:
            ans_index.append(tup[0])
        else:
            break
    for i in range(n):
        if i in ans_index:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 62552
#include <stdio.h>
#include <math.h>

double N;
double K;

int main(void){
	scanf("%lf %lf",&N,&K);

	double winPro=0;
	double invN=1/N;

	double m;

	for(double i=1; i<=N; i++){

		for(m=0; ;m++){
			if(K<=pow(2,m)*i){

				break;
			}
		}

		winPro += invN * pow(0.5,m);
	}

	printf("%.13lf\n",winPro);


}

Measured memory_bytes: 128
n = gets.chomp.to_i
p = gets.chomp.split
q = gets.chomp.split

list = '12345678'[0,n]
p_count = 1
(n-1).times do |i|
  num = list.index(p[i])
  p_count += num * (1..(n-i-1)).reduce(:*)
  list.delete!(p[i])
end

list = '12345678'[0,n]
q_count = 1
(n-1).times do |i|
  num = list.index(q[i])
  q_count += num * (1..(n-i-1)).reduce(:*)
  list.delete!(q[i])
end

puts((p_count - q_count).abs)

Measured memory_bytes: 14340
x1 ,x2 ,x3 ,x4 ,x5 = map(int,input().split())
if x1 == 0:
  print("1")
if x2 == 0:
  print("2")
if x3 == 0:
  print("3")
if x4 == 0:
  print("4")
if x5 == 0:
  print("5")

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }
  ll h = v[0];

  ll ret = 0;
  rep(i,N){
    if(h > v[i]){
      ret += h - v[i];
    }
    h = max(h, v[i]);
  }
  
  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 5368
m = int(input())
if m==1:
    print(0)
    exit()
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
key=list(pf.keys())
used=[0]*len(key)
#print(pf)
cnt=0
for i in range(len(key)):
    k=key[i]
    tmp=0
    while pf[k]>used[i]+tmp:
        tmp+=1
        used[i]+=tmp
        cnt+=1
        #print(used,tmp)
print(cnt)

Measured memory_bytes: 63624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

bool judge(int k, int n, int s){
  if(k % 2){
    int l = s, r = s;
    for(int i = 0; i < k/2; i++){
      l -= 2 * pow(4, i);
      r += pow(4, i);
    }
    l -= 2 * pow(4, k/2);
    r -= pow(4, k/2);
    if(l <= n && n <= r){
      return true;
    }else{
      return false;
    }
  }else{
    int l = s, r = s;
    for(int i = 0; i < k/2; i++){
      l += pow(4, i);
      r += pow(4, i);
    }
    l += 1;
    r += pow(4, k/2);
    if(l <= n && n <= r){
      return true;
    }else{
      return false;
    }
  }
}

int main(){
  int N;
  cin >> N;
  if(N == 0){
    cout << 0 << endl;
    return 0;
  }
  int k = 0;
  while(!judge(k, N, 0)){
    k++;
  }
  int ans[k+1];
  if(N) ans[k] = 1;
  else ans[k] = 0;
  int s = pow(-2, k);
  for(int i = k-1; i >= 0; i--){
    if(judge(i, N, s)){
      ans[i] = 1;
      s += pow(-2, i);
    }else{
      ans[i] = 0;
    }
  }
  for(int i = k; i >= 0; i--){
    cout << ans[i];
  }
  cout << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end(), greater<int>());
  int al = 0, bo = 0;
  for(int i = 0; i < n; i++) {
    if(i % 2)
      bo += a.at(i);
    else
      al += a.at(i);
  }
  cout << al - bo << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  string s,t;
  int c = 0;
  cin >> s >> t;
  for(int i = 0; i < 3;i++)
  {
      if(s[i] == t[i])c++;
  }
  cout << c << endl; 
  return 0;
}



Measured memory_bytes: 256