akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

const int SIZE = (1e5) + 4;
bool inp[SIZE] = {};
vector<int> pr;

int main(){
    for(int i = 2; i < SIZE; i++){
        if(!inp[i]){
            for(int j = 2*i; j < SIZE; j += i) inp[j] = 1;
            pr.push_back(i);
        }
    }
    int x;
    cin >> x;
    cout << *lower_bound(pr.begin(), pr.end(), x) << '\n';
}


Measured memory_bytes: 512
#include <stdio.h>
 
int main()
{
    char c;
 
    fscanf(stdin, "%c", &c);
 
    while (c != '\n') {
        if (c >= 'A' && c <= 'Z') {
            c = c + ('a' - 'A');
        } else if (c >= 'a' && c <= 'z') {
            c = c + ('A' - 'a');
        }
        fprintf(stdout, "%c", c);
        fscanf(stdin, "%c", &c);
    }
    putchar('\n');
 
    return 0;
}

Measured memory_bytes: 524
import Control.Applicative
import Control.Monad
import Data.List

factors m = sub m (2:[3,5..])
  where
    sub 1 _ = []
    sub n pa@(p:ps)
      | q < p = [n]
      | r == 0 = p : sub q pa
      | otherwise = sub n ps
      where
        (q, r) = divMod n p

ffc m = map length $ group $ sort $ concat $ map factors [1..m]

solve n =
    lenn 74 + 
    lenn 24 * (lenn 2 - 1) +
    lenn 14 * (lenn 4 - 1) + 
    lenn 4 * (lenn 4 - 1) * (lenn 2 - 2) `div` 2
  where
    fc = ffc n
    lenn t = length $ takeWhile (>=t) fc

main = readLn >>= print . solve

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
	ll i,j,k,l,m,n,t;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	t=1;
	while(t--)
	{
		cin>>n;
		ll a[n];
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		l=0;
		m=0;
		for(i=n-2;i>=0;i--)
		{
		    if(a[i]>=a[i+1])
		    {
		        l++;
		    }
		    else
		    {
		        l=0;
		    }
		    m=max(m,l);
		}
		cout<<m<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 4;

ll n, k, a[N];
ll pref[N], suff[N], sum[N];

void solve() {
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }

    for (int i = k + 1; i <= n; ++i) {
        pref[i] = pref[i - 1] + max(0LL, a[i - k]);
    }
    for (int j = n - k; j > 0; --j) {
        suff[j] = suff[j + 1] + max(0LL, a[j + k]);
    }

    ll ans = 0;
    for (int i = 1; i + k - 1 <= n; ++i) {
        ans = max(ans, pref[i + k - 1] + suff[i]);
        ans = max(ans, pref[i + k - 1] + suff[i] + sum[i + k - 1] - sum[i - 1]);
    }

    cout << ans << "\n";
}

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

    int z = 1;
    /// cin >> z;

    while (z--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 6732
#include<bits/stdc++.h>
using namespace std;
bool ok(int a)
{
   int n=0;
   int aa=a;
   while(aa)
   {
      n = n*10 + aa%10;
      aa/=10;
   }
   return a==n;
}
int main()
{
   int a,b,i,j,cnt=0;
   cin>>a>>b;
   for(i=a;i<=b;i++)
   {
      if(ok(i))cnt++;
   }
   cout<<cnt<<endl;
   return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    string s, t;
    cin >> s >> t;
    int ans = INF;
    int len1 = s.size();
    int len2 = t.size();
    for (int i = 0; i + len2 <= len1; i++)
    {
        int pos = i;
        int k = 0;
        int cnt = 0;
        for (int j = pos; j < pos + len2; j++)
        {
            if (t[k] != s[j])
            {
                cnt++;
            }
            k++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   int n;
   cin >> n;
   vector<ll> a(n);
   rep(i,n)cin >> a.at(i);
   unordered_map<int ,int> cnt;
   rep(i,n){
      if(cnt.count(a[i])){
         cnt.at(a[i])++;
      }
      else{
         cnt[a[i]]=1;
      }
   }
   ll sum=0;
   for(auto p:cnt){
      auto k=p.first;
      auto v=p.second;
      if(v>=k){
         sum+=v-k;
      }
      else{
         sum+=v;
      }
   }
   cout << sum << endl;
}

Measured memory_bytes: 7996
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
    int N;cin >> N;
    long long K; cin >> K;
    vector<pair<long long,long long>> ab(N);
    rep(i,N){
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ab.begin(),ab.end());
    long long sum = 0;
    long long ans;
    rep(i,N){
        sum += ab[i].second;
        if(sum >= K){
            ans = ab[i].first;
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int edge[][] = new int[n-1][3];
		List<int[]>[] link = new List[n];
		for(int i=0; i<n; i++) {
			link[i] = new LinkedList<int[]>();
		}
		int[] color = new int[n];
		Arrays.fill(color, -1);

		int u, v, w;
		for(int i=0; i<n-1; i++) {
			u=sc.nextInt()-1;
			v=sc.nextInt()-1;
			w=sc.nextInt();
			edge[i][0]=u;
			edge[i][1]=v;
			edge[i][2]=w;
		}
		for(int i=0; i<n-1; i++) {
			link[edge[i][0]].add(edge[i]);
			link[edge[i][1]].add(edge[i]);
		}
		Queue<Integer> q= new ArrayDeque<>();
		q.add(0);
		color[0]=0;
		int next;
		int p;
		while(q.size()!=0) {
			p = q.poll();
			for(int[] l: link[p]) {
				if(l[0]==p) next=l[1];
				else next=l[0];
				if(color[next]>=0) continue;
				q.add(next);
				color[next]=color[p]^l[2]%2;
			}
		}
		for(int c: color)
			System.out.println(c);
	}
}

Measured memory_bytes: 105308
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include<iterator>
#include <map>
using namespace std;
// bool cmp(long long a, long long b){
//     return a > b;
// }
int main() {
    // ios_base::sync_with_stdio(false);
    long long t, ch, i, h, a, b, l, r, z, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, q, count, ans = 0;
    long long fl;
    string s, s1;
//    cin >> t;
    // long long d, g, w;
    // long long kol = 0, ch2;
//    for (long long test_case = 0; test_case < t; test_case++){
//        cin >> n;
//        for (i )
//        }
//    }
    cin >> n;
    long long* arr = new long long[n];
    for (i = 0; i < n; i++){
        cin >> arr[i];
    }
    k = 0;
    ans = 0;
    sort(arr, arr + n);
    for (i = 0; i < n; i++)
        for (j = i + 1; j < n; j++)
            for (z = j + 1; z < n; z++){
                if ((arr[i] + arr[j] > arr[z]) && (arr[i] != arr[j]) && (arr[i] != arr[z]) && (arr[z] != arr[j])) {
//                    cout << arr[i] << " " << arr[j] << " " << arr[z] << endl;
                    ans++;
                }
            }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().ToDecimal();
            if (n % 2 == 1)
            {
                WriteRead(0);
                return;
            }
            var ans = Math.Min(G2(n, 2), G2(n, 5));
            WriteRead(ans);
        }

        static decimal G1(decimal n, decimal p)
        {
            if (n == 0) return 0;
            return Math.Floor(n / p) + G1(Math.Floor(n / p), p);
        }

        static decimal G2(decimal n, decimal p)
        {
            decimal result = G1(Math.Floor(n / 2), p);
            if (p == 2) result += Math.Floor(n / 2);
            return result;
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  char maps[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> maps[i][j];
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << maps[i][j];
    }
    cout << endl;
    for(int j=0;j<w;j++){
      cout << maps[i][j];
    }
    cout << endl;
  }

  return 0;

}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

max_damage = max(damage for damage, cost in magic)
dp = [0] * (H + max_damage)

for x in range(1, H + max_damage):
    dp[x] = min(dp[x - damage] + cost for damage, cost in magic)

ans = min(dp[H:])

print(ans)

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=112345;

int n,w,wi[112],a[nmax];
ll v[112];
struct linetree
{
    int l,r,flg;
    ll v;
}lt[812345],n1;

void build()
{
    int i=1;
    int cnt=0;
    int mid;
    if(w>0)
    {
        lt[1].l=1;
        lt[1].r=w;
        while(1)
        {
            if(lt[i].l!=lt[i].r)
            {
                mid=(lt[i].l+lt[i].r)/2;
                lt[2*i].l=lt[i].l;
                lt[2*i].r=mid;
                lt[2*i+1].l=mid+1;
                lt[2*i+1].r=lt[i].r;
            }
            else if(lt[i].l)
            {
                a[lt[i].l]=i;
                ++cnt;
                if(cnt==w)
                {
                    break;
                }
            }
            ++i;
        }
    }
}

void solve2(int li,ll vi,int i,int pos)
{
    if(lt[i].v<vi)
    {
        if(lt[i].l==li)
        {
            lt[i].v=vi;
            i*=2;
            while(lt[i].l)
            {
                lt[i].v=vi;
                i*=2;
            }
            lt[i/2].flg=pos;
        }
        else
        {
            int mid=(lt[i].l+lt[i].r)/2;
            if(li<=mid)
                solve2(li,vi,2*i,pos);
            else
                solve2(li,vi,2*i+1,pos);
        }
    }
}

void solve(int i)
{
    for(int j=w; j>0; --j)
    {
        if(lt[a[j]].l==lt[a[j]].r && lt[a[j]].v!=0 && lt[a[j]].l+wi[i]<=w && lt[a[j]].flg!=i)
        {
            solve2(lt[a[j]].l+wi[i],lt[a[j]].v+v[i],1,i);
        }
    }
    solve2(wi[i],v[i],1,i);
}


int main()
{
    scanf("%d %d",&n,&w);
    for(int i=0; i<n; ++i)
        scanf("%d %lld",&wi[i],&v[i]);
    build();
     for(int i=0; i<n; ++i)
    solve(i);
    ll res=0;
    for(int i=w;i>0;--i){
        if(res<lt[a[i]].v)
            res=lt[a[i]].v;
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 8832
import sys
input = sys.stdin.readline


def main():
    H, W = map(int, input().split())
    A = []
    ans = []
    for h in range(H):
        a = list(map(int, input().split()))
        A.append(a)
    for y in range(H):
        for x in range(W):
            if A[y][x] % 2 == 1:
                if x <= W-2:
                    A[y][x] -= 1
                    A[y][x+1] += 1
                    ans.append((y+1, x+1, y+1, x+2))
                elif y <= H-2:
                    A[y][x] -= 1
                    A[y+1][x] += 1
                    ans.append((y+1, x+1, y+2, x+1))
    print(len(ans))
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75484
#include<cstdio>
#include<iostream>

using namespace std;


int main() {
  long long a, b, ab, cost;
  int x, y;


  cin >> a >> b >> ab >> x >> y;

  cost = 0;


  while (x > 0 || y > 0) {
    if (2 * ab < a + b && x > 0 && y > 0) {
      x -= 1;
      y -= 1;
      cost += 2 * ab;
    } else if (2 * ab < a && x > 0) {
      x -= 1;
      cost += 2 * ab;
    } else if (2 * ab < b && y > 0) {
      y -= 1;
      cost += 2 * ab;
    } else {
      if (x > 0) { 
        x -= 1;
        cost += a;
      }
      if (y > 0) { 
        y -= 1;
        cost += b;
      }
    }
  }

  cout << cost << endl;

}
  



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,x;
  cin >> n >> x;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n) x-=a.at(i);
  int ans = n;
  sort(ALL(a));
  ans+=x/a.at(0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 10

void DropInk(int, int);

int data[N][N];

int main(){
  int i, j, x, y, size, count=0, max=0;
  char c1, c2;

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      data[i][j] = 0;
    }
  }

  while(scanf("%d %c %d %c %d", &x, &c1, &y, &c2, &size) != EOF){
    if(size == 1){
      DropInk(y-1, x);
      DropInk(y, x-1);
      DropInk(y, x);
      DropInk(y, x+1);
      DropInk(y+1, x);
    }else if(size == 2){
      DropInk(y-1, x-1);
      DropInk(y-1, x);
      DropInk(y-1, x+1);
      DropInk(y, x-1);
      DropInk(y, x);
      DropInk(y, x+1);
      DropInk(y+1, x-1);
      DropInk(y+1, x);
      DropInk(y+1, x+1);
    }else if(size == 3){
      DropInk(y-2, x);
      DropInk(y-1, x-1);
      DropInk(y-1, x);
      DropInk(y-1, x+1);
      DropInk(y, x-2);
      DropInk(y, x-1);
      DropInk(y, x);
      DropInk(y, x+1);
      DropInk(y, x+2);
      DropInk(y+1, x-1);
      DropInk(y+1, x);
      DropInk(y+1, x+1);
      DropInk(y+2, x);
    }
  }

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(data[i][j] == 0)
         count++;
      else if(data[i][j] > max)
         max = data[i][j];
    }
  }

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

void DropInk(int i, int j){
  if(i>-1 && i<N && j>-1 && j<N)
    data[i][j]++;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long ll;
const int mod = 1000000007;
int md = 1000000007;

int prime[MAX];
unordered_map<int, int> max_map;

// Function to return a^n
int power(int a, int n)
{
	if (n == 0)
		return 1;
	int p = power(a, n / 2) % mod;
	p = (p * p) % mod;
	if (n & 1)
		p = (p * a) % mod;
	return p;
}

// Function to find the smallest prime factors
// of numbers upto MAX
void sieve()
{
	prime[0] = prime[1] = 1;
	for (int i = 2; i < MAX; i++) {
		if (prime[i] == 0) {
			for (int j = i * 2; j < MAX; j += i) {
				if (prime[j] == 0) {
					prime[j] = i;
				}
			}
			prime[i] = i;
		}
	}
}

// Function to return the LCM modulo M
ll lcmModuloM(const int* ar, int n)
{

	for (int i = 0; i < n; i++) {
		int num = ar[i];
		unordered_map<int, int> temp;

		// Temp stores mapping of prime factor to
		// its power for the current element
		while (num > 1) {

			// Factor is the smallest prime factor of num
			int factor = prime[num];

			// Increase count of factor in temp
			temp[factor]++;

			// Reduce num by its prime factor
			num /= factor;
		}

		for (auto it : temp) {

			// Store the highest power of every prime
			// found till now in a new map max_map
			max_map[it.first] = max(max_map[it.first], it.second);
		}
	}

	ll ans = 1;

	for (auto it : max_map) {

		// LCM is product of primes to their highest powers modulo M
		ans = (ans * power(it.F, it.S)) % mod;
	}

	return ans;
}

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(long long &a, long long b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (long long) ((long long) a * b % md);
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> n;
    int arr[n];
    for(i = 0; i < n; i++){
        cin >> arr[i];
    }
    sieve();
    l = lcmModuloM(arr,n);
    //cout << l;
    for(i = 0; i < n; i++){
        x = inv(arr[i]);
        y = mul(x,l);
        add(sum,y);
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 39808
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	n := nextInt()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = nextInt()
	}

	bs := make([]int, n)
	for i := 0; i < n; i++ {
		bs[i] = nextInt()
	}

	cs := make([]int, n-1)
	for i := 0; i < n-1; i++ {
		cs[i] = nextInt()
	}

	var score int
	before := -1
	for _, a := range as {
		score += bs[a-1]
		if before+1 == a {
			score += cs[before-1]
		}

		before = a
	}

	fmt.Println(score)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, res = 0; cin >> n;
	vector<int> h(n); rep(i, 0, n - 1)cin >> h[i];
	vector<int> a(n, 0);
	while (h != a)
	{
		rep(i, 0, n - 1)
		{
			if (h[i] > 0)
			{
				++res;
				--h[i];
				while (i + 1 < n && h[i + 1] > 0)
				{
					--h[i + 1];
					++i;
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
def f(a):
    q=a[:n];s=sum(q);heapify(q);yield s
    for e in a[n:2*n]:s+=e-heappushpop(q,e);yield s
from heapq import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),list(f([-e for e in a[::-1]]))[::-1]))))

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

bool compare(tuple<string, int, int> p, tuple<string, int, int> q)
{
  if (get<0>(p) != get<0>(q))
    return get<0>(p) < get<0>(q);
  else 
    return get<1>(p) > get<1>(q);
}

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

  vector<tuple<string, int, int>> v(N);
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    v.at(i) = make_tuple(s, p, i+1);
  }

  sort(v.begin(), v.end(), compare);

  for (int i = 0; i < N; i++) {
    //cout << get<0>(v.at(i)) << "," << get<1>(v.at(i)) << endl;
    cout << get<2>(v.at(i)) << endl;
  }
}
/*
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
*/


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

int main(){
    int N,M;
    cin>>N>>M;
    vector<string>A(N);
    vector<string>B(M);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    for(int i=0;i<M;i++){
        cin>>B.at(i);
    }
    bool ans=false;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i>=N-M+1 || j>=N-M+1)continue;
            bool flg=true;
            for(int k=0;k<M;k++){
                for(int l=0;l<M;l++){
                    if(A.at(i+k).at(j+l) != B.at(k).at(l))  flg=false;
                }
            }
            if(flg) ans=true;
        }
    }

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

Measured memory_bytes: 256
# 連鎖行列積 Matrix chain multiplication

n = int(input())
p = [-1 for i in range(n + 1)]
M = [[-1 for i in range(n + 1)] for i in range(n + 1)]

for i in range(1, n + 1):
    l, m = (int(i) for i in input().split())
    p[i - 1] = l
    p[i] = m

for i in range(1, n + 1):
    M[i][i] = 0

for l in range(2, n + 1):
    for i in range(1, n - l + 2):
        j = i + l - 1
        M[i][j] = 2000000000
        for k in range(i, j):
            M[i][j] = min(M[i][j], M[i][k] + M[k + 1][j] + p[i - 1] * p[k] * p[j])

print(M[1][n])



Measured memory_bytes: 5680
n = int(input())
a = list(map(int, input().split()))

ball = [0]*200001
for i in range(n):
    ball[a[i]] += 1

ans = 0
for i in range(1, 200001):
    ans += ball[i]*(ball[i]-1)//2

for i in range(n):
    now = a[i]
    ans -= ball[now]*(ball[now]-1)//2
    ans += (ball[now]-1)*(ball[now]-2)//2
    print(ans)
    ans += ball[now]*(ball[now]-1)//2
    ans -= (ball[now]-1)*(ball[now]-2)//2


Measured memory_bytes: 85196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=3e6+10;
const int mod7=1e9+7;
const ll mod=1000000000000000000;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    int n,m;
    read(n),read(m);
    ll ans=0;
    for(re int i=1,x;i<=m;i++) read(x),ans+=x;
    printf("%lld\n",ans<=n?n-ans:-1);
    return 0;
}

Measured memory_bytes: 3748
#include <cstdio>
#include <string>

using namespace std;

int main() {
    size_t n;
    scanf("%zu", &n);

    int score[2]={};
    for (size_t i=0; i<n; ++i) {
        char buf[1<<7];
        scanf("%s", buf);
        string s(buf);

        scanf("%s", buf);
        string t(buf);

        if (s != t) {
            score[s<t] += 3;
        } else {
            ++score[0];
            ++score[1];
        }
    }

    printf("%d %d\n", score[0], score[1]);
    return 0;
}

Measured memory_bytes: 2840
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int a, l;
    while(cin >> a >> l, a|l){
        int cnt = 0;
        map<int, int> m;
        m[a] = 0;
        while(true){
            cnt++;
            string t = to_string(a);
            while(t.size() < l) t += '0';
            sort(t.begin(), t.end(), greater<>());
            int ans = stoi(t);
            reverse(t.begin(), t.end());
            ans -= stoi(t);
            if(m.count(ans)){
                a = ans;
                break;
            }
            m[ans] = cnt;
            a = ans;
        }
        printf("%d %d %d\n", m[a], a, cnt-m[a]);
    }
    return 0;
}



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

using namespace std; 

int main()
{
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;
  if(s == u)
    a--;
  else b--;
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
long long int MOD=1000000007;
long long int fun(long long int a,long long int n)
{ long long int res=1;
  while(n)  
  { if(n%2==1)
   { res=(res*a) % MOD;
     n--; }
  a=(a*a) % MOD;
   n/=2;
  }
 return res;
}
int main()
{long long int N;
  cin>>N;
 long long int X=fun(10,N)-fun(9,N)-fun(9,N)+fun(8,N);
 X=X % MOD;
 X=(X+MOD) % MOD;
 cout<<X;
}

Measured memory_bytes: 3640
using System;
class Program{
	static void Main(){
		string r=Console.ReadLine();
		int A=int.Parse(r.Split(' ')[0]);
		int B=int.Parse(r.Split(' ')[1]);
		int X=int.Parse(r.Split(' ')[2]);
                for(bool f=true;X-->0;f=!f){
                    if(f){
                        B+=(A/=2);
                    }
                    else{
                         A+=(B/=2);
                    }
                }
		
		//出力
		Console.WriteLine(A.ToString()+" "+B.ToString());
	}
}

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    string s;
    cin >> s;
    int ans=100100100;
    for(int i=0;i<s.size()-2;i++){
        int num=stoi(s.substr(i,3));
        ans=min(ans,abs(753-num));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int A, B = 0;
	std::cin >> A >> B;

	int ans1 = A + B;
	int ans2 = A - B;
	int ans3 = A * B;

	if (ans1 > ans2)
	{
		if (ans1 > ans3)
		{
			std::cout << ans1 << "\n";
		}
		else
		{
			std::cout << ans3 << "\n";
		}
	}
	else if (ans2 > ans3)
	{
		std::cout << ans2 << "\n";
	}
	else
	{
		std::cout << ans3 << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#include <deque> 
#define DBL_MIN 0.000000000000001

#include <iostream>
using namespace std;


int main(void){
    long K,S;
    cin >> K >> S;

    int cnt = 0;
    for(int i =0; i <= K ;i++){
        for(int j = 0; j <=  (S- i) && j <= K ; j++){
            if( (S-i-j) <= K){
                //cout << i << ":" << j << ":" << (S-i-j) << endl;
                cnt++;
            }
        }   
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3616
def main():
    n, m, q = [int(i) for i in raw_input().strip().split()]
    f = [[0 for j in xrange(n)] for i in xrange(n)]
    for i in xrange(m):
        l, r = [int(i) - 1 for i in raw_input().strip().split()]
        f[l][r] += 1
    for d in xrange(1, n):
        for i in xrange(0, n - d):
            f[i][i + d] += f[i][i + d - 1] + f[i + 1][i + d] - f[i + 1][i + d - 1]
    for i in xrange(q):
        p, q = [int(i) - 1 for i in raw_input().strip().split()]
        print f[p][q]

if __name__ == '__main__':
    main()


Measured memory_bytes: 8196
from heapq import*
n,*a=map(int,open(0).read().split())
b=a[:n]
c=[-i for i in a[n:][::-1]]
d=c[:n]
e=c[n:]
heapify(b)
heapify(d)
s=sum(b)
t=sum(d)
red=[s]
blue=[t]
for i in range(n,n*2):
    s+=a[i]-heappushpop(b,a[i])
    t+=c[i]-heappushpop(d,c[i])
    red+=[s]
    blue+=[t]
print(max(map(sum,zip(red,blue[::-1]))))

#あｈｊｆｋぁｄｓｈｆｌｋじゃｇはｌｋｊｄｊｇｌｋ；あｊｄｇｌｋ；あｄｓｊｇｌ；あｊｓｄｇｌｋ；あｊｓｄｇｌ；かｓ

Measured memory_bytes: 38356
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x,y,z;
    bool operator<(const P &a)const{
        //if(y!=a.y) return y>a.y;
        return max(x,-x)>max(a.x,-a.x);

    }

};
vector<int> v[1];
//bitset<4001000> b;
int i,n,d,m,k,a,b,c,e;
long long o[111111][211];
int l[1111];
int j[1];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s,s1;

//priority_queue<int> q;
queue<int> q;
string r;
char r1[11],r2[11];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());
/*struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> p;//safe_map;
*/
bool as(P a,P b)
{
    //if(a.y!=b.y)
    //return a.y>b.y;
    return a.x<b.x;
}

long long f(int n,int m)
{
    if(m==0) return n;
    if(o[n][m]>=0) return o[n][m];
    long long x=0;
    x=((f(n,m-1))*(m-1)%mod+f(n%l[m],m-1))%mod;
    return o[n][m]=x;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();

int main()
{
    memset(o,-1,sizeof(o));
    scanf("%d %d",&a,&b);
    for(int t=1;t<=a;t++)
        scanf("%d",&l[t]);
    sort(l+1,l+1+a);
    printf("%lld",f(b,a));
}


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

using namespace std;

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

int main() {
    unsigned int n, m; cin >> n >> m;
    bitset<32> a(n), b(m);
    cout << (a & b) << endl;
    cout << (a | b) << endl;
    cout << (a ^ b) << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  ll n;
  cin>>n;
  ll a[n];
  ll b[n];
  rep(i,n){
    cin>>a[i];
    b[a[i]-1]=i+1;
  }
  rep(i,n){
      cout<<b[i]<<" ";
  }
  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define cinn(a) for(auto &_k:(a)) cin >> _k
#define coutt(a) for(auto _k:(a)) cout << _k << ' '
int main(){
    ll t(0), n, m; cin >> n >> m;
    priority_queue<int> pq;
    while(n--){
        int temp; cin >> temp; pq.push(temp);
    }
    while(m--){
        int temp; temp=pq.top() >> 1; pq.pop();
        pq.push(temp);
    }
    while(!pq.empty()){
        t+=pq.top();
        pq.pop();
    }cout << t;
    return 0;
}

Measured memory_bytes: 892
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nab = readln.split.to!(int[]);
    auto A = nab[1];
    auto B = nab[2];
    writeln(A%2 == B%2 ? "Alice" : "Borys");
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  
  int W,H,x,y,r,a=0,b=0;
  
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  
  if(x + r > W || x - r < 0) printf("No\n"); 
  else if(y + r > H || y - r < 0) printf("No\n"); 
  else printf("Yes\n");  
  return 0; 
}

Measured memory_bytes: 584
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

string s;
int segtree[500000*4+1][26],a[500001],fre[26],i;

void makeSegTree(int index,int start,int end)
{
	if(start==end)
	{
		segtree[index][a[start]]++;
		return;	
	}	
	
	int mid=(start+end)>>1;
	
	makeSegTree(index<<1,start,mid);
	makeSegTree(index<<1|1,mid+1,end);
	
	for(i=0;i<26;i++)
		segtree[index][i]=segtree[index<<1][i]+segtree[index<<1|1][i];
}

void update(int index,int start,int end,int i,int pos)
{
	if(start==end)
	{
		segtree[index][a[i]]--;
		a[i]=pos;
		segtree[index][a[i]]++;
		return;
	}
	
	int mid=(start+end)>>1;
	
	if(i<=mid)
		update(index<<1,start,mid,i,pos);
	else
		update(index<<1|1,mid+1,end,i,pos);
	
	for(i=0;i<26;i++)
		segtree[index][i]=segtree[index<<1][i]+segtree[index<<1|1][i];
}

void query(int index,int start,int end,int l,int r)
{
	if(start==l && end==r)
	{
		for(i=0;i<26;i++)
			fre[i]+=segtree[index][i];
		return;
	}
	
	int mid=(start+end)>>1;
	
	if(r<=mid)
		query(index<<1,start,mid,l,r);
	else if(l>=mid+1)
		query(index<<1|1,mid+1,end,l,r);
	else
	{
		query(index<<1,start,mid,l,mid);
		query(index<<1|1,mid+1,end,mid+1,r);
	}
}

int main()
{
	fastio;
	int n,i,j,q,l,r,type,ans;
	char ch;
	
	cin>>n>>s>>q;
	
	for(i=0;i<n;i++)
		a[i]=s[i]-'a';
	
	makeSegTree(1,0,n-1);
	
	while(q--)
	{
		cin>>type;
	
		if(type==1)
		{
			cin>>l>>ch;
			update(1,0,n-1,l-1,ch-'a');
		}
		else
		{
			cin>>l>>r;
			ans=0;
			memset(fre,0,sizeof(fre));
			query(1,0,n-1,l-1,r-1);
			for(i=0;i<26;i++)
				ans+=(0 || fre[i]);
			cout<<ans<<"\n";
		}
	}
	return 0;
}


Measured memory_bytes: 112352
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, m, x = map(int, input().split())
c_list = []
a_list = []
for i in range(0, n):
    y_list = list(map(int, input().split()))
    c_list.append(y_list[0])
    a_list.append(y_list[1:])
ans = []
for i in range(0, 2**n):
    cost = 0
    gaku = [0] * m
    for j in range(0, n):
        if ((i >> j) & 1):
            cost += c_list[j]
            for k in range(0, m):
                gaku[k] += a_list[j][k]
    if all([r >= x for r in gaku]):
        ans.append(cost)
if ans:
    print(min(ans))
else:
    print(-1)
    

Measured memory_bytes: 9252
#include <iostream>

using namespace std;
int main() {
    char S[101];
    cin >> S;
    for (int i=0; S[i] != 0; i++) {
        if (i%2 == 0) {
            if (S[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
  int n,i,j,mn,cnt=1,r;
  scanf("%d",&n);
  scanf("%d",&r);
  mn=r;
  for(i=2; i<=n; i++)
  {
    scanf("%d",&r);
    if(r<mn)
    {
      cnt++;
      mn=r;
    }
  }
  printf("%d\n", cnt);

  return 0;
}

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

using namespace std;

char m[110][110];
int h,w;

void dfs(int x,int y,char c){
  int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
  m[y][x] = 'f';
  for(int i = 0 ; i < 4 ; i ++){
    int nx = x + dx[i] , ny = y + dy[i];
    if(m[ny][nx] != c)continue;
    if(ny < 0 || nx < 0 || h <= ny || w <= nx)continue;
    dfs(nx,ny,c);
  }
  return;
}


int main(void){
  while(cin>>h>>w,h+w){
    for(int i = 0 ; i < h ; i ++){
      for(int j = 0 ;j  < w ; j ++){
        cin>>m[i][j];
      }
    }
    int ret = 0;
    for(int i = 0 ; i < h ; i ++){
      for(int j = 0 ;j  < w ; j ++){
        if(m[i][j] != 'f'){
          ret ++;
          //cout<<i<<" "<<j<<endl;
          dfs(j,i,m[i][j]);
          /*
          for(int k = 0 ; k < h ; k ++){
            for(int l = 0 ; l < w ; l ++){
              cout<<m[k][l];
            }
            cout<<endl;
          }
          cout<<endl;
          */
        }
      }
    }    
    cout<<ret<<endl;
  }
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
int A, B;
bool flag = true;
string a;
int main(){
	cin >> A >> B >> a;
	if(A + B + 1 != a.length())	flag = false;
	if(flag){
		for(int i = 0; i < A; i++){
			int x = (a[i] == '-' ? 10 : a[i] - '0');
			if(!(0 <= x && x <= 9))	flag = false;
		}
		if(a[A] != '-') flag = false;
		for(int i = A + 1; i < A + B + 1; i++){
			int x = (a[i] == '-' ? 10 : a[i] - '0');
			if(!(0 <= x && x <= 9)) flag = false;
		}
	}
	if(flag)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;

    while (s != "-")
    {
        int m;
        cin >> m;
        int h[m];
        for (int i = 0; i < m; i++)
        {
            cin >> h[i];
            s = s.substr(h[i]) + s.substr(0, h[i]);
        }

        cout << s << endl;
        cin >> s;
    }
    return 0;
}



Measured memory_bytes: 3140
N = int(input())
P = list(map(int, input().split()))

count = 0
for n, p in zip(range(1, N+1), P):
    if n != p:
        if count == 0:
            count += 1
            i = P.index(p)
            j = P.index(n)
            P[j] = P[i]
            P[i] = n
        else:
            print('NO')
            break
else:
    print('YES')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    string s,s2;
    cin >> s;
    for (ll i=2;i<s.size();++i){
        ll a=s.size()-i;
        if (a%2==0){
            if (s.substr(0,a/2)==s.substr(a/2,a/2)){
                cout << a << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
H,W = [int(i) for i in input().split()]
S = [[i for i in input().strip().split()] for j in range(H)]

for h in range(H):
  for w in range(W):
    if S[h][w] == 'snuke':
      ans = '{}{}'.format(chr(ord('A')+w), h+1)
      break
print(ans)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.readInt();
            int b = in.readInt();
            if (a > 8 || b > 8) out.println(":(");
            else out.println("Yay!");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 20692
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    int ans;
    if(N%K==0){
        ans = 0;
    }else{
        ans = 1;
    }

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

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int maxn = 1<<20, mod = 924844033;
ll c[maxn], r[maxn], n, m;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	ll s = 0;
	for(int i = 1; i <= n; i++) cin >> c[i], s += c[i];
	int x = -1;
	for(int i = 1; i < n; i++) if(c[i]+c[i+1] >= m) x = i;
	if(x == -1) return cout << "Impossible", 0;
	cout << "Possible\n";
	for(int i = 1; i < x; i++) cout << i << '\n';
	for(int i = n-1; i > x; i--) cout << i << '\n';
	cout << x << '\n';
}


Measured memory_bytes: 2944
n,x = map(int,input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
f = 0
for i in range(n):
    if x-a[i]>=0:
        ans+=1
        x-=a[i]
    else:
        f = 1
        break
if x>0 and f==0:
    ans-=1
print(ans)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**7)
input= lambda:sys.stdin.readline().rstrip()
N=int(input())
class BIT:
    # 1,,,,,,,Nまでの数値を扱える
    def __init__(self,n):
        self.n=n
        self.data=[0]*(n+1)
    def to_sum(self,i):
        # i番目のところまで要素を足し合わせる
        s=0     
        while i>0:
            s+=self.data[i]
            i-=(i& -i)
        return s
    def add(self,i,x):
        # i 番目のところに要素を足し合わせる
        while i<=self.n:
            self.data[i]+=x
            i+=(i & -i)
    def get(self,i,j):
        #i番目からj番目までの要素の合計値を数える
        return self.to_sum(j)-self.to_sum(i-1)
ans = 0

A=list(map(int,input().split()))
B=sorted(A)
how_big={B[i]:i+1 for i in range(N)}
tree = BIT(N+100)

for index, p in enumerate(A):
    tree.add(how_big[p], 1)
    #自分よりも左側にある（小さい）の数を求める。
    ans += index+1-tree.to_sum(how_big[p])
print(ans)


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int d;
	cin >> d;
	cout << "Christmas";
	FOR(i, d, 25)cout << " Eve";
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:i32 = read();
    let b:i32 = read();

    println!("{}", max(a+b, max(a+a-1,b+b-1)));
    
}


Measured memory_bytes: 4352