akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(void) {
    int n;
    cin >> n;
    vi p(n), pp(n);
    rep (i, n) cin >> p[i];
    rep (i, n) p[i]--;

    rep (i, n) pp[i] = p[i];

    int ans = 0;
    rep (i, n - 1) {
        if (p[i] == i) {
            swap(p[i], p[i + 1]);
            ans ++;
        }
    }
    if (p[n - 1] == n - 1) ans++;

    int ans2 = 0;

   

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var t = new Tuple<int, int>[n];
        for (int i = 0; i < n; i++)
        {
            t[i] = Tuple.Create(a[i], i + 1);
        }

        Array.Sort(t);

        for (int i = 0; i < n; i++)
        {
            Console.Write(t[i].Item2 + " ");
        }
        Console.WriteLine();
    }
}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int a, b, h, m; cin >> a >> b >> h >> m;
	double ans = 0.0;
	double theta = double(abs(360*h/12.0+30*m/60.0-360*m/60.0));
	if(theta>180){
		theta = 360.0-theta;
	}
	if(theta==180){
		ans = a+b;
	}
	// else if(theta==90){
	// 	ans = sqrt(a*a+b*b);
	// }
	else{
		ans = sqrt(a*a+b*b-2*a*b*cos(theta*M_PI/180));
	}
	printf("%.10f\n", ans);
	//cout << theta << endl;
	return 0;
}

Measured memory_bytes: 4156
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit

def solve(n,b):
  a = []
  for i in range(n-1,-1,-1):
    flag = False
    for j in range(i,-1,-1):
      if b[j] == j+1:
        a.append(j+1)
        b.pop(j)
        flag = True
        break
    if not flag:
      return [-1]
  return reversed(a)



def main():
  N = int(input())
  b = list(map(int,input().split()))
  print(*solve(N,b),sep="\n")
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9192
MOD = 10**9 + 7
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
dp = [0] * (1 << N)
dp[0] = 1
bits = [1 << i for i in range(N)]
cands = [[] for _ in range(N+1)]
for s in range(1 << N):
    temp = 0
    for n in range(N):
        if s & (1 << n): temp += 1
    cands[temp].append(s)
for i, a in enumerate(A):
    for j in [k for k, v in enumerate(a) if v == 1]:
        bit = bits[j]
        for s in cands[i]:
            if s & bit == 0:
                new_s = s | bit
                dp[new_s] += dp[s]
                dp[new_s] %= MOD
print(dp[-1])

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll ans = 1;
    REP(i, N){
        ll t;
        cin >> t;
        
        ans = lcm(ans, t);
        // cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1e5+5;
int n,a[N],b[N],c[N],tot,dfn[N],siz[N],lcm; ll k;
bool vis[N];
int rdn()
{
  int ret=0;bool fx=1;char ch=getchar();
  while(ch>'9'||ch<'0'){if(ch=='-')fx=0;ch=getchar();}
  while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
  return fx?ret:-ret;
}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void dfs(int cr)
{
  siz[tot]++;vis[cr]=1;dfn[cr]=tot;
  if(!vis[b[cr]])dfs(b[cr]);
}
int main()
{
  n=rdn();
  for(int i=1;i<=n;i++)a[i]=rdn();
  for(int i=n;i;i--)a[i]-=a[i-1];
  for(int i=1;i<=n;i++)b[i]=i;
  int m;m=rdn(); scanf("%lld",&k);
  for(int i=1,d;i<=m;i++)
    {
      d=rdn(); swap(b[d],b[d+1]);
    }
  lcm=1;
  for(int i=1;i<=n;i++)
    if(!vis[i])
      {
	tot++; dfs(i);
      }
  for(int i=1;i<=n;i++)
    {
      int d=k%siz[dfn[i]],cr=i;
      for(int j=1;j<=d;j++)cr=b[cr];
      c[i]=cr;
    }
  for(int i=1;i<=n;i++)c[i]=a[c[i]];
  ll lj=c[1];
  for(int i=1;i<=n;i++,lj+=c[i])
    printf("%lld\n",lj);
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

const int MAX = 10000000;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/****** define constant end ********/

/****** define variable start ******/
ll n;
vl a;
/******* define variable end *******/
int solve() {
	cin >> n;
	a.resize(n);
	vl sumvec(n+1);
	sumvec[0] = 0;
	REP(i, n){
		cin >> a[i];
		sumvec[i+1] = sumvec[i] + a[i];
		sumvec[i+1] %= MOD;
	}
	ll ans = 0;
	REP(i, n){
		ans += (sumvec[n] + MOD  - sumvec[i+1]) * a[i];
		ans %= MOD;
	}
	ans %= MOD;
	cout << ans << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll x;
  cin>>x;
  for (ll i = -1000; i <= 1000; ++i)
  {
    for (ll j = -1000; j <= 1000; ++j)
    {
      if((i*i*i*i*i-j*j*j*j*j)==x)
      {
        cout<<i<<" "<<j;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3584
import sys
from collections import deque
import copy

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def calc(N, A, max_min):

    if max_min:
        al = deque([A.popleft()])
        f = True
    else:
        al = deque([A.pop()])
        f = False

    while A:
        if len(A) >= 2:
            if f:
                al.append(A.pop())
                al.appendleft(A.pop())
                f = False
            else:
                al.appendleft(A.popleft())
                al.append(A.popleft())
                f = True

        elif len(A) == 1:
            al.append(A.pop())

    ans = 0
    for i in range(N - 1):
        ans += abs(al[i + 1] - al[i])

    return ans


def main():
    N = in_n()
    A = deque(sorted(list(in_na())))

    ans1 = calc(N, copy.copy(A), True)
    ans2 = calc(N, copy.copy(A), False)
    print(max(ans1, ans2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 19868
# coding: utf-8
n = int(input())
dic = []
for i in range(n):
    a, b = list(map(int, input().split()))
    dic.append({'task': i, 'duration': a, 'due': b})
dicsort = sorted(dic, key = lambda x: (x['due'], x['duration']))
completed = 0
result = True
for i in dicsort:
    completed += i['duration']
    if completed > i['due']:
        result = False
        break
if result:
    print('Yes')
else:
    print('No')


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

using namespace std;

int main() {

	long a, b;
	cin >> a >> b;

	if (b == 1) {
		cout << 0 << endl;
		return 0;
	}

	long counter = 1;
	long i=0;

	for ( i = 1; i < 100; i++) {
		counter = counter-1 + a;
		if (counter >= b) { break; }
	}

	cout << i << endl;
}

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

int main()
{
	int64_t n, inf = (1LL << 60);
	cin >> n;
	vector<int64_t> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	vector<int64_t> bs(n + 1, 0);
	for (int64_t i = 0; i < n; i++)
	{
		bs[i + 1] = bs[i] + as[i];
	}

	int64_t ans = inf;

	for (int64_t i = 0; i < n - 1; i++)
	{
		ans = min(ans, abs(bs[i + 1] - (bs[n] - bs[i + 1])));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
 unsigned long int a,b,k,i;
 scanf("%ld %ld %ld",&a,&b,&k);
 
    if(a>=k){
      a=a-k;
    }
    else {
        if(b<k-a){
        b=0;
      }else{
      b=b-k+a;
    }
      a=0;
    
    }
  
  printf("%ld %ld",a,b);
}
    
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
int r[20000],c[20000];
int aa[2001][2001][2],bb[2001][2001][2];
int32_t main()
{
	fastio();
	int h,w;
	cin>>h>>w;
	string s[h];
	f(i,0,h)
	cin>>s[i];
	int l=-1,r;
	f(i,0,h)
	{
		f(j,0,w)
		{
			if(s[i][j]=='#')
			{
				l=j;
			}
			else
			{
				aa[i][j][0]=l;
			}
		}
		l=-1;
	}
	l=w;
	f(i,0,h)
	{
		for(int j=w-1;j>=0;j--)
		{
			if(s[i][j]=='#')
			{
				l=j;
			}
			else
			{
				aa[i][j][1]=l;
			}
		}
		l=w;
	}
	l=-1;
	f(j,0,w)
	{
		f(i,0,h)
		{
			if(s[i][j]=='#')
			{
				l=i;
			}
			else
			{
				bb[i][j][0]=l;
			}
		}
		l=-1;
	}
	l=h;
	f(j,0,w)
	{
		for(int i=h-1;i>=0;i--)
		{
			if(s[i][j]=='#')
			{
				l=i;
			}
			else
			{
				bb[i][j][1]=l;
			}
		}
		l=h;
	}
	int ans=0;
	f(i,0,h)
	{
		f(j,0,w)
		{
			if(s[i][j]!='#')
			{
				int tt=aa[i][j][1]-aa[i][j][0]-1;
				tt+=bb[i][j][1]-bb[i][j][0]-1;
				ans=max(ans,tt);
				//cout<<tt-1<<" ";
			}
			//cout<<bb[i][j][0]<<" "<<bb[i][j][1]<<endl;
		}
		//cout<<endl;
	}
	cout<<ans-1;
}

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


int main(){
	char s[16];
	int i;
	int g;
	scanf("%s",s);
	g=strlen(s);
	for(i=0;i<g;i++){
		if(s[i]!=','){
			
			printf("%c",s[i]);
		}else{
			printf(" ");
		}
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#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> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

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

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 &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

// [1, n]
i64 f(i64 n, i64 d) {
    return n - (n / d);
}

i64 lcm(i64 a, i64 b) {
    return a / __gcd(a, b) * b;
}

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

    i64 A, B, C, D;
    read(A, B, C, D);

    const i64 not_c_div = f(B, C) - f(A-1, C);
    const i64 not_d_div = f(B, D) - f(A-1, D);
    const i64 not_c_or_d_div = f(B, lcm(C, D)) - f(A-1, lcm(C, D));

    trace(not_c_div);
    trace(not_d_div);
    trace(not_c_or_d_div);

    print(not_c_div + not_d_div - not_c_or_d_div);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long s = sc.nextLong();
        long max = (long)Math.pow(10,9);
        if(s <= max){
            System.out.println("0 0 0 1 "+s+" 0");
        }else{
            if(s%max == 0){
                long y = s/max;
                System.out.println("0 0 "+max+" 1 0 "+y);
            }else{
                long x = max-(s%max);
                long y = s/max+1;
                System.out.println("0 0 "+max+" 1 "+x+" "+y);
            }
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 23124
S = input()
N = len(S)
if S != S[::-1]:
    print('No')
    exit()

X = S[:N // 2]
if X != X[::-1]:
    print('No')
    exit()

X = S[N // 2 + 1:]
if X != X[::-1]:
    print('No')
    exit()

print('Yes')


Measured memory_bytes: 3064
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

a,b,c = map(int,input().split())

ans = 0

if a+b>=c:
	print(b+c)
	exit()

if a>=c:
	print(b+c)
	exit()

else:
	ans = ans + a
	c = c - a
	if c == b:
		ans = ans + 2*b
	elif c < b:
		ans = b + c
	else:
		ans = ans + 2*b + 1

print(ans)



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

//??¨??????????????????????????£??????
#define MAX 7500000

int main(){

    while(1){
        int m, n; cin >> m >> n;
        if(n == 0) break;

        vector<bool> p(MAX, false);
        int j = m;
        int ans;
        while(n > 0){
            if(p[j] == false){
                ans = j;
                for(int k = j; k < MAX; k += j){
                    p[k] = true;
                }
                n--;
            }
            j++;
        }
        
        while(1){
            if(p[ans] == false){
                cout << ans << endl;
                break;
            }
            ans++;
        }
    }

    return 0;
}

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

/*typedefs*/
typedef vector<int> vi;
typedef map<string,int> msi;
typedef complex<double> point;
typedef  long long ll;


#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define X real()
#define Y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define length(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)
#define rotateO(p,ang)          ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about)  (rotateO(vec(about,p),ang)+about)
#define reflectO(v,m)  (conj((v)/(m))*(m))
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)

bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}


unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
ll  OO = 10e6;
const int MAXN = 3*10e5;
int arr[MAXN];
int main() {
    IOS();

    int n;
    cin>>n;
    REP(i,n) cin>>arr[i];
    int mn = OO;
    int cnt =0;
    REP(i,n)
    {
        if(arr[i] <= mn)
            ++cnt,mn=arr[i];
    }

    cout<<cnt;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	static const ULL MOD = 1000000007;

	void Solve() {
		UL N, M; cin >> N >> M;
		UL s, t; cin >> s >> t; s--; t--;
		vector<vector<pair<UL, ULL>>> E(N);
		rep(i, M) {
			UL u, v; cin >> u >> v; u--; v--;
			ULL d; cin >> d;
			E[u].push_back({ v, d });
			E[v].push_back({ u, d });
		}
		ULL ans, sub; ans = sub = 0;
		vector<ULL> DS, DT;
		vector<ULL> PS, PT;
		DS.assign(N, -1); DT.assign(N, -1);
		PS.assign(N, 0); PT.assign(N, 0);
		PS[s] = 1; PT[t] = 1;
		using Node = pair<pair<ULL, UL>, UL>;
		priority_queue<Node, vector<Node>, greater<Node>> Q;
		Q.push({ { 0, s }, (UL)-1 });
		while (Q.size()) {
			ULL d = Q.top().first.first; UL p = Q.top().first.second;
			UL pre = Q.top().second;
			Q.pop();
			if (DS[p] != -1) {
				if (DS[p] == d) PS[p] = (PS[p] + PS[pre]) % MOD;
				continue;
			}
			DS[p] = d;
			if (pre != -1) PS[p] = (PS[p] + PS[pre]) % MOD;
			for (auto e : E[p]) {
				Q.push({ { d + e.second, e.first }, p });
			}
		}
		Q.push({ { 0, t }, (UL)-1 });
		while (Q.size()) {
			ULL d = Q.top().first.first; UL p = Q.top().first.second;
			UL pre = Q.top().second;
			Q.pop();
			if (DT[p] != -1) {
				if (DT[p] == d) PT[p] = (PT[p] + PT[pre]) % MOD;
				continue;
			}
			DT[p] = d;
			if (pre != -1) PT[p] = (PT[p] + PT[pre]) % MOD;
			for (auto e : E[p]) {
				Q.push({ { d + e.second, e.first }, p });
			}
		}
		ans = PS[t] * PT[s] % MOD;
		//cout << ans << endl;

		ULL D = DS[t];
		//cout << "D = " << D << endl;
		//cout << "DS = "; rep(i, N) cout << DS[i] << " "; cout << endl;
		//cout << "DT = "; rep(i, N) cout << DT[i] << " "; cout << endl;
		//cout << "PS = "; rep(i, N) cout << PS[i] << " "; cout << endl;
		//cout << "PT = "; rep(i, N) cout << PT[i] << " "; cout << endl;

		rep(p, N) {
			for (auto e : E[p]) {
				if (DS[p] + DT[e.first] + e.second == D) {
					if (DS[p] * 2 < D) {
						if (DS[e.first] * 2 > D) {
							ULL tmp = PS[p] * PT[e.first] % MOD;
							tmp = tmp * tmp % MOD;
							//cout << p << " " << e.first << " " << tmp << endl;
							sub = (sub + tmp) % MOD;
						}
					}
				}
			}
			if (DS[p] * 2 == D) {
				ULL tmp = PS[p] * PT[p] % MOD;
				tmp = tmp * tmp % MOD;
				//cout << p << " " << tmp << endl;
				sub = (sub + tmp) % MOD;
			}
		}

		ans = (ans + MOD - sub) % MOD;
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

int main()
{
  while(1){
    int n;
    cin >> n;
    if(n == 0){
      break;
    }else{
      queue<string> move;
      for(int i = 0; i < n; i++){
        string x;
        cin >> x;
        move.push(x);
      }
      int ans = 0;
      while(!move.empty()){
        string x;
        x = move.front();
        move.pop();
        if(!move.empty()){
          if(x == "lu"){
            if(move.front() == "ru"){
              ans++;
              move.pop();
            }else{
              move.pop();
            }
          }else if(x == "ru"){
            if(move.front() == "lu"){
              ans++;
              move.pop();
            }else{
              move.pop();
            }
          }else if(x == "ld"){
            if(move.front() == "rd"){
              ans++;
              move.pop();
            }else{
              move.pop();
            }
          }else if(x == "rd"){
            if(move.front() == "ld"){
              ans++;
              move.pop();
            }else{
              move.pop();
            }
          }
        }
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 1228
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;  
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) 
{
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) 
{
	ll ans = 1;
	while (n) 
	{
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

void solve() 
{
	int t;
	cin >> t;
	if (t >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;			
}

int main() 
{
	fast_io();
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int t = 1;
	// cin >> t;
	while (t--) solve();
	return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    char c;
    cin>>c;
    (isupper(c))?cout<<"A":cout<<"a";    
	return 0;
}

Measured memory_bytes: 3468
// AOJ_C++.cpp : アプリケーションのエントリ ポイントを定義します。
//
#include <iostream>
#include <math.h>

int main()
{
	int x, y, r, w, h;
	std::cin >> w >> h >> x >> y >> r;
	if(r <= x && x <= w - r && r <= y && y <= h - r)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 3124
def Q2(x):
    A, B, C, D = x[0], x[1], x[2], x[3]
    if B <= C or D <= A:
        return 0
    else:
        if A <= C:
            return min(B, D) - C
        else:
            return min(B, D) - A
          
l = [int(i) for i in input().split()]
print(Q2(l))

Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCALc
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
template<typename T, typename l>
void getv(T& a, int n, l f) {
	a.resize(n);
	for (auto& i : a)
		cin >> i, f(i);
}
template<typename T>
void getv(T& a, int n) {
	a.resize(n);
	for (auto& i : a)
		cin >> i;
}
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, m, k, t, ans = 0;
vi a, pref, suf;
multiset<ll> f;

int main() {
	doin();
	cin >> n >> k;
	a.resize(n);
	for (auto& i : a)
		cin >> i;
	ll ans = 0, lans = 0, ls = 0, rs = 0;
	for (ll l = 0; l <= min(k, n); l++) {
		ls = 0;
		f.clear();
		for (ll i = 0; i < l; i++)
			f.insert(a[i]), ls += a[i];
		rs = 0;
		for (ll r = 0; l + r <= min(n, k); r++) {
			if (r)
				f.insert(a[n - r]), rs += a[n - r];
			ll left = k - (l + r);
			lans = rs + ls;
			auto it = f.begin();
			while (left-- && it != f.end() && (*it) < 0)
				lans -= *it, it++;
			ans = max(ans, lans);
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define nil -1
#define max 2000001
typedef struct{
  int key;
  int parent;
  int right;
  int left;
} node;
int parent(int);
int left(int);
int right(int);
void maxHeapify(int);
node heapExtractMax(void);
void maxHeapInsert(int);
void heapIncreaseKey(int, int);
int H = 0;
node data[max];

int main()
{
  int key;
  char order[8];
  node output;
 
  while(1){
    scanf("%s",order);
    if(strcmp(order,"end") == 0) break;
    if(strcmp(order,"insert") == 0){
      scanf("%d",&key);
      maxHeapInsert(key); }
    if(strcmp(order,"extract") == 0){
      output = heapExtractMax();
      if(output.key != nil) printf("%d\n",output.key); }
  }
  
  return 0;
}

int parent(int i)
{
  return i/2;
}

int left(int i)
{
  return 2*i;
}

int right(int i)
{
  return 2*i + 1;
}

void maxHeapify(int i)
{
  int l, r, largest, ForKeep;

  l = left(i);
  r = right(i);

  if(l <= H && data[l].key > data[i].key) largest = l;
  else largest = i;

  if(r <= H && data[r].key > data[largest].key) largest = r;
  
  if(largest != i){
    ForKeep = data[i].key;
    data[i].key = data[largest].key;
    data[largest].key = ForKeep;
    maxHeapify(largest); }
}

node heapExtractMax(void)
{
  node Max, NIL;
  NIL.key = nil;
  if(H < 1) return NIL; 
  
  Max = data[1];
  data[1] = data[H];
  H--;
  maxHeapify(1); 

  return Max;
}

void maxHeapInsert(int key)
{
  H++;
  data[H].key = -200000;
  heapIncreaseKey(H, key);
}

void heapIncreaseKey(int i, int key)
{
  int ForChange;

  if(key < data[i].key) return;
    
  data[i].key = key;

  while(i > 1 && data[parent(i)].key < data[i].key){
    ForChange = data[i].key; 
    data[i].key = data[parent(i)].key;
    data[parent(i)].key = ForChange;
    i = parent(i); }
  
}



Measured memory_bytes: 17320
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Compute c1=new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d=sc.nextInt();
        int x[][]=new int[n][d];
        for (int i=0;i<n;++i){for (int j=0;j<d;++j){x[i][j]=sc.nextInt();}}

        for (int k=0;k<n;++k)
        {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        }
        answer=count;
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
}

Measured memory_bytes: 21972
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, k, *h = map(int, read().split())

h.sort()
ans = 10 ** 9
for i in range(n - k + 1):
    ans = min(ans, h[i + k - 1] - h[i])
print(ans)

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

using namespace std;
int main(){
    int cnt=0;
    int a[4];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    
    for(int i=0;i<2;i++){
        if(a[i]==a[i+1]){
            cnt++;
        }
    }
    
    if(cnt==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
    return 0;
}

    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt() - 1;
        int y = sc.nextInt() - 1;
        int jump = 1;
        int []arr = new int[n-1];
       Start start;
       End end;
        for (int i=0; i < n; i++) {
            if (i < x) start = Start.LEFT;
            else if(i >= x && i <= y) start = Start.INSIDE;
            else start = Start.RIGHT;
            for (int j=i+1;  j < n; j++) {
                if (j < x) end = End.LEFT;
                else if (j >= x && j <= y) end = End.INSIDE;
                else end = End.RIGHT;

                if (start == Start.LEFT) {
                    if (end == End.LEFT) arr[j-i-1]++;
                    else if (end == End.INSIDE) {
                        int distance = Math.min(j-i, x-i+jump+y-j);
                        arr[distance-1]++;
                    }
                    else if (end == End.RIGHT) {
                        arr[x-i + jump + j-y -1]++;
                        //System.out.println("PIYO!");
                    }
                } else if (start == Start.INSIDE) {
                    if (end == End.INSIDE) {
                        int distance = Math.min(j - i, i - x + jump + y - j);
                        arr[distance - 1]++;
                    } else if(end == End.RIGHT) {
                        int distance = Math.min(j-i, i-x + jump + j-y);
                        arr[distance-1]++;
                    }
                } else if (start == Start.RIGHT) {
                    arr[j-i-1]++;
                }
            }
        }
        for (int a: arr) System.out.println(a);
    }
    enum Start { LEFT, INSIDE, RIGHT}
    enum End { LEFT, INSIDE, RIGHT}
}


Measured memory_bytes: 24532
#include <cstdio>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cctype>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define llong long long
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;

vector<string> split(string str, char delim)
{
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos)
	{
		string tmp = string(str, current, found - current);
		res.push_back(tmp);
		current = found + 1;
	}
	string tmp = string(str, current, found - current);
	tmp.replace(tmp.size() - 1, tmp.size(), "\0");
	res.push_back(string(str, current, str.size() - current));
	return res;
}

char *StrToLower(char *s)
{
	char *p;
	for (p = s; *p; p++)
	{
		*p = tolower(*p);
	}
	return s;
}

int main()
{
	int cnt[26] = {0};
	char cstr[1201];
	bool isEnd = false;


	while (cin >> cstr)
	{
		string str = cstr;
		string word = StrToLower(cstr);

		REP(i, str.size())
		{
			cnt[cstr[i] - 'a']++;
			if (cin.eof()) { isEnd = true; break; }
		}

		if (isEnd)break;
	}

	REP(i, 26)
	{
		printf("%c : %d\n", 'a' + i, cnt[i]);
	}
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,a,b,v[300005],sol;
long long k,t1,t2;
int usu1(int x)
{
    int p=mod-2,aux=x,ans=1;
    for(int i=0;(1<<i)<=p;++i)
    {
        if((1<<i)&p) ans=(1ll*ans*aux)%mod;
        aux=(1ll*aux*aux)%mod;
    }
    return ans;
}
int comb(int n,int k)
{
    int ans=v[n],p1,p2;
    p1=usu1(v[n-k]);
    p2=usu1(v[k]);
    ans=(1ll*ans*p1)%mod;
    ans=(1ll*ans*p2)%mod;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>a>>b>>k;
    v[0]=v[1]=1;
    for(int i=2;i<=n;++i) v[i]=(1ll*v[i-1]*i)%mod;
    for(int i=0;i<=n;++i)
    {
        t1=k-1LL*i*a;
        if(t1<0) break;
        if(t1%b) continue;
        t2=t1/b;
        if(t2>n) continue;
        sol=(sol+(1ll*comb(n,i)*comb(n,t2))%mod)%mod;
    }
    cout<<sol;
    return 0;
}


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

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

    int ans = 0;
    int check = 1;
    for(int i=0; i<n; i++) {
        if(a[i]!=check) ans++;
        else check++;
    }

    if(ans==n) ans=-1;

    cout<<ans<<endl;

    return 0;
}

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

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000007LL
#define OO 1000000000000000007LL
#define maxN 1000007

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vi>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const ii& a, const ii& b) {return (a.FF > b.FF || (a.FF == b.FF && a.SS >= b.SS));}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

const string namePro = "tmp";

int a[maxN], c[maxN];
ii b[maxN];

int main() {
    ll H, W;
    scanf("%lld%lld", &H, &W);

    if (H%3 == 0LL || W%3 == 0LL) {
        puts("0");
        return 0;
    }

    ll ans = min(H, W);
    fto (i, 1, H) {
        int x = W/2;
        ans = min(ans, max(W*i, (W-x)*(H-i), x*(H-i))-min(W*i, (W-x)*(H-i), x*(H-i)));
    }

    fto (i, 1, W) {
        int x = H/2;
        ans = min(ans, max(H*i, (H-x)*(W-i), x*(W-i))-min(H*i, (H-x)*(W-i), x*(W-i)));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
 
public class Main {
	Scanner sc = new Scanner(System.in);
 
	public static void main(String[] args) {
		new Main();	
	}
 
	public Main() {
		new B().doIt();
	}
	class B{
		void set(char ctr[]){
			for(char c = '0';c <= '9';c++)ctr[c] = c;
			for(char c = 'a';c <= 'z';c++)ctr[c] = c;
			for(char c = 'A';c <= 'Z';c++)ctr[c] = c;
		}
		char cs(){
			char ctr[] = sc.next().toCharArray();
			return ctr[0];
		}
		void doIt(){
			while(true){
				int n = sc.nextInt();
				if(n == 0)break;
				char ctr[] = new char[128];
				set(ctr);
				String s1 = "";
				String s2 = "";
				for(int i = 0;i < n;i++){
					s1 = sc.next();
					s2 = sc.next();
					char c1[] = s1.toCharArray();
					char c2[] = s2.toCharArray();
					ctr[c1[0]] = c2[0];
				}
				StringBuilder sb = new StringBuilder();
				int m = sc.nextInt();
				for(int i = 0;i < m;i++){
					sb.append(ctr[cs()]);
				}
				System.out.println(sb);
			}
		}
	}
}

Measured memory_bytes: 67892
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    int n, x, t;
    cin >> n >> x >> t;
    if (n % x == 0)
        cout << (n / x * t) << endl;
    else
        cout << ((n / x + 1) * t) << endl;
}

Measured memory_bytes: 3624
//↓template↓

#include "bits/stdc++.h"
using namespace std;
/*#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()*/
typedef long long ll;
//typedef complex<double>P;
/*const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;*/
/*int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];*/
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

/*ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS*(abs(a) + abs(b))) { return 0; }
	return a + b;
}*/


//↑template↑

int main() {
	ll a, b;
	cin >> a >> b;
	if (a % 2 == b % 2) { cout << (a + b) / 2 << endl; }
	else { cout << "IMPOSSIBLE" << endl; }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int request=sc.nextInt();
		long sum=0;
		int[] ary=new int[request];
		for(int i=0;i<request;i++){
			ary[i]=sc.nextInt();
			sum+=(long)ary[i];
		}
		//配列aryを昇順にソートして、最初と最後の数字をとる
		Arrays.sort(ary);
		//System.out.println(sum);
		System.out.println(ary[0]+" "+ary[request-1]+" "+sum);
	}

}



Measured memory_bytes: 43204
import copy
s = input()
ss = list(s)
sss = copy.copy(ss)
n = len(ss)
ans = "yes"

for i in range(n):
  sss = copy.copy(ss)
  sss.remove(sss[i])
  if ss[i] in sss:
    ans = "no"
print(ans)
    

Measured memory_bytes: 67856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,a,p[100005];set<int> s;ll ans;
int main()
{
    scanf("%d",&n);
    rep(i,1,n){
        scanf("%d",&a);
        p[a]=i;
        s.insert(i);
    }
    rep(i,1,n){
        int p1,p2,p3,p4;
        sit it=s.lower_bound(p[i]+1);
        if(it!=s.end()) {
            p3=*it;
            it++;
            if(it!=s.end()) p4=*it;
            else p4=n+1;
        }
        else p3=p4=n+1;
        it=s.lower_bound(p[i]);
        if(it!=s.begin()) {
            it--,p2=*it;
            if(it!=s.begin())
                it--,p1=*it;
            else p1=0;
        }
        else p1=p2=0;
        int a=p2-p1,b=p[i]-p2,c=p3-p[i],d=p4-p3;
        ans+=((ll)a*c+(ll)b*d)*i;
        s.erase(p[i]);
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vvl G(n);
    vl indeg(n);
    rep(i, m) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        G[x].pb(y);
        indeg[y]++;
    }
    
    queue<ll> Q;
    rep(v, n) {
        if(indeg[v] == 0) {
            Q.push(v);
        }
    }

    vl dp(n);
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        for(auto u : G[v]) {
            indeg[u]--;
            if(indeg[u] == 0) {
                Q.push(u);
                chmax(dp[u], dp[v] + 1);
            }
        }
    }
    
    ll longestPathLen = 0;
    rep(v, n) {
        chmax(longestPathLen, dp[v]);
    }
    
    out(longestPathLen);
    re0;
}

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

int main()
{
  int n;
  while(cin >> n, n){
    int cnt = 0, co[6] = {500, 100, 50, 10, 5, 1};
    n = 1000 - n;

    for (int i = 0; i < 6; i++){
      int a = n / co[i];
      cnt += a;
      n -= a * co[i];
    }

    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	if n%2 == 1 {
		fmt.Println(0)
		return
	}

	ans := 0
	for i := 10; i <= n; i *= 5 {
		ans += n / i
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512