akhauriyash/Code-Regression huggingface dataset:
#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);
	rep(i,n) cin >> a[i];
	vector<int> s = a;
	sort(s.rbegin(),s.rend());
	rep(i,n)
	{
		int ans = s[0];
		if(s[0] == a[i]) ans = s[1];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n;
  cin >> n;
  map<int, int> m;
  rep(i, n){
    int k;
    cin >> k;
    m[k-1]++;
    m[k]++;
    m[k+1]++;
  }
  int ans = 0;
  for(auto itr = m.begin(); itr != m.end(); itr++){
    ans = max(ans, itr->second);
  }
  cout << ans << endl;
  system("pause");
}


Measured memory_bytes: 4984
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

using namespace std;

typedef pair<int, int> pii;

int a[100010];
int c[100010];

int main() {
	int N, S;
	scanf("%d %d", &N, &S);

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

	int l = 0, r = -1, L = 10000000;
	int t = 0;
	
	while (r < N)
	{
		if (t == S)
		{
			L = min(L, (r - l) + 1);
			if (L == S)
			{
				break;
			}
			if (a[l] <= S)
			{
				c[a[l]]--;
				if (c[a[l]] == 0)
				{
					t--;
				}
			}
			l++;
		}
		else
		{
			r++;
			if (a[r] <= S)
			{
				c[a[r]]++;
				if (c[a[r]] == 1)
				{
					t++;
				}
			}
		}
	}

	printf("%d\n", L == 10000000 ? 0 : L);
}


Measured memory_bytes: 3948
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int x;

			for (int cnt = 1; (x = sc.nextInt()) != 0; cnt++) {
				System.out.println("Case " + cnt + ": " + x);
			}
		}
	}
}


Measured memory_bytes: 41328
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100000;

int main(){
    int N;
    int A[MAX],B[MAX];
    int diff[MAX];

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

    long long d = 0;

    for(int i = 0;i < N;i++){
        diff[i] = A[i] - B[i];
        d += diff[i];
    }

    sort(diff,diff + N);

    int l = 0;
    int r = N - 1;
    int cnt = 1;

    if(diff[0] >= 0){
        cout << 0 << endl;
        return 0;
    }

    while(diff[l] < 0){
        cnt++;
        if(diff[r] <= 0){
            cout << -1 << endl;
            return 0;
        }

        if(diff[l] + diff[r] > 0){
            diff[r] += diff[l];
            l++;
        }else if(diff[l] + diff[r] < 0){
            diff[l] += diff[r];
            r--;
        }else{
            l++;
            r--;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>

int main(void){
	char s[1010],m[100],c[1010],p[1010];
	int q,i,j,a,b;
	scanf("%s %d",s,&q);	/*????????????????????????????????°*/
	strcpy(c,s);		/*??????????????????*/
	for(i=0;i<q;i++){
	scanf("%s",m);		/*??????????????????*/
	if(strcmp(m,"print")==0){	/*??????*/
		scanf("%d %d",&a,&b);
		for(j=a;j<=b;j++){
			printf("%c",s[j]);
			}
		strcpy(c,s);	/*??????????????????*/
		printf("\n");
		}
		if(strcmp(m,"reverse")==0){	/*??????*/
		scanf("%d %d",&a,&b);
		for(j=a;j<=b;j++){
		s[j]=c[b-j+a];		/*??????*/
		}
		strcpy(c,s);	/*??????????????????*/
		}
		if(strcmp(m,"replace")==0){		/*??????*/	
		scanf("%d %d %s",&a,&b,p);
		for(j=a;j<=b;j++){
		s[j]=p[j-a];		/*????????????*/
		}
		strcpy(c,s);	/*??????????????????*/
		}
	}
	return 0;
}

Measured memory_bytes: 588
N, K = map(int, input().split())

x = []
for i in range(N):
    x.append(1)

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for num in A:
        x[num-1] = 0

count = 0
for num in x:
    if num == 1:
        count += 1

print(count)

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n, k;
	cin >> n >> k;

	vector<int> mp(200001, 0);
	rep (i, 0, n) {
		int tmp;
		cin >> tmp;
		mp[tmp]++;
	}

	sort(mp.begin(), mp.end(), greater<int>());
	int res = n;
	rep (i, 0, k) {
		res -= mp[i];
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    ll ret = 1;
    rep(i,n){
        ret *= (i+1);
        ret %= MOD;
    }
    cout << ret << endl;
}


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

int main() {
  int n;
  cin >> n;
  cout << n / 2 + n % 2 << endl;
  return 0;
}


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

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int main() {
	int X, Y;
	cin >> X >> Y;

	REP(crane,X+1) {
		int turtle = X - crane;
		if (crane * 2 + turtle * 4 == Y) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
using namespace std;
#define PI 3.141592
int main(){
  float angle=0;
  float x=0,y=0;
  float d,t;
  string str;
  cin >> str;
  if(str[1]==','){
    d= str[0]-'0';
    if(str[2]=='-'){
      if(str.size()==4) t = (str[3]-'0')*(-1);
      else if(str.size()==5) t = ((str[3]-'0')*10+(str[4]-'0'))*(-1);
      else t = ((str[3]-'0')*100+(str[4]-'0')*10+(str[5]-'0'))*(-1);
    }else{
      if(str.size()==3) t = str[2]-'0';
      else if(str.size()==4) t = (str[2]-'0')*10+(str[3]-'0');
      else t = (str[2]-'0')*100+(str[3]-'0')*10+(str[4]-'0');
    }
  }else if(str[2]==','){
    d= (str[0]-'0')*10+str[1]-'0';
    if(str[3]=='-'){
      if(str.size()==5) t = (str[4]-'0')*(-1);
      else if(str.size()==6) t = ((str[4]-'0')*10+(str[5]-'0'))*(-1);
      else t = ((str[4]-'0')*100+(str[5]-'0')*10+(str[6]-'0'))*(-1);
    }else{
      if(str.size()==4) t = str[3]-'0';
      else if(str.size()==5) t = (str[3]-'0')*10+(str[4]-'0');
      else t = (str[3]-'0')*100+(str[4]-'0')*10+(str[5]-'0');
    }
  }else if(str[3]==','){
    d= (str[0]-'0')*100+(str[1]-'0')*10+(str[2]-'0');
    if(str[4]=='-'){
      if(str.size()==6) t = (str[5]-'0')*(-1);
      else if(str.size()==7) t = ((str[5]-'0')*10+(str[6]-'0'))*(-1);
      else t = ((str[5]-'0')*100+(str[6]-'0')*10+(str[7]-'0'))*(-1);
    }else{
      if(str.size()==5) t = str[4]-'0';
      else if(str.size()==6) t = (str[4]-'0')*10+(str[5]-'0');
      else t = (str[4]-'0')*100+(str[5]-'0')*10+(str[6]-'0');
    }
  }
  while(d!=0||t!=0){
    x+=d*sin(angle/180*PI);y+=d*cos(angle/180*PI);
    angle+=t;
    if(angle>360) angle-=360;
    if(angle<-360) angle+=360;
    cin >> str;
      if(str[1]==','){
    d= str[0]-'0';
    if(str[2]=='-'){
      if(str.size()==4) t = (str[3]-'0')*(-1);
      else if(str.size()==5) t = ((str[3]-'0')*10+(str[4]-'0'))*(-1);
      else t = ((str[3]-'0')*100+(str[4]-'0')*10+(str[5]-'0'))*(-1);
    }else{
      if(str.size()==3) t = str[2]-'0';
      else if(str.size()==4) t = (str[2]-'0')*10+(str[3]-'0');
      else t = (str[2]-'0')*100+(str[3]-'0')*10+(str[4]-'0');
    }
  }else if(str[2]==','){
    d= (str[0]-'0')*10+str[1]-'0';
    if(str[3]=='-'){
      if(str.size()==5) t = (str[4]-'0')*(-1);
      else if(str.size()==6) t = ((str[4]-'0')*10+(str[5]-'0'))*(-1);
      else t = ((str[4]-'0')*100+(str[5]-'0')*10+(str[6]-'0'))*(-1);
    }else{
      if(str.size()==4) t = str[3]-'0';
      else if(str.size()==5) t = (str[3]-'0')*10+(str[4]-'0');
      else t = (str[3]-'0')*100+(str[4]-'0')*10+(str[5]-'0');
    }
  }else if(str[3]==','){
    d= (str[0]-'0')*100+(str[1]-'0')*10+(str[2]-'0');
    if(str[4]=='-'){
      if(str.size()==6) t = (str[5]-'0')*(-1);
      else if(str.size()==7) t = ((str[5]-'0')*10+(str[6]-'0'))*(-1);
      else t = ((str[5]-'0')*100+(str[6]-'0')*10+(str[7]-'0'))*(-1);
    }else{
      if(str.size()==5) t = str[4]-'0';
      else if(str.size()==6) t = (str[4]-'0')*10+(str[5]-'0');
      else t = (str[4]-'0')*100+(str[5]-'0')*10+(str[6]-'0');
    }
  }
  }
  int x1=x,y1=y;
  
  printf("%d\n%d\n",x1,y1);
  return 0;
}

Measured memory_bytes: 1184
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

line = -20
satisfy = 0
for i in A:
    satisfy += B[i - 1]
    if line + 1 == i:
        satisfy += C[i - 2]
    line = i

print(satisfy)


Measured memory_bytes: 3060
n, k = map(int, input().split())

A = [0] * n
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in range(d):
        A[a[i]-1] += 1

ans = 0
for i in range(n):
    if A[i] == 0:
        ans += 1

print(ans)



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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

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

    ios_base::sync_with_stdio(false);

    long long n, a, b;
    cin >> n >> a >> b;
    if(a + b >= n){
        cout << min(n, a) << "\n";
        return 0;
    }
    long long rem = n % (a + b);
    cout << (n / (a + b)) * a + (rem <= (a + b) ? min(a, rem) : (rem / (a + b)) * a) << "\n";
}


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

int main(){
  int n;
  cin>>n;
  int even=0,odd=0;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    if(a%2==0) even++;
    else odd++;
  }
  even+=odd/2;
  if(odd%2!=0){
    if(even==0) cout<<"YES";
    else cout<<"NO";
  }else{
    cout<<"YES";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define All(A) A.begin(),A.end()
#define RAll(A) A.rbegin(),A.rend()
typedef long long LL;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;


string dfs(string s,int t,LL N){
    if(t==-1) return s;
    LL a=0,b=0;
    for(LL i=0;i<t;i++){
        if(i%2){
            b-=1LL<<i;
        }
        else{
            a+=1LL<<i;
        }
    }
    if(t%2){
        if(N+(1<<t)<=a) return dfs(s+"1",t-1,N+(1<<t));
        else return dfs(s+"0",t-1,N);
    }
    else{
        if(N-(1<<t)>=b) return dfs(s+"1",t-1,N-(1<<t));
        else return dfs(s+"0",t-1,N);
    }
}


int main(){
    LL N;
    cin >> N;
    LL a=0,b=0;
    if(N==0) puts("0");
    string s="1";
    for(LL i=0;i<100;i++){
        if(i%2){
            b-=1LL<<i;
            if(b<=N&&N<0){
                cout << dfs(s,i-1,N+(1LL<<i)) << endl;
                return 0;
            }
        }
        else{
            a+=1LL<<i;
            if(a>=N&&N>0){
                cout << dfs(s,i-1,N-(1LL<<i)) << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<math.h>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<map>
#include<set>
#define FOR(i,a) for(int i=0;i<a;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define ll long long
using namespace std;
int n,b;
int a[100000];
int ans = 0;
int main() {
	cin >> n >> b;
	if((n*b)%2 == 0){
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    std::ios_base::sync_with_stdio(false);

    int n,m; cin >> n >> m;

    UnionFind uft(n);

    rep(i,m){
        int x,y,z; cin >> x >> y >> z;
        uft.unionSet(x-1, y-1);
    }

    std::vector<bool> used(n,false);
    int ans = 0;

    rep(i,n){
        if(used[uft.root(i)]){
            continue;
        } else {
            ans++;
            used[uft.root(i)] = true;
        }
        
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(){
  int num,jap,i;
  float btc,temp,sum;
  char type[3];
  char str2[3]="JPY";
  jap =0;
  btc =0;
  scanf("%d",&num);
  for(i=1;i<=num;i++){
    scanf("%f %s",&temp,type);
    if(strcmp(type,str2)==0){ jap=jap+temp;}
    else {btc=btc+temp;}
  }
  sum = jap+btc*380000.0;
  printf("%f\n",sum);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdbool.h>

int main(){
	int h,w,i,j;
	while(scanf("%d %d",&h,&w),h!=0 && w!=0){
			bool flags=true,flagl=false;
		for(i=0;i<h;i++){
			if(flagl) flagl=false;
			else flagl=true;
			flags=flagl;
			for(j=0;j<w;j++){
				if(flags){
					printf("#");
					flags=false;
				}
				else{
					printf(".");
					flags=true;
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}




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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long

typedef pair<lint, lint> P;
const lint MOD = 1e9+7;
const lint INF = MOD * MOD;

int main(){
    int a, b, c, d, e, f;
    cin>>a>>b>>c>>d>>e>>f;

    vector<int> water, suger;
    int p = 0, q = 0;
    while(1){
        if(100*p*a > f) break;
        q = 0;
        while(1){
            if(100*p*a + 100*q*b > f) break;
            water.push_back(100*p*a + 100*q*b);
            q++;
        }
        p++;
    }
    p = 0;
    while(1){
        if(p*c > f) break;
        q = 0;
        while(1){
            if(p*c + q*d > f) break;
            suger.push_back(p*c + q*d);
            q++;
        }
        p++;
    }

    sort(all(suger)); suger.erase(unique(all(suger)), suger.end());
    int w = 0, s = 0; double x = -1;
    rep(i, water.size()){
        if(water[i] == 0) continue;
        int max_s = min(f - water[i], e * water[i] / 100);
        auto itr = upper_bound(all(suger), max_s);
        int sug;
        if(itr == suger.begin()) sug = 0;
        else sug = *(--itr);
        double y = (double)sug / (double)(sug + water[i]);
        if(y > x){
            w = water[i]; s = sug; x = y;
        }
    }
    cout << (w+s) << " " << s << endl;
}

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

#define sid 200050
#define ri register int
#define mod 1000000007

int fac[sid], inv[sid];
int H, W, A, B;

void Init_C() {
    fac[0] = fac[1] = 1; inv[0] = inv[1] = 1;
    for(ri i = 2; i <= 200000; i ++) fac[i] = 1ll * fac[i - 1] * i % mod;
    for(ri i = 2; i <= 200000; i ++) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
    for(ri i = 2; i <= 200000; i ++) inv[i] = 1ll * inv[i - 1] * inv[i] % mod;
}

int C(int n, int m) {
    if(m > n) return 0;
    return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int way(int x1, int y1, int x2, int y2) {
    return C(x2 - x1 + y2 - y1, x2 - x1);
}

int main() {
    Init_C();
    cin >> H >> W >> A >> B;
    int ans = 0, sum = 0;
    for(ri i = 1; i <= H - A; i ++)
    ans = (ans + 1ll * way(1, 1, B, i) * way(B + 1, i, W, H) % mod) % mod; 
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

const int N = 1e5 + 5;

string s, t;
vector<int> have[26];

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

    vector<bool> diff(26);

    cin >> s >> t;

    for (char c : s) 
        diff[c - 'a'] = true;;
    for (char c : t) 
        if (!diff[c - 'a']) {
            cout << -1 << endl; return 0;
        }

    int n = (int) s.size();
    for (int i = 0; i < n; ++i)
        have[s[i] - 'a'].push_back(i);

    int m = (int) t.size();

    ll cnt = 0, idx = -1;
    for (int i = 0; i < m; ++i) {
        ll nxt = upper_bound(have[t[i] - 'a'].begin(), have[t[i] - 'a'].end(), idx) - have[t[i] - 'a'].begin();

        if (nxt == (int) have[t[i] - 'a'].size()) {
            cnt++;
            nxt = 0;
        }

        idx = have[t[i] - 'a'][nxt];
    }

    cout << cnt * n + idx + 1 << endl;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=998244353;

int n;
int f[15];

void dfs(int cnt,string s)
{
    if(cnt>n)
    {
        cout<<s<<'\n';
        return;
    }
    for(int i=1;i<=cnt;i++)
    {
        string ss=s;
        if(f[i]==0)
            continue;
        ss+=char('a'+i-1);
        f[i+1]++;
        dfs(cnt+1,ss);
        f[i+1]--;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    string a;
    f[1]=1;
    dfs(1,a);











}


Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=300005;
int S[MAXN],n,m;
int lowbit(int x){return x&-x;}
void modify(int x,int c){for(;x<=m;x+=lowbit(x))S[x]+=c;}
int qry(int x){int ret=0;for(;x>=1;x-=lowbit(x))ret+=S[x];return ret;}
vector<pii> vec[MAXN];
int ans[MAXN];
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)
	{
		int l=read(),r=read();
		vec[r-l+1].emplace_back(mp(l,r));
		modify(l,1);modify(r+1,-1);
	}
	int pres=0;
	for(int i=m;i>=1;i--)
	{
		int sum=0;pres+=SZ(vec[i]);
		for(auto p:vec[i])modify(p.first,-1),modify(p.second+1,+1);
		for(int j=1;i*j<=m;j++)sum+=qry(j*i);
		ans[i]=sum+pres;
	}
	for(int i=1;i<=m;i++)pr2(ans[i]);
	return 0;
}



Measured memory_bytes: 13056
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	as := make([]int, 3*n)
	for i := 0; i < len(as); i++ {
		as[i] = eGetInt(scanner)
	}
	sort.Ints(as)
	sum := 0
	for i := n; i < len(as); i = i + 2 {
		sum += as[i]
	}
	fmt.Println(sum)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 5760
N = int(input())
L = list(map(int, input().split()))


L.sort(reverse=True)
dic = {}
cnt = 0

for i in range(1, N - 1):
    p = L[i]
    for j in range(i + 1, N):
        s = p + L[j]

        if s not in dic:
            dic[s] = 1
        else:
            dic[s] += 1

for i in range(N - 2):
    p = L[i]

    if i > 0:
        for x in range(i + 1, N):
            dic[p + L[x]] -= 1

    for key, value in dic.items():
        if key > p:
            cnt += value

print(cnt)

Measured memory_bytes: 3316
def isCLKWISE(ph):
    a = [-ph[-3][0]+ph[-1][0],ph[-1][1]-ph[-3][1]]
    b = [-ph[-3][0]+ph[-2][0],ph[-2][1]-ph[-3][1]]
    crs = b[1]*a[0] - a[1]*b[0]
    if crs < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P.append([int(x) for x in input().split()])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

Measured memory_bytes: 33776
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, M; cin >> N >> M;
    vec k(M);
    mat s(M);
    REP(i, M){
        cin >> k[i];
        s[i] = vec(k[i]);
        cin >> s[i];
    }
    vec p(M); cin >> p;
    int ans = 0;
    REP(i, bit(N)){
        vec cnt(M, 0);
        int c = 0;
        REP(j, M){
            for(int v: s[j]) if((i >> (v - 1)) & 1) cnt[j]++;
            if(cnt[j] % 2 == p[j]) c++;
        }
        if(c == M)ans++;
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
from collections import deque
n, m = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(n)]
arr.sort()
arr = deque(arr)
ans = 0
while m > 0:
    shop = arr.popleft()
    if shop[1] < m:
        ans += shop[0] * shop[1]
        m -= shop[1]
    else:
        ans += shop[0] * m
        break
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


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

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll n,x,d;
  cin >> n >> x >> d;
  
  if(d==0) {
    if(x==0) cout << 1 << endl;
    else cout << n+1 << endl;
    return 0;
  }
  else if(d<0) {
   x=-x;
   d=-d; 
  }
 
 
  map<ll,vpll> mp;
  rep(k,0,n+1){
    ll u=k*(2*n-k-1)*d/2+k*x;
    ll l=k*(k-1)*d/2+k*x;
      mp[((k*x)%d+d)%d].push_back(make_pair(l,u));  
  }
  
   ll res=0;
  for(auto p:mp){
   vpll v=p.second;
    sort(v.begin(),v.end());
   ll now=-1*inf;
    rep(i,0,v.size()){
     if(v[i].first>now) {
       res+=(v[i].second-v[i].first)/d+1;
       now=v[i].second;
     }
     else if(v[i].second>now){
        res+=(v[i].second-now)/d;
       now=v[i].second;
     } 
    }
  }
  
  cout << res << endl;
 
}

Measured memory_bytes: 22144
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
   string s, t;
   cin >> s >> t;
   for (int i = 0; i < s.size(); ++i){
      if (s==t){
         cout << "Yes" << endl;
         return 0;
      }
      else {
         char cp = s[s.size()-1];
         for (int j = s.size()-1; j >= 1; --j){
            s[j] = s[j-1];
         }
         s[0] = cp;
      }
   }
   cout << "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;
const int inf = 1001001001;
vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,-1,0,1};


int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s (h);
    rep(i,h) cin >> s.at(i);
    
    int ans = 0;
    rep(i,h){
        rep(j,w){
            if(s.at(i).at(j) == '#') continue;
            vector<vector<int>> seen (h, vector<int> (w,inf));
            seen.at(i).at(j) = 0;
            queue<pair<int, int>> q;
            q.push({i,j});
            while(!q.empty()) {
                pair<int, int> p;
                p.first = q.front().first;
                p.second = q.front().second;
                q.pop();
                rep(k,4) {
                    int ni = p.first + dy.at(k);
                    int nj = p.second + dx.at(k);
                    if(ni < 0 || ni > h-1 || nj < 0 || nj > w-1) continue;
                    if(seen.at(ni).at(nj)  != inf || s.at(ni).at(nj) == '#') continue;
                    q.push({ni,nj});
                    seen.at(ni).at(nj) = seen.at(p.first).at(p.second) + 1;
                }
            }
            rep(k,h){
                rep(l,w){
                    if(seen.at(k).at(l) == inf) continue;
                    ans = max(ans, seen.at(k).at(l));
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
while True:
    s=int(input())
    if s==0:
        break
    a=1000-s
    b=a//500
    c=a%500
    d=c//100
    e=c%100
    f=e//50
    g=e%50
    h=g//10
    i=g%10
    j=i//5
    k=i%5
    print(b+d+f+h+j+k)


Measured memory_bytes: 5588
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <limits.h>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define lamsort(v, p) sort(v.begin(), v.end(), [](p a, p b) { return a.num < b.num; });
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define INF 1e8
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    int a = 0;
    map<int, int> m;
    rep(i, n)
    {
        cin >> v[i];
        m[v[i]]++;
        if(v[i]==1) a++;
    }
    sort(ALL(v));
    int ans = 0;
    if(a==1) ans++;
    rep(k, n)
    {
        int tmp = pow(v[k], 0.5) + 1;
        bool flag = true;
        for (int i = 1; i < tmp; i++)
        {
            if (v[k] % i == 0)
            {
                if (m[i] > 0)
                    flag = false;
                if (i != v[k] / i)
                {
                    if (i == 1)
                    {
                        if (m[v[k] / i] > 1)
                            flag = false;
                    }
                    else
                    {
                        if (m[v[k] / i] > 0)
                            flag = false;
                    }
                }
            }
        }
        if (flag)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 33644
#include<stdio.h>
int main(void)
{
    int N,M;
    int i,S=0;
    
    scanf("%d%d",&N,&M);
    
    for(i=N-1;i>=1;i--)
      S+=i;
  
    for(i=M-1;i>=1;i--)
      S+=i;
  
    printf("%d\n",S);
  
    return 0;
}

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

int main() {
  int a, b;

  cin >> a >> b;
  
  if ( (a + b) % 2 == 0) {
    cout << (a + b) / 2  << endl;   
  }
  else {
    cout << (a + b) / 2 + 1 << 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;
    string s;cin>>s;
    int r=0;
    int w=0;
    rep(i,n){
        if(s[i]=='R')++r;
        else ++w;
    }
    int w_migi=0;
    for(int i=r;i<n;++i)if(s[i]=='W')++w_migi;
    cout<<w - w_migi<<endl;
	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int dp[10000005];

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    while(n > 0){
        for(int i=1;i<=n;i++){
            if(n <= i*(i+1)/2){
                cout << i << endl;
                n -= i;
                break;
            }
        }
    }
    return 0;
}


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

static const int ds = 6;

void dbigsort( int a[], int i0, int i1, int i2, int i3 ) {
	int ta[] = { a[i0], a[i1], a[i2], a[i3] };
	int max = ta[0];
	for( int i = 0; i < 4; i++ ) {
		if( max < ta[i] ) {
			max = ta[i];
		}
	}

	int t = 0;
	while( true ) {
		if( a[i0] == max ) {
			break;
		}
		t = a[i0];a[i0]=a[i1];a[i1]=a[i2];a[i2]=a[i3];a[i3]=t;
	}

	return;
}

bool dcomp( int a[], int b[] )
{
	for( int i = 0; i < ds; i++ ) {
		if( a[i] != b[i] ) {
			return false;
		}
	}

	return true;
}

bool dcheck( int a[], int b[] ) {
	bool ret = false;
	ret = dcomp( a, b );
	return ret;
}

int main()
{
	int dx[ds], dy[ds];

	for( int i = 0; i < ds; i++ ) {
		cin >> dx[i];
	}
	dbigsort( dx, 0, 1, 5, 4 );
	dbigsort( dx, 0, 3, 5, 2 );
	dbigsort( dx, 1, 2, 4, 3 );

	for( int i = 0; i < ds; i++ ) {
		cin >> dy[i];
	}
	dbigsort( dy, 0, 1, 5, 4 );
	dbigsort( dy, 0, 3, 5, 2 );
	dbigsort( dy, 1, 2, 4, 3 );

	bool ret = false;
	ret = dcheck( dx, dy );
	cout << ( ret?"Yes":"No" ) << endl;

	return 0;
}


Measured memory_bytes: 3124
use num::integer::gcd;
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let a_max = a.iter().max().unwrap();
    let mut v = vec![0; a_max + 1];

    for na in &a {
        v[*na] += 1;
    }

    match v.iter().skip(2).max() {
        Some(n) => {
            if *n > 1 {
                if check_setwise_coprime(&a) {
                    println!("setwise coprime");
                } else {
                    println!("not coprime");
                }
                return;
            }
        }
        None => {}
    }

    for i in 2..a_max + 1 {
        let mut j = i;
        let mut count = 0;
        while j < a_max + 1 {
            if v[j] > 0 {
                count += 1;
            }
            j += i;
        }
        if count > 1 {
            if check_setwise_coprime(&a) {
                println!("setwise coprime");
            } else {
                println!("not coprime");
            }
            return;
        }
    }

    println!("pairwise coprime");
}

fn check_setwise_coprime(a: &Vec<usize>) -> bool {
    let mut ans = gcd(a[0], a[1]);
    for na in a.iter().skip(2) {
        ans = gcd(*na, ans);
    }

    if ans == 1 {
        return true;
    } else {
        return false;
    }
}


Measured memory_bytes: 20476
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN

import sys


def main():
    N = int(input())  # 桁数
    S = str(input())

    ans = set()

    digit1 = set()

    for i in range(0, N - 2):
        if S[i] in digit1:
            continue
        digit1.add(S[i])
        digit2 = set()

        for j in range(i + 1, N - 1):
            if S[j] in digit2:
                continue
            digit2.add(S[j])
            digit3 = set()
            for k in range(j + 1, N):
                if len(digit3) == 10:
                    break
                code = S[i] + S[j] + S[k]
                ans.add(code)

    print(len(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 40556
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n,d;
  cin >> n >> d;
  double x[n][d];
  rep(i,n){
    rep(j,d){
      cin >> x[i][j];
    }
  }

  double sum = 0;
  int memo;
  int cnt = 0;
  rep(i,n){
    for(int j = i+1; j < n; j++){
      rep(k,d){
        sum += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
      }
      memo = (int)(sqrt(sum));
      if(sum == memo*memo) cnt++;
      sum = 0;

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


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

dp = [-1] * N
for x in range(N):
    if x == 0:
        dp[0] = 0
    elif x == 1:
        dp[1] = abs(h[1] - h[0])
    else:
        dp[x] = min(abs(h[x] - h[x - 1]) + dp[x - 1],
                    abs(h[x] - h[x - 2]) + dp[x - 2])
print(dp[N - 1])


Measured memory_bytes: 52208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		
		
		long save = Long.parseLong(sc.next());
		
		long s = 1;
		
		boolean judge = true;
		
		for (int i=1; i<N; i++) {
			s = Long.parseLong(sc.next());
			
			if (s - save > 0) {
				save = s -1;
			}
			
			if (s - save < 0) {
				judge = false;
				break;
			}
			
		}
		
		if (judge) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
		
		
		sc.close();

	}

}


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

int main() {

	string s; cin >> s;
	int n = s.size();
	int tmp1 = 0;
	int tmp2 = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			if (s[i] == '0') {}
			else tmp1++;
		}
		else {
			if (s[i] == '0') tmp1++;
			else {}
		}
		if (i % 2 == 0) {
			if (s[i] == '0') tmp2++;
			else {}
		}
		else {
			if (s[i] == '0') {}
			else tmp2++;
		}
	}
	cout << min(tmp1, tmp2) << endl;
	return 0;
}

Measured memory_bytes: 3756
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 998244353
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	int a, b;
	cin >> a >> b;
	if (abs(b - a) % 2 == 1)
	{
		cout << "IMPOSSIBLE";
		return;
	}
	else
	{
		cout << (a + b) / 2;
	}
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int n, y;
    cin >> n >> y;
    for(int i=0; i<=n; i++) {
        for(int j=0; i+j<=n; j++) {
            int k = (y-10000*i-5000*j)/1000;
            if(k + i + j == n){
                cout << i << " " << j << " " << k << endl;
                    return 0;
            }
        }
    }
    end:
        cout << -1 << " " << -1 << " " << -1 << endl;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  priority_queue<pair<int, int>> P;
  for(int i = 0; i < N; i++){
    int in;
    cin >> in;
    P.push(make_pair(in, i));
  }
  
  multiset<int> place;
  place.insert(-1); place.insert(-1);
  place.insert(N); place.insert(N);
  
  long long second_sum = 0;
  while(!P.empty()){
    auto p = P.top();
    P.pop();
    
    int leftleft, left, right, rightright;
    auto itr = place.lower_bound(p.second);
    right = *itr;
    rightright = *(++itr);
    --itr;
    left = *(--itr);
    leftleft = *(--itr);
    
    second_sum += (long long)(left - leftleft) * (right - p.second) * p.first;
    second_sum += (long long)(rightright - right) * (p.second - left) * p.first;
    
    place.insert(p.second);
  }
  
  cout << second_sum << endl;
  
  return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n ,k; cin >> k >> n;
  vector<bool> dp(n+1, false);
  vi a(k);
  for(int i=0;i<k;++i) {
    cin >> a[i];
  }

  for(int i=0;i<n;++i) {
    if(dp[i]) continue;
    for(int j=0;j<k;++j) {
      if(i + a[j] <= n) {
        dp[i+a[j]] = true;
      }
    }
  }

  cout << (dp[n] ? "First" : "Second") << endl;


}


Measured memory_bytes: 256
#Unhappy Hacking (ABC Edit)
s = input()
r = ""
for i in range (0,len(s)):
    if s[i:i+1] == "0":
        r = r + '0'
    elif s[i:i+1] == "1":
        r = r + '1'
    else:
        if r != "":
            r = r[0:len(r)-1]
        else:
            pass
print(r)

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n+1, vector<int>(m+1));
  for (int i = 0; i < n; i++)
  {
    int k;
    cin >> k;
    a[i][0] = k;
    for(int j = 1; j < k+1; j++)
    {
      cin >> a[i][j];
    }
  }
 
  int count, check;
  for (int i = 1; i <= a[0][0]; i++)
  {
    for (int j = 1; j < n; j++)
    {
      for (int k = 1; k <= a[j][0]; k++)
      {
        if (a[0][i] == a[j][k])
        {
          check++;          
          break;
        }
      }
    }
    if (check == n-1)
    {
      count++;
    }
    check = 0;
  }
  cout << count << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=2e5+5;
int n,a[maxn];
ll ans;
map<int,int> Map;
int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++){
		ans+=Map[i-a[i]];
		++Map[i+a[i]]; 
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 21372
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e5+100, mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n;
	cin>>n;
	cout<<1LL*n*(n-1)/2;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
  long S;
  cin >> S;
  long ans = 10000;
  while (S >= 100) {
    long tmp = abs(753 - (S % 1000));
    if (ans > tmp) ans = tmp;
    S /= 10;
  }
  cout << ans << endl;;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))

r = l[::-1]
ans = [0] * n
for i in range(n):
    s = 0
    for j in range(n//(n-i)):
        s += ans[n-i + j*(n-i)-1]

        # print(j,n-i + j*(n-i)-1)
    else:
        if s%2 != l[n-i-1]:
            ans[n-i-1]+=1
            ans[n-i-1]%=2
ansL = []
R = 0
for i , a in enumerate(ans):
    if a == 1:
        R+=1
        ansL.append(i+1)
print(R)
if R >0:
    print(*ansL)

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  string s;
  cin >> s;

  i64 dsum = 0;
  for (int i = s.length()-1; i > 0; --i) {
    if (s[i] != '9') {
      --s[i-1];
      dsum += 9;
    }
    else dsum += 9;
  }

  cout << dsum + (s[0] - '0') << "\n";

  return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
num = [0] * (10 ** 5)
for i in range(N):
    a, b = list(map(int, input().split()))
    num[a - 1] += b

cnt = 0
for i in range(len(num)):
    cnt += num[i]
    if cnt >= K:
        print(i + 1)
        exit()


Measured memory_bytes: 5876
#include <algorithm>
#include <array>
#include <iostream>
#include <set>
#include <string>
#include <vector>

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

using namespace std;

int to_second(string time) {
  auto h = stoi(time.substr(0, 2));
  auto m = stoi(time.substr(3, 2));
  auto s = stoi(time.substr(6, 2));
  return h * 60 * 60 + m * 60 + s;
}

int main() {
  int n;
  string str;

  while (true) {
    cin >> n;
    if (n == 0) {
      return 0;
    }

    vector<array<int, 2>> timetable(n);
    for (auto &y : timetable) {
      for (auto &x : y) {
        cin >> str;
        x = to_second(str);
      }
    }

    auto start_f = [](const array<int, 2> &t1, const array<int, 2> &t2) {
      return t1[0] < t2[0];
    };
    sort(timetable.begin(), timetable.end(), start_f);

    multiset<int> trains;  // record arraive-time
    int max_train = 0;
    for (auto x : timetable) {
      while (trains.cbegin() != trains.end() && *trains.cbegin() <= x[0]) {
        trains.erase(trains.cbegin());
      }

      trains.insert(x[1]);

      auto pool_size = trains.size();
      if (max_train < pool_size) {
        max_train = pool_size;
      }
    }

    // cout << max_train << endl;
    cout << max_train << endl;
  }
}


Measured memory_bytes: 3296
#include <iostream>
#include <cstdio>
using namespace std;
int main(int argc, const char * argv[]) {
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if((b-a-1)&1)
        puts("Alice");
    else
        puts("Borys");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] p = new int[N];
        
        for(int i = 0; i < N; i++) {
            p[i] = Integer.parseInt(sc.next());
        }

        int count = 0;
        for(int i = 1; i < N-1; i++) {
            if(p[i-1] < p[i] && p[i] < p[i+1] || p[i+1] < p[i] && p[i] < p[i-1]) {
                count++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 21844