akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//here i1 is showing whether some digit is smaller or not encountered till date
//if smaller or equal digit then no restriction and if larger digit then smaller encountered should be true
int main()
{string s;
cin>>s;
int d;
cin>>d;
//cout<<s<<" s_d "<<d<<endl;
int mod=1e9+7;
int dp[d+1][2][s.length()+1];
for(int i=0;i<=d;i++)
{for(int j=0;j<=s.length();j++){
	dp[i][0][j]=0;
dp[i][1][j]=0;
}}
//cout<<dp[0][0][0]<<endl;
dp[0][0][0]=1;
//cout<<"pp "<<endl;
for(int k=1;k<=s.length();k++){

for(int i=0;i<d;i++)
{for(int j=0;j<=9;j++)
{//cout<<s[k]-'0'<<"pp "<<endl;
for(bool i1:{false,true})
{int x=s[k-1]-'0';
	if((j>(x)&&i1==true)||(j<=x)){
dp[(i+j)%d][i1||(j<x)][k]=(dp[(i+j)%d][i1||(j<x)][k]+dp[i][i1][k-1])%mod;
//cout<<dp[(i+j)%d][i1||(j<s[k]-'0')][k]<<" ll "<<endl;
		
	}
}}}}
int ans=(dp[0][false][s.length()]+dp[0][true][s.length()])%mod;
ans--;
if(ans<0)
ans+=mod;
cout<<(ans)<<endl;
return 0;}


Measured memory_bytes: 8192
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int Q,H,S,D,n;

int main()
{
	scanf("%d%d%d%d%d",&Q,&H,&S,&D,&n);
	if(2*Q<H)H=2*Q;
	if(2*H<S)S=2*H;
	if(2*S<D)D=2*S;
	printf("%lld\n",(long long)n/2*D+n%2*S);
}

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, A, B;
string S;
signed main() {
    cin >> N >> A >> B >> S;
    int kak = 0, kai = 0;
    rep(i, N) {
        if (S[i] == 'a') {
            if (kak < A + B) { kak++, cout << "Yes" << endl; }
            else { cout << "No" << endl; }
        } else if (S[i] == 'b') {
            if (kak < A + B && kai < B) { kak++, kai++, cout << "Yes" << endl; }
            else { cout << "No" << endl; }
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 896
using System;
using System.Linq;

namespace abc080_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] f = new int[n,10];
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < 10; j++) f[i,j] = x[j];
            }
            int[,] p = new int[n,11];
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < 11; j++) p[i,j] = x[j];
            }
            int ret = int.MinValue;
            for (int i = 1; i < Math.Pow(2,10); i++)
            {
                int choice = i;
                int[] store = new int[n];
                for (int j = 0; j < 10; j++)
                {
                    if (choice % 2 == 1)
                    {
                        for (int k = 0; k < n; k++)
                        {
                            if (f[k,j] == 1) store[k]++;
                        }
                    }
                    choice /= 2;
                }
                int now = 0;
                for (int j = 0; j < n; j++)
                {
                    now += p[j,store[j]];
                }
                ret = Math.Max(ret,now);
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13396
long long d[101][39];
v,i,j;
main(n){
	scanf("%d%d",&n,&v);
	d[0][9+v]=1;
	for(i=0;i<n-2;i++){
		scanf("%d",&v);
		for(j=0;j<=20;j++){
			d[i+1][9+j]=d[i][9+j-v]+d[i][9+j+v];
		}
	}
	scanf("%d",&v);
	v=!printf("%lld\n",d[i][9+v]);
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int a, b;
	cin >> a >> b;
	cout << max(max(a + b, a - b), a * b);
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3616
n=int(input())
C,S,F=[],[],[]
for i in range(n-1):
  c,s,f=map(int,input().split())
  C.append(c)
  S.append(s)
  F.append(f)
T=[0 for i in range(n)]
for i in range(n-1):
  t=S[i]+C[i]
  for j in range(i+1,n-1):
    if t<S[j]:
      t=S[j]
    else:
      t=S[j]+F[j]*((t-S[j]-1)//F[j]+1)
    t+=C[j]
  T[i]=t
print(*T,sep="\n")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N; cin >> N;
    set<int> coins;
    
    for (int i=0; pow(6,i)<=N; i++) coins.insert(pow(6,i));
    for (int i=0; pow(9,i)<=N; i++) coins.insert(pow(9,i));
    vector <int> dp(1001000,INF);
    
    dp[0]=0;
    rep(i,N+1){
        for (auto x:coins){
            if (i>=x) chmin(dp[i],dp[i-x]+1);
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 4096
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

out = 0
prev = -1
for i in range(n):
    out += b[a[i]-1]
    if prev+1 == a[i]:
        out+= c[a[i-1]-1]
    prev = a[i]
print(out)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007

int main(){
	string s;
	cin >> s;
	if(s.size()>9){
		cout << "NO" << endl;
		return 0;
	}
	int n = (int)s.size()-1;
	int x = 0;
	string s1 = "AKIHABARA";
	bool flag = 1;
	while(1){
		if(n>9){
			flag = 0;
			break;
		}
		if(s==s1){
			break;
		}
		if(x>n){
			if(x==8){
				break;
			}else{
				flag = 0;
				break;
			}
		}
		if(s[x]!=s1[x]){
			s.insert(s.begin()+x,'A');
			n++;
		}else{
			x++;
		}
	}
	if(flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

vector<int> ans;

bool check(vector<int> v) {
	int count = 0, no;

	for (int i = 0; i < 3; ++i)
		if (ans[v[i]] != 1) {
			no = v[i];
			++count;
		}

	if (count > 1) return false;
	else if (count == 0) { cout << "ERROR" << endl; return false; }
	else ans[no] = 0;

	return true;
}

vector<int> make_result(int a, int b, int c, int r) {
	vector<int> ret;

	ret.push_back(a);
	ret.push_back(b);
	ret.push_back(c);
	ret.push_back(r);

	return ret;
}

int main() {
	int a, b, c;
	while (cin >> a >> b >> c, a || b || c) {
		int n = a + b + c;
		int N; cin >> N;
		ans.erase( ans.begin(), ans.end() );

		for (int i = 0; i < n; ++i)
			ans.push_back(2);

		vector< vector<int> > results;
		for (int i = 0; i < N; ++i) {
			int r;
			cin >> a >> b >> c >> r;
			--a, --b, --c;

			if (r == 1)
				ans[a] = ans[b] = ans[c] = 1;

			else results.push_back( make_result(a, b, c, r) );
		}

		bool update = false;
		for (int i = 0; i < results.size(); ++i)
			if (update = check(results[i]))
				results.erase( results.begin()+i, results.begin()+i );


		for (int i = 0; i < n; ++i)
			cout << ans[i] << endl;
	}
}

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

int main(){
  int A,B;
  cin>>A>>B;
  if(A>B){
    int num=A-B;
    if(num%2==0){
      num /= 2;
      cout<<B+num<<endl;
    }
    else cout<<"IMPOSSIBLE\n";
  }
  else{
   	int num =B-A ;
    if(num%2==0){
      num/=2;
      cout<<A+num<<endl;
    }
    else cout<<"IMPOSSIBLE\n";
  }
    
 return 0; 
}

Measured memory_bytes: 256
N,K,Q = map(int,input().split())
mem = [0]*N
A_l = [int(input()) for i in range(Q)]
for x in A_l:
  mem[x-1]+=1
for i in mem:
  if K-(Q-i) > 0:
    print("Yes")
  else:
    print("No")
  

Measured memory_bytes: 13696
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
int hh[SIZE],ww[SIZE];
void solve() {
    int h,w,n;
    R(h,w,n);
    set<PII>AA;
    REP(i,n){
        int x,y;
        R(x,y);
        AA.insert(MP(x,y));
        hh[x]++;
        ww[y]++;
    }
    int ma_h=*max_element(hh,hh+h+1);
    int ma_w=*max_element(ww,ww+w+1);
    int an=ma_h+ma_w-1;
    VI hd,wd;
    FOR(i,1,h){
        if(hh[i]==ma_h)hd.PB(i);
    }
    FOR(i,1,w){
        if(ww[i]==ma_w)wd.PB(i);
    }
    for(int x:hd)for(int y:wd){
        if(!AA.count(MP(x,y))){
            W(an+1);
            return;
        }
    }
    W(an);
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


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

const int N = (int)1e5 + 7;

int n, a[N], c[2][N], id[2][N], len[2];

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        c[i & 1][x]++;
    }
    for(int i = 1; i <= 100000; i++) {
        id[0][i] = id[1][i] = i;
    }
    sort(id[0] + 1, id[0] + 1 + 100000, [&](int x, int y) {return c[0][x] > c[0][y];});
    sort(id[1] + 1, id[1] + 1 + 100000, [&](int x, int y) {return c[1][x] > c[1][y];});
    len[0] = 1;
    while(c[0][id[0][len[0]]]) len[0]++;
    len[1] = 1;
    while(c[1][id[1][len[1]]]) len[1]++;
    len[0]--; len[1]--;
    int ans = 0;
    if(id[0][1] != id[1][1]) ans = n - c[0][id[0][1]] - c[1][id[1][1]];
    else {
        if(len[0] == 1 && len[1] == 1) ans = n / 2;
        else if(len[1] == 1) {
            ans = n - c[0][id[0][1]] + c[1][id[1][2]];
        }
        else if(len[0] == 1) {
            ans = n - c[0][id[0][2]] + c[1][id[1][1]];
        }
        else {
            ans = n - max(c[0][id[0][1]] + c[1][id[1][2]], c[0][id[0][2]] + c[1][id[1][1]]);
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<ll,ll>;

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

int N;
ll A[100100], B[100100];
std::vector<P> v;
std::queue<ll> st;

int f(){
    ll rem = 0;
    int cnt = 0;

    for(auto &e : v){
        ll diff;
        int idx;

        std::tie(diff, idx) = e;

        if(diff > 0){
            st.emplace(diff);
        }else if(diff < 0){
            diff = -diff;

            while(rem < diff && !st.empty()){
                rem += st.front();
                cnt += 1;
                st.pop();
            }

            if(rem < diff){
                return -1;
            }

            rem -= diff;
            cnt += 1;
        }
    }

    return cnt;
}

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

    std::cin >> N;

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

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

    for(int i=0;i<N;++i){
        v.emplace_back(A[i] - B[i], i);
    }

    std::sort(v.rbegin(), v.rend());

    int res = f();
    std::cout << res << std::endl;
}


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

int main(){
	int a,b,k,s=0;
	cin>>a>>b>>k;
	for(int i=max(a,b);i>=1;i--){
		if(a%i==0&&b%i==0){
			s++;
			if(s==k){
				cout<<i;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
object Main {
  var mul_limit = 12000
  var depth_limit = 7
  def dfs(p: Int, q: Int, depth: Int, sub: Int, mul: Int): Int = {
    p match {
      case 0 => 1
      case _ =>
        var ret = 0
        for{
          i <- (sub to mul_limit).takeWhile(x =>
            mul * x <= mul_limit &&
            (depth_limit - depth) * q >= p * x)
          if p * i >= q
        } ret += dfs(p * i - q, q * i, depth + 1, i, mul * i)
        ret
    }
  }
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var p, q = sc.nextInt
    mul_limit = sc.nextInt
    depth_limit = sc.nextInt
    while(p != 0) {
      println(dfs(p, q, 0, 1, 1))
      p = sc.nextInt
      q = sc.nextInt
      mul_limit = sc.nextInt
      depth_limit = sc.nextInt
    }
  }
}

Measured memory_bytes: 260796
/*
        HELLO WORLD
        -----------
        SHUBHAM
        -----------
        :) CODING
*/
#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 ff                                         first
#define ss                                         second
#define pb                                         push_back
#define int                                        long long
#define mp                                         make_pair
#define pii                                        pair<int,int>
#define vi                                         vector<int>
#define mii                                        map<int,int>
#define umii                                       unordered_map<int,int>
#define pqb                                        priority_queue<int>
#define pqs                                        priority_queue<int,vi,greater<int>>
#define setbits(x)                                 __builtin_popcountll(x)
#define zerobits(x)                                 __builtin_ctzll(x)
#define mod                                        1000000007
#define inf                                        1e18
#define ps(x,y)                                    fixed<<setprecision(y)<<x
#define mk(arr,n,type)                             type *arr=new type[n]
#define test(t)                                    int t;cin>>t;while(t--)
#define rep(i,n)                                   for(int i=0;i<n;i++)
#define rep1(i,n)                                  for(int i=1;i<=n;i++)
#define fio                                        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SIZE                                       1000001
#define all(x)                                     (x).begin(),(x).end()
#define sclk()                                     auto start_time = Clock::now()
#define eclk()                                     auto end_time = Clock::now();  cout << "\nTime Taken : " << chrono::duration_cast<chrono::milliseconds>(end_time    - start_time).count() << " ms"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef std::chrono::high_resolution_clock Clock;

int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}

void f_io()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif // ONLINE_JUDGE
}
int dp[100000];
int arr[100000];
int n,k;
int solve()
{
  dp[0]=0;
  for(int i=1;i<n;i++)
    {
        dp[i]=inf;
        for(int j=1;(j<=k && i-j >=0);j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
  return dp[n-1];
}
int32_t main()
{
   cin>>n>>k;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  cout<<solve();
    return 0;
}


Measured memory_bytes: 1792
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func newGraph(nNodes int) *Graph {
	g := Graph{}
	g.nodes = make([]*GraphNode, nNodes)
	for iNode := 0; iNode < len(g.nodes); iNode++ {
		g.nodes[iNode] = &GraphNode{}
		g.nodes[iNode].key = GraphNodeKey(iNode)
	}
	return &g
}

var infty = 1000000000

type GraphNodeKey int

// GraphNode is a node for undirected graph
type GraphNode struct {
	key       GraphNodeKey
	adjacents []*GraphNode
	visited   bool
	d, f      int
	parent    *GraphNode
	cc        int
}

func (g *Graph) setAdjacent(l, r GraphNodeKey) {
	g.nodes[l].adjacents = append(g.nodes[l].adjacents, g.nodes[r])
}

// Graph is a undirected graph
type Graph struct {
	nodes []*GraphNode
}

func (g *Graph) initialize() {
	for iNode := 0; iNode < len(g.nodes); iNode++ {
		g.nodes[iNode].visited = false
		g.nodes[iNode].d = infty
		g.nodes[iNode].f = infty
		g.nodes[iNode].parent = nil
		g.nodes[iNode].cc = -1 // 22.3-12
	}
}

type QueueEntry struct {
	node *GraphNode
	next *QueueEntry
}

type Queue struct {
	head, tail *QueueEntry
}

func (q *Queue) enqueue(node *GraphNode) {
	entry := QueueEntry{}
	entry.node = node

	if q.tail == nil {
		q.head = &entry
		q.tail = &entry
		return
	}

	q.tail.next = &entry
	q.tail = q.tail.next
}

func (q *Queue) dequeue() *QueueEntry {
	if q.head == nil {
		return nil
	}
	poped := q.head
	q.head = q.head.next
	if q.head == nil {
		q.tail = nil
	}
	return poped
}

func (q *Queue) isEmpty() bool {
	return q.head == nil
}

var time = 0

func fillDistancesByDepthFirstSearch(g *Graph) {
	g.initialize()
	time = 0
	cc := 0

	for _, u := range g.nodes {
		if !u.visited {
			dfsVisit(g, u, cc)
			cc++
		}
	}
}

func dfsVisit(g *Graph, u *GraphNode, cc int) {
	time++
	u.d = time
	u.cc = cc

	u.visited = true
	for _, v := range u.adjacents {
		if !v.visited {
			v.parent = u
			dfsVisit(g, v, cc)
		}
	}
	time++
	u.f = time
}

func main() {
	scanner.Split(bufio.ScanWords)

	nUsers := nextInt()
	nEdges := nextInt()
	graph := newGraph(nUsers)
	for iEdge := 0; iEdge < nEdges; iEdge++ {
		l := GraphNodeKey(nextInt())
		r := GraphNodeKey(nextInt())
		graph.setAdjacent(l, r)
		graph.setAdjacent(r, l)
	}

	fillDistancesByDepthFirstSearch(graph)

	nQueries := nextInt()
	for iQuery := 0; iQuery < nQueries; iQuery++ {
		l := GraphNodeKey(nextInt())
		r := GraphNodeKey(nextInt())

		// fmt.Println(graph.nodes[l].d, graph.nodes[r].d, graph.nodes[r].f, graph.nodes[l].f)
		if graph.nodes[l].cc == graph.nodes[r].cc {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}



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

int main(){

    int N, T, A, H[1000];
    cin >> N;
    cin >> T >> A;
    for( int i = 0; i < N; i++ ) cin >> H[i];


    int num;
    double diff = 10000.;

    for( int i = 0; i < N; i++ ){
        double temp = T - H[i] * 0.006;
        if( diff > abs( temp - A ) ){
            diff = abs( temp - A );
            num = i+1;
        }
    }
    
    cout << num << endl;

    return 0;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <unordered_map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define FAST cin.tie(0);ios::sync_with_stdio(false)

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

map<LLONG, LLONG> num2MinCostMap;
LLONG costs[3];
LLONG ks[3];
LLONG N, D;

const LLONG DFS(const LLONG n)
{
    if (num2MinCostMap.count(n)) return num2MinCostMap[n];
    LLONG minCost = log10(n) * log10(D) < 18.0 ? n * D : 9e18;
    for (int i = 0; i < 3; ++i)
    {
        LLONG k = ks[i];
        LLONG lower = n / k;
        LLONG upper = lower + 1;
        minCost = min(minCost,
            min(DFS(lower) + costs[i] + (n - lower * k) * D,
            DFS(upper) + costs[i] + (upper * k - n) * D));
    }
    return num2MinCostMap[n] = minCost;
}

void Solve()
{
    cin >> N >> costs[0] >> costs[1] >> costs[2] >> D;
    num2MinCostMap.clear();
    num2MinCostMap[0] = 0;
    num2MinCostMap[1] = D;
    num2MinCostMap[2] = min(D * 2, D + costs[0]);
    ks[0] = 2, ks[1] = 3, ks[2] = 5;
    cout << DFS(N) << endl;
}

int main()
{
    FAST;
    int T; cin >> T;
    for (int i = 0; i < T; ++i)
    {
        Solve();
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  for (int i = 0; i < N; i++) {
    num.at(i) = i + 1;
  }
  int ans;
  bool flag = true;
  if (N == 1) {
    ans = 1;
    flag = false;
  }
  while (flag) {
    flag = false;
    for (int i = 0; i <N; i++) {
      if (num.at(i) == 0) {
        continue;
      }
      else if (num.at(i) % 2 == 0) {
        num.at(i) /= 2;
        ans = i + 1;
        flag = true;
      }
      else {
        num.at(i) = 0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

pair<int, int> calc_mn_total(string& s){
    int mn = 0, total = 0;
    int sz = s.length();
    for (int i = 0; i < sz; ++i){
        if (s[i] == '(')
            ++total;
        else{
            --total;
            mn = min(mn, total);
        }
    }
    return pair<int, int>(mn, total);
}

int main(){
    int N; cin >> N;
    vector<pair<int, int>> s(N);
    for (int i = 0; i < N; ++i){
        string si; cin >> si;
        s[i] = calc_mn_total(si);
    }

    vector<pair<int, int>> zero_pos, neg;
    for (auto& p : s){
        if (p.second > 0) zero_pos.push_back(p);
        else neg.push_back(p);
    }

    sort(
        zero_pos.begin(), zero_pos.end(),
        [&](auto p1, auto p2){
            return p1.first > p2.first;
        }
    );
    int now = 0;
    for (auto p : zero_pos){
        if (now + p.first < 0){
            cout << "No" << endl;
            return 0;
        }
        now += p.second;
    }

    sort(
        neg.begin(), neg.end(),
        [&](auto p1, auto p2){
            return (p1.second - p1.first) > (p2.second - p2.first);
        }
    );
    for (auto p : neg){
        if (now + p.first < 0){
            cout << "No" << endl;
            return 0;
        }
        now += p.second;
    }

    string res = (now == 0) ? "Yes" : "No";
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 19164
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(), (a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//
int main() {
	int N;
	cin >> N;
	Vec< string > S(N);
	Vec< int > P(N);
	for_(i,0,N) cin >> S[i] >> P[i];
	Vec< int > id(N);
	iota(allof(id), 0);
	sort(allof(id), [&](int i, int j) { return S[i] < S[j] ? true : (S[i] > S[j] ? false : P[i] > P[j]); });
	for_(i,0,N) cout << id[i] + 1 << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	int a[n], b[n];
	int maxa = -1, ansb = -1;
	REP(i, n){
		cin >> a[i] >> b[i];
		if (a[i] > maxa){
			maxa = a[i];
			ansb = b[i];
		}
	}

	cout << maxa + ansb << endl;

}


Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

data class ModInt(var value: Long) {
    init {
        assert(value in 0 until MOD)
    }

    override fun toString(): String = value.toString()

    operator fun plusAssign(b: Long) {
        this.value += b
        this.value %= MOD
    }

    operator fun plusAssign(b: ModInt) {
        this.value += b.value
        this.value %= MOD
    }

    companion object {
        const val MOD = 1000000007L
    }
}


object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toLong()
        val K = sc.next().toLong()
        val ans = ModInt(0L)
        for (k in K..(N + 1)) {
            // 0 + 1 + 2 + 3 + ...
            val a = (k - 1) * k / 2
            val b = k * N - a * 2 + 1
            ans += b
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 36460
x1, y1, x2, y2 = map(int, input().split())
xdiff = x2-x1
ydiff = y2-y1
y3 = y2 + xdiff
x3 = x2 - ydiff
y4 = y1 + xdiff
x4 = x1 - ydiff
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	if((b - a) % 2 == 1){
		cout << "Borys" << endl;
	}else{
		cout << "Alice" << endl;
	}
}


Measured memory_bytes: 256
/*
* @Author: 王文宇
* @Date:   2017-11-19 02:23:09
* @Last Modified by:   王文宇
* @Last Modified time: 2017-11-19 02:30:34
*/
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	char a[4],b[4];
	cin>>a>>b;
	if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int n=sc.nextInt();
		int[] a=new int[n];
		int[] b=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		long[][] dp=new long[n+1][h+10000];
		Arrays.fill(dp[0],100000001);
		dp[0][0]=0;
		for(int i=1; i<=n; i++){
			for(int j=0; j<h+10000; j++){
				if(j>=a[i-1] && dp[i][j-a[i-1]]!=100000001){
					dp[i][j]=Math.min(dp[i-1][j],dp[i][j-a[i-1]]+b[i-1]);
				}else{
					dp[i][j]=dp[i-1][j];
				}
			}
		}
		long ans=100000001;
		for(int i=h; i<h+10000; i++){
			ans=Math.min(ans,dp[n][i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 243020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S; string T;
  cin>>S>>T;
  int A; int B;
  cin>>A>>B;
  string U; cin>>U;
  if(U==S)
    A--;
  else if(U==T)
    B--;
  cout<<A<<" "<<B<<endl;
}

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

int main() {
	long long a,b,k,an;
	cin>>a>>b>>k;
	an = a-k; 
	a = a-k;
	if(an>0)
	an=0;
	if(an<0)
	an = -1*an;
	b = b-an;
	if(a<0)
	cout<<"0"<<" ";
	else
	cout<<a<<" ";
	if(b<0)
	cout<<"0";
	else 
	cout<<b;
	
	return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c,d,sum1,sum2;
	cin>>a>>b>>c>>d;
	sum2=b;
	sum2-=b/c;
	sum2-=b/d;
	sum2+=b/(c*d/__gcd(c,d));
	a--;
	sum1=a;
	sum1-=a/c;
	sum1-=a/d;
	sum1+=a/(c*d/__gcd(c,d));
	cout<<sum2-sum1<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		if ((Math.abs(b - a) <= d && Math.abs(c - b) <= d) || Math.abs(c - a) <= d) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define UNIQUE(v) do{ (v).erase( unique(begin(v), end(v)), end(v) ); } while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	ll ans = 0;
	for (int b = K + 1; b <= N; b++) {
		ll p = N / b;
		ll q = N % b;
		ans += p * (b - K);
		if (K == 0) ans--;
		if (q >= K) ans += q - K + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#[allow(dead_code)] 
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    
    let div = v[1] / v[0];
    if div > v[2] {
        println!("{}", v[2]);
    }else{
        println!("{}", div);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
    
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n) {
        if(s[i] == '7') {
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;

 return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;

int main(){
	cin >> n;
	ll T, A;
	REP(i, n){
		ll a, b;
		cin >> a >> b;
		if (i == 0){
			T = a;
			A = b;
		}
		else{
			ll num1, num2;
			if (T > a || A > b){
				if ((T - a) % a == 0)num1 = (T - a) / a;
				else num1 = (T - a) / a + 1;
				if ((A - b) % b == 0)num2 = (A - b) / b;
				else num2 = (A - b) / b + 1;
				ll num = max(num1, num2);
				T = a*(num + 1);
				A = b*(num + 1);
			}
			else{
				T = a;
				A = b;
			}
		}
		//cout << T << " " << A << endl;
	}
	cout << T + A << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>


using namespace std;

int main(){

    int N;
    int x[100000];
    int y[100000];
    int t[100000];

    cin >> N;

    for(int i = 0;i < N;i++){
    	cin >> t[i] >> x[i] >> y[i];
    }

    int nx = 0,ny = 0,nt = 0;

    for(int i = 0;i < N;i++){
    	int dx = abs(nx-x[i]);
    	int dy = abs(ny-y[i]);
    	int dt = abs(nt-t[i]);
    	int te = dt - dx - dy;
    	if(te < 0 || te%2 == 1){
    		cout << "No" << endl;
    		return 0;
    	}
    	nx = x[i];
    	ny = y[i];
    	nt = t[i];
    }


    cout << "Yes" << endl;

	return 0;

}


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

int main()
{
  int N;
  cin >> N;
  vector< int > L(N + N);
  for(int i = 0; i < 2 * N; i++) {
    cin >> L[i];
  }
  sort(begin(L), end(L));
  int ret = 0;
  for(int i = 0; i < 2 * N; i += 2) {
    ret += L[i];
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> P;

int n;
int a[1 << 18];
int b[1 << 18];	//b[k] = (i or j) ⊆ kを満たす(i, j)におけるa[i] + a[j]の最大値 (k > 0)
P c[1 << 18];	//c[k] = i ⊆ kを満たすiにおけるa[i]のTop 2のindex

int main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < (1 << n); i++) cin >> a[i];
	
	c[0] = P(0, -1);
	for (i = 1; i < (1 << n); i++) {
		vector<P> vec;	//(val, pos);
		vec.push_back(P(a[i], i));
		for (j = 0; j < n; j++) {
			if ((i >> j) & 1) {
				int id1 = c[i - (1 << j)].first;
				int id2 = c[i - (1 << j)].second;
				if (id1 >= 0) vec.push_back(P(a[id1], id1));
				if (id2 >= 0) vec.push_back(P(a[id2], id2));
			}
		}
		sort(vec.begin(), vec.end(), greater<P>());
		vec.erase(unique(vec.begin(), vec.end()), vec.end());
		c[i] = P(vec[0].second, vec[1].second);
	}
	
	for (i = 1; i < (1 << n); i++) b[i] = a[c[i].first] + a[c[i].second];
	
	int ans = 0;
	for (i = 1; i < (1 << n); i++) {
		ans = max(ans, b[i]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 7168
#include <stdio.h>
int main()
{
	int i, R = 0, N, ans = 0;
	char WR[200000];
	scanf("%d", &N);
	WR[N + 1] = '\0';
	for (i = 0; i <= N; i++) {
		scanf("%c", &WR[i]);
	}
	for (i = 0; i <= N; i++) {
		if (WR[i] == 'R') {
			R++;
		}
	}
	for (i = 0; i <= R; i++) {
		if (WR[i] == 'W') {
			ans++;
		}	
	}
	printf("%d", ans);
}

Measured memory_bytes: 1928
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }


void solve() {
    auto a = reads();
    writeln(abs(a[0] - a[1]) > 1 ? ":(" : "Yay!");
}

void main() {
    solve();
    readln;
}

Measured memory_bytes: 256
def judge(L):
    cnt_plus = 0
    cnt_minus = 0
    for l in L:
        if l >= 0:
            cnt_plus += 1
        else:
            cnt_minus += 1

    if cnt_plus == len(L):
        return 1
    elif cnt_minus == len(L):
        return -1
    else:
        return 0


def solve():
    N = int(input())
    A = list(map(int, input().split(" ")))

    if judge(A) == 1:
        print(N - 1)
        for i in range(1, N):
            print(i, i + 1)
    elif judge(A) == -1:
        print(N - 1)
        for i in range(N, 1, -1):
            print(i, i - 1)
    elif judge(A) == 0:
        print(2 * N - 1)
        MAX = max(A)
        MAX_INDEX = A.index(MAX) + 1
        MIN = min(A)
        MIN_INDEX = A.index(MIN) + 1
        if abs(MAX) >= abs(MIN):
            for i in range(1, N + 1):
                print(MAX_INDEX, i)
            for i in range(1, N):
                print(i, i + 1)
        elif abs(MAX) < abs(MIN):
            for i in range(1, N + 1):
                print(MIN_INDEX, i)
            for i in range(N, 1, -1):
                print(i, i - 1)


solve()

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

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

using namespace std;

void dump(vector<string> f, int x = -1, int y = -1) {
    REP(i, f.size()) {
        REP(j, f[i].size()) {
            if ( i == y && j == x )
                cout << "#";
            else
                cout << f[i][j];
        }
        cout << endl;
    }
}

/*
0:上
1:右
2:下
3:左
*/
int mx[] = {0, 1, 0, -1},
    my[] = {-1, 0, 1, 0};

vector< vector<int> > closed;

void go(vector<string> &f, int x, int y) {
    // dump(f, x, y);
    // cout << endl;

    int mv;
    if ( closed[y][x] ) {
        cout << "LOOP" << endl;
        return;
    }
    closed[y][x] = 1;

    switch(f[y][x]) {
        case '.':
            cout << x << " " << y << endl;
            return;
        case '^':
            mv = 0;
            break;
        case '>':
            mv = 1;
            break;
        case 'v':
            mv = 2;
            break;
        case '<':
            mv = 3;
            break;
    }
    go(f, x+mx[mv], y+my[mv]);
}

int main() {
    int w, h;

    while( cin >> h >> w, w || h ) {
        vector<string> f(h);
        closed = vector< vector<int> >(h, vector<int>(w, 0));

        REP(i, h) {
            REP(j, w) {
                closed[i][j] = 0;
            }
        }

        REP(i, h) {
            cin >> f[i];
        }

        go(f, 0, 0);
    }

    return 0;
}

Measured memory_bytes: 1324
#include <iostream>
#include <vector>
#include <map>
 
using namespace std;
 

map<pair<int, int>, int> bk;
long long H, W, N;

void inc_square(int h, int w){
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if((h-i >= 1) & (w-j >= 1) & (h-i <= H-2) & (w-j <= W-2)){
                bk[make_pair(h-i, w-j)]++;
            }
        }
    }
  }

int main(void){
    long long tmp, tmp2;

    cin >> H >> W >> N;

    for(int i=0;i<N;i++){
        cin >> tmp >> tmp2;
        inc_square(tmp, tmp2);   
    }
    
    long long ans[10] = {};

    /*for(map<pair<int, int>, int>::iterator it=bk.begin();it!=bk.end();it++){*/
    for(auto it=bk.begin();it!=bk.end();it++){
        ans[it->second]++;
    }

    ans[0] = (H -2) * (W - 2) - bk.size();
    for(int i=0;i<10;i++){
        cout << ans[i] << endl;
    }
    return 0;
 }


Measured memory_bytes: 56448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll h;
ll num[11][6];

int main() {
	while (cin >> h&&h) {
		ll ans = 0;
		rep(i, h) {
			rep(j, 5)cin >> num[i][j];
		}
		bool f = 1;
		int cnt = 0;
		while (f) {
			f = 0;
			rep(i, h) {
				ll add = 0;
				ll lb = -1, ub = -1;
				rep(j, 3) {
					FOR(k, j + 2, 5) {
						FOR(l, j, k + 1) {
							if (num[i][j] != num[i][l])break;
							if (l == k) {
								if (add < num[i][j] * (k - j + 1)) {
									add = num[i][j] * (k - j + 1);
									lb = j, ub = k;
									f = 1;
								}
							}
						}
					}
				}
				ans += add;
				if (add != 0) {
					FOR(j, lb, ub + 1) {
						num[i][j] = -1;
					}
				}
			}
			//rep(i, h) {
			//	rep(j, 5)cout << num[i][j] << " ";
			//	cout << endl;
			//}
			//cout << endl;
			rep(j, 5) {
				vector<ll> n;
				rep(i, h) {
					if (num[i][j] != -1)n.push_back(num[i][j]);
				}
				rep(i, h - n.size())num[i][j] = -1;
				rep(i, n.size())num[h - n.size() + i][j] = n[i];
			}
			//rep(i, h) {
			//	rep(j, 5)cout << num[i][j] << " ";
			//	cout << endl;
			//}
			//cout << endl;
			//if (cnt == 2)break;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3120
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, x, num ;
	cin >> n >> x;
	num = n;
	vector<int> m(n);
	for(int i = 0; i < n; i++) {
		cin >> m.at(i);
		x -= m.at(i);
	}
	int min=m.at(0);
	for (int i = 1; i < n; i++) {
		if (min > m.at(i))min = m.at(i);
	}
	while (x >= 0) {
		x -= min;
		if (x < 0) break;
		num++;
	}
	cout << num;


}

Measured memory_bytes: 3632
import math
a,b = map(int, input().split())

mina = a*12.5
maxa = (a+1)*12.5
minb = b*10
maxb = (b+1)*10

def calc_price(mina,maxa,minb,maxb):
    if mina >= maxb or minb >= maxa:
        return -1
    else:
        price = max(mina, minb)
        return math.ceil(price)

print(calc_price(mina,maxa,minb,maxb))

Measured memory_bytes: 3064