akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int l[101010], r[101010], imos[101010];
int N, K, a[101010];

void solve() {
    for (int i = 0; i < N; i++) {
        if (a[i] >= 0)
            l[i + 1] = l[i] + a[i];
        else
            l[i + 1] = l[i];
    }
    for (int i = N - 1; i >= 0; i--) {
        if (a[i] >= 0)
            r[i] = r[i + 1] + a[i];
        else
            r[i] = r[i + 1];
    }
    for (int i = 0; i < N; i++) {
        imos[i + 1] = imos[i] + a[i];
    }
    int ans = -INF;
    for (int i = 0; i < N; i++) {
        //閉区間
        int L = i;
        int R = i + K - 1;
        if (R >= N)
            break;
        chmax(ans, l[L] + r[R + 1] + imos[R + 1] - imos[L]);
        chmax(ans, l[L] + r[R + 1]);
    }
    cout << ans << endl;
}

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

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

    solve();
    return 0;
}


Measured memory_bytes: 6788
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	char map[100][100], *sep;
	int ans, n, m, i, j;
	fscanf(stdin, "%d%d", &n, &m);
	for (i = 0; i < n; i++) fscanf(stdin, "%s", map[i]);
	for (i = 0, sep = ""; i < n; i++, sep = "", puts(""))
		for (j = 0, ans = -1; j < m; j++, sep = " ") {
			if (map[i][j] == 'c') ans = 0;
			fprintf(stdout, "%s%d", sep, ans);
			if (ans != -1) ans++;
		}
	return 0;
}

Measured memory_bytes: 628
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

signed main() { 
        int a, b, c;
        cin >> a >> b >> c;
        cout << ((b * 10  + c) % 4 == 0 ? "YES" : "NO") << endl;
        return 0;
}               



Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

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

int main()
{
  int N, M;
  int sx, sy;
  while (cin >> M >> N)
  {
    if (M == 0 && N == 0)
      return 0;
    int count = 0;
    queue<P> que;
    char d[21][21];
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < M; j++)
      {
        cin >> d[i][j];
        if (d[i][j] == '@')
        {
          sx = j;
          sy = i;
          d[i][j] = '#';
          count++;
        }
      }
    }
    que.push(P(sx, sy));

    while (que.size())
    {
      P p = que.front();
      que.pop();
      for (int i = 0; i < 4; i++)
      {
        int nx = p.first + dx[i], ny = p.second + dy[i];
        if (0 <= nx && nx < M && 0 <= ny && ny < N && d[ny][nx] != '#')
        {
          que.push(P(nx, ny));
          d[ny][nx] = '#';
          count++;
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}



Measured memory_bytes: 3148
#include<iostream>

using namespace std;

int main(void)
{

        long long a,b,x;
        cin >> a >> b >> x;

        if(a==0)
        {
                cout << b/x+1 << endl;
        }
        else
        {
                cout << b/x-(a-1)/x << endl;
        }

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX_N = 40;
int N;
ll W, w[MAX_N], v[MAX_N];
pll ps[1 << (MAX_N/2)];

int main() {
    cin >> N >> W;
    rep(i, N) cin >> v[i] >> w[i];

    int n2 = N / 2;
    for (int i = 0; i < 1<<n2; i++) {
        ll sw = 0, sv = 0;
        for (int j = 0; j < n2; j++) {
            if (i >> j & 1) {
                sw += w[j];
                sv += v[j];
            }
        }
        ps[i] = make_pair(sw, sv);
    }

    sort(ps, ps+(1<<n2));
    int m = 1;
    for (int i = 1; i < (1<<n2); i++) {
        if (ps[m-1].second < ps[i].second) {
            ps[m++] = ps[i];
        }
    }

    ll res = 0;
    for (int i = 0; i < 1 << (N - n2); i++) {
        ll sw = 0, sv = 0;
        for (int j = 0; j < N - n2; j++) {
            if (i >> j & 1) {
                sw += w[n2+j];
                sv += v[n2+j];
            }
        }
        if (sw <= W) {
            ll tv = (lower_bound(ps, ps+m, make_pair(W-sw, LLINF))-1)->second;
            res = max(res, sv + tv);
        }
    }
    cout << res << endl;
}



Measured memory_bytes: 19504
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <cmath>
#include <cstdio>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <map>
#include <set>
#include <vector>

using namespace std;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

long long n;

void input() {
  cin >> n;
}

void solve1() {
  map<long long, long long> a;

  a[n]++;

  long long ans = 0;

  while (a.crbegin()->first != 1) {
    auto b = *a.crbegin();

    a[b.first / 2] += b.second * 2;

    a.erase(b.first);

    ans += b.second;
  }

  cout << ans + a[1];
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve1();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define M 1000000007

int bins(int a[],int l,int r,int x)
{
    while(r>=l)
    {
        int mid=(l+r)/2;
        if(a[mid]>=x) r=mid-1;
        else l=mid+1;
    }
    return l;
}

int32_t main()
{   fast

    int n;
    cin>>n;
    int l[n];

    for(int i=0;i<n;i++)
    {
        cin>>l[i];
    }
    sort(l,l+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {   int k=i+2;
        for(int j=i+1;j<n;j++)
        {
           k=bins(l,k,n-1,l[i]+l[j]);
           ans+=k-j-1;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    int N, K;
    cin >> N >> K;

    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans += min(v[i], K - v[i]); 
    }
    cout << ans * 2<< endl;

}

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

using namespace std;

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

using ll = long long;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	map<ll, int> mp;
	rep (i, n) {
	  ll a;
	  cin >> a;
	  mp[a]++;
	}
	rep (i, m) {
	  int b;
	  ll c;
	  cin >> b >> c;
	  mp[c] += b;
	}
	int cnt = 0;
	ll res = 0;
	for (auto iter = mp.rbegin(); iter != mp.rend(); ++iter) {
	  if (cnt + iter->second > n) {
		res += iter->first * (n - cnt);
		break;
	  }
	  res += iter->first * iter->second;
	  cnt += iter->second;
	}
	cout << res << endl;
	
    return 0;
}


Measured memory_bytes: 16136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    int b = 2;
    for (int i = 0; i < n; i++) {
        s[i] -= '1';
        if (s[i] == 1) b = 1;
    }

    auto f = [](int i) {
        int k = 0;
        while (i % 2 == 0) i /= 2, k++;
        return k;
    };

    int r = 0, x = 0;
    for (int i = 0; i < n; i++) {
        r ^= (s[i] == b && x == 0);
        if (i < n - 1) x += f(n - 1 - i) - f(i + 1);
    }

    cout << r * b << endl;

    return 0;
}

Measured memory_bytes: 1948
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

class Edge{
public:
	ll to;
	ll dist;
};

ll n, q, k;

vector<vector<Edge>> g;

ll dist[100100] = { 0 };

bool visited[100100] = { false };

void dfs(int now){

	visited[now] = true;
	
	for (int i = 0; i < g[now].size(); i++){
		ll next = g[now][i].to;
		ll nextdist = g[now][i].dist;
		if (visited[next]){
			continue;
		}
		dist[next] = dist[now] + nextdist;
		dfs(next);
	}
}



int main(void){

	cin >> n;

	g.resize(n);

	

	for (int i = 0; i < n - 1; i++){
		ll a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		Edge e1;
		e1.to = b;
		e1.dist = c;
		Edge e2;
		e2.to = a;
		e2.dist = c;
		g[a].push_back(e1);
		g[b].push_back(e2);
	}

	cin >> q >> k;

	k--;

	dfs(k);

	vector<pair<ll, ll>> l(q);

	for (int i = 0; i < q; i++){
		ll x, y;
		cin >> x >> y;
		x--;
		y--;
		l[i] = make_pair(x, y);
	}

	for (int i = 0; i < q; i++){
		cout << dist[l[i].first] + dist[l[i].second] << endl;
	}




} 


Measured memory_bytes: 14336
n = int(input())
a = list(map(int,input().split()))
a.sort()
a.append(0)
answer = 0
i = 0
counter = 1
while i <= n-1:
	if a[i] == a[i+1]:
		counter += 1
		i += 1
	else:
		if counter != a[i]:
			if counter > a[i]:
				answer += (counter - a[i])
				i += 1
				counter = 1
			else:
				answer += counter
				i += 1
				counter = 1
		else:
			i += 1
			counter = 1
print(answer)

Measured memory_bytes: 14800
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int n, m, d;
  cin>>n>>m>>d;
  double a = m-1;
  double b = 0.0;
  if(d==0) b = (double)n/n/n;
  else if(d < n) {
    b=abs(n-d)*2.0/n/n;
  }
  printf("%0.10f", a*b);
  puts("");
  return 0;
}


Measured memory_bytes: 256
S= input()
stack=0
# hoge=""
# print("len(S)",len(S))
if len(S)==2 and S[0]==S[1]:
  print("1 2")
  exit(0)

for i in range(2,len(S)):
    if S[i-2]==S[i-1]!=S[i] or S[i-2]!=S[i-1]==S[i] or S[i-2]==S[i]!=S[i-1]:
      print(i-1,i+1)
      exit(0)

print("-1 -1")

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

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

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int x, y; cin >> x>> y;
	cout << x + y / 2;


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

class WeightedUnionFindTree:
  def __init__(self, n):
    self.par = list(range(n))
    self.rank = [0 for _ in range(n)]
    self.weight = [0 for _ in range(n)]
   
  def root(self, t):
    if t == self.par[t]:
      return t
    # 経路圧縮してみる
    r = self.root(self.par[t])
    self.weight[t] += self.weight[self.par[t]]
    self.par[t] = r
    return r
   
  def rec_weight(self, t):
    if t == self.par[t]:
      return 0
    return self.weight[t] + self.rec_weight(self.par[t])
   
  def same(self, x, y):
    return self.root(x) == self.root(y)
     
  def unite(self, x, y, w):
    rootx = self.root(x)
    rooty = self.root(y)
    if rootx != rooty:
      if y != rooty:
        # 直接yにつなげる
        self.weight[rootx] = w - self.rec_weight(x)
      else:
        # 根につなげる
        self.weight[rootx] = w - (self.weight[x] - self.weight[y])
      # ここで親を更新
      self.par[rootx] = y
    else:
      return w == self.diff(x, y)
 
  def diff(self, x, y):
    return self.rec_weight(x) - self.rec_weight(y)

n, m = list(map(int, input().split()))
par = list(range(n+1))
dist = [0 for _ in range(n+1)]


wuft = WeightedUnionFindTree(n+1)
flag = True
for _ in range(m):
  l, r, d = list(map(int, input().split()))
  # 根が異なってたらとりあえず併合、同じならdifを取って整合性を確かめる
  a = wuft.unite(l, r, d)
  if a is not None:
    if a == False:
      flag = False
"""
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(wuft.par)]
print()
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(wuft.weight)]
print()
"""

print("Yes" if flag else "No")
  

Measured memory_bytes: 16560
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

const long long mod = 1000000007;

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

	int n, capacity;
	cin >> n >> capacity;

	vector<int> w(n);
	for(int i = 0; i < n; ++i)
		cin >> w[i];

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

	vector<vector<int> > dp(n + 1, vector<int>(capacity + 1, 0));
	dp[n][0] = 1;
	for(int i = n - 1; i >= 0; --i) {
		for(int j = 0; j <= capacity; ++j) {
			dp[i][j] += dp[i + 1][j];
			dp[i][j] %= mod;
		}

		for(int j = 0; j + w[i] <= capacity; ++j) {
			dp[i][j + w[i]] += dp[i + 1][j];
			dp[i][j + w[i]] %= mod;
		}
	}

	long long ans = (accumulate(w.begin(), w.end(), 0) <= capacity ? 1 : 0);

	int sum = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = max(0, capacity - w[i] + 1 - sum); j <= max(-1, capacity - sum); ++j) {
			ans += dp[i + 1][j];
			ans %= mod;
		}
		sum += w[i];
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 8924
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	pair<int, int>a[114]; int n, t,ans=100000,jj=10000;
	signed main() {
      cin>>n>>t;
		for (int i = 0; i < n; i++)cin >> a[i].first >> a[i].second;
		for (int i = 0; i < n; i++) {
			if (a[i].second <= t && a[i].first < jj) {
				jj = a[i].first;
				ans = a[i].first;
			}
				}
		if (ans !=100000 )cout << ans << endl;
		else cout << "TLE" << endl;
		ll
	}

Measured memory_bytes: 256
import collections
N = int(input())
A = [int(input()) for i in range(N)]
acount = collections.Counter(A)
a = acount.most_common()
count = 0
alen = len(a)
for j in range(alen):
    if a[j][1]%2 == 1:
        count+=1
print(count)

Measured memory_bytes: 21344
#include <algorithm>
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int n = 1;
  for (int i = 0; i < N; ++i) {
    n = min(n * 2, n + K);
  }
  printf("%d\n", n);
}

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

typedef long long ll;
typedef pair<ll,ll> P;

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


int main() {
  ll n;
  cin>>n;
  vector<ll> v(n);
  vector<ll> a(100005,0);
  vector<ll> b(100005,0);

  rep(i,n){
    cin>>v[i];
    if(i%2==0)a[v[i]]++;
    else b[v[i]]++;
  }
  vector<P>ap;
  vector<P>bp;
  rep(i,100005){
    if (a[i]!=0){
        ap.push_back(make_pair(a[i],i));
    }
    if (b[i]!=0){
        bp.push_back(make_pair(b[i],i));
    }
  }
  ap.push_back(make_pair(0,-1));
  bp.push_back(make_pair(0,-1));
  ap.push_back(make_pair(0,-2));
  bp.push_back(make_pair(0,-2));

  sort(ap.rbegin(),ap.rend());
  sort(bp.rbegin(),bp.rend());
  ll a1=ap[0].first;
  ll b1=bp[0].first;
ll ans;
  if (ap[0].second==bp[0].second){
    ll a2=ap[1].first;
    ll b2=bp[1].first;
    ans=min(n-a1-b2,n-a2-b1);

  }
  else{
    ans=n-a1-b1;
  }

cout<<ans;


}


Measured memory_bytes: 4340
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	vector<int> D(4);
	for(int i=0;i<4;++i){
		cin>>D[i];
	}
	if( abs(D[0]-D[2]) <= D[3] ){
		cout<<"Yes"<<endl;
	}else if(abs(D[0]-D[1])<=D[3] && abs(D[1]-D[2])<=D[3]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

int main() {
    int a[3],ans;
    for(int i=0;i<3;++i){
        cin>>a[i];
    }
    sort(a,a+3);
    ans=a[2]*10+a[1]+a[0];
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// aのp乗を求める関数
ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1)*a%MOD;
	}
}

signed main() {
	int n,s; cin>>n>>s;
  ll dp[n+5][s+5]; rep(i,n+5)rep(j,s+5) dp[i][j]=0LL;
	dp[0][0]=1LL;
	VL a(n);
	rep(i,n)cin>>a[i]; sort(ALL(a));
	
	rep(i,n){
      rep(j,s+1){
        dp[i+1][j]+=2*dp[i][j];
        dp[i+1][j]%=MOD;
        if(j+a[i]<=s){
          dp[i+1][j+a[i]]+=dp[i][j];
          dp[i+1][j+a[i]]%=MOD;
        }
      }
	}
  cout<<dp[n][s]<<endl;
	
	return 0;
}


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

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var aw = new List<int>();
        var hw = new List<int>();
        var bw = new List<int>();
        var a = new int[n, 6];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < 6; j++)
            {
                var w1 = int.Parse(line[j * 2]);
                var w2 = int.Parse(line[j * 2 + 1]);
                a[i, j] = w1 * 60 + w2;
                if (j == 0 ) aw.Add(a[i, j]);
                else if (j == 2 ) hw.Add(a[i, j]);
                else if (j == 4) bw.Add(a[i, j]);
            }
        }
        var aw2 = aw.Distinct().OrderBy(x => x).ToArray();
        var hw2 = hw.Distinct().OrderBy(x => x).ToArray();
        var bw2 = bw.Distinct().OrderBy(x => x).ToArray();
        Console.WriteLine(getAns(a, aw2, hw2, bw2));
    }
    public static int getAns(int[,] w, int[] a, int[] b, int[] c)
    {
        var ret = 0;
        for (int i = 0; i < a.Length; i++)
            for (int j = 0; j < b.Length; j++)
                for (int k = 0; k < c.Length; k++)
                {
                    var count = 0;
                    for (int m = 0; m < w.GetLength(0); m++)
                        if (a[i] >= w[m, 0] && a[i] <= w[m, 1] && b[j] >= w[m, 2] && b[j] <= w[m, 3] && c[k] >= w[m, 4] && c[k] <= w[m, 5]) count++;
                    ret = Math.Max(ret, count);
                }
        return ret;
    }
}




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

int n;
int t[100][100];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			scanf("%d", &t[i][j]);
		}
	}
	long long res = 0;
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			res += min(t[i][j], t[j][i]);
		}
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int n = sc.nextInt();

		int[] a = new int[n];

		for (int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}

		int maxKyori=0;
		for (int i=0; i<n; i++){
			int kyori;
			if (i == n-1){
				kyori = a[0] + k - a[i];
			} else {
				kyori = a[i+1] - a[i];
			}
			maxKyori = Math.max(maxKyori, kyori);
		}
		System.out.println(k - maxKyori);
	}
}

Measured memory_bytes: 87212
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define maxn 1771562
#define mod 1000000007
#define inf 10000000



int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    lli a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    lli l=1,h=1e9,ans;
    while(l<=h){
        lli mid=(l+h)/2;
        lli ca=0;
        for(int i=0;i<n;i++){
            ca+=a[i]/mid-1;
            if(a[i]%mid) ca++;
        }
        //cout<<mid<<" "<<ca<<"\n";
        if(ca<=k) ans=mid,h=mid-1;
        else l=mid+1;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 5084
#include <bits/stdc++.h>
#define fin(a,n)  for(int i=0;i<n;i++) cin>>a[i];
#define fout(a,n)  for(int i=0;i<n;i++) cout<<a[i]<<" ";

using namespace std;

vector<string> getComb(int n) {
	vector<string> res;
	for(int i=0;i<(1<<n);i++) {
		string temp(n, '0');
		for(int j=0;j<n;j++)
			if((i & (1<<j)) != 0)
				temp[j] = '1';
		res.push_back(temp);
	}
	return res;
}

int cntBlack(string s1, string s2, vector<string> v) {
	for(int i=0;i<s2.size();i++) {
		if(s2[i]-'0') {
			for(int j=0;j<s1.size();j++)
				v[j][i] = '@';
		}
	}
	int ans = 0;
	for(int i=0;i<s1.size();i++)
		if(s1[i] == '0')
			ans += count(v[i].begin(), v[i].end(), '#');
	return ans;
}
int main() 
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); cout.tie(NULL);
	int r,c,k;
	cin>>r>>c>>k;
	vector<string> v(r), rowComb, colComb;
	fin(v, r);
	rowComb = getComb(r);
	colComb = getComb(c);
	int ans = 0;
	for(int i=0;i<rowComb.size();i++)
		for(int j=0;j<colComb.size();j++)
			if(cntBlack(rowComb[i], colComb[j], v) == k)
				ans++;
	cout<<ans<<'\n';
	return 0;
}

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

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

int two=0,four=0,no=0;
for(int i=0;i<n;i++){
if(a[i]%4==0)four++;
else if(a[i]%2==0)two++;
else no++;
}
no+=two%2;
if(four>=no-1) cout << "Yes" <<endl;
else cout << "No"<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll>>
#define INF 99999999

int main(){
  int N,sum=0,B[100]={0},A[100]={0};
  cin>>N;
  rep(i,N-1){
    cin>>B[i+1];
  }

  sum=B[1]+B[N-1];

  For(i,1,N-1){
    A[i+1]=min(B[i],B[i+1]);
    sum+=A[i+1];
  }
  cout<<sum<<endl;

  return 0;
}


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

int coin[20]={0};
int dp[30][50010]={0};
int main(){
    int n,m;
    cin >> n >> m;

    for(int i=1;i<=m;i++){
        cin >> coin[i];
    }
    
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(i==1){
                dp[i][j]=dp[i][j-1]+1;
            }
            else if(coin[i]<=j){
                dp[i][j]=min(dp[i-1][j],dp[i][j-coin[i]]+1);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout << dp[m][n] << endl;;
    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	if(1<<i>n) 
		{
			cout<<(1<<i)/2<<endl;
			return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){
	int N;

char D[10][7]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

scanf("%d",&N);
for(int iii=0;iii<N;iii++){char x[1025]={};
scanf("%s",x);

int d=0;char pp;int y=0;
for(int i=0;i<1024;i++)
{if(x[i]!='0'&&x[i-1]==x[i]){d++;if(D[y][d]==NULL){d=0;}}
else if(x[i]!='0'&&x[i-1]!=x[i]){d=0;y=x[i]-'0';}
else if(x[i]=='0'&&y!=0){printf("%c",D[y][d]);y=0;d=0;}

}
printf("\n");
}
return 0;
}

Measured memory_bytes: 1000
#include<stdio.h>
long long N[400010],L[400010],T;
long long  hyouka(long long a,long long b){return a+b;}
void lsset(int n,int *d){
  int i;
  for(T=1;T<n;T*=2);
  for(i=0;i<T;i++)N[T+i]=i<n?d[i]:0;
  for(i=T-1;i;i--)N[i]=hyouka(N[i*2],N[i*2+1]);
}
void lasy(int i,int l,int r){
  if(L[i]==0)return;
  N[i]+=L[i]*(r-l);
  if(r-l>1){
    L[i*2  ]+=L[i];
    L[i*2+1]+=L[i];
  }
  L[i]=0;
}
void lsadd(int a,int b,int c,int i,int l,int r){//printf("%d %d %d\n",i,l,r);
  lasy(i,l,r);
  if(r<=a||b<=l)return;
  if(a<=l&&r<=b){
    L[i]+=c;
    lasy(i,l,r);
  }
  else{
    lsadd(a,b,c,i*2  ,l,(l+r)/2);
    lsadd(a,b,c,i*2+1,(l+r)/2,r);
    N[i]=hyouka(N[i*2],N[i*2+1]);
  }
}
long long lsget(int a,int b,int i,int l,int r){
  lasy(i,l,r);
  if(b<=l||r<=a)return 0;
  if(a<=l&&r<=b)return N[i];
  return hyouka(lsget(a,b,i*2,l,(l+r)/2),lsget(a,b,i*2+1,(l+r)/2,r));
}
int main(){
  int n,m,i,a,b,c,q,d[100010]={};
  scanf("%d %d",&n,&m);
  lsset(n,d);
  for(i=0;i<m;i++){
    scanf("%d %d %d",&q,&a,&b);
    if(q)printf("%lld\n",lsget(a-1,b,1,0,T));
    else{
      scanf("%d",&c);
      lsadd(a-1,b,c,1,0,T);
    }
  }
  return 0;
}


Measured memory_bytes: 5820
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    S,W,H = N[l].split(",")
    s = int(S)
    w = float(W)
    h = float(H)
    BMI = w / h**2
    if BMI >= 25.0:
        print(s)



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

int main() {

	int n; cin >> n;
	string s;
	unordered_map<string, int> count;
	for (int i = 0; i < n; i++) {
		cin >> s;
		count[s]++;
	}

	struct comp{
		bool operator()(const pair<int, string> a, const pair<int, string> b) {
			return a.first < b.first || (a.first == b.first && a.second > b.second);
		}
	};

	priority_queue<pair<int, string>, vector<pair<int, string>>, comp> pq;
	for (auto it : count)
		pq.push({it.second, it.first});

	int last = pq.top().first;
	while (!pq.empty() && last == pq.top().first) {
		cout << pq.top().second << endl;
		pq.pop();
	}
}

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

int main(){
    int l,r,d,count=0;
    cin >> l >> r >> d;
    for (int i=l; i<=r; i++){
        if (i%d == 0)count +=1;
    }
    cout << count << endl;

    
    return 0;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <iostream>

using namespace std;

int main() {
  int a, b;
  char op; 
  while (true) {
    cin >> a >> op >> b;
    if (op == '?') return 0;
    switch (op) {
      case '+':
        cout << a + b << endl;
        break;
      case '-':
        cout << a - b << endl;
        break;
      case '*':
        cout << a * b << endl;
        break;
      case '/':
        cout << a / b << endl;
        break;
    }   
  }
}

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int a,b;
	cin>>a>>b;
	cout << max( max(a+b,a-b) , a*b) << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

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

	int first = 0, second = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] > first) {
			second = first;
			first = A[i];
		} else if (A[i] == first || A[i] > second) {
			second = A[i];
		}
	}

	for (int i = 0; i < N; i++) {
		if(A[i] == first) cout << second << endl;
		else cout << first << endl;
	}
    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin>>N;
  bool ans= true;
  rep(i,N){
    ll x;
    cin>>x;
    if (x%2 ==0 && (x%3!= 0 && x%5!=0)){
      ans=false;
    }
  }
  cout<<(ans?"APPROVED":"DENIED")<<endl;
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool Read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool Write(int x){
	if(x >= 10) Write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

int n;
double dp[303][303][303];
int cnt[3];

double dfs(int a1, int a2, int a3){
	if(dp[a1][a2][a3] >= 0.00) return dp[a1][a2][a3];
	int s = a1 + a2 + a3;
	dp[a1][a2][a3] = (double)((double)n / (double)s);
	if(a1 > 0) dp[a1][a2][a3] += (double)((double)a1 / (double)s) * (double)(dfs(a1 - 1, a2, a3)); 
	if(a2 > 0) dp[a1][a2][a3] += (double)((double)a2 / (double)s) * (double)(dfs(a1 + 1, a2 - 1, a3));
	if(a3 > 0) dp[a1][a2][a3] += (double)((double)a3 / (double)s) * (double)(dfs(a1, a2 + 1, a3 - 1));
	return dp[a1][a2][a3];
}

signed main(){
	ios::sync_with_stdio(false);
	memset(cnt, 0, sizeof(cnt));
	cin >> n;
	rep(i, n){
		int a;
		cin >> a;
		if(a) cnt[a - 1]++;
	}
	rep(i, n + 1){
		rep(j, n + 1){
			rep(k, n + 1){
				dp[i][j][k] = -1.00;
			}
		}
	}
	dp[0][0][0] = 0.00;
	cout << fixed << setprecision(12) << dfs(cnt[0], cnt[1], cnt[2]) << endl;
	return 0;
}

Measured memory_bytes: 217472
#include<stdio.h>

int main(){
  int N,D,t;
  
  scanf("%d%d",&N,&D);
  
  if(N%(2*D+1)==0){
    t=N/(2*D+1);
  }else{
    t=N/(2*D+1)+1;
  }
  printf("%d\n",t);

}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(n);
    rep(i,m){
        int k;
        cin>>k;
        rep(j,k){
            int s;
            cin>>s;
            s--;
            a[s]|=1<<i;
        }
    }
    int p=0;
    rep(i,m){
        int x;
        cin>>x;
        p|=x<<i;
    }
    int ans=0;
    for(int i=0;i<(1<<n);i++){
        int t=0;
        rep(j,n){
            if((i>>j)&1){
                t^=a[j];
            }
        }
        if(t==p){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(all(a));
    for (int i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        
        int ans = 0;
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)==t.charAt(i)){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> order(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    for(int i = 0; i < n; i++){
        cin >> q[i];
        order[i] = i+1;
    }

    int a = -1, b = -1;
    int cnt = 1;
    do{
        bool f_a = true;
        bool f_b = true;
        for(int i = 0; i < n; i++){
            if(order[i] != p[i]) f_a = false;
            if(order[i] != q[i]) f_b = false;
        }
        if(f_a) a = cnt;
        if(f_b) b = cnt;
        cnt++;
    }while(next_permutation(order.begin(), order.end()));

    cout << abs(a-b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#define ll long long
using namespace std;
ll n,m,i,j,k,l,o,p,ans,ans1;
vector<ll> v[10010];
struct E
{
	ll x,y;
}a[10010];
void dfs(ll x,ll y,ll de)
{
	if (de>k/2) ans++;
	for (ll i=0;i<v[x].size();i++)
	 if (v[x][i]!=y)
	  dfs(v[x][i],x,de+1);
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for (i=1;i<n;i++)
	{
		ll x,y;
		scanf("%lld%lld",&x,&y);
		E t;
		t.x=x;t.y=y;
		a[i]=t;
		v[x].push_back(y);
		v[y].push_back(x);  
	}
	ans1=1e9;
	if (k%2==0)
	{
		for (i=1;i<=n;i++)
		 {
		 	ans=0;
		 	dfs(i,-1,0);
		 	ans1=min(ans,ans1);
		 }
	}
	else
	{
		for (i=1;i<n;i++)
		{
			ans=0;
		 	dfs(a[i].x,a[i].y,0);
		 	dfs(a[i].y,a[i].x,0);
		 	ans1=min(ans,ans1);
		}
	}
	printf("%lld\n",ans1);
}


Measured memory_bytes: 768
import sys
from heapq import heappush, heappop
sys.setrecursionlimit(10**6)

def input():
    return sys.stdin.readline()[:-1]

n, m = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
k = 0

pqs = []
edge = [[] for _ in range(n)]
for i in range(m):
    x, y = [int(item) for item in input().split()]
    edge[x].append(y)
    edge[y].append(x)

def dfs(n):
    kind[n] = k
    heappush(pqs[k], a[n])
    for item in edge[n]:
        if kind[item] == -1:
            dfs(item)

kind = [-1] * n
for i, item in enumerate(kind):
    if item == -1:
        pqs.append([])
        dfs(i)
        k += 1

if k == 1:
    print(0)
    exit()
    
ans = 0
for i in range(k):
    val = heappop(pqs[i])
    ans += val
pqs = [flatten for inner in pqs for flatten in inner] 
pqs.sort()
for i in range(k-2):
    if i > len(pqs) - 1:
        print("Impossible")
        exit()
    ans += pqs[i]
print(ans)

Measured memory_bytes: 30252
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	m := scanInt()

	if n == m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

public class Main {
	public static int[] sort(int[] nums){
		for(int h=nums.length-1;h>0;h--){
			for(int i=1;i<=h;i++){
				if(nums[i]>nums[i-1]){
					int tmp=nums[i];
					nums[i]= nums[i-1];
					nums[i-1]=tmp;
				}
			}
		}
		return nums;
	}
	public static void main(String[] a) {
		BufferedReader br;
		br = new BufferedReader(new InputStreamReader(System.in));

		String str;

		try {
			//data set num
			str = br.readLine();
			int setNum=Integer.parseInt(str);
			for (int h = 0; h < setNum; h++) {
				int[] num = new int[3];
				str = br.readLine();
				String[] numbers =str.split(" ");
				for (int i = 0; i < numbers.length; i++) {
					num[i] = Integer.parseInt(numbers[i]);
				}
				num =sort(num);
				int answer = (int)Math.pow(num[1], 2)+(int)Math.pow(num[2], 2);
				if(answer==(Math.pow(num[0], 2))){
					System.out.println("YES");
				}else {
					System.out.println("NO");
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}

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

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        int n;
        cin >> n;
        vector<int> p(n);
        for (int i = 0; i < n; i ++) {
                cin >> p[i];
        }
        int ans = 0;
        for (int i = 0; i < n; i ++) {
                if (p[i] == i + 1) {
                        swap(p[i], p[i + 1]);
                        ans ++;
                }
        }
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

#列を組める条件は、
#N=奇数: 0が1人、2,4,..len(N)-1 が2人ずつ
#N=偶数: 1,3,..len(N)-1 が2人ずつ
#想定される数列と同様のものを作成して、イコールかどうかを確認する

#それぞれの番号持ちは場所を入れ替えることができるので、(0より大きい数の個数**2)%(10**9 + 7)が答え

def check(L):
    if len(L) % 2 == 1:
        C = [x for x in range(2,len(L), 2)]*2 + [0]
        C = sorted(C)
        if L == C:
            return True
        else:
            return False
    elif len(L) % 2 == 0:
        C = [x for x in range(1,len(L), 2)]*2
        C = sorted(C)
        if L == C:
            return True
        else:
            return False

if check(A) == True:
    ans = (2 ** (len(A)//2)) % (10**9 + 7)
else:
    ans = 0

print(ans)

Measured memory_bytes: 14008
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=int(n/3)
if(a[0]==a[n-1] and a[0]==0):
    print('Yes')
elif(n%3!=0):
    print('No')
elif(a[0]==a[b-1] and a[b-1]!=a[b] and a[b]==a[n-1]):
    if(a[0]^a[n-1]^a[n-1]==0):
        print('Yes')
    else:
        print('No')
elif(a[0]==a[2*b-1] and a[2*b-1]!=a[2*b] and a[2*b]==a[n-1]):
    if(a[0]^a[0]^a[n-1]==0):
        print('Yes')
    else:
        print('No')
else:
    if(a[0] == a[b-1] and a[b-1] != a[b]):
        if(a[b]==a[2*b-1] and a[2*b-1]!=a[2*b]):
            if(a[2*b]==a[n-1]):
                if(a[0]^a[b]^a[n-1]==0):
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
    

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

//-1???ISONO WIN, 1???NAKAJIMA WIN
int dfs( int il, int ir, int nl, int nr, int turn = 0 ){
	//cout << il << " " << ir << " " << nl << " " << nr << " " << turn << endl;
	if( il > 4 && ir > 4 )
		return 1;
	if( nl > 4 && nr > 4 )
		return -1;

	//?£?????????????
	if( turn % 2 == 0 ){
		int win = 1;
		if( il < 5 ){
			if( nl < 5 )
				win = min(win, dfs( il, ir, nl + il, nr, turn + 1 ));
			if( nr < 5 )
				win = min(win, dfs( il, ir, nl, nr + il, turn + 1 ));
		}
		if( ir < 5 ){
			if( nl < 5 )
				win = min(win, dfs( il, ir, nl + ir, nr, turn + 1 ));
			if( nr < 5 )
				win = min(win, dfs( il, ir, nl, nr + ir, turn + 1 ));
		}
		return win;
	}
	//?????¶?????????
	int win = -1;
	if( nl < 5 ){
		if( il < 5 )
			win = max(win, dfs( il + nl, ir, nl, nr, turn + 1 ));
		if( ir < 5 )
			win = max(win, dfs( il, ir + nl, nl, nr, turn + 1 ));
	}
	if( nr < 5 ){
		if( il < 5 )
			win = max(win, dfs( il + nr, ir, nl, nr, turn + 1 ));
		if( ir < 5 )
			win = max(win, dfs( il, ir + nr, nl, nr, turn + 1 ));
	}
	return win;
}

int main() {
	int il, ir, nl, nr;
	cin >> il >> ir >> nl >> nr;
	int res = dfs(il, ir, nl, nr, 0);
	if( res == -1 )
		cout << "ISONO" << endl;
	else
		cout << "NAKAJIMA" << endl;
	return 0;
}

Measured memory_bytes: 1156