akhauriyash/Code-Regression huggingface dataset:
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    int a; cin>>a;
    vec<ld> m(a);
    for(int q=0; q<a; q++) cin>>m[q];
    sort(m.begin(), m.end());
    ld o  = m[0];
    for(int q=1; q<a; q++) o = (o+m[q])/2.0;
    cout.precision(12);
    cout<<fixed;
    cout<<o;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
//#define sz 2

using namespace std;

map< string, int > mp;

int main() {
	int n, ans = 0;
	string s;
	cin >> n;
	while( n-- ) {
		cin >> s;
		if( mp.count( s ) == 0 ) {
			mp[ s ] = 1;
			++ans;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 19228
N = int(input())
L = list(map(int,input().split()))

counter = 0
for i in range(N):
    for j in range(i,N):
        for k in range(j,N):
            if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[j]+L[k] > L[i]:
                counter += 1
                """
                print("i:%d" % (i+1))
                print("j:%d" % (j+1))
                print("k:%d" % (k+1))
                print("\n")
                """
print(counter)


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

using namespace std;

int main(){
    int_fast64_t n,m,l=0,ans;
    cin >>n >>m;
    int_fast64_t r =n;

    for(int i=0;i<m;i++){
        int_fast64_t a,b;
        cin >>a >>b;
        l = max(l,a);
        r = min(r,b); 
    }

    ans = r -l+1;
    if(ans>0){
        cout << ans<<endl;
    }else{
         cout << 0 << endl;
    }
   

}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto D = s[1].to!long;
    auto A = readln.split.map!(to!long).array;
    auto B = new long[](N+1);
    B[0] = D;
    foreach (i; 0..N) B[i+1] = min(B[i], abs(B[i] - A[i]));
    auto ans = new bool[](N);

    long x = 1;
    foreach_reverse(i; 0..N) {
        ans[i] = B[i] >= x;
        if (x > A[i] / 2) x += A[i];
    }

    auto Q = readln.chomp.to!int;
    readln.split.map!(i => (ans[i.to!int-1] ? "YES" : "NO")).each!writeln;
}


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

const int N = 1000;

int lcs(string a, string b) {
  int C[N+1][N+1];
  int n = a.size();
  int m = b.size();
  for (int i = 0; i <= n; i++) C[i][0] = 0;
  for (int i = 0; i <= m; i++) C[0][i] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i-1] == b[j-1]) {
        C[i][j] = C[i-1][j-1] + 1;
      } else {
        C[i][j] = C[i][j-1] > C[i-1][j] ? C[i][j-1] : C[i-1][j];
      }
    }
  }
  return C[n][m];
}

int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    string X, Y;
    cin >> X >> Y;
    cout << lcs(X, Y) << endl;
  }
  return 0;
}



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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
 ll N,K;cin >> N >> K;
 vector<ll> V(N);
 for(int i = 0;i < N;i++)cin >> V[i];
 ll ans = 0;
 for(int i = 0;i <= N;i++){
   for(int j = 0;j <= N-i;j++){
     if(i+j > K)continue;
     ll sum = 0;
     vector<ll> memo;
     for(int k = 0;k < i;k++){
       sum += V[k];
       if(V[k] < 0){
         memo.push_back(V[k]);
       }
     }
     for(int k = N-1;k > N-1-j;k--){
       sum += V[k];
       if(V[k] < 0){
         memo.push_back(V[k]);
       }
     }
     sort(memo.begin(),memo.end());
     for(int k = 0;k < min(K-(i+j),(ll)memo.size());k++){
       sum -= memo[k];
     }
     ans = max(ans,sum);
   }
 }
 cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);
	ll a,b,c; 
	cin>>a>>b>>c;
	a = abs(a);
	if(b<=a/c)
	{
		cout<<a-b*c<<Endl;
		return 0;
	}
	ll k = a/c;
	ll yu = (b-k)%2;
	if(yu%2>0)
	{
		cout<<abs(a-k*c-c)<<endl;
		return 0;
	}
	cout<<abs(a-k*c)<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
  int a, b, c;
  int tmp;

  scanf("%d %d %d", &a, &b, &c);
  if (a > b){
    tmp = a;
    a = b;
    b = tmp;
  }
  if (b > c){
    tmp = b;
    b = c;
    c = tmp;
  }
  if (a > b){
    tmp = a;
    a = b;
    b = tmp;
  }
    printf("%d %d %d\n", a, b, c);
    return 0;
}



Measured memory_bytes: 2124
def main():
    N=int(input())
    B=list(map(int,input().split()))

    Ans=B[0]

    for i in range(1,N-1):
        Ans += B[i-1] if B[i-1]<B[i] else B[i]

    Ans+=B[N-2]

    print(Ans)

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
  long A, B, lcd;
  cin >> A >> B;
  lcd = __gcd(A, B);
  long a = 2, ans = 2;
  if(lcd == 1){
    cout << 1 << endl;
    return 0;
  }
    while (lcd >= a * a) {
      if (lcd % a == 0) {
        lcd /= a;
        if(lcd % a != 0)ans++;
      } else {
        a++;
      }
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long int ll;

constexpr ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}

struct perm{
private:
	int sz;
	vector<ll> p,invp;
public:
	perm(int n){
		sz=n+1;
		p.resize(sz),invp.resize(sz);
		p[0]=1;
		for(int i=1;i<=sz-1;i++){
			p[i]=p[i-1]*i%mod;
		}
		invp[sz-1]=mod_pow(p[sz-1],mod-2);
		for(int i=sz-2;i>=0;i--){
			invp[i]=invp[i+1]*(i+1)%mod;
		}
	}
	ll comb(ll x,ll y){
		if(x<y||y<0)return 0;
		return (p[x]*invp[x-y]%mod)*invp[y]%mod;
	}
};
perm p(1<<20);

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	vector<ll> cnt(n+1,0);
	for(int i=0;i<n;i++){
		cnt[i+1]=(mod_pow(i+1,mod-2)+cnt[i])%mod;
	}
	ll res=0;
	for(int i=0;i<n;i++){
		(res+=a[i]*(cnt[i+1]+cnt[n-i]-1)%mod)%=mod;
	}
	for(int i=1;i<=n;i++){
		res*=i;
		res%=mod;
	}
	if(res<0)res+=mod;
	cout << res << endl;
}

Measured memory_bytes: 18176
N=int(input())
a=[list(map(int,input().split())) for _ in range(N)]
c=[list(map(int,input().split())) for _ in range(N)]
X=[(q,w,0) for q,w in a]+[(e,r,1) for e,r in c]
X.sort()
ans=0
dp=[0]*(2*N)
for x,y,z in X:
  if z==0:
    dp[y]+=1
  else:
    for v in range(y-1,-1,-1):
      if dp[v]>0:
        ans+=1
        dp[v]-=1
        break
print(ans)

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

#define each(i, mp) for(auto& i:mp)

int main() {
    string s;
    cin >> s;
    map<ll, ll> mp;
    mp[0] = 1;
    reverse(s.begin(), s.end());
    ll now = 0, ten = 1;
    each(e, s) {
        //cout << now << endl;
        now = (now + (e - '0') * ten) % 2019;
        ten *= 10;
        ten %= 2019;
        mp[now]++;
    }
    ll ans = 0;
    each(e, mp) {
        ans += e.second * (e.second - 1) / 2;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[][] cnt = new long[10][10];
        for (int i = 1; i <= n; i++) {
            cnt[String.valueOf(i).charAt(0) - '0'][String.valueOf(i).charAt(String.valueOf(i).length() - 1) - '0']++;
        }
        long ans = 0;
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                ans += cnt[i][j] * cnt[j][i];
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 45580
# coding: utf-8
n = input()
total=0
op_cnt = len(n) - 1 
for i in range(2 ** op_cnt):
    op = ["+"] * op_cnt  
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "-" 
    formula = ""
    for p_n, p_o in zip(n, op + [""]):  
        formula += (p_n + p_o)
    if eval(formula)==7:
        print(formula+"=7")
        break

Measured memory_bytes: 3060
n = int(raw_input())
s = ["S"]
h = ["H"]
c = ["C"]
d = ["D"]
card_list = [s,h,c,d]

for i in range(n):
    card = raw_input().split()
    for v in card_list:
        if v[0] == card[0]:
            v.append(int(card[1]))
# print card_list

for i in card_list:
    for j in range(1, 14):
        if not j in i:
            print "%s %d" % (i[0], j)

Measured memory_bytes: 6408
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=100005,mod=1e9+7;
int n,a[N],fn,inv[N],ans;
int main()
{
	RI i; for (scanf("%d",&n),i=1;i<=n;++i) scanf("%d",&a[i]);
	for (fn=inv[0]=inv[1]=1,i=2;i<=n;++i)
	inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for (i=2;i<=n;++i) fn=1LL*fn*i%mod,(inv[i]+=inv[i-1])%=mod;
	for (i=1;i<=n;++i) (ans+=1LL*(inv[i]+inv[n-i+1]-1)*fn%mod*a[i]%mod)%=mod;
	return printf("%d",ans),0;
}

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


int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n); //q.at(i)がp.at(i)までの中の最小値
    int count = 0;

    for(int i=0;i<n;i++){
        cin >> p.at(i);
    }
    q.at(0) = p.at(0);
    for(int i=1;i<n;i++){
        if(p.at(i)<q.at(i-1)){
            q.at(i) = p.at(i);
        }else{
            q.at(i) = q.at(i-1);
        }
        //cout << "q.at(" << i << ")=" << q.at(i) << endl;
    }

    for(int i=0;i<n;i++){
        if(q.at(i) == p.at(i)){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    cin >> k;
    vector<vector<int>> res;
    if(k==1) res = {{0}};
    else {
        int n = 2*((k+3)/4);
        res.assign(n,vector<int>(n));
        rep(i,0,n) rep(j,0,n) {
            res[i][j] = (i+j)%n;
            if(i%2==0 && res[i][j]+n<k) res[i][j]+=n;
        }
    }
    int n = res.size();
    cout<<n<<"\n";
    rep(i,0,n) rep(j,0,n) {
        cout<<res[i][j]+1;
        if(j+1==n) cout<<"\n";
        else cout<<" ";
    }
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n, m, k;
    cin >> n >> m;
    vector<int> a(m,0);

    rep(i,n) {
        cin >> k;
        rep(j,k) {
            int tmp;
            cin >> tmp;
            tmp--;
            a[tmp]++;
        }
    }

    int ans = 0;
    sort(a.begin(), a.end());
    if (a[m-1] != n) {
        cout << 0 << endl;
        return 0;
    }
    rep(i,m) {
        if (a[i] == a[m-1])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int n; cin>>n;
	double k; cin>>k;
	ll ans=0;
	rep(i,0,n){
		double a,b; cin>>a>>b;
		if(sqrt(a*a+b*b)<=k)ans++;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    
    int n, i, ok = 1;
    scanf("%d", &n);
    getchar();
    char* s = calloc(n+(n-1), sizeof(char));
    scanf("%[^\n]", s);
    getchar();
    for(i = 0; i < strlen(s) && ok; i ++)
        if(s[i] == 'Y')
            ok = 0;
    if(ok)
        printf("Three");
    else
        printf("Four");
    return 0;
}

Measured memory_bytes: 128
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (a, b, c, k) = readLongList()

    val ans = if (k <= a) {
        k
    } else if (k <= a + b) {
        a
    } else {
        a - (k - a - b)
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36524
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a=0,b=0,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
  cin>>a>>b>>c;
  if(c==a&&a==b) Yes;
  else No;

    return 0;
}


Measured memory_bytes: 3644
n,k=map(int,input().split())
ans=0
if k==0:
    print(n*n)
    exit()
for i in range(k+1,n+1):
    ans+=(i-k)*(n//i)
    if n-i*(n//i)-k+1>0:
        ans+=n-i*(n//i)-k+1
    # print(ans,i)
print(ans)

Measured memory_bytes: 3060
a,b = map(int, input().split())

def xor(n):
    check = n % 4
    if check == 0:
        return n
    if check == 1:
        return 1
    if check == 2:
        return n + 1
    if check == 3:
        return 0
      
print(xor(a-1)^ xor(b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
    string s;
    cin >>s;
rep(i,3){
if(s[i]=='1')y++;
}
cout<<y;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

int main() {
    int n;
    cin >> n;
    vector<int> a(n, 0);
    REP(i, n) cin >> a[i];

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

    int cnt = 1;
    int kijun = a[0];
    int ans = 0;

    REPN(i, 1, n) {
        if(kijun == a[i]) {
            cnt++;
        } else {
            if(cnt % 2 == 1) {
                ans++;
            }
            cnt = 1;
            kijun = a[i];
        }
    }

    if(cnt % 2 == 1) {
        ans++;
    }
    
    cout << ans << endl;

    return 0;
}
 

Measured memory_bytes: 640
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    val t, s, e, w, n, b = scanner.nextInt
    var dice = Dice(t, n, e, s, w, b)

    for(_ <- 1 to scanner.nextInt) {
      val qt, qs = scanner.nextInt

      if(qt == dice.e) {
        dice = dice.rotW()
      } else if(qt == dice.w) {
        dice = dice.rotE()
      } else if(qt == dice.b) {
        dice = dice.rotE().rotE()
      }

      if(qt != dice.t) dice = dice.rotN()
      if(qt != dice.t) dice = dice.rotN()
      if(qt != dice.t) dice = dice.rotN()

      if(qs == dice.s) {
        println(dice.e)
      } else if(qs == dice.e) {
        println(dice.n)
      } else if(qs == dice.n) {
        println(dice.w)
      } else {
        println(dice.s)
      }
    }
  }
}

case class Dice(t: Int, n: Int, e: Int, s: Int, w: Int, b: Int) {
  def rotN(): Dice = Dice(s, t, e, b, w, n)
  def rotS(): Dice = Dice(n, b, e, t, w, s)
  def rotW(): Dice = Dice(e, n, b, s, t, w)
  def rotE(): Dice = Dice(w, n, t, s, b, e)
}



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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ar array

typedef long long ll;
typedef pair<int, int> ii;
 
ll gcd(ll a, ll b, ll& x, ll& y) {
  if (b == 0) {
      x = 1;
      y = 0;
      return a;
  }
  ll x1, y1;
  ll d = gcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - y1 * (a / b);
  return d;
}
 
bool dio(ll a, ll b, ll c, ll &x0, ll &y0, ll&g) {
  g = gcd(abs(a), abs(b), x0, y0);
  if (c % g) {
    return false;
  }
 
  x0 *= c / g;
  y0 *= c / g;
  if (a < 0) x0 = -x0;
  if (b < 0) y0 = -y0;
  return true;
}
 
ll solve(ll a,ll b,ll c)
{
  ll  x0, y0, g;
   b = -b;
  if(dio(a, b, c, x0, y0, g) == 0){
    assert(false);
    return 0;
  }
  //cerr << x0 << ' ' << y0;
  ll oo = 1e18;
  function<pair<ll, ll>(ll k)>get = [&](ll k)
  {
    return mp(x0 + b / g * k, y0 - a / g * k);
  };
  auto check = [&](ll k)
  {
    auto tmp = get(k);
    return tmp.fi >= 0 && tmp.se >= 0;
  };
  ll b1 = b / g, a1 = a / g; b1 = abs(b1);
  ll l = max((-oo + x0) / b1, (-oo + y0) / a1);
  ll r = min((oo + x0) / b1, (oo + y0) / a1);
  ll mid;
  l = max(l, -oo), r = min(r, oo);
  if(l > r) swap(l, r);
  while(l <= r){
    mid = (l + r) / 2;
    if(!check(mid)) r = mid - 1;
    else l = mid + 1;
  }
  return get(r).first * a;
}
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long now = 0;
  long long n;
  cin >> n;
  vector<long long> a;
  long long fixed = n;
  n *= 2;
  for (int i = 2; 1ll * i * i <= n; i++) {
  	if (n % i == 0) {
  		long long x = 1;
  		while (n % i == 0) {
  			n /= i;
  			x *= i;
			}
			a.push_back(x);
		}
	}
	if (n > 1) a.push_back(n);
	if ((int)a.size() == 2 && a.front() == 2) {
		cout << fixed - 1;
		return 0;
	}
	long long ans = 2 * fixed;
	for (int mask = 1; mask < 1 << (int)a.size(); mask++) {
		long long x = 1,y = 1;
		for (int i = 0; i < (int)a.size(); i++) {
			if (mask >> i & 1) {
				x *= a[i];
			}
			else y *= a[i];
		}
		ans = min(ans,solve(x,y,1));
		//x * p + 1 = y * q (x,y) = 1
	}
	cout << ans - 1;
} 

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	set<char> st={'A','T','G','C'};
	int mx =0, cr=0;
	rep(i, sz(s)){
		if(st.count(s[i])) cr++;
		else cr=0;
		mx = max(mx, cr);
	}
		
	cout << mx<<"\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define _CRT_SECURE_NO_WARNINGS
#endif
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void print(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
template<typename First, typename ... Ints>
void scan(First &arg, Ints&... rest) { scan(arg);scan(rest...); }

using namespace std;
const int MM = 1e5+2;

int N, dp[MM][3];

int main(){
    
    scan(N);
    
    for(int i = 1,a,b,c; i <= N; i++){
        scan(a, b, c);
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
    }
    print(max(dp[N][0], max(dp[N][1], dp[N][2])));
    
    return 0;
}

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

int main() {
	int n, p[11];
	cin >> n;
	int sum = 0;
	int max_num = 0;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		sum += p[i];
		max_num = max(p[i], max_num);
	}
	cout << sum - max_num / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n,w=pM(split(readline()))
  dp=[Int[10^20 for i=1:10^6] for j=1:n+1]
  dp[1][1]=0
  for i=1:n
    wi,vi=pM(split(readline()))
    for j=1:10^6
      if j-vi>0
        dp[i+1][j]=min(dp[i+1][j],dp[i][j-vi]+wi)
      end
      dp[i+1][j]=min(dp[i+1][j],dp[i][j])
    end
  end
  ans=0
  for i=1:10^6
    if dp[n+1][i]<=w
      ans=i-1
    end
  end
  println(ans)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


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

long long A[1 << 18];
vector<tuple<int, int, int, int>> vec;

void add(int x, int y, int pos) {
	vec.push_back(make_tuple(1, x, y, pos));
	A[pos] = A[x] + A[y];
}

void bunki(int x, int y, int pos) {
	vec.push_back(make_tuple(2, x, y, pos));
	if (A[x] < A[y]) A[pos] = 1;
	else A[pos] = 0;
}

int main() {
	// 入力
	long long X = 89, Y = 77;
	A[0] = X;
	A[1] = Y;

	// Step #1. 最初の部分を作る
	add(0, 1, 10);
	bunki(11, 10, 100);
	add(1, 100, 3);
	for (int i = 1; i <= 30; i++) add(99 + i, 99 + i, 100 + i);

	// Step #2. 繰り返し処理部分
	for (int i = 30; i >= 0; i--) {
		add(4, 100 + i, 5);
		bunki(0, 5, 8);
		add(11, 11, 6);
		for (int j = 30; j >= 0; j--) {
			add(6, 100 + j, 7);
			bunki(7, 3, 9);
			bunki(8, 9, 200);
			for (int k = 1; k <= j; k++) add(199 + k, 199 + k, 200 + k);
			add(6, 200 + j, 6);
		}
		add(11, 6, 300);
		for (int j = 1; j <= i; j++) add(299 + j, 299 + j, 300 + j);
		add(2, 300 + i, 2);

		bunki(8, 100, 400);
		for (int j = 1; j <= i; j++) add(399 + j, 399 + j, 400 + j);
		add(4, 400 + i, 4);
	}

	// 出力
	cout << vec.size() << endl;
	for (int i = 0; i < vec.size(); i++) {
		if (get<0>(vec[i]) == 1) cout << "+ " << get<1>(vec[i]) << " " << get<2>(vec[i]) << " " << get<3>(vec[i]) << endl;
		if (get<0>(vec[i]) == 2) cout << "< " << get<1>(vec[i]) << " " << get<2>(vec[i]) << " " << get<3>(vec[i]) << endl;
	}
	return 0;
}

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

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

	double t1, t2;
	cin >> t1 >> t2;

	double a = (t1 + t2) / 2;
	double xa = abs(t1 - a);
	xa = min(xa, 360 - xa);
	double b = a + 180;
	double ans = a;
	double xb = abs(t1 - b);
	xb = min(xb, 360 - xb);
	if(abs(xb) < abs(xa)) ans = b;

	while(ans - 360 > 0) ans -= 360;
	cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 3264
#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, m, x, c[13], a[13][13];
	cin >> n >> m >> x;
	rep(i, n) {
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}
	int ans = -1;
	for(unsigned long long b = 0; b < (1LL << n); b++) {
		int acc[13] = {0};
		int cost = 0;
		rep(i, n) {
			if (((b >> i) & 1) == 0) continue;
			cost += c[i];
			rep(j, m) acc[j] += a[i][j];
		}
		bool ok = true;
		rep(j, m) {
			if (acc[j] < x) {
				ok = false;
				break;
			}
		}
		if (ok) {
			if (ans == -1) ans = cost;
			else ans = min(ans, cost);
		}
	}
	cout << ans << endl;

}


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

inputs = [[int(elm) for elm in input().split(" ")] for i in range(N)]
inputs = sorted(inputs, key=lambda x: x[::-1])

#print(inputs)

out = "Yes"
tmp = 0
for A, B in inputs:
    tmp += A
    if tmp > B:
        out = "No"
        break

print(out)

Measured memory_bytes: 61676
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

int a[100005];
pair<int, int> q[100005];

void Main() {
  int n, m; cin >> n >> m;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < m; i++) {
    cin >> q[i].second >> q[i].first;
  }
  sort(q, q + m);
  reverse(q, q + m);
  priority_queue<int> Q;
  for(int i = 0; i < m && int(Q.size()) < n; i++) {
    for(int j = 0; j < q[i].second && int(Q.size()) < n; j++) {
      Q.push(q[i].first);
    }
  }
  for(int i = 0; i < n; i++) {
    Q.push(a[i]);
  }
  int cnt = 0;
  long long ans = 0;
  while(cnt < n) {
    ans += Q.top();
    Q.pop();
    cnt++;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.in","r",stdin);freopen ("kmp.out","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum;

int main()
{
	fast;
	cin>>n;
	fs(ar,n);
	fo(i,1,n)
	{
		if(ar[i]!=1 && ar[i]!=ar[i-1])
			ar[i]--;
	}
	fo(i,1,n)
	{
		if(ar[i]<ar[i-1])
			return cout<<"No",0;
	}
	cout<<"Yes";


}



/*     cd onedrive\desktop\kod
cls


*/

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

#define inf 0x3f3f3f3f

using namespace std;

typedef long long ll;

int i, j;
string s;
int n;
ll dp[100001][13] = {0};
const ll mod = 1e9 + 7;

void solve() {
  int n;
  cin >> n;
  vector<int> data(n);
  for (i = 0; i < n; ++i) cin >> data[i];
  int pre = 0;
  for (i = 0; i < n; ++i) {
    if (pre <= data[i] - 1) {
      pre = data[i] - 1;
    } else if (pre <= data[i]) {
      pre = data[i];
    } else {
      puts("No");
      return;
    }
  }
  puts("Yes");
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}

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

using namespace std;
const int N = 200000 + 10;
typedef long long ll;
int a[N], l[N], r[N];
int main()
{
    int n;
    scanf("%d", &n);
    ll sum = 0;
    for(int i = 0; i<n; i++)
        scanf("%d", &a[i]), sum += a[i];
    ll res = 0;
    ll ans = 1LL<<60;
    for(int i =0; i<n-1; i++)
    {
        res += a[i];
        ans = min(ans, abs(res -  (sum-res)));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,a,b;
    cin >> n;
    b = n/100;
    a = n%100;
    
    bool ym = true;
    bool my = true;

    if(0 == a || a>12) ym = false;
    if(0 == b || b>12) my = false;

    if(ym && my) cout << "AMBIGUOUS" <<endl;
    else if(~ym && my) cout << "MMYY" << endl;
    else if(ym&&~my) cout << "YYMM" << endl;
    else cout << "NA" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<map>
#include<algorithm>
#include<queue>
#include <functional>
using namespace std;

int main(){
  
  int a,b,n,root;
  int x[111],y[111];

  while(1){
    int mapp[1111][1111]={0};
    cin >> a >> b;
    if(a == 0 && b == 0)break;
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> x[i] >> y[i];
      mapp[x[i]][y[i]]=-1;
    }
    mapp[1][1]=1;
    for(int i=1;i<=a;i++){
      for(int j=1;j<=b;j++){
	if(mapp[i][j]!=-1){
	  if(i!=1 && mapp[i-1][j]!=-1){
	    mapp[i][j]+=mapp[i-1][j];
	  }
	  if(j!=1 && mapp[i][j-1]!=-1){
	    mapp[i][j]+=mapp[i][j-1];
	  }
	}
      }
    }
    cout << mapp[a][b] << endl;
  }
}

Measured memory_bytes: 5988
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const double EPS = 1e-11;
const double PI = 2 * acos(0.0);
using ll = long long;
using ull =  unsigned long long;

#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define pf printf
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sll(x,y) scanf("%lld %lld",&x,&y)

#define pii pair<int,int>
#define nl '\n'
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define uniq(a) a.erase(unique(a.begin(), a.end()), a.end())
#define out(x) cout <<"#x = "<<x<<endl
#define outt(x,y) cout <<"# "<<x<<" "<<y<<endl
#define mem(array,value) memset(array,value,sizeof(array))
#define MX 10005

int h[100007];
int n,k;
int dp[100007];

int solve(int pos)
{
	if(pos==n)return 0;
	if(dp[pos]!=-1)return dp[pos];
	int a=abs(h[pos]-h[pos+1])+solve(pos+1);
	for(int i=2;i<=k;i++){
		if(pos+i<=n)a=min(a,abs(h[pos]-h[pos+i])+solve(pos+i));
	}
	return dp[pos]=a;
}
int main()
{
	mem(dp,-1);
	cin >>n>>k;

	for(int i=1;i<=n;i++)cin >>h[i];

	cout <<solve(1)<<endl;
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int W, H; cin >> W >> H;
  ll p[W]; rep(i,W) cin >> p[i];
  ll q[H]; rep(i,H) cin >> q[i];

  ll result = 0;
  rep(i,W) result += p[i];
  rep(i,H) result += q[i];

  sort(q,q+H);
  ll qs[H+1] = {}; rep(i,H) qs[i+1] = qs[i] + q[(H-1)-i];
  rep(i,W) {
    auto ite = upper_bound(q, q+H, p[i]);
    int pos = (q+H) - ite;
    result += qs[H] - qs[pos] + p[i] * pos;
    // cout << i << " " << p[i] << " " << pos << endl;
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//ワーシャルフロイト法のテンプレ.graphに最短経路が格納される.
//負の重みがある場合inf + const = inf に気を付けること.
//graphは隣接行列.
void WF(vector<vector<int>> &graph){
	int n = graph.size();
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
			}
		}
	}
}

//素因数分解をする関数.
map<long long int, int> prime_factorization(long long int a)
{
	map<long long int, int>ans;
	for (long long i = 2; i*i <= a; ++i) {
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;
	return ans;
}

int main()
{
	int d, t, s;
	cin >> d >> t >> s;
	if (d )
	if (d <= t * s){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
	
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
long long int factorial(long long int);
int main(){
	int n,m;
	cin>>n>>m;
	if(n-m==0){
		cout<<(2*factorial(n)*factorial(m))%1000000007<<endl;
	}
	else if(n-m==1 || n-m==-1){
		cout<<(factorial(n)*factorial(m))%1000000007<<endl;
	}
	else{
		cout<<"0"<<endl;
	}
	return 0;
}
long long int factorial(long long int M){
	int some;
	some=M;
	for(int i=1;i<some;i++){
		M=M*i%1000000007;
	}
	return M;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    cout << ((B % A == 0) ? (A + B) : (B - A)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------
string digit(int n, int k){
  string s;
  if(k==0){s="0";}
  while(k>0){
    if(k%2==0){
      s.push_back('0');
    } else {
      s.push_back('1');
      k -= 1;
    }
    k/=2;
  }

  while(s.size()<n){
    s.push_back('0');
  }
  return s;
}

int main(void) {
  int n;
  cin >> n;
  vector<vector<pair<int,char>>> a;

  rep(i,n){
    int num;
    cin >> num;
    vector<pair<int,char>> tmp(num);
    a.push_back(tmp);
    rep(j,num){
      int x;
      char y;
      cin >> x >> y;
      x--;
      a[i][j]=make_pair(x, y);
    }
  }
  /*
  rep(i,a.size()){
    cout << i << " ------->" << endl;
    rep(j,a[i].size()){
      cout << a[i][j].first << " " << a[i][j].second << endl;
    }
  }
  */

  int ans=0;
  rep(i,pow(2,n)){
    string s = digit(n, i);
    int anstmp=0;
    rep(l,s.size()){if(s[l]=='1'){anstmp++;}}
    //prt3("pattern", s, anstmp);
    bool ok=true;

    rep(j,a.size()){
      if(s[j]=='0'){continue;}
      rep(k,a[j].size()){
        if(s[a[j][k].first]!=a[j][k].second){
          //prt2(s[a[j][k].first], a[j][k].second);
          ok=false;
          //prt3("break!--->", j, k);
        }
      }
    }

    if(ok){
      //prt("OK!!!!!");
      ans = max(ans, anstmp);
    }
  }

  prt(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
vector<vector<ll>> G(200010);
vector<ll> cnt(200010, 0);

void dfs(ll v, ll p, ll prev_cnt) {
  cnt[v] += prev_cnt;
  for (auto x : G[v]) {
    if (x == p) continue;
    dfs(x, v, cnt[v]);
  }
  return;
}

int main() {
  ll N, Q;
  cin >> N >> Q;
  REP(i, N - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  REP(i, Q) {
    ll p, q;
    cin >> p >> q;
    p--;
    cnt[p] += q;
  }

  dfs(0, 200001, 0);

  REP(i, N) { cout << cnt[i] << " "; }

  return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	string s;
	bool sw = true;
	vi ans('z' - 'a' + 1, 0);
	cin >> s;
	rep(i, s.size()) {
		ans[s[i] - 'a']++;
	}
	rep(i, ans.size()) {
		if (ans[i] % 2)sw = false;
	}
	cout << (sw?"Yes":"No") << endl;
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#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(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#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 Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    vec a(3); cin >> a;
    Sort(a);

    if(a[0] == a[1] && a[1] != a[2]) Out("Yes");
    else if(a[0] != a[1] && a[1] == a[2]) Out("Yes");
    else Out("No");

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int x=0;
  int ma=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='I'){
      x++;
    }else if(S.at(i)=='D'){
      x--;
    }
    if(ma<x){
      ma=x;
    }
  }
  cout << ma << endl;
  return 0;
}


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

int main() 
{
	int n,k;
	cin>>n>>k;
	vector<int> v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	
	sort(v.begin(),v.end());
	
	int ans = 0;
	for(int i = 0;i<k;i++)
	{
		ans += v[i];
	}
	
	cout<<ans<<endl;
	
	// your code goes here
	return 0;
}

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

int a[10];
bool flag;

void dfs(int x, int l, int r){
	if(x == 10){
		flag = true;
		return;
	}
	if(a[x] > l)
		dfs(x+1, a[x], r);
	else if(a[x] > r)
		dfs(x+1, l, a[x]);
	else flag = false;
}
int main(){
	int N;
	scanf("%d", &N);
	while(N--){
		memset(a, 0, sizeof(a));
		for(int i = 0; i < 10; i++) scanf("%d", &a[i]);
		flag = false;
		dfs(0, 0, 0);
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 2604
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100009],R[100009];
main(){
    ll n;
    cin >> n;
    for(ll i = 0; i <= n; i++){
        cin >> a[i];
    }
    ll r = 1;
    ll inf = 1e18;
    for(ll i = 0; i < n; i++){
        if(a[i] > r) {cout << -1 <<endl; return 0;}
        R[i] = r;
        r = (r - a[i]) * 2;
        if(r > inf) r = inf;
    }
    if(a[n] > r){
        cout<<-1<<endl;
        return 0;
    }
    ll x = a[n];
    ll ans = 0;
    for(ll i = n; i >= 0; i--){
        ans += x;
        x = min(R[i-1],  x+ a[i-1]);
    }
    cout<<ans<<endl;

}



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

bool isPrime(int a)
{
    for (int i = 3; i <= sqrt(a); i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if (a == 2)
        {
            ans++;
        }
        else if (a % 2 != 0)
        {
            if (isPrime(a))
            {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3088
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int Max = 0;
		int res = 0;
		for(int i=0;i<3;i++) {
			int t = nextInt();
			res += t;
			Max = Math.max(t,Max);
		}
		out.println(res-Max);
	}

	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}

}

Measured memory_bytes: 21844