akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int max(int *N,int size){
  int max=N[0],i;
  for(i=1;i<size;i++){
    if(max<N[i]){
      max=N[i];
    }
  }
  return max;
}

int main(void){
  int N,i,Max,ans=0;
  scanf("%d",&N);
  int p[N];
  for(i=0;i<N;i++){
    scanf("%d",&p[i]);
  }
  Max=max(p,N);
  for(i=0;i<N;i++){
    ans=ans+p[i];
  }
  ans=ans-Max/2;
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
from collections import deque



def main():
    h,w=map(int,input().split())
    w+=2

    a=[list('@'*w)]
    for i in range(h):
        a+=[list('@'+input()+'@')]
    a+=[list('@'*w)]
    h+=2

    xy=[(-1,0),(0,-1),(0,1),(1,0)]
    que=deque()



    A=[[float('inf')]*w for i in range(h)]

    for i in range(1,h-1):
        for j in range(1,w-1):
            if a[i][j]=='#':
                A[i][j]=0
                que.append((i,j))


    res=0
    while que:
        x,y=que.popleft()
        for dx,dy in xy:
            nx,ny=dx+x,dy+y
            tmp=A[x][y]+1
            if a[nx][ny]!='@':
                if A[nx][ny]<=tmp:continue
                A[nx][ny]=tmp
                que.append((nx,ny))
                res=max(res,tmp)

    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 129756
#include <iostream>
#include <string>
#define mod 10007
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans=0,a[5]={0,0,0,0,0};
  s='J'+s;
  if(s[1]=='J') {
    a[2]=0;
    a[3]=0;
    a[4]=1;
  } else {
    a[2]=1;
    a[3]=0;
    a[4]=0;
  }
  for(int i=2; i<=s.size(); i++) {
    int x=a[2],y=a[3],z=a[4];
    if(s[i]==s[i-1]) {
      a[2]=0;
      a[3]=0;
      a[4]=(x*2+y*3+z*4)%mod;
    } else if(s[i]==s[i-2]) {
      a[2]=z;
      a[3]=(y+z)%mod;
      a[4]=(x*2+y*2+z*2)%mod;
    } else {
      a[2]=z;
      a[3]=(x+y+z)%mod;
      a[4]=(x+y*2+z*2)%mod;
    }
  }
  cout << (a[2]+a[3]+a[4])%mod << endl;
  return 0;
}

Measured memory_bytes: 1208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
        BufferedReader in = new BufferedReader(reader);
        String[] str = in.readLine().split(" ");
        double n = Double.parseDouble(str[0]);
        double x = Double.parseDouble(str[1]);
        int t = Integer.parseInt(str[2]);
        System.out.println((int)Math.ceil(n/x)*t);

    }
}

Measured memory_bytes: 33244
#include <cstdio>

using namespace std;

int main(void)
{
	int n;
	
	scanf("%d", &n);
	
	while (n-- > 0){
		int a, b;
		
		scanf("%d %d", &a, &b);
		if (a % b != 0){
			printf("%d\n", a % b);
		}
		else {
			printf("%d\n", b);
		}
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int maxn = 100010;

char str[maxn];

int main()
{
	//freopen("D.in","r",stdin);
	scanf("%s",str);
	int len = strlen(str);

	int ans = len;
	for (int i=0;i<len-1;i++)
	{
		if (str[i] != str[i+1]) ans = min(ans, max(i+1,len-1-(i+1)+1));
	}

	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a =0;
    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        string x;
        cin >> x;
        if(x == "Y"){
            cout << "Four" << endl;
            break;
        }
        else{
            a++;
        }
    }
    if (a==N){
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;

int main() {
    abdelrahman010
    int n , m , sum = 0;
    cin >> n >> m;
    for(int i = 0 , x;i < m;i++) {
        cin >> x , sum += x;
    }
    sum > n ? cout << -1 : cout << n - sum;
    return 0;
}

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

const ll MOD = 1000000007;

int main(){
  ll N , K;
  cin >> N >> K;

  ll ans = 0;
  for ( ll i=K; i<=N+1; i++ ) {
    ll mi = (K-1+(i-K)) * i / 2;
    ll ma = (N+(N-(K-1)-(i-K))) * i / 2;
    ans = ((ma - mi + 1) + ans) % MOD;
//  cout << i << " " << mi << " " << ma << " : " << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    
    int S[n];
    for(int i=0; i<n; i++){
        scanf("%d", &S[i]);
    }
    
    int q;
    scanf("%d", &q);
    
    int T[q];
    for(int i=0; i<q; i++){
        scanf("%d", &T[i]);
    }
    sort(T,T+q);
    
    int count=0;
    int left=0;
    int right,mid;    
    
    for(int i=0; i<q; i++){
        right=n-1;
        mid = (left+right)/2;
        while(left<=right){
            
            if(S[mid]==T[i]){
                count++;
                left=mid+1;
                break;
            }
            else if(S[mid]>T[i]){
                right=mid-1;
            }
            else{
                left=mid+1;
            }
            mid = (left+right)/2;
        }
    }
    printf("%d\n", count);
}


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


int main(){
    int64_t N,A,B;
    cin >> N >> A >> B;
    int64_t syou;
    int64_t amari;
    syou = N/(A+B);
    amari = int64_t(N%(A+B));
    if(A+B!=0){
    if(amari > A){
        cout << syou*A + A;
    }
    else{
        cout << syou*A + amari;
    }
    }
    else{
        cout << 0;
    }
}

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

using namespace std;

int main()
{
	string S;
	bool all_diff = true;

	cin >> S;

	for (int i = 0; i < S.size(); i++)
	{
		for (int j = 0; j < S.size(); j++)
		{
			if (i == j)
				continue;
			if (S[i] == S[j])
			{
				all_diff = false;
				break;
			}
		}

		if (!all_diff)
			break;
	}

	if (all_diff)
		cout << "yes" << endl;
	else
		cout << "no" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a;
  ci(a);
  vec b(a*3);
  For(i,0,a){
    ci(b[i]);
    b[a+i]=b[i]+1;
    b[2*a+i]=b[i]-1;
  }
  sort(b,b);
  ll an=1;
  ll ans=1;
  For(i,1,3*a){
    if(b[i-1]==b[i])
      an++;
    else{
      ans=max(an,ans);
      an=1;
    }
  }
  co(ans);
}

Measured memory_bytes: 2560
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a*b,c)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <climits>

typedef int type;
typedef long long ll;
using namespace std;
const bool isDebug = false;

void showArray(type A[], int N){
    for(int i=0; i<N; i++){
        printf("%d", A[i]);
        if(i != N-1) printf(" ");
    }
    printf("\n");
}

int bubbleSort(type A[], int N){
    bool flag_inv = true;
    int changeTime = 0;
    while(flag_inv){
        if(isDebug) showArray(A, N);
        flag_inv = false;
        for(int j=N-1; j>=1; j--){
            if(A[j] < A[j-1]){
                type tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;

                changeTime++;
                flag_inv = true;
            }
        }
    }
    return changeTime;
}

#define MAX_N 2000000
#define INF  INT_MAX
int N;
ll A[MAX_N];
void input(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
}

//void solve(){
//    ll maxDiff = -1*INF;
//    ll minR = INF;
//    for(int i_border = 1; i_border < N; i_border++){
//        //????°??????´??°
//        if(A[i_border-1] < minR){
//            minR = A[i_border-1];
//        }
//        
//        ll maxR = 0;
//        //?????§?????´??°???O(N)??????????????£???????????????
//        for(int i_k=i_border; i_k < N; i_k++){
//            if(A[i_k] > maxR) maxR = A[i_k];
//        }
//
//        if(maxDiff < maxR-minR) maxDiff = maxR-minR;
//        if(isDebug) printf("%lld %lld %lld\n", minR, maxR, maxDiff);
//    }
//
//    printf("%lld\n", maxDiff);
//}
void solve(){
    ll maxDiff = -1*INF;
    ll minR = A[0];
    for(int i_border = 1; i_border < N; i_border++){
        
        if(maxDiff < A[i_border]-minR) maxDiff = A[i_border]-minR;
        if(isDebug) printf("%lld %lld\n", minR, maxDiff);
        
        //????°??????´??°
        if(A[i_border] < minR){
            minR = A[i_border];
        }
    }

    printf("%lld\n", maxDiff);
}

int main(){
    input();
    solve();
    return 0;
}

Measured memory_bytes: 4780
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]
s = 0
for x in a:
    s += x
    b += [s]
ans = 0
for i in range(n-k+1):
    ans = max(ans, (b[k+i] - b[i] + k) / 2)
print(ans)

Measured memory_bytes: 24812
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

template <typename T>
class SegmentTree {
  template <typename B>
  struct BinaryOperation {
    const static B unit = numeric_limits<B>::max();
    B operator()(const B &a, const B &b) const { return min(a, b); }
  };
  BinaryOperation<T> bo;
  const T   unit;
  vector<T> tree;
  int v_size;

  public:
  SegmentTree(const int n = 0, const T unit = BinaryOperation<T>::unit) : unit(unit) { init(n); }
  SegmentTree(const vector<T> &v, const T unit = BinaryOperation<T>::unit) : unit(unit) { init(v); }
  void init(int n) {
    v_size = 1;
    while (v_size < n) v_size <<= 1;
    tree.assign(2 * v_size, unit);
  }
  void init(const vector<T> &v) {
    init(v.size());
    copy(v.begin(), v.end(), tree.end() - v_size);
    for (int i = v_size - 1; i > 0; --i) tree[i] = bo(tree[i * 2], tree[i * 2 + 1]);
  }
  void update(int i, const int x) {
    i += v_size;
    tree[i] = x;
    while (i >>= 1) tree[i] = bo(tree[i * 2], tree[i * 2 + 1]);
  }
  T query(int l, int r) const {
    T ret = unit;
    for (l += v_size, r += v_size; l < r; l = (l + 1) >> 1, r >>= 1) {
      if (l & 1) ret = bo(ret, tree[l]);
      if (r & 1) ret = bo(ret, tree[r - 1]);
    }
    return ret;
  }
  int size(void) const { return v_size; }
  T   operator[](const int i) const { return tree[i + v_size]; }
};

int main(void) {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  int len  = n + 1;
  int maxi = 0;
  rep (i, len) {
    int l = i;
    while (i < len && s[i] == '1') ++i;
    maxi = max(maxi, i - l);
  }
  if (m <= maxi) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> v(len, INT_MAX);
  v[n] = 0;
  SegmentTree<int> dpst(v);
  rrep (i, n) {
    if (s[i] == '1') continue;
    int l = i + 1, r = min(len, l + m);
    dpst.update(i, dpst.query(l, r) + 1);
  }
  vector<int> ans;
  int cnt = dpst[0], now = 0;
  while (cnt) {
    int prev = now;
    --cnt;
    while (now < len && dpst[now] != cnt) ++now;
    ans.push_back(now - prev);
  }
  rep (i, ans.size()) cout << ans[i] << (i < ans.size() - 1 ? " " : "\n");
  return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "<" << #__VA_ARGS__ << ">:", debug_out(__VA_ARGS__)
#define INF LLONG_MAX


int main()
{
  ll x, y;
  cin >> x >> y;
  if (y % 2 != 0 or y < 2 * x or y > x * 4)
	cout << "No" << endl;
  else
	cout << "Yes" << endl;
}


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

// Segment-Tree
struct SegmentTree {
  vector<int> dat;
  int n;
  
  // Constructor
  SegmentTree(int _n) {
    init(_n);
  }
  
  // 初期化
  void init(int _n) {
    int x = 1;
    while(x < _n) x *= 2;
    dat.resize(2 * x - 1);
    n = x;
    for(int i = 0; i < 2 * x - 1; i++) dat[i] = 0;
  }
  
  // i番目の値にxを加算
  void update(int i, int x) {
    i += n - 1; // 葉のノード
    dat[i] += x;
    while(i > 0){ // 更新
      i = (i - 1) / 2;
      dat[i] += x;
    }
  }
  
  // [a, b)の和
  // k:ノードの番号 [l, r)がkに対応づいている
  // query(a, b, 0, 0, n)と呼ぶ
  int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return dat[k];
    else{
      int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return vl + vr;
    }
  }
  
  int ret_n() {
    return n;
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, q;
  string s;
  cin >> n >> s >> q;
  
  vector<SegmentTree> x(26, SegmentTree(n));
  for (int i = 0; i < n; i++) {
    x.at(s.at(i) - 'a').update(i, 1);
  }
  
  for (int i = 0; i < q; i++) {
    int a;
    cin >> a;
    if (a == 1) {
      int j;
      char c;
      cin >> j >> c;
      j--;
      x.at(s.at(j) - 'a').update(j, -1);
      x.at(c - 'a').update(j, 1);
      s.at(j) = c;
    }
    else {
      int l, r;
      cin >> l >> r;
      int count = 0;
      for (int j = 0; j < 26; j++) {
        if (x.at(j).query(l - 1, r, 0, 0, x.at(j).ret_n()) > 0) count++;
      }
      cout << count << '\n';
    }
  }
}

Measured memory_bytes: 111516
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mygcd(ll a,ll b){
    return (b==0?a:mygcd(b,a%b));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x,y;
    cin >> x >> y;
    ll z = mygcd(x,y);

    if(z == y){
        cout << -1 << endl;
        return 0;
    }

    cout << x << endl;
    
    return 0;
}

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

#define int long long
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define fs first
#define sc second
#define mpr make_pair
#define iter iterator
#define all(X) X.begin(),X.end()
#define sau(X) sort(all(X)),X.resize(unique(all(X))-X.begin())
#define exist(X,ele) binary_search(all(X),ele)
#define y0 I_love_Ryougi_Shiki_0
#define y1 I_love_Ryougi_Shiki_1

template<typename T1,typename T2>
ostream& operator << (ostream& out,const pair<T1,T2>& X)
{
	out<<"{"<<X.fs<<","<<X.sc<<"}";
	return out;
}

template<typename T>
ostream& operator << (ostream& out,const vector<T>& X)
{
	for(auto i:X) out<<i<<" ";
	return out;
}

template<typename T>
inline void cmin(T& x,T y)
{
	if(!(x<y)) x=y;
}

template<typename T>
inline void cmax(T& x,T y)
{
	if(x<y) x=y;
}

const int inf=5000000000000000ll;

int N;
vector<int> e[200010];
vector<int> v[2];
int ans[200010];

void build(int p,int col,int fa)
{
	v[col].pb(p);
	for(auto to:e[p])
	{
		if(to!=fa) build(to,!col,p);
	}
}

main()
{
	ios::sync_with_stdio(false);
	
	cin>>N;
	for(int i=1;i<=N-1;i++)
	{
		int u,v; cin>>u>>v;
		e[u].pb(v);
		e[v].pb(u);
	}
	v[0].pb(1),v[1].pb(1);
	build(1,0,-1);
	
	if(v[0].size()-v[0][0]<v[1].size()-v[1][0]) swap(v[0],v[1]);
//	cout<<"A"<<endl;
//	for(int i=v[0][0];i<v[0].size();i++) cout<<v[0][i]<<" "; cout<<endl;
//	for(int i=v[1][0];i<v[1].size();i++) cout<<v[1][i]<<" "; cout<<endl;
//	for(int i=1;i<=N;i++) cout<<ans[i]<<" "; cout<<endl;
	for(int i=1;i<=N;i+=3)
	{
		int& pos0=v[0][0];
		ans[v[0][pos0++]]=i;
	}
	if(v[0].size()-v[0][0]<v[1].size()-v[1][0]) swap(v[0],v[1]);
//	cout<<"B"<<endl;
//	for(int i=v[0][0];i<v[0].size();i++) cout<<v[0][i]<<" "; cout<<endl;
//	for(int i=v[1][0];i<v[1].size();i++) cout<<v[1][i]<<" "; cout<<endl;
//	for(int i=1;i<=N;i++) cout<<ans[i]<<" "; cout<<endl;
	for(int i=2;i<=N;i+=3)
	{
		int& pos0=v[0][0];
		ans[v[0][pos0++]]=i;
	}
//	cout<<"C"<<endl;
//	for(int i=v[0][0];i<v[0].size();i++) cout<<v[0][i]<<" "; cout<<endl;
//	for(int i=v[1][0];i<v[1].size();i++) cout<<v[1][i]<<" "; cout<<endl;
//	for(int i=1;i<=N;i++) cout<<ans[i]<<" "; cout<<endl;
	for(int i=3;i<=N;i+=3)
	{
		int& pos0=v[0][0];
		int& pos1=v[1][0];
		if(pos0<v[0].size()) ans[v[0][pos0++]]=i;
		else ans[v[1][pos1++]]=i;
	}
	for(int i=1;i<=N;i++) cout<<ans[i]<<" "; cout<<endl;
	
	return 0;
}






















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

int main(void)
{
    IOS
    const int H = 1e4;
    int h, n;
    cin >> h >> n;
    vector<pii> v(n);
    REP(i,n) cin >> v[i].first >> v[i].second;
    sort(RALL(v));
    vector<int> dp(H*2);
    REP(i,dp.size()) dp[i] = 1 << 30;
    dp[0] = 0;

    int ans = 1 << 30;
    REP(i,h) {
        REP(j,n) {
            dp[i + v[j].first] = min(dp[i + v[j].first],dp[i] + v[j].second);
            if (i + v[j].first >= h) ans = min(ans,dp[i + v[j].first]);
        } 
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 384
n = gets.to_i
result = []
n.times do
  c, e = gets.split
  case c
  when 'insert'
    result.unshift(e)
  when 'delete'
    i = result.index(e)
    result.delete_at(i) unless i.nil?
  when 'deleteFirst'
    result.shift
  else
    result.pop
  end
end
puts result.join(' ')

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

//Gap
public class Main{

	String trans(){
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<4;i++)for(int j=0;j<8;j++){
			sb.append(a[i][j]==0?"00":a[i][j]);
		}
		return sb.toString();
	}
	
	int min, INF = 1<<29;
	int[][] a;
	int[] pos;
	String g = "1112131415161700212223242526270031323334353637004142434445464700";
	Map<String, Integer> ref;
	
	void dfs(int d){
		String r = trans();
		if(min<=d||ref.containsKey(r)&&ref.get(r)<=d)return;
		if(r.equals(g)){
			min = d;return;
		}
		ref.put(r, d);
		for(int i=0;i<4;i++)for(int j=1;j<8;j++){
			if(a[i][j]!=0||a[i][j-1]==0||a[i][j-1]%10==7)continue;
			int x = a[i][j-1]+1;
			int p = pos[x];
			a[p/8][p%8] = 0; a[i][j] = x;
			pos[x] = i*8+j;
			dfs(d+1);
			a[p/8][p%8] = x; a[i][j] = 0;
			pos[x] = p;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			min = INF;
			a = new int[4][8];
			for(int i=0;i<4;i++)for(int j=1;j<8;j++){
				a[i][j]=sc.nextInt();
			}
			for(int i=0;i<4;i++)for(int j=1;j<8;j++){
				if(a[i][j]%10==1){
					int t = a[i][j]/10-1;
					a[t][0] = a[i][j];
					a[i][j] = 0;
				}
			}
			pos = new int[48];
			for(int i=0;i<4;i++)for(int j=0;j<8;j++){
				if(a[i][j]==0)continue;
				pos[a[i][j]] = i*8+j;
			}
			ref = new HashMap<String, Integer>();
			dfs(0);
			System.out.println(min==INF?-1:min);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 30000
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int MOD = 1000000007;
int dp[100005][13];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n;
    n = s.size();
    dp[0][0] = 1;
    rep(i, n) {
        rep(j, 13) {
            if (s[i] == '?') {
                rep(l, 10) {
                    dp[i+1][(10*j+l)%13] += dp[i][j];
                    dp[i+1][(10*j+l)%13] %= MOD;
                }
            } else {
                int l = s[i] - '0';
                dp[i+1][(10*j+l)%13] += dp[i][j];
                dp[i+1][(10*j+l)%13] %= MOD;
            }
        }
    }
    cout << dp[n][5] << endl;
}

Measured memory_bytes: 5584
#include <stdio.h>

int main(){
    int H, W, N;
    scanf("%d", &H);
    scanf("%d", &W);
    scanf("%d", &N);
    int temp1 = 0;
    int temp2 = 0;
    int ctr1 = 0;
    int ctr2 = 0;
    for(int i =0; i < H; i ++){
        ctr1++;
        temp1+=W;
        if (temp1 >= N){
            break;
        }
    }    
    for(int i =0; i < W; i ++){
        ctr2++;
        temp2+=H;
        if (temp2 >= N){
            break;
        }
    }    
    if(ctr1 < ctr2){
        printf("%d\n", ctr1);
    }else{
        printf("%d\n", ctr2);
    }
    
    return 0;
}

Measured memory_bytes: 1728
fun main(args:Array<String>?): Unit {
    while(true){
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val state = readLine()!!.trim()
        var field = 0
        val players = IntArray(n){0}
        for ((i, c) in state.withIndex()){
            when(c){
                'M' -> players[i % n]++
                'S' -> {
                    field += players[i % n] + 1
                    players[i % n] = 0
                }
                'L' -> {
                    players[i % n] += field + 1
                    field = 0
                }
                else -> TODO()
            }
        }
        println("${players.sorted().joinToString(" ")} $field")
    }
}


Measured memory_bytes: 34840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    vector<int> p(N);
    rep(i,N){
        cin >> p[i];
        p[i]--;
    }
    ll d = 20000;
    vector<ll> a(N),b(N);
    a[0] = d;
    rep(i,N-1)a[i+1] = a[i] + d;
    b.back() = 1;
    int start = 0;
    rep(i,N){
        if(p[i] == N - 1)start = i;
    }
    for(int i = start; i+1 < N; i++){
        ll y = p[i];
        ll x = p[i+1];
        ll delta_a = abs(a[y] - a[x]);
        if(x < y){
            b[x] = b[y] + delta_a + 1;
        }
        else{
            b[x] = b[y] - delta_a + 1;
        }
    }
    for(int i = start; i - 1 >= 0; i--){
        ll y = p[i-1];
        ll x = p[i];
        ll delta_a = abs(a[x] - a[y]);
        if(x < y){
            b[y] = b[x] - delta_a - 1;
        }
        else{
            b[y] = b[x] + delta_a - 1;
        }
    }
    // print(p);
    // print(a);
    // print(b);
    rep(i,N){
        cout << a[i] << " ";
    }
    cout << endl;
    rep(i,N){
        cout << b[i] << " ";
    }
    cout << endl;

    // rep(i,N){
    //     cerr << a[i] + b[i] << " ";
    // }
    // cout << endl;
}


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

int main(){
  int n;
  cin >> n;
  int Ans=0;
  int p1, p2, p3;
  cin >> p1 >> p2 >> p3;
  if((p1<p2 && p2<p3) || (p1>p2 && p2>p3)){
    Ans++;
  }
  for(int i=0; i<n-3; i++){
    p1=p2;
    p2=p3;
    cin >> p3;
    if((p1<p2 && p2<p3) || (p1>p2 && p2>p3)){
      Ans++;
    }
  }
  cout << Ans << endl;
}

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

#define int long long
int n;
int x[100], y[100];


class UnionFind{
public:
    vector<int> tree;

    void init(){
        for(int i = 0;i < tree.size();i++){
            tree[i] = -1;
        }
        return;
    }

    UnionFind(int n){
        n++;
        tree.resize(n);
        init();
        return;
    }

    int root(int i){
        if(tree[i] < 0) return i;
        return tree[i] = root(tree[i]);
    }

    bool unite(int i, int j){
        i = root(i);
        j = root(j);
        if(i == j) return false;

        tree[i] += tree[j];
        tree[j] = i;
        return true;
    }

    int size(int i){
        return -tree[root(i)];
    }

    bool same(int i, int j){
        return root(i) == root(j);
    }
};

int solve(int p, int q){
    UnionFind uf(n);

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(i != j){
                if(x[i]-x[j] == p && y[i] - y[j] == q){
                    uf.unite(i, j);
                }
            }
        }
    }

    int cnt = 0;
    for(int i = 0;i < n;i++){
        if(i == uf.root(i)){
            cnt++;
        }
    }

    return cnt;
}

signed main(){
    cin >> n;

    for(int i = 0;i < n;i++) cin >> x[i] >> y[i];

    int ans = INT_MAX;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(i != j){
                ans = min(ans, solve(x[i]-x[j], y[i]-y[j]));
            }
        }
    }

    if(n == 1){
        cout << 1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int move(Int l, Int r, Int x){
  return max(l, min(x, r));
}

Int n;
Int l[108000], r[108000];

Int solve(){
  priority_queue<P, vector<P>, greater<P> > rpq;
  priority_queue<P> lpq;
  for(int i = 0;i < n;i++){
    lpq.push(P(l[i], i));
    rpq.push(P(r[i], i));
  }
  Int res = 0;
  Int now = 0;
  Int nxtlr = 0;
  vector<int> used(n, 0);

  for(int i = 0;i < n;i++){
    Int ind;
    if(nxtlr == 0){
      while(used[lpq.top().second])lpq.pop();
      ind = lpq.top().second;lpq.pop();
    }
    else{
      while(used[rpq.top().second])rpq.pop();
      ind = rpq.top().second;rpq.pop();
    }
    Int nxt = move(l[ind], r[ind], now);
    //    cout << ind << " " << nxt << endl;
    used[ind] = true;
    res += abs(now - nxt);
    now = nxt;
    nxtlr ^= 1;
  }
  res += abs(now- 0);
  return res;  
}

int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> l[i] >> r[i];
  }

  Int res = solve();
  for(int i = 0;i < n;i++){
    l[i] *= -1;
    r[i] *= -1;
    swap(l[i], r[i]);
  }

  res = max(res, solve());

  cout << res << endl; 
  return 0;
}

Measured memory_bytes: 7404
def main() :
    input()
    a = map(int, input().split())
    for i in a :
        if i%2==0 and i%3 != 0 and i%5 != 0 :
            print("DENIED")
            return
            
        
    print("APPROVED")
    

if __name__ == '__main__':
    import sys;
    try:
        main(sys.argv)
    except TypeError:
        main()

Measured memory_bytes: 3060
#!/usr/bin/python3
import copy

r = 998244353

(n, s) = map(int, input().split())

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

# s => comb
itbl = {}
rtbl = {}

for i in range(n):
    ai = a[i]
    
    if ai <= s:
        nitbl = copy.copy(itbl)        
        if ai in nitbl:
            nitbl[ai] = (nitbl[ai] + i + 1) % r
        else:
            nitbl[ai] = i + 1

        if ai in rtbl:
            rtbl[ai] += (i + 1) * (n - i)
        else:
            rtbl[ai] = (i + 1) * (n - i)

        for sk in itbl:
            if sk + ai <= s:
                if sk + ai in nitbl:
                    nitbl[sk + ai] = (nitbl[sk + ai] + itbl[sk]) % r
                else:
                    nitbl[sk + ai] = itbl[sk]
                    
                if sk + ai in rtbl:
                    rtbl[sk + ai] = (rtbl[sk + ai] + itbl[sk] * (n - i)) % r
                else:
                    rtbl[sk + ai] = (itbl[sk] * (n - i)) % r
            
        itbl = nitbl
    
print(rtbl.get(s, 0))


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

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

  int c = 64;

  for (int i = 0; i < n; i++) {
    int64_t a;
    std::cin >> a;

    int t = 0;
    while (a % 2 == 0) {
      t++;
      a /= 2;
    }
    c = std::min<int>(c, t);
  }

  std::cout << c << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[101];
long long l[23][1010];
long long ff[2000],re[2000];
int j[2];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[100101];
priority_queue<int,vector<int>,greater<int> > q;

//stack<int> s;
set<int> s;
map<int,int> p[100101];
vector<int> v[100101];

bool as(P a,P b)
{
  if(a.x==b.x)
  return a.y<b.y;
  return a.x<b.x;
}

long long g(long long x,long long y)
{
  long long p=1;
  for(;y;x*=x,x%=mod,y/=2)
    if(y%2)
    p*=x,p%=mod;
  return p;
}

long long f(int n,int m)
{
  if(n>a)
  {
    //if(m==b) printf("%lld\n",ff[b]);
    if(m==b) return 1;
    return 0;
  }
  if(l[n][m]>=0) return l[n][m];
  long long x=0;
  for(int i=0;i+m<=b&&i<=o[n];i++)
  {
    x+=f(n+1,m+i)*ff[b-i]%mod*re[o[n]-i]%mod*re[b-o[n]]%mod*re[i]%mod;
    x%=mod;
  }
  return l[n][m]=x;
}

int main()
{
  memset(l,-1,sizeof(l));
  scanf("%d %d",&b,&a);
  for(int t=1;t<=a;t++)
    scanf("%d",&o[t]);
  ff[0]=re[0]=1;
  for(int t=1;t<=1000;t++)
    ff[t]=ff[t-1]*t%mod,re[t]=g(ff[t],mod-2);
  printf("%lld",f(1,0)*ff[b]%mod);
  
}



Measured memory_bytes: 7552
#include <bits/stdc++.h> 
#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 REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int n; CI n;
	vector<int> a(n); CI a;

	long long int ans = 0;
	REP(i, n) {
		ans += a[i]-1;
	}

	CO ans EN;
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 112345;
int d[MAX_N];

int main2() {
  int N = nextInt();
  REP(i, N) d[i] = nextInt();
  sort(d, d+N);
  if (d[N/2-1] == d[N/2]) {
    cout << 0 << endl;
  } else {
    cout << d[N/2] - d[N/2-1] << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 300005
#define endl "\n"
#define mod 1000000007
ll n,ar[N],dp[N];
ll minval(ll i){
	if(i==n){
		return 0;
	}
	if(dp[i]!=-1){
		return dp[i];
	}

	if(i+2<=n){
		ll a,b;
		a=minval(i+1)+abs(ar[i+1]-ar[i]);
		b=minval(i+2)+abs(ar[i+2]-ar[i]);
		return dp[i]=min(a,b);
	}
	else {
		return dp[i]=abs(ar[i+1]-ar[i]);
	}
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	
	k=minval(1);
	cout<<k;
	return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
typedef struct aaaaa{
  int x,y,t;
}Grid;
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>vi;
  map<int,int>mii;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(mii[a]==0)
      vi.pb(a);
    mii[a]++;
  }
  vector<int>beki;
  ll kake=1;
  while(kake<=2000000000){
    beki.pb((int)kake);
    kake*=2;
  }
  sort(ALL(vi),greater<int>());
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<beki.size();j++){
      if(beki[j]-vi[i]>=0){
	int plus=min(mii[vi[i]],mii[beki[j]-vi[i]]);
	if(vi[i]==beki[j]-vi[i])
	  plus/=2;
	ans+=plus;
	mii[vi[i]]-=plus;
	mii[beki[j]-vi[i]]-=plus;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 33652
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int a,b;
  cin >> a >> b;
  
  if(a > 8 || b > 8) cout << ":(" << endl;
  else cout << "Yay!" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  string n;
  cin >> n;
  long x , fx = 0;
  istringstream iss(n);
  iss >> x;
  for(int i = 0 ; i < n.size() ; i++ ){
    fx += n[i] - '0'; 
  }

  if(x % fx == 0)
    Yes;
  else
    No;
  ret 0;
}

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

int main (){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  int xor_sum = 0;
  for(int i = 0; i<n; i++){
    cin >> v[i];
    xor_sum ^= v[i];
  }

  for(int i = 0; i<n; i++){
    cout << (xor_sum ^ v[i]) << ' ';
  }
}

Measured memory_bytes: 3976
import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.regex.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		String S = sc.get();
		if (S.length() == 2) {
			if (S.charAt(0) == S.charAt(1)) {
				System.out.println("1 2");
			} else {
				System.out.println("-1 -1");
			}
			return;
		}
		Pattern cont = Pattern.compile("(.)((\\1.)|(.\\1)|((.)\\6))");
		Matcher matcher = cont.matcher(S);
		if (!matcher.find()) {
			System.out.println("-1 -1");
			return;
		}
		MatchResult result = matcher.toMatchResult();
		System.out.printf("%d %d%n", result.start() + 1, result.end());
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}


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

int main() {
    int K, A, B;
    cin >> K >> A >> B;

    bool ok = false;
    for (int n=A; n<=B; n++) {
        if (n%K == 0) ok = true;
    }

    if (ok) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define Mod 1000000007
using namespace std;

// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// print vector
template <typename T> 
inline ostream &operator<<(ostream &out, vector<T> &a) {
    for(auto &x : a) out << x <<" ";
    // return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}
ll power(ll x, unsigned ll y, ll p=Mod)  
{  
    ll res = 1;
    x = x % p;
    while (y > 0)  
    {    
        if (y & 1)  
            res = (res*x) % p;    
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
} 
ll modInverse(ll A,ll M=Mod)
{
    return power(A,M-2,M);
}
ll gcd (ll a, ll b) {
  return b ? gcd (b, a % b) : a;
}
ll lcm (ll a, ll b) {
  return a / gcd(a, b) * b;
}
int main()	
{
	#ifdef SANS
		freopen("ongoingin.txt","r",stdin);
		freopen("ongoingout.txt","w",stdout);
	#endif
	fast
	int t=1;
	// cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		vector<ll> a(n),b(n);
		cin>>a;
		b[0]=0;
		b[1]=abs(a[0]-a[1]);
		for(int i=2; i<n; i++)
			b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
		cout<<b[n-1]<<endl;
	}
	#ifdef SANS
		cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
	#endif
}

Measured memory_bytes: 4776
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

A, B = getNM()
ans = -1
for i in range(1, 2000):
    optA = math.floor(i * 0.08)
    optB = math.floor(i * 0.1)
    if optA == A and optB == B:
        ans = i
        break
print(ans)

Measured memory_bytes: 38640
require 'set'
n, m = gets.split.map(&:to_i)
a = (1..n).map { gets.split.map(&:to_i) }
m.times do
    o = gets.split.map(&:to_i)
    if o[0] == 0
        i0, j0, s, t = o[1]-1, o[2]-1, o[3], o[4]
        r1 = (i0..i0+s-1)
        r2 = (j0..j0+s-1)
        b = r1.map {|i| r2.map {|j| a[i][j]}}
        (t / 90).times do
            b = (0..s-1).map{|i| (0..s-1).map{|j| b[s-1-j][i]}}
        end
        a = (0..n-1).map {|i| (0..n-1).map {|j|
            if (i0..i0+s-1).include?(i) && (j0..j0+s-1).include?(j)
                b[i-i0][j-j0]
            else
                a[i][j]
            end
        }}
    elsif o[0] == 1
        i0, j0, s = o[1]-1, o[2]-1, o[3]
        a = (0..n-1).map {|i| (0..n-1).map {|j|
            if (i0..i0+s-1).include?(i) && (j0..j0+s-1).include?(j)
                1 - a[i][j]
            else
                a[i][j]
            end
        }}
    elsif o[0] == 2
        a[o[1]-1] << a[o[1]-1].shift
    elsif o[0] == 3
        a[o[1]-1].unshift a[o[1]-1].pop
    elsif o[0] == 4
        queue = [[o[1]-1, o[2]-1]]
        reached = Set[*queue]
        until queue.empty?
            i, j = queue.shift
            [[i-1, j], [i+1, j], [i, j-1], [i, j+1]].each do |t|
                if t.min >= 0 && t.max < n && a[t[0]][t[1]] == a[i][j] && !reached.include?(t)
                    queue << t
                    reached << t
                end
            end
        end
        reached.each do |i, j|
            a[i][j] = 1 - a[i][j]
        end
    end
end
a.each do |r|
    puts r * ' '
end


Measured memory_bytes: 9068
a = int(input())
s = list(map(int, input().split()))
q = int(input())

val = {}

suss = 0
for i in s:
    if i not in val:
        val[i] = 1
    else:
        val[i] += 1

for k, v in val.items():
    suss += k *v

while q:
    c, d = map(int, input().split())
    # print(c, d)
    if c in val:
        if d in val:
            val[d] += val[c]
        else:
            val[d] = val[c]
        suss -= c * val[c]
        suss += d * val[c]
        del val[c]
    # print(val)


    print(suss)

    q -= 1



Measured memory_bytes: 20716
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int count = 0;
        out: while(true) {
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 == 1) {
                    break out;
                } else {
                    a[i] /= 2;
                }
            }
            count++;
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 21844
n, m = map(int, input().split())
dicts = {i+1:0 for i in range(n)}
for i in range(m):
    a, b = map(int, input().split())
    dicts[a] += 1
    dicts[b] += 1
    
for i in range(n):
    print(dicts[i + 1])


Measured memory_bytes: 2940