akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [int(i) for i in input().split()]
count = {i:0 for i in range(8)}
over = 0
for a in A:
    if a < 3200:
        count[a//400] = 1
    else:
        over += 1
hp = sum(count.values())
print(hp + int(hp == 0), hp + over)

Measured memory_bytes: 9176
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
//const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll modpow(ll a,ll n,ll mod){
	ll res=1;
	while(n){
		if(n&1)(res*=a)%=mod;
		(a*=a)%=mod;
		n>>=1;
	}
	return res;
}
int main(){
	ll n;
	cin>>n;
	string x;
	cin>>x;
	ll cnt=0;
	for(int i=0;i<n;i++){
		if(x[i]=='1')cnt++;
	}
	ll d=cnt;
	ll a=0,b=0;
	for(int i=0;i<n;i++){
            if(x[i]=='1')a+=modpow(2,n-i-1,d+1);
            a%=(d+1);
	}
	if(d-1>1){
		for(int i=0;i<n;i++){
            if(x[i]=='1')b+=modpow(2,n-i-1,d-1);
            b%=(d-1);
	   }
	}
	for(int i=0;i<n;i++){
		ll t;
		if(x[i]=='1')t=cnt-1;
		else t=cnt+1;
		if(t==0){
			cout<<0<<"\n";
			continue;
		}
		if(t==1){
			cout<<1<<"\n";
			continue;
		}
		ll tmp=0;
		if(t==d+1){
			  tmp=a;
			  tmp+=modpow(2,n-i-1,d+1);
			  tmp%=t;
		}else{
			tmp=b;
			tmp-=modpow(2,n-i-1,d-1);
            tmp+=d-1;
			tmp%=t;
		}
		ll ans=1;
		while(tmp){
			ans++;
			tmp%=__builtin_popcountll(tmp);
		}
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 3784
abc = list(map(int,input().split()))
abc.sort()
a = abc[0]
b = abc[1]
c = abc[2]
count = 0
x = c-b
a += x
b += x
count += x
if not (b-a) % 2 == 0:
    b += 1
    c += 1
    count += 1
x = (b-a)//2
a += (b-a)
count += x
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int N, K;
    string S;
    int sequence[100009];
    cin>>N>>K>>S;
    MEMSET(sequence, 0);
    int index=0;
    rep(i, N){
        char s = S[i];
        if(s == '0' && index%2 == 0)  index++;
        if(s == '1' && index%2 == 1)  index++;
        sequence[index]++;
    }
    //cout <<endl;
    if(index%2==1) index++;
    int range = index;
    //rep(i, range+1) //cout <<i <<" : " << sequence[i]<<endl;
    int count=0;
    int Maximum=0;
    int head_i = min(2*K, range);
    rep(i, head_i+1) count +=sequence[i];
    
    //cout <<head_i<<" ... "<<count<<endl;
    
    head_i=head_i+2;
    Maximum=max(Maximum, count);
    while(head_i<=range){
        count-=(sequence[head_i-2*K-2]+sequence[head_i-2*K-1]);
        count+=(sequence[head_i-1]+sequence[head_i]);
        Maximum=max(Maximum, count);
        
        //cout <<head_i<<" ... "<<count<<endl;
        
        head_i=head_i+2;
    }
    cout << Maximum <<endl;
    return 0;
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			int a = Integer.parseInt(br.readLine());
			int b = Integer.parseInt(br.readLine());

			System.out.println(6-a-b);
		}
	}
}

Measured memory_bytes: 25372
#include <stdio.h>

typedef long long int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[],long long int left, long long int right)
/* クイックソート
 * a     : ソートする配列
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 */
{
    if (left < right) {
        long long int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            i++; j--;
        }
        quicksort(a, left, i - 1);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
    }
}


int main(void){
    long long int n,i,l,sum,K;
 
    scanf("%lld",&n);
    scanf("%lld",&K);

   long long int h[n];

    for(i=0; i<n; i++){
        scanf("%lld",&h[i]);
    }

    quicksort(h,0,n-1);

    sum = 0;

    if(K<n){
        for(l=0; l<n-K; l++){
            sum = sum + h[l];
        }

        printf("%lld",sum);
    }

    else if(K>=n){
        printf("0");
    }
    return 0;

}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}
 
int main(void){
    int n, i, r=0, t=1;
    int arr[999];
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&arr[i]);
    qsort(arr, n, sizeof(*arr), desc);
    for(i=0;i<n;i++){
        r+=t*arr[i];
        t=-t;
    }
    printf("%d\n",r);
}

Measured memory_bytes: 128
from collections import deque, defaultdict
N, M = map(int, input().split())
adj = [[0]*(N+1) for _ in range(N+1)] #1idx
edges = [tuple(map(int, input().split())) for _ in range(M)]
bridges = []
for e in edges:
    x,y=e
    adj[x][y] = 1
    adj[y][x] = 1

for bridge in edges:
    bx, by = bridge
    adj[bx][by] = 0
    adj[by][bx] = 0
    seen = [0]*(N+1)
    def dfs(s):
        seen[s] = 1
        for nx in range(1, N+1):
            if adj[s][nx]:
                if seen[nx]:
                    continue
                dfs(nx)
    dfs(1)
    is_ok = 1
    for i in range(1, N+1):
        if not seen[i]:
            is_ok = 0
            break
    if not is_ok:
        bridges.append(bridge)
    adj[bx][by] = 1
    adj[by][bx] = 1

print(len(bridges))

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

int main() {
    int n, x, count=0; cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,n) {
       if(x>=a[i]) {
       count++;
       x-=a[i];
       }
    }
    if(count==n && x>0) count--;
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int nK;
	char chS[120];

	cin >> nK;
	cin >> chS;

	int nCounter = 0;
	for (int i =0; chS[i] != 0; i++)
	{
		nCounter++;
	}

	if (nK<nCounter)
	{
		for (int i = 0; i < nK; i++)
		{
			cout << chS[i];
		}
		cout << "..." << endl;
	}
	else
	{
		for (int i = 0; chS[i] != 0; i++)
		{
			cout << chS[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int n;
    cin>>n;
    
    double a[n],b[n],d[n];
    
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        d[i]=abs(b[i]-a[i]);
    }
    
    double c[4];
    for(int i=0;i<4;i++){
        c[i]=0;
    }

    for(int i=0;i<n;i++){
    c[0]+=d[i];
    c[1]+=d[i]*d[i];
    c[2]+=d[i]*d[i]*d[i];
    }
    c[1]=pow(c[1],0.5);
    c[2]=pow(c[2],0.3333333333333);
    
    for(int i=0;i<n;i++){
        c[3]=max(c[3],d[i]);
    }

    for(int i=0;i<4;i++){
    cout<<setprecision(10)<<c[i]<<endl;
    }
	return 0;
}


Measured memory_bytes: 3472
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fst first
#define sec second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);	
}
int main()
{
	fastio;
	//fopen();
	ll n;
	cin>>n;
	int k=floor(sqrt(n));
	cerr<<k;
	for(int j=k;j>0;j--)
	{
		if(n%j==0)
		{
			cout<<j-1+n/j-1;
			exit(0);
		}
	}

}


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

int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  set<int> st;
  multiset<int> mulst;

  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    st.insert(x);
    mulst.insert(x);
  }
  int kazu[st.size() + 1] = {100000};
  if (st.size() <= m) {
    ans = 0;
    cout << ans << endl;
    return 0;
  }
  auto itr = st.begin();
  for (int i = 0; i < st.size() + 1; i++) {

    kazu[i] = mulst.count(*itr);
    itr++;
  }

  // cout << endl;
  sort(kazu, kazu + st.size() + 1);

  for (int i = 1;; i++) {

    ans += kazu[i];
    if (st.size() - i <= m) {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 19712
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	String c = sc.next();
	for(int i = 0; i<s.length(); i++) {
	    String str = s.substring(i)+s.substring(0,i);
	    if(str.equals(c)) {
		System.out.println("Yes");
		return;
	    }
	}
	System.out.println("No");
    }
}

Measured memory_bytes: 21588
S = gets.chomp
answer = 0
if S == "SUN"
    answer = 7
elsif S == "MON"
    answer = 6
elsif S == "TUE"
    answer = 5
elsif S == "WED"
    answer = 4
elsif S == "THU"
    answer = 3
elsif S == "FRI"
    answer = 2
elsif S == "SAT"
    answer = 1
end
puts answer

Measured memory_bytes: 1788
# coding: utf-8
# Your code here!
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

n,a,b=map(int,input().split())

m=10**9+7
ans=1
t=2**100
for i in range(n//100):
    ans*=t
    ans%=m
ans*=2**(n-(n//100)*100)

m=10**9+7
temp_a=1

for i in range(a):
    temp_a*=(n-i)*mod_inv(i+1,m)
    temp_a%=m
temp_b=1
for i in range(b):
    temp_b*=(n-i)*mod_inv(i+1,m)
    temp_b%=m


print((ans-temp_a-temp_b+m*2)%m-1)

Measured memory_bytes: 42032
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  long long S,h,m,s;
  cin>>S;
  h=S/3600;
  m=(S%3600)/60;
  s=(S%3600)%60;
  cout<<h<<":"<<m<<":"<<s<<'\n';
  return(0);
}



Measured memory_bytes: 3224
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  --N;
  ll space = 2 * C - (D - C) * (N - 1) - 1;
  ll block = N * (D - C) + 1;
  ll L = A - D * N, R = A + D * N;
  bool res = false;
  if (L <= B && B <= R) {
    if (space > 0) {
      res = (B - L) % (block + space) < block;
    } else {
      res = true;
    }
  }
  cout << (res ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  for(int i = 1; i <= 9; ++i) {
    if(n % i == 0 && n / i <= 9) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 10000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

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

    if(s[2] != s[3] || s[4] != s[5])
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
# define INF 0x3f3f3f3f 
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}

// vl sum(500001);


void solve()
{
    ll n,k;
    cin>>n>>k;
    vl a(n);
    rep(i,n){
        cin>>a[i];
        if(i>=k){
            if(a[i] <= a[i-k]){
                cout<<"No"<<endl;
            }
            else{
                cout<<"Yes"<<endl;
            }
        }
    }

    
    

}

int main()
{

    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 16396
// AOJ 0579
#include<iostream>
using namespace std;

const int DMAX = 300, NMAX = 300;
const int INF = 1e4;
int d, n;
int T[DMAX], A[NMAX], B[NMAX], C[NMAX];
int black[NMAX], red[NMAX];
int dp[2][DMAX];

int diff(int x, int y) {
  return (x > y ? x - y:y - x);
}

int solve() {
  for (int day = 0; day < d; day++) {
    black[day] = INF, red[day] = -1;
  }

  for (int day = 0; day < d; day++) {
    for (int cloth = 0; cloth < n; cloth++) {
      if (A[cloth] <= T[day] and T[day] <= B[cloth]) {
        black[day] = min(black[day], C[cloth]);
        red[day] = max(red[day], C[cloth]);
      }
    }
  }

  for (int day = 1; day < d; day++) {
    dp[0][day] =  
      max(dp[0][day-1] + diff(red[day],red[day-1]), 
          dp[1][day-1] + diff(red[day],black[day-1]));
    dp[1][day] =  
      max(dp[0][day-1] + diff(black[day],red[day-1]), 
          dp[1][day-1] + diff(black[day],black[day-1]));
//    cout << dp[0][day] << " " << dp[1][day] << endl;
  }

  return max(dp[0][d-1], dp[1][d-1]);
}

int main() {
  cin >> d >> n;
  for (int i = 0; i < d; i++) {
    cin >> T[i];
  }
  
  for (int i = 0; i < n; i++) {
    cin >> A[i] >> B[i] >> C[i];
  }

  cout << solve() << endl;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
using pii = pair<int, int>;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

struct edge{
    int from,to,cost;
};
bool bellman_ford(const vector<edge>& g, vector<ll>& d, int s){
    const int n = d.size();
    d[s] = 0;
    rep(i, n) {
        bool update = false;
        for(auto& e : g){
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                update = true;
                if(i==n-1) return false;
            }
        }
        if(!update) break;
    }
    return true;
}

int main(){
    int n, m, r;
    cin >> n >> m >> r;

    vector<edge> g;
    rep(i, m){
        int s, t, d;
        cin >> s >> t >> d;
        g.push_back({s,t,d});
    }
    vector<ll> d(n, INF);
    bool y = bellman_ford(g, d, r);
    if (!y){
        cout << "NEGATIVE CYCLE" << nl;
        return 0;
    }
    rep(i, n) {
        if(d[i] == INF)
            cout << "INF" << nl;
        else
            cout<< d[i] << nl;
    }
}



Measured memory_bytes: 3228
def resolve():
    N,K=map(int,input().split())
    l=[]
    mx=10**9

    for i in range(N):
        l.append(int(input()))
    l.sort()
    for i in range(N-K+1):
        mx=min(mx,l[i+K-1]-l[i])
    print(mx)
resolve()

Measured memory_bytes: 50868
#include <iostream>
#include <vector>
#include <string>
#define N 100000

using namespace std;

int main(){
        int n;
        cin>>n;
        string line;
        cin.ignore();
        getline(cin,line);

        int sum[N] = { -1 };
        int write = 1;
        int before = line.c_str()[0] - '0';

        for(int i = 1;i < n;i++){
                if( before - (line.c_str()[2*i] - '0') == 0 ){
                        sum[ write++ ] = i - 1;
                }
                before = line.c_str()[2*i] - '0';
        }
        sum[ write++ ] = n-1;

        int max_size = 0;
        if(write <= 3){
                max_size = n;
        }else{
                for(int i = 3;i < write ;i++){
                        max_size = std::max( max_size, sum[i] - sum[i - 3]);
                }
        }
        cout<<max_size<<endl;
        return 0;
}

Measured memory_bytes: 3712
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int A, B;
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
ls = list(map(int, input().split()))
s = [i for i in range(1, n+1)]
lss = list(zip(ls, s))
ans = 0
for i in range(n):
    if lss[i][0] % 2 != 0 and lss[i][1] % 2 != 0:
        ans += 1
print(ans)


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

typedef long int32;
typedef unsigned long uint32;
typedef long long int64;
typedef unsigned long long uint64;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rFOR(i,a,b) for(int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x,n) FOR(i,0,n) cout << x[i] << " "; cout << endl

// Custom global variable 



// ----------------------
auto main() -> int
{
  #ifdef DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
  #endif
  // Fast I/O
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  // Code starts here ---


  string s;
  cin >> s;

  map<char, int> e;
  for(auto i:s) e[i]++;
  if(e.size() != 2) {
    cout << "No";
  } else {
    cout << "Yes";
  }


  // ---------------------
  #ifdef DEBUG
    cerr << endl << "Time:" << double(clock())/CLOCKS_PER_SEC << " secs" << endl;
  #endif
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	
	int n = sc.nextInt();
	double[] a= new double[n];
	double ave =0;
	
	for (int i=0; i<n; i++){
		a[i]=n*sc.nextInt();
		ave=ave+a[i]/n;
	}
	
	int ans = 0;
	double dist = 100000;
	
	for (int i=0; i<n; i++){
		double k =Math.abs(ave-a[i]);
		if(dist>k){
			dist=k;
			ans=i;
		}
		if(dist==k){
			if(ans>i){
				ans=i;
			}
		}
		
	}
	
	System.out.println(ans);
}
}


Measured memory_bytes: 22740
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    print(input()[:-len("FESTIVAL")])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import bisect
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    a = list(map(int, input().split()))
    a.sort()
    p = 0
    for i in range(n - 1):
        x = bisect.bisect(a, m - a[i], i + 2)
        if a[x - 1] + a[i] <= m:
            p = max(p, a[x - 1] + a[i])
            if p == m:
                break
    if p:
        print(p)
    else:
        print("NONE")


Measured memory_bytes: 5664
# dp[i] - True if first player has i stones and win

n, k = [int(x) for x in input().split()]

arr = [int(x) for x in input().split()]

dp = [False for _ in range(k+1)]

for i in range(k+1):
    for x in arr:
        if i-x >= 0 and not dp[i-x]:
            dp[i] = True

print("First" if dp[k] else "Second")


Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	if(s[1]=='R')
		s[1]='B';
	else
		s[1]='R';
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,k,l,m,n;
    cin>>n;
    long long a[n+10];
    long long b[n+10];
    for(i=0; i<=n; i++)
        cin>>a[i];
    for(i=0; i<n; i++)
        cin>>b[i];
    long long sum=0;
    for(i=0; i<=n-1; i++)
    {
        sum += (min(a[i],b[i]));
        b[i] -= min(a[i],b[i]);
        sum+= (min(a[i+1],b[i]));
        a[i+1] -= min(a[i+1],b[i]);
    }
    cout<<sum<<endl;
}


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

int main(){
  int n;
  string s, t;
  cin >> n >> s >> t;
  
  string ans = s;
  int start = 1000;
  for(int i = 0; i < n; i++){
    char x = s.at(i);
    if(x == t.at(0)){
      bool ok = true;
      int ti = 0;
      for(int j = i; j < n; j++){
        if(ti >= n) break;
        if(s.at(j) != t.at(ti)) ok = false;
        ti++;
      }
      if(ok){
        start = i;
        break;
      }
    }
  }
  
  for(int i = 0; i < n; i++){
    if(start < n) ans.at(start) = t.at(i);
    else ans.push_back(t.at(i));
    start++;
  }
  
  cout << ans.size() << endl;
}

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

const int INF = 1001001001;



int main(){
    int n;cin>>n;
    vector<ll>x(n);
    vector<ll>y(n);
    rep(i,n){
      cin>>x[i]>>y[i];
    }
     double sum=0;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        sum+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
      }
    }
    cout<<fixed<<setprecision(7);
    cout<<sum*2/n<<endl;
}



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


int main() {
  int N;
  cin >> N;
  int m = floor(sqrt((4*N+1)-1)/2);
  for(int n=1;n<=N;n++) {
    int cnt = 0;
    for(int x=1;x<=m;x++){
      for(int y=1;y<=x;y++){
        for(int z=1;z<=y;z++) {
          if(x*x+y*y+z*z+x*y+y*z+z*x==n) {
            if(x==y&&y==z) {
              cnt++;
            } else if(x!=y && y!=z && z!=x) {
              cnt +=6;
            } else {
              cnt += 3;
            }
          }
        }
      }
    }
    cout << cnt << endl;
  }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n,d;
  cin >> n >> d;
  vector<vector<int>> point(n,vector<int>(2));
  for(int i=0;i<n;i++){
    cin >> point.at(i).at(0) >> point.at(i).at(1);
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    if(pow(pow(point.at(i).at(0),2) + pow(point.at(i).at(1),2),0.5) <= d)ans++;
  }
  cout << ans << endl;
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define RREP(i, a, n) for(int i = (int)(n); i >= a; i--)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

ll N,X;
vector<ll> total(51);
vector<ll> p_total(51);

ll dfs( ll n, ll x )
{
    if( x >= total[n]-1 )
    {
        return p_total[n];
    }
    else if( x > total[n-1]+2 )
    {
        return dfs( n-1, x - total[n-1]-2 ) + p_total[n-1]+1;
    }
    else if( x - total[n-1] == 2 )
    {
        return p_total[n-1]+1;
    }
    else if( 1 < x ) return dfs(n-1, x-1);
    else return 0;
}

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

    total[0] = 1;
    p_total[0] = 1;

    REP(i, 1, 51)
    {
        chmax(total[i],total[i-1]*2+3);
        chmax(p_total[i],p_total[i-1]*2+1);
    }

    cout << dfs(N,X) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,c,d;
  cin >> n >> k;
  int a[n+1];
  for(int i=1;i<=n;i++) cin >> a[i]; 
  for(int i=k+1;i<=n;i++){
    if(a[i-k]<a[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}
      

Measured memory_bytes: 4404
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()

def calc_next(n):  # nの次のルンルン数を求める
	l = len(n)
	n = n[::-1]
	i = 0
	for i in range(l-1):
		if n[i] != 9 and abs(n[i+1]-(n[i]+1))<=1:  # 指定の桁を1増やしてもOK
			n[i] += 1
			break
	else:  # 最後を変更
		if n[-1] == 9:  # 次の桁へ
			n = list(map(int, list("1"+"0"*l)))
			return n
		else:  # 先頭 +1
			i = l-1
			n[-1] += 1
	for j in range(i-1, -1, -1):  # i 桁以下を減らす
		n[j] = max(0, n[j+1]-1)
	return n[::-1]

N = [1]
cnt = 1
while cnt != K:
	N = calc_next(N)
	cnt += 1
print("".join(list(map(str, N))))


Measured memory_bytes: 5652
#include <stdio.h>
#define LL long long
#define eps 1e-6
int main(){
	LL a,b,c;
	double d;
	scanf("%lld%lf",&a,&d);
	d+=eps;//此句很关键
	b=d*100;
	c=a*b/100;
	printf("%lld\n",c);
}


Measured memory_bytes: 1728
import sys
N,K=map(int, raw_input().split())
A=map(int, sys.stdin.readline().split())

dp=[ None for i in range(K+1) ]

for i in range( min(A) ):
	dp[i]="L"


for i,x in enumerate(dp):
	if x is None:
		for j in A:
		#	print "i,j,i-j,dp[i-j] :::: ",  i, j,i-j,dp[i-j]
			if 0<=i-j and dp[i-j]=="L":
				dp[i]="W"
				break
		else:
			dp[i]="L"


print "Second" if dp[K]=="L" else "First"
	

Measured memory_bytes: 33388
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i;
  bool flag=false;
  for(i=1;i<=50000;i++){
    int price=i*1.08;
    if(n==price){
      flag++;
      break;
    }
  }
  if(flag){
    cout << i;
  }
  else{
    cout << ":(";
  }
  return(0);
}

Measured memory_bytes: 256
h=0
w=0
n=0
while 1:
    h,w=map(int,input().split())
    if not h and not w:
      break
    h-=1
    w-=1
    obs=[[1]*(w+1) for i in range(h+1)]
    n=int(input())
    for i in range(n):
        x,y=map(int,input().split())
        obs[x-1][y-1]=0
    dp=[[0]*(w+2) for i in range(h+2)]
    dp[0][0]=obs[0][0]
    for i in range(h+1):
        for j in range(w+1):
            if obs[i][j]:
                dp[i+1][j]+=dp[i][j]
                dp[i][j+1]+=dp[i][j]
    if obs[h][w]:
        print(dp[h][w])
    else:
        print(0)


Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
 
using namespace std;
 
const int maxn = 1e5 + 5;
 
struct Node {
    int x, y, id;
}node[maxn];
 
struct Edge {
    int u, v, val;
    bool operator <(const Edge& rhs) const {
        return val < rhs.val;
    }
}e[maxn << 1];
 
int par[maxn];
int n;
 
bool cmp1(const Node &a, const Node &b) {
    return a.x < b.x;
}
 
bool cmp2(const Node &a, const Node &b) {
    return a.y < b.y;
}
 
void init() {
    for (int i = 0; i <= n; i ++)
        par[i] = i;
}
 
int findpar(int x) {
    return par[x] = (par[x] == x ? x : findpar(par[x]));
}
 
void unite(int x, int y) {
    x = findpar(x), y = findpar(y);
    if (x == y) return;
    par[x] = y;
}
 
int main(int argc, char const *argv[]) {
    
    cin >> n;
 
    init();
 
    for (int i = 1; i <= n; i ++) {
        scanf("%d%d", &node[i].x, &node[i].y);
        node[i].id = i;
    }
 
    sort(node + 1, node + n + 1, cmp1);
 
    int cnt = 0;
    for (int i = 2; i <= n; i ++)
        e[cnt ++] = (Edge){node[i - 1].id, node[i].id, node[i].x - node[i - 1].x};
    
    sort(node + 1, node + n + 1, cmp2);
    for (int i = 2; i <= n; i ++)
        e[cnt ++] = (Edge){node[i - 1].id, node[i].id, node[i].y - node[i - 1].y};
 
    sort(e, e + cnt);
 
    long long ans = 0;
    for (int i = 0; i < cnt; i ++) {
        int u = e[i].u, v = e[i].v, val = e[i].val;
        if (findpar(u) == findpar(v)) continue;
        unite(u, v);
        ans += val;
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <set>
#include <cmath>

namespace CSV{
	class CistreamCsv { // http://homepage2.nifty.com/well/Stream.html CSV Stream
		// }js[^ endl Ìè`
		friend CistreamCsv& CSV::endl(CistreamCsv& riscsv);
	private:
		std::istream& m_ris;     // üÍÉg¤ istream ÌQÆ
	public:
		CistreamCsv(std::istream& ris) : m_ris(ris) {}
		CistreamCsv& operator >>(int& ri) {
			ri = 0;
			int iChar = 0;
			// óðÇÝòÎ·B
			while (isspace(iChar = m_ris.get()) && iChar != '\n') {}
			if (iChar == EOF ) { return *this; }
			std::string strValue;
			if (iChar == '\n') { m_ris.putback(iChar); iChar = 0; }
			else               { strValue += iChar;               }
			// R}ÜÅÇÞB
			while ((iChar = m_ris.get()) != ',' && iChar != EOF && iChar != '\n') {
				strValue += iChar;
			}
			ri = std::atoi(strValue.c_str());
			if (iChar == EOF ) { return *this;         }
			if (iChar == '\n') { m_ris.putback(iChar); }
			return *this;
		}
		// }js[^ðó¯üêé½ßÌ}üZq
		CistreamCsv& operator >>(CistreamCsv& (*pmanipulatorfunction)(CistreamCsv&)) {
			return (*pmanipulatorfunction)(*this);
		}
	};
	CistreamCsv& endl(CistreamCsv& riscsv) {
        int iChar = 0;
        while ((iChar = riscsv.m_ris.get()) != '\n' && iChar != EOF) {}        // sÜÅÇÝòÎ·B
        return riscsv;
    }
};
int main(int,char**){
	int w,n;
	std::cin >> w >> n;
	CSV::CistreamCsv CSVin(std::cin);
	CSVin>> CSV::endl;

	std::vector<int> dl;
	dl.reserve(w);
	for(int i(0);i<w;++i) dl.push_back(i);
	while(n--){
		int s1,s2;
		CSVin>> s1>>s2>>CSV::endl;
		//std::cout << s1<<s2<<std::endl;
		std::swap(dl[s1-1],dl[s2-1]);
	}
	for(int i(0);i<w;++i) std::cout << dl[i]+1<<std::endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int digit = log10(N)+1;
  int ans = 0;
  if (digit == 1) {
    ans = N;
  }
  if (digit == 2) {
    ans = 9;
  }
  if (digit == 3) {
    ans = 9 + (N-99);
  }
  if (digit == 4) {
    ans = 909;
  }
  if (digit == 5) {
    ans = 909 + (N-9999);
  }
  if (digit == 6) {
    ans = 90909;
  }
  cout << ans << endl;
}

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

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

int N, A;
vi X;

void init(){
    cin >> N >> A;
    X = vi( N );
    for( int i = 0; i < N; ++i )
        cin >> X[ i ];
}

void solve(){
    vvvl dp( N + 1, vvl( N + 1, vl( N * A + 1 ) ) ); // considered first i, taken j, sum k
    dp[ 0 ][ 0 ][ 0 ] = 1;
    for( int i = 0; i < N; ++i )
        for( int j = 0; j <= i; ++j )
            for( int k = 0; k <= N * A; ++k ){
                dp[ i + 1 ][ j ][ k ] += dp[ i ][ j ][ k ];
                if( k + X[ i ] <= N * A )
                    dp[ i + 1 ][ j + 1 ][ k + X[ i ] ] += dp[ i ][ j ][ k ];
            }
    ll ans = 0;
    for( int i = 1; i <= N; ++i )
        ans += dp[ N ][ i ][ i * A ];
    cout << ans << endl;
}

signed main(){
    ios::sync_with_stdio( false );
    init();
    solve();
    return 0;
}


Measured memory_bytes: 52224
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int line[2],cercle[3],j=0;
    for(int i=0;i<5;i++){
        if(i<2){
            cin >> line[i];
        }
        else{
            cin >> cercle[j];
            j++;
        }
    }
    
    //x方向の判定
    if(cercle[0]-cercle[2]<0||cercle[0]+cercle[2]>line[0]||
    cercle[1]-cercle[2]<0||cercle[1]+cercle[2]>line[1]){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    
    
}



Measured memory_bytes: 3120
N=int(input())
A=list(map(int, input().split()))
A.sort()
P=sum([1 for a in A if a >= 0])
Q=N-P
if P==0:
  P=1
  Q=N-1
elif Q==0:
  P=N-1
  Q=1
ans=[]
for y in range(Q, N-1):
  ans.append((A[0], A[y]))
  A[0]=A[0]-A[y]

for y in range(Q):
  ans.append((A[N-1],A[y]))
  A[N-1]=A[N-1]-A[y]

print(A[N-1])
for x in ans:
  print(*x)

Measured memory_bytes: 19420
#!/usr/bin/env python3
# sys.stdin.readline()
import numpy as np
import sys
input = sys.stdin.readline
import math

n=int(input())
a = [0]
a += (list(map(int,input().split())))
a += [0]
b = np.array([ abs(a[i] - a[i+1]) for i in range(n+1)])
c = sum(b)
d = np.array([ abs(a[i] - a[i+2]) for i in range(n)])
e = np.array([])
e = [(c - b[j] - b[j+1] + d[j]) for j in range(n) ]
for i in range(n):
    print(e[i])

Measured memory_bytes: 23420
#include <stdio.h>
int main(void)
{
        int i,N,K,P;

        scanf("%d",&N);

        int a[N];

        for(i=0; i<N; i++){
                scanf("%d %d",&K,&P);
                a[i]=K%P;
                if(K%P==0)
                        a[i]=P;
        }

        for(i=0; i<N; i++)
                printf("%d\n",a[i]);

        return 0;
}

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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   n = n % 1000;
   if(n)
      n = 1000 - n;
   cout << n;
   return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main (void) {
    int N;

    cin >> N;
    ll X[N];
    ll Y[N];
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        Y[i] = X[i];
    }

    sort(Y, Y + N);
    for (int i = 0; i < N; i++) {
        if (X[i] <= Y[(N - 1) / 2]) {
            cout << Y[(N - 1) / 2 + 1] << endl;
        } else {
            cout << Y[(N - 1) / 2] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5248
<?php
	fscanf(STDIN, "%d", $N);
	$input = explode(' ', trim(fgets(STDIN)));
    
	$count = 0;
	for ($i = $N-1; $i > 0; $i--) {
      $diff = $input[$i] - $input[$i-1];
      if ($diff > 0) {
        $count = 0;
      } else {
        $count += abs($diff);
      }
      
      if ($count >=2) {
        echo ('No');
        return;
      }
    }
	echo ('Yes');
?>

Measured memory_bytes: 22076
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

template<class T>
void sort(T& arr) {
  std::sort(arr.begin(), arr.end());
}
template<class T, class By>
void sort_by(T& arr, By by) {
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
}

template<class T>
void reverse(T& arr) {
  std::reverse(arr.begin(), arr.end());
}

class Random {
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
};
// }}}

// main {{{
void solve();
int main() {
  solve();
}
// }}}

void solve() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(Q);
  rep(i, Q) {
    cin >> A[i];
  }
  vector<int> S(N);
  rep(i, Q) {
    S[A[i] - 1]++;
    debugn(S);
  }
  rep(i, N) {
    if(Q - S[i] < K) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 1408
#include <stdio.h>
int main(void){
    int i,o;
    char map[8][10];
    for(i=0;i<8;i++)
        fgets(map[i],10,stdin);
    puts("90");
    for(i=0;i<8;i++){
        for(o=7;o>=0;o--)
            printf("%c",map[o][i]);
        puts("");
    }
    puts("180");
    for(i=7;i>=0;i--){
        for(o=7;o>=0;o--)
            printf("%c",map[i][o]);
        puts("");
    }
    puts("270");
    for(i=7;i>=0;i--){
        for(o=0;o<8;o++)
            printf("%c",map[o][i]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
using namespace std;
int main (void) {
    string s;

    cin >> s;

    int ai;
    int zi;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A') {
            ai = i;
            break;
        }
    }
    for (int i = s.length() - 1; i >= 0; i--) {
        if (s[i] == 'Z') {
            zi = i;
            break;
        }
    }

    cout << zi - ai + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int N;
int array[32];

void solve(int n, int s, int *array, int d)
{
    int i;

    while (n > 0){
        array[d] = n;
        if (s + n == N){
            for (i = 0; i <= d; i++){
                printf("%d%c", array[i], "\n "[i < d]);
            }
        }
        if (s + n < N){
            solve(n, s + n, array, d + 1);
        }
        n--;
    }
}

int main(void)
{
    while (scanf("%d", &N), N != 0){
        solve(N, 0, array, 0);
    }

    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
const int N= 2e5;
int A[N],n,x,y,z,mx=INT_MAX;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",A+i);
        if(A[i]<=mx){
            mx=A[i];
            y++;
        }
    }
    printf("%d\n",y);
    return 0;
}


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

int main(int argc, char const *argv[]) {
  string n;
  cin >> n;
  if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
# ABC053D - Card Eater (ARC068D)
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    ans = len(set(A))  # kind of distinct numbers
    # consume one if the sum of duplicates are odd
    ans -= (N - ans) % 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14524
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#include <queue>
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define endl "\n"
#define int long long
using namespace std;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl


#define MAX 55

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

    int n;
    int num;
    int s1 = 0, s2 = 0;
    priority_queue<pair<int,int>> a, b;
    static int ans[MAX][MAX];

    cin>>n;

    for(int i = 0, sum = 0; i <= n; i++){
        cin>>num;
        s1 += num;
        for(int j = 0; j < num; j++){
           
            a.push(make_pair(i,sum++));
            
        }
    }

    for(int j = 0, sum = 0; j <= n; j++){
        cin>>num;
        s2 += num;
        for(int k = 0; k < num; k++){
           
            b.push(make_pair(j,sum++));
            
        }
    }

    if(s1 =! s2 || s1 != n){
        cout<<"NO"<<endl;
        return 0;
    }
    while(!a.empty()){
        pair<int,int> A = a.top(); a.pop();
        vector<pair<int,int>> temp;
        
        if(A.first == 0) break;
        
        for(int i = 0; i < A.first; i++){

            if(b.size() == 0){
                cout<<"NO"<<endl;
                return 0;
            }
            pair<int,int> B = b.top(); b.pop();
            
            if(B.first == 0){
                cout<<"NO"<<endl;
                return 0;
            }
            
            if(B.first-1 > 0)temp.push_back(make_pair(B.first-1,B.second));
           
            ans[B.second][A.second]++;
        }

        for(int j = 0; j < temp.size(); j++){
            b.push(temp[j]);
        }
    }

    cout<<"YES"<<endl;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(j) cout<<" ";
            cout<<ans[i][j];
        }
        cout<<endl;
    }
    
    return 0;
}




Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int p[30],q[30][30],ans=0;
vector<int> v;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=0;i<b;i++)
	{
		cin>>p[i];
	}
	for(int i=0;i<a;i++)
	{
		int s=c;
		for(int j=0;j<b;j++)
		{
			cin>>q[i][j];
			s+=p[j]*q[i][j];
		}
		if(s>0)
		ans++;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    N, M = MI()
    if N > 1:
        n = combinations_count(N, 2)
    else:
        n = 0
    if M > 1:
        m = combinations_count(M, 2)
    else:
        m = 0
    print(n+m)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3824