akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

int main() {
	string S, C,A[2];
	A[0] = "";
	A[1] = "";
	ll Q,T,F,cnt=0;
	std::cin >> S;
	std::cin >> Q;
	rep(i, 0, Q) {
		std::cin >> T;
		if (T == 1) {
			cnt++;
		}
		else {
			std::cin >> F >> C;
			if (F == 1) {
				A[cnt % 2] += C;
			}
			else {
				A[(cnt+1)%2] += C;
			}
		}
	}
	
	ll size = A[cnt % 2].size();
	rep(i, 0, size) {
		std::cout << A[cnt % 2][size - 1 - i];
	}

	if (cnt % 2 == 0) {
		std::cout << S;
	}
	else {
		size = S.size();
		rep(i, 0, size) {
			std::cout << S[size - 1 - i];
		}
	}

	std::cout << A[(cnt + 1)%2] << endl;

	return 0;

}


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

using namespace std;

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

int f[10][10];

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

int main(){
	int x,y,size;
	while (scanf("%d,%d,%d",&x,&y,&size)!=-1){
		int x2,y2;
		switch (size){
			case 1:
				f[y][x]++;
				REP(i,4){
					x2=x+dx[i];
					y2=y+dy[i];
					if (x2>=0 && x2<10 && y2>=0 && y2<10){
						f[y2][x2]++;
					}
				}
				break;
			case 2:
				FOR(i,-1,2){
					FOR(j,-1,2){
						x2=x+i;
						y2=y+j;
						if (x2>=0 && x2<10 && y2>=0 && y2<10){
							f[y2][x2]++;
						}
					}
				}
				break;
			case 3:
				FOR(i,-1,2){
					FOR(j,-1,2){
						x2=x+i;
						y2=y+j;
						if (x2>=0 && x2<10 && y2>=0 && y2<10){
							f[y2][x2]++;
						}
					}
				}
				REP(i,4){
					x2=x+dx[i]*2;
					y2=y+dy[i]*2;
					if (x2>=0 && x2<10 && y2>=0 && y2<10){
						f[y2][x2]++;
					}
				}
				break;
		}
	}
	int e=0;
	int m=0;
	REP(i,10){
		REP(j,10){
			m=max(m,f[i][j]);
		}
	}
	REP(i,10){
		REP(j,10){
			if (f[i][j]==0){
				e++;
			}
		}
	}
	printf("%d\n%d\n",e,m);
	return 0;
}

Measured memory_bytes: 1188
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        String s[]=br.readLine().trim().split(" ");
        int L=Integer.parseInt(s[0])-1;
        int R=Integer.parseInt(s[1]);
        int D=Integer.parseInt(s[2]);

        System.out.println(R/D-L/D);
    }
}

Measured memory_bytes: 32544
from sys import stdin
N = int(stdin.readline().rstrip())
B = [int(_) for _ in stdin.readline().rstrip().split()]
A = [0 for i in range(N)]
A[0] = B[0]
A[-1] = B[-1]
for i in range(1, N-1):
    A[i] = min(B[i], B[i-1])
print(sum(A))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	vi a(3);
	rep(i, 3)cin >> a[i];
	sort(all(a));
	cout << a[0] + a[1] << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}

// long long version
const int MAX_N = 300005;
ll bit[MAX_N+1];
int nn = MAX_N; //　1-index

void adds(int a, ll w){
    for(int x = a; x <= nn; x += x & -x) bit[x] += w;
}
ll sums(int a){ // bit[1,a]の和を返す.
    ll ret = 0;
    for(int x = a; x > 0; x -= x & -x) ret += bit[x];  
    return ret;
}

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

    rep(loop, q){
        int c;
        cin >> c;
        if(c == 0){
            int s, t, x;
            cin >> s >> t >> x;
            adds(s, x);
            adds(t+1, -x);
        }else{
            int x;
            cin >> x;
            ll res = sums(x);
            cout << res << endl;
        }
    }
    
    return 0;
}
 
 



Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

/*
素因数分解して
 2 2 2 2
 3 3 3
 4 4

各素因数の数

*/

void divsoinsu(map<ll, int>& divmap, ll input){
    for (ll i = 2; i*i <= input; i++)
    {
        while((input%i) == 0){
            if (divmap.find(i) == divmap.end()){
                divmap.insert({i, 1});
            } else {
                divmap[i]++;
            }
            input /= i;
        }
    }
    if (input != 1){
        if (divmap.find(input) == divmap.end()){
            divmap.insert({input, 1});
        } else {
            divmap[input]++;
        }
    }
}

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

    map<ll, int> dmap;
    divsoinsu(dmap, n);

    int ans = 0;
    for(auto x = dmap.begin(); x != dmap.end(); x++){
        //cout << x->first  << "  "<< x->second;
        int num = x->second;
        int tans = 1;
        while(1){
            num-=tans;
            if (num < 0){
                tans--; break;
            }
            tans++;
        }
        ans += tans;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3592
a, b, c = map(int, input().split())

ans = 0
flag = False
while True:
    if a == b == c and a % 2 == 0:
        flag = True
        break
    elif a % 2 == b % 2 == c % 2 == 0:
        a, b, c = b//2 + c//2, c//2 + a//2, a//2 + b//2
        ans += 1
    else:
        break

if flag:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n; cin >> n;
  int tmp = 0, tmp2 = 0;
  for(int i = 1; i < n + 1; i++){
    int a; cin >> a;
    if(i != a){
      if(tmp == 0){
        tmp = a;
      }else{
        if(i != tmp){
          cout << "NO";
          return 0;
        }
      }
    }    
  }
  cout << "YES";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(i64, N, X);
    vector<i64> a(N);
    read(a);
    a.push_back(X);
    sort(all(a));

    i64 ans = 0;
    rep(i, 1, N + 1) {
        const i64 d = a[i] - a[i - 1];
        ans = __gcd(ans, d);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

ll acum(int m){
    return m*(m+1)/2;
}

int main(){
    int N; cin >> N;
    int m = -1;
    ll sum;
    for(int i=1;i<=N;i++){
        if(acum(i-1) < N && N <= acum(i)){
            m = i;
            sum = acum(i);
            break;
        }
    }
    int k = sum - N;
    for(int i=1;i<=m;i++){
        if(i == k) continue;
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php
    fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $d);
    $leftWeight = $a + $b;
    $rightWeight = $c + $d;
    switch(true){
      case $leftWeight > $rightWeight:
      echo 'Left';
      break;

      case $leftWeight < $rightWeight:
      echo 'Right';
      break;

      case $leftWeight === $rightWeight:
      echo 'Balanced';
      break;
    }
    
  ?>

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

int main()
{
	string s;
	cin >> s;
	if (s == "SUN")
		cout << 7;
	else if (s == "MON")
		cout << 6;
	else if (s == "TUE")
		cout << 5;
	else if (s == "WED")
		cout << 4;
	else if (s == "THU")
		cout << 3;
	else if (s == "FRI")
		cout << 2;
	else if (s == "SAT")
		cout << 1;
	return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.size()){
        if(s[i]==t[i]) ans++;
     }

     cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N;
    long long x;
    cin >> N >> x;
    vector<long long> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    long long res = 0;
    long long ans = 0;
    for(int i = 0; i < N; i++){
        if(i == 0){
            if(a[i] >= x){
                ans += a[i] - x;
                res = x;
            }
            else res = a[i];
        }
        else if(a[i] >= x - res){
            ans += a[i] - (x - res);
            res = x - res;
        }
        else res = a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
	long long a, b, x;
	long long cnt;
	cin >> a >> b >> x;
	cnt = (b / x) - (a / x);
	if(a % x == 0) cnt++;
	cout << cnt << endl;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
x = int(input())
ans = 0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a+100*b+50*c == x:
        ans += 1

print(ans)

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	string S; cin >> S;
	int y = stoi(S.substr(0,4));
	if(y!=2019){
		cout << (y>2019?"TBD":"Heisei") << endl;
		return 0;
	}

	int m = stoi(S.substr(5,2));
	if(m!=4){
		cout << (m>4?"TBD":"Heisei") << endl;
		return 0;
	}
	
	int d = stoi(S.substr(8,2));
	cout << (d>30?"TBD":"Heisei") << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("-O3")
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<vector>
#include<bitset>
#define DB double
#define LL long long
#define ui unsigned int
#define ull unsigned long long
using namespace std;
  
inline int read(){
    int 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*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int x){
    if(x>9) Out(x/10);
    putchar('0'+x%10);
}
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
LL qpow(LL x,LL y,LL P){
    LL re=1;
    while(y){
        if(y&1) re=re*x%P;
        x=x*x%P;y>>=1;
    }
    return re;
}
const DB eps=1e-6;
const LL P=1e9+7;
const DB PI=acos(-1);
const int N=2e5+50;
int n;
int c[N];
LL f[N],a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&c[i]);
	f[0]=1;
	c[0]=-1;c[n+1]=-1;
	LL x;
	for(int i=1;i<=n;++i){
		f[i]=f[i-1];
		if(c[i]!=c[i-1]){
			x=f[i-1];
			f[i]=(f[i]+a[c[i]])%P;
		}
		if(c[i]!=c[i+1]) a[c[i]]=(a[c[i]]+x)%P;
	}
	cout<<f[n]<<endl;
}
/*

*/

Measured memory_bytes: 4096
#include<stdio.h>
#include<stdlib.h>

int BinarySearch(int*, int, int);

int main(){
  int i,j,n,q,c=0;
  int *S,*T;

  scanf("%d",&n);
  S=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  T=(int *)malloc(q*sizeof(int));
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    c+=BinarySearch(S,T[i],n);
  }

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

}

int BinarySearch(int *x,int key,int n){
  int mid,max,min=0;

  max=n;

  while(min<max){
    mid=(min+max)/2;
    if(key==x[mid]){
      return 1;
    }
    if(key>x[mid]){
      min=mid+1;
    }
    else if(key<x[mid]){
      max=mid;
    }
  }

  return 0;
}
      



Measured memory_bytes: 2288
import java.util.*;
import java.io.*;

class Main
{
    static class Len
    {	
	int a[]; //= new int[2000010];
	int b[]; //= new int[2000010];
	
	Len(int n)
	{
	    a = new int[n+1];
	    b = new int[n+1];
	}
	

    }

    public static void main(String args[])
    {
	int n;
	int i, j, k;

	String line = new String();
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));

	//Read ----------------
	//Read n
	try{
	    line=line=bin.readLine();
	}	
	catch(IOException e){
	    System.out.println("Error");
	}

	n=Integer.parseInt(line);
	Len len = new Len(n);
	j=0;
	//Read A[]
	try{
	    line=bin.readLine();
	    //System.out.println(line);
	    StringTokenizer str = new StringTokenizer(line);   
	    for(i=0; i<n; i++)
		{
		    len.a[i]=Integer.parseInt(str.nextToken());
		    if(j<len.a[i])j=len.a[i];
		}
	}
	catch(IOException e){
	    System.out.println("Error");
	}

	bin=null;

	//Read end------------


	//sort
	countingSort(len, j, n);

	//print
	StringBuffer s = new StringBuffer(100);
	for(i=1; i<=n; i++)
	    {
		s.append(len.b[i]);
		if(i!=n)s.append(" ");
	    }
	System.out.println(s);

    }

    static void countingSort(Len len, int max, int n)
    {
	int i, j, k;
	int[] c = new int[max+1];

	for(i=0; i<n; i++)c[len.a[i]]++;

	for(i=0; i<=max; i++)
	    {
		if(i!=0)c[i]+=c[i-1];
	    }

	for(i=n-1; i>=0; i--)
	    {
		len.b[c[len.a[i]]]=len.a[i];
		c[len.a[i]]--;
	    }
    }
}

Measured memory_bytes: 102000
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  int t[n],a[n];
  REP(i,n){
    cin>>t[i]>>a[i];
  }
  long long ct,ca;
  long long div;
  REP(i,n){
    if(i==0){
      ct=t[i];
      ca=a[i];
    }else{
      div=max((ct+t[i]-1)/t[i],(ca+a[i]-1)/a[i]);
      ct = div*t[i];ca=div*a[i];
    }
  }
  long long ans;
  ans = ct + ca;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 60;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n;
  long long k;
  cin>>n>>k;
  map<int, long long> mp;
  rep(i, n) {
    int a, b; cin>>a>>b;
    mp[a] += b;
  }
  long long cnt = 0;
  for (auto x: mp) {
    cnt += x.second;
    if (cnt >= k) {
      print(x.first);
      break;
    }
  }
  return 0;
}


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

const int mod = 998244353;
const int maxn = 200000 + 5;
ll f[maxn],a[maxn],b[maxn];
ll c[20];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	
	for(int i = 0;i < m;++i)
		scanf("%d%d",&a[i],&b[i]);
	
	f[1] = 1;
	for(int i = 2;i <=n;++i)
		for(int j = 0;j < m;++j)
		{
			c[j] += (i - a[j] >= 1? f[i-a[j]] : 0) - (i - b[j] - 1>= 1 ? f[i-b[j] - 1] : 0);
			f[i] = (f[i] + c[j]) % mod;
		}
	cout<<f[n];
	return 0;
} 

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    if(400 <= N && N <= 599) cout << 8 << endl;
    else if(600 <= N && N <= 799) cout << 7 << endl;
    else if(800 <= N && N <= 999) cout << 6 << endl;
    else if(1000 <= N && N <= 1199) cout << 5 << endl;
    else if(1200 <= N && N <= 1399) cout << 4 << endl;
    else if(1400 <= N && N <= 1599) cout << 3 << endl;
    else if(1600 <= N && N <= 1799) cout << 2 << endl;
    else if(1800 <= N && N <= 1999) cout << 1 << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
const ll mo = 1e9+7;
ll dp[100005][13];
string s;
ll go(ll id,ll rem){
    if(id==s.size()) return (rem == 5);
    if(dp[id][rem]!=-1) return dp[id][rem];
    ll ans=0;
    if(s[id]!='?'){
        ans+= go(id+1, (rem*10+(s[id]-'0'))%13);
        ans%=mo;
    }
    else {
        for(ll i=0;i<10;i++){
            ans+=go(id+1,((rem*10+i))%13);
            ans%=mo;
        }
    }
    return dp[id][rem]=ans;
    
}

int main(){
  ll i,j,k,n,m,t;
  memset(dp,-1,sizeof(dp));
  cin>>s;
  cout<<go(0,0);
}

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

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

  std::string s;
  std::cin >> s;
  int N = s.length();
  std::cout << s[0] << N -2 << s[N - 1] << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,s,b) for(int i=(s);i<(b);i++)
#define rrep(i,s,b) for(int i=(b)-1;i>=(s);i--)
#define all(s) (s).begin(),(s).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int n, cnt = 0; cin >> n; cnt++) {
		if (cnt)cout << endl;
		string s[5] = {};
		rep(i, 0, 5) {
			int a = n % 10;
			if (a >= 5)s[i] += " *=";
			else s[i] += "* =";
			a %= 5;
			rep(j, 0, 4) {
				if (j == a) s[i] += " ";
				s[i] += "*";
			}
			if (a == 4)s[i] += " ";
			n /= 10;
		}
		rep(h, 0, s[0].size()) {
			string ans = "";
			//bool flag = true;
			rep(i, 0, 5) {
				//if (flag&&s[i][h] == ' ')continue;
				//flag = false;
				ans = s[i][h] + ans;
			}
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3044
def main():
    s = input()
    n = len(s)
    if s[0] == s[-1]:
        if n%2 == 1:
            print("Second")
        else:
            print("First")
    else:
        if n%2 == 0:
            print("Second")
        else:
            print("First")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9220
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N; cin >> N;
	
	int B[N-1]; F0R(i, N-1) cin >> B[i];
	
	int A[N]; F0R(i, N-1) A[i] = B[i];
	A[N-1] = MX;
	
	F0R(i, N-1) A[i+1] = min(A[i+1], B[i]);
	
	int sum = 0;
	F0R(i, N) {
		sum += A[i];
	}
	
	cout << sum << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define pb push_back
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
 
const int mod = 1e9 + 7;
 
ll S, mul = 9, cnt, ans;
int pref[15000005];
bool ck[100000005];
 
ll binpw(ll base, ll pw){
	ll ans = 1;
	while(pw){
		if(pw & 1) ans = (ans * base) % mod;
		base = (base * base) % mod;
		pw >>= 1;
	}
	return ans;
}
 
signed main(){
	ios_base::sync_with_stdio(0);
	cin >> S;
	ck[0] = 1;
	for(int i = 1; i <= 7; i++){
		for(int j = 1; j <= mul; j++){
			++cnt;
			pref[cnt] = pref[cnt - 1] + i;
			ans += (pref[cnt] >= S && ck[pref[cnt] - S]);
			ck[pref[cnt]] = 1;
		}
		mul *= 10;
	}
	//cout << "OK\n";
	int pos = -1;
	int temp = pref[cnt];
	for(int i = 1; temp <= (S + 100000000); i++){
		temp += 8;
		ans += (temp >= S && ck[temp - S]);
	}
	//cout << ans << "\n";
	for(int i = (S - 1) / 8; i >= 1; i--){
		if(!(S % i)){
			ll tmp = S / i, tmp2 = binpw(10, tmp - 1) * 9;
			//cout << tmp << " " << tmp2 % mod << "\n";
			//if(tmp2 < i) continue;
			//cout << ans << " " << tmp2 << "\n";
			ans = (ans + tmp2 - i + 1 + mod) % mod;
		}
		else{
			ans++;
			if(ans >= mod) ans -= mod;
		}
	}
	if(!(S % 8)){
		ans += 90000000 - S / 8;
		//cout << 90000000 - S / 8 + 1 << "\n";
		//if(ans >= mod) ans -= mod;
		if(ans >= mod) ans -= mod;
	}
	cout << ans;
}

Measured memory_bytes: 109980
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 0.5;
const LL INF = 1e9;
const LL mod = 1000003;
const LL LINF = 1e18 + 10;
const LL MAX = 1e5 + 1;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	int n;
	cin >> n;
	VI x(n + 1);
	VI a(n*n + 1, -1);
	FOR(i, 0, n)
		cin >> x[i + 1];

	FOR(i, 1, n + 1)
		a[x[i]] = i;

	bool mozhna = 1;
	VI treba(n + 1, 0);
	FOR(i, 1, n + 1)
		treba[i] = i - 1;

	VPII now(n + 1);
	set<PII> kr;
	
	FOR(i, 1, n + 1)
		now[i] = MP(x[i] - i - 1, i), kr.insert(now[i]);

	VI totake(n + 1, 0);

	FOR(i, 1, n*n + 1)
	{
		if (a[i] != -1)
		{
			kr.erase(now[a[i]]);
			treba[a[i]] = 0;
			totake[a[i]] = n - a[i];
			continue;
		}

		PII del;
		bool fkag = 0;

		for (auto j : kr)
			if (treba[j.Y])
			{
				--treba[j.Y];
				a[i] = j.Y;
				del = j;
				fkag = 1;
				break;
			}

		if (fkag)
		{
			kr.erase(del);
			del.X++;
			kr.insert(del);
			now[del.Y].X++;
			continue;
		}

		FOR(j, 1, n + 1)
			if (totake[j])
			{
				totake[j]--;
				a[i] = j;
				break;
			}
	}

	FOR(i, 1, n + 1)
		if (treba[i])
			mozhna = 0;

	FOR(i, 1, n*n + 1)
		if (a[i] == -1)
			mozhna = 0;

	FOR(i, 1, n + 1)
		if (totake[i])
			mozhna = 0;

	if (!mozhna)
	{
		cout << "No";
		return 0;
	}

	cout << "Yes" << endl;
	FOR(i, 1, 1 + n * n)
		cout << a[i] << " ";

	cin >> n;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 5e18+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct UnionFind {
    vector<int> par,size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
        else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main() {
    int N;
    cin >> N;
    UnionFind uf(N);
    vector<pair<P,int>>xy(N);
    for(int i = 0; i < N; i++) {
        cin >> xy[i].first.first >> xy[i].first.second;
        xy[i].second = i;
    }
    sort(xy.rbegin(),xy.rend());
    set<int>st;
    map<int,int>Mp;
    for(int i = 0; i < N; i++) {
        auto it = st.lower_bound(xy[i].first.second);
        if(it != st.end()) {
            while (it != st.end()) {
                uf.unite(i,Mp[*it]);
                it++;
            }
        }
        else {
            st.insert(xy[i].first.second);
            Mp[xy[i].first.second] = i;
        }
    }
    vector<int>ans(N);
    for(int i = 0; i < N; i++) {
        ans[xy[i].second] = uf.consize(i);
    }
    for(int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 14564
from collections import Counter

def solve(n, v):
    # すべて同じ値
    if len(set(v)) == 1:
        return len(v) / 2

    odd = []
    even = []

    for i, k in enumerate(v):
        if i % 2 == 0:
            even.append(k)
        else:
            odd.append(k)

    odd_dic = Counter(odd).most_common()
    even_dic = Counter(even).most_common()

    ans = 0

    if odd_dic[0][0] == even_dic[0][0]:
        if odd_dic[0][1] > even_dic[0][1]:
            odd_v = odd_dic[0][0]
            even_v = even_dic[1][0]
        elif odd_dic[0][1] < even_dic[0][1]:
            odd_v = odd_dic[1][0]
            even_v = even_dic[0][0]
        else:
            if odd_dic[1][1] >= even_dic[1][1]:
                odd_v = odd_dic[1][0]
                even_v = even_dic[0][0]
            else:
                odd_v = odd_dic[0][0]
                even_v = even_dic[1][0]
    else:
        odd_v = odd_dic[0][0]
        even_v = even_dic[0][0]

    for i in range(len(even)):
        if even_v != even[i]:
           ans += 1

        if odd_v != odd[i]:
            ans += 1

    return ans

def test():
    assert solve(4, [3, 1, 3, 2]) == 1
    assert solve(6, [105, 119, 105, 119, 105, 119]) == 0
    assert solve(4, [1, 1, 1, 1]) == 2

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

if __name__ == '__main__':
    # test()
    main()

Measured memory_bytes: 21076
import java.util.*;
import java.util.stream.*;
public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    List<Integer> p = new ArrayList<>();
    for(int i = 0; i<n; i++){
      p.add(sc.nextInt());
    }
    Collections.sort(p);
    p = p.subList(0,k);
 		// 出力
    String ans = p.stream().reduce(0,Integer::sum).toString();
    System.out.println(ans);
	}
}

Measured memory_bytes: 39000
"use strict";

process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    const n = parseInt(input[0], 10);
    const a = input[1].split(' ').map(function(value) { return parseInt(value, 10); });
    const sum = a.reduce(function(prev, current, index) {
        if (index === 0) {
            prev.push(current);
        }
        else {
            prev.push(current + prev[index - 1]);
        }
        return prev;
    }, []);

    let ans = Number.MAX_SAFE_INTEGER;
    let left = 0;
    let right = 2;
    for (let center = 1; center < n - 2; center++) {
        
        while (left < center - 1 && Math.abs(sum[left] - (sum[center] - sum[left])) > Math.abs(sum[left + 1] - (sum[center] - sum[left + 1]))) {
            left++;
        }

        if (right <= center) {
            right = center + 1;
        }

        while (right < n - 1 && Math.abs((sum[right] - sum[center]) - (sum[n - 1] - sum[right])) > Math.abs((sum[right + 1] - sum[center]) - (sum[n - 1] - sum[right + 1]))) {
            right++;
        }

        const p = sum[left];
        const q = sum[center] - sum[left];
        const r = sum[right] - sum[center];
        const s = sum[n - 1] - sum[right];
        const max = Math.max(p, q, r, s);
        const min = Math.min(p, q, r, s);

        ans = Math.min(ans, max - min);
    }

    console.log(ans);

    return 0;
}


Measured memory_bytes: 56988
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast


        
    ll a,b;
    cin>>a>>b;

    if(abs(a+b)%2 == 0) cout<<abs(a+b)/2;    
    else cout<<"IMPOSSIBLE";











    return 0;
}

Measured memory_bytes: 256
local n=io.read("n")

local function upper_bound(x)
    local max=n+1
    local min=0
    while 1<max-min do
        mid=(max+min)//2
        if mid*(mid+1)//2>=n then
            max=mid
        else
            min=mid
        end
    end
    return max
end

local x=upper_bound(n)
for i=1,x do
    if i~=x*(x+1)//2-n then
        print(i)
    end
end

Measured memory_bytes: 760
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>


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

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;

    int ans = 0;

    for (unsigned int i = 0; i < s.size(); i++) {
        if (s[i] == t[i])
            continue;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


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

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

  vector<pair<ll,int>> fs;//ll:prime,int:index
  for(ll i=2;i*i<=n;i++){
    int x=0;
    while(n%i==0){
      n/=i;
      x++;
    }
    fs.emplace_back(i,x);
  }
  if(n!=1) fs.emplace_back(n,1);//n:prime

  int ans=0;
  for(auto p:fs){
    int x=p.second;
    int b=1;
    while(b<=x){
    x-=b;
    b++;
    ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 19700
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



ll L,A,B,M;
ll S;

struct MOD_INT{
  ll x;

  MOD_INT(ll arg_x){
	  x = arg_x;
	  x %= M;
  }

  MOD_INT& operator+=(const MOD_INT a) {
    (x += a.x) %= M;
    return *this;
  }
  MOD_INT& operator-=(const MOD_INT a) {
    (x += M-a.x) %= M;
    return *this;
  }
  MOD_INT& operator*=(const MOD_INT a) {
    (x *= a.x) %= M;
    return *this;
  }
  MOD_INT operator+(const MOD_INT a) const {
	  MOD_INT res(*this);
    return res+=a;
  }
  MOD_INT operator-(const MOD_INT a) const {
	  MOD_INT res(*this);
    return res-=a;
  }
  MOD_INT operator*(const MOD_INT a) const {
    MOD_INT res(*this);
    return res*=a;
  }
};


MOD_INT mod_pow(MOD_INT x,ll count, ll mod){

	if(count == 0){

		return 1;
	}

	if(count%2 == 1){

		return mod_pow(x,count-1,mod)*x;
	}
	else{

		MOD_INT y = mod_pow(x,count/2,mod);
		return y*y;
	}
}


MOD_INT f(ll loc){
	if(loc == 0){

		return 0;
	}

	MOD_INT ret(0);

	if(loc%2 == 1){

		ll tmp = loc-1;
		ret = f(tmp);
		return ret*S+1;

	}else{

		ll tmp = loc/2;
		ret = f(tmp);
		return ret*mod_pow(S,loc/2,M)+ret;
	}
}


MOD_INT g(ll loc){
	if(loc == 0){

		return 0;
	}

	MOD_INT ret(0);

	if(loc%2 == 1){

		ll tmp = loc-1;
		ret = g(tmp);
		return ret*S+MOD_INT(B)*tmp;

	}else{

		ll tmp = loc/2;
		ret = g(tmp);
		return ret = ret*mod_pow(S,tmp,M)+ret+MOD_INT(B)*tmp*f(tmp);
	}
}


int main(){

	scanf("%lld %lld %lld %lld",&L,&A,&B,&M);

	MOD_INT ans = 0;

	S = 10;
	ll last = A+B*(L-1);
	ll head,tail,num;

	for(ll i = 1; i <= 18; i++,S *= 10){

		ll mini = S/10,maxi = S-1;
		if(A > maxi || last < mini)continue;

		if(A >= mini){

			head = A;

		}else{

			head = ((mini-A)+(B-1))/B*B+A;
			head = min(head,last);
		}

		if(last <= maxi){

			tail = last;
		}else{
			tail = (maxi-A)/B*B+A;
		}

		num = (tail-head)/B+1;
		//printf("i:%lld head:%lld  tail:%lld num:%lld\n",i,head,tail,num);

		ans *= mod_pow(S,num,M);
		ans += f(num)*head;
		ans += g(num);
	}

	printf("%lld\n",ans.x);

	return 0;
}


Measured memory_bytes: 256
import pdb
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
d=[]
if n<m:
    for i in range(0,len(x)-1):
        d.append(x[i+1]-x[i])
    d.sort(reverse=True)
    for i in range(n-1):
        d.pop(0)
    ans=sum(d)
    print(ans)
else:#koma are assigned
    print(0)
#pdb.set_trace()



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

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

using namespace std;

int main(){
  int a[4];
  rep(i,4) cin >> a[i];
  sort(a,a+4);
  if( a[0] == a[1] && a[2] == a[3] ) puts("yes");
  else                               puts("no");
  return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main(){
    ll N; cin >> N;
    vector<ll> div;
    ll tmp = N;
    for (ll i = 1; i*i <= tmp; i++) {
        if(tmp % i == 0){
            if(i * i != tmp){
                div.push_back(N / i);
            }
            div.push_back(i);
        }
    }
    ll ans = INF;
    for (ll i = 0; i < div.size(); i++) {
        ll p = div[i];
        ll q = N / p;


        ll s = 2 * p;
        ll t = q;
        if(__gcd(s, t) == 1){
            ll x, y;
            auto xy1 = extGCD(t, s, x, y);
            if(y >= 0){
                y = y % t;
                y -= t;
            }
            else{
                y = -y;
                y = y % t;
                y = -y;
            }
            ans = min(abs(y) * s, ans);
        }
        s = p;
        t = 2 * q;
        if(__gcd(s, t) == 1){
            ll x, y;
            auto xy1 = extGCD(t, s, x, y);
            if(y >= 0){
                y = y % t;
                y -= t;
            }
            else{
                y = -y;
                y = y % t;
                y = -y;
            }
            ans = min(abs(y) * s, ans);
        }
        


    }

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

Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

int main()
{
	vector<int> a(3);
	while(true)
	{
		cin >> a[0] >> a[1] >> a[2];
		if(a[0] == 0 && a[1] == 0 && a[2] == 0) break;

		sort(a.begin(),a.end());
		int d = a[0]*a[0] + a[1]*a[1];

		int n;
		cin >> n;
		rep(i,n)
		{
			int r;
			cin >> r;

			if(d < (r*2)*(r*2))
			{
				cout << "OK" << endl;
			}
			else
			{
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}

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

typedef long long ll;

int main() {
  int N;
  std::vector<std::pair<ll, ll>> tasks;

  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    ll a, b;
    std::cin >> a >> b;
    tasks.push_back(std::make_pair(b, a));
  }
  std::sort(tasks.begin(), tasks.end());

  ll t = 0;
  bool ans = true;
  for(auto task : tasks) {
    ll b = task.first;
    ll a = task.second;
    t += a;
    if(t > b) {
      ans = false;
      break;
    }
  }

  if(ans) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 6128
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int m,d,e;
    m=a+b;
    d=b+c;
    e=a+c;
    if(m<=d&&m<=e)
        printf("%d\n",m);
    else if(d<=m&&d<=e)
        printf("%d\n",d);
    else
        printf("%d\n",e);
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)



int main(){
ll X;
cin>>X;

ll wari = (ll)(X/500.0);
if(X%500==0){
    cout<<1000*wari<<endl;
    return 0;
}

ll s3 = X%1000;
if(s3>=500){
    s3-=500;
}
ll w2 = s3/5;



cout<<1000*wari+w2*5<<endl;











}


Measured memory_bytes: 256