akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,d[100][3],s=1e9,i,j;
  char c;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    d[i][0]=d[i][1]=d[i][2]=m;
    for(j=0;j<m;j++){
      scanf(" %c",&c);
      if(c=='W')d[i][0]--;
      if(c=='B')d[i][1]--;
      if(c=='R')d[i][2]--;
    }
  }
  for(i=1;i<n;i++){
    for(j=0;j<3;j++)d[i][j]+=d[i-1][j];
  }
  //for(i=0;i<n;i++)printf("%d %d %d\n",d[i][0],d[i][1],d[i][2]);
  for(i=0;i<n;i++){
    for(j=i+1;j+1<n;j++)s=MIN(s,d[i][0]+d[j][1]-d[i][1]+d[n-1][2]-d[j][2]);
  }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 596
#include <iostream>

int main()
{
    int n;
    std::string s;

    std::cin >> n;
    std::cin >> s;

    bool judge;
    judge = false;

    if (n%2 == 0) {
        int mid = n/2;
        std::string t = s.substr(mid);
        if (s == (t+t)) {
            judge = true;
        }
    }

    std::cout << (judge ? "Yes" : "No") << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
int main()
{
    ll a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a-c<0) {c-=a;a=0;b=max(b-c,0ll);}
    else a-=c;
    printf("%lld %lld\n",a,b);
}


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

int main() {
    int n, ans = 1, a, b, temp;
    cin >> n;
    vector<pair<int, int>> robot;
    rep(i, n) {
        cin >> a >> b;
        robot.push_back(make_pair(a + b, a - b));
    }
    sort(robot.begin(), robot.end());
    temp = robot.at(0).first;
    rep(i, n) {
        if(robot.at(i).second >= temp) {
            temp = robot.at(i).first;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
    public static boolean debug = true;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();

        if(a <10){
            System.out.println(a);
        }else if(a<100){
            System.out.println(9);
        }else if(a<1000){
            System.out.println(9 + a-100+1);
        }else if(a<10000){
            System.out.println(9 + 900);
        }else if(a<100000){
            System.out.println(909 + a-10000+1);
        }else if(a==100000){
            System.out.println(9 + 900 + 90000);
        }



    }
}

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

int main() {
  int n;
  cin >> n;
  int a[110];
  
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int alice = 0;
  int bob = 0;
  sort(a, a+n, greater<int>());
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      alice += a[i];
    } else {
      bob += a[i];
    }
  }

  cout << alice - bob << endl;
  return 0;
}

Measured memory_bytes: 256
# ikatakosさんの提出を見てlru_cacheなるものを知った。
# まだまだ知らないことがたくさんありますね。

from functools import lru_cache

N = int(input())
A = [int(i) for i in input().split()]

@lru_cache(maxsize=None)
def rec(l, r, xl, xr) :
    if l + 1 == r :
        return 0
    
    return min(rec(l, m, xl, xl+xr)+rec(m, r, xl+xr, xr)+A[m]*(xl+xr) for m in range(l+1, r))
    
print(A[0] + rec(0, N-1, 1, 1) + A[N-1])

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

int n;
vector<int> a;
int x[15][15];
int y[15][15];

bool judge(int bit) {
  for (int i = 0; i < n; i++) {
    if (!(bit & (1 << i))) {
      continue;
    }

    for (int j = 0; j < a[i]; j++) {
      if (y[i][j] == 1 && !(bit & (1 << x[i][j]))) {
        return false;
      }

      if (y[i][j] == 0 && (bit & (1 << x[i][j]))) {
        return false;
      }
    }
  }
  return true;
}

int main() {
  cin >> n;
  a.resize(n);

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

    for (int j = 0; j < a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    if (judge(bit)) {
      int count = 0;
      for (int i = 0; i < n; i++) {
        if (bit & (1 << i)) {
          count++;
        }
      }
      ans = max(ans, count);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n;
    cin >> n;
    int a[n];
    map<ll,ll> M;
    rep(i,n)cin >> a[i];
    ll ans=0;
    rep(i,n){
        ans+=M[i-a[i]];
        M[a[i]+i]++;
    }
    cout << ans;


}

/*
j-i=h[i]+h[j]
j-h[j]=h[i]+i


 */



Measured memory_bytes: 27104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int m = 0;
		int f = 0;
		int r = 0;
		while (m != -1 || f != -1 || r != -1) {
			m = scanner.nextInt();
			f = scanner.nextInt();
			r = scanner.nextInt();
			if (m == -1 && f == -1 && r == -1) {
				break;
			} else if (m == -1 || f == -1) {
				System.out.println("F");
			} else if (m + f >= 80) {
				System.out.println("A");
			} else if (m + f >= 65) {
				System.out.println("B");
			} else if (m + f >= 50) {
				System.out.println("C");
			} else if (m + f >= 30) {
				if (r >= 50) {
					System.out.println("C");
				} else {
					System.out.println("D");
				}
			} else {
				System.out.println("F");
			}

		}
	}
}


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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

// ベクトル要素の列挙
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

// エラトステネスの篩による素数配列の出力
vector<int> Eratosthenes(int N){
  vector<int> p = {2};
  int sqrtN = sqrt(N);
  for(int i = 3; i <= N; i++){
    p.push_back(i);
    for (int j = 0; p.at(j) <= sqrtN; j++) {
      if(i%p.at(j) == 0) {
        p.pop_back();
        break;
      }
    }
  }
  return p;
}

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K < A) {
    cout << K << endl;
    return 0;
  } else {
    K -= A;
  }
  if (K < B) {
    cout << A << endl;
    return 0;
  } else {
    K -= B;
  }
  cout << A-K << endl;
  return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
//const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;


      cin>>n;

      ll ara[n+2],dp[n+2];

      dp[0]=dp[1]=0;

      ara[0]=0;

      for(i=1; i<=n; i++)
      {
          cin>>ara[i];

          if(i==2)
          {
              dp[i]=abs(ara[i]-ara[i-1]);
          }

          else if(i>2)
          {
        dp[i]=min(dp[i-1]+abs(ara[i-1]-ara[i]),dp[i-2]+abs(ara[i]-ara[i-2]));
          }
      }

      cout<<dp[n]<<endl;



}



Measured memory_bytes: 5152
//median time 26mins
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i <=(n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    ll cd = 1;
    repi(i, A, 2)
    {
        if (A % i == 0 && B % i == 0)
        {
            cd = i;
        }
    }
    cout << (C % cd == 0 ? "YES" : "NO") << endl;
    return 0;
}

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

int main()
{
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
     for (int i = 0; i < N; ++i)
    {
        cin >> T[i];
    }
    sort(T.begin(), T.end());
    int ans = 1;
    int earliest = T[0];
    int count = 1;
     for (int i = 1; i < N; ++i)
    {
        if(T[i] - earliest > K || count >= C){
            earliest = T[i];
            count = 1;
            ++ans;
            continue;
        }
        ++count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    while(y > 0) {
        int tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

int main() {
    int k;
    cin >> k;
    int ans = 0;
    rep(a, 1, k + 1) {
        rep(b, 1, k + 1) {
            rep(c, 1, k + 1) {
                int g = gcd(a, b);
                g = gcd(g, c);
                ans += g;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<string> fd(H);
    for (auto& i : fd) cin >> i;

    vec objx(N+1), objy(N+1);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (fd[i][j] == 'S') objx[0] = i, objy[0] = j;
            else if ('0' <= fd[i][j] && fd[i][j] <= '9') {
                int num = fd[i][j] - '0';
                objx[num] = i;
                objy[num] = j;
            }
        }
    }

    int ans = 0;

    for (int i = 0; i < N; i++) {
        queue<P> que;
        que.push(P(objx[i], objy[i]));

        int INF = 1<<28;
        int dx[] = {0,1,-1,0};
        int dy[] = {1,0,0,-1};
        mat dp(H, vec(W, INF));
        dp[objx[i]][objy[i]] = 0;
        while (que.size()) {
            P p = que.front(); que.pop();
            int x = p.first;
            int y = p.second;

            for (int j = 0; j < 4; j++) {
                int nx = x + dx[j];
                int ny = y + dy[j];

                if (0 <= nx && nx < H && 0 <= ny && ny < W && fd[nx][ny] != 'X') {
                    if (dp[nx][ny] > dp[x][y] + 1) {
                        dp[nx][ny] = dp[x][y] + 1;
                        que.push(P(nx,ny));
                    }
                }
            }
        }

        ans += dp[objx[i+1]][objy[i+1]];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7788
def LCS(s,t,restore=False):
    dp = [[0 for j in range(len(t)+1)] for i in range(len(s)+1)]
    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j]+1
            else:
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
    if restore:
        lcs = []
        stack = [(len(s),len(t))]
        while stack:
            x,y = stack.pop()
            if dp[x][y] == 0:
                break
            if x-1 >= 0 and dp[x][y] == dp[x-1][y]:
                stack.append((x-1,y))
            elif y-1 >= 0 and dp[x][y] == dp[x][y-1]:
                stack.append((x,y-1))
            else:
                lcs.append(s[x-1])
                stack.append((x-1,y-1))
        lcs = ''.join(lcs)[::-1]
        return dp[-1][-1],lcs
    return dp[-1][-1]
  
S = input()
T = input()

print(LCS(S,T,True)[1])

Measured memory_bytes: 120284
N=int(input())
listA=list(map(int,input().split()))
listB=list(map(int,input().split()))
listC=list(map(int,input().split()))
sumB=int(sum(listB))
for i in range(1,N):
    if listA[i] == listA[i-1]+1:
        sumB=sumB+int(listC[listA[i-1]-1])
print(sumB)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 1e6+5;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    char c;
    cin>>c;
    if(c>='A'&&c<='Z')
        cout<<"A"<<endl;
    else if(c>='a'&&c<='z')
        cout<<"a"<<endl;
    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (int)l; i <= (int)r; ++i)

using namespace std;
typedef long long ll;
const int Nmax = 3011;
const ll inf = 1e18;

int n, a[Nmax];
ll f[Nmax][Nmax][2];

ll dp(int l, int r, int t) {
    if (l > r) return 0;
    if (f[l][r][t] != -1) return f[l][r][t];
    ll res = -inf;
    if (t == 0) {
        res = max(dp(l + 1, r, 1 - t) + a[l], dp(l, r - 1, 1 - t) + a[r]);
    }
    if (t == 1) {
        res = min(dp(l + 1, r, 1 - t) - a[l], dp(l, r - 1, 1 - t) - a[r]);
    }
    return f[l][r][t] = res;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    FOR(i, 1, n) {
        cin >> a[i];
    }
    memset(f, -1, sizeof(f));
    cout << dp(1, n, 0);
}


Measured memory_bytes: 142208
/*
Stay innocent, be naive. 
But still dream big. 
Dream big to the point that it is beyond your ability and endeavour to achieve it. 
So dream big and don’t lose your innocence.
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long K = Long.parseLong(st.nextToken());
         long max = Math.max(N+K, N-K);
         max = Math.max(max, N*K);
         System.out.println(max);
      }
   }

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int stadt[n][n];
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n; ++j ){
			stadt[i][j] = 0;
		}
	}
	for( int i = 0; i < m; ++i ){
		int a, b;
		cin >> a >> b;
		--a; --b;
		++stadt[a][b];
		++stadt[b][a];
	}
	for( int i = 0; i < n; ++i ){
		int sum = 0;
		for( int j = 0; j < n; ++j ){
			sum += stadt[i][j];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x;
char c;
inline int read()
{
	x=0; c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return x;
}
int main()
{
	long n = read(), ans = n;
	for (int i = 1; i < n; ++i)
	{
        int u = read(), v = read();
		if (u > v) { u ^= v; v ^= u; u ^= v; }
        ans += i * (n - i + 1) - u * (n - v + 1);
	}
	printf("%ld", ans);
  
    return 0;
}


Measured memory_bytes: 3688
import std.stdio, std.algorithm, std.conv, std.string, std.array, std.math, std.range, std.container.dlist;

enum long MOD = 1000000007;

N modinv(N)(N x, N m) {
  assert(m != 0);
  
  N y = m, u = 1, v = 0;
  while (y) {
    const t = x / y;
    x -= t*y; swap(x, y);
    u -= t*v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

immutable facts = {
  long[1000000] result;
  result[0] = 1;
  foreach (i; 1..result.length) result[i] = result[i-1]*i % MOD;
  return result;
}();
immutable facts_inv = {
  long[1000000] result;
  result[$-1] = facts[$-1].modinv(MOD);
  foreach_reverse (i; 0..result.length-1) result[i] = result[i+1]*((i+1)%MOD) % MOD;
  return result;
}();

N nCr(N)(N n, N r) {
  if (n < r || r < 0) return 0;
  return (facts[n] * facts_inv[r] % MOD) * facts_inv[n-r] % MOD;
}

void main() {
  long X, Y;
  readf(" %d %d ", &X, &Y);
  
  const move_count = (X+Y)/3;
  if (move_count*3 != X+Y) {
    0.writeln;
    return;
  }
  
  nCr(move_count, X-move_count).writeln;
}

Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 1e5+7;
ll s[MX];
ll t[MX];
int A,B,Q;

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> A >> B >> Q;
    s[0] = -LINF;
    s[A+1] = LINF;
    t[0] = -LINF;
    t[B+1] = LINF;
    FOR(i,1,A) {
        cin >> s[i];
    }
    FOR(i,1,B) {
        cin >> t[i];
    }
    A += 2;
    B += 2;
    while(Q--) {
        ll x; cin >> x;
        ll su, sd, tu, td;
        ll ans = LINF;
        su = *lower_bound(s, s+A, x)-x;
        sd = x - *(upper_bound(s, s+A, x)-1);
        tu = *lower_bound(t, t+B, x)-x; 
        td = x - *(upper_bound(t, t+B, x)-1);
        chmin(ans, max(su, tu));
        chmin(ans, max(sd, td));
        chmin(ans, min(su,td)+su+td);
        chmin(ans, min(sd, tu)+sd+tu);
        cout << ans  << endl;
    }
    return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
   int a,b;
   cin>>a>>b;
   
   if((a-(2*b))<0)
   cout<<"0"<<endl;
   else
   cout<<a-(2*b)<<endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a;
  cin>>a;
  int i,j,b=0;
  for(i=1;i<=a;i++)
  {
     int l=i;int k=0;
     while(l!=0)
     {
       j=l%10;
       k++;
       l=l/10;
     }
    if(k%2!=0)
      b++;
  }
  cout<<b;
  return 0;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
vector<ll> calc(ll x){
  vector<ll> v;
  for (int l=0;l<100;l++){
    ll c=x%2;
    v.push_back(c);
    x/=2;
  }
  return v;
}
 
 
vector<ll> counter(vector<ll> x){
  ll N=x.size();
  ll cnt[100];
  for (int l=0;l<100;l++){
    cnt[l]=0;
  }
 
  for(ll i=0;i<N;i++){
    vector<ll> v=calc(x[i]);
    for(ll l=0;l<100;l++){
      cnt[l]+=v[l];
    }
  }
 
  vector<ll> ans;
  for(int l=0;l<100;l++){
    ans.push_back(cnt[l]);
  }
  return ans;
}
 
 
int main(){
  ll N,K;cin>>N>>K;
  vector<ll> x;
  for(ll i=0;i<N;i++){
    ll a;cin>>a;
    x.push_back(a);
  }
 
  vector<ll> count=counter(x);
  vector<ll> bin_K=calc(K);
 
  ll X=0;
  int flag=0;
 
  for(int l=99;l>=0;l--){
    int X_l=0;
    if((flag==0)&&(bin_K[l]==0)){
      X+=0;
    }
    else{
      if((N%2==0) and(count[l]==N/2)){
        X+=0;
      }
      else if(count[l]<=N/2){
        X+=pow(2,l);
        X_l=1;
      }
      else{
        X+=0;
      }
    }
 
    if (X_l!=bin_K[l]){
      flag=1;
    }
  }
  ll ans=0;
  for (ll i=0;i<N;i++){
    ans+=X^x[i];
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 1908
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

string s;

int main() {
	int i;
	
	cin >> s;
	int n = s.length();
	
	string prev = "";
	string now = "";
	int ans = 0;
	rep(i, n) {
		now += s[i];
		if (prev != now) {
			prev = now;
			now = "";
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  
  int N;
  cin >> N;
  
  vector<int> V(N);
  for(auto& v : V)
  {
    cin >> v;
  }
  
  vector<int> dp(N, INT_MAX);
  
  dp[0] = 0;
  dp[1] = abs(V[1] - V[0]);
  
  for(int i = 2; i < N; ++i)
  {
    for(auto& j : {i - 1, i - 2})
    {
      dp[i] = min(dp[i], dp[j] + abs(V[i] - V[j]));
    }
  }
  
  cout << dp[N - 1] << "\n";
  
  return 0;
}


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

int main()
{   
    int N; cin >> N;
    long A[200005], B[200005];
    REP(i, N) cin >> A[i] >> B[i];
    sort(A, A+N);
    sort(B, B+N);
    if(N%2==0){
        long temp = B[N/2-1]+B[N/2]-A[N/2-1]-A[N/2];
        cout << temp+1l << endl;
    }else{
        long temp = B[(N-1)/2]-A[(N-1)/2];
        cout << temp+1l << endl;
    }


    return 0;
}






Measured memory_bytes: 6708
#include <cstdio>
main(){
	int a[4],b[4],ar,br;
	scanf("%d%d%d%d",a,a+1,a+2,a+3);
	scanf("%d%d%d%d",b,b+1,b+2,b+3);
	ar=*a+a[1]+a[2]+a[3],br=*b+b[1]+b[2]+b[3];
	printf("%d\n",ar>br?ar:br);
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    double r;
    cin >> r;
    double pi = atan(1) * 4;
    cerr << pi << endl;
    cout << setprecision(10) << 2 * pi * r << endl;
    return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;


int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i,a+1){
	rep(j,b+1){
	  rep(k,c+1){
		if(i*500+j*100+k*50 == x){
		  ans++;
		  //cout << i << " " << j << " " << k << endl; 
		}
	  }
	}
  }

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


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

struct Hen {
	int x;
	int y;
	int id;
};

int main() {
	int n = ri();
	int m = ri();
	std::pair<int, int> all[n];
	for (int i = 0; i < n; i++) all[i].first = ri(), all[i].second = i;
	std::sort(all, all + n);
	
	std::vector<Hen> hen[n];
	for (int i = 0; i < m; i++) {
		int x = ri() - 1;
		int y = ri() - 1;
		hen[x].push_back({x, y, i});
		hen[y].push_back({y, x, i});
	}
	std::vector<int> cost(m, -1);
	std::vector<int> color(n, -1);
	bool ava[n];
	memset(ava, 0, sizeof(ava));
	int start = 0;
	for (int i = 0; i < n; i++) {
		if (i + 1 < n && all[i].first == all[i + 1].first) continue;
		// [start, i]
		std::set<int> newed;
		for (int j = start; j <= i; j++) ava[all[j].second] = true, newed.insert(all[j].second);
		for (int j = start; j <= i; j++) {
			int next = -1;
			int id = -1;
			for (auto k : hen[all[j].second]) {
				if (ava[k.y]) {
					next = k.y;
					id = k.id;
					break;
				}
			}
			// std::cerr << all[j].second << "->" << next << std::endl;
			if (color[all[j].second] != -1) continue;
			if (next == -1) {
				puts("-1");
				return 0;
			}
			if (cost[id] == -1) {
				cost[id] = all[i].first;
				if (color[next] == -1) color[next] = 0;
				color[all[j].second] = !color[next];
			} else assert(0);
		}
		
		start = i + 1;
	}
	for (auto &i : cost) if (i == -1) i = 1000000000;
	for (int i = 0; i < n; i++) {
		std::cout << (color[i] ? "B" : "W");
	}
	std::cout << std::endl;
	for (int i = 0; i < m; i++) std::cout << cost[i] << std::endl;
	
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int r = 0, w = 0, ans = 0;
  vector<char> c(n);
  rep(i,n) {
    cin >> c[i];
    if (c[i] == 'R') r++;
    else w++;
  }

  rep(i,r) if (c[i] == 'W') ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int s[50]={},w,n,a,b,i;
    cin >> w;
    for(i=1;i<=w;i++){
        s[i] = i;
    }
    cin >> n;
    for(i=1;i<=n;i++){
        scanf("%d,%d",&a,&b);
        swap(s[a],s[b]);
    }
    for(int i=1;i<=w;i++){
        cout << s[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int a,b;
  cin>>a>>b;
  int s=0;
  if(a>=b){
  	s=s+a;
  	a--;
  	if(a>=b){
  		s=s+a;
  		a--;
	}
	else if(b>=a){
		s=s+b;
		b--;
	}
	
  }
  
  else if(b>=a){
  	s=s+b;
  	b--;
  	if(b>=a){
  		s=s+b;
  		b--;
	}
	else if(a>=b){
		s=s+a;
		a--;
	}
  }
  
  cout<<s<<endl;

  return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {
    vector<pair<ll,ll>>T;
    SS(ll,N);
    rep(i,N){
        SS(ll,x,l);
        T.emplace_back(make_pair(x-l,x+l));
    }
    sort(all(T),cmp);
    ll max_x=-MOD;
    ll ans=0;
    rep(i,T.size()){
        if(max_x>T[i].first)ans++;
        else max_x=T[i].second;
    }
    p(N-ans);
}

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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<int> X(N);

    int sum = 0;

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

        sum += X[i];
    }
    int min = (sum / N) * N;
    int max = (sum / N + 1) * N;

    int P;

    if(sum - min <= max - sum){
        P = min / N;
    }else{
        P = max / N; 
    }
    int ans = 0;

    for(int i = 0; i < N; i ++){
        ans += (X[i] - P) * (X[i] - P);   
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

int a,b,c,d,sum=0;
cin >> a >> b;
while(b--)
{
    cin >> c;
    sum+=c;




}
if(a-sum>=0)
    cout << a-sum << endl;
else
    cout << -1 << endl;

}



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

#define INF 100100100
#define MOD 1000000007

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

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

   ll N,H;
   cin>>N>>H;
   vector<ll>A(N),B(N);
   for(int i=0;i<N;i++)cin>>A[i]>>B[i];

   sort(A.begin(),A.end());
   sort(B.begin(),B.end());

   ll ans = 0;
   for(int i=N-1;i>=0;i--){
      if(B[i]>=A[N-1]){
         ans++;
         H -= B[i];
      }
      if(H<=0) break;
   }
   if(H>0)ans += (H+A[N-1]-1)/A[N-1];
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
       	int n,k;cin>>n>>k;
       	int ans=n;
       	map<int,int> m;
       	while(k--){
       		int d;cin>>d;
       		while(d--){
       			int x;cin>>x;
       			m[x]=1;
       		}
       	}
       	cout<<ans-m.size();
    }   
    timecalculater();
    return 0;   
} 	

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int calc_ans(int i, vec &dp, map<int, set<int>> &m){
    if(dp[i] < INF) return dp[i];
    int p = m[i].size(), k = 0;
    vec tmp(p);
    for(int v: m[i]){
        tmp[k] = calc_ans(v, dp, m);
        k++;
    }
    SORT(tmp);
    int M = 0;
    REP(k, tmp.size()){
        M = max(M, tmp[k] + p);
        p--;
    }
    dp[i] = M;
    return dp[i];
}

signed main(){

    int N; cin >> N;
    vec a(N - 1); readvec(a);
    map<int, set<int>> m;
    REP(i, N - 1) m[a[i] - 1].insert(i + 1);

    vec dp(N, INF);
    cout << calc_ans(0, dp, m);
    //REP(i, N) cout << i + 1 << ", " << dp[i] << endl;

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 31488
#include <stdio.h>
using namespace std;
typedef long long ll;

int main(void) {
  int i, j, k, min = 10, a, ans = 0;
  for(i = 0; i < 5; ++i) {
    scanf("%lld", &a);
    ans += (a + 9) / 10 * 10;
    if(a % 10 && min > a % 10) min = a % 10;
  }
  printf("%lld", ans - 10 + min);
  return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split(' ');
            int N = int.Parse(ss[0]);
            int M = int.Parse(ss[1]);
            int L, R, LL = 1, RR = N;
            for (int i = 0; i < M; i++)
            {
                ss = Console.ReadLine().Split(' ');
                L = int.Parse(ss[0]);
                R = int.Parse(ss[1]);
                if (LL > R || RR < L)
                {
                    Console.WriteLine("0");
                    return;
                }
                if (LL < L)
                {
                    LL = L;
                }
                if (RR > R)
                {
                    RR = R;
                }
            }
            Console.WriteLine(RR-LL+1);
        }
    }
}


Measured memory_bytes: 15296
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>

typedef long long int64;

int main(void) {
  int64 n, k;
  std::cin >> n >> k;
  std::vector<int64> hs;
  for (int i = 0; i < n; i++) {
    int64 h;
    std::cin >> h;
    hs.push_back(h);
  }
  std::sort(hs.begin(), hs.end(), std::less<int64>());
  int64 sum = 0;
  for (int i = 0; i < n - k; i++) {
    sum += hs.at(i);
  }

  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

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

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

vector<int> make_tree(int n) {
    return vector<int>(n, 0);
}

void add(vector<int>& tree, int i, int x) {
    while(i < tree.size()) {
        tree[i] += x;
        i = (i | (i + 1));
    }
}

int getsum(vector<int>& tree, int i) {
    int sum = 0;
    while(i >= 0) {
        sum += tree[i];
        i = (i & (i + 1)) - 1;
    }
    return sum;
}

bool cmpranges(pair<int,int>& a, pair<int,int> b) {
    return a.second < b.second || (a.second == b.second && a.first < b.first);
}

bool cmpqueries(pair<pair<int,int>, int>& a, pair<pair<int,int>, int>& b) {
    return a.first.second < b.first.second || (a.first.second == b.first.second && a.second < b.second);
}

int main() {
    int n, m, q;
    scanf("%d%d%d", &n, &m, &q);
    vector< pair<int, int> > ranges(m);
    for(int i = 0; i < m; i++) scanf("%d%d", &ranges[i].first, &ranges[i].second);
    vector< pair<pair<int,int>, int> > queries(q);
    for(int i = 0; i < q; i++) {
        scanf("%d%d", &queries[i].first.first, &queries[i].first.second);
        queries[i].second = i;
    }

    sort(ranges.begin(), ranges.end(), cmpranges);

    sort(queries.begin(), queries.end(), cmpqueries);

    vector<int> responses(q, 0);
    vector<int> tree(505, 0);

    for(int j = 0, i = 0; j < queries.size(); j++) {
        while(i < ranges.size() && ranges[i].second <= queries[j].first.second) {
            add(tree, ranges[i].first, 1);
            i++;
        }
        responses[queries[j].second] = i - getsum(tree, queries[j].first.first - 1);
    }
    
    for(int i = 0; i < responses.size(); i++) {
        printf("%d\n", responses[i]);
    }
}



Measured memory_bytes: 4096
#include<cstdio>
#define maxn 100005
typedef long long ll;
int a[maxn];
int main(){
	int n,k;
	int count = 0;
	scanf("%d%d",&n,&k);
	for(int i = 0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>=k){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    LL n,p;
    Problem(LL n):n(n){};

    void solve(){
        vector<int> c(2);
        cin >> p;
        for(int i=0; i<n; ++i){
            int tmp;
            cin >> tmp;
            c[tmp%2]++;
        }
        if(p==1){
            if(c[1]==0)cout << 0 << "\n";
            else cout << (1ll<<(c[0]+c[1]))/2<<"\n";
        }else{
            if(c[1] == 0)cout << (1ll<<(c[0]+c[1])) <<"\n";
            else cout << (1ll<<(c[0]+c[1]))/2 <<"\n";
        }
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n,i,a[1099];
	int max=0;
	int min=10000000000;
	scanf("%d",&n);
	
	for(i=0;i<n; i++)
	{scanf("%d",&a[i]);
		if(a[i]>max) max=a[i];
		if(a[i]<min) min=a[i];
	}
	
	
	printf("%d",max-min);
	
	return 0;}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
	int n, max=0, s[100] = {},sum=0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sum += s[i];
		if (s[i] > max) { max = s[i]; }
	}
	cout << sum - (max / 2);
	return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc  =new Scanner(System.in);
		int N = sc.nextInt();
		Map<Integer,Integer> map = new HashMap<>();
		for(int i = 0;i < N;i++) {
			int num = sc.nextInt();
			if(map.containsKey(num)) {
				map.put(num, map.get(num)+1);
			}else {
				map.put(num, 1);
			}
		}
		sc.close();
		String s = "";
		if(map.size()==1 && map.containsKey(0)) {
			s = "Yes";
		}else if(map.size()==2
				&& map.containsKey(0)
				&& map.get(0)==N/3) {
			s = "Yes";
		}else if(map.size()==3){
			boolean flag = true;
			Object[] key = map.keySet().toArray();
			int k1 = (int)key[0];
			int k2 = (int)key[1];
			int k3 = (int)key[2];
			if((k1^k2^k3) != 0) {
				flag = false;
			}
			for(Map.Entry<Integer, Integer> e : map.entrySet()) {
				if(e.getValue() != N/3) {
					flag = false;
				}
			}
			s = flag ? "Yes" : "No";
		}else {
			s = "No";
		}
		System.out.println(s);
	}
}

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

using namespace std;

int main()
{
    string str = "ABCDEF";
    string x, y;
    cin >> x >> y;

    int xIndex = str.find_first_of(x);
    int yIndex = str.find_first_of(y);

    string result;
    if (xIndex > yIndex)
    {
        result = ">";
    }
    else if (yIndex > xIndex)
    {
        result = "<";
    }
    else
    {
        result = "=";
    }
    
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 998244353
N, K = map(int, readline().split())
data = []
for _ in range(K):
    L,R = map(int, readline().split())
    data.append((L,R))
    
A = [0]*(N+1)
A[1] = 1
S = [0]*(N+1)
S[1] = 1

for i in range(2,N+1):
    for k in range(K):
        L,R = data[k]
        A[i] += (S[max(0,i-L)]- S[max(0,i-R-1)]) % MOD
        A[i] %= MOD
    S[i] = (S[i-1] + A[i]) % MOD

print(A[N])

Measured memory_bytes: 76868
import bisect, collections

n = int(input())
num = collections.deque([])
for i in range(n):
    a = int(input())
    temp = bisect.bisect_left(num, a)
    if temp == 0:
        num.appendleft(a)
    else:
        num[temp - 1] = a
print(len(num))

Measured memory_bytes: 76996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> v(9);
  rep(i,n) {
    v[min(8, (a[i] / 400))]++;
  }
  int mn = 0;
  int yet = 0;
  int sw = v[8];
  rep(i,8) {
    if (v[i]) mn++;
    else yet++;
  }
  if (mn && !sw) {
    cout << mn << " " << mn << endl;
  } else if (!mn && !sw) {
    cout << 0 << " " << 0 << endl;
  } else if (mn && sw) {
    cout << mn << " " << mn + sw << endl;
  } else {
    cout << 1 << " " << sw << endl;
  }
}

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

Measured memory_bytes: 3612
#include<iostream>
#include<queue>
using namespace std;
typedef pair<int,int> pii;

int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    priority_queue<pii> pq;
    for(int i = 0; i <= k; i++)   pq.push({a[i], -i});
    int ret[n-k], rind = 0, next = k+1, now = 0;
    while(true){
        pii p = pq.top();   pq.pop();
        if(now > -p.second) continue;
        ret[rind++] = p.first;
        now = -p.second;
        if(rind == n-k) break;
        pq.push({a[next], -next});
        next++;
    }
    for(int i = 0; i < n-k; i++)    cout << ret[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 5716
#include<stdio.h>

int main(void)
{
	int H,W,i,a;
	while(1)
	{
	scanf("%d %d",&H,&W);
		if(H==0 && W==0)break;
	for(a=1;a<=H;a++){
	for(i=1;i<=W;i++)
		{printf("#");}
		printf("\n");}
		printf("\n");
	}
return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
    int X;
    int num, tmp;
    num = 0;
    cin >> X;
    for (int i = 1; i <= X; i++){
        tmp = 0;
        for(int j = 2; j < 10; j++){
            if (int(pow(i, j)) <= X){
                tmp = max(tmp, int(pow(i, j)));
            }
        }
        num = max(num, tmp);
    }

    cout << num << endl;

	return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

ll fact[maxn];
ll C(ll n, ll k) {
	return mul(fact[n], inv(mul(fact[n - k], fact[k])));
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("output.txt", "w", stdout);
	mod = 998244353;
	fact[0] = 1;
	for (ll i = 1; i < maxn; i++) fact[i] = mul(fact[i - 1], i);

	ll n, m, k; cin >> n >> m >> k;
	ll ans = 0;

	for (ll i = 0; i <= min(k, n - 1); i++) {
		ans += mul(C(n - 1, i), poww(m - 1, n - 1 - i));
		ans %= mod;
	}

	cout << mul(ans, m) << endl;

	return 0;
}

/*

*/


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  string s;
  cin>>s;
  int N=s.size();
  for(int i=N-1;i>=2;i--){
    if(i%2)continue;
    bool ok=true;
    for(int j=0;j<i/2;j++){
      if(s[j]!=s[i/2+j])ok=false;
    }
    if(ok){
      cout<<i<<endl;
      return 0;
    }
  }

  return 0;
}


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

#define LL long long
#define MAXN 10000

int main(){
	std::vector<int> v(1000,0);
	for(int i=0;i<3;i++){
		int temp;
		cin>>temp;
		v[temp+200]++;
	}
	for(int i=0;i<1000;i++){
		if(v[i]==1){
			cout<<i-200;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys

input=sys.stdin.readline

N=int(input())
p=[]
for i in range(N):
    p.append(tuple(map(int,input().split())))

p.sort()

rmin=[0]*N
rmin[0]=p[0][1]
for i in range(1,N):
    rmin[i]=min(rmin[i-1],p[i][1])

kukan=[(0,0)]*N
kukan[-1]=p[-1]
for i in range(N-2,-1,-1):
    l1,r1=p[i]
    l2,r2=kukan[i+1]
    kukan[i]=(max(l1,l2),min(r1,r2))

l1,r1=p[0]
l2,r2=kukan[1]
ans=max(0,r1-l1+1)+max(0,r2-l2+1)

for i in range(1,N-1):
    l1,r1=p[i]
    l2,r2=kukan[i+1]
    R=rmin[i-1]
    test1=max(0,r1-l1+1)+max(0,min(r2,R)-l2+1)
    test2=max(0,r2-l2+1)+max(0,min(r1,R)-l1+1)
    ans=max(ans,test1,test2)

print(ans)

Measured memory_bytes: 60892
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll f(ll b,ll n){
  if(b<=1) return -1;
  ll res = 0;
  while(n>0){
    res += n%b;
    n /= b;
  }
  return res;
}
int main() {
  ll n,s;
  cin >> n >> s;
  if(n<s){
    cout << -1 << endl;
    return 0;
  }
  if(n==s){
    cout << n+1 << endl;
    return 0;
  }
  ll nr = 1;
  for(ll b=2;b*b<=n;++b){
    if(f(b,n)==s){
      cout << b << endl;
      return 0;
    }
    nr=b;
  }
  for(ll p=nr;p>0;--p){
    if(p>s) continue;
    ll b = (n-(s-p))/p;
    if(f(b,n)==s){
      cout << b << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3648