akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

int main() {
    long long n;
    cin >> n;
    vector<long long> as(n);
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        cnt[as[i]]++;
    }
    int sumbad = 0;
    sort(as.begin(), as.end());
    for (int i = 0; i <= 100000; i++) {
        if (cnt[i] > 1) {
            // cout << cnt[as[i]] << endl;
            sumbad += cnt[i] - 1;
        }
    }
    // cout << sumbad << endl;
    cout << n - (sumbad + (sumbad % 2)) << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

#define lef 0
#define rig 1
#define up 2
#define down 3

const int N = 200005;

int h, w, n;
int sx, sy;
string a, b;
int p1[N][4], p2[N][4];

int what(char c) {
  if (c == 'U') return up;
  if (c == 'D') return down;
  if (c == 'L') return lef;
  return rig;
}

int main() {
  cin >> h >> w >> n >> sx >> sy >> a >> b;
  for (int i = 0; i < a.size(); i++) {
    if (i > 0) {
      for (int j = 0; j < 4; j++) {
        p1[i][j] = p1[i - 1][j];
        p2[i][j] = p2[i - 1][j];
      }
    }
    p1[i][what(a[i])]++;
    p2[i][what(b[i])]++;
  }
  // lef
  int ty = sy;
  for (int i = 0; i < n; i++) {
    if (a[i] == 'L') ty--;
    if (ty <= 0 || ty > w) {
      cout << "NO" << endl;
      return 0;
    }
    if (b[i] == 'R' && ty < w) {
      ty++;
    }
  }
  // rig
  ty = sy;
  for (int i = 0; i < n; i++) {
    if (a[i] == 'R') {
      ty++;
    }
    if (ty <= 0 || ty > w) {
      cout << "NO" << endl;
      return 0;
    }
    if (b[i] == 'L' && ty > 1) {
      ty--;
    }
  }
  // up
  int tx = sx;
  for (int i = 0; i < n; i++) {
    if (a[i] == 'U') {
      tx--;
    }
    if (tx <= 0 || tx > h) {
      cout << "NO" << endl;
      return 0;
    }
    if (b[i] == 'D' && tx < h) {
      tx++;
    }
  }
  // down
  tx = sx;
  for (int i = 0; i < n; i++) {
    if (a[i] == 'D') {
      tx++;
    }
    if (tx <= 0 || tx > h) {
      cout << "NO" << endl;
      return 0;
    }
    if (b[i] == 'U' && tx > 1) {
      tx--;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

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

  int h, w, n;
  int tmp;
  deque<int> a[100];
  vector<int> f;
  cin >> h >> w >> n;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    for (int j = 0; j < tmp; j++) {
      f.push_back(i+1);
    }
  }

  int pos = 0;
  bool flag = true;
  for (int i = 0; i < h; i++) {
    if (flag) {
      flag = false;
      for (int j = 0; j < w; j++) {
        a[i].push_back(f[pos++]);
      }
    }
    else {
      flag = true;
      for (int j = 0; j < w; j++) {
        a[i].push_front(f[pos++]);
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << a[i][j] << ' ';
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#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>;
const int INF = 1001001001;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(si,h)rep(sj,w) {
        if (s[si][sj] == '#') continue;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x) {
            if (dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i,j));
        };
        update(si, sj, 0);
        while (!q.empty()) { 
            int i = q.front().first;
            int j = q.front().second; q.pop();
            rep(dir,4) {
                int ni = i+di[dir], nj = j+dj[dir];
                if (ni<0||ni>=h||nj<0||nj>=w) continue;
                if (s[ni][nj] == '#') continue;
                update(ni, nj, dist[i][j]+1);
            }
        }
        rep(i,h)rep(j,w) {
            if (dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std; 
#define fr for(int i = 0;i < n;i++)
#define pb push_back
void printVector(vector<char>x){
    for(auto i:x){
        cout << i << " ";
    }
    cout << endl;
}


int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    string s,t;
    cin >> s >> t;
    int _count = 0;
    for (int i = 0; i < t.length(); i++)
    {
        if(s[i] != t[i]) _count++;
    }
    
    cout << _count << endl;

    



}

Measured memory_bytes: 3776
import math
from functools import reduce

def gcd(a,b,c):
    return math.gcd(math.gcd(a,b),c)

k = int(input())

ans = 0
for a in range(1, k+1):
  for b in range(1, k+1):
    for c in range(1, k+1):
      if a==b:
        ans += math.gcd(a,c)
      elif a==c:
        ans += math.gcd(a,b)
      elif b==c:
        ans += math.gcd(a,b)
      else:
        ans += gcd(a,b,c)

print(ans)

Measured memory_bytes: 68884
#include<bits/stdc++.h>
using namespace std;
int linearSearch(int *,int,int);
int main(){
  int n,q,i,S[10000],T,count=0;
  cin>>n;
  for(i=0;i<n;i++)cin>>S[i];
  cin>>q;
  for(i=0;i<q;i++){
    cin>>T;
    if(linearSearch(S,T,n)!=-1)count++;
  }
  cout<<count<<endl;
  return 0;
}

int linearSearch(int A[],int key,int n){
  int i=0;
  while(A[i]!=key){
    i++;
    //cout<<A[i]<<en dl;
    if(i==n)return -1;
  }
  return i;
}
  



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

static inline bool IsOverflow(ull a, ull b)
{
    return a && b > std::numeric_limits<ull>::max() / a;
}

static inline bool IsNotOverflow(ull a, ull b)
{
    return a && b <= std::numeric_limits<ull>::max() / a;
}

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

    constexpr ull border = (ull)10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10;

    bool over = false;
    ull result = 1;
    for (int i = 0; i < n; ++i)
    {
        ull a;
        cin >> a;

        if (!a)
        {
            result = 0;
            over = false;
            break;
        }

        if (IsOverflow(result, a))
            over = true;

        result *= a;
        if (result > border)
            over = true;
    }

    if (over)
        cout << -1 << endl;
    else
        cout << result << endl;

    return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys

# def dist(N, X, Y, i, j):
#     print(i, j, flush=True)
#     if (i <= 0):
#         return 0
#     if (i == j):
#         return 0
#     if (abs(i - j) == 1):
#         return 1
#     if (i == X and j == Y):
#         return 1
#     m = N
#     if (i < N):
#         m = min(m, dist(N, X, Y, i+1, j))
#     if (i > 1):
#         m = min(m, dist(N, X, Y, i-1, j))
#     if (i == X):
#         m = min(m, dist(N, X, Y, Y, j))
#     if (i == Y):
#         m = min(m, dist(N, X, Y, X, j))
#     return 1 + m

def solve(N: int, X: int, Y: int):
    dist = dict()
    sc = Y - X - 1

    for i in range(1, N+1):
        for j in range(i+1, N+1):
            d = j - i
            if i <= X:
                if j >= Y:
                    d -= sc
                else:
                    d = min(d, (X - i) + (Y - j) + 1)
            elif i < Y:
                if j >= Y:
                    d = min(d, (i - X) + 1 + (j - Y))
                else:
                    d = min(d, (i - X) + 1 + (Y - j))

            #print(i, j, d)
            dist[d] = dist.get(d, 0) + 1

    #print(dist)
    for i in range(1, N):
        print(dist.get(i, 0))

    # d = dict()
    # for i in range(1, N+1):
    #     for j in range(i+1, N+1):
    #         r = dist(N, X, Y, i, j)
    #         d[r] = 1 + d.get(r, 0)
    # print(d)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, X, Y)

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back

constexpr auto inf = numeric_limits<int>().max() - 1;
constexpr auto llinf = numeric_limits<ll>().max() - 1LL;

template<typename ForwardIterator>
void dump(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << *it << " ";
	}
	cout << endl;
}

template<typename ForwardIterator>
void dump_map(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << (*it).first << ":" << (*it).second << " ";
	}
	cout << endl;
}
template<typename T>
void debug(initializer_list<T> list) {
  for (auto el : list) {
    cout << el << " ";
  }
  cout << endl;
}

constexpr ll mod = ll(1e9 + 7);

ll mult(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }

ll power(ll a, ll b) {
	ll result = 1LL;
	while (b) {
		if (b % 2LL) result = mult(result, a);
		a = mult(a, a);
		b /= 2LL;
	}
	return result;
}

ll divide(ll a, ll b) { return mult(a, power(b, mod - 2)); }

ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }

ll subtract(ll a, ll b) { return ((a - b) % mod + mod) % mod; }

ll a, b, n;

void solve() {
	cin >> a >> b >> n;
	if (n < b - 1LL) {
		cout << (a * n) / b;
	} else {
		cout << (a * (b - 1LL)) / b;
	}
	cout << "\n";
}

#define REPEAT 0
#define CASE 0

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#if REPEAT
		int t;
		cin >> t;
		repa(i, 1, t) {
			#if CASE
				cout << "Case #" << i << ": ";
			#endif
			solve();
		}
	#else
		solve();
	#endif
	return 0;
}


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

const int N = (int) 2e6 + 5 ;
const int inf = (int) 2e9 ;

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    long long arr[5] ;
    for( int i = 1 ; i <= 3 ; i++ ) scanf("%lld" , &arr[i] ) ;
    sort( arr + 1 , arr + 3 + 1 ) ;
    int k ; scanf("%d" , &k ) ;
    for( int i = 1 ; i <= k ; i++ ) {
        arr[3] *= 2LL ;
    }
    long long ans = 0 ;
    for( int i = 1 ; i <= 3 ; i++ ) ans += arr[i] ;
    cout << ans << endl ;

    return 0 ;
}


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

inline int kthbit(int A, int K) { return (A >> K) & 1; }

int main(){
    int N; cin >> N;
    vector<int> A(N+1,0);
    for(int i=1; i<=N; i++) cin >> A[i];

    vector<vector<int>> cnt = vector<vector<int>>(20, vector<int>(N+2,0));
    for(int i=1; i<=N; i++){
        int bit = 0;
        int a = A[i];
        while(a>0){
            if(a%2==1) cnt[bit][i]++;
            a/=2;
            bit++;
        }
    }
    for(int i=0; i<20; i++){
        for(int j=1; j<=N; j++){
            cnt[i][j] += cnt[i][j-1]; 
        }
        cnt[i][N+1] = 1e9;
    }

    ll ans = 0;
    for(int i=1; i<=N; i++){
        int len = 1e9;
        for(int j=0; j<20; j++){
            int d = 1;
            if(kthbit(A[i],j)==0) d++;

            int lenj = 1e9;
            lenj = lower_bound(cnt[j].begin(), cnt[j].end(),cnt[j][i] + d) - (cnt[j].begin() + i);
            len = min(len, lenj);
        }
        ans += len;
    }
    cout << ans << endl;
}



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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.14159bus2653589793238
using namespace std;

int32_t main() {
    nitin;
    string s;
    cin >> s;
    if (s[s.size() - 1] == 's')
    {
        s+="es";
        cout<<s<<endl;
    }
    else{
        s+='s';
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;

int N;
int p[MAX_N];

bool same[MAX_N];

void solve(){
	for(int i = 0; i < N; i++){
		if(p[i] - 1 == i) same[i] = true;
		else same[i] = false;
	}

	int cnt = 0;
	for(int i = 0; i < N; i++){
		if(same[i] == true){
			cnt++;
			i++;
		}
	}
	printf("%d\n", cnt);
}

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &p[i]);
	solve();
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,f,g,h,i;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
  int N;
  cin>>N;
  vector<int> aa(N);
  for(int j=0;j<N;j++){
    cin>>aa.at(j);
  }
  for(int j=0;j<N;j++){
    if(aa.at(j)==a){
      a=0;
    }
    if(aa.at(j)==b){
      b=0;
    }
    if(aa.at(j)==c){
      c=0;
    }
    if(aa.at(j)==d){
      d=0;
    }
    if(aa.at(j)==e){
      e=0;
    }
    if(aa.at(j)==f){
      f=0;
    }
    if(aa.at(j)==g){
      g=0;
    }
    if(aa.at(j)==h){
      h=0;
    }
    if(aa.at(j)==i){
      i=0;
    }
  }
  int flag=0;
  if(a==0&&b==0&&c==0){
    flag=1;
  }
  if(d==0&&e==0&&f==0){
    flag=1;
  }
  if(g==0&&h==0&&i==0){
    flag=1;
  }
  if(a==0&&d==0&&g==0){
    flag=1;
  }
  if(b==0&&e==0&&h==0){
    flag=1;
  }
  if(c==0&&f==0&&i==0){
    flag=1;
  }
  if(a==0&&e==0&&i==0){
    flag=1;
  }
  if(c==0&&e==0&&g==0){
    flag=1;
  }
  if(flag==1){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n,a,b,ans[1048576],d[1048576],c[1048576];
void solve(int s,int t,int a,int b,int l,int r){
    //cout<<s<<' '<<a<<' '<<b<<' '<<l<<' '<<r<<endl;
    if (l+2==r){
        ans[l]=a;
        ans[l+1]=b;
        return;
    }
    int p=-1;
    for (int i=0;i<n;i++)
        if (s&(1<<i)){
            if ((a&(1<<i))^(b&(1<<i))) {p=i;break;}
        }
    assert(p!=-1);
    s^=1<<p;
    //cout<<s<<endl;
    int mid=(l+r)>>1;
    for (int i=s;;i=(i-1)&s){
        if ((a&(1<<p))&&d[i|t|(1<<p)]!=d[a]){
            i|=t;
            solve(s,t|(1<<p),a,i|(1<<p),l,mid);
            solve(s,t,i,b,mid,r);
            return;
        }
        if ((b&(1<<p))&&d[i|t|(1<<p)]!=d[b]){
            i|=t;
            solve(s,t,a,i,l,mid);
            solve(s,t|(1<<p),i|(1<<p),b,mid,r);
            return;
        }
        if (!i) assert(0);
    }
}
int main(){
    cin >> n >> a >> b;
    for (int i=1;i<(1<<n);i++) d[i]=d[i/2]^(i%2);
    if (d[a]==d[b]) {puts("NO");return 0;}
    puts("YES");
    solve((1<<n)-1,0,a,b,0,1<<n);
    for (int i=1;i<(1<<n);i++) d[i]=d[i/2]+i%2;
    for (int i=0;i<(1<<n);i++) c[ans[i]]++;
    for (int i=0;i<(1<<n);i++) assert(c[i]==1);
    for (int i=1;i<(1<<n);i++) assert(abs(d[ans[i]]-d[ans[i-1]])==1);
    for (int i=0;i<(1<<n);i++) printf("%d ",ans[i]);puts("");
    return 0;
}


Measured memory_bytes: 5632
// C + T = X
// 2 * C + 4 * T = Y
// T = X - C
// 2 * C + 4 * (X - C) = Y
// - 2 * C = Y - 4 * X
// C = 2 * X - Y / 2
// T = -X + Y / 2
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ").map(Number);
    const X = arr[0];
    const Y = arr[1];
    const C = 2 * X - (Y / 2) | 0;
    const T = -X + (Y / 2) | 0;
    console.log(0 <= C && 0 <= T && C + T === X && 2 * C + 4 * T === Y ? "Yes" : "No");
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29612
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

int main() {
  int in(N); int in(M);

  vi H(N);
  vector<bool> ok(N, true);
  rep(i, N) {
    cin >> H[i];
  }

  rep(i, M) {
    int in(A);
    int in(B);
    --A, --B;
    if (H[A] < H[B])
      ok[A] = false;
    if (H[A] == H[B])
      ok[A] = ok[B] = false;
    if (H[A] > H[B])
      ok[B] = false;
  }

  int ans = 0;
  rep(i, N) {
    if (ok[i])
      ++ans;
  }
  cout << ans << endl;
  return 0;
}


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

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

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

	ll N;
	cin >> N;
	for(ll h = 1; h <= 3500; h++){
		for(ll n = 1; n <= 3500; n++){
			ll b = N * h * n;
			ll a = 4 * h * n - N * n - N * h;
			if(b > 0 && a > 0 && b % a == 0){
				cout << h << " " << n << " " << b / a << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

from itertools import permutations

B=sorted(P)
PMT=list(permutations(B))

#print(PMT)
p=PMT.index(tuple(P))
q=PMT.index(tuple(Q))
print(abs(p-q))

Measured memory_bytes: 8052
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    
    int a, p;
    cin>>a>>p;
    cout<<(a*3 +p)/2<<endl;
    
    
    return 0;
}



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

using namespace std;

int main ( void ) {
    int N;
    cin >> N;
    vector<int> a;
    int tmp;
    int cnt = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> tmp;
        a.push_back(tmp);
    }
    std::sort(a.begin(),a.end());

    int num = 1;

    for ( int i = 0; i < N; i++ ) {
        if ( a[i] == a[i+1] ) {
            num++;
        } else {
            if (num % 2 == 1) {
                cnt++;
            }
            num=1;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}

int main(){
	IO();
	LL h,w,m;
	cin>>h>>w>>m;
	VII rows(h);
	VII cols(w);
	rep(i,0,h){
		rows[i] = {0, i};
	}
	rep(i,0,w){
		cols[i] = {0, i};
	}
	LL a,b;
	set<II> present;
	rep(i,0,m){
		cin>>a>>b;
		a--;b--;
		present.insert({a, b});
		rows[a].F++;
		cols[b].F++;
	}
	sort(ALL(rows), greater<II> ());
	sort(ALL(cols), greater<II> ());
	LL ans = rows[0].F + cols[0].F;
	// rep(i,0,w){
	// 	cout<<cols[i].F<<" "<<cols[i].S<<"\n";
	// }
	// cout<<rows[0].S<<" "<<cols[0].S<<"\n";
	a = rows[0].F;
	LL ind = 0;
	b = cols[0].F;
	LL done = 0;
	while(ind < h && rows[ind].F == a){
		for(int i=0;i<w;i++){
			if(cols[i].F != b)
				break;
			if(present.find({rows[ind].S, cols[i].S}) == present.end()){
				// cout<<rows[ind].S<<" "<<cols[i].S<<"\n";
				done = 1;
				break;
			}
		}
		if(done)
			break;
		ind++;
	}
	if(!done)
		ans--;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 21952
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
using namespace std;
int main()
{//AKIHABARA 9
	string a;
	int b,i,j,flag=0;
	cin>>a;
	b=a.size();
	if(b>9)
	flag=0;
	else
	{
		if(a=="AKIHABARA")
		flag=1;
		else if(a=="KIHABARA"||a=="AKIHBARA"||a=="AKIHABRA"||a=="AKIHABAR")
		flag=1;
		else if(a=="KIHBARA"||a=="KIHABRA"||a=="KIHABAR"||a=="AKIHBRA"||a=="AKIHBAR"||a=="AKIHABR")
		flag=1;
		else if(a=="KIHBRA"||a=="KIHBAR"||a=="AKIHBR"||a=="KIHABR")
		flag=1;
		else if(a=="KIHBR")
		flag=1;
	}
	if(flag)
	printf("YES\n");
	else
	printf("NO\n");
} 

Measured memory_bytes: 256
#include <stdio.h>
int N, X, A[200000];
int main() {
    scanf("%d", &N);
    for(int i=0;i<N;++i) scanf("%d",A+i), X ^= A[i];
    for(int i=0;i<N;++i) printf("%d ", A[i] ^ X);
}


Measured memory_bytes: 3240
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => {
  var arry = input.split(' ').map(Number);

  var x = arry[0];
  var y = arry[1];

  var a = Math.floor(x / y);
  var b = x % y;
  var c = (x / y).toFixed(5)

  console.log(a + ' ' + b + ' ' + c);
})



Measured memory_bytes: 15576
input_lines = $stdin.read.split("\n")
s = input_lines[0].split('')
t = input_lines[1].split('')

s_hash = Hash.new(0)
s.each do |elm|
  s_hash[elm] += 1
end

t_hash = Hash.new(0)
t.each do |elm|
  t_hash[elm] += 1
end

if s_hash.values.sort == t_hash.values.sort
	puts 'Yes'
else
	puts 'No'
end

Measured memory_bytes: 24828
#include<stdio.h>
#include<string.h>
char ar[1000000];
int ar1[1000000];
int main()
{
    int a,b,c,i;
    scanf("%d",&a);
    getchar();
    gets(ar);
    b=strlen(ar);
    for(i=0;i<b;i++)
    {
        ar1[i]=(ar[i]-64)+a;
        if(ar1[i]>26)ar1[i]=ar1[i]-26;
    }
    for(i=0;i<b;i++)
        printf("%c",ar1[i]+64);
    printf("\n");
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;

// Sum of digits in base 10 is a multiple of D
ll generate(ll depth, ll sum, bool tight, ll D, const string& digits, vector<vector<vector<ll>>>& memo) {
    if (depth == digits.size()) {
        return sum % D == 0;
    }
    if (memo[depth][sum][tight] != -1) {
        return memo[depth][sum][tight];
    }
    ll limSup = tight ? (digits[depth] - '0') : 9;
    ll ans = 0;
    for (ll d = 0; d <= limSup; d++) {
        bool newTight = tight && d == limSup;
        ans = (ans + generate(depth + 1, (sum + d) % D, newTight, D, digits, memo)) % MOD;
    }
    return memo[depth][sum][tight] = ans;
}

int main() {
    string s;
    cin >> s;
    ll D;
    cin >> D;
    ll n = s.size();
    vector<vector<vector<ll>>> memo(n, vector<vector<ll>>(D, vector<ll>(2, -1)));
    ll ans = generate(0, 0, true, D, s, memo);
    cout << (ans - 1 + MOD) % MOD << "\n"; // don't count 0
}

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

int main() {
	string str;

	cin >> str;

	int acgt_max = 0;
	int counter = 0;

	for (auto x : str) {
		if (x == 'A' || x == 'C' || x == 'G' || x == 'T') {
			counter++;
			if (acgt_max < counter) acgt_max = counter;
		}
		else {
			counter = 0;
		}
	
	}
	cout << acgt_max << endl;

}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int ans=0;
  for(int i=0;i<k;i++) ans+=a[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-12;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

using namespace std;

ll n;
double dp[310][310][310];

double getE(ll ones, ll twos, ll threes) {
	if(ones == 0 && twos == 0 && threes == 0) return 0.0;
	if(dp[ones][twos][threes] != -1) return dp[ones][twos][threes];

	double output = 1.0;

	ll zeros = n - ones - twos - threes;
	double pZero = 1;
	ll i = 0;
	
	double oneE, twoE, threeE;
	if(ones > 0) oneE = getE(ones - 1, twos, threes);
	if(twos > 0) twoE = getE(ones + 1, twos - 1, threes);
	if(threes > 0) threeE = getE(ones, twos + 1, threes - 1);
	
	while(pZero > eps) {
		if(ones > 0) output += pZero * (double(ones) / double(n)) * (i + oneE);
		if(twos > 0) output += pZero * (double(twos) / double(n)) * (i + twoE);
		if(threes > 0) output += pZero * (double(threes) / double(n)) * (i + threeE);
		
		pZero *= double(zeros) / double(n);
		i++;
	}
	
	dp[ones][twos][threes] = output;
	return output;
}


int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	FOR(i, 0, 310) FOR(j, 0, 310) FOR(z, 0, 310) dp[i][j][z] = -1;
	
	cin >> n;
	ll counts[4] = { 0 };
	FOR(i, 0, n) {
		ll next; cin >> next;
		counts[next]++;
	}
	
	cout << setprecision(15) << getE(counts[1], counts[2], counts[3]) << endl;
	
	return 0;
}

Measured memory_bytes: 233088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static final int MOD = 1000000007;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] S = br.readLine().split(" ");
		int H = Integer.parseInt(S[0]);
		int W = Integer.parseInt(S[1]);
		
		String[] square= new String[H+1];
		
		for(int i = 1; i <= H; i++) {
			square[i] = br.readLine();
		}
		
		int[][] paths = new int[H+1][W+1];
		
		for(int i = 1; i <= H; i++) {
			for(int j = 1; j <= W; j++) {
				if(i == 1 && j == 1) {
					paths[i][j] = 1;
				} else if(square[i].charAt(j-1) != '#') {
					paths[i][j] = (paths[i-1][j] + paths[i][j-1]) % MOD;
				}
			}
		}
		
		System.out.println(paths[H][W]);
	}
}


Measured memory_bytes: 34096
x,y,a,b,c = map(int,input().split())

p = list(map(int,input().split()))

q = list(map(int,input().split()))

r = list(map(int,input().split()))

p.sort(reverse=True)

q.sort(reverse=True)

memo = []

for i in range(x):
    memo.append(p[i])
for j in range(y):
    memo.append(q[j])
for k in r:
    memo.append(k)

memo.sort(reverse=True)
ans = 0

for l in range(x+y):
    ans += memo[l]
print(ans)

Measured memory_bytes: 114028
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=200000+10;
int fa[maxn],d[maxn];
int n,m,flag;
int find(int x){
    if(fa[x]==x) return x;
    int y=find(fa[x]);
    d[x]+=d[fa[x]];
    return fa[x]=y;
}
void add(int x,int y,int z){
    int u=find(x),v=find(y);
    if(u!=v){
        fa[u]=v;
        d[u]=d[y]-d[x]-z; 
    }
    else if(d[y]-d[x]!=z) flag=1;
}
int main(){
    memset(d,0,sizeof(d));
	n=read();m=read();
	flag=0;
    REP(i,0,n) fa[i]=i;
    while(m--){
        int x,y,z;
        x=read(),y=read(),z=read();
        if(!flag) add(x,y,z);
    }
    if(flag) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;



void str_sort(vector<string> &S, int N) {

	FOR(i, 0, N-1) {
		FOR(j, 0, N - 1 - i) {
			if (S[j] > S[j + 1]) {
				swap(S[j], S[j + 1]);
			}
		}
	}

}


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

	int N;
	int L;
	vector<string> S;
	cin >> N >> L;
	FOR(i, 0, N) {
		string s;
		cin >> s;
		S.push_back(s);
	}

	str_sort(S, N);

	FOR(i, 0, N)
		cout << S[i];

	


	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

char mp[6][6];
void solve() {
	int h, w; cin >> h >> w;
	int k; cin >> k;
	rep(i, h)rep(j, w) {
		cin >> mp[i][j];
	}
	int ans = 0;
	rep(sh, (1 << h))rep(sw, (1 << w)) {
		int cnt = 0;
		rep(i, h)if (sh & (1 << i))rep(j, w)if (sw & (1 << j)) {
			if (mp[i][j] == '#')cnt++;
		}
		if (cnt == k)ans++;
	}
	cout << ans << "\n";
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


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

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

    long M = 2019;
    char[] S = scanner.next().toCharArray();
    int N = S.length;
    long res = 0;
    Map<Integer, Integer> freq = new HashMap<>();
    freq.put(0, 1);
    int r = 0;
    long e = 1;
    for (int i = N - 1; i >= 0; i--) {
      r += (S[i] - '0') * e % M;
      r %= M;
      res += freq.getOrDefault(r, 0);
      freq.put(r, freq.getOrDefault(r, 0) + 1);
      e *= 10;
      e %= M;
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 51896
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!
    val t = br.readLine()!!

    val mapST = mutableMapOf<Char, Char>()
    val mapTS = mutableMapOf<Char, Char>()
    for ((sc, tc) in s.zip(t)) {
        val valueST = mapST[sc]
        val valueTS = mapTS[tc]

        if (valueST == null) {
            mapST[sc] = tc
        } else if (valueST != tc) {
            out.println("No")
            return
        }

        if (valueTS == null) {
            mapTS[tc] = sc
        } else if (valueTS != sc) {
            out.println("No")
            return
        }
    }

    out.println("Yes")
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 45896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define re cin>>
#define pr cout<<
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)


const int N=2e6+5;
const int mod=1e9+7;


int main(){
      
      cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
      ll t,d,ans=0;
      cin>>t>>d;
      while(t--){
            ll a,b;
            cin>>a>>b;
            if(a*a+b*b<=d*d) ans++;
      }

      cout<<ans;
      return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n;
    cin >> n;

    vector<int> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
    }

    sort(a.begin(), a.end(), greater<int>());

    int alice=0, bob=0;
    for(int in=0;in<n;in++) {
        if(in%2==0) alice += a.at(in);
        else bob += a.at(in);
    }

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


Measured memory_bytes: 256
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

counter = Counter(s)
count = counter.most_common()
most = count[0][1]

c = []
for i in range(len(count)):
    if most == count[i][1]:
        c.append(count[i][0])

c.sort()
print(*c, sep='\n')

Measured memory_bytes: 50196
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int n,r;cin>>n>>r;
if(n>=10) cout<<r;
else cout<<r+100*(10-n);

return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max()/100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[310000], b[310000]
,d[110000][3];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n-2) {
		if ((a[i] < a[i + 1] && a[i + 1] < a[i + 2]) || (a[i + 2] < a[i + 1] && a[i + 1] < a[i]))
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N,w[103],v[103],W,dp[103][200000];
int main(){
	for (ll i=0;i<103;i++)
		for (ll j=0;j<200000;j++)
			dp[i][j]=1e16; 
	cin>>N>>W;
	ll num=0;
	for (ll i=1;i<=N;i++){
		cin>>w[i]>>v[i];
		num+=v[i];
	}
	dp[0][0]=0;
	for (ll i=1;i<=N;i++)
		for (ll j=0;j<=num;j++){
			dp[i][j]=min(dp[i][j],dp[i-1][j]);
			dp[i][j+v[i]]=dp[i-1][j]+w[i];
		}
	ll ans=0;
	for (ll i=0;i<=num;i++)
		if (dp[N][i]<=W && dp[N][i]<1e16) ans=i;
	cout<<ans;
}

Measured memory_bytes: 161152
n, k = map(int, input().split())
P = list(map(int, input().split()))


E = [0] * 1001

total = 0
for i in range(1, 1001):
    total += i
    e = total / i
    E[i] = e

P_to_E = [E[p] for p in P]


candidate = sum(P_to_E[:k])
candidates = [candidate]

for i in range(n-k):
    drop = P_to_E[i]
    add = P_to_E[i+k]
    candidate += add - drop
    candidates.append(candidate)

print(max(candidates))

Measured memory_bytes: 25060
from itertools import permutations as perm
import sys
readline = sys.stdin.buffer.readline

n = int(readline())
p = tuple(map(int, readline().split()))
q = tuple(map(int, readline().split()))

p_lst = list(perm(list(range(1, n + 1)), n))  # 排列
pn = qn = 0
for i,j in enumerate(p_lst, 1):
  if p == j:
    pn = i
  if q == j:
    qn = i
  if pn * qn != 0:
    break
print(abs(pn - qn))

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
bool us[300010];
int x[510];
pii e[510];
int pos[510][510];
int ans[300010];

int main() {
	cin >> N;

	rep(i, N) {
		cin >> x[i];
		--x[i];
		us[x[i]] = 1;
		e[i] = mp(x[i], i);
		pos[i][i] = x[i];
	}

	sort(e, e + N);

	int now = 0;

	rep(i, N) {
		int p = e[i].se;
		rep(j, p) {
			while (us[now]) {
				++now;
				if (now >= e[i].fi) {
					puts("No");
					return 0;
				}
			}
			us[now] = 1;
			pos[p][j] = now;
		}
	}

	reverse(e, e + N);

	now = N * N - 1;
	rep(i, N) {
		int p = e[i].se;
		for (int j = N-1; j > p; --j) {
			while (us[now]) {
				--now;
				if (now <= e[i].fi) {
					puts("No");
					return 0;
				}
			}
			us[now] = 1;
			pos[p][j] = now;
		}
	}

	rep(i, N) {
		rep(j, N) {
			ans[pos[i][j]] = i;
		}
	}

	puts("Yes");
	rep(i, N*N) {
		printf("%d%c", ans[i] + 1, i == N*N-1 ? '\n' : ' ');
	}

	return 0;
}

Measured memory_bytes: 3456
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int[] a=new int[5];
        for (int i = 0; i < 5; i++) {
            a[i]=sc.nextInt();
        }
        int k=sc.nextInt();
        int c=0,d=0;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                if(i==j)continue;
                c++;
                if(abs(a[i]-a[j])<=k){
                    d++;
                }
            }
        }
        out.println(c==d?"Yay!":":(");

        out.close();
    }
    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

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

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

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

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

// int ar[200005][200005];

vector <ll> a;
vector <ll> b;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll i,j,k,l,m,n;

	cin >> n >> m >> k;

	a.push_back(0);
	b.push_back(0);

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


	for(i=0;i<m;i++)
	{
		cin >> l;
		b.push_back(l);
	}

	for(i=1;i<=n;i++)
	{
		a[i] += a[i-1];
	}


	for(i=1;i<=m;i++)
	{
		b[i] += b[i-1];
	}

	ll maxi = -1,best_j=m,indexj;

	for(i=0;i<=n;i++)
	{
		for(j=best_j;j>=0;j--)
		{
			indexj = j;
			// cout << i << " " << j << '\n';
			// cout << (((a[i]-a[0])+(b[j]-b[0]))) << '\n';
			if(((a[i]-a[0])+(b[j]-b[0])) <= k)
			{
				maxi = max(maxi,i+j);
				break;
				
			}
		}

		best_j = indexj;
	}

	cout << maxi << '\n';
	
}

Measured memory_bytes: 7976
from collections import deque


S = deque(list(input()))
Q = int(input())
f = True
for i in range(Q):
    query = input().split(' ')
    if len(query) == 1:
        f = not f
    else:
        if (query[1] == '1' and f) or (query[1] == '2' and not f):
            S.appendleft(query[2])
        else:
            S.append(query[2])
S = "".join(list(S))
if not f:
    S = S[::-1]
print(S)

Measured memory_bytes: 72296