akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <vector>
#include <iostream>
#pragma warning(disable : 4996)
using namespace std;
int n, m, x;
int main() {
	scanf("%d%d", &n, &m);
	vector<vector<int> > f(m);
	vector<int> c(m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		f[x % m].push_back(x);
		c[x % m]++;
	}
	for (int i = 0; i < m; i++) {
		map<int, int> e;
		for (int j : f[i]) e[j]++;
		vector<int> g;
		for (pair<int, int> j : e) g.push_back(j.second);
		f[i] = g;
	}
	int ret = 0;
	for (int i = 0; i <= m / 2; i++) {
		int p = (m - i) % m;
		if (i == p) {
			f[i].clear(); ret += c[i] / 2; c[i] = 0;
		}
		else {
			if (c[i] < c[p]) {
				swap(c[i], c[p]);
				swap(f[i], f[p]);
			}
			f[p].clear(); ret += c[p];
			while (c[p]--) {
				bool flag = false;
				for (int j = 0; j < f[i].size() && !flag; j++) {
					if (f[i][j] % 2 == 1) {
						f[i][j]--;
						flag = true;
					}
				}
				if (!flag) {
					for (int j = 0; j < f[i].size(); j++) {
						if (f[i][j] != 0) {
							f[i][j]--; break;
						}
					}
				}
			}
			for (int j = 0; j < f[i].size(); j++) ret += f[i][j] / 2;
			c[p] = 0;
			f[i].clear(); c[i] = 0;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 6144
from collections import defaultdict
n = int(input())
s = input()
d = defaultdict(int)
for i in s:
    d[i] += 1

for i in range(1,n):
    s = input()
    di = defaultdict(int)
    for j in s:
        di[j] += 1
    for dik, div in di.items():
        d[dik] = min(d[dik],div)
    for dk,dv in d.items():
        d[dk] = min(dv,di[dk])

ans = []
for dk,dv in d.items():
    ans.append(dk*dv)

ans.sort()
print("".join(ans))


Measured memory_bytes: 3316
def main():
    n = int(input())
    c = 0
    
    if n % 2 == 1:
        print(0)
        return 
    
    i = 10
    x, _ = divmod(n, i)
    while x:
        c += x
        i *= 5
        x, _ = divmod(n, i)

    print(c)


if __name__ == '__main__':
    main()


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

int main(){
  int K;string S;cin>>K>>S;
  int l=S.size();
  string ans;
  if(l<=K) ans=S;
  else {
    ans=S.substr(0,K);
    ans = ans+"...";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
char s[N],t[N];
int q, tr1[N<<2], tr2[N<<2];
int add(int x, int y) {
	if (!x||!y) return x+y;
	return x==y?"AB"[x=='A']:0;
}
void build(int tr[], char s[], int o, int l, int r) {
	if (l==r) tr[o]=s[l];
	else { 
		build(tr,s,ls),build(tr,s,rs);
		tr[o] = add(tr[lc],tr[rc]);
	}
}
int qry(int tr[], int o, int l, int r, int ql, int qr) {
	if (ql<=l&&r<=qr) return tr[o];
	if (mid>=qr) return qry(tr,ls,ql,qr);
	if (mid<ql) return qry(tr,rs,ql,qr);
	return add(qry(tr,ls,ql,qr),qry(tr,rs,ql,qr));
}
int main() {
	scanf("%s%s%d",s+1,t+1,&q);
	int c1,c2;
	build(tr1,s,1,1,c1=strlen(s+1));
	build(tr2,t,1,1,c2=strlen(t+1));
	REP(i,1,q) {
		int l1,r1,l2,r2;
		scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
		puts(qry(tr1,1,1,c1,l1,r1)==qry(tr2,1,1,c2,l2,r2)?"YES":"NO");
	}
}








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

using namespace std;

int main()
{
    string a;
    cin >> a;
    int l=a.size(),i;
    for (i=0;i<(l+1)/2;i++)
        if (a[i]=='p'&&a[l-1-i]!='q'||a[i]=='q'&&a[l-1-i]!='p'||a[i]=='b'&&a[l-1-i]!='d'||a[i]=='d'&&a[l-1-i]!='b')
        {
            cout << "No";
            return 0;
        }
    cout << "Yes";
    return 0;
}

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

int main()
{
	long long int a, b, k = -1, temp1, temp2, min, max;
	scanf("%lld %lld", &a, &b);
	min = a;
	max = b;
	if (min > b)
	{
		min = b;
		max = a;
	}
	for (; min <= max; ++min)
	{
		temp1 = llabs(a-min);
		temp2 = llabs(b-min);
		if (temp1 == temp2)
		{
			k = min;
			break;
		}
	}
	if (k == -1)
	{
		printf("IMPOSSIBLE");
	} else {
		printf("%lld", k);
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class B {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        int X;
        Input(out X);
        int c500 = (X / 500) * 1000;
        X = X % 500;
        int c5 = (X / 5) * 5;
        Print(c500 + c5);
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void Inputs<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int n,ans=0;cin>>n;
    vector<int>v(n),c(n);
    rep(i,n){
        cin>>v[i];
    }
    rep(i,n){
        cin>>c[i];
    }

    rep(i,n){
        if(v[i]>=c[i]){
            ans+=v[i]-c[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
    if a in dic: dic[a] += 1
    else: dic[a] = 1

C = {0:0}

sum_ni = 0
for i in range(1, N+1):
    C[i] = i*(i-1)//2

D = {}
for k, v in dic.items():
    sum_ni += C[v]


for k, v in dic.items():
    D[k] = sum_ni - C[dic[k]] + C[dic[k]-1]

for i in range(N):
    print(D[A[i]])


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

int main()
{
    long long int n,m;
    cin>>n>>m;
    
    if(n>=m)
    {
        cout<<min(n%m,m-(n%m));
    }
    
    else
    {
        cout<<min(n,m-n);
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 200000
long long int a[40], sum1[41][MAX], sum2[41][MAX], w1[41], w2[41];
int w;
int Input(void);
long long int Inputll(void);
long long int Combi(int w, int k);
int Compare(const void *a, const void *b);
long long int Binary_search(long long int *sum, long long int x, long long int r);
int main(void)
{
  int n, k, m1, m2;
  long long int i, j, l, r, x, y, limit;
  n = Input(), k = Input(), l = Inputll(), r = Inputll();
  y = Inputll();
  if (y + k - 1 <= r) a[w++] = y;
  for (i = 1; i < n; i++) {
    x = Inputll();
    if (x != y) y = 0;
    if (x + k - 1 <= r) a[w++] = x;
  }
  if (x == y) {
    if (w >= k && (y = x * k) >= l && y <= r) printf("%lld\n", Combi(w, k));
    else printf("0\n");
    return 0;
  }
  m1 = w / 2, limit = 1 << m1;
  for (i = 0; i < limit; i++) {
    x = 0, n = 0, j = 0;
    while (1) {
      if (j == m1) {
        sum1[n][w1[n]++] = x;
        break;
      }
      if ((i >> j) & 1) {
        x += a[j];
        if (++n > k) break;
      }
      j++;
    }
  }
  m2 = w - m1, limit = 1 << m2;
  for (i = 0; i < limit; i++) {
    x = 0, n = 0, j = 0;
    while (1) {
      if (j == m2) {
        sum2[n][w2[n]++] = x;
        break;
      }
      if ((i >> j) & 1) {
        x += a[j+m1];
        if (++n > k) break;
      }
      j++;
    }
  }
  for (i = 0; i <= k; i++) qsort(sum2[i], w2[i], sizeof(long long int), Compare);
  limit = 0;
  for (i = 0; i <= k; i++) {
    int kk = k - i;
    for (j = 0; j < w1[i]; j++) {
      x = l - sum1[i][j], y = r - sum1[i][j];
      if (y < 0) continue;
      limit += Binary_search(sum2[kk], y + 1, w2[kk]);
      if (x > 0) limit -= Binary_search(sum2[kk], x, w2[kk]);
    }
  }
  printf("%lld\n", limit);
  return 0;
}
int Input(void)
{
  int n = 0, c;
  while ((c = getchar_unlocked()) >= '0' && c <= '9') n = 10 * n + c - '0';
  return n;
}
long long int Inputll(void)
{
  long long int n = 0;
  int c;
  while ((c = getchar_unlocked()) >= '0' && c <= '9') n = 10 * n + c - '0';
  return n;
}
long long int Combi(int w, int k)
{
  if (sum1[w][k]) return sum1[w][k];
  if (k == 0 || k == w) return 1;
  else if (k == 1) return w;
  else {
    if (k * 2 > w) k = w - k;
    return sum1[w][k] = Combi(w - 1, k) + Combi(w - 1, k - 1);
  }
}
int Compare(const void *a, const void *b)
{
  long long int *ta = (long long int*)a, *tb = (long long int*)b;
  if (*ta > *tb) return 1;
  else if (*ta < *tb) return -1;
  return 0;
}
long long int Binary_search(long long int *sum, long long int x, long long int r)
{
  int m, l = 0;
  while (l < r) {
    m = (l + r) / 2;
    if (sum[m] < x) l = m + 1;
    else r = m;
  }
  return l;
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll w,h,x,y;cin>>w>>h>>x>>y;

  cout<<double(w*h)/2.0<< ' ';

  if(w%2==0&&h%2==0&&w/2==x&&h/2==y){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }


  return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  for (int i = 0; i < 100; i++) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<math.h>
#include <cstdio>
#include<iomanip>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,m,n) for(int i=m;i<(int)(n);i++)
const int inf = 10e9 + 7;
using namespace std;
pair<int, int>p[100005];
int a[100005], b[100005];
signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, m)cin >> a[i] >> b[i];
	rep(i, m) {
		p[i].first = b[i];
		p[i].second = a[i];
	}
	sort(p, p + m);
	int ans = 0,s=0;
	rep(i, m) {
		if (s <= p[i].second) {
			ans++;
			s = p[i].first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
a = l()
A = 0
for i in range(N):
    A = A^a[i]
bit = bin(A)[2:]
n = len(bit)
bits = []
for i in range(N):
    bits.append(bin(a[i])[2:])
ans = []
maxlen = len(bin(max(a))[2:])
bit = list(bit.zfill(maxlen))[::-1]
for i in range(N):
    b = list(bits[i].zfill(maxlen))[::-1]
    num = 0
    for j in range(maxlen):
        if bit[j] != b[j]:
            num += 2**j
    ans.append(num)
print(*ans)

Measured memory_bytes: 45264
li = list(map(int, input().split()))
n = li[0]
m = li[1]
k = list(map(int, input().split()))

s = sum(k)
limit = s/(4*m)
a = 0
for i in k:
    if i >= limit:
        a += 1

if a >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


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

#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
ll n,W;
ll w[105];
ll v[105];
ll dp[105][100009];
ll knapsack(int items,int weight){
if(weight<=0||items<=0) return 0;
if(dp[items][weight]!=-1) return dp[items][weight];
ll value=0;
if(w[items]<=weight)
	value=v[items]+knapsack(items-1,weight-w[items]);
value=max(value,knapsack(items-1,weight));
return dp[items][weight]=value;}
int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	cin>>n>>W;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	ll ans=knapsack(n,W);
	cout<<ans;
	return 0;
}



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

using namespace std;

int main()
{
  int n;
  int AB[2001] = {0};
  for(int i = 0; i <= 1000; i++){
    for(int j = 0; j <= 1000; j++){
      AB[i+j]++;
    }
  }

  while(cin >> n){
    int ans = 0;
    for(int i = 0; i <= 2000; i++){
      if(n - i > 2000) continue;
      if(n - i >= 0) ans += AB[i]*AB[n-i];
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF = 1e18;
#define TENS(n) int(1e##n + n)

// dp[c1][c2][c3] : 寿司 i 個の皿が ci 個あるときの操作回数の期待値
double dp[301][301][301];
// = 1 + dp[c1-1][c2][c3] * c1/N
//     + dp[c1+1][c2-1][c3] * c2/N
//     + dp[c1][c2+1][c3-1] * c3/N
//     + dp[c1][c2][c3] * (N-(c1+c2+c3))/N
bool flag[301][301][301];

double rec(int N, int c1, int c2, int c3)
{
    if (flag[c1][c2][c3])
        return dp[c1][c2][c3];
    if (c1 + c2 + c3 == 0)
        return 0.0;

    flag[c1][c2][c3] = true;

    double prob_no_chosen = (double)(N - (c1 + c2 + c3)) / N;
    double coef = (1.0 - prob_no_chosen);
    double e = 1.0;

    if (c1 > 0)
        e += rec(N, c1 - 1, c2, c3) * (c1 / (double)N);
    if (c2 > 0)
        e += rec(N, c1 + 1, c2 - 1, c3) * (c2 / (double)N);
    if (c3 > 0)
        e += rec(N, c1, c2 + 1, c3 - 1) * (c3 / (double)N);

    dp[c1][c2][c3] = e / coef;

    return dp[c1][c2][c3];
}

void solve()
{
    int N;
    cin >> N;
    vector<double> a(N);
    int cnt[3] = {0, 0, 0};

    REP0(i, N)
    {
        int a;
        cin >> a;
        cnt[a - 1]++;
    }

    cout << rec(N, cnt[0], cnt[1], cnt[2]) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 240000
#include<bits/stdc++.h>
#define boost std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
using LL = long long;

constexpr int MAXN = 1e4 + 4;
constexpr LL M = 998244353;

template <typename T> inline void read(T &x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

LL n, m, a[MAXN], sum;

int main() {
    boost;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        cin >> a[i];
        sum += a[i];
    }
    cout << (sum <= n ? n - sum : -1) << endl;
    return 0;
}

Measured memory_bytes: 3688
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int a,b,k,i,j;
	cin>>a>>b>>k;
	for (i=0;i<k;i++)
	{
		if (i%2==0)
		{
			//a
			if (a%2) a--;
			j=a/2;
			a-=j;
			b+=j;
		} else {
			//b
			if (b%2) b--;
			j=b/2;
			b-=j;
			a+=j;
		}
		//printf("%d %d,%d,i%d\n",a,b,j,i);
	}
	printf("%d %d\n",a,b);
	return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tesnik      
**/
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int ans = 0;
  while (n > 0) {
    n /= k;
    ans++;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

// 素数判定 O(√N)
bool isPrime( ULL n )
{
	if ( n < 2 )
	{
		return false;
	}

	for ( ULL i = 2; i * i <= n; ++i )
	{
		if ( !( n % i ) )
		{
			return false;
		}
	}

	return true;
}

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

	for ( int k; cin >> k, k; )
	{
		int lb, ub;

		for ( lb = k; !isPrime( lb ); lb-- );
		for ( ub = k; !isPrime( ub ); ub++ );

		cout << ub - lb << endl;
	}

	return 0;
}

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

int main() {
  int A,B,C,D,op1, op2, op3, bit;
  vector<int>v={1,-1};
  vector<char>ans={'+','-'};
  A = getchar() - '0';
  B = getchar() - '0';
  C = getchar() - '0';
  D = getchar() - '0';
  
  for(bit=0; bit<(1<<3); bit++){
    op1=v[(bit>>2)&1];
    op2=v[(bit>>1)&1];
    op3=v[bit&1];
    if(A+B*op1+C*op2+D*op3==7){
      cout << A << ans[(bit>>2)&1] << B << ans[(bit>>1)&1] << C << ans[bit&1] << D << "=" << A+B*op1+C*op2+D*op3 << "\n";
      return 0;
    }
  }
  return 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll a,b; cin >> a >> b;
    vector<ll> lis;
    REP(i, 1, 1000){
        ll k = (i * (i+1)) / 2;
        lis.pb(k);
    }
    REP(i, 1, 999){
        if(lis[i] - a == lis[i+1] - b){
            cout << lis[i] - a << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3648
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int q;
    cin >> q;
    map<string, int> mp;
    while (q--) {
        int com, x; string key, l, r;
        cin >> com; 
        if (com == 0) {
            cin >> key >> x;
            mp[key] = x;
        } else if (com == 1) {
            cin >> key;
            cout << mp[key] << endl;
        } else if (com == 2) {
            cin >> key;
            mp.erase(key);
        } else {
            cin >> l >> r;
            auto litr = mp.lower_bound(l);
            auto ritr = mp.upper_bound(r);
            for (auto itr = litr; itr != ritr; ++itr) {
                if (itr->second == 0) continue;
                cout << itr->first << " " << itr->second << endl;
            }
        }
    }
}



Measured memory_bytes: 25960
#include<bits/stdc++.h>
using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main() {
    IOS;
    int n,i,j;
    cin>>n;
    int d1[n],d2[n];
    REP(i,0,n-1) cin>>d1[i]>>d2[i];
    REP(i,0,n-3){
    	int cnt=0;
    	REP(j,0,2){
    		if(d1[i+j]==d2[i+j]) cnt++; 
    	}
    	if(cnt==3){
    		cout<<"Yes";
    		return 0;
    	}
    }
    cout<<"No";
    return 0;   
} 

Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main()
{
    int n,t,m0,m,xp[10],yp[10],x[10],y[10],i,k,j,xp0,yp0,l,same,samen;
	
	while(0<=scanf("%d",&n)){
		
		if(n==0){
			break;
		}
		
		for(i=0;i<10;i++){
			xp[i]=0;
			yp[i]=0;
			x[i]=0;
			y[i]=0;
		}
		
		scanf("%d",&m0);
		for(i=0;i<m0;i++){
			scanf("%d%d",&xp[i],&yp[i]);
		}
		
		xp0=xp[0];
		yp0=yp[0];
		
		samen=0;
		
		for(i=0;i<m0;i++){
			
			xp[i]=xp[i]-xp0;
			yp[i]=yp[i]-yp0;
		}
			
			
		
		for(i=1;i<=n;i++){
			
			scanf("%d",&m);
			
			for(k=0;k<10;k++){
				x[k]=0;
				y[k]=0;
			}
			
			for(k=0;k<m;k++){
				scanf("%d%d",&x[k],&y[k]);
			}
			
			if(m!=m0){
				continue;
			}
			
			for(k=0;k<2;k++){
				xp0=x[0];
				yp0=y[0];
			
				for(j=0;j<m;j++){
					x[j]-=xp0;
					y[j]-=yp0;
				}
				for(l=0;l<4;l++){
					same=0;
					
					for(j=0;j<m;j++){
						if(x[j]==xp[j] && y[j]==yp[j]){
							++same;
						}
						if (same==m){
							printf("%d\n",i);
						}
					}
					
					for(j=0;j<10;j++){
						t=-y[j];
						y[j]=x[j];
						x[j]=t;
					}
					
				}
				
				for(l=0;l<=(m-1)/2;l++){
					j=x[l];
					x[l]=x[m-1-l];
					x[m-1-l]=j;
					j=y[l];
					y[l]=y[m-1-l];
					y[m-1-l]=j;
				}
			}
		}
		printf("+++++\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;

void main()
{
  int n = readln.chomp.to!int;
  int l = int.max;
  int r = int.min;
  foreach (v; readln.chomp.split.map!(to!int)) {
    l = min(l, v);
    r = max(r, v);
  }
  writeln = r - l;
}


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

int A,B,ax[100009],ay[100009];
int R;

vector<int>v[100009];

int main(){
  while(cin>>A>>B>>R){
    if(!A && !B)break;
    r(i,100009) v[i].clear();
    long long sum=0;
    R*=4;
    r(i,A)cin>>ax[i]>>ay[i];
    r(i,B){
      int x,y;
      cin>>x>>y;
      v[x].push_back(y);
    }
    r(i,100009) sort(v[i].begin(),v[i].end());
    r(ii,A){
      int x=ax[ii] , y=ay[ii];
      for(int i=-R;i<=R;i++){
	if(x+i<0)continue;
	double r = R*R - i*i;
	r = sqrt(r);
	int rr = r; 
	sum += upper_bound(v[x+i].begin(),v[x+i].end(),y+rr) - lower_bound(v[x+i].begin(),v[x+i].end(),y-rr);
	
      }
    }
    cout<<sum<<endl;
  }
}



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

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

	if (A<B){
		if (B<C){
			cout << "No" << endl;
		}else if(C<A){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}else{
		if (C<B || A<C){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}

	
	
	
	return 0;
}



Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

#input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
    n = int(input())
    k = list(map(int,input().split()))
    l = Counter(k)
    ans_ = sum([i*(i-1)//2 for i in l.values()])
    for i_n in range(n):
        d = k[i_n]
        print(ans_ - l[d]*(l[d]-1)//2 + (l[d]-1)*(l[d]-2)//2)

main()


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

int main() {
  char s;
  cin >> s;
  if (s == 'A') {
    cout << 'T';
  } 
  else if (s == 'T') {
    cout << 'A';
  }
  else if (s == 'C') {
   cout << 'G';
  }
  else cout << 'C';
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int H, W;
    int N;
    int sr, sc;
    string S, T;

    void input() {
        cin >> H >> W;
        cin >> N;
        cin >> sr >> sc;
        sr--, sc--;
        cin >> S >> T;
    }

    bool concheck(int h, int w) {
        return h >= 0 && h < H && w >= 0 && w < W;
    }

    bool up() {
        int h = sr;
        int w = sc;

        for (int i = 0; i < N; ++i) {
            if (S[i] == 'U') h--;

            if (!concheck(h, w)) return true;
            if (T[i] == 'D') h++;
            if (!concheck(h, w)) h--;
        }
        return false;
    }

    bool down() {
        int h = sr;
        int w = sc;

        for (int i = 0; i < N; ++i) {
            if (S[i] == 'D')h++;
            if (!concheck(h, w)) return true;
            if (T[i] == 'U') h--;
            if (!concheck(h, w)) h++;
        }
        return false;
    }

    bool right() {
        int h = sr;
        int w = sc;

        for (int i = 0; i < N; ++i) {
            if (S[i] == 'R') w++;
            if (!concheck(h, w)) return true;
            if (T[i] == 'L') w--;
            if (!concheck(h, w)) w++;
        }
        return false;
    }

    bool left() {
        int h = sr;
        int w = sc;

        for (int i = 0; i < N; ++i) {
            if (S[i] == 'L') w--;
            if (!concheck(h, w)) return true;
            if (T[i] == 'R') w++;
            if (!concheck(h, w)) w--;
        }
        return false;
    }

    void solve() {
        input();
        if (up()) {
            cout << "NO" << endl;
            return;
        }

        if (down()) {
            cout << "NO" << endl;
            return;
        }
        if (left()) {
            cout << "NO" << endl;
            return;
        }
        if (right()) {
            cout << "NO" << endl;
            return;
        }
        cout << "YES" << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    int a[N],b[N],c[N],d[N];
    P x[N],y[N];
    rep(i,0,N){
        cin>>a[i]>>b[i];
        x[i]=P(a[i],b[i]);
    }
    rep(i,0,N){
        cin>>c[i]>>d[i];
        y[i]=P(c[i],d[i]);
    }
    sort(x,x+N); sort(y,y+N);
    int ans=0;
    bool used[N];
    rep(i,0,N) used[i]=0;;
    rep(i,0,N){
        int maxy=-1;
        int temp=N;
        rep(j,0,N){
            if(!used[j]&&x[j].first<y[i].first&&x[j].second<y[i].second&&maxy<x[j].second){
                maxy=x[j].second;
                temp=j;
            }
        }
        if(temp<N){
            used[temp]=1;
            ans++;
        }
    }
    cout <<ans<<"\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct card{
  char mark;
  int value;
};

void BubbleSort(struct card c[], int N){
  for(int i = 0; i < N; i++){
    for(int j = N-1; j > i; j--){
      if(c[j].value < c[j-1].value){
	card tmp = c[j];
	c[j] = c[j-1];
	c[j-1] = tmp;
      }
    }
  }
}

void SelectionSort(struct card c[], int N){
  int minj;

  for(int i = 0; i < N; i++){
    minj = i;
    for(int j = i; j < N; j++){
      if(c[j].value < c[minj].value){
	minj = j;
      }
    }
    card tmp = c[i];
    c[i] = c[minj];
    c[minj] = tmp;
  }
}

void PrintCard(struct card c[], int N){
  for(int i = 0; i < N; i++){
    if(i > 0){ cout << " "; }
    cout << c[i].mark << c[i].value;
  }
  cout << endl;
}

bool isStable(struct card c1[], struct card c2[], int N){
  for(int i = 0; i < N; i++){
    if(c1[i].mark != c2[i].mark){ return false; }
  }
  return true;
}

int main(){
  int N;
  struct card c1[36], c2[36];
  
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> c1[i].mark >> c1[i].value;
    c2[i] = c1[i];
  }

  BubbleSort(c1, N);
  PrintCard(c1, N);
  cout << "Stable" << endl;

  SelectionSort(c2, N);
  PrintCard(c2, N);
  if(isStable(c1, c2, N)){ cout << "Stable" << endl; }
  else{ cout << "Not stable" << endl; } 
  
  return 0;
}



Measured memory_bytes: 3100
S = input()
n = [0]*(len(S)+1)

if S[0]=='<':
    n[0]==0
if S[-1]=='>':
    n[-1]==0
for i in range(1,len(S)):
    if S[i-1]=='<' and S[i]=='<':
        n[i] = n[i-1]+1
        n[i+1]=n[i]+1
    elif S[i-1]=='>' and S[i]=='<':
        n[i] = 0
        n[i+1]=1
        
for i in range(len(S)-1,-1,-1):
    if S[i]=='>':
        n[i]=max(n[i],n[i+1]+1)
        
print(sum(n))

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

using namespace std;

string arr[105] ;
int val[105] ;
int n ;

bool cmp(int &a , int &b)
{
    if(arr[a] != arr[b])
        return arr[a] < arr[b] ;
    return val[a] > val[b] ;
}

int main()
{
    cin>>n ;
    vector<int>v ;
    for(int i = 1 ; i <= n ; ++i)
    {
        cin>>arr[i]>>val[i] ;
        v.push_back(i) ;
    }
    sort(v.begin() , v.end() , cmp) ;
    for(auto &i : v)
        cout<<i<<"\n";
    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){

    int a, b;
    int result;
    
    scanf("%d %d", &a, &b);
    
    result=a*b;
    
    if(result%2==0)
    {
        printf("Even\n");        
    }
    else
    {
        printf("Odd\n");
    }
    

    
    return 0;
}


Measured memory_bytes: 128
def main():
    s = list(input())
    k = int(input())
    lst = []
    cnt = 1
    flg = 0
    ans = 0
    prev = s[0]
    for i in range(1, len(s)):
        if prev == s[i]:
            cnt += 1
        else:
            lst.append(cnt)
            cnt = 1
            prev = s[i]
            flg = 1
    lst.append(cnt)
    if len(lst) == 1:
        ans = len(s) * k // 2
    else:
        ans += sum(map(lambda x: x // 2, lst[1:len(lst)-1])) * k
        # for l in lst[1: len(lst) - 1]:
        #     ans += l // 2 * k
        if s[-1] == s[0]:
            ans += (lst[0] + lst[-1]) // 2 * (k - 1)
            ans += lst[0] // 2 + lst[-1] // 2
        else:
            ans += (lst[0] // 2 + lst[-1] // 2) * k
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
#include<iostream>
#include <complex>

using namespace std;
int main() {

        int i;
        int N,K;
        int AVE;
        int ANS;
        int MOD;
        int LAST;

        cin >> N >> K;

        AVE = N/K;
        MOD = N%K;

        if(N >= K){
                if(MOD != 0){
                        MOD=1;
                }
        LAST=AVE+MOD;
        ANS=abs(AVE-LAST);
        }else{
                ANS=1;
        }
        cout << ANS << endl;

return 0;


}

Measured memory_bytes: 256
#include <stdio.h>
	int main(){
		int n,a,b,c,i,kotae[100];
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&c);
			if((a*a)+(b*b)==(c*c)||(c*c)+(b*b)==(a*a)||(a*a)+(c*c)==(b*b)){
				printf("YES\n");
			}else{
				printf("NO\n");
			}
		}
	return 0;
}

Measured memory_bytes: 580
n = int(input())
kl = []
for i in range(n):
    a = int(input())
    kl.append(a)
from collections import defaultdict
dic = defaultdict(int)

for idx, i in enumerate(sorted(kl)):
    dic[i] = idx + 1
cl = [k for k in kl]

al = []
bl = []
for i, c in enumerate(cl):
    if i % 2 == 0:
        al.append(c)
    else:
        bl.append(c)


ans = 0
for b in bl:
    if dic[b] % 2 != 0:
        ans += 1

print(ans)

Measured memory_bytes: 64980
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <utility>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    int d,n,a;
    cin>>d>>n;
    if (d==0) a=1;
    if (d==0 && n==100)
    {
        cout<<"101\n";
        return 0;
    }
    if (d==1) a=100;
    if (d==1 && n==100)
    {
        cout<<"10100\n";
        return 0;
    }
    if (d==2) a=10000;
    if (d==2 && n==100)
    {
        cout<<"1010000\n";
        return 0;
    }
    cout<<a*n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	ll A, B, C;
	cin >> A >> B >> C;
	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
		cout << 0 << endl;
	}
	else{
		ll M = max(max(A, B), C);
		if (A == M){
			cout << B*C << endl;
		}
		else if (B == M){
			cout << A*C << endl;
		}
		else{
			cout << A*B << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int f=N/4;
		int s=0;
		int cul = 0;
		while(f>-1){
			cul = f*4+s*7;
			if(cul == N)break;
			if(cul > N) f--;
			else if(cul < N) s++;
		}
		System.out.println(cul==N?"Yes":"No");
	}
}


Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

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

      return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] a = sc.nextIntArray(n);
    int all = a[0];
    for (int i = 1; i < n; i++) all ^= a[i];
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < n; i++) {
      if (sb.length() > 0) sb.append(" ");
      sb.append(all ^ a[i]);
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 54800
import collections
def main():

    N = int(input())
    edge = [[] for _ in range(N)]
    ncol = 0
    start = None
    graph = collections.defaultdict(list)
    pair = collections.defaultdict(dict)
    for i in range(N-1):
        a, b = map(int, input().split())
        edge[a-1].append(i)
        edge[b-1].append(i)
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
        pair[a-1][b-1] = i
        pair[b-1][a-1] = i
        if len(graph[a-1]) > ncol:
            ncol = len(graph[a-1])
            start = a-1
        if len(graph[b-1]) > ncol:
            ncol = len(graph[b-1])
            start = b-1

    n = max(edge)
    cols = [0 for _ in range(N-1)]
    idx = 1
    for i in edge[start]:
        cols[i] = idx
        idx += 1
    visited = set([start])
    m = ncol
    cur = [[h, cols[pair[start][h]]] for h in graph[start]]

    while cur:
        temp = []
        for node, c in cur:
            idx = 1
            for h in graph[node]:
                if cols[pair[node][h]] == 0:
                    if idx == c:
                        idx += 1
                    cols[pair[node][h]] = idx
                    idx += 1
                    temp.append([h, cols[pair[node][h]]])
        cur = temp
    print(m)
    for i in range(N-1):
        print(cols[i])

if __name__ == '__main__':
    main()

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

using namespace std;

bool solve(string s1, string s2){
	if(s1.compare(s2)==0) return true;
	for(int i=0; i<s1.length(); i++){
		rotate(s1.begin(), s1.begin()+1, s1.end());
		if(s1.compare(s2)==0) return true;
	}
	return false;
}

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

	string s1, s2;
	cin >> s1 >> s2;
	if(solve(s1,s2)) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3656
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] Cnts = new int[N + 1];

        for (int i = 0; i < N; i++)
        {
            int a = cin.nextInt();
            Cnts[a]++;
        }

        for (int i = 0; i < N + 1; i++)
        {
            if (N % 2 == 0)
            {
                if (i % 2 == 0)
                {
                    if (Cnts[i] == 0) continue;
                }
                else
                {
                    if (Cnts[i] == 2) continue;
                }
            }
            else
            {
                if (i == 0)
                {
                    if (Cnts[i] == 1) continue;
                }
                else if (i % 2 == 0)
                {
                    if (Cnts[i] == 2) continue;
                }
                else
                {
                    if (Cnts[i] == 0) continue;
                }
            }
            Console.WriteLine(0);
            return;
        }

        Console.WriteLine(pow2(N / 2));
    }

    private int pow2(int n)
    {
        int ret = 1;
        int mod = 1000000007;

        for (int i = 0; i < n; i++)
        {
            ret *= 2;
            ret %= mod;
        }
        return ret;
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

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

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

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int main(){
	
	string ans="Yes";
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])ans="No";
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x, y;
  cin >> x >> y;
  bool ans = false;
  
  for(int i = 0; i <= x; i++){
    int j = x - i;
    if(y == 2 * i + 4 * j){
      ans = true;
      break;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3608