akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int tax(int N, int t) {
    return (int)(N * t / 100.0);
}

int main() {
    int A, B; cin >> A >> B;
    for(int i=0; i<=100000; i++) {
        int X = tax(i, 8);
        int Y = tax(i, 10);
        if(X == A and Y == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

class UnionFind {
public:
    UnionFind(int n) {
        this->parent.resize(n);
        this->rank.resize(n);
        this->nsize.resize(n);

        for (int i = 0; i < n; ++i) {
            this->parent[i] = i; // default parent is itself
            this->rank[i] = 0;   // default rank is 0
            this->nsize[i] = 1;  // default size is 1
        }
    }

    ~UnionFind() = default;

    // return the parent of node x
    int find(int x) noexcept {
        if (this->parent[x] == x) {
            return x;
        } else {
            return this->parent[x] = this->find(parent[x]);
        }
    }

    // unite the tree of x and the tree of y
    void unite(int x, int y) noexcept {
        const int xp = this->find(x);
        const int yp = this->find(y);
        if (xp == yp) {
            return;
        }

        // change the parent node of tree whose rank is samller.
        if (this->rank[xp] < this->rank[yp]) {
            this->parent[xp] = yp;
            this->nsize[yp] += this->nsize[xp];
        } else {
            this->parent[yp] = xp;
            this->nsize[xp] += this->nsize[yp];

            if (this->rank[xp] == this->rank[yp]) { 
                ++(this->rank[xp]);
            }
        }
    }

    // return true if x and y belong to the same tree.
    bool same(int x, int y) noexcept {
        return (this->find(x) == this->find(y));
    }

    // return the number of nodes in tree which contains x
    int size(int x) {
        return this->nsize[this->find(x)];
    }

private:
    std::vector<int> parent; // parent of each node
    std::vector<int> rank;   // depth of each tree
    std::vector<int> nsize;  // number of nodes in each tree
};

int main() {
    int N, M, K;
    std::cin >> N >> M >> K; 

    UnionFind uf(N);

    int A[M], B[M];
    for (int i = 0; i < M; ++i) {
        std::cin >> A[i] >> B[i];
        --A[i];
        --B[i];
        uf.unite(A[i], B[i]);
    }

    int C[K], D[K];
    for (int i = 0; i < K; ++i) {
        std::cin >> C[i] >> D[i];
        --C[i];
        --D[i];
    }

    int ans[N];
    for (int i = 0; i < N; ++i) {
        ans[i] = uf.size(i) - 1;
    }

    for (int i = 0; i < M; ++i) {
        --ans[A[i]];
        --ans[B[i]];
    }

    for (int i = 0; i < K; ++i) {
        if (uf.same(C[i], D[i])) {
            --ans[C[i]];
            --ans[D[i]];
        }
    }

    for (int i = 0; i < N; ++i) {
        if (i != 0) {
            std::cout << " ";
        }

        std::cout << ans[i];
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3968
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String, Integer> map = new HashMap<String, Integer>();
        
        while (n-- > 0) {
            String tmp = sc.next();
            int val = map.getOrDefault(tmp, 0);
            map.put(tmp, ++val);
        }
        
        System.out.println("AC x " + map.getOrDefault("AC", 0));
        System.out.println("WA x " + map.getOrDefault("WA", 0));
        System.out.println("TLE x " + map.getOrDefault("TLE", 0));
        System.out.println("RE x " + map.getOrDefault("RE", 0));
    }
}


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


int main() {
	int n = 0;
	cin >> n;
	vector<int> A(n);
	vector<int> B(n);
	vector<int> C(n-1);

	for (int& x : A)
		cin >> x;
	for (int& x : B)
		cin >> x;
	for (int& x : C)
		cin >> x;

		
	int sum = 0;
	for (int i = 0;i < n;i++)
	{
		sum += B.at(i);
		if (i == n - 1)
			break;
		if (A.at(i) == A.at(i+1) - 1)
			sum += C.at(A.at(i) -1);
	}
	cout << sum << "\n";

}


Measured memory_bytes: 256
S = input()
if 'N' in S and 'S' not in S: print('No')
elif 'S' in S and 'N' not in S: print('No')
elif 'W' in S and 'E' not in S: print('No')
elif 'E' in S and 'W' not in S: print('No')
else: print('Yes')


Measured memory_bytes: 2940
#include<stdio.h>
int main(){
		int a,b,c,count=0;
	while(scanf("%d %d",&a,&b)!=EOF){
		count = 0;
		c = a+b;
		while(1){
			c = c /10;
			count++;
			if(c==0)	break;
		}
		printf("%d\n",count);
	}
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
//~ const int mod = (int)1e9 + 7;
const int mod = 998244353;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){stringstream ss;ss << a;string str = ss.str();return str;}
string conv(char a){stringstream ss;ss << a;string str = ss.str();return str;}
int conv(string a){stringstream geek(a); int x = 0; geek >> x;   return x;}



int main(void) 
{	
	int a, p; cin>> a >> p;
	cout<< (a*3 + p)/2;
	return 0;
} 



Measured memory_bytes: 256
#include <string>
#include <string.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
using namespace std;
const int maxn = 400200;
int head[maxn],nxt[maxn],to[maxn],w[maxn];
int flag[maxn];
int sz;
int n,m;
int ans = 1;
void init()
{
	for(int i=1;i<=n;i++) head[i]=-1,flag[i]=0;
	sz=0;
 
}
void add(int u,int v,int ww)
{
	nxt[++sz]=head[u];
	to[sz]=v;
	w[sz]=ww;
	head[u]=sz;
 
}
int dis[maxn];
void dfs(int u,int pre)
{
	if(!ans) return;
	for(int i=head[u];~i;i=nxt[i]){
		int v = to[i];
		if(v==pre) continue;
		if(flag[v]){
			if(dis[v]-dis[u]!=w[i]){
				ans=0;
				return;
			}
		}else{
			flag[v]=1;
			dis[v]=dis[u]+w[i];
			dfs(v,u);
		}
	}
}
int main()
{
	scanf("%d %d",&n,&m);
	init();
	for(int i=1;i<=m;i++){
		int l,r,d;scanf("%d %d %d",&l,&r,&d);
		add(l,r,d);
		add(r,l,-d);
	}
	for(int i=1;i<=n;i++){
		if(flag[i]==0){
			flag[i]=1;
			dis[i]=0;
			dfs(i,-1);
		}
	}
	if(ans){
		printf("Yes\n");
	}else
		printf("No\n");
 
 
	return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <cstdio>
#include <vector>

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)

double dp[3000][3000];

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

	vector<double> p(n+1);
	rep1(i, n) cin >> p[i];

	dp[1][0] = 1.0 - p[1], dp[1][1] = p[1];

	for (int i = 2; i <= n; ++i) {
		for (int j = 0; j <= i; ++j) {
			dp[i][j] += dp[i - 1][j] * (1.0 - p[i]);
			if (j - 1 >= 0) {
				dp[i][j] += dp[i - 1][j - 1] * p[i];
			}
		}
	}

	double ans = 0;

	for (int i = n / 2 + 1; i <= n; ++i) { 
		ans += dp[n][i];
	}

	printf("%.10f\n", ans);
}


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

int main()
{
    ll N;ll ans = 1;
    cin>>N;
    for(ll i = N;i>=1;i--)
    {
        ans*=i;
        ans%= 1000000007;
    }
    cout<<ans<<endl;
    return 0;

}


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

int n;
long long inf = 10e9+1;
long long R[200010] ;
long long M[200010];
int main(){
	cin >> n;
	R[0] = inf;
	for(int i=1;i<=n;i++){
		cin >> M[i];
		R[i] = min(M[i],R[i-1]);
	}
	long long ans = -10e9;
	for(int i=1;i<=n;i++){
		if(ans < M[i]-R[i-1]) ans = M[i] - R[i-1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 6208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003;
const ll INF=1LL<<60;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,K;cin>>N>>K;
    ll left=0,right=INF;
    
    while(right-left>1){
        ll mid=(left+right)/2;
        
        ll sum=0;
        
        ll now=mid;
        
        for(int i=0;i<N;i++){
            sum+=now;
            now/=2;
            
            if(now==0) break;
        }
        
        if(sum>K) right=mid;
        else left=mid;
    }
    
    cout<<left<<endl;
}





Measured memory_bytes: 3160
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>
#include <tgmath.h>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    int n,ans=0;
    cin>>n;

    vector<int>a(n);
    rep(i,n)cin>>a[i];

    rep(i,n-1){
        if(a[i]==a[i+1]){
            a[i+1]=200;
            ans++;
        }
    }


    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a;
    cin >> a;
    int s[a];
    for(int i=0; i<a-1; i++){
        cin >> s[i];
    }
    
    int t[a];
    for(int i=0; i<a; i++){
        t[i] = 0;
    }
    for(int i=0; i<a-1; i++){
        t[s[i]-1]++;
    }
    for(int i=0; i<a; i++){
        cout << t[i] << endl;
    }
}

Measured memory_bytes: 4728
#include <iostream>
using namespace std;
int main(){
  int n,a;
  cin >> n;
  int mn = 1000000;
  int mx= -1000000;
  long long sum = 0;
  
  for(int i = 0; n > i; i++){
    cin >> a;
    if(a > mx){
      mx = a;
    }
    if(a < mn){
      mn = a;
    }
    sum += a;
  }
  cout << mn << " " << mx << " " << sum << endl;
}


Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
#define bitcheck(a,b) ((a>>b)&1)


long long calculate(string fml) {
	long long work = 0;
	long long sum = 0;
	for (int i = 0; i<(int)fml.length(); i++) {
		if (fml.at(i) == '+') {
			sum += work;
			work = 0;
			continue;
		}
		work = work * 10 + (long long)(fml.at(i) - '0');
	}
	sum += work;
	return sum;

}
int main() {
	string s;
	string formula;
	int pos;
	int i;
	long long sum = 0;
	cin >> s;
	for (pos = 0; pos<pow(2, s.length() - 1); pos++) {
		for (i = 0; i<(int)s.length() - 1; i++) {
			formula += s.at(i);
			if (bitcheck(pos, i) == 1) {
				formula += '+';
			}
		}
		formula += s.at(i);
		sum += calculate(formula);

		formula.erase(formula.begin(), formula.end());
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(typeof(a) i=a;i!=(b);++i)
#define CLEAR(a,v) memset(a,v,sizeof(a))
#define MOD 1000000007
using namespace std;
typedef long long int LL;

LL pm(int a){
	LL ret = 1;
	REP(i,a){
		ret = ret * (i+1) % MOD;
	}
	return ret;
}

int main() {
	int N, K;
	cin >> N >> K;
	int ar[N+1][256], tmp[N+1][256];
	CLEAR(ar,0);
	ar[0][0] = 1;
	REP(i,N){
		int v;
		cin >> v;
		REP(j,N){
			REP(k,256){
				tmp[j+1][k] = (ar[j+1][k] + ar[j][k^v]) % MOD;
			}
		}
		tmp[0][0] = 1;
		memcpy(ar, tmp, sizeof(ar));
	}
	LL ret = 0;
	REP(i,N+1){
		LL p = pm(i);
		p *= ar[i][K];
		ret = (ret + p) % MOD;
	}
	cout << ret << endl;
}

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

int main(){
    int n; cin >> n;
    int luca0=2, luca1=1;
    int64_t ans=0, temp1=2, temp2=1;
    for(int i=2; i<=n; ++i){
        ans = temp1+temp2;
        temp1 = temp2;
        temp2 = ans;
    }

    if(n==0) ans=2;
    if(n==1) ans=1;

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,k;
cin >> n;
int ans;
if(n%2==0) {
  ans = n*n/4;
} else {
  ans = (n+1)*(n-1)/4;
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,arr[22],cnt;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&arr[i]);
    for(int i=1;i<=n;i++){
        int fl=0;
        for(int j=1;j<i;j++) if(arr[j] > arr[i]) fl=1;
        if(!fl) cnt++;
    }
    printf("%d",cnt);
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int n , p ; 
string s ;
int fast(int a, int b){
    if ( b == 0 ) return 1 ;
    if ( b == 1 ) return a ;
    int y = fast(a, b / 2) ;
    y %= p ; 
    int ans = 1 ;
    if ( b & 1 ) ans = a ;
    return ((((y % p) * (y % p) ) % p ) * ans ) % p ; 
}
signed main(){
    fastio
    cin >> n >> p >> s ;
    if ( p == 2 ){
        int ans = 0 ;
        for(int i = 0; i < n; i++){
            if ( !(s[i] & 1) ) ans += i + 1 ;
        }
        cout << ans << endl; 
        return 0 ; 
    }
    else if ( p == 5 ){
        int ans = 0 ;
        for(int i = 0; i < n; i++){
            if ( s[i] == '0' || s[i] == '5' ) ans += i + 1 ;
        }
        cout << ans << endl; 
        return 0 ;
    }
    vector<int> v(n + 1) ;
    v[0] = 0 ; 
    for(int i = 1; i < n + 1; i++){
        v[i] = v[i - 1] + (fast(10, n - i) * (s[i - 1] - '0')) % p ; 
        v[i] %= p ;
    }
    map<int,int> mp ; 
    int ans = 0 ;
    for(int i = 0; i < n + 1; i++){
        if ( mp.count(v[i]) ){
            ans += mp[v[i]] ;
        }
        ++mp[v[i]];
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 2580
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}else if(a == b){
		printf("a == b\n");
	}else{
		printf("a < b\n");
	}
	return 0;
}

Measured memory_bytes: 580
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = [list(map(int, input().split())) for _ in range(q)]

c = Counter(a)
ans = sum(a)
for i in range(q):
    ans = ans + (b[i][1] - b[i][0])*c[b[i][0]]
    c[b[i][1]] += c[b[i][0]]
    c[b[i][0]] = 0
    print(ans)

Measured memory_bytes: 40224
n = int(input())
d = [0]*(n+1)
f = [0]*(n+1)
t = 1

adjacent_list = [[] for _ in range(n+1)]
for i in range(n):
    e = list(map(int,input().split()))
    if e[1] != 0:
        adjacent_list[i+1].extend(e[2:])
#print(adjacent_list)

def dfs(v):
    if d[v] >= 1:
        return

    global t
    if d[v] == 0: #未発見なら発見時刻を記入
        d[v] = t
    t += 1

    for nv in adjacent_list[v]:
        dfs(nv)
    f[v] = t
    t += 1

for v in range(1,n+1):
    dfs(v)

#dfs(1)
#print(d)
#print(f)
for i in range(1,n+1):
    print(i, d[i], f[i])


Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  int n; cin >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i];

  ll ans = 0;
  int r=1, t=a[0];
  rep(l,n) {
    while(r<n && (a[r] & t)==0) t |= a[r++];
    ans += r - l;
    t &= ~a[l];
  }
  cout << ans << endl;
}


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

#define sz(a) (int)a.size()
#define rep(i,x,n,j) for(int i=x; i<n; i+=j)

int main()
{
	int x, n; cin >> x >> n;
	int a[n];
	rep(i,0,n,1) cin >> a[i];
	map<int, int> done;
	rep(i,0,n,1) done[a[i]]=1;
	int MIN = 1e9;
	int diff = 1e9, ans = -1;
	rep(i,-10000,10000,1){
		if(done[i]==1) continue;
		if(abs(x-i)<diff){
			ans = i;
			diff = abs(x-i);
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int N = 2 * 1e5;
const int REP = 32;
int func(string& x, int mod) {
    if(mod <= 0) return 0;
    int64_t rem = 0;
    for (auto i = 0; i < (int)x.size(); i++) rem <<= 1, rem = (rem + (x[i] - '0')) % mod;
    return rem;
}

int64_t modpow(int64_t a, int64_t n, int64_t mod) {
    int64_t res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int n, cnt = 0; string x; cin >> n >> x;
    for (auto i = 0; i < n; i++) if(x[i] == '1') cnt++;
    int r1 = func(x, cnt + 1), r2 = func(x, cnt - 1);
    for (auto i = 0; i < n; i++) {
        int r, ans = 1, tmp = cnt;
        if(x[i] == '1') {
            if(tmp != 1) r = r2 - modpow(2, n - i - 1, --tmp);
            else r = 0, ans = 0;
        }
        else r = r1 + modpow(2, n - i - 1, ++tmp);
        r += tmp, r %= tmp;
        while(r > 0) {
            ans++;
            r %= __builtin_popcount(r);
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N, K;
	cin >> N >> K;
	vector<int>h(N);
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> h[i];
		if (h[i] >= K)cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 1024
N = int(input())
S = list(input())
cnt = [0] * N
ans = []

for i in range(N-1):
    if S[i] == S[i+1]:
        cnt[i+1] = 1
for i in range(N):
    if cnt[i] == 0:
        ans.append(S[i])
print(len(ans))

Measured memory_bytes: 5420
#include <iostream>
using namespace std;
int n, m, a, num[51];
int main(void){
    // Your code here!
    cin >> n >> m;
    for (int i = 0; i < m * 2; i++) {
        cin >> a;
        num[a]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << num[i] << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> L(N);
    for(int i = 0; i < N; i++) cin >> L[i];
    sort(all(L));
    reverse(all(L));
    int sum = 0;
    for(int i = 0; i < K; i++){
        sum += L[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {

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

		while(sc.hasNext()){
			int rst = sc.nextInt();
			int n = 0;
			String s = "";
			while(true){
				s = sc.next();
				if(s.compareTo("=")==0)break;
				n = sc.nextInt();
				if(s.compareTo("+")==0){
					rst += n; 
				}else if(s.compareTo("-")==0){
					rst -= n; 
				}else if(s.compareTo("*")==0){
					rst *= n; 
				}else if(s.compareTo("/")==0){
					rst /= n; 
				}
			}
			System.out.println(rst);
						
		}
	}
}

Measured memory_bytes: 19500
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

using P = pair<int, int>;
int main() {
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int dx[] = {1,1,0,-1,-1,-1,0,1};
int dy[] = {0,1,1,1,0,-1,-1,-1};
int c[51][51];
int main()
{

	int w, h;

	while (cin >> w && cin >> h && w != 0 && h != 0)
	{
		for (int i = 1; i < h + 1; i++)
		{
			for (int j = 1; j < w + 1; j++)
			{
				int tmp;
				cin >> tmp;
				if (tmp == 0)
				{
					c[i][j] = -1;
				}
				else
				{
					c[i][j] = 0;
				}
			}
		}

		int count = 0;
		queue<pair<int,int> > q;
		for (int i = 1; i < h + 1; i++)
		{
			for (int j = 1; j < w + 1; j++)
			{
				if (c[i][j] != 0)continue;
				q.push(make_pair(i,j));
				c[i][j] = 1;
				while (q.size() > 0)
				{
					pair<int, int> p = q.front();
					q.pop();
					int y = p.first;
					int x = p.second;

					for (int d = 0; d < 8; d++)
					{
						int nx = x + dx[d];
						int ny = y + dy[d];

						if (nx < 1 || ny < 1 || nx > w || ny > h)continue;
						if (c[ny][nx] != 0)continue;
						q.push(make_pair(ny, nx));
						c[ny][nx] = 1;
					}
				}
				count++;
			}
		}

		cout << count << endl;


	}

	return 0;
}

Measured memory_bytes: 1224
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int dir(int x,int y){
  // up 0, right 1, down 2, left 3
  if(y<0) return 0;
  if(x>0) return 1;
  if(y>0) return 2;
  if(x<0) return 3;
  return -1;
}
int absint(int a){
  return a<0?-a:a;
}
deque<int> rev(deque<int> line){
  deque<int> revline;
  REP(i,SZ(line)){
    if(i%2) revline.push_front(4-line[i]);
    else revline.push_front(line[i]);
  }
  return revline;
}   
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<deque<int> > lines;
    REP(i,n+1){
      deque<int> line;
      int m;
      cin >> m;
      int lastx,lasty,tmpx,tmpy,lastdir,tmpdir;
      REP(j,m){
	int dx,dy;
	cin >> tmpx >> tmpy;
	dx=tmpx-lastx;
	dy=tmpy-lasty;
	if(j>=1){
	  tmpdir=dir(dx,dy);
	}
	if(j>=2){
	  line.PB(((tmpdir-lastdir)+4)%4);
	}
	if(j>=1){
	  line.PB(absint(dx)+absint(dy));
	  lastdir=tmpdir;
	}
	lastx=tmpx;
	lasty=tmpy;
      }
      lines.PB(line);
    }
    FOR(i,1,n+1){
      if(lines[0]==lines[i] || lines[0]==rev(lines[i]))
	cout << i << endl;
    }
    cout << "+++++" << endl;
  }
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T,class U>
ostream& operator<<(ostream& os,const map<T, U> & mp){
	os << "{";
	int i = 0;
	for(auto it : mp){
		if(i) os<<", ";
		os << it;
		i++;
	}
	os << "}";	
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int mod = 1e9 + 7;
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}
int a[2005];
int main(){
	int n, k;
	sd(n); sd(k);
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		sd(a[i]);
		for(int j = 1; j < i; j++) if(a[j] > a[i]) cnt++;
	}
	int c = 0;
	for(int i = 1; i <= n; i++)
	for(int j = 1; j <= n; j++) if(a[i] > a[j]) c++;
	int ans = mul(k, cnt);
	int inv2 = (mod + 1) >> 1;
	ans = add(ans, mul(c, mul(k, mul(k - 1, inv2))));
	printf("%d\n", ans);
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    if (S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi") {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    if(n%2==1){cout<<"No"<<endl;
    return 0;
    }
    else{
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[n/2+i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

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

int main() {
    string S;
    cin >> S;
    int a[30] = {};
    rep(i, S.size()) {
        a[int(S[i]-'a')]++;
    }
    rep(i, 30) {
        if (a[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long h;
    cin >> h;
    if( h%2 == 0){
        h++;
    }
    long long tmp1,tmp2;
    tmp1 = 1;
    tmp2 = 2;
    long long cnt;
    cnt=0;
    while(1){
        tmp1 = tmp1*2;
        tmp2 = tmp2*2;
        cnt++;
        if(h<=tmp1 && h<tmp2) break;
    }
    //cout << cnt << endl;
    long long ans;
    long long i;
    ans = 1;
    for( i=1; i<cnt; i++){
        ans = ans*2+1;
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n, k  = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
ans = 0
for i in range(k):
    ans += p[i]
print(ans)

Measured memory_bytes: 10468
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el cout << "\n"
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);
ll n , m ,k;
ll nbr;

int main()
{
	IOS;
    ll n;
    cin >> n;
    vector<ll> A,B,C;
   vector<ll> dp1(n+1,0);
   vector<ll> dp2(n+1,0);
   vector<ll> dp3(n+1,0);
    for(int i=0;i<n;i++)
    {
        ll a,b,c;
        cin >> a >> b >> c;
        A.push_back(a);
        B.push_back(b);
        C.push_back(c);
    }

    for(int i=1;i<=n;i++)
    {
        dp1[i]=max(dp2[i-1],dp3[i-1])+A[i-1];
        dp2[i]=max(dp1[i-1],dp3[i-1])+B[i-1];
        dp3[i]=max(dp1[i-1],dp2[i-1])+C[i-1];
    }

    cout << max(dp1[n],max(dp2[n],dp3[n]));

    return 0;
}


Measured memory_bytes: 5216
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
f = []
for i in range(n):
    f.append(LIST())
p = []
for i in range(n):
    p.append(LIST())

ans = -inf
for x in product([0, 1], repeat=10):
    if sum(x) != 0:
        tmp = 0
        for j in range(n):
            count = 0
            for k in range(10):
                count += f[j][k]*x[k]
            tmp += p[j][count]
        ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 10376
#include <stdio.h>

int main(void){
  char input[100];
  int a=0;
  int b=0;
  int c=0;
  int d=0;
  int e=0;
  int f=0;
  int g=0;
  int h=0;
  int i=0;
  int j=0;
  int k=0;
  int l=0;
  int m=0;
  int n=0;
  int o=0;
  int p=0;
  int q=0;
  int r=0;
  int s=0;
  int t=0;
  int u=0;
  int v=0;
  int w=0;
  int x=0;
  int y=0;
  int z=0;
  
  int loop;
  char check;
  int flg=0;
  scanf("%s",input);
  
  for(loop=0;input[loop]!='\0';loop++){
    check = input[loop];
    switch(check){
      case 'a':
        a++;
        break;
      case 'b':
        b++;
        break;
      case 'c':
        c++;
        break;
      case 'd':
        d++;
        break;
      case 'e':
        e++;
        break;
      case 'f':
        f++;
        break;
      case 'g':
        g++;
        break;
      case 'h':
        h++;
        break;
      case 'i':
        i++;
        break;
      case 'j':
        j++;
        break;
      case 'k':
        k++;
        break;
      case 'l':
        l++;
        break;
      case 'm':
        m++;
        break;
      case 'n':
        n++;
        break;
      case 'o':
        o++;
        break;
      case 'p':
        p++;
        break;
      case 'q':
        q++;
        break;
      case 'r':
        r++;
        break;
      case 's':
        s++;
        break;
      case 't':
        t++;
        break;
      case 'u':
        u++;
        break;
      case 'v':
        v++;
        break;
      case 'w':
        w++;
        break;
      case 'x':
        x++;
        break;
      case 'y':
        y++;
        break;
      case 'z':
        z++;
        break;        
      default:
        break;
    }
  }
  if(a%2 != 0){
    flg++;
  }
  if(b%2 != 0){
    flg++;
  }
  if(c%2 != 0){
    flg++;
  }
  if(d%2 != 0){
    flg++;
  }
  if(e%2 != 0){
    flg++;
  }
  if(f%2 != 0){
    flg++;
  }
  if(g%2 != 0){
    flg++;
  }
  if(h%2 != 0){
    flg++;
  }
  if(i%2 != 0){
    flg++;
  }
  if(j%2 != 0){
    flg++;
  }
  if(k%2 != 0){
    flg++;
  }
  if(l%2 != 0){
    flg++;
  }
  if(m%2 != 0){
    flg++;
  }
  if(n%2 != 0){
    flg++;
  }
  if(o%2 != 0){
    flg++;
  }
  if(p%2 != 0){
    flg++;
  }
  if(q%2 != 0){
    flg++;
  }
  if(r%2 != 0){
    flg++;
  }
  if(s%2 != 0){
    flg++;
  }
  if(t%2 != 0){
    flg++;
  }
  if(u%2 != 0){
    flg++;
  }
  if(v%2 != 0){
    flg++;
  }
  if(w%2 != 0){
    flg++;
  }
  if(x%2 != 0){
    flg++;
  }
  if(y%2 != 0){
    flg++;
  }
  if(z%2 != 0){
    flg++;
  }
  if(flg != 0){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 2000
#include<iostream>

using namespace std;

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

int main() {
  int n, q;
  cin >> n >> q;
  string name = "kogakubu10gokan";
  rep (i, n) {
    int year;
    string nm;
    cin >> year >> nm;
    if (q < year) {
      cout << name << endl;
      return 0;
    }
    name = nm;
  }
  cout << name << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i);
  }
  for (int i = n - 1; i >= 0; --i) {
    cout << a.at(i);
    if (i == 0) cout << endl;
    else cout << " ";
  }

  return 0;
}


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

const int mod = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	
	vector<int> cnt(n);
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		cnt[t]++;
	}
	
	vector<int> foo(n);
	for (int i = 0; i < n; i++) {
		foo[abs(i - (n - 1 - i))]++;
	}

	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (cnt[i] != foo[i]) {
			ans = 0;
		}
		if (cnt[i] == 2) {
			ans *= 2;
			ans %= mod;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;


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

   string s,hitachi="";
   cin >> s;
   bool ok=false;
   rep(j,0,5){
     hitachi+="hi";
     if(s==hitachi) ok=true;
   }
   if(ok)cout << "Yes" << endl;
   else cout << "No" << endl;
   
}



Measured memory_bytes: 256
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T>
void in(T& x) {
    std::cin >> x;
}

template <typename T>
void out(const T H) {
    std::cout << H;
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << H << " "; out(T...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << "(" << v.first << " " << v.second << ")";
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    os << "[ "; for (auto &i: v) os << i << " "; return os << "]";
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);
    //std::cout.tie(0);

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    inn(a);
    inn(b);
    int k = (a + b);
    (k&1) ? out("IMPOSSIBLE") : out(k/2);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
    int a, b, c, e;
	cin >> a >> b >> c;	
	if (b > c) {
		cout << max(b - (a + c), 0) << "\n";
	}
	else if (b < c) {
		cout << max(c - (a + b), 0) << "\n";
	}
	else {
		cout << '0' << "\n";
	}
	cin >> e;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(b-a<=0){
        cout << "delicious" << endl;
    }else if(b-a<=x){
        cout << "safe"  << endl;
    }else{
        cout << "dangerous"  << endl;
    }


    return 0;
}


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

#define For(i,a,b) for(long long (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX_N 100000

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

ll bit[MAX_N+1];
ll n;
ll k;

ll Sum(ll i){
    ll s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(ll i, ll x){
    while(i <= n){
        bit[i] += x;
        i += i & -i;
    }
}

int main(){
    cin >> n >> k;
    vector<ll> A(n+1);
    vector<ll> sum;
    vector<ll> B(n+1,0);
    vector<ll> t(n+1,0);
    ll ans = 0;
    A[0] = 0;
    B[0] = 0;
    sum.push_back(0);
    Rep(i,n){
        cin >> A[i+1];
        sum.push_back(sum[i] + A[i+1]);
        sum[i+1] -= k;
        B[i+1] = sum[i+1];
        //cout << sum[i+1] << endl;
    }
    //cout << endl;
    sort(All(B));
    B.erase(unique(B.begin(),B.end()),B.end());
    vector<ll> f(n+1);
    Rep(i,n+1){
        ll p = lower_bound(All(B),sum[i])-B.begin();
        f[i] = p+1;
        //cout << f[i] << endl;
    }
    Rep(i,n+1){ 
        t[i] = Sum(f[i]);
        //cout << t[i] << endl;
        ans += t[i];
        add(f[i],1);
    }
    cout << ans << endl;
    //cin >> n;
}


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

int my_ceil(int a, int b){
  return (a + b - 1) / b;
}

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int x, y;
  x = my_ceil(A, D);
  y = my_ceil(C, B);
  if (x >= y) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3592
n=int(input())
L=[0 for _ in range(n+1)]
for i in range(n):
    L[i]=int(input())
list.sort(L, reverse=True)
ans=0
cnt=1
for i in range(n):
    if L[i]==L[i+1]:
        cnt+=1
    else:
        if cnt%2!=0:
            ans+=1
        cnt=1
print(ans)

Measured memory_bytes: 7396
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define INF (1<<26)
int M,N;
int K[100];
int s[100][100];
string cond[100][100];
int t[100][100];

int A[100][100];
int B[100];

int check(int a,int b){
  int L[100],R[100];
  for(int i=0;i<100;i++){
    L[i]=0;
    R[i]=INF;
  }
  for(int i=0;i<K[a];i++){
    if(cond[a][i]==">="){
      L[s[a][i]]=max(L[s[a][i]],t[a][i]);
    }else{
      R[s[a][i]]=min(R[s[a][i]],t[a][i]);
    }
  }

  for(int i=0;i<100;i++)
    if(L[i]>R[i])return 0;
  
  for(int i=0;i<K[b];i++){
    if(cond[b][i]==">="){
      L[s[b][i]]=max(L[s[b][i]],t[b][i]);
    }else{
      R[s[b][i]]=min(R[s[b][i]],t[b][i]);
      if(L[s[b][i]] > R[s[b][i]])return 0;
    }
  }


  return 1;
}

int main(){
  cin>>M>>N;
  for(int i=0;i<M;i++){
    cin>>K[i];
    for(int j=0;j<K[i];j++){
      cin>>s[i][j]>>cond[i][j]>>t[i][j];
      s[i][j]--;
    }
  }

  
  for(int i=0;i<M;i++){
    for(int j=0;j<M;j++){
      A[i][j]=check(i,j);
    }
  }


  bool flg=true;

  for(int i=0;i<M;i++){
    
    for(int j=0;j<M;j++){
      B[j]=0;
      for(int k=0;k<M;k++){
        B[j]+=A[j][k];
      }
    }
      
    int id=-1,maxm=-1;
    for(int j=0;j<M;j++){
      if(maxm<B[j]){
        maxm=B[j];
        id=j;
      }
    }
    
    if(maxm<M-i)flg=false;
    
    for(int j=0;j<M;j++){
      A[j][id]=0;
      A[id][j]=0;
    }
  
  }

  cout<<(flg?"Yes":"No")<<endl;
  
  return 0;
}

Measured memory_bytes: 1868
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a[] {0,1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin >> x >> y;
  cout << (a[x] == a[y]? "Yes" : "No") << endl;
}


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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    vector<int> B(N);

    rep(i,N){
        cin >> A[i];
        B[i] = A[i];
    }

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

    rep(i,N){

        if(A[i] != B[N-1]){
        cout << B[N-1] << endl;
        }

        else{
            cout << B[N-2] << endl;
        }

    }
}

Measured memory_bytes: 3200
import math
x, k, d = map(int,input().split())
x = abs(x)
if x > k * d:
    print(x - k * d)
else:
    time = math.floor(x/d)
    x -= time * d
    k -= time
    if k % 2 == 0:
        print(x)
    else:
        print(d - x)


Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main (){
        long long N;
        long long ans;
        long long count;
        long long tmp;
        cin >> N ;
        for (int i = 0; i < N; i++) {
          cin >> tmp;
          count += tmp;
        }
        ans =count -N;
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
N = int(input())

def calculate(n):
    n = n % 10

    s1 = [2,4,5,7,9]
    s2 = [0,1,6,8]

    if n in s1:
        print("hon")
        return

    if n in s2:
        print("pon")
        return

    print("bon")

calculate(N)

Measured memory_bytes: 9120
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
double n;
while(cin>>n){
if(n>91){
cout<<"heavy"<<endl;
}else if(n>81){
cout<<"light heavy"<<endl;
}else if(n>75){
cout<<"middle"<<endl;
}else if(n>69){
cout<<"light middle"<<endl;
}else if(n>64){
cout<<"welter"<<endl;
}else if(n>60){
cout<<"light welter"<<endl;
}else if(n>57){
cout<<"light"<<endl;
}else if(n>54){
cout<<"feather"<<endl;
}else if(n>51){
cout<<"bantam"<<endl;
}else if(n>48){
cout<<"fly"<<endl;
}else{
cout<<"light fly"<<endl;
}
}
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(){
  int maxv;
  int minv;
  int R[200000];
  int num;
  int i;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%d",&R[i]);
  }

  maxv = R[1] - R[0];
  minv = R[0];

  for(i=1;i<num;i++){

    maxv = maxv > R[i] - minv ? maxv : R[i] - minv;

    minv = minv < R[i] ? minv : R[i];
  }

  printf("%d\n",maxv);

  return 0;
}



Measured memory_bytes: 2636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };


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

	ll n, k, ans = 0;
	cin >> n >> k;
	map<char, ll> v;
	rep(i, k) {
		char x;
		cin >> x;
		v[x]++;
	}
	while (true) {
		string s = to_string(n);
		bool flag = true;
		rep(i, s.size()) {
			if (v[s[i]]) flag = false;
		}
		if (flag) {
			cout << s << endl;
			break;
		}
		else n++;
	}

	return 0;
}


Measured memory_bytes: 256