akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(void)
{
    int N; cin >> N;
    float x;
    string u;
    float sum = 0;

    for (int i = 0; i < N; ++i)
    {
        cin >> x >> u;
        if (u == "JPY")
            sum += x;
        else
            sum += 380000.0*x;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

int main() {
	std::string s; std::cin >> s;
	intt N = s.size();
	intt count = 0;
	intt num = 0;
	for (int i = 0; i < N; ++i) {
		if (s[i] == 'W') {
			count += num;
		}
		else
			++num;
	}
	std::cout << count << std::endl;

}

Measured memory_bytes: 3744
#include <iostream>
#include <cmath>
#include <fstream>

#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

using namespace std;

int px[90001], py[90001];
int d[90001];

int main(){
    int H, W, D, A;
    cin >> H >> W >> D;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A;
            px[A] = i, py[A] = j;
        }
    }
    for (int i = D + 1; i <= H * W; i++) {
        d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
    }
    int Q, L, R;
    cin >> Q;
    while (Q--) {
        cin >> L >> R;
        printf("%d\n", d[R] - d[L]);
    }
}

Measured memory_bytes: 2176
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int a = 0 , b = 0 , c = 0 , q;
		for(int i = 0 ; i < n ; i++){
			q = Integer.parseInt(sc.next()) % 4;
			if(q == 0) c++;
			else if(q == 2) b++;
			else a++;
		}
		sc.close();
		String s = "Yes";
		if(b != 0) a++;
		if(a > c + 1) s = "No";
		ou.println(s);
		ou.flush();
    }
}

Measured memory_bytes: 56704
def main(n):
    list1 = range(1, 10)
    list2 = range(1, 10)
    qq = set()
    for a in list1:
        for b in list2:
            qq.add(a * b)
    if n in qq:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    N = int(input())
    print(main(N))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        if (a == 7 || a == 5 || a == 3) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  for(int i;i<s.size()-1;i++){
    if(s.at(i)==s.at(i+1)){
      cout << "Bad" << endl;
      break;
    }
    if(i == s.size()-2){
      cout << "Good" << endl;
    }
  }
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N,K;
  cin >> N >> K;
  K++;
  ll A[N];
  vector<ll> B[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
  }
  ll turn = 1;
  ll spot = 0;
  ll syuuki = 1;
  ll roop = 0;
  while (0 == 0) {
    B[spot].push_back(turn);
    if (B[spot].size() == 2) {
      break;
    }
    spot = A[spot];
    turn++;
  }
  syuuki = B[spot][1] - B[spot][0];

  if (K < B[spot][1]) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < B[i].size(); j++) {
        if (B[i][j] == K) {
          cout << i + 1 << endl;
          return 0;
        }
      }
    }
  }
  ll M[syuuki];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < B[i].size(); j++) {
      if (B[spot][0] <= B[i][j] && B[i][j] <= B[spot][1]) {
        M[B[i][j] % syuuki] = i + 1;
      }
    } 
  }
  K = K % syuuki;
  cout << M[K] << endl;
  return 0;
}

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

	char* string = (char*)malloc(6 * sizeof(char));
	scanf("%s", string);
	if (string[2] == string[3] && string[4] == string[5]) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

typedef long long int int64;

const int mod=1000000007;

int modPow(int r,int n){
  int t=1;
  int s=r;
  while(n){
    if(n&1) t=(int64)t*s%mod;
    s=(int64)s*s%mod;
    n>>=1;
  }
  return t;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  printf("%d\n",modPow(k,n));
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
    int r, g, b;
    int v;

    scanf("%d %d %d\n", &r, &g, &b);
    v = r * 100 + g * 10 + b;
    if ( v % 4 == 0 ){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    if(K == 1) cout << 0 << endl;
    else cout << N - K << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin>>n;
    ll a[100010];
    a[0]=0;
    rep(i,n){
        cin>>a[i+1];
    }
    a[n+1]=0;
    ll sum[100010]={};
    rep(i,n+2){
        sum[i+1]=sum[i]+abs(a[i+1]-a[i]);
    }
    /*
    rep(i,n+2){
        cout<<sum[i]<<" ";
    }
    */
    rep2(i,1,n+1){
        ll ans=0;
        ans+=sum[i-1];
        ans+=sum[n+1]-sum[i+1];
        ans+=abs(a[i+1]-a[i-1]);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2816
X = int(input())

check = [0]*(X+106)
check[0] = 1
for i in range(X+1):    ##0-Xまで
    if check[i] == 1:
        for tmp in [100, 101, 102, 103, 104, 105]:
            check[i + tmp] = 1


print(check[X])

Measured memory_bytes: 3828
import java.util.*;
import java.io.*;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int value = in.nextInt();
            if (value > max) {
                max = value;
            }
            if (value < min) {
                min = value;
            }
        }
        out.println(max - min);
    }

}


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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int a,p; cin >> a >> p;
    cout << (3*a + p) /2 << '\n';
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,ans=INF;
    string s;
    cin >> n >> s;
    vector<ll> b(n+1,0),w(n+1,0);
    REP(i,1,n+1){
        b[i] = b[i-1];
        w[i] = w[i-1];
        if(s[i-1]=='#') b[i]++;
        else w[i]++;
    }
    rep(i,n+1){
        ans = min(ans, b[i]+(w[n]-w[i]));
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    
    unordered_map<int, int> mp;
    int res = 0;
    
    for(int i = 0; i < m; ++i){
        int t1, t2;
        cin >> t1 >> t2;
        if(n > 1 && t1 == 1 && t2 == 0){
            res = -1;
            break;
        }
        auto itr = mp.find(t1);        // "xyz" が設定されているか？
        if( itr != mp.end() ) {
            if(itr -> second != t2){
                res = -1;
                break;
            }
         } else {
            mp[t1] = t2;
        }
    }
    
    if(res == -1){
        cout << res << endl;
        return 0;
    }
    
    for(int i = 1; i <= n; ++i){
        auto itr = mp.find(i);
        if( itr != mp.end() ) {
            res += itr -> second * pow(10, n - i);
        }
    }
    
    if(n > 1 && res < pow(10, n - 1)){
        res += pow(10, n - 1);
    }
    
    cout << res << endl;
    
    return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;


int root = 0;

struct edge{
    int id;
    int to;
};

vector<edge> nodes[100000];
int E[100000];

int main(void){
    rep(i, 100000) E[i] = -1;
    int N; cin >> N;
    rep(i, N-1){
        int a, b; cin >> a >> b;
        edge e;
        a--; b--;
        e.id = i;
        e.to = b;
        nodes[a].push_back(e);
        e.to = a;
        nodes[b].push_back(e);
    }
    int has_most_child = 0;
    rep(i, N){
        if(nodes[has_most_child].size() < nodes[i].size()) has_most_child = i;
    }
    root = has_most_child;

    vector<int> visited(N, 0);
    queue<pair<int, pair<int, int>>> que; //(頂点番号, (親の頂点番号, 親の色)
    que.push(make_pair(root, make_pair(-1, -1)));
    visited[root] = 1;

    //親の辺の色と被らないように塗っていく
    //親が誰かの情報が欲しい
    //親の辺の色の情報を持たせておくと便利
    while(!que.empty()){
        int nid = que.front().first;
        pair<int, int> pinfo = que.front().second;
        que.pop();
        int color = 1;
        rep(i, nodes[nid].size()){
            edge e = nodes[nid][i];
            if(e.to == pinfo.first) continue;
            if(color == pinfo.second) color++;
            E[e.id] = color;
            que.push(make_pair(e.to, make_pair(nid, color)));
            color++;
        }
    }

    cout << nodes[root].size() << endl;
    rep(i, N-1){
        cout << E[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 7424
from itertools import accumulate
INF = float('inf')


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [True] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            for j in range(2 * i * (i + 1), m, 2 * i + 1):
                p[j] = False

    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


N = 10 ** 5
P = set(prime_numbers(N))
# これが素数
# print(P)
P = [n for n in P if (n + 1) // 2 in P]
# 自身 + 1 //2 も素数であるもののみに絞る
# print(P)
a = [0] * (N + 1)
for n in P:
    # likenumberは1にする
    a[n] = 1
# 累積和に変換
a = list(accumulate(a))


Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(a[r] - a[l - 1])


Measured memory_bytes: 52516
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
    int n, tp = 0, hp = 0;
    cin >> n;
    for (int a = 0; a < n; a++)
    {
        string t, h;
        cin >> t;
        cin >> h;
        if (t < h)hp += 3;
        else if (t>h)tp += 3;
        else tp += 1, hp += 1;
    }
    cout << tp << " " << hp << endl;
    return 0;
}

Measured memory_bytes: 3136
A, B = map(int, input().split())
ans = [['.']*50 + ['#']*50 for i in range(500)]
cnt = 1
for i in range(0, 100, 2):
    for j in range(0, 49, 2):
        if cnt == B:
            break
        ans[i][j] = '#'
        cnt += 1
    if cnt == B:
        break
cnt = 1
for i in range(0, 100, 2):
    for j in range(51, 100, 2):
        if cnt == A:
            break
        ans[i][j] = '.'
        cnt += 1
    if cnt == A:
        break

print(100, 100)
for i in range(100):
    print(''.join(ans[i]))


Measured memory_bytes: 63648
S = input()
N = len(S)
def is_kaibun(s):
    for i in range(len(s) // 2):
        if s[i] != s[-i-1]:
            return False
    return True
if is_kaibun(S) and is_kaibun(S[:int((N-1)/2)]) and is_kaibun(S[int((N+3)/2)-1:]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>
int main (void)
{
    int x,i;
    i = 1;
 
    while(1){
        scanf("%d",&x);
 
    if( x > 0 ){
        printf("Case %d: %d\n",i,x);
    i = i + 1;
        }else if(x == 0)break;
    }
 
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N;
    ll ans = 0, ma = 0;
    rep(i,N){
        cin>>M;
        ans += M;
        ma = max(ma,M);
    }
    cout<<ans-(ma/2)<<endl;
}


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


int main(){
	int n;
	cin >> n;
	vector<long long int> a(n);
	for(int i=0;i<n;i++){
		cin >> a.at(i);
	}
	sort(a.begin(),a.end());
	if(a.at(0)!=0){
    	int f=0;
    	long long int seki=1;
    	for(int i=0;i<n;i++){
		    long long int syo = 1000000000000000000/seki;
		    if(syo>=a.at(i)){
    			seki=seki*a.at(i);
		    }else{
    			f++;
		    }
	    }
	    if(f==0){
	    cout << seki << endl;
	    }else{
    		cout << -1 << endl;
    	}
	}else{
	    cout << 0 << endl;
	}
}

Measured memory_bytes: 4056
#include <stdio.h>
typedef long long ll;

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

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

int main(void) {
  ll i, j, a, b, k;
  scanf("%lld%lld%lld", &a, &b, &k);
  for(i = a; i < min(a + k, b + 1); ++i) printf("%lld\n", i);
  for(i = max(b - k + 1, a + k); i <= b; ++i) printf("%lld\n", i);
  return 0;
}

Measured memory_bytes: 128
#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;}

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(){
    vector<int> lis(3);
    cin >> lis[0] >> lis[1] >> lis[2];
    sort(ALL(lis));
    int k = -1, ans = 0;
    REP(i, 0, 3){
        if(k != lis[i])
            ans++;
        k = lis[i];
    }
    cout << ans << endl;
}

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

int card[13];
int solve(){
    int m;
    vector<int> n;
    for(int i=0;i<13;i++){
        if(card[i]) n.push_back(card[i]);
    }
    for(int i=0;i<n.size();i++){
        for(int j=1;j<n.size()-i;j++){
            if(n[j-1] < n[j]) swap(n[j-1], n[j]);
        }
    }
    if(n[0] == 4){
        cout << "four card" << endl;
    }else if(n[0] == 3){
        if(n[1] == 2){
            cout << "full house" << endl;
        }else{
            cout << "three card" << endl;
        }
    }else if(n[0] == 2){
        if(n[1] == 2){
            cout << "two pair" << endl;
        }else{
            cout << "one pair" << endl;
        }
    }else{
        bool straight=false;
        for(int i=0;i<13-3;i++){
            if(card[i]&&card[i+1]&&card[i+2]&&card[i+3]&&card[(i+4)%13]){
                cout << "straight" << endl;
                straight=true;
                break;
            }
        }
        if(!straight){
            cout << "null" << endl;
        }
    }
}

int main(){
    char comma;
    int m;
    while(cin >> m){
        for(int i=0;i<13;i++){
            card[i] = 0;
        }
        m--;
        card[m]++;
        for(int i=0;i<4;i++){
            cin >> comma >> m;
            m--;
            card[m]++;
        }
        solve();
    }
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <math.h>
int judge(int);
int main(){
  int n,a[10000],i,j,count=0,hantei=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    if(judge(a[i])==0) count++;
  }
  printf("%d\n",count);
  return 0;
}
int judge(int n){
  int i,r;
  r=sqrt(n);
  if(n<=3){
    return 0;
  } else {
  for(i=2;i<=r;i++){
    if(n%i==0){
      return 1;
      break;
    }
  }
}
  return 0;
}


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

int main (){
	/*for(int k = 1; k<MAX;k++)
	{
		if(PrimeCheck(v[k+1]))
		{
			//cout << v[k+1] << " ";
			v2[d] = v[k+1];
			d++;
		}
	}
	//rep(i,d) cout << v2[i] << " ";
	//cout << d << endl;*/
	int number;
	while(cin >> number,number)
	{


		int counter = 0;
		vector<bool>v(MAX+1,0);
		vector<int>v2(MAX,0);
		rep(i,MAX)
			v[i+1] = true;
		long long answer = 0;
		int lim = (int)sqrt(number);
		int d = 0;
//		cout << lim <<" ";
		for(int i = 2; i<MAX; i++)
		{
			if(v[i])
			{
				for(int j = 2; j <MAX/i;j++)
				{
					v[j*i]  = false;
					//cout << " " << i << "i*j=  " << i*j;
				}
				v2[d] = i;
				d++;
			}	
		}
		//rep(i,number) cout << v[i+1] << " ";
		for(int i = 2; i<MAX+1;i++)
		{	
			if(v[i])
			{
				answer+=i;
				counter++;
				//cout << " " << i;
				if(counter == number)
					break;
			}
			
		}
		cout  /*<< " answer is "*/ << answer << endl;
	    
	}
	return 0;
}

Measured memory_bytes: 3524
using System;
class Program
{
    static void Main(string[] args)
    {
        int[] a = new int[5];
        for (int i = 0; i < 5; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
        }
        int last = 0;
        int min = int.MaxValue;
        for(int i = 0; i < a.Length; i++)
        {
            int remain = a[i] % 10;
            if(remain != 0 && remain < min)
            {
                min = remain;
                last = i;
            }
        }
        int t = a[last];
        for(int i = 0; i < a.Length; i++)
        {
            int remain = a[i] % 10;
            if (i != last)
            {
                if (remain == 0)
                    t += a[i];
                else
                    t += a[i] + 10 - remain;
            }
        }
        Console.WriteLine(t);
    }
}

Measured memory_bytes: 11092
n,k=gets.split.map(&:to_i)
list = [0]*n
k.times do
    i=gets.to_i
    l=gets.split.map(&:to_i)
    l.each do |j|
        list[j-1]+=1
    end
end
ans=0
list.each do |i|
    ans+=1 if i==0
end

p ans

Measured memory_bytes: 14392
use proconio::input;

fn main() {
    input! {
        s: String,
    }

    let ans = match s.as_str() {
        "RRR" => 3,
        "RRS" | "SRR" => 2,
        "RSR" | "RSS" | "SRS" | "SSR" => 1,
        _ => 0,
    };

    println!("{}", ans)
}


Measured memory_bytes: 2148
using System;
using System.Linq;
using System.Collections.Generic;
class ProgramE
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split();
            int n = int.Parse(input[0]);
            long k = long.Parse(input[1]);

            long[] eat = new long[n];
            long[] food = new long[n];
            long[] sec = new long[n];


            string[] input_a = Console.ReadLine().Split();
            for(int i = 0; i < n; i++)
                eat[i] = long.Parse(input_a[i]);
            
            
            
            string[] input_f = Console.ReadLine().Split();
            for(int i = 0; i < n; i++)
                food[i] = long.Parse(input_f[i]);
            
            long check = 0;

            for(int i = 0; i < n; i++)
                check += eat[i];
            
            if( k >= check)
            {
                Console.WriteLine("0");
                return;
            }


            Array.Sort(eat);
            Array.Sort(food);
            Array.Reverse(food);

            for(int i = 0; i < n; i++)
                sec[i] = food[i] * eat[i];

            
            long max = sec.Max();
            long min = 0;
            
            while(max != min + 1)
            {
                long x =(max + min) /2;
                long count = 0;

                for (int i = 0; i < n; i++)
                {
                    if (sec[i] > x)
                    {
                        if((sec[i] - x)%food[i] == 0)
                            count += (sec[i] - x)/food[i];
                        else
                            count += (sec[i] - x)/food[i] + 1;
                    }
                }

                if(count <= k)
                    max = x;
                else
                    min = x;

            }

            Console.WriteLine(max);    
        }

        
    }

Measured memory_bytes: 45172
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF 1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second
#define setprecision(d) cout << fixed << setprecision(d);

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

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


signed main(){

	ll n,m;
	cin >> n >> m;
	cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000009
# define pi acos(-1)
# define f first
# define s second
using namespace std;

signed main()
{
    gok
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;





      return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=400050;
const ll inf=9e18;
int a[N],b[N];
void Solve(int n, ll ans[2][N])
{
	int l=1,l2=1;
	ll b1=0,b2=0,s1=0,as1=0,sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=b[i];
		ans[0][i]=ans[1][i]=ans[0][i-1]+2-a[i];
		ans[1][i]=min(ans[1][i],ans[1][i-1]+(2-a[i])+(a[i]==2?1:-1));
		ans[0][i]=min(ans[0][i],sum);
		ans[1][i]=min(ans[1][i],sum);
		/*//bal+=2-a[i];
		b1+=2-a[i];
		//sum+=b[i];
		s1+=b[i];
		if(a[i]==0) b2--;
		else if(a[i]==1) b2--;
		else if(a[i]==2) b2++;
		if(b2>0) b2=0;
		//printf("%lld %lld %lld %lld\n",b1,b2,s1,as1);
		if(b1+b2-s1>0) b1=b2=0,l2=i+1,as1+=s1,s1=0;
		//if(bal-sum>0) l=i+1,bal=0,as+=sum,sum=0;
		//if(l>i) ans[0][i]=as;
		//else ans[0][i]=bal+as;
		if(l2>i) ans[i]=as1;
		else ans[i]=b1+b2+as1;*/
	}
}
ll l[2][N],r[2][N];
int main()
{
	int n,i;
	scanf("%i",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%i",&b[i]);
		if(b[i]!=0)
		{
			if(b[i]&1) a[i]=1;
			else a[i]=2;
		}
		else a[i]=0;
	}
	Solve(n,l);
	reverse(a+1,a+1+n);
	reverse(b+1,b+1+n);
	Solve(n,r);
	reverse(r[0]+1,r[0]+1+n);
	reverse(r[1]+1,r[1]+1+n);
	ll ans=inf;
	for(i=0;i<=n;i++)
	{
		//ans=min(ans,l[0][i]+r[1][i+1]);
		//ans=min(ans,l[1][i]+r[0][i+1]);
		ans=min(ans,l[1][i]+r[1][i+1]);
	}
	//for(i=1;i<=n;i++) printf("l[0][%i]:%lld l[1][%i]:%lld\n",i,l[0][i],i,l[1][i]);
	//for(i=1;i<=n;i++) printf("r[0][%i]:%lld r[1][%i]:%lld\n",i,r[0][i],i,r[1][i]);
	printf("%lld\n",ans);
	return 0;
}

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

void solve(){

	int x,y ;
	cin>>x>>y ;

	cout<<max(0,x-y) ;
	
}


int main(){

		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int n;
  while (cin >> n) {
    vector<pair<lli, lli>> v(n);
    cin >> v;
    sort(v.begin(), v.end(), [] (auto i, auto j) { return i.first + i.second > j.first + j.second; });
    lli sum = 0;
    for (int i = 0; i < v.size(); ++i) {
      if (i % 2) sum -= v[i].second;
      else sum += v[i].first;
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll h, n;
ll a[N];
ll b[N];

ll dp[1003][10004];
ll recur(ll pos, ll rem) {

  if (rem <= 0)
    return 0;
  if (pos == n + 1) {
    return inf;
  }
  ll &ans = dp[pos][rem];
  if (ans != -1)
    return ans;

  ans = min(recur(pos + 1, rem), b[pos] + recur(pos, rem - a[pos]));

  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

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

  pair<ll, ll> arr[n + 5];
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i].first >> arr[i].second;
    arr[i].second = (arr[i].second + a - 1) / a;
  }

  sort(arr + 1, arr + n + 1);

  ll xcord[n + 5];
  for (ll i = 1; i <= n; i++) {
    xcord[i] = arr[i].first;
  }

  ll pre[n + 5];
  ll res = 0;
  memset(pre, 0, sizeof(pre));
  for (ll i = 1; i <= n; i++) {
    pre[i] += pre[i - 1];
    ll val = arr[i].second - pre[i];
    if (val <= 0)
      continue;
    res += val;

    ll indx =
        upper_bound(xcord + 1, xcord + n + 1, arr[i].first + 2 * d) - xcord;
    indx--;

    pre[i + 1] += val;
    pre[indx + 1] -= val;
  }

  cout << res << en;

  return 0;
}

Measured memory_bytes: 6528
# coding:utf-8

INF = float('inf')


N = int(input())
S = input()

num_E = 0
num_W = 0
for s in S:
    if s == 'E':
        num_E += 1
    else:
        num_W += 1

e = num_E
w = num_W
ans = INF
for s in S:
    cost = 0
    if s == 'E':
        e -= 1
        cost = e + (num_W - w)
    else:
        w -= 1
        cost = e + (num_W - w - 1)
    ans = min(ans, cost)

print(ans)


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

int d[300][300];

int n;

signed main(){
    cin >> n;
    REP(i,n) REP(j,n) cin >> d[i][j];
    REP(k,n)REP(i,n)REP(j,n) if(chmin(d[i][j],d[i][k]+d[k][j])){
        cout << -1 << '\n';
        return 0;
    }
    int ans = 0;
    REP(i,n)REP(j,n){
        if(!d[i][j]) continue;
        bool flg = true;
        REP(k,n){
            if(i == k or j == k ) continue;
            if(d[i][j] >= d[i][k] + d[k][j]) flg = false;
        }
        if(flg) ans += d[i][j];
    }
    cout << ans/2 << endl;
} 

Measured memory_bytes: 1024
import heapq
N,M=map(int,input().split())
A=list(map(lambda x:-int(x),input().split()))
heapq.heapify(A)
for _ in range(M):
    v=heapq.heappop(A)
    heapq.heappush(A,-(-v//2))
print(-sum(A))

Measured memory_bytes: 14380
import java.util.*;
 
class Main {
	  static long mod=1_000_000_007;
  public static void main(String[] args) {
	  int flg = 0;
	  Scanner sc = new Scanner(System.in);
      long N = sc.nextLong();
      long M = sc.nextLong();
      Integer[] a = new Integer[(int)N];
      for (int i=0 ; i<N; i++) {
          a[i] = sc.nextInt();
      }
      Arrays.sort(a, Comparator.reverseOrder());
      
      int cnt;
      long tmp;
      for(int i=0;i<M;i++) {
    	  cnt=0;
    	  a[0]=a[0]/2;
    	  tmp = a[0];
    	  for(int j=1;j<N;j++) {
    		  if(a[j]>a[0]) {
    			  cnt++;
    		  }
    	  }
    	  
    	  for(int j=1;j<M-1 && j<N;j++) {
        	  if(tmp<=a[j] && i<M-1) {
        		  a[j]=a[j]/2;
        		  i=i+1;
        	  } else {
        		  break;
        	  }
    	  }
    	  
          Arrays.sort(a, Comparator.reverseOrder());
    	  
//    	  for(int j=1;j<cnt+1;j++) {
//    		  a[j-1]=a[j];
//    	  }
//    	  a[cnt]=tmp;
      }
      
      long ans=0;
      for(int i=0;i<N;i++) {
//          System.out.println(a[i]);
    	  ans = ans + a[i];
      }
      
      System.out.println(ans);
      
  }
}

Measured memory_bytes: 62360
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff  first
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 1e5+9;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
lli lcm(lli a,lli b)
{
    lli ans=(a*b)/(__gcd(a,b));
    return ans;
}
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
void solve()
{
    int w,a,b;cin>>w>>a>>b;
    if(a+w >= b and a<b or a-w <=b and a>b or a==b)cout<<0<<endl;
    else
    {
        if(a>b)
        {
            cout<<abs(b-(a-w))<<endl;
        }
        else
        {
            cout<<abs(b-(a+w))<<endl;
        }
    }
}
int main()
{
    FAST;
    //int tc=1;cin>>tc;while(tc--)solve();
    solve();
}



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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

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

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

const int N = 212345;
const int MOD = 998244353;

LL pw[N], fac[N];
int n, m, k;

LL inv(LL x) {
    LL ans = 1;
    int val = MOD - 2;
    while (val) {
        if (val & 1) ans = ans * x % MOD;
        x = x * x % MOD;
        val >>= 1;
    }
    return ans;
}

LL C(int a, int b) {
    LL ans = fac[a];
    ans = ans * inv(fac[a - b]) % MOD;
    ans = ans * inv(fac[b]) % MOD;
    return ans;
}

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

    cin >> n >> m >> k;

    pw[0] = fac[0] = 1;
    for (int i = 1; i <= n; ++i) pw[i] = pw[i - 1] * (m - 1) % MOD;
    for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % MOD;

    LL ans = 0;
    for (int i = n - k; i <= n; ++i) {
        LL cur = C(n - 1, i - 1);
        cur = cur * m % MOD;
        cur = cur * pw[i - 1] % MOD;
        ans = (ans + cur) % MOD;
    }

    cout << ans << '\n';
    return 0;
}

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

int main(){
  int ans = 0;
  string s;
  cin>>ans;
  while(cin>>s){
    int b;
    if(s[0]=='=') cout<<ans<<endl;
    else {
      cin>>b;
      if(s[0]=='+') ans+=b;
      else if(s[0] == '-') ans-=b;
      else if(s[0]=='*') ans*=b;
      else  ans/=b;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  cout << (b-a == c-b ? "YES" : "NO") << endl;
  return 0;
}



Measured memory_bytes: 256
#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 yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	string s;

	cin>>s;

	int f=0;
	if(s.substr(0,7)=="keyence"){
		cout<<"YES"<<endl;
		return 0;
	}
	if(s.substr(s.size()-7,7)=="keyence"){
		cout<<"YES"<<endl;
		return 0;
	}
	if(s.substr(0,1)=="k"&&s.substr(s.size()-6,6)=="eyence"){
		cout<<"YES"<<endl;
		return 0;
	}
	if(s.substr(0,2)=="ke"&&s.substr(s.size()-5,5)=="yence"){
		cout<<"YES"<<endl;
		return 0;
	}
	if(s.substr(0,3)=="key"&&s.substr(s.size()-4,4)=="ence"){
		cout<<"YES"<<endl;
		return 0;
	}
	if(s.substr(0,4)=="keye"&&s.substr(s.size()-3,3)=="nce"){
		cout<<"YES"<<endl;
		return 0;
	}
	if(s.substr(0,5)=="keyen"&&s.substr(s.size()-2,2)=="ce"){
		cout<<"YES"<<endl;
		return 0;
	}
	if(s.substr(0,6)=="keyenc"&&s.substr(s.size()-1,1)=="e"){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

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


int main() {
    int n;
    vector<int> a;
    int ans = 0;

    cin >> n;

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

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

    if (a[0] == a[n-1] && (a[0] ^ a[1]) == a[2]) ans = 1;
    if (n % 3 == 0 && a[0] == a[(n/3)-1] && a[(n/3)] == a[2*(n/3)-1] && a[2*(n/3)] == a[n-1] && (a[0] ^ a[(n/3)]) == a[2*(n/3)]) ans = 1;
    

    cout << ((ans == 1) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 892
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
hash = [0 for i in range(n+1)]

if len(set(a))<=k:
  print(0)
  exit()
else:
  ans=0
  for i in a:
    hash[i]+=1
  hash.sort()
  L=hash
  #何種類減らすかカウントするx
  x = len(set(a)) - k
  j=0
  m=0
  while m!=x:
    if L[j]==0:
      j+=1
      continue
    else:
      ans+=L[j]
      j+=1
      m+=1
  print(ans)


Measured memory_bytes: 28804
import scala.io.StdIn
object Main extends App {
  val A = StdIn.readLine().toInt
  val B = StdIn.readLine().toInt
  val C = StdIn.readLine().toInt
  val X = StdIn.readLine().toInt

  val answer = for {
    a <- 0 to A
    b <- 0 to B
    c <- 0 to C
    if (500 * a + 100 * b + 50 * c == X)
  } yield (a, b, c)
  println(answer.length)
}


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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define fi first
#define se second

const int N = 1e5 + 5;
const ll inf = 1e18;
int n, k;
ll dp[N], h[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> h[i];
    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
        dp[i] = inf;
        for (int j = i - 1; j >= max(1, i - k); j--) {
            dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
        }
    }
    cout << dp[n];
    
    return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int a, b;
	cin >> a >> b;
	if (abs(a - b) % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << (a + b) / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    char s;
    cin >> a >> s >> b;
    if (s=='+'){
        cout << a+b << endl;
    }else{
        cout << a-b << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <complex>
#include <queue>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb  push_back

const double EPS = 1e-8;
typedef complex<double> Pt;

double dot(const Pt &a, const Pt &b) { return real(conj(a) * b); }
double cross(const Pt &a, const Pt &b) { return imag(conj(a) * b); }

struct L : public vector<Pt>
{
    L(){}
    L(const Pt &a, const Pt &b) {
        push_back(a); push_back(b);
    }
};

int ccw(Pt a, Pt b, Pt c)
{
    b -= a; c -= a;
    if(cross(b, c) > 0)     return 1;   // counter clockwise
    if(cross(b, c) < 0)     return -1;  // clockwise
    if(dot(b,c) < 0)        return 2;   // c-a-b on line
    if(norm(b) < norm(c))   return -2;  // a-b-c on line
    return 0;                           // a-c-b on line
}

bool intersectSP(const L &l, const Pt &p)
{
    return abs(l[0]-p) + abs(l[1]-p) - abs(l[1]-l[0]) < EPS;
}

bool intersectSS(const L& s, const L& t)
{
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
    ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

Pt projection(const L &l, const Pt &p)
{
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}

double distSP(const L& l, const Pt &p)
{
    const Pt r = projection(l, p);
    if(intersectSP(l, r)) return abs(r - p);
    return min(abs(l[0] - p), abs(l[1] - p));
}

double distSS(const L &s, const L &t)
{
    if(intersectSS(s, t)) return 0;
    return min(min(distSP(s, t[0]), distSP(s, t[1])),
               min(distSP(t, s[0]), distSP(t, s[1])));
}

int INF = 1001001001;
typedef pair<double, int> P;

int main()
{
    int W, N, M, x, y;
    
    while(cin >> W >> N && W)
    {
        vector<L> line;
        rep(i, N)
        {
            vector<Pt> pt;
            cin >> M;
            rep(j, M) cin >> x >> y, pt.pb(Pt(x, y));
            rep(j, M-1) line.pb(L(pt[j], pt[j+1]));
            line.pb(L(pt[0], pt[M-1]));
        }
        
        int src = line.size(), dst = src + 1, n = src + 2;
        line.pb(L(Pt(0, 0), Pt(0, 10000)));
        line.pb(L(Pt(W, 0), Pt(W, 10000)));
        
        vector<double> d(n, INF);
        d[src] = 0;
        priority_queue<P, vector<P>, greater<P> > que;
        que.push(P(0, src));
        
        while(true)
        {
            P p = que.top(); que.pop();
            int cur = p.second;
            if(cur == dst) {
                cout << setprecision(10) << d[dst] << endl; break;
            }
            if(d[cur] < p.first) continue;
            rep(i, n) if(i != n && d[i] > d[cur] + distSS(line[i], line[cur])) {
                d[i] = d[cur] + distSS(line[i], line[cur]);
                que.push(P(d[i], i));
            }
        }
    }
}

Measured memory_bytes: 1820