akhauriyash/Code-Regression huggingface dataset:
import itertools

n = int(input().strip())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
p_cnt = 0
q_cnt = 0
for i, e in enumerate(sorted(list(itertools.permutations(p)))):
    if p == e:
        p_cnt = i
    if q == e:
        q_cnt = i
print(abs(p_cnt - q_cnt))


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

using namespace std;

long long int gcd(long long int a, long long int b){
    return (a == 0) ? b : gcd(b % a, a);  
} 
    
long long int lcm(long long int a, long long int b){  
    return (a*b)/gcd(a, b);
} 

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

    long long int a, b;
    cin >> a >> b;

    cout << lcm(a, b) << "\n";

    return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

#define LL long long

using namespace std;

int main()
{
    LL N, P;
    cin >> N >> P;
    if(1 == N)
    {
        cout << P << endl;
        return 0;
    }

    LL ans = pow(P, 1.0/N) + 1;
    for(; ans >= 1; ans--)
    {
        if((P % (LL)pow(ans, N)) == 0)
        {
            break;
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
const int mod = 1000000007;
signed main(){
    int n, k, r=1, a, b, c;
    cin >> n >> k;
    for (int t = k;t<=n;++t){
        a = t * n % mod;
        b = (t * (t - 1) - 1) % mod;
        r = (r + (a - b + mod)) % mod;
    }
    cout << r;
}

Measured memory_bytes: 3672
// AtCoder Grand Contest 011
// C - Squared Graph

#include <cstdio>
#include <cstring>
#include <vector>
#define MAX_N 100000
using namespace std;
typedef long long int ll;


int N, M;
vector<int> G[MAX_N];
int color[MAX_N];
ll ans;

bool dfs(int v, int c) {
  bool is_bipartite = true;
  if (color[v] != 0) {
    return (color[v] == c);
  }
  color[v] = c;
  for (int e = 0; e < (int)G[v].size(); e++) {
    is_bipartite = dfs(G[v][e], -color[v]) && is_bipartite;
  }
  return is_bipartite;
}

int main() {

  int u, v;
  ll a, b, c;

  scanf("%d%d", &N, &M);
  for (int j = 0; j < M; j++) {
    scanf("%d%d", &u, &v);
    G[u - 1].push_back(v - 1);
    G[v - 1].push_back(u - 1);
  }
  memset(color, 0, sizeof(color));

  a = b = c = 0;
  for (int i = 0; i < N; i++) {
    if (color[i] != 0) {
      continue;
    }
    if (G[i].empty()) {
      c++;
      color[i] = 1;
    } else {
      if (dfs(i, 1)) {
        a++;
      } else {
        b++;
      }
    }
  }
  ans = (a + b) * (a + b) + a * a + 2 * N * c - c * c;
  printf("%lld\n", ans);

  return 0;

}




Measured memory_bytes: 9984
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

ll gcd(ll a, ll b) {
	if (a == 0 || b == 0) return 0;
	if (a < b) swap(a, b);
	while (b != 0) {
		a = a%b;
		swap(a, b);
	}
	return a;
}

ll lcm(ll a, ll b) {
	if (a == 0 || b == 0) return 0;
	return a / gcd(a, b)*b;
}


int main() {
	int N;
	cin >> N;
	VL T(N);
	cin >> T[0];
	FOR(i, 1, N) {
		cin >> T[i];
		T[i] = lcm(T[i - 1], T[i]);
	}
	cout << T[N - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> vo,ve;

    REP(i,n) {
        int x; cin >> x;
        if (i % 2 == 0) ve.push_back(x);
        else vo.push_back(x);
    }
    reverse(ALL(vo));
    vector<int> v(vo);
    v.insert(v.end(),ALL(ve));
    if (n % 2 == 1) reverse(ALL(v));

    string ans = "";
    REP(i,n-1) {
        ans += to_string(v[i]) + " ";
    }
    ans += to_string(v[n-1]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6252
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int a, b;
    cin >> a >> b;
    int m = min(a, b);
    int M = max(a, b);
    rep(i, M) cout << m;
    cout << '\n';

    return 0;
}



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

int main(){
  long long N,K,Q;
  cin >> N >> K >> Q;
  vector<long long> A(N);
  for(int i=0;i<Q;i++){
    int X;
    cin >> X;
    A[X-1]++;
  }
  for(int i=0; i<N; i++){
    if(K+A[i]-Q > 0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}


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

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

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    string s;
    cin >> s;
    int a = 0, b = 0, c = 0, d = 0;
    REP(i, s.size()) {
        if(s[i] == 'S') a++;
        else if(s[i] == 'N') b++;
        else if(s[i] == 'W') c++;
        else d++; 
    }

    bool ue;
    if(a == 0) {
        if(b == 0) ue = true;
        else ue = false;
    } else {
        if(b == 0) ue = false;
        else ue = true;
    }

    bool shita;
    if(c == 0) {
        if(d == 0) shita = true;
        else shita = false;
    } else {
        if(d == 0) shita = false;
        else shita = true;
    }

    //cout << ue << " " << shita << endl;

    if(shita && ue) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main()
{
vector<int> d(7);
int q;
for(int i=1;i<7;i++){cin >> d[i];}
cin >> q;
for(int i=0;i<q;i++)
{
int t,f,o,ans;
o=0;
cin >> t >> f;
for(int j=1;j<7;j++){if(t==d[j])t=j;if(f==d[j])f=j;}
if(f>t){o=t;t=f;f=o;o=1;}
if(t==2)ans=4;
else if(t==3){if(f==1)ans=2;else ans=6;}
else if(t==4){if(f==1)ans=5;else ans=1;}
else if(t==5){if(f==1)ans=3;else if(f==3)ans=6;else ans=1;}
else {if(f==2)ans=4;else if(f==3)ans=2;else if(f==4)ans=5;else ans=3;}
if(o!=0)ans=7-ans;
cout << d[ans] << endl;
}
}


Measured memory_bytes: 3100
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort();b.sort();c.sort()
#print(a,b,c)
ans=0
for i in range(n):
    x=bisect.bisect_left(a,b[i])
    y=bisect.bisect_right(c,b[i])
    #print(x,y)
    ans+=x*(n-y)
print(ans)

Measured memory_bytes: 22720
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int n, k = 0;
  cin >> n;
  vector<ll> a(n), s;
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  a.push_back(0);
  for(int i = 0; i < n + 1; i++) {
    if(a.at(k) != a.at(i)) {
      if(i - k > 3)
        s.push_back(a.at(k));
      if(i - k > 1)
        s.push_back(a.at(k));
      k = i;
    }
  }
  sort(s.begin(), s.end(), greater<ll>());
  if(s.size())
    cout << s.at(0) * s.at(1) << endl;
  else
    cout << 0 << endl;
}

Measured memory_bytes: 1904
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  for(j = 2; j <= n; j++){
    key = A[j];
    i = j -1;
    while(i > 0 && A[i] > key){ 
      A[i+1] = A[i];
      i--;
      A[i+1] = key;
    }
    trace(A, n);
  }
  return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
#include <stdio.h>

int main()
{
    int n,w[100],sum[101];
    scanf("%d",&n);
    sum[0] = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&w[i]);
        sum[i + 1] = sum[i] + w[i];
    }
    
    int min = 100;
    for (int i = 1; i < n; i++)
    {
        if(abs(sum[i] * 2 - sum[n]) < min)
        {
            min = abs(sum[i] * 2 - sum[n]);
          	//printf("%d ",min);
        }  
    }
    printf("%d",min);
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class AConnectionAndDisconnection {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        ll k,ans=0;
        string s;
        in>>s>>k;
        if(s.length()==1){
            out<<k/2<<endl;
            return;
        }
        if(s.length()==2){
            if(s[0]==s[1]){
                out<<k<<endl;
                return;
            }
            else{
                out<<0<<endl;
                return;
            }
        }
        if(*s.begin()==*s.rbegin()){
            char c=*s.begin();
            int a=0;
            int t=0;
            while(s[a]==c){
                ++a;
                ++t;
                if(a==s.length()-1){
                    out<<(s.length()*k)/2<<endl;
                    return;
                }
            }
            int b=s.length()-1;
            while(s[b]==c){
                --b;
                ++t;
            }
            ans+=(a/2)+(t-a)/2+(t/2)*(k-1);
            int A=1;
            for(int i=a;i<b;++i){
                if(s[i]==s[i+1]){
                    ++A;
                    continue;
                }
                else{
                    ans+=(A/2)*k;
                    A=1;
                }
            }
            ans+=(A/2)*k;
            out<<ans<<endl;
            return;
        }
        int a=1;
        fr(i,s.length()-1){
            if(s[i]==s[i+1]){
                ++a;
                continue;
            }
            else{
                ans+=(a/2)*k;
                a=1;
            }
        }
        ans+=(a/2)*k;
        out<<ans<<endl;
    }
};

int main() {
    AConnectionAndDisconnection solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <limits.h>

#define N 100

int main()
{
    int n;
    int p[N + 1];
    int m[N + 1][N + 1];

    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d %d", &p[i - 1], &p[i]);
    }

    for (int i = 1; i <= n; i++) {
        m[i][i] = 0;
    }

    for (int l = 2; l <= n; l++) {
        for (int i = 1; i <= n - l + 1; i++) {
            int j = i + l - 1;
            m[i][j] = INT_MAX;
            for (int k = i; k <= j - 1; k++) {
                int cost = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
                m[i][j] = (m[i][j] < cost) ? m[i][j] : cost;
            }
        }
    }

    printf("%d\n", m[1][n]);
    return 0;
}


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

ll gcd(ll a, ll b){
// 結合法則も成り立つ
    if(a < b) return gcd(b, a);
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), left(n), right(n);
    rep(i, 0, n) cin >> a[i];
    left[0] = a[0]; right[n-1] = a[n-1];
    
    rep(i, 1, n) left[i] = gcd(a[i], left[i-1]);
    for(ll i = n-2; i >= 0; i--) right[i] = gcd(a[i], right[i+1]);

    ll ans = right[1]; // a0消したとき
    rep(i, 1, n-1) ans = max(ans, gcd(left[i-1], right[i+1])); // a1 - an-1
    ans = max(ans, left[n-2]); // an消したとき
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main()
{
  int n;
  string s;
  cin >> n;
  cin >> s;
  
  // . = 白
  // # = 黒
  // #の後に.が来たらだめ
  // 大丈夫なパターンは
  // 1, ###############
  // 2, .......########
  // 3, ...............
  
  // パターン１にする場合
  int p1 = 0;
  for (int i=0; i<s.size(); ++i) {
    if (s[i] != '#') {
      p1++;
    }
  }
  
  // パターン3にする場合
  int p3 = 0;
  for (int i=0; i<s.size(); ++i) {
    if (s[i] != '.') {
      p3++;
    }
  }
  
  // パターン２にする場合
  vector<int> whiteNums;
  int whiteCount = 0;
  int p2 = 200000;
  for (int i=0; i<s.size(); ++i) {
    if (s[i] == '.') {
      whiteCount++;
    }
    whiteNums.push_back(whiteCount);
  }
  for (int i=0; i<s.size(); ++i) {
    int numBlack = i+1 - whiteNums[i];
    int numWhite = whiteNums[s.size()-1] - whiteNums[i];
    //cout << numBlack << ',' << numWhite << endl;
    p2 = min(p2, numBlack+numWhite);
  }
  
  int answer = 0;
  answer = min(p1, p2);
  answer = min(answer, p3);
  
  cout << answer << endl;

  return 0;
}


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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pull pair<ull, ull>
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	
	bool no=1;
	while(n){
		if(n%10 == 7){
			no=0;
			break;
		}
		n /= 10;
	}
	
	if(no)cout << "No";
	else cout << "Yes";
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  vector<vector<int>> A(K);
  for (int i = 0; i < K; ++i) {
    cin >> d[i];
    A[i].resize(d[i]);
    for (int j = 0; j < d[i]; ++j) {
      cin >> A[i][j];
    }
  }

  vector<int> snuke(N);
  for (int i = 0; i < K; ++i) {
    for (int j = 0; j < d[i]; ++j) {
      ++snuke[A[i][j] - 1];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (snuke[i] == 0) {
      ++ans;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[60];

int main() {
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  rep(i,0,v.sz){
    rep(j,0,60){
      if((v[i]>>j)&1LL){
        d[j]++;
      }
    }
  }
  ll ans1 = 0;
  rep(i,0,60){
    if(d[i]%2==1){
      ans1 += 1LL<<i;
      ll mask = (1LL<<60)-1LL;
      mask ^= (1LL<<i);
      rep(j,0,v.sz){
        v[j] &= mask;
      }
    }
  }
  ll sum = 0;
  rep(i,0,v.sz){
    sum ^= v[i];
  }
  ll index = 0;
  per(i,0,60){
    ll flag = 0;
    rep(j,index,v.sz){
      if(v[j]&(1LL<<i)){
        flag = 1;
        swap(v[index],v[j]);
        break;
      }
    }
    rep(j,index+1,v.sz){
      if(v[j]&(1LL<<i)){
        v[j]^=v[index];
      }
    }
    if(flag==1){
      index++;
    }
  }
  ll mx = 0;
  rep(i,0,v.sz){
    ll a = mx^v[i];
    if(a>mx)mx^=v[i];
  }
  cout << (ans1 + mx + (mx^sum)) << endl;
  return 0;
}

Measured memory_bytes: 1400
import collections
n = int(input())
a = list(map(int,input().split()))
b = list(set(a))
c = collections.Counter(a)
ans = 0
for i in range(len(b)):
    if c[b[i]] >= 2:
        ans += c[b[i]] - 1
print(n-2*(-(-ans//2)))

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int3(k, a, b);
    int ans = 1;
    if (b - a >= 2) {
        if (a-1 <= k) {
            ans = a;
            k -= a-1;
            ans += (k / 2) * (b - a);
            ans += k % 2;
        } else {
            ans += k;
        }
    } else {
        ans += k;
    }
    std::cout << ans << std::endl;


    return 0;
}


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

int main(){
  int t;
  while((cin >> t), t){
    int num=0;
    t = 1000-t;
    while(t>=500){
      num++;
      t-=500;
    }
    while(t>=100){
      num++;
      t-=100;
    }
    while(t>=50){
      num++;
      t-=50;
    }
    while(t>=10){
      num++;
      t-=10;
    }
    while(t>=5){
      num++;
      t-=5;
    }
    while(t>=1){
      num++;
      t-=1;
    }
    cout << num << endl;
  }
  return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    int cnt = 0;
    for (int i = 0; i < N-2; i++) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, K = [int(x) for x in input().split()]
D = [str(x) for x in input().rstrip().split()]
D = set(D)
for i in range(N, N + 10 ** 6):
    i_list = list(str(i))
    flag = 1
    for j in i_list:
        if j in D:
            flag = 0
            break
    if flag:
        print(i)
        sys.exit()
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007ll
#define mod1 998244353ll
#define endl '\n'
#define inf ((ll)1e18+1)
#include<chrono>
using namespace chrono;
mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define deb(x) cout<<"-->  "<<#x<<" :  "<<x<<endl;
#define debr(x,y) {cout<<"-->  "<<#x<<" to "<<#y<<" :  "; auto itr=x; while(itr!=y) cout<<(*itr++)<<' '; cout<<endl; }
#define deba(x) {cout<<"-->  "<<#x<<" :  "; for(auto ele:(x)) cout<<ele<<"  "; cout<<endl; }


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }
    return 0;
}

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

int main(){
	int n;
    cin >> n;
	vector<int> vc(n);
	int x, sum=0;
	for (int i=0;i<n;i++){
		cin >> x;
		sum += x;
		vc.at(i) = sum;
	}
	int min = 100;
	int s1, s2, s3;
	for (int i=0;i<n;i++){
		s1 = vc.at(i);
		s2 = sum - s1;
		if (s1<s2){
			s3 = s2 - s1;
		}
		else{
			s3 = s1 - s2;
		}
		if (s3<min){
			min = s3;
		}
	}
	cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b,c,d;
  string s;
  cin >>s;
  bool yes=true;
  if(s.size()%2!=0) yes=false;
  for(int i=0;i<s.size();i+=2){
    if(s[i]!='h'||s[i+1]!='i') yes=false;
  }
  if(yes) cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end())
#define PSort(x) sort(begin(x), end(x), pairCompare)
#define ll long long
#define INF 2000000000
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.14159265358979
int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
using namespace std;
bool f = false;
vector<int> v(20);
int a, b, c;

void dfs(int sum,int i) {
	if (f)return;
	if (i >= 20)return;
	if (sum%b == c)f = true;

	dfs(sum + v[i], i + 1);
	dfs(sum, i + 1);

	return;
	
}
int main(){	
	cin >> a >> b >> c;
	for (int i = 0; i < 20; i++) {
		v[i] = a*(i + 1);
	}
	dfs(0, 0);
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
	
	
	return 0;
}



Measured memory_bytes: 256
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
sorted(n)
k = int(input())
print(n[k-1])

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>

typedef long long LL;
using namespace std;

void read(int &v){int k=0,l=1;char ch;ch=getchar();while (ch>'9' || ch<'0'){if (ch=='-') l=-1;ch=getchar();}while (ch>='0' && ch<='9') k=k*10+ch-'0',ch=getchar();v=l*k;}
void print(int v){if (v<0) putchar('-'),v=-v;if (v>9) print(v/10);putchar(v%10+'0');}
int max(int a, int b) { return a>b ? a: b;}
int min(int a, int b) { return a<b ? a: b;}

static int x, n;

int main() {
        read(n);
        int k = 0;
        for (int i = 1; i <= n; ++i )
                read(x), k ^= x;
        if (k == 0) cout << "Yes"; 
                else cout << "No";
        return 0;
}

Measured memory_bytes: 384
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int N;
	cin >> N;
	VI T(N);
	FOR(i, 0, N)
		T[i] = IN<int>();
	int M;
	cin >> M;
	FOR(i, 0, M) {
		int P, X;
		LL ans = 0;
		cin >> P >> X;
		FOR(j, 0, N) {
			if (P - 1 == j)
				ans += X;
			else
				ans += T[j];
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  bool f=1;
  rep(i,n){
    if(a[i]!=0) f=0; 
  }
  if(f){
    cout << "Yes" << endl;
    return 0;
  }
  if(n%3!=0){
    cout << "No" << endl;
    return 0;
  }
  map<ll,int> mp;
  rep(i,n){
    mp[a[i]]++;
  }
  if(mp.size()==3){
    bool f=1;
    vector<ll> v(0);
    for(auto c:mp){
      v.push_back(c.first);
      if(c.second!=n/3) f=0;
    }
    if((v[0]^v[1]^v[2])!=0) f=0;
    if(f){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(mp.size()==2){
    bool f=0,f1=0,f2=0;
    for(auto c:mp){
      if(c.first!=0&&c.second==2*n/3) f1=1;
      if(c.first==0&&c.second==n/3) f2=1;
    }
    if(f1&&f2) f=1;
    if(f){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

#define REP(i, n) for (int i = 0; i < (int)(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 ALL(v) v.begin(), v.end()

int main() {
  string S;
  cin >> S;
  bool ans = true;
  REP(i ,S.size()) {
    if (S[i] == 'U' || S[i] == 'D') {
		continue;
    }
    if (i % 2 == 0) {
      if (S[i] == 'R') {
        continue;
      }
    } else {
      if (S[i] == 'L') {
        continue;
      }
    }
    ans = false;
    break;
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char s[100020];
    scanf("%s",s);
    if (s[0]==s[strlen(s)-1] && strlen(s)%2==0){
        printf("First\n");
    } else if (s[0]!=s[strlen(s)-1] && strlen(s)%2!=0){
        printf("First\n");
    } else {
        printf("Second\n");
    }
	return 0 ;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define vint vector<int>


int main(){
	long long n;
	cin >> n;
	
	
	long long a;
	vector<char> c;
	while(true){
		n--;
		a = n%26;
		
		c.push_back((char)((int)'a'+a));
		
		n = n/26;
		
		if(n==0) break;
	}
	
	
	for(long long i=(long long)c.size()-1; i>=0; i--) cout << c[i];
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3628
while True:
    num,total = map(int, input().split())
    if num == 0 and total == 0:
        break

    seen = set()
    for idx1 in range(1, num+1):
        for idx2 in range(idx1+1, num+1):
            candidate = total - (idx1 + idx2)
            if 1 <= candidate <= num and idx1 != candidate and idx2 != candidate:
                combo = tuple(sorted([idx1, idx2, candidate]))
                seen.add(combo)
    print(len(seen))


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = 1e18;
constexpr ll MOD = 1e9+7;
#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 ALL(v) v.begin(), V.end()

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

  if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9) {
    cout << "hon" << endl;
  } else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
    cout << "pon" << endl;
  } else if(N % 10 == 3) {
    cout << "bon" << endl; 
  }
  
}

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

bool comp(string s, string t){
	for(int i = 0; i < min(s.size(), t.size()); i++){
		if(s[i] < t[i]) return true;
		if(s[i] > t[i]) return false;
	}
	return s.size() <= t.size();
}

int getDist(const string& s, const string& t){
	int dp[20][20];
	for(int i = 0; i <= s.size(); i++) dp[i][0] = i;
	for(int i = 0; i <= t.size(); i++) dp[0][i] = i;

	for(int i = 1; i <= s.size(); i++)
		for(int j = 1; j <= t.size(); j++)
			dp[i][j] = min(min(dp[i - 1][j] + 1, dp[i][j - 1] + 1),
						   dp[i - 1][j - 1] + (s[i - 1] != t[j - 1]));
	return (dp[s.size()][t.size()]);
}

string name[256];

bool f(string s, string t, int d){
	if(s == t) return true;
	if(getDist(s, t) <= d) return true;

	if(d >= 1){
		// 1???????????????
		if(s.size() == t.size()){
			for(int i = 0; i < s.size() - 1; i++){
				swap(s[i], s[i + 1]);
				if(s == t) return true;
				swap(s[i], s[i + 1]);
			}
		}
	}
	if(d == 2){
		// 2???????????????
		if(s.size() == t.size()){
			for(int i = 0; i < s.size() - 1; i++){
				swap(s[i], s[i + 1]);
				for(int j = 0; j < s.size() - 1; j++){
					if(i == j) continue;
					swap(s[j], s[j + 1]);
					if(s == t) return true;
					swap(s[j], s[j + 1]);
				}
				swap(s[i], s[i + 1]);
			}
		}
		if(s.size() - 1 == t.size()){
			// ???????????£???????????????
			for(int i = 0; i < s.size() - 2; i++){
				swap(s[i], s[i + 2]);
				int l = i + 1, r = s.size() - 1 - l;
				string ss = s.substr(0, i + 1) + s.substr(i + 2, r);
				if(ss == t) return true;
				swap(s[i], s[i + 2]);
			}
		}
		if(t.size() - 1 == t.size()){
			// ???????????£???????????????
			for(int i = 0; i < t.size() - 2; i++){
				swap(t[i], t[i + 2]);
				int l = i + 1, r = t.size() - 1 - l;
				string tt = t.substr(0, i + 1) + t.substr(i + 2, r);
				if(tt == s) return true;
				swap(t[i], t[i + 2]);
			}
		}
		// 1?????????????????§??¨????????¢1
		for(int i = 0; i < s.size() - 1; i++){
			swap(s[i], s[i + 1]);
			if(getDist(s, t) <= 1) return true;
			swap(s[i], s[i + 1]);
		}
	}
	return false;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int n, d;
	while(cin >> n >> d, n){
		for(int i = 0; i < n; i++){
			cin >> name[i];
		}

		vector<pair<string, string>> ans;
		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				if(f(name[i], name[j], d)){
					string s1 = min(name[i], name[j], comp);
					string s2 = max(name[i], name[j], comp);
					ans.push_back({ s1, s2 });
				}
			}
		}
		sort(ans.begin(), ans.end());
		for(auto v : ans){
			cout << v.first + "," + v.second << endl;
		}
		cout << ans.size() << endl;
	}
}

Measured memory_bytes: 3224
n = int(input())
time = [i for i in map(int,input().split())]
m = int(input())
ch_time = []
for i in range(m):
    ch_time.append([i for i in map(int,input().split()) ])

for i in range(m) :
    num = ch_time[i][0]
    dif = ch_time[i][1] - time[num-1]
    print("{}".format(sum(time)+dif))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define int long long

signed main() {
	int N;
	cin >> N;
	vector<int> X(N), Y(N);
	for(int i = 0; i < N; ++i) {
		cin >> X[i] >> Y[i];
	}
	int p = (abs(X[0]) + abs(Y[0])) % 2;
	for(int i = 0; i < N; ++i) {
		if (p != (abs(X[i]) + abs(Y[i])) % 2) {
			cout << -1 << endl;
			return 0;
		}
	}
	int m = 36;
	vector<int> d(m);
	for(int i = 0; i < m - 1; ++i) {
		d[i] = 1LL << (m - 2 - i);
	}
	d[m - 1] = 1;
	if (p) {
		cout << m + 1 << endl;
		cout << "1 ";
	} else {
		cout << m << endl;
	}
	for(int i = 0; i < m; ++i) {
		cout << d[i] << (i == m -1 ? "\n": " ");
	}

	for(int i = 0; i < N; ++i) {
		int x, y;
		x = y = 0;
		if(p) {
			X[i]--;
			cout << "R";
			++x;
		}
		int U = X[i] + Y[i], V = X[i] - Y[i];
		vector<int> a(m), b(m);
		for(int j = 0; j < m; ++j) {
			if(U >= 0) {
				a[j] = 0;
				U -= d[j];
			} else {
				a[j] = 1;
				U += d[j];
			}
			if (V >= 0) {
				b[j] = 0;
				V -= d[j];
			} else {
				b[j] = 1;
				V += d[j];
			}
			if (a[j] == 0 && b[j] == 0) {
				x += d[j];
				cout << "R";
			} else if (a[j] == 0 && b[j] == 1) {
				y += d[j];
				cout << "U";
			} else if (a[j] == 1 && b[j] == 0) {
				y -= d[j];
				cout << "D";
			} else {
				x -= d[j];
				cout << "L";
			}
			//cerr << " " << x << "," << y << " " << U << "," << V << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>

int main(int argc, char *argv[]) {
  std::string s;
  std::cin >> s;

  int even = 0;
  for (size_t i = 0; i < s.size(); ++i) {
    if (i % 2 == 0 && s.at(i) == '0')
      ++even;
    if (i % 2 != 0 && s.at(i) == '1')
      ++even;
  }

  int odd = 0;
  for (size_t i = 0; i < s.size(); ++i) {
    if (i % 2 == 0 && s.at(i) == '1')
      ++odd;
    if (i % 2 != 0 && s.at(i) == '0')
      ++odd;
  }

  std::cout << std::min(even, odd) << std::endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;
// const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// struct edge {int to, cost;};
// vector<edge> graph[MAX];
// bool visited[MAX];
// int dist[MAX];

int main() {
    // input
    int n, q;
    cin >> n >> q;
    // solve
    dsu d(n);
    rep(i, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        } else if (t == 1) {
            if (d.same(u, v)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
}

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

int main() {
    int a, b;
    cin >> a >> b;

    if (a <= 8 && b <= 8) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }

    return 0;
}


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

int main(){
  
  string a;
  cin >> a;
  
  if( a == "A" ){
  
    cout << "T"  << endl;
    
  }
  
  else if( a == "T" ){
    
    cout << "A" << endl;
    
  }
  
  else if( a == "C" ){
    
    cout << "G" << endl;
    
  }
  
  else if( a == "G" ){
    
    cout << "C" << endl;
    
  }
  
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n, m;
    cin >> n >> m;
    //cout << ((n == m) ? "Yes" : "No");
    int res1 = 0, res2 = 0;
    for (int i = 0;i < n;i++) {
        res1 *= 10;
        res1 += m;
    }
    for (int i = 0;i < m;i++) {
        res2 *= 10;
        res2 += n;
    }
    stringstream ss1, ss2;
    string a, b;
    ss1 << res1;
    ss1 >> a;
    ss2 << res2;
    ss2 >> b;
    cout << min(a, b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int S[10][30000];
  vector<int>si(10, 0);
  for (int i = 0; i < N; i ++) {
    char c;
    cin >> c;
    int kj = (int)c - (int)'0';
    S[kj][si[kj]] = i;
    si[kj] ++;
  }
  for (int i = 0; i < 10; i ++) S[i][si[i]] = N;
  int ans = 0;
  for (int i = 0; i < 10; i ++) {
    for (int j = 0; j < 10; j ++) {
      if (!(si[i]) || !(si[j])) continue;
      int a = S[i][0];
      int b = S[j][si[j] - 1];
      for (int k = 0; k < 10; k ++) {
        if(!(si[k])) continue;
        int mi = 0;
        int ma = si[k];
        while(mi != ma) {
          int mu = (mi + ma) / 2;
          if (S[k][mu] > a) ma = mu;
          else mi = mu + 1;
        }
        if (S[k][mi] < b) ans ++;
      }
    }
  }
  cout << ans << endl;
}

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

#define ll long long int
#define pi 3.141592653589793238
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007


void solve()
{
    ll n;
    cin>>n;
    cout<<1-n;
    return;
}

int main()
{
    FAST;
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      #endif
    ll q;
    q=1;
    // sieve();
    // cin>>q;
    while(q--)
        solve();
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
// #include <unordered_map>
// #include <bitset>
// #include <iomanip>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define EPS 1e-9
#define LL_INF 0x3fffffffffffffff
#define MEM(a, b) memset(a, b, sizeof(a))
#define PPER(i, n, m) for (int i = n; i >= m; i--)
#define REPP(i, n, m) for (int i = n; i <= m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define PER(i, n, m) for (int i = n; i > m; i--)
#define SA(n) scanf("%d", &(n))
#define SLLA(n) scanf("%lld", &(n))
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define DE(val) cout << #val << ": " << val << endl;
// #define DBG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
// #else
// #define DBG(...) 42
// #endif
const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 0, 1,-1};
const int dy4[6] = {1, -1, 0,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};

void update(ll& x,ll v){
    if(x==-1)x=v;
    else if(x>v)x=v;
}
 
ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 1e5 + 15;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
#define mst(x, a) memset(x, a, sizeof(x))
/*************************************************************************/




int main()
{   

    //  ios::sync_with_stdio(false);
    //  cin.tie(nullptr);
    int x;
    SA(x);
    printf("%d\n", 1-x);
    return 0;
 
}


Measured memory_bytes: 3220
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0;i < n;i++){
        cin >> x[i];
    }

    int coord_max = *max_element(x.begin(),x.end());
    int coord_min = *min_element(x.begin(),x.end());

    int ans = INT32_MAX;
    for(int p = coord_min;p <= coord_max;p++){
        int tempans = 0;
        for(int i = 0;i < x.size();i++){
            tempans += (x[i] - p) * (x[i] - p);
        }
        ans = min(ans,tempans);
    }

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

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		long a = fs.nextLong(), b = fs.nextLong();
		
		int as[] = new int[50];
		if(a != 0) as = xorsum(a-1);
		int bs[] = xorsum(b);
		
		long res = 0;
		for(int i=0;i<50;i++) {
			if(as[i]!=bs[i]) res += pow(2,i); 
		}
		System.out.println(res);
	}
	
	static int[] xorsum(long x) {
		//各桁の1の数を数える
		int a[] = new int[50];
		for(int i=0;i<50;i++) {
			if(i==0) {
				a[i] = (int)(((x + 1)/2)%2);
			}
			else {
				long t = pow(2, i+1);
				long u = pow(2, i);
				long rem = (x+1) % t;
				if(rem <= u)a[i] = 0;
				else a[i] = (int)((rem - u) % 2);
			}
		}
		return a;
	}
	
	static long pow(long x, long p) {
		if(p == 0) return 1;
		if(p%2!=0) return x * pow(x, p-1);
		long t = pow(x, p/2);
		return t * t; 
	}
	
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

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

Measured memory_bytes: 23124