akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
bool ok;
int main()
{
	int n;
	cin>>n;
	while(n)
	{
		if(n%10==7)
		{
			ok=true;
		}
		n/=10;
	}
	if(ok)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3672
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


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

typedef long long ll;
#define all(x) x.begin(),x.end()
class BGoToJail {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int n;
        cin  >> n;

        vector<vector<int>> d(n,vector<int>(2));

        for (int i = 0; i < n; ++i) {
            cin >> d[i][0] >> d[i][1];
        }

        for (int i = 0; i + 2 < n; ++i) {
            if (d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]){
                cout << "Yes" << endl;
                return;
            }
        }
        cout << "No" << endl;
	}
};


#define loveAfterTheGame main

int loveAfterTheGame() {
	BGoToJail solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3668
import sys
input = sys.stdin.readline

D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]

for i in range(D):
    MAX=-1
    for j in range(26):
        if S[i][j]>MAX:
            k=j
            MAX=S[i][j]
    print(k+1)
        
        


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

using namespace std;

#define int long long

constexpr int INF = 1LL << 60;

constexpr int MAX_P = 500005;
constexpr int MAX_S = 505;
constexpr int MAX_IMOS = MAX_P + 2 * MAX_S;

typedef pair<int, int> pii;

int r, s, p, imos[MAX_IMOS];

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

    cin >> r >> s >> p;

    for (int i = 0; i < p; i++)
    {
        int y, x;
        cin >> y >> x;
        if (s < x) x++;
        imos[abs(s + 1 - x) + (r - y) + 1]++;
    }

    int left = 0, last = 0;
    for (int i = 1; i < MAX_IMOS; i++)
    {
        left = left + imos[i];
        if (left)
        {
            last = i;
            left--;
        }
    }

    cout << last << endl;
}




Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[100008];
    queue<int>q;
    int n,k=0,c=0,x=0;
    scanf("%d%d",&n,&k);
    scanf("%s",a);
    int b=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='0')
        {
            while(a[i]!='1' && i<n){i++;b++;}
            q.push(b);
            b=0;
            i--;
        }
        else b++;
    }

    for(int i=0;i<n;i++)
    {
        if(a[i])
        if(k>0 && a[i]=='0')
        {
            while(a[i]!='1' && i<n)
            {
                i++;c++;
            }
            k--;i--;
        }
        else if(k==0 && a[i]=='0')
        {
            //cout<<c<<endl;
            if(c>x)x=c;
            c-=q.front();
            q.pop();
            //cout<<c<<endl;
            while(a[i]!='1' && i<n)
            {
                i++;
                c++;
            }
            i--;
        }
        else c++;
    }
    //cout<<c<<endl;
    if(c>x)x=c;
    printf("%d",x);
    return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    
    double ans = 0;
    for ( int i = 1; i <= N; ++i){
        int x = i;
        double prb = 1.0/N;
        for ( int j = 1; j < 100; ++j){
            if ( x >= K ){
                ans += prb;
                break;
            }
            x *= 2;
            prb *= 0.5;
        }
    }
    
    printf("%10.10f", ans);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <assert.h>
#include <string>
#include <algorithm>

using namespace std;
class dice{
	int a[7];
public:	
	dice(){ for (int i = 1; i <= 6; ++i) a[i] = i + 1; }
	void set(int i, int n){ assert(1<=i && i<=6); a[i] = n; }
	void rot(char ch){
		assert(ch=='W' || ch=='N' || ch=='S' || ch=='E');
		int tmp = a[1];
		switch (ch)
		{
		case 'W':
			a[1] = a[3]; a[3] = a[6]; a[6] = a[4]; a[4] = tmp;
			break;
		case 'E':
			a[1] = a[4]; a[4] = a[6]; a[6] = a[3]; a[3] = tmp;
			break;
		case 'N':
			a[1] = a[2]; a[2] = a[6]; a[6] = a[5]; a[5] = tmp;
			break;
		case 'S':
			a[1] = a[5]; a[5] = a[6]; a[6] = a[2]; a[2] = tmp;
			break;
		}
	}
	int top(){ return a[1]; }
	int south(){ return a[2]; }
	int west(){ return a[4]; }
	int east(){ return a[3]; }
	int north(){ return a[5]; }
	int bottom(){ return a[6]; }
	friend bool operator==(dice d1, dice d2){	
		for (int k = 0; k < 4; ++k){
			for (int i = 0; i < 4; ++i){
				for (int j = 0; j < 4; ++j){
					if (d1.top() == d2.top() &&
						d1.south() == d2.south() &&
						d1.north() == d2.north() &&
						d1.east() == d2.east() &&
						d1.west() == d2.west() &&
						d1.bottom() == d2.bottom()
						) return true;
					d1.rot('W');
				}
				d1.rot('N');
			}
			d1.rot('W');
		}
		return false;
	}
};
dice D[101];
int main(){
	int n; cin >> n;
	int a[6];
	for (int j = 0; j < n; ++j){
		for (int i = 0; i < 6; ++i){ cin >> a[i]; D[j].set(i + 1, a[i]); }
	}
	bool flag = false;
	for (int i = 0; i < n; ++i){
		for (int j = i + 1; j < n; ++j) if (D[i] == D[j]) { flag = true; goto out;}
	}
	out:
	if (flag) cout << "No\n"; else cout << "Yes\n";
}

Measured memory_bytes: 1128
#include <stdio.h>

int x,y,c,t;

int main(){

	scanf("%d%d", &x,&y);	for(t=0; t<=x; t++){

		c=x-t;

		if(4*t+2*c==y){

		printf("Yes\n");

		return 0;

	}

	}

	printf("No\n");

	return 0;

}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
using namespace std;
void roll(vector<int> &saikoro,char houkou){
    //上が１、下が６、手前が２、奥が５、右が３、左が４
    int x,y;
    x = saikoro.at(6);
    y = saikoro.at(1);
    if(houkou == 'N') {
        saikoro.at(6) = saikoro.at(5);
        saikoro.at(1) = saikoro.at(2);
        saikoro.at(2) = x;
        saikoro.at(5) = y;
    }
    else if(houkou == 'S') {
        saikoro.at(6) = saikoro.at(2);
        saikoro.at(1) = saikoro.at(5);
        saikoro.at(5) = x;
        saikoro.at(2) = y;
    }
    else if(houkou == 'E') {
        saikoro.at(6) = saikoro.at(3);
        saikoro.at(1) = saikoro.at(4);
        saikoro.at(4) = x;
        saikoro.at(3) = y;
    }
    else if(houkou == 'W') {
        saikoro.at(6) = saikoro.at(4);
        saikoro.at(1) = saikoro.at(3);
        saikoro.at(3) = x;
        saikoro.at(4) = y;
    }
}

int main() {
    vector<int> sai(7);
    for(int i = 1; i <= 6; i++) {
        cin >> sai.at(i);
    }
    string todo;
    cin >> todo;
    for(int i = 0; i < todo.size(); i++) {
        roll(sai,todo.at(i));
    }
    cout << sai.at(1) << endl;
}


Measured memory_bytes: 3212
#include <iostream>

void swap(int &a, int &b){
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

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

  if (a > b) swap(a,b);
  // b >= a;
  
  while(a>0){
    int r = b%a;
    //int c = b/a;
    //b = a*c + r
    b = a;
    a = r;
  }
  
  std::cout << b << std::endl;
}

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

char sym[128];

int main(){
	sym['i'] = 'i';
	sym['w'] = 'w';
	sym['('] = ')';
	sym[')'] = '(';
	sym['{'] = '}';
	sym['}'] = '{';
	sym['['] = ']';
	sym[']'] = '[';

	string s;
	cin >> s;
	int last = 1 << s.size();
	int iwi = 0;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'i'){
			iwi = 7 << i;
			break;
		}
	}

	int ans = 0;
	for(int S = 0; S < last; ++S){
		if(~S & iwi){ continue; }
		string t;
		for(int i = 0; i < s.size(); ++i){
			if(S >> i & 1){ t += s[i]; }
		}
		if(t.size() % 2 == 0 || t.size() <= ans){ continue; }
		int k = t.size() - 1;
		bool ok = true;
		for(int i = 0; i < k; ++i, --k){
			if(sym[t[i]] != t[k]){
				ok = false;
				break;
			}
		}
		if(ok){ ans = t.size(); }
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1184
import scala.io.StdIn

object Main extends App {
  val n  = StdIn.readLine().toInt
  val s  = StdIn.readLine()

  def solve2(s: String): Int = {
    var min = s.count(_=='.')
    var ret = min
    s.reverse.dropWhile(_ == '#').reverse.foreach ({
      v => v match {
        case '#' =>  min = min + 1; ret = ret.min(min)
        case '.' => min = min - 1; ret = ret.min(min)
      }
    })

    ret
  }

  
  println(solve2(s))


}

  



Measured memory_bytes: 33964
#include <queue>
#include <cstdio>
#include <cstring>

const int maxn = 112345, maxm = 412345;
typedef long long ll;

struct edge{
	int v, nxt, flow;
	ll cost;
};

edge e[maxm]; int fir[maxn], num(1);
int S = 0, T;

inline void add(int u, int v, int flow, ll cost){
	e[++num].v = v; e[num].flow = flow; e[num].cost = cost;
	e[num].nxt = fir[u]; fir[u] = num;
	e[++num].v = u; e[num].flow = 0; e[num].cost = -cost;
	e[num].nxt = fir[v]; fir[v] = num;
}

ll ans(0);

ll dis[maxn]; int pre[maxn], f[maxn];

inline ll max(ll a, ll b){
	return a > b ? a : b;
}

inline ll min(ll a, ll b){
	return a < b ? a : b;
}

bool vis[maxn];

const ll inf = -1e18;

inline bool spfa(){
	std::queue<int> q; q.push(0);
	for(int i(1); i <= T; ++i) dis[i] = inf, f[i] = 0, vis[i] = 0;
	dis[0] = 0; f[0] = 1123456789; vis[0] = 1;
	while(!q.empty()){
		int now = q.front(); q.pop(); vis[now] = 0;
		for(int itr(fir[now]), v; itr; itr = e[itr].nxt){
			if(e[itr].flow == 0) continue;
		 	v = e[itr].v;
		 	/*
			if(dis[now] + e[itr].cost == dis[v] && min(f[now], e[itr].flow) >= f[v]){
				f[v] = min(f[now], e[itr].flow); pre[v] = now; 
				if(!vis[v]){
					vis[v] = true; q.push(v);
				}
			}
			*/
			if(dis[now] + e[itr].cost > dis[v]){
				f[v] = min(f[now], e[itr].flow); pre[v] = itr;
				dis[v] = dis[now] + e[itr].cost;
				if(!vis[v]){
					vis[v] = true; q.push(v);
				}
			}
		}
	}
	return f[T] != 0;
}

inline void process(){
	int now = T;
	while(now != 0){
		int itr = pre[now], oppo = itr^1, nxt = e[oppo].v;
		e[itr].flow -= f[T], e[oppo].flow += f[T];
		now = nxt;
	}
}

inline void EK(){
	while(spfa()){
		process();
		ans += dis[T]*f[T];
	}
}

int main(){
	int n; scanf("%d", &n);
	T = 2*n + 5;
	for(int i(1), t; i <= n; ++i){ ll x, y;
		scanf("%lld%lld%d", &x, &y, &t);
		add(S, i, t, 0);
		add(i, 2*n + 1, t, x + y);
		add(i, 2*n + 2, t, x - y);
		add(i, 2*n + 3, t,-x + y);
		add(i, 2*n + 4, t,-x - y);
	}
	for(int i(1), t; i <= n; ++i){ ll x, y;
		scanf("%lld%lld%d", &x, &y, &t);
		add(i + n, T, t, 0);
		add(2*n + 1, i + n, t,-x - y);
		add(2*n + 2, i + n, t,-x + y);
		add(2*n + 3, i + n, t,x - y);
		add(2*n + 4, i + n, t,x + y);
	}
	EK();
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 2304
#include <stdio.h>


int main(void)
{
	long i = 0,t,j;
	long test[10000];
	do {
		scanf("%d", &t);
		test[i] = t;
		i++;
	} while (t != 0);
	i = i - 2;
	for (j = 0; j <= i; j++){
		printf("Case %d: %d\n",j + 1,test[j]);
	}
	return 0;
}

Measured memory_bytes: 1876
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    int count=0;
    
    cin >> a >> b >> c;
    
    for(int i=a; i<=b; i++){
        if(c%i==0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1160
from fractions import gcd
a, b = map(int,input().split())

GCD = gcd(a,b)
ans = 1
for i in range(2, int(GCD ** 0.5) + 1):
    if GCD%i == 0:ans += 1
    while GCD%i == 0:
        GCD //= i
if GCD != 1:ans += 1
print(ans)

Measured memory_bytes: 65640
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>

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

using namespace std;

typedef long long ll;

inline int getInt(){ int s; scanf("%d", &s); return s; }

int main(){
  int n = getInt();
  vector<int> h(n);
  vector<int> a(n);
  vector<int> d(n);
  vector<int> s(n);
  vector<int> memo(n);
  vector<pair<double, int> > c(n);

  int hh = getInt();
  int aa = getInt();
  int dd = getInt();
  int ss = getInt();
  ll ans = 0;
  ll tm  = 0;

  REP(i,n){
    h[i] = getInt();
    a[i] = getInt();
    d[i] = getInt();
    s[i] = getInt();
    ll dam = aa - d[i];

    if(dam <= 0){
      if(a[i] - dd <= 0){
	i--;
	n--;
	continue;
      }else{
	goto bad;
      }
    }

    memo[i] = (h[i] + dam - 1) / dam;

    if(s[i] > ss)
      c[i].first = (double)max(0, a[i] - dd) / (memo[i]);
    else
      c[i].first = (double)max(0, a[i] - dd) / (memo[i]);
    c[i].second = i;
  }

  c.resize(n);

  sort(c.rbegin(), c.rend());

  REP(i,n){
    int ii = c[i].second;
    int tt = memo[ii] - 1;

    if(s[ii] > ss) tt++;
    ans += (tm + tt) * max(0, a[ii] - dd);
    if(ans >= hh) goto bad;    
    tm  += memo[ii];
  }

  printf("%d\n", (int)ans);

  return 0;

 bad:
  puts("-1");

  return 0;
}

Measured memory_bytes: 0
n, k = map(int, input().split())
ans = 0
if k % 2 != 0:
    ans = 1
    for i in range(3):
        ans *= n // k
    print(ans)

else:
    ans_1 = 1
    for i in range(3):
        ans_1 *= n // k
    ans_2 = 1
    for i in range(3):
        ans_2 *= len(list(range(int(k/2), n+1, k)))
    ans = ans_1 + ans_2
    print(ans)


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

int main(){
	int N, M;
	cin >> N >> M;
	vector< vector<int> >  H(N + 1, vector<int>(20000)), V(M + 1, vector<int>(20000));
	vector< vector< pair<char, pair<int, int>> > > X(N + 1, vector< pair<char, pair<int, int>> >(M + 1)); //char, (idh, idv)
	int cnt = 0, res = 0, id = 0;
	char c;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cin >> c;
			X[i][j] = make_pair(c, make_pair(0, 0));
		}
	}
	//horizontal ids
	for(int i = 0; i < N; i++){
		id = 0;
		cnt = 0;
		for(int j = 0; j < M; j++){
			if(X[i][j].first == '#' or j == M - 1){
				H[i][id] = cnt;
				//cout << i << " " << j << " " << H[i][id] << " " <<id << endl; 
				cnt = 0;
				if(X[i][j].first == '#'){
					if(j != 0){id ++;}
					X[i][j].second.first = id;
					H[i][id] = cnt;
					//cout << i << " " << j << " " << H[i][id] << " " <<id << endl;
					id ++;
				}else if(j == M - 1){
					H[i][id] ++;
					X[i][j].second.first = id;
					//cout << " hh " << H[i][id] << endl; 
				}
			}else{
				X[i][j].second.first = id;
				cnt ++;
			}
		}
	}
	//vertical ids
	for(int i = 0; i < M; i++){
		id = 0;
		cnt = 0;
		for(int j = 0; j < N; j++){
			if(X[j][i].first == '#' or j == N - 1){
				V[i][id] = cnt; 
				cnt = 0;
				//cout << i << " " << j << " " << V[i][id] << " " <<id << endl;
				if(X[j][i].first == '#'){
					if(j != 0){id ++;}
					X[j][i].second.second = id;
					V[i][id] = cnt;
					//cout << i << " " << j << " " << V[i][id] << " " <<id << endl;
					id ++;
				}else if(j == N - 1){
					V[i][id] ++;
					X[j][i].second.second = id;
					//cout <<" hh" <<  i << " " << j << " " << V[i][id] << " " <<id << endl;
				}
			}else{
				X[j][i].second.second = id;
				cnt ++;
			}
		}
	}
	/*
	for(int i = 0; i < N ;i ++){
		for(int j =0;j < M; j++){
			cout << H[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	for(int i = 0; i < M ;i ++){
		for(int j =0;j < N; j++){
			cout << V[i][j] << " ";
		}
		cout << endl;
	}*/
	
	//get answer
	int id1 = 0, id2 = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			id1 = X[i][j].second.first, id2 = X[i][j].second.second;
			res = max( H[i][id1] + V[j][id2] - 1 , res);
			//cout << i << " " << j << " " << id1 << " " << id2 << " " << H[i][id1] << " " << V[j][id2] << endl;
		}
	}
	cout << res;  
	return 0;
}


Measured memory_bytes: 361600
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int* a = new int[N];

    // cout << "ok" << endl;
    int result[100000];

    for(int i =0; i < 100000; i++){
        result[i] = 0;
    }

    for(int i = 0; i < N; i++){
        cin >> a[i];
        result[a[i]]++;
        if(a[i]+1 != 100000) result[a[i] + 1]++;
        if(a[i]-1 != -1) result[a[i] - 1]++;
    }

    int max = 0;
    for(int i = 0; i < 100000; i++){
        if (result[i]) {
            // cout << i << " " << result[i] << endl;
            if (result[i] > max)
                max = result[i];
        }
    }
    cout << max;

    return 0;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  reverse(a.begin(),a.end());
  ll dp[114514];
  rep(i,n+1)dp[i]=INF;
  rep(i,n){
    *upper_bound(dp,dp+n,a[i])=a[i];
  }
  ll ans=lower_bound(dp,dp+n,INF)-dp;
  cout<<ans<<endl;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K;
int p[220000];
double pcc[220000];
signed main() {
    cin >> N >> K;
    rep(i, N) { cin >> p[i]; }
    for (int i = 0; i < N; i++) { pcc[i + 1] = (p[i] + 1.0) / 2 + pcc[i]; }
    double ans = 0;
    for (int i = 0; i <= N - K; i++) {
        chmax(ans, pcc[i + K] - pcc[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;


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

i64 K, A, B; cin >> K >> A >> B;

if (B - A <= 1) // 交換でビスケットを増やすことができない．
    cout << K + 1 << endl;
else if (B - A > 1){ 
    // 1個からA - 1 回叩いてA個に増やす．
    if (A - 1 <= K) {
        i64 ans = A;
        K -= A - 1;
        ans += (B - A) * (K / 2);
        if (K % 2) ++ans;
        cout << ans << endl;
    }
    else 
        cout << K + 1 << endl;
}


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

void Search(string &s, vector<string>&ans, int n,char mx='a') {
	if (s.size() == n) {
		ans.push_back(s);
		return;
	}
	for (char i = 'a'; i <= mx + 1; i++) {
		s.push_back(i);
		Search(s, ans, n, max(mx, i));
		s.pop_back();
	}
}

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

	int N;
	cin >> N;
	vector<string>ans;
	string s = "a";
	Search(s, ans, N);
	for (auto i : ans)cout << i << endl;
}

Measured memory_bytes: 9716
import os
from math import*
import sys
input=sys.stdin.buffer.readline

n=int(input())
arr=list(map(int,input().split()))

if n==2:
	print(arr[0]+arr[0])
else:
	ans=arr[0]+arr[-1]
	for i in range(0,n-2):
		ans+=min(arr[i],arr[i+1])
	print(ans)

Measured memory_bytes: 62192
R, C, K = map(int, input().split())
item = {}
for _ in range(K):
    r, c, v = map(int, input().split())
    item[(r, c)] = v

dp = [[0] * 4 for _ in range(3010)]
ndp = [[0] * 4 for _ in range(3010)]
for r in range(1, R+1):
    for c in range(1, C+1):
        prer = max(dp[c])
        ndp[c][0] = max(prer, ndp[c-1][0])
        ndp[c][1] = max(prer, ndp[c-1][1])
        ndp[c][2] = max(prer, ndp[c-1][2])
        ndp[c][3] = max(prer, ndp[c-1][3])
        if item.get((r, c)):
            ndp[c][1] = max(ndp[c][1], max(prer, ndp[c-1][0]) + item[(r,c)])
            ndp[c][2] = max(ndp[c][2], max(prer, ndp[c-1][1]) + item[(r,c)])
            ndp[c][3] = max(ndp[c][3], max(prer, ndp[c-1][2]) + item[(r,c)])
    dp = ndp
    ndp = [[0] * 4 for _ in range(3010)]

#print(dp)
print(max(dp[C]))


Measured memory_bytes: 224768
#include <cstdio>
#include <cstring>
using namespace std;

int h, w, n;
int a[1010][1010];
int dp[1010][1010][2];

int main(){
	while(1){
		scanf("%d %d %d", &h, &w, &n);
		if(h == 0) break;
		for(int i=1; i<=h; ++i)
			for(int j=1; j<=w; ++j)
				scanf("%d", &a[i][j]);
		memset(dp, 0, sizeof(dp));
		dp[1][1][1-a[1][1]] = (n-1) / 2;
		dp[1][1][a[1][1]] = n-1 - dp[1][1][1-a[1][1]];
		for(int i=2; i<=h; ++i){
			dp[i][1][1-a[i][1]] = dp[i-1][1][0] / 2;
			dp[i][1][a[i][1]] = dp[i-1][1][0] - dp[i][1][1-a[i][1]];
		}
		for(int i=2; i<=w; ++i){
			dp[1][i][1-a[1][i]] = dp[1][i-1][1] / 2;
			dp[1][i][a[1][i]] = dp[1][i-1][1] - dp[1][i][1-a[1][i]];
		}
		for(int i=2; i<=h; ++i){
			for(int j=2; j<=w; ++j){
				int s = dp[i-1][j][0] + dp[i][j-1][1];
				dp[i][j][1-a[i][j]] = s / 2;
				dp[i][j][a[i][j]] = s - dp[i][j][1-a[i][j]];
			}
		}
		for(int i=1; i<=h; ++i){
			for(int j=1; j<=w; ++j){
				int t = (dp[i][j][0] + dp[i][j][1]) % 2;
				a[i][j] = (a[i][j] + t) % 2;
			}
		}
		int x = 1, y = 1;
		while(x <= w && y <= h){
			if(a[y][x] == 0) y++;
			else x++;
		}
/*		for(int i=1; i<=h; ++i){
			for(int j=1; j<=w; ++j){
				printf("%d\t", a[i][j]);
			}
			printf("\n");
		}
*/		printf("%d %d\n", y, x);
	}
}

Measured memory_bytes: 14576
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	FOR(i,1,3501) {
		FOR(j,1,3501) {
			ll ue=n*i*j;
			ll st=4*i*j-n*i-n*j;
			if(st!=0&&ue%st==0&&ue/st>0) {
				cout<<i<<" "<<j<<" "<<ue/st<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll h,w;cin>>h>>w;
  vector<string>s(h);
  rep(i,h)cin>>s[i];
  vector<vector<char> >ans(h,vector<char>(w));
  vl dx={-1,-1,-1,0,0,1,1,1};
  vl dy={1,0,-1,1,-1,1,0,-1};
  rep(i,h){
    rep(j,w){
      ll count=0;
      if(s[i][j]=='#'){
        ans[i][j]='#';
        continue;
      }
      rep(k,8){
        if(0<=j+dx[k]&&j+dx[k]<w&&0<=i+dy[k]&&i+dy[k]<h){
          if(s[i+dy[k]][j+dx[k]]=='#')count++;
        }
      }
      ans[i][j]='0'+count;
    }
  }
  rep(i,h){
    rep(j,w)cout<<ans[i][j];
    cout<<endl;
  }
}
      
      
      

Measured memory_bytes: 256
/*
 * FileName:     min_max_elements
 * CreatedDate:  2020-05-24 15:24:17 +0900
 * LastModified: 2020-05-24 15:36:14 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#define m 1000000001


int main(void){
    int n;
    scanf("%d",&n);
    long int *a = malloc(n*sizeof(long int));
    for(int i=0;i<n;i++){
        scanf("%ld",a+i);
    }
    int q;
    scanf("%d",&q);
    long int tmp;
    for(int i=0;i<q;i++){
        int command,b,e;
        scanf("%d %d %d",&command,&b,&e);
        if(command==0){
            tmp=m;
            for(int j=b;j<e;j++){
                if(tmp>a[j]){tmp=a[j];}
            }
            printf("%ld\n",tmp);
        }
        else{
            tmp=-m;
            for(int j=b;j<e;j++){
                if(tmp<a[j]){tmp=a[j];}
            }
            printf("%ld\n",tmp);

        }
        
    }
    free(a);
    return 0;
}



Measured memory_bytes: 2100
import numpy as np
n = int(input())
shops = []
for _ in range(n):
    shops.append(list(map(int, input().split())))
scores = []
for _ in range(n):
    scores.append(list(map(int, input().split())))

cans = []
def dfs(ind, array):
    if ind == 10:
        cans.append(array)
    else:
        dfs(ind+1, array + [0])
        dfs(ind+1, array + [1])
dfs(0, [])
cans.remove([0 for _ in range(10)])

totalscorelist = []
for one in cans:
    indexlist = []
    for other in shops:
        one = np.array(one)
        other = np.array(other)
        k = np.dot(one, other)
        indexlist.append(k)
    totalscore = 0
    for scorebord, index in zip(scores, indexlist):
        totalscore += scorebord[index]
    totalscorelist.append(totalscore)
print(max(totalscorelist))

Measured memory_bytes: 12500
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
int bit[MAX];
  
void Add(int i,int x){
  while(i){
    bit[i]+=x;
    i-=(i&-i);
  }
}
  
int Get(int i){
  int res=0;
  while(i<MAX){
    res+=bit[i];
    i+=(i&-i);
  }
  return res;
}
  
int n,q;
  
int main(){
  scanf("%d %d",&n,&q);
  while(q--){
    int type;
    scanf("%d",&type);
    if(type==0){
      int l,r,x;
      scanf("%d %d %d",&l,&r,&x);
      Add(r,x);
      Add(l-1,-x);
    }else{
      int target;
      scanf("%d",&target);
      printf("%d\n",Get(target));
    }
  }
  return 0;
}

Measured memory_bytes: 3580
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc  = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int x = sc.nextInt();
      	int ans = 0;
      	int sum;
      	for(int i = 0; i <= a; i++){
        	for(int j = 0; j <= b; j++){
            	for(int k = 0; k <= c; k++){
                	sum = (500*i) + (100*j) + (50*k);
                  	if(sum == x) ans++;
                }
            }
        }
      	System.out.println(ans);
    }
}

Measured memory_bytes: 35696
// Problem : C - Tsundoku
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

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

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m), pa(n + 1, 0), pb(m + 1, 0);
    rep(i, 0, n - 1) {
      cin >> a[i];
      pa[i + 1] = pa[i] + a[i];
    }
    rep(i, 0, m - 1) {
      cin >> b[i];
      pb[i + 1] = pb[i] + b[i];
    }

    int ans = 0;

    for (int i = 0; i <= n; i++) {
      if (pa[i] > k) break;
      int r = k - pa[i];
      int lo = 0;
      int hi = m;
      int a = 0;
      while (lo <= hi) {
        int mid = lo + (hi - lo) / 2;
        if (pb[mid] <= r) {
          a = mid;
          lo = mid + 1;
        } else {
          hi = mid - 1;
        }
      }
      ans = max(a + i, ans);
    }
    cout << ans << '\n';
  }

  return 0;
}


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

int main(){
int X, A, B;
cin >> X >> A >> B;
if (A - B >= 0 ){
    cout << "delicious" << endl;
}
else if (B - A <= X) {
    cout << "safe" << endl;
}
else {
    cout << "dangerous" << endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

map<char, bool> mp;
void solve(string s) {
    bool now = mp[s.front()];
    int cnt = 0;
    FORE(e, s) {
        cnt += now != mp[e];
        now = mp[e];
    }
    cout << cnt << endl;
}

signed main(void) {
    int n, m, p;
    string s;
    FORE(e, "qwertasdfgzxcvb") {
        mp[e] = true;
    }
    FORE(e, "yuiophjklnm") {
        mp[e] = false;
    }
    while (cin >> s) {
        if (s == "#") return 0;
        solve(s);
    }
}

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

using namespace std;

string str1 = "", str2 = "";

int n;

int main () {
    cin >> n;
    if (n % 2 == 1) {
        cout << "No";
        exit (0);
    }
    for (int i = 1;i <= n;i ++) {
        char c;
        cin >> c;
        if (i <= n / 2)str1 += c;
        else str2 += c;
    }
    cout << (str1 == str2 ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll a,b,c,d;
	ll cd;
	ll left=0LL,right=0LL;
	cin >>a>>b>>c>>d;
	a--;
	cd = c * d / __gcd(c, d);
	left = a - a / c - a / d + a / cd;
	right = b - b / c - b / d + b / cd;
	clog << right << " " << left << endl;
	cout<<right-left<<endl;
}
/*
find; N|c - N|D + N|(C*D/gcd(C*D))
*/

Measured memory_bytes: 3584
import java.awt.*;
import java.io.*;
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestB().doIt();
	}
	class TestB{
		void doIt() {
			String S = sc.next();
			String T = sc.next();
			char SubT[] = T.toCharArray();
			int lengthS = S.length();
			int lengthT = T.length();
			int length = lengthS - lengthT;
			int min = 10000;
			for(int i = 0;i <= length;i++){
//				System.out.println(S.substring(i,i + lengthT));
				char SubS[] = S.substring(i,i + lengthT).toCharArray();
				int count = 0;
				for(int j = 0;j < lengthT;j++) {
					if(SubS[j] != SubT[j]) {
						count++;
					}
				}
				min = Math.min(min,count);
			}
			System.out.println(min);
		}
	}
}

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

typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	int ans = 0;
	cin>>n;
	for (int a = 1; a <= n; a++) {
		for (int b = 1; b <= n; b++) {
			for (int c = 1; c <= n; c++) {
				ans += __gcd(a, __gcd(b, c));
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int h,w;
    cin >> h >> w;
    char a;
    int cnt[26] = {};
    REP(i,h){
        REP(j,w){
            cin >> a;
            cnt[a - 'a']++;
        }
    }
    if(h == 1 || w == 1){
        bool odd = false;
        REP(i,26){
            if(cnt[i] % 2 == 1){
                if(odd){
                    cout << "No" << endl;
                    return 0;
                }
                odd = true;
            }
        }
        cout << "Yes" << endl;
    }else if(h % 2 == 0 && w % 2 == 0){
        REP(i,26){
            if(cnt[i] % 4 != 0){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }else if(h % 2 == 0 || w % 2 == 0){
        int even;
        if(h % 2 == 0) even = h;
        else even = w;
        int two = 0;
        REP(i,26){
            if(cnt[i] % 4 == 2){
                two++;
                if(two > even / 2){
                    cout << "No" << endl;
                    return 0;
                }
            }else if(cnt[i] % 4 != 0){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }else{
        int two = 0;
        bool odd = false;
        REP(i,26){
            if(cnt[i] % 4 == 2){
                two++;
                if(two > h / 2 + w / 2){
                    cout << "No" << endl;
                    return 0;
                }
            }else if(cnt[i] % 4 != 0){
                if(odd){
                    cout << "No" << endl;
                    return 0;
                }
                odd = true;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
	g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
	addArc(g, a, b, w);
	addArc(g, b, a, w);
}

template<typename T>
vector<T> compress(vector<T> v) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	return v;
}

template<typename T>
int index(const vector<T> &zip, T i) { return lower_bound(zip.begin(), zip.end(), i) - zip.begin(); }

vector<int> getPath(int s, int g, vector<int> prev) {
	vector<int> path;
	path.emplace_back(g);
	for (int i = g; i != s; ) {
		if (i == -1)
			return vector<int>();
		path.emplace_back(i = prev[i]);
	}
	reverse(path.begin(), path.end());
	return path;
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	using P = tuple<int, int>;
	vector<P> v;
	vector<int> p(M), q(M), c(M); rep(i, 0, M) {
		cin >> p[i] >> q[i] >> c[i];
		p[i]--, q[i]--;
		v.emplace_back(p[i], c[i]);
		v.emplace_back(q[i], c[i]);
	}

	vector<P> zip = compress(v);

	int n = zip.size();
	Graph g(n + N);
	rep(i, 0, M) {
		addEdge(g, index(zip, P(p[i], c[i])), index(zip, P(q[i], c[i])), 0);
	}

	rep(i, 0, n) {
		int cv, cc; tie(cv, cc) = zip[i];
		addEdge(g, n + cv, i, 1);
	}

	auto zeroOneBfs = [&](const Graph &g, int s, Array &dist) {
		int n = g.size();
		deque<int> dq = { s };
		dist.assign(n, INF);
		dist[s] = 0;
		while (dq.size()) {
			int v = dq.front(); dq.pop_front();
			for (auto &e : g[v]) {
				if (dist[e.d] == INF) {
					dist[e.d] = dist[v] + e.w;
					if (e.w == 0)
						dq.push_front(e.d);
					else
						dq.push_back(e.d);
				}
			}
		}
	};

	Array dist;
	zeroOneBfs(g, n + 0, dist);
	dump(dist);
	cout << (dist[n + N - 1] == INF ? -1 : dist[n + N - 1] / 2) << endl;

	return 0;
}

Measured memory_bytes: 55404
N = int(input())
X = list(map(int, input().split()))

mod = 10 ** 9 + 7

can_goal = 1
pos = 0
cand = 0

ans = 1
for x in X:
    can_goal += x - pos - 1
    cand += 1
    pos = x

    if can_goal == 0:
        ans = ans * cand % mod
        cand -= 1
        can_goal += 1
    else:
        can_goal -= 1

while cand:
    ans = ans * cand % mod
    cand -= 1

print(ans)

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

#define N 10000

int main(){

  int n, a[N], i, j, flag=0, count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]==1)flag=1;
    else if(a[i]==2||a[i]==3)flag=0;
    else if(a[i]%2==0)flag=1;
    else{
    for(j=3;j<=sqrt(a[i]);j++){
      if(a[i]%j==0){
	flag=1;
	break;
      }}}
    if(flag==0)count++;
    flag=0;
  }
  printf("%d\n",count);

  return 0;
}
  

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

int n;
int x[100001];
int v[100001];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> v[i];
    int count = 0;

	for(int i = 0; i < n ; i = i + 2){
		x[v[i]]++;
	}
	
	int Max_odd = 0;
	int Max_even = 0;
	int arg_Max_odd = 0;
	int arg_Max_even = 0;
	int Max2 = 0;

	for(int i = 1; i < 100001; ++i){
		Max_even = max(Max_even, x[i]);
		arg_Max_even = i;
	}

	for(int i = 1; i < 100001; ++i){
		if(x[i] == Max_even){
			arg_Max_even = i;
			break;
		}
	}

	x[arg_Max_even] = 0;

	for(int i = 1; i < 100001; ++i){
		Max2 = max(Max2, x[i]);
	}	

	int count_even =  (n / 2) - Max_even;
	int count_even2 =  (n / 2) - Max2;

	Max2 = 0;

	for(int i = 0; i < 100001; ++i){
		x[i] = 0;
	}

	for(int i = 1; i < n ; i = i + 2){
		x[v[i]]++;
	}

\

	for(int i = 1; i < 100001; ++i){
		Max_odd = max(Max_odd, x[i]);
	}

	for(int i = 1; i < 100001; ++i){
		if(x[i] == Max_odd){
			arg_Max_odd = i;
			break;
		}
	}


	x[arg_Max_odd] = 0;

	for(int i = 1; i < 100001; ++i){
		Max2 = max(Max2, x[i]);
	}	

	int count_odd = (n / 2) - Max_odd;
	int count_odd2 = (n / 2) - Max2;

	if(arg_Max_odd == arg_Max_even) count = min(count_even + count_odd2, count_even2 + count_odd);
	else count = count_even + count_odd;


	int one_kind = 0;
	for(int i = 0; i < n; ++i){
		if(v[i] != v[0]) break;
		if(i == n - 1) one_kind = 1;
	}
	if(one_kind == 1) count = n / 2;

	cout << count << endl;

}

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

A = list(map(int, input().split()))
B = list(map(int, input().split()))

#print(A)
#print(B)

x=y=0
for i in range(len(A)):
  a, b = A[i], B[i]

  if a<b: x+=(b-a)//2*2
  if a>b: y+=a-b

ans="Yes" if x >= y*2 else "No"
print(ans)

Measured memory_bytes: 4724
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

const int maxn = (int) 1e4 + 10;
int fact[maxn], ifact[maxn];

void precalc() {
  fact[0] = ifact[0] = 1;
  for (int i = 1; i < maxn; ++i) {
    fact[i] = mult(fact[i - 1], i);
    ifact[i] = mult(ifact[i - 1], myPower(i, mod - 2));
  }
}

int n, a, b, c;

int read() {
  if (scanf("%d%d%d%d", &n, &a, &b, &c) < 4) {
    return 0;
  }
  return 1;
}

void solve() {
  if (b & 1) {
    printf("0\n");
    return;
  }
  int b2 = b / 2;

  int res = 0;
  for (int x = 0; x <= a; ++x) {
    for (int y = 0;; ++y) {
      int left = c - (3 * y + a - x);
      if (left < 0) {
        break;
      }
      int cur = 1;
      cur = mult(cur, fact[a + y + b2]);
      cur = mult(cur, ifact[x]);
      cur = mult(cur, ifact[a - x]);
      cur = mult(cur, ifact[y]);
      cur = mult(cur, ifact[b2]);
      if (b2 == 0) {
        if (left != 0) {
          cur = 0;
        }
      } else {
        cur = mult(cur, fact[left + b2 - 1]);
        cur = mult(cur, ifact[b2 - 1]);
        cur = mult(cur, ifact[left]);
      }
      add(res, cur);
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

#define ll 					long long
#define db					double
#define ull 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define vi 					vector<int>
#define vl					vector<ll>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 1e9 + 5;
const ll infll = 1e18+5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

int a,b,c;
ll k;

int main() {
	gi(a); gi(b); gi(c); gi(k);
	if (k&1) printf ("%d\n", b-a);
	else printf ("%d\n", a-b);
	return 0;
}

Measured memory_bytes: 256
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
a = []
for i in range(n):
  a.append(list(map(int, input().split())))
count = 0

for i in range(n):
  s = c
  for j in range(m):
    s += a[i][j]*b[j]
  if s > 0:
    count += 1

print(count)

Measured memory_bytes: 3064