akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define N 5010
#define ll long long
int n,m,b[N][N],q[N],q1[N],L[N][N],R[N][N];
ll sum[N],ans=0,mp[N][N];
inline char gc(){
	static char *S,*T,buf[1<<16];
	if(T==S){T=(S=buf)+fread(buf,1,1<<16,stdin);if(T==S) return EOF;}
	return *S++;
}
inline int read(){
	int x=0,f=1;char ch=gc();
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1;ch=gc();}
	while('0'<=ch && ch<='9') x=x*10+ch-'0',ch=gc();
	return x*f;
}
int main(){
	n=read();m=read();
	for(int i=2;i<=n;++i) sum[i]=sum[i-1]+read();
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			b[j][i]=read();
	for(int i=1;i<=m;++i){
		int top=0;
		for(int j=1;j<=n;++j){
			while(top && q[top]<b[i][j]) --top;
			L[i][j]=top?q1[top]+1:1;
			q1[++top]=j;q[top]=b[i][j];
		}
		top=0;
		for(int j=n;j>=1;--j){
			while(top && q[top]<b[i][j]) --top;
			R[i][j]=top?q1[top]-1:n;
			q1[++top]=j;q[top]=b[i][j];
		}
		for(int j=1;j<=n;++j){
			mp[L[i][j]][j]+=b[i][j];
			mp[L[i][j]][R[i][j]+1]-=b[i][j];
			mp[j+1][j]-=b[i][j];
			mp[j+1][R[i][j]+1]+=b[i][j];
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j) mp[i][j]+=mp[i][j-1];
		for(int j=1;j<=n;++j) mp[i][j]+=mp[i-1][j];
		for(int j=i;j<=n;++j) ans=max(ans,mp[i][j]-sum[j]+sum[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 213248
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastReader fs = new FastReader();
        int k = fs.nextInt();
        int A = fs.nextInt();
        int B = fs.nextInt();

         boolean ans = false;
         int start =A;
         while(start<=B){
             if(start%k ==0){
                 ans = true;
                 break;
             }
             start++;
         }
        if(ans){
            System.out.println("OK");
        }else{
            System.out.println("NG");
        }
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define _setl(x) __builtin_popcountll(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007LL

void debug(){
	cerr<<"]\n";
}
template<class H,class ... T> void debug(H h,T... t){
	cerr<<h;
	if(sizeof... (t)){
		cerr<<", ";
	}
	debug(t...);
}
#ifdef DEBUG
	#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", debug(__VA_ARGS__)
	#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"
#else
	#define dbg(...) 0
	#define dpv(...) 0
#endif


void solve(){
	int n;
	cin>>n;
	ll s1,s2;
	s1=s2=0;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		s1 = (s1+x)%mod;
		x= (x*x)%mod;
		s2 = (s2+x)%mod;
	}
	s1 = (s1*s1)%mod;
	s1 = (s1-s2+mod)%mod;
	ll half = (mod+1)/2;
	cout<<(s1*half)%mod<<"\n";
}


int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	for(int i=1;i<=_;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

/*
   check for overflows int long long
   correct mize of array
*/


Measured memory_bytes: 3636
#

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    N = int(input())
    d = [0] * N
    multi = [0] * N

    edges = defaultdict(list)
    edges_l = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        d[a-1] += 1
        d[b-1] += 1
        multi[a-1] += 1
        multi[b-1] += 1

        edges_l.append((a-1, b-1))
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)

    for i in range(len(d)):
        d[i] = (d[i], i)
    d.sort(key=lambda v: v[0], reverse=True)

    C = list(map(int, input().split()))
    C.sort(reverse=True)
    # print(d)
    # print(C)
    used = [False] * N
    ans = [0] * N
    count = 0
    que = []
    que.append(d[0][1])
    while que:
        index = que.pop()
        if not used[index]:
            # print('i = {}, Ci = {}'.format(i, C[i]))
            ans[index] = C[count]
            used[index] = True
            count += 1

        # print(edges[i])
        for nei in edges[index]:
            if not used[nei]:
                que.append(nei)

    val = 0
    for a, b in edges_l:
        node_val = min(ans[a], ans[b])
        val += node_val

    print(val)
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 53976
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
const long MOD=1000000007;
bool check=false;


int main(void){
    long N;
    cin>>N;
    vector<long> A(N);
    
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    
    sort(A.begin(),A.end());
    
    for(int i=0;i<N-1;i++){
        if(A.at(i)==A.at(i+1)){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 1792
#include <iostream>

#include <algorithm>
#include <vector>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvl = vector<vl>;


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

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

  vi w(N), v(N);
  REP(i, N) {
    cin >> w[i] >> v[i];
  }
  vvl dp(N+1, vl(W+1, 0));
  REP(i, N) {
    REP(j, W+1) {
      if (j - w[i] >= 0)
        dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
      else
        dp[i+1][j] = dp[i][j];
    }
  }
  ll ans = 0;
  REP(j, W+1) {
    ans = max(ans, dp[N][j]);
  }
  OUT(ans);

  return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, a[202020], t;
void solve(){
	cin >> n >> t;
	i64 cnt = t;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i != 0) cnt += min(a[i]-a[i-1],t);
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1024
using System;

	class Program
	{
		public static void Main(string[] args)
		{
			double n=double.Parse(Console.ReadLine());
			int[] array= new int[(int)n];
			for(int k=0;k<array.Length;k++)
			{
				array[k]=int.Parse(Console.ReadLine());
			}
			int cnt=0;
			int m=1;//?????£??????????????°???h=3???m?????????/??? h<n???
			
			while((Math.Pow(3,m+1)-1)/2<n)//?????????m+1??????
			{
				m++;
			}
			
		/*	
			for(int gap=2;(Math.Pow(3,gap)-1)/2<n;gap++)
			{			
				m++;
			}
		*/	
			int []  G=new int[m];//?????£??????????´???????????????£???????????????????????????????????????????????£??????
			for(int i=0;i<G.Length;i++)//??????.Length????????????????????? m=G.Length
			{
				G[m-1-i]=(int)((Math.Pow(3,i+1)-1)/2);
			}
			for(int s=0;s<G.Length;s++)
			{
				//cnt+=sort( array, G[s]);//?????\?????????????????????
				//?????\???????????´??????
					
			int v=0;
			int j=0;
			for (int k=0;k<G[s];k++)
			{				//?????\?????????
				for(int i=k+G[s];i<array.Length;i+=G[s])
			{
				
				 v=array[i];
				 j=i-G[s];
				while(j>=0&&
				       array[j]>v)
				{
				 	array[j+G[s]]=array[j];
					
				array[j]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				j=j-G[s];
					//?????????????????£??????????????\??¨????????¢?????§???????????§????????????
					//??§????????????????????????????????????
				cnt ++; //????????????????????§????????????????????§??????????????¢??????
				
				}
				
			}
			}
				//?????\???????????´?????????????????§
				
				
			}
			//?????????????????????m???????????????G[i]????????????????????§???????????????G?????¨????????´??????count?????????
			//????????????????????????????????????
			Console.WriteLine(m);
			for(int o=0;o<G.Length-1;o++)
			{
				Console.Write(G[o]+" ");
			}
			Console.Write(G[G.Length-1]+"\r\n");//???????????§?????????
			Console.WriteLine(cnt);//?????????
			for(int l=0;l<array.Length;l++)
			{
				Console.WriteLine(array[l]);
			
			}
			
			
		}
		/*public static int sort(int [] A,int g)
		{
			//g????????£??????
			int count=0;//??????????????°
			int v=0;
			int j=0;
			for (int k=0;k<g;k++)
			{
				//?????\?????????
			for(int i=k+g;i<A.Length;i+=g)
			{
				
				 v=A[i];
				 j=i-g;
				while(j>=0&&
				       A[j]>v)
				{
					A[j+g]=A[j];
					
				A[j]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				j=j-g;
					//?????????????????£??????????????\??¨????????¢?????§???????????§????????????
					//??§????????????????????????????????????
				count ++; //????????????????????§????????????????????§??????????????¢??????
				
				}
				
			}
			}
			return count;
		}
		*/
	}
	

Measured memory_bytes: 16832
#include<stdio.h>
#include<string.h>
char ch[205][11],str[11];
int s[205];
int main()
{
	int a,b,k=0;
	scanf("%d",&a);
	getchar();
	for(int i=0;i<a;i++)
	{
		scanf("%s",str);
		int flag=0;
		for(int j=0;j<k;j++)
		{
			if(strcmp(ch[j],str)==0)
			{
				flag=1;
				s[j]++;
				break;
			}
		}
		if(flag==0)
		{
			strcpy(ch[k],str);
			s[k]++;
			k++;
		}
	}
	scanf("%d",&b);
	getchar();
	for(int i=0;i<b;i++)
	{
		scanf("%s",str);
		int flag=0;
		for(int j=0;j<k;j++)
		{
			if(strcmp(ch[j],str)==0)
			{
				flag=1;
				s[j]--;
				break;
			}
		}
		if(flag==0)
		{
			strcpy(ch[k],str);
			s[k]--;
			k++;
		}
	}
	int max=0;
	for(int i=0;i<k;i++)if(s[i]>max)max=s[i];
	printf("%d\n",max);
}

Measured memory_bytes: 504
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] ai = new int[N];
        int[] bi = new int[N];
        int[] ci = new int[N];

        for (int i = 0; i < N; i++) {

            ai[i] = Integer.parseInt(sc.next());
            bi[i] = Integer.parseInt(sc.next());
            ci[i] = Integer.parseInt(sc.next());
        }

        sc.close();

//        int[] dp = new int[N+1];
        int[] aiDp = new int[N+1];
        int[] biDp = new int[N+1];
        int[] ciDp = new int[N+1];

//        dp[0] = Math.max(ai[0], Math.max(bi[0], ci[0]));
        aiDp[0] = ai[0];
        biDp[0] = bi[0];
        ciDp[0] = ci[0];

//      dp[1] = Math.max((ai[1] + Math.max(bi[0], ci[0])), Math.max((bi[1] + Math.max(ai[0], ci[0])), (ci[1] + Math.max(ai[0], bi[0]))));
//        aiDp[1] = ai[1] + Math.max(bi[0], ci[0]);
//        biDp[1] = bi[1] + Math.max(ai[0], ci[0]);
//        aiDp[1] = ci[1] + Math.max(ai[0], bi[0]);

        for (int i = 1; i < N; i++) {

            aiDp[i] = ai[i] + Math.max(biDp[i-1], ciDp[i-1]);
            biDp[i] = bi[i] + Math.max(aiDp[i-1], ciDp[i-1]);
            ciDp[i] = ci[i] + Math.max(aiDp[i-1], biDp[i-1]);
        }

        System.out.println(Math.max(aiDp[N-1], Math.max(biDp[N-1], ciDp[N-1])));

    }
}

Measured memory_bytes: 63900
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define N 200005

int cnt[N];

int main(void) {
	int n;
	CL(cnt, 0);
	scanf("%d", &n);
	REP(i, n - 1) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}

	FOR(i, 1, n + 1) {
		printf("%d\n", cnt[i]);
	}
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
int n,cnt[505];
int ans[250005],p[505];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&p[i]),ans[p[i]]=i;
	for (int i=1;i<=n*n;i++){
		if (!ans[i]){
			int id=-1,tp;
			for (int j=1;j<=n;j++){
				if (cnt[j]==n||(cnt[j]==j-1&&j<p[j])) continue;
				int tp1=(cnt[j]>=j);
				if (id==-1) id=j,tp=tp1;
				else if (tp!=tp1){
					if (tp==1&&tp1==0)
						id=j,tp=tp1;
				}
				else if (p[id]>p[j])
					id=j,tp=tp1;
			}
			if (id==-1) return puts("No"),0;
			ans[i]=id;
		}
		else if (cnt[ans[i]]!=ans[i]-1)
			return puts("No"),0;
		cnt[ans[i]]++;
	}
	puts("Yes");
	for (int i=1;i<=n*n;i++)
		printf("%d ",ans[i]);
}

Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#define REP(i, START, n, STEP) for(int i = START; i < (n); i += (STEP))
#define rep(i, n) REP(i, 0, n, 1)
using namespace std;

typedef long long int ll;
typedef pair<int, int> P;

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

	return gcd(b, a % b);
}
ll solve(ll n)
{
	if (n == 1) {
		return 0;
	}
	// 割る数の初期値
	ll a = 2;
	set<ll> s;
	while (n >= a * a) {
		if (n % a == 0) {
			n /= a;
			s.insert(a);
		}
		else {
			a++;
		}
	}

	// 最後に残った数も素因数
	if(n != 1) s.insert(n);

	return s.size();
}


int main()
{
	ll a, b;
	cin >> a >> b;

	// 最大公約数
	ll _gcd = gcd(a, b);

	cout << solve(_gcd) + 1;

	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
d={};price=0
for _ in range(n):
  a,b=map(int,input().split())
  if a not in d:
    d[a] = b
  else:
    d[a] += b
d=sorted(d.items(),key=lambda x:x[0])
for i in d:
  for _ in range(i[1]):
    if m == 0:
      print(price)
      exit()
    m-=1
    price+=i[0]
else:
  print(price)

Measured memory_bytes: 28932
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> d(k);
	for(int i = 0; i < k; i++){
		cin >> d[i];
	}

	for(int x = n; x < 100000; x++){
		int tmp = x;
		set<int> s;
		while(tmp!=0){
			s.insert(tmp%10);
			tmp /= 10;
		}
		bool flag = true;
		
		for(int i = 0; i < k; i++){
			if(s.count(d[i])) flag = false;
		}
		if(flag){
			cout << x << endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void){

  long a,b,k;
  scanf("%ld %ld %ld", &a, &b, &k);
  for (long i = a; i <= b; i++) {
    if (i-a+1 <= k) {
      printf("%ld\n", i);
    } else if (b-i+1 <= k) {
      printf("%ld\n", i);
    }
  }

  return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

from math import log2

x,y = readInts()

kouho = int(log2(y)-log2(x)+1)-1

ans = kouho-1

for i in range(kouho,kouho+3):
	if x*2**(i-1)<=y:
		ans+=1
	else:
		print(ans)
		break

Measured memory_bytes: 9436
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


S = _S()
T = _S()
ans = 0

ls = len(S)
lt = len(T)
count = [0]*(ls-lt+1)
for i in range(ls-lt+1):
    for j in range(lt):
        if S[i+j]==T[j]:
            count[i]+=1
ans = lt - max(count)

print(ans)

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

int main()
{
    int n,m,i,a,sum=0;
    cin>>n>>m;
    for(i=0; i<m; i++)
    {
        scanf("%d",&a);
        sum+=a;
    }
    if(sum<=n)printf("%d\n",n-sum);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 3836
#include "stdio.h"
#include <iostream>
using namespace std;

/** Problem0074 : Videotape **/
void print(int s)
{
	printf("%02d:%02d:%02d\n", s/3600, (s/60)%60, s%60);
}

int main()
{
	int h, m, s, sum, ans;
	
	while (1) {
		cin >> h >> m >> s;
		if (h == -1 && m == -1 && s == -1)
			break;
		sum = h*60*60 + m*60 + s;
		ans = 120*60 - sum;
		print(ans);
		print(3*ans);
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1001

vector<pair<int,pair<int,int> > > vec;


bool calc(){
  int h,w;

  scanf("%d%d",&h,&w);

  if(h==0) return false;

  auto it = upper_bound(vec.begin(),vec.end(),make_pair(h*h+w*w,make_pair(h,w)));

  printf("%d %d\n",it->second.first,it->second.second);
  
  return true;
}

int main(){

  for(int i=1;i<=150;i++){
    for(int j=i+1;j<=150;j++){
      vec.push_back({i*i+j*j,{i,j}});
    }
  }

  sort(vec.begin(),vec.end());
  
  while(calc());
  
  return 0;
}

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

using namespace std;

#define ll long long
#define mod 1000000007

const ll INF = 1e11;

void solve(){

    int n; cin >> n;
    string str; cin >> str;
    int pt = 0, ans = 0;
    for(int i = 0; i < n; ++i){
        if(str[i] == 'R'){
            if(str[pt] != 'R') ++ans;
            ++pt;
        }
    }
    cout << ans;

    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


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

  std::vector<std::vector<int>> L(10, std::vector<int>(10));

  for(int A=1; A<=N; A++) {
    std::string a = std::to_string(A);
    int h = a.front() - '0';
    int b = a.back() - '0';
    L[h][b]++;
  }

  ll ans = 0;
  rep(i,10) rep(j,10) {
    ans += L[i][j]*L[j][i];
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
v = list(map(float,input().split()))
v.sort()
for i in range(0,100,2):
  v.append((v[i]+v[i+1])/2)
  v[i] = v[i+1] = 0
  v.sort()
  if v[-2] == 0:
    break
print(v[-1])


Measured memory_bytes: 2940
# B - Frog 2
def main():
    N, K, *H = map(int, open(0).read().split())
    H = [0] + H + [0] * K
    dp = [1 << 30] * (N + K + 1)
    dp[1] = 0
    for i, a in enumerate(H[1:N + 1], 1):
        for j, b in enumerate(H[i + 1:i + K + 1], i + 1):
            dp[j] = min(dp[j], dp[i] + abs(a - b))
    print(dp[N])


if __name__ == "__main__":
    main()


Measured memory_bytes: 59948
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char data[1010],data2[1010];
int alg(void);
int main(){
    int i,n,A[1010];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",data,data2);
        A[i]=alg();
    }
    for(i=0;i<n;i++){
        printf("%d\n",A[i]);
    }
    return 0;
}
int alg(){
    int i,j,x,y,a[1010][1010];
    x=strlen(data);
    y=strlen(data2);
    for(i=0;i<=x;i++){
        a[i][0]=0;
    }
    for(j=0;j<=y;j++){
        a[0][j]=0;
    }
    for(i=1;i<=x;i++){
        for(j=1;j<=y;j++){
            if(data2[j-1]==data[i-1])a[i][j]=a[i-1][j-1]+1;
            else if(a[i-1][j]>=a[i][j-1])a[i][j]=a[i-1][j];
            else a[i][j]=a[i][j-1];
        }
    }
    return a[x][y];
}



Measured memory_bytes: 5740
N = int(input())
s = []
for i in range(N):
    s.append(str(input()))

print ("AC x " + str(s.count('AC')))
print ("WA x " + str(s.count('WA')))
print ("TLE x " + str(s.count('TLE')))
print ("RE x " + str(s.count('RE')))

Measured memory_bytes: 16272
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
bool valid(vector<vector<int>> v){
	int N = v.size();
	int K = v[0].size();
	rep(i,N){
		if( v[i].size() != K ) return 0;
	}
	rep(i,N) rep(j,i){
		set<int> st;
		for(int a:v[i]) st.insert(a);
		for(int a:v[j]) st.insert(a);
		if(st.size() != 2*K-1) return 0;
	}
	vector<int> cnt(N);
	rep(i,N){
		for(int a:v[i]) cnt[a]++;
	}
	rep(i,N){
		if(cnt[i] != K) return 0;
	}
	return 1;
}
int main(){
	int K = 42;
	int N = K*(K-1)+1;
	vector<vector<int>> ans;
	int X = N-1;
	rep(i,K){
		vector<int> vc;
		vc.pb(X);
		rep(j,K-1) vc.pb(i*(K-1)+j);
		ans.pb(vc);
	}
	rep(d,K-1){
		rep(i,K-1){
			vector<int> vc;
			vc.pb(d);
			rep1(j,K-1){
				vc.pb(j*(K-1) + (i+d*j)%(K-1));
			}
			ans.pb(vc);
		}
	}
//	show(valid(ans));

	cout<<N<<" "<<K<<endl;
	rep(i,N){
		rep(j,K) cout<<ans[i][j]+1<<" ";
		puts("");
	}
}


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

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

int main() {
    int n, cnt = 0, ans = 0;
    int a, b, k;
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=200005;
int n,val[N],nxt[N],pre[N],cnt2[N][26];
string s;
bool done[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  string s;
  cin>>s; n=sz(s);
  s="#"+s;
  rep(i,1,n+1)
    {
      rep(j,0,26) cnt2[i][j]=cnt2[i-1][j];
      cnt2[i][s[i]-'a']++;
    }
  set<int> tmp;
  int ans=0;
  rep(i,1,n+1)
    {
      int j=i;
      while(j<=n && sz(tmp)<26)
	{
	  tmp.insert(s[j]-'a');
	  j++;
	}
      if(sz(tmp)==26) ans++;
      tmp.clear();
      i=j-1;
    }
  int cnt=0;
  repv(i,1,n+1)
    {
      int j=i;
      while(j>=1 && sz(tmp)<26)
	{
	  val[j]=cnt;
	  nxt[j]=i+1;
	  tmp.insert(s[j]-'a');
	  j--;
	}
      if(sz(tmp)==26) cnt++;
      tmp.clear();
      i=j+1;
    }
  val[0]=ans;
  int rem=ans,taken=0;
  string ret="";
  rep(i,1,n+1)
    {
      int c=s[i]-'a';
      if(val[i]==rem || pre[c]>taken)
	{
	  pre[c]=i;
	  continue;
	}
      rep(j,0,26) done[j]=false;
      vector<ii> valid;
      rep(j,i,nxt[i])
	{
	  c=s[j]-'a';
	  bool ok=false;
	  rep(k,0,26)
	    if(cnt2[nxt[j]-1][k]-cnt2[j][k]==0) ok=true;
	  if(ok && pre[c]<=taken && !done[c]) valid.pb(mp(c,j));
	  done[c]=true;
	}
      sort(all(valid));
      assert(sz(valid)>0);
      taken=valid[0].se;
      ret+=(char)(valid[0].fi+'a');
      rep(j,i,nxt[i])
	pre[s[j]-'a']=j;
      rem--;
    }
  rep(i,0,26)
    if(pre[i]<=taken)
      {
	ret+=(char)(i+'a');
	break;
      }
  assert(sz(ret)==ans+1);
  cout<<ret<<endl;
  return 0 ;
}


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

#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;


void solve() {
    ll n;
    cin >> n;
    vector<pair<ll, int>> primes;
    ll m = n;
    for (ll div = 2; div * div <= n; ++div) {
        if (m % div == 0) {
            primes.push_back({div, 0});
            while (m % div == 0) {
                m /= div;
                primes.back().second++;
            }
        }
    }
    if (m != 1) primes.push_back({m, 1});
    int cnt = 0;
    for (auto p : primes) {
        int need = 1;
        while (p.second >= need) {
            p.second -= need; ++cnt;
            ++need;
        }
    }
    cout << cnt << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3644
from collections import deque

BLACK = '#'
WHITE = '.'
vec_x = [1, 0, -1, 0]
vec_y = [0, 1, 0, -1]
vec_num = len(vec_x)

def solve():
    count = 0
    for i in range(H):
        for j in range(W):
            if used[i][j]:
                continue
            b = 0
            w = 0
            que = deque([(i, j)])
            used[i][j] = True

            while que:
                next_i, next_j = que.popleft()

                #黒か白かをカウント
                if(S[next_i][next_j] == BLACK):
                    b += 1
                else:
                    w += 1

                #隣接するマスの色が現在のマスと違うならキューに追加
                for d in range(vec_num):
                    d_i = next_i + vec_y[d]
                    d_j = next_j + vec_x[d]
                    if not check(next_i, next_j, d_i, d_j) or used[d_i][d_j]:
                        continue
                    que.append((d_i, d_j))
                    used[d_i][d_j] = True
            count += b * w
    return count

def check(i, j, d_i, d_j):
    if not (0 <= d_i < H and 0 <= d_j < W):
        return False
    if S[i][j] == S[d_i][d_j]:
        return False
    return True



if __name__ == "__main__":
    H, W = map(int, input().split())
    S = [[]] * H
    used = [[]] * H
    for h in range(H):
        S[h] = list(input())
        used[h] = [False] * W
    print(solve())


Measured memory_bytes: 6132
N, M = list(map(int, input().split()))
questions = []
for i in range(M):
    p, S = list(input().split())
    questions.append([int(p), S])

ac_list = [0] * N
wa_list = [0] * N

for p, S in questions:
    if S == 'AC':
        ac_list[p - 1] = 1
    else:
        if ac_list[p - 1] == 1:
            continue
        wa_list[p - 1] += 1

for i in range(N):
    if ac_list[i] == 0:
        wa_list[i] = 0

print(sum(ac_list), sum(wa_list))


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

int main()
{
  int n,nn;
  string s,ans;
  cin>>n>>s;
  if(n%2!=0)
    ans="No";
  else
  {
    nn=n/2;
    for(int i=0;i<nn;i++)
    {
      if(s.at(i)!=s.at(i+nn))
      {
        ans="No";
        break;
      }
    }
  }
  if(ans!="No")
  {
    ans="Yes";
  }
  cout<<ans<<endl;
}


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

bool dp[101][10001];
int n;

void ans() {
  for (int i = 100*n; i > 0; --i) {
    if (i % 10 == 0 || !dp[n][i]) continue;
    cout << i << endl;
    return;
  }
  cout << 0 << endl;
}

int main() {
  cin >> n;
  int s[n];
  rep(i, n) cin >> s[i];
	
  dp[0][0] = true;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= 100*n; ++j) {
      dp[i][j] = dp[i-1][j];
      if (j-s[i-1] >= 0 && dp[i-1][j-s[i-1]]) dp[i][j] = true;
    }
  }
  ans();
  return 0;
}

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

vector<int> vec(110);

int main(void)
{

    int n;
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> vec.at(i);
    }

    int sum_alice = 0;
    int sum_bob = 0;
    vector<int>::iterator it;

    for(int i = 0; i < n; i++)
    {
        it = max_element(vec.begin(), vec.end());
        sum_alice += *it;
        *it = 0;
        it = max_element(vec.begin(), vec.end());
        sum_bob += *it;
        *it = 0;
    }

    cout << sum_alice - sum_bob << endl;

    return 0;
}

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

	cin >> x >> y;
	cout << x*y/gcm(x,y) << endl;
	return 0;
}

int gcm(int x, int y){
	int r;
	if (x<y) swap(x,y);

	while(y>0){
		r =x%y;
		x=y;
		y=r;
	}
	return x;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;


int main(){
	fast;
	string s;
	cin >> s;
	ll ans = 0, mx = 0;
	for(int i = 0; i < s.size(); ++i){
		while(s[i] == 'R' && i < s.size()){
			++ans;
			++i;
		}
		mx = max(mx, ans);
		ans = 0;
	}
	cout << mx;
	return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a > 12)
        cout << b << endl;
    else if (a >= 6)
        cout << b / 2 << endl;
    else
        cout << 0 << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(){
    int N;
    int i;
    int array[50];

    int tmp;
    int tmp2;
    int x = 0;

    scanf("%d", &N);

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

    for (i = 1; i < N; i++){
        if(array[i]<array[i-1]){
            if(x==0){
                tmp = i-1;
                x = 1;
            }
            else if(x==1){
                tmp2 = array[tmp];
                array[tmp] = array[i];
                array[i] = tmp2;
                break;
            }
        }
    }

    for (i = 0; i < N-1; i++){
        if(array[i]>array[i+1]){
            printf("NO\n");
            return 0;
        }
    }

    printf("YES\n");

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{     int n,i,j,s;
    while(~scanf("%d",&n)) 
  {  s=0;
  int a[n];
  for(i=0;i<n;i++)
  scanf("%d",&a[i]);
  	for(i=1;i<n-1;i++)
  	{
	if(a[i]>a[i-1]&&a[i]<a[i+1])
  	{
	  s++;
	  continue;}
  	if(a[i]<a[i-1]&&a[i]>a[i+1])
  	s++;}
  	printf("%d\n",s);
  	
  }
      
  
  
}


Measured memory_bytes: 504
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    A=[]
    for i in range(m):
        p,y=map(int,input().split())
        A.append((p,y,i))
    A.sort()
    cunt,pre,ans=0,0,[]
    for a in A:
        s1=str(a[0])
        if pre!=a[0]:
            cunt=1
            pre=a[0]
        s2=str(cunt)
        ans.append((a[2],s1.zfill(6)+s2.zfill(6)))
        cunt+=1
    ans.sort()
    for s in ans:
        print(s[1])

if __name__=='__main__':
    main()

Measured memory_bytes: 76636
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define No 100005
const ll INF = 1000000001;
const ll MOD = 998244353 ; //1e9+7;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0}, cnt = 0;


void solve(){
    string s1, s2;
    cin >> s1 >> s2;
    ll n, m;
    n = s1.size();
    m = s2.size();
    ll a[n+1][m+1];
    f(0, n) a[i][0] = 0;
    f(0, m) a[0][i] = 0;
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=m; j++){
            if(s1[i-1] == s2[j-1]) a[i][j] = a[i-1][j-1] + 1;
            else a[i][j] = max(a[i-1][j], a[i][j-1]);
        }
    }
    //cout << a[n][m] << "\n";
    string ans = "";
    ll i=n, j= m;
    while(i >0 and j > 0){
        if(s1[i-1] == s2[j-1]){
            ans += s1[i-1];
            i--; j--;
        }
        else if(a[i][j-1] > a[i-1][j]) j--;
        else i--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
    //}
    return 0;
}


Measured memory_bytes: 73928
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		
		int[] count = new int[m];
		
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < n; j++) {
				if(sc.nextInt() == 1) count[i]++;
			}
		}
		Arrays.sort(count);
		System.out.println(count[m-1]);
		
	}
}

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

const int mod = 1E9 + 7;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> A(n+1, 0);
	vector<int> flg(n+1, 0);

	for (int i = 1; i <= m; i++) {
		int x;
		cin >> x;
		A[x] = 1;
	}

	flg[0] = 1;

	for (int i = 1; i <= n; i++) {
		if (!A[i])
			flg[i] = (flg[i-1] + flg[i-2]) % mod;
	}

	cout << flg[n] << endl;
}

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

int main(void){
		while(1){
				int n,x,p = 0;
				cin >> n >> x;

				if(n == 0 && x == 0) break;
				for(int i = 1;i <= n-2;i++){
						for(int j = i + 1;j <= n-1;j++){
								for(int k = j + 1;k <= n;k++){
										if( x == i + j + k){
												p++;
										}
								}
						}
				}
				cout << p << endl;
		}
		return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
 
public class Main {
	static ArrayList<Integer> primes;
	static int[] isComposite;

	static void sieve(int N)	// O(N log log N) 
	{
		isComposite = new int[N+1];					
		isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i) 					//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N)) 
			if (isComposite[i] == 0) 					//can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				if(1l * i * i <= N)
					for (int j = i * i; j <= N; j += i)	// j = i * 2 will not affect performance too much, may alter in modified sieve
						isComposite[j] = 1;
			}   
	}
	public static void main(String[] args) throws IOException {
		MScanner sc = new MScanner(System.in);
		//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		int n=sc.nextInt();int b=sc.nextInt();
		if(Math.abs(n-b)%2!=0) {
			pw.println("IMPOSSIBLE");
		}
		else {
			pw.println(Math.min(n, b)+(Math.abs(n-b)/2));
		}
		//int[]in=new int[n];for(int i=0;i<n;i++)in[i]=sc.nextInt();
		
		
		
		
		pw.close();
		pw.flush();
 
	}
	static int gcd(int a, int b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 21584
import copy
from collections import deque
cnt = 0
def dfs(G,s,n,seen):
    global cnt
    li = copy.copy(seen)
    li.append(s)
    if len(li) == n:
        cnt += 1
        return 0
    for x in G[s]:
        if x in li:
            continue
        dfs(G,x,n,li)

N,m = map(int,input().split())
seen = []
G = [[] for _ in range(N)]
for i in range(m):
    a,b = map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
dfs(G,0,N,seen)
print(cnt)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <unordered_map>
using namespace std;

int main(void){
    int N;
    cin >> N;
    int ans;
    for(int i=N;i<=999;i++){
        if(i % 111 == 0){
            ans = i;
            break;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  for (int i=0;i<s.size();i++){
    int r=0;
    for (int j=0;j<s.size();j++){
      if(s.at(i)==s.at(j)) r+=1;
    }
    
    if(r%2==1) {
      cout<<"No";
      break;
    }
    if(i==s.size()-1) cout<<"Yes";
  
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int n = scanner.nextInt();
    int k = scanner.nextInt();
    int num = k;
    
    for(int i = 0; i < n - 1; i++) {
      num = num * (k - 1);
    }
    System.out.println(num);
  }
}

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

int main() {
  char c;
  cin >> c;
  if (c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout << "vowel" << endl;
  }else
  {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if(n%10 == 7 || (n/10)%10 == 7 || (n/100)%10 == 7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
pair<ll,int> p[100010],q[100010];
map<ll,vector<pair<int,int>>> mp;
vector<pair<int,int>> ans;
vector<int> G[100010];
ll d[100010],j[100010],e[100010],n;
int dfs(int s,int p){
	int res = 1;
	for(int v: G[s]){
		if(v!=p){
			d[v] = d[s] + 1;
			res += dfs(v,s);
		}
	}
	return j[s] = res;
}

void solve(int s, int p, ll val){
	for(int v:G[s]){
		if(v!=p){
			e[v] = val + n - 2*j[v];
			solve(v,s,e[v]);
		}
	}
}

int main(){
	int i;
	cin >> n;
	for(i=0;i<n;i++){
		ll d; cin >> d;
		p[i] = {d,i};
	}
	sort(p,p + n);
	for(i=n-1;i>=0;i--){
		if(mp.find(p[i].first)==mp.end()){
			mp[p[i].first - n + 2].push_back({p[i].second,1});
		}else{
			int sum = 1;
			for(auto x:mp[p[i].first]){
				sum += x.second;
				ans.push_back({x.first,p[i].second});
			}
			mp[p[i].first - n + 2*sum].push_back({p[i].second,sum});
		}
	}
	if(ans.size()==n-1){
		for(i=0;i<n;i++) d[i] = -1;
		for(i=0;i<n-1;i++){
			int f = ans[i].first,s = ans[i].second;
			G[f].push_back(s); G[s].push_back(f);
		}
		d[0] = 0; dfs(0,-1);
		ll m = 0;
		for(i=0;i<n;i++){
			if(d[i]==-1){
				cout << -1 << endl;
				return 0;
			}
			m += d[i];
		}
		e[0] = m; solve(0,-1,m);
		for(i=0;i<n;i++){
			q[i] = {e[i],i};
		}
		sort(q,q + n);
		for(i=0;i<n;i++){
			if(p[i]!=q[i]){
				cout << -1 << endl;
				return 0;
			}
		}
		for(i=0;i<ans.size();i++){
			cout << ans[i].first + 1 << " " << ans[i].second + 1 << "\n";
		}
	}else{
		cout << -1 << endl;
	}
}

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

int main(void){
    ld a, b, h, m;
    ld rad;
    ld ans;

    cin >> a >> b >> h >> m;

    h=h*(ld)30.0+m*(ld)0.5;
    m=m*(ld)6.0;
    rad=h-m;
    rad=rad*(ld)3.1415926535897932384626/(ld)180.0;

    if(rad<0)rad*=-1.0;
    ans=a*a+b*b+((ld)-2.0*a*b*cos(rad));
    //cout<<ans<<endl;
    printf("%.30Lf\n",sqrtl(ans));
    //cout<<sqrtl(ans)<<endl;
    return 0;
}

Measured memory_bytes: 4164
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

bool sosuu(int num) {
	if (num < 2)return false;
	else if (num == 2)return true;
	else if (num % 2 == 0)return false;

	long double b = num;
	long double a = sqrt(b);
	for (int i = 3; i <= a; i += 2) {
		if (num % i == 0)
			return false;
	}
	return true;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int X;
	cin >> X;
	while (1) {

		if (sosuu(X)) {
			cout << X << endl;
			return 0;
		}
		X++;

	}

	return 0;
}



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

int main(){
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if (c <= 0){
        cout << "Yes" << endl;
        break;
    }
    a -= d;
    if (a <= 0){
        cout << "No" << endl;
        break;
    }
  }
}


Measured memory_bytes: 3636