akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

class mint{
    public:
        ll x;
        static unsigned long long mod;
        static unsigned long long mod_plus;
        mint(){x = 0;}
        mint(ll _x) : x((_x < 0 ? ((_x += mod_plus) < 0 ? _x + mod_plus : _x) : _x)%mod){}
        /*mint& operator=(const ll &a){
            x = a;
            return *this;
        }*/

        mint operator-(){
            return x == 0 ? 0 : mod - x;
        }
        mint& operator+=(const mint& a){
            if((x += a.x) >= mod) x -= mod;
            return *this;
        }
        mint operator+(const mint& a) const{
            mint res(*this);
            return res += a;
        }
        mint& operator-=(const mint& a){
            if((x -= a.x) < 0) x += mod;
            return *this;
        }
        mint operator-(const mint& a) const{
            mint res(*this);
            return res -= a;
        }
        mint& operator*=(const mint& a){
            (x *= a.x)%=mod;
            return *this;
        }
        /*mint& operator*=(const ll& a){
            mint temp(a);
            return *this *= temp;
        }*/
        mint operator*(const mint& a) const{
            mint res(*this);
            return res *= a;
        }
        /*mint operator*(const ll& a) const{
            mint res(*this);
            return res *= a;
        }*/
        mint pow(unsigned long long pw) const{
            mint res(1), comp(*this);
            while(pw){
                if(pw&1) res *= comp;
                comp *= comp;
                pw >>= 1;
            }
            return res;
        }
        //以下、modが素数のときのみ
        mint inv() const{
            mint res(*this);
            return res.pow(mod - 2);
        }
        mint& operator/=(const mint &a){
            (x *= a.inv().x)%=mod;
            return *this;
        }
        mint operator/(const mint &a) const{
            mint res(*this);
            return res /= a;
        }
};
ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
unsigned long long mint::mod = int(1e+9) + 7;
unsigned long long mint::mod_plus = (LLONG_MAX / mint::mod) * mint::mod;
typedef vector<mint> vm;

const ll MAX_N = ll(4e+6) + 10;
vm fact(MAX_N, mint(1));
void makefact(){
    reps(i,2,MAX_N) fact[i] = fact[i-1] * mint(i);
}
mint nCm(ll n, ll m){
    return fact[n] / (fact[n-m] * fact[m]);
}

int main() {
    cin>>K>>S;
    N = K + S.size();
    makefact();
    mint ans = mint(26).pow(N);
    rep(i,N - K){
        ans -= nCm(N, i) * mint(25).pow(N - i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 36536
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var a = cin.ReadInt();
            var b = cin.ReadInt();
            if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) WriteLine("Possible");
            else WriteLine("Impossible");
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}



Measured memory_bytes: 11220
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;


int main(){
	int n;
	cin >> n;
	for(int i=0 ; i<n ; i++){
		string a, b;
		cin >> a;
		cin >> b;

		int flag=0;

		if(a.size() < b.size()){
			string temp;
			temp = a;
			a = b;
			b = temp;
		}
		while(b.size() != a.size()){
			b = "0" + b;
		}

		if(a.size() > 80){
			flag = 1;
			cout << "overflow" << endl;
		}else{
			for(int i=0 ; i<a.size() ; i++){
				a[a.size()-1-i] += b[b.size()-1-i] - '0';
			}
			for(int j=0 ; j<a.size()-1 ; j++){
				if(a[a.size()-1-j] > '9'){
					a[a.size()-1-j] -= 10;
					a[a.size()-2-j]++;
				}
			}
			if(a[0] > '9'){
				a[0] -= 10;
				a = "1" + a;
			}

		}

		if(a.size() > 80) {
			if(flag == 0)cout << "overflow" << endl;
		}else{
			cout << a << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
const int MAXN = 100005;

lint dap[MAXN];

struct disj{
	int pa[MAXN], sz[MAXN];
	lint offset[MAXN];
	vector<int> nd[MAXN];
	void init(int n){
		for(int i=1; i<=n; i++){
			pa[i] = i;
			sz[i] = 1;
			nd[i].push_back(i);
		}
	}
	int find(int x){
		return pa[x] = (pa[x] == x ? x : find(pa[x]));
	}
	bool uni(int p, int q, lint x){
		p = find(p);
		q = find(q);
		if(sz[p] < sz[q]) swap(p, q);
		pa[q] = p;
		offset[p] += sz[q] * x;
		for(auto &i : nd[q]){
			dap[i] += sz[p] * x + offset[q];
			dap[i] -= offset[p];
			nd[p].push_back(i);
		}
		sz[p] += sz[q];
		return 1;
	}
}disj;

struct edg{
	int s, e, x;
	bool operator<(const edg &e)const{
		return x > e.x;
	}
}v[MAXN];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1; i<n; i++){
		int s, e, x;
		scanf("%d %d %d",&s,&e,&x);
		v[i] = {s, e, x};
	}
	sort(v+1, v+n);
	disj.init(n);
	for(int i=1; i<n; i++){
		disj.uni(v[i].s, v[i].e, v[i].x);
	}
	lint f = disj.offset[disj.find(1)];
	for(int i=1; i<=n; i++) printf("%lld\n",f +  dap[i]);
}

Measured memory_bytes: 13944
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


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


int r, c;
ii arr[200005];


int main(){

    ios_base::sync_with_stdio(0);

    cin>>r>>c;
    for(int i=0;i<r;i++){
        int a;
        cin>>a;
        arr[i] = {a, 1};
    }
    for(int i=0;i<c;i++){
        int a;
        cin>>a;
        arr[r+i] = {a, 0};
    }

    sort(arr, arr+r+c);

    ll ans = 0;
    ll rows = c+1, cols = r+1;
    for(int i=0;i<r+c;i++){
        if(arr[i].ss == 1){
            if(cols == 1)   continue;
            ans += rows * arr[i].ff;
            cols--;
        }
        else{
            if(rows == 1)   continue;
            ans += cols * arr[i].ff;
            rows--;
        }
    }

    cout<<ans;
    return 0;
}





 



Measured memory_bytes: 1920
#include <iostream>
#include <vector>
using namespace std;
const long long MIN = -1e18;

struct edge {
    int from, to;
    long long dist;
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<long long> score(n, MIN);
    vector<edge> es(m);
    for (int i=0; i<m; ++i) {
        int a, b; long long c;
        cin >> a >> b >> c;
        a--; b--;
        es[i].from = a;
        es[i].to = b;
        es[i].dist = c;
    }
    score[0] = 0;
    for (int i=0; i<n-1; ++i) {
        for (edge e: es) {
            int now = e.from;
            int next = e.to;
            if (score[now] == MIN) continue;
            if (score[next] < score[now] + e.dist) {
                score[next] = score[now] + e.dist;
            }
        }
    }
    vector<bool> is_pos(n, false);
    for (int i=0; i<n; ++i) {
        for (edge e: es) {
            int now = e.from;
            int next = e.to;
            if (score[now] == MIN) continue;
            if (score[next] < score[now] + e.dist) {
                score[next] = score[now] + e.dist;
                is_pos[next] = true;
            }
            if (is_pos[now]) is_pos[next] = true;
        }
    }
    if (is_pos[n-1]) cout << "inf" << endl;
    else cout << score[n-1] << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env pypy3

import collections


INF = 10 ** 10


def solve(n, t, xs):
    trades = collections.Counter()
    maxs = [INF for _ in range(n)]
    maxs[n - 1] = xs[n - 1]
    for i in range(n - 1)[::-1]:
        maxs[i] = max(xs[i], maxs[i + 1])
    for i in range(n):
        delta = maxs[i] - xs[i]
        if delta > 0:
            trades[delta] += 1
    max_delta = max(trades.keys())
    return trades[max_delta]


def main():
    n, t = map(int, input().split())
    xs = list(map(int, input().split()))
    print(solve(n, t, xs))


if __name__ == '__main__':
    main()


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

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

  std::string S;

  std::cin >> S;

  uint64_t result = 0;
  for (int bit = 1; bit < (1 << (S.size() - 1)); bit++) {
    std::vector<int> v;
    for (int i = 0; i < S.size(); i++) {
      if (bit & (1 << i)) {
        v.push_back(i + 1);
      }
    }

    if (v.size() > 0) {
      result += std::stoll(S.substr(0, v[0]));
      for (uint32_t i = 1; i < v.size(); i++) {
        result += std::stoll(S.substr(v[i - 1], v[i] - v[i - 1]));
      }
      if (v.back() < S.size()) {
        result += std::stoll(S.substr(v.back(), S.size()));
      }
    }
  }
  std::cout << (result + std::stoll(S)) << std::endl;
  return 0;
}


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

int main(){
	int n, x, num, a, ans;
	cin >> n >> x;
	vector<int> vec(n);
	for (int i=0; i<n; i++){
		cin >> vec.at(i);
	}
	for (int i=0; i<n; i++){
		x-=vec.at(i);
	}
	sort(vec.begin(), vec.end());
	num=x%vec.at(0);
	a=(x-num)/vec.at(0);
	ans=a+n;
	cout << ans << endl;
}


Measured memory_bytes: 3624
n = int(input())
y = list(map(int, input().split(" ")))
s = 1
hoge = False
for i in y:
    if i ==0:
        print(0)
        hoge = True

def f():
    s = 1
    for i in y:
        s *= i
        if s>10**18:
            print(-1)
            return
    print(s)
if not hoge:
    f()


Measured memory_bytes: 21656
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
int n,m;
cin>>n>>m;
if(n==m){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}







Measured memory_bytes: 256
using System;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[0] == 0 && x[1] == 0)
                {
                    break;
                }
                for (int i = 0; i < x[0]; i++)
                {
                    for (int I = 0; I < x[1]; I++)
                    {
                        if ((I + i) % 2 == 0)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    
}

Measured memory_bytes: 9292
#include <stdio.h>
#define MAX 100005
#define NIL -1
struct Node {
    int p; // parent
    int l; // left-child
    int r; // right-sibling
};

struct Node T[MAX];
int n, D[MAX]; //D[i]: save the depth from root to point i 

void setDepth( int u, int p ) {
    D[u] = p;
    if (T[u].r != NIL) setDepth(T[u].r, p);
    if (T[u].l != NIL) setDepth(T[u].l, p+1);
}

int getDepth(int u) {
    int d = 0;
    while (T[u].p != NIL) {
        u = T[u].p;
        d++;
    }
    return d;
}

void printChildren(int u) {
    printf("[") ;
    for ( int i = 0 , c = T[u].l; c != NIL ; c = T[c].r, i ++ ) {
        if (i) printf(", ");
        printf("%d",c);
    }

    printf("]\n");
}

void makeTree() {
    int i, j, d, v, c,l, r, u;
    for (i = 0 ; i < n ; i ++) T[i].p = T[i].r = T[i].l = NIL;

    for (i = 0 ; i < n ; i ++) {
        scanf("%d %d",&v, &d);  // v: parent d: the number of childs
        for ( j = 0 ; j < d ; j++ ) {
            scanf("%d", &c);    //c: child
            if (j == 0 ) T[v].l = c; //most left child for v(parent)
            else T[l].r = c;
            l = c; //set the child number to l
            T[c].p = v; //set the parent number for c(children)
        }
    }

}
int main(void) {
    int i, j, d, v, c,l, r, u;
    scanf("%d", &n);

    makeTree();

    for (i = 0 ; i < n ; i ++ ){
        if (T[i].p == NIL ) r = i; // point i is root because i don't have a parent.
    }
    setDepth(r, 0);
    
    for (u = 0 ; u < n ; u ++) {

        printf("node %d: parent = %d, depth = %d, ", u, T[u].p, getDepth(u));

        if ( T[u].p == NIL ) printf("root, ");
        else if (T[u].l == NIL ) printf("leaf, ");
        else printf("internal node, ");

        printChildren(u);

    } 
    return 0;
}



Measured memory_bytes: 7288
//! Oos Karim Rokhsat
#include<bits/stdc++.h>
using namespace std;

typedef double                      ld;
typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define endl                        '\n'
#define file_io                     freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define kill(x)                     return cout << x << endl , 0;
#define pb                          push_back

const ll MXN = 1e3 + 10;
const ll MXM = 50 + 10;
const ll MX5 = 2e5 + 10;
const ll MX6 = 1e6 + 10;
const ll LOG = 20;
const ll INF = 8e18;
const ld eps = 1e-9;
const ll MOD = 1e9 + 7; //998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}
string base2(ll n){
    string a="";while(n>=2){a+=(char)(n%2+'0');n/=2;}a+=(char)(n+'0');reverse(all(a));return a;
}

ll n, A[MX5];
ll p = 1, ans = 0;
bool check(ll x){

    for(int i = 0; i < n; i ++){
        if(A[i] == p){
            p ++;
        }
        else{
            ans ++;
        }
    }
    if(p >= x) return 1;
    return 0;
}

int main(){
    fast_io
    //file_io
    cin >> n;
    if(n % 2) kill(0);

    ll ans = 0, p = 2;
    while(p * 5 <= n){
        p *= 5;
        ans += n / p;
    }
    cout << ans;

    return 0;
}

//! N.N


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
 
  int a[4],b[4];
 
  while(true) {
 
  
 
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3];
 
  if ( cin.eof() ) break;

    int hit = 0;
    int blow = 0;
 
    for ( int i = 0; i < 4; i++ ) {
 
      for ( int j = 0; j < 4; j++ ) {
 
    int k = ( i + j ) % 4;
 
    if ( a[i] == b[k] ) {
 
      if ( i == k ) {
        hit++;
      }else {
        blow++;
      }
      break;
 
    }
 
      }
 
    }
 
    cout << hit << " " << blow << endl;
 
  }
 
  return 0;
 
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 105

ll a , b , n;

int main()
{
    _FastIO;
    cin >> a >> b >> n;
    ll x = b - 1;
    if(x > n)
        x = n;
    ll ans = (a  * x) / b;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
'use strict'

function main(s) {

  const str = s.split('\n')[0].split(' ').join('');
  const num = Number(str);
  const ans = (num % 4 === 0) ? 'YES' : 'NO';
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	string s,t;
	cin>>s>>t;
	int ans;
	rep(i,3){
		if(s[i]==t[i]){
			ans++;
		}
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    cout << "Christmas";
    FOR(i,1,25-n) cout << " Eve";
    return 0;
}

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

using namespace std;

int main(){
    int n,d; cin>>n>>d;
    vector<int>arr;
    int maxi = 0;
    while(d--){
        int x; cin>>x;
        if(x>maxi)maxi=x;
        arr.push_back(x);
    }
    sort(arr.begin(),arr.end());
    arr.push_back(n+arr[0]);
    int ash = 0,sum= 0;
    for(int i = 0;i<arr.size()-1;i++){
        if((arr[i+1]-arr[i])>ash){
            sum+=ash;
            ash = arr[i+1]-arr[i];
        }else{
        sum+=(arr[i+1]-arr[i]);
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            List<int> lstInp = new List<int>();
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++) { lstInp.Add(int.Parse(sS[i])); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<int> lstOut = new List<int>();
            int iNow = lstInp[0];                       // 現在高さ
            int iCnt = 0;                               // 移動数
            for (int i = 1; i < lstInp.Count; i++)
            {
                if (iNow >= lstInp[i])                  // 現在高以下でOK
                {
                    iCnt += 1;                          // 移動+1
                    iNow = lstInp[i];                   // 現在高を隣に
                }
                else                                    // 移動終了
                {
                    lstOut.Add(iCnt);                   // 今までの移動数保持
                    iCnt = 0;                           // 移動数クリア
                    iNow = lstInp[i];                   // 現在高を隣に
                }
            }
            lstOut.Add(iCnt);                           // 最後の移動数保持
            lstOut.Sort(delegate (int mca1, int mca2) { return mca2 - mca1; });     // 降順

            // 出力
            System.Console.WriteLine("{0}", lstOut[0].ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 27740
n=int(input())
a=list(map(int,input().split()))
q=int(input())
from collections import Counter
dic=Counter(a)
ans=sum(a)
for i in range(q):
  b,c=list(map(int,input().split()))
  num=dic.get(b,0)
  dic[b]=0
  dic[c]=dic.get(c,0)+num
  ans=ans-b*num+c*num
  print(ans)
  

Measured memory_bytes: 23832
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vsort(x) sort(x.begin(),x.end())

using namespace std;

int main() {

	int i, j, k;
	int x, a, b;
	cin >> x >> a >> b;
	int c, d;
	c = abs(x - a);
	d = abs(x - b);
	if (c > d) {
		cout << "B" << endl;
	}
	else {
		cout << "A" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
  int a,b;
  cin >> a>> b;
  if(a%2!=0&&b%2!=0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;

}

Measured memory_bytes: 256
while True:
    h, w = map(int, input().split())

    if h == 0 and w == 0:
        break
    for i in range(h):
        for j in range(w):
            if (i == 0 or i == h - 1 or j == 0 or j == w - 1):
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()





Measured memory_bytes: 7004
n = int(input())
work = []
for i in range(n):
    a,b = map(int,input().split())
    work.append([a,b])
work.sort(key = lambda x:x[1],)
time = 10000000000
for i in range(len(work)):
    x = work.pop()
    time = min(time,x[1])-x[0]
    if time < 0:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 38044
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let p: Vec<usize> = sc.vec(n);
    let mut mn = p[0] + 100;
    let mut ans = 0;
    for i in 0..n {
        if mn > p[i] {
            mn = p[i];
            ans += 1;
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 17540
k, a, b = map(int, input().strip().split())

# ビスケットa枚を1円に交換し、1円をb枚に交換するという操作を考えると、
# これは操作回数を2回消費して b - a 枚だけビスケットが増える
# よって、 b - a > 2 で残り回数が2回以上なら
# ビスケットを叩いて1枚増やすより常に有利なのでやるべし。

biscuits = 1
if b - a > 2:
    # 何回できる?
    # 最初に a - 1回叩いてビスケットを a 枚に増やす必要がある
    if a - 1 > k:
        # a枚まで増やせないので k 回叩いて終わる
        biscuits += k
    else:
        # a枚まで増やした
        biscuits += a - 1
        k -= a - 1
        if k > 0:
            times = k // 2
            rest = k - times * 2
            biscuits += (b - a) * times
            biscuits += rest
else:
    # 常に叩いて1枚増やすほうがマシ
    biscuits += k

print(biscuits)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int i,cnt=0;
	char lea=s[0],ru,chu;
	for (i=1;i<=s.size()-1;i++)
	{
		if (s[i]=='E')
		{
			cnt++;
		}
	}
	int minv=cnt;
	ru=s[1];
	chu=s[0];
	for (i=1;i<=s.size()-1;i++)
	{
		if (s[i]=='E')
		{
			if (s[i-1]=='E')
			{
				cnt--;
			}
		}
		if (s[i]=='W')
		{
			if (s[i-1]=='W')
			{
				cnt++;
			}
		}
		if (cnt<minv)
		{
			minv=cnt;
		}
	}
	cout<<minv<<endl;
	return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

int main() {
    
    int n;
    while (cin >> n && n) {
        stack<pii> stk;
        
        int ans = 0;
        rep(i, n) {
            int a;
            cin >> a;
            // cout << "sz " << sz(stk) << endl;
            if (i == 0) stk.push(pii(a, 1));
            else if (i % 2 == 0) { // 0indexedで奇数番目
                pii b = stk.top();
                stk.pop();
                if (b.F == a) {
                    stk.push(pii(a, b.S + 1));
                } else {
                    stk.push(b);
                    stk.push(pii(a, 1));
                }
            } else {
                pii b = stk.top();
                stk.pop();
                // cout << b.F << " " << b.S << endl;
                
                if (b.F != a && sz(stk)) {
                    pii c = stk.top();
                    stk.pop();
                    stk.push(pii(a, b.S + c.S + 1));
                } else {
                    stk.push(pii(a, b.S + 1));
                }
                
            }
            
            // cout << stk.top().F << " " << stk.top().S << endl;
            
        }
        while (!stk.empty()) {
            pii a = stk.top();
            // cout << a.F << " " << a.S << endl;
            if (a.F == 0) ans += a.S;
            stk.pop();
        }
        
        cout << ans << '\n';
    }
}



Measured memory_bytes: 3068
def b_shift_only(N, A):
    # Aの全要素についてbitごとorを取った値が
    # 何回2で割れるかが解となる
    bitwise_or = 0
    for a in A:
        bitwise_or |= a
    
    ans = 0
    while bitwise_or % 2 == 0:
        bitwise_or //= 2
        ans += 1
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(b_shift_only(N, A))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K; cin >> K;
  string S; cin >> S;
  int L = S.size();
  if(K >= L) cout << S << endl;
  else {
    for(int i=0; i<K; i++) {
      cout << S[i];
    }
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>

using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		long long int a[n];
		long long int max=-100000;
		int input;
		for(int i=0;i<n;i++){
			a[i]=0;
			cin>>input;
			for(int j=0;j<=i;j++){
				a[j]+=input;
				if(max<a[j])max=a[j];
			}
		}
		cout<<max<<endl;
	}
	return 0;
}

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

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

	int a[100];
	for (int i = 0; i < n; i++) cin >> a[i];

	string ans = "APPROVED";
	for (int i = 0; i < n; i++) {
		if ((a[i] % 2) == 0) {
			if (!((a[i] % 3) == 0 || (a[i] % 5 == 0))) {
				ans = "DENIED";
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N,K,Q = map(int, input().split())
D = {c:0 for c in range(1, N+1)}
for _ in range(Q):
  a = int(input())
  D[a] += 1
r = Q-K
for v in D.values():
  if v>r:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 19260
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	a, b, m := scanInt(), scanInt(), scanInt()
	as, bs := make([]int, a), make([]int, b)
	minA, minB := math.MaxInt32, math.MaxInt32
	for i := range as {
		as[i] = scanInt()
		minA = min(minA, as[i])
	}
	for i := range bs {
		bs[i] = scanInt()
		minB = min(minB, bs[i])
	}

	ans := minA + minB
	for i := 0; i < m; i++ {
		x, y, c := scanInt(), scanInt(), scanInt()
		ans = min(ans, as[x-1]+bs[y-1]-c)
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 5852
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cctype>
#define LL long long
#define mk make_pair
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 3;
char s[N];
int n; 
int main(){
	scanf("%s",s + 1);
	n = strlen(s + 1);
	if(n & 1){
		puts("No");
		return 0;	
	}
	bool flag = 1;
	for(int i = 1;i <= n;i += 2) if(s[i] != 'h') flag = 0;
	for(int i = 2;i <= n;i += 2) if(s[i] != 'i') flag = 0;
	puts(flag ? "Yes" : "No");
	return 0;
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    	r:usize
    }
    
    println!("{}", r*r);
}

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

void solve()
{
    long double a,b;
    cin>>a>>b;

    long long int res=a*b;

    cout<<setprecision(0)<<fixed<<res;
}

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


    solve();
    return 0;
}


Measured memory_bytes: 3764
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
#include <set>
//#include <string.h>
using namespace std;
using Graph = vector<vector<int>>;
queue<long>que;

int main(){
    string a,b;
    cin >> a>>b;
    string b1 = b.substr(0,b.size()-1);
    if(b1==a)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}



Measured memory_bytes: 3624
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())printf("%d ",v[_]);cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n;
	cin>>n;
	vvi in(n,vi(n));
	rep(i,n)rep(j,n)cin>>in[i][j];
	int N=1<<n,MOD=1000000007;
	vi dp(N);
	dp[0]=1;
	rep(i,n)for(int j=N-1;j>=0;j--)if(dp[j])rep(k,n)if(!(1<<k&j)&&in[i][k])
		(dp[j|1<<k]+=dp[j])%=MOD;

	cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 8448
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
vector<int>g[50];
map<pair<int,int>, int> mp;
ll cal(int n, const int u, const int v){
    vector<int> pre(n);
    queue<int>q;
    q.push(u);
    vector<int>used(n);
    while(q.size()){
        int s = q.front();
        used[s]=1;
        q.pop();
        for(auto x:g[s]){
            if(used[x])continue;
            q.push(x);
            pre[x] = s;
        }
    }
    ll res = 0;
    int now = v;
    while(now!=u){
        res+=1LL<<mp[{now,pre[now]}];
        now = pre[now];
    }
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
        mp[{a,b}] = mp[{b,a}] = i;
    }
    int m;
    cin >> m;
    vector<ll> st(m);
    rep(i,m){
        int u, v;
        cin >> u >> v;
        st[i] = cal(n, u - 1, v - 1);
    }
    vector<ll> dp(1<<m);
    vector<ll> dp2(1<<m);
    rep(i,1<<m){
        if(i){
            rep(j,m){
                if(i>>j&1){
                    dp2[i] = st[j] | dp2[i-(1<<j)];
                    break;
                }
            }
        }
        dp[i] = 1LL<<(n - 1 - __builtin_popcountll(dp2[i]));
    }
    ll ans = 0;
    for(int i = 0; i < 1 << m; i++){
        int f = __builtin_popcount(i);
        if(f%2)ans -= dp[i];
        else ans += dp[i];
    }
    cout << ans << endl;
}


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

int n, a;
int x[55];
long long way[2][27][2555], res;

void go(int v, int t, int cur = 0, int cnt = 0) {
	if (v >= t) {
		way[0][cnt][cur]++;
		return;
	}

	go(v + 1, t, cur + x[v], cnt + 1);
	go(v + 1, t, cur, cnt);
}
void go2(int v, int t, int cur = 0, int cnt = 0) {
	if (v >= t) {
		way[1][cnt][cur]++;
		return;
	}

	go2(v + 1, t, cur + x[v], cnt + 1);
	go2(v + 1, t, cur, cnt);
}
int main() {
	scanf("%d %d", &n, &a);
	
	for (int i = 0; i < n; i++) scanf("%d", &x[i]);

	go(0, n / 2);
	go2(n / 2, n);

	for (int i = 0; i <= n / 2 + 1; i++) {
		for (int j = 0; j <= n / 2 + 1; j++) {
			if (i == 0 && j == 0) continue;

			int tot = i + j;
			int should = a * tot;

			for (int k = 0; k <= 2500; k++) {
				if (should - k < 0) break;
				res += way[0][i][k] * way[1][j][should - k];
			}
		}
	}

	printf("%lld\n", res);

	return 0;
}	

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

using namespace std;

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

    int k, n, cur = 0;
    cin >> k >> n;
    int arr[n];

    for (int i = 0; i < n; i++)
        cin >> arr[i];
    for (int i = 1; i < n; i++)
        cur = max(cur, arr[i] - arr[i - 1]);
    cur = max(cur, k - arr[n - 1] + arr[0]);

    cout << k - cur << '\n';

    return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

long double rad = 3.14159265358979 / 180.0;

pair<long double, long double> calc(long double l, long double t){
    pair<long double, long double> res;
    if(t < 90){
        res.first = l * sin(t * rad);
        res.second = l * cos(t * rad);
    }else if(t < 180){
        res.first = l * cos((t - 90) * rad);
        res.second = l * -sin((t - 90) * rad);
    }else if(t < 270){
        res.first = l * -sin((t - 180) * rad);
        res.second = l * -cos((t - 180) * rad);
    }else{
        res.first = l * -cos((t - 270) * rad);
        res.second = l * sin((t - 270) * rad);
    }
    return res;
}

int main(){
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double ta = (h * 60.0 + m) / (12 * 60) * 360;
    long double tb = m * 1.0 / 60 * 360;
    auto ac = calc(a, ta);
    auto bc = calc(b, tb);
    long double ans = sqrt(abs(ac.first - bc.first) * abs(ac.first - bc.first) + abs(ac.second - bc.second) * abs(ac.second - bc.second));
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 4168
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
a = na()
b = [0]*40

for i in a:
    for j in range(40):
        if (i>>j) & 1:
            b[j]+=1

ans = 0
for i in range(40)[::-1]:
    if b[i] < n/2:
        ans += 1<<i
    if ans > k:
        ans -= 1<<i

bns = 0
for i in a:
    bns += i^ans

print(bns)

Measured memory_bytes: 14620
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
int main ()
{
    long long int a,b;
    cin>>a>>b;
    long long unsigned shuma=a+b;
    if(a==0 || b==0 || shuma%2==1)
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
    else
    {
        shuma=shuma/2;
        cout<<shuma;
    }
 
     return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MOD int(1e9 + 7)
using namespace std;

long long a[1001],div_final = 1,i,N;

void dec_fact(int N)
{
    int d = 2,p = 0;
    while(N > 1)
    {
        while(N % d == 0)
            N /= d, ++p;
        if(p)
            a[d] += p,p = 0;
        if(d == 2)
            d++;
        else
            d += 2;
        if(d * d > N)
            d = N;
    }

}

int main()
{
    cin >> N;
    for(i = 1; i <= N; ++i)
        dec_fact(i);
    for(i = 1; i <= N; ++i)
        if(a[i])
            div_final = (div_final*(a[i] + 1)) % MOD;
    cout << div_final;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
 
 
def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}
 
 
def solve(N, T, t):
    ans = 0
    t_dif = [t[i + 1] - t[i] for i in range(N - 1)]
    
    for i in t_dif:
        if i >= T:
            ans += T
        else:
            ans += i
    
    ans += T
    
    return ans

 
def main():
    N, T = ILI()
    t = ILI()
    print(solve(N, T, t))
 
 
if __name__ == "__main__":
    main()


Measured memory_bytes: 26168
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 500005;
int A[MAX_N];
string str;
long long ans;
int main(void)
{
	cin >> str;
	int n = str.size();
	for (int i = 0; i < n; i++)
	{
		if (str[i] == '<')
		{
			A[i + 1] = max(A[i + 1], A[i] + 1);
		}
	}
	for (int i = n - 1; i >= 0; i--)
	{
		if (str[i] == '>')
		{
			A[i] = max(A[i], A[i + 1] + 1);
		}
	}
	for (int i = 0; i <= n; i++)
	{
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int n; cin >> n;
    vector<int> p(n); rep(i, n) cin >> p[i];
    vector<int> q(n); rep(i, n) cin >> q[i];
    vector<int> nums(n);
    iota(nums.begin(), nums.end(), 1);

    int cnt = 0;
    int pans = 0;
    int qans = 0;
    do {
        cnt++;
        bool pflag = true;
        bool qflag = true;
        rep(i, n){
            if(p[i] != nums[i]) pflag = false;
            if(q[i] != nums[i]) qflag = false;
        }
        if(pflag) pans += cnt;
        if(qflag) qans += cnt;
    } while(next_permutation(nums.begin(), nums.end()));
    int ans = abs(pans - qans);
    OP(ans);
}


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

using namespace std;

int main(){
	double n;
	double x,y;
	cin>>n;
	x=y=n;
	while(cin>>n){
		x=min(x,n);
		y=max(y,n);
	}
	cout<<y-x<<endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    map<int,ll> mp;
    mp[1]=300000;
    mp[2]=200000;
    mp[3]=100000;
    int x,y;
    while(cin>>x>>y)
    {
        ll ans=mp[x]+mp[y];
        if(x==1 && y==1)
        {
            ans +=400000;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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



int main() {
	int a, b;
	cin >> a >> b;
	int ans=0;
if(a>=b)
	for (int i = 0; i < a; i++) {
		ans += b * pow(10, i);
	}
else
for (int i = 0; i < b; i++) {
	ans += a * pow(10, i);
}
 cout << ans << endl;
}

Measured memory_bytes: 892