akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

#include <bits/stdc++.h>
using namespace std;

string to_string(string s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

ll N, ans = infll, sum;

int main()
{
    cin >> N;
    vector<ll> A(N + 2), cnt;
    A[0] = 0;
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
        sum += abs(A[i] - A[i -1]);
    }
    sum += abs(A[N + 1] - A[N]);
    A[N + 1] = 0;
    cnt.push_back(A[0]);
    for (int i = 1; i <= N; i++)
    {
        cout << sum - abs(A[i - 1] - A[i]) - abs(A[i + 1] - A[i]) + abs(A[i - 1] - A[i + 1]) << endl;
    }
}

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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0;i<N;i++) {
        int l,r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		scan.close();
		if(A <= 8 && B <= 8) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include<string>

using namespace std;

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	int a;
	vector<int> points(n, 0);
	for (int i = 0; i < q; i++) {
		cin >> a;
		points[a-1]++;
	}
	for (int i = 0; i < n; i++) {
		if (q - points[i] >= k) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

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

  ld h, w;
  cin >> h >> w;

  if (h == 1 || w == 1) {
    cout << 1;
    return 0;
  }

  cout << fixed << (ll)ceill((ld)h * w / 2);
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890l
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing if(db)cout << " ";
#define space " "
#define cbr cout << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, m;
int main()
{
	cin >> n >> m;
	if(m%n == 0) cout << n+m <<'\n';
	else cout << m-n << '\n';
} 


Measured memory_bytes: 256
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1e15+7;
const ll mod = 1e9 + 7;
const int MAX_N = 1e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<vector<int>> kake(vector<vector<int>> &tim1,vector<vector<int>> &tim2) {
	vector<vector<int>> res = vector<vector<int>>(tim1.size(),vector<int>(tim1[0].size(),0));
	REP (i,tim1.size()) {
		REP (j,tim1[0].size()) {
			REP (k,tim2[0].size()) {
				res[i][k] += tim1[i][j] * tim2[j][k];
				res[i][k] %= mod;
			}
		}
	}
	return res;
}

signed main() {
	int h,w,n;
	cin >> h >> w >> n;
	int r,c;
	cin >> r >> c;
	int dl,dr,du,dd;
	dl = c - 1;
	dr = w - c;
	du = r - 1;
	dd = h - r;
	string s,t;
	cin >> s >> t;
	int L=0,R=0,U=0,D=0;
	REP (i,n) {
		if (s[i] == 'L') L++;
		if (s[i] == 'R') R++;
		if (s[i] == 'U') U++;
		if (s[i] == 'D') D++;
		if (L > dl || R > dr || U > du || D > dd) {
			cout << "NO" << endl;
			return 0;
		}
		if (t[i] == 'L') {
			if (R > 0 || -R < dl) R--;
		}
		if (t[i] == 'R') {
			if (L > 0 || -L < dr) L--;
		}
		if (t[i] == 'U') {
			if (D > 0 || -D < du) D--;
		}
		if (t[i] == 'D') {
			if (U > 0 || -U < dd) U--;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 776
using System;

class Program
{
  static void Main(string[] args)
  {
          // スペース区切りの整数の入力
          string[] input = Console.ReadLine().Split(' ');
          int a = int.Parse(input[0]);
          int b = int.Parse(input[1]);
          int c = int.Parse(input[2]);

    int ans = 3;
    if (a == b) ans--;
    if (a == c || b == c) ans--;

          //出力
          Console.WriteLine(ans);
  }
}

Measured memory_bytes: 2648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
using namespace std;

#define ll long long int
const int MOD = 1000000007;//10^9+7

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

int min(int a, int b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

int avd_i(int a, int b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll calc(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = calc(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*calc(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = calc(b, p - 2, p);
	c = calc(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

int main() {

	string S;

	cin >> S;

	for (int i = 0; i < S.size(); i += 2) {

		cout << S[i];

	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 512
import sys
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
connections = []
for i in range(1, m+1):
    connection = [0] * n
    _, *S = map(int, inputs[i].split())
    for s in S:
        connection[s-1] = 1
    connections.append(connection)
*P, = map(int, inputs[i+1].split())

patterns = []
for i in range(2 ** n):
    pattern = [(i >> j) & 1 for j in range(n)]
    on_switches = [sum(c and p for c, p in zip(connection, pattern)) for connection in connections]
    if all(p == s%2 for p, s in zip(P, on_switches)):
        patterns.append(pattern)
print(len(patterns))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main() {
  int N; cin >> N;
  vector<long long> A(N);
  int sgn = 0;
  for(int i=0; i < N; ++i){
    cin >> A[i];
    if(A[i] < 0){
      sgn += 1;
    }
  }
  long long ans = 0;
  long long min_num = abs(A[0]);
  for(int i=0; i < N; ++i){
    ans += abs(A[i]);
    if(abs(A[i]) < min_num){
      min_num = abs(A[i]);
    }
  }
  if(sgn%2 != 0){
    ans -= 2 * min_num;
  }
  cout << ans << endl;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(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 EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

string day[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main() {
	string s;
	cin >> s;
	int i = find(day, day+7, s) - day;
	cout << 7 - i << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define ARRAY_MAX 100005
#define MOD 1000000007

/*mod Mでの割り算は割る数aのM-2をかける*/
/*ここではaのb乗をpで割った余りを返す*/
ll calc(ll a,ll b,ll p){

   if(b == 0){
       return 1;
   }else if(b % 2 == 0){
       ll tmp = (calc(a,b/2,p)) % p;
       return ((tmp%p)*(tmp%p))%p;
   }else{
       return ((a%p)*(calc(a,b-1,p)%p)) % p;
   }
}


/*nCrの計算*/
ll nCr(ll n,ll r){

    if(n < r){
        return 0;
    }else if(n == r || r == 0){
        return 1;
    }else{
        ll total = n,under1 = n-r,under2 = r;
        /*n!を求める*/
        for(ll i = n-1; i > 0;i--){
            total *= i;
            total %= MOD;
        }
        /*(n-r)!を求める*/
        for(ll i = n-r-1; i > 0;i--){
            under1 *= i;
            under1 %= MOD;
        }
        /*r!を求める*/
        for(ll i = r-1; i > 0;i--){
            under2 *= i;
            under2 %= MOD;
        }
        /*(n-r)! * r!を求める*/
        ll under = (under1*under2) % MOD;
        return ((total % MOD) * calc(under,MOD-2,MOD)) % MOD;
    }
}



int main(){

    ll n,p;
    cin >> n >> p;
    vector<ll> a(n);
    ll even = 0,odd = 0;
    REP(i,n){
        cin >> a[i];
        if(a[i]%2 == 0){
            even++;
        }else{
            odd++;
        }
    }

    ll ans = 0;
    ll odd_sum = 0;
    if(p == 1){
        //余りが1
        for(int i = 1;i <= odd;i += 2){
            //奇数は奇数個選ぶ
            odd_sum += nCr(odd,i);
        }
        ans = (ll)pow(2,even)*odd_sum;
    }else{
        //余りが0
        for(int i = 0;i <= odd;i += 2){
            odd_sum += nCr(odd,i);
        }
        ans = (ll)pow(2,even)*odd_sum;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  vector<int> group(12);
  group = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if (group.at(x - 1) == group.at(y - 1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int n;
vector<pair<int, int>> p;
pair<int, int> P;
ll t = 0, a = 0;

int main() {

	int a, b;
	cin >> a >> b;
	cout << a + (b / 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
int main()
{
    ll t,n,k,p,q,r,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    map<ll,ll>mp;
    vector<ll>v;
      cin>>s;
      p=s.size();
    for(ll i=0;i<p;i++)
    {
        if(s[i]=='?') s[i]='D';
    }
    cout<<s<<endl;

}






Measured memory_bytes: 3760
class SegmentTree:
    def __init__(self, initial_values, f=max, zero=0, converter=lambda x:x):
        self.__f, self.__z, self.__c, self.__size = f, zero, converter, len(initial_values)
        self.__n = 1 << ((self.__size - 1).bit_length())
        self.__dat = [zero] * (2 * self.__n)
        zi = self.__get_leaf(0)
        for i, v in enumerate(initial_values): self.__dat[zi + i] = converter(v)
        for i in range(zi-1, -1, -1): self.__dat[i] = f(*self.__get_children(i))
    
    def update(self, index, value):
        i, v = self.__get_leaf(index), self.__c(value)
        if self.__dat[i] == v: return
        self.__dat[i] = v
        while i:
            i = self.__get_parent(i)
            self.__dat[i] = self.__f(*self.__get_children(i))
    
    def query(self, from_inclusive, to_exclusive):
        ans = self.__z
        if to_exclusive <= from_inclusive: return ans
        l, r = self.__get_leaf(from_inclusive), self.__get_leaf(to_exclusive) - 1
        while r - l > 1:
            if self.__is_right(l): ans = self.__f(ans, self.__dat[l])
            if self.__is_left(r): ans, r = self.__f(ans, self.__dat[r]), r-1
            l, r = l//2, self.__get_parent(r)
        ans = self.__f(ans, self.__dat[l])
        if l != r: ans = self.__f(ans, self.__dat[r])
        return ans

    def __get_leaf(self, i): return self.__n + i - 1
    def __get_parent(self, i): return (i-1)//2
    def __get_children(self, i): return (self.__dat[2*i+1], self.__dat[2*i+2])
    def __is_left(self, i): return i&1 == 1
    def __is_right(self, i): return i&1 == 0

import sys
input = sys.stdin.readline
N = int(input())
S = input().rstrip()
tree = SegmentTree(S, f=lambda x,y:x|y, converter=lambda c: 1 << (ord(c)-ord('a')))
Q = int(input())
update = tree.update
query = tree.query
for _ in range(Q):
    t, a, b = input().rstrip().split()
    if t == '1': update(int(a)-1, b)
    else: print(bin(query(int(a)-1, int(b))).count('1'))


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){

    int X;

    cin>>X;





    if(X >= 30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


    return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
#define rep(i,x,y)  for(ll i=x;i<y;++i)
#define For(i,x,y)  for(ll i=x;i<=y;++i) 
#define FOr(i,x,y)  for(ll i=x;i>=y;--i) 
#define pi acos(-1)
#define mk make_pair<ll,ll>
#define pa pair<ll,ll>
#define lf else if
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)		(x)*(x)
#define abs(x)		(x)>0?(x):-(x)
#define Mul(x,y)    x=x*(y)%mod
#define Add(x,y)    x=(x+(y))%mod
#define Max(x,y)	x=x<(y)?(y):x
#define Min(x,y)	x=x>(y)?(y):x
#define E(x) 		return writeln(x),0
#define p(x)		printf("~%d~\n",x)
#define pp(x,y)		printf("~~%d %d~~\n",x,y)
#define ppp(x,y,z)	printf("~~~%d %d %d~~~\n",x,y,z)
#define f_in(x)		freopen(x".in","r",stdin)
#define f_out(x) 	freopen(x".out","w",stdout)
#define open(x)		f_in(x),f_out(x)
#define fi first
#define se second
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_;
#endif 
#define NEG 0
    const int L=2333333;
    char SZB[L],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,L,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,f=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') f=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*f; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    inline void writeln(ll x){  write(x);   puts("");   }
}using namespace SHENZHEBEI;
const ll N=100000;
int main(){
	read();	ll a=read(),b=read();
	puts(!((b-a)&1)?"Alice":"Borys");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;

    // 1の個数 0の個数 ... 0の個数 1の個数
    vector<int> num;
    if (s[0] == '0') num.push_back(0);
    for (int i = 0; i < s.size();) {
        int j = i;
        while (j < s.size() && s[i] == s[j]) j++;
        num.push_back(j-i);
        i = j;
    }
    if (s.back() == '0') num.push_back(0);

    vector<int> sum((int)num.size()+1);
    for (int i = 0; i < num.size(); i++)
    {
        sum[i+1] = sum[i] + num[i];
        // cout << num[i] << ' ';
    }
    // cout << endl;
    int ans = 0;
    for (int i = 0; i < sum.size(); i += 2)
    {
        int j = i + k*2+1;
        if (j >= sum.size()) j = (int)sum.size()-1;
        ans = max(ans, sum[j]-sum[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1272
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<string, string> P;
const ll MOD = 1000000007LL;
ll sum_r[100001];
int main() {
	int N;
	cin >> N;
	vector<int> vl, vr;
	for (int i = 0; i < N; i++) {
		int L, R;
		cin >> L >> R;
		vl.push_back(L * 2);
		vr.push_back(-R * 2);
	}
	sort(vl.rbegin(), vl.rend());
	sort(vr.rbegin(), vr.rend());
	for (int i = 0; i < N; i++) {
		sum_r[i + 1] = sum_r[i] + vr[i];
	}
	ll ans = 0;
	ll sum_l = 0;
	for (int i = 0; i <= N; i++) {
		for (int j = -1; j <= 1; j++) {
			int k = i + j;
			if (k<0 || k>N) continue;
			ans = max(ans, sum_l + sum_r[k]);
		}
		if (i < N) sum_l += vl[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2036
package main

import "fmt"

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	var str string
	_, _ = fmt.Scan(&str)
	str += "_"
	ans := 0
	for i := 0; i < len(str) - 1; i++ {
		if str[i] != str[i + 1] {
			ans ++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1408
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 210000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
const ll ainf = 998244353;

void solv() {
	int n;
	cin >> n;

	ll a[100010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	ll la[100010];
	la[0] = a[0];
	for (size_t i = 1; i < n; i++)
	{
		la[i] = gcd(a[i], la[i - 1]);
	}
	ll ra[100010];
	ra[n - 1] = a[n - 1];
	for (int i = n - 2; i >= 0; i--)
	{
		ra[i] = gcd(a[i], ra[i + 1]);
	}
	ll res = ra[0];
	res = max(ra[1], la[n - 2]);
	for (int i = 1; i < n - 1; i++)
	{
		res = max(gcd(la[i - 1], ra[i + 1]), res);
	}
	cout << res << endl;
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 2005;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl

int main()
{
    ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans=max(x,y)*2*c;
    ans=min(ans,min(x,y)*2*c+(y>x?(y-x)*b:(x-y)*a));
    ans=min(ans,a*x+b*y);
    cout<<ans<<endl;
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int N,i,count,count_div,check;
    int A[201];
    scanf("%d",&N);
    for(i = 0; i < N;i++){
        if(scanf("%d",&A[i]) == 1){
        }
    }
    count = 0;
    check=0;
    while(check == 0){
        count_div = 0;
        for(i=0;i<N;i++){
            if(A[i]%2 == 0){
                count_div++;
            }else{
                check = 1;
            }
        }
        if(count_div == N){
            count++;
            for(i=0;i<N;i++){
                A[i] = A[i]/2;
            }
        }
    }
    
    printf("%d",count);
    return 0;
}


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

int main(){
    int N, i;
    string S;
    bool A = false;

cin >> N;
    for(i = 0; i < N; i++){
        cin >> S;
        if(S == "Y"){
            A = true;
        }
    }
    if(A == true) cout << "Four" << endl;

    else cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2*1e5;

int n;
vint ans;

void dfs(vint b, vint tmp_ans) {
    if (b.empty()) {
        reverse(all(tmp_ans));
        ans = tmp_ans;
        return;
    }
    int n = b.size();
    for (int i = n; i >= 1; i--) {
        if (b[i-1] == i) {
            tmp_ans.push_back(i);
            b.erase(b.begin()+i-1);
            dfs(b,tmp_ans);
            break;
        }
    }
}

int main() {
    cin >> n;
    vint b(n);
    rep(i,n) cin >> b[i];
    dfs(b,vint {});
    if (ans == vint {}) cout << -1 << endl;
    else rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 3716
import sys
readline = sys.stdin.readline
write = sys.stdout.write

from itertools import repeat

N = int(readline())
L = 10001

C = [0]*L;
for a in map(int, readline().split()):
    C[a] += 1


ans = []
for i, c in enumerate(C):
    if c:
        ans.extend(repeat(str(i), c))
write(" ".join(ans))
write("\n")



Measured memory_bytes: 151132
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void print(int w){
	rep(i,w+2) cout << '#';
  	cout << endl;
}

void Main()
{
	int h, w;
  	cin >> h >> w;
  	vector<string> a(h);
  	rep(i,h) cin >> a[i];
	print(w);  	
	rep(i,h) cout << '#' << a[i] << '#' << endl;
  	print(w);  	
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

template<typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int x, y;
    cin >> x >> y;


    auto solve = [&]() {
        int ans = INF;
        if (x <= y) {
            chmin(ans, y - x);
        }
        x = -x;
        if (x <= y) {
            chmin(ans, y - x + 1);
        }
        y = -y;
        if (x <= y) {
            chmin(ans, y - x + 2);
        }
        x = -x;
        if (x <= y) {
            chmin(ans, y - x + 1);
        }
        return ans;
    };
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
n, k, s = map(int, input().split())
a = [0 for i in range(n)]
for i in range(k):
    a[i] = s
if s == 10**9:
    for j in range(n-k):
        a[k+j] = 10**9-1
else:
    for j in range(n-k):
        a[k+j] = s+1

print(*a)


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

int main(){
  int w, h, n;
  cin >> w >> h >> n;

  int x, y, a;
  int s[105][105] = {};

  for( int i = 0; i < n; ++i ) {
    cin >> x >> y >> a;
    if(a == 1) {
      for(int i = 0; i <= x; ++i){
        for(int j = 0; j <= h; ++j){
          s[i][j] = 1;
        }
      }
    }

    else if( a == 2 ){
      for( int i = x + 1; i <= w; ++i  ){
        for( int j = 0; j <= h; ++j ){
          s[i][j] = 1;
        }
      }
    }

    else if( a == 3 ){
      for( int i = 0; i <= w; ++i ){
        for( int j = 0; j <= y; ++j ){
          s[i][j] = 1;
        }
      }
    }

    else if( a == 4 ){
      for( int i = 0; i <= w; ++i ){
        for(int j = y + 1; j <= h; ++j){
          s[i][j] = 1;
        }
      }
    }
  }

  int ans = 0;

  for(int i = 1; i <= w; ++i){
    for( int  j = 1; j <= h; ++j){
      if(!s[i][j]) ans++;
    }
  }
  cout << ans << endl;
  return 0;


}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<ll,ll>> pc;
//int ABS(int a){return max(a,-a);}
//int a[100001];
ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll tw=0,yk=1;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=a[0];
    for(ll i=1;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define max(x, y) (((x) > (y)) ? (x) : (y))

int solv(int n) {
  int i, res = 0, abc[100000][3], p[3], t[3];

  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &abc[i][0], &abc[i][1], &abc[i][2]);
  }

  p[0] = abc[0][0];
  p[1] = abc[0][1];
  p[2] = abc[0][2];
  // n 日繰り返す
  for (i = 1; i < n; i++) {
    t[0] = max(p[1] + abc[i][0], p[2] + abc[i][0]);
    t[1] = max(p[0] + abc[i][1], p[2] + abc[i][1]);
    t[2] = max(p[0] + abc[i][2], p[1] + abc[i][2]);
    p[0] = t[0];
    p[1] = t[1];
    p[2] = t[2];
  }

  for (i = 0; i < 3; i++) {
    res = max(res, p[i]);
  }

  return res;
}

int main(int argc, char **argv) {
  int n;

  while (scanf("%d", &n) != EOF) {
    printf("%d\n", solv(n));
  }

  return 0;
}


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

int main(void) {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;

    vector<vector<pair<int,int>>> Gy(n);
    vector<vector<pair<int,int>>> Gs(n);
    for(int i=0; i<m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        Gy[u].push_back(pair<int,long>(v, a));
        Gy[v].push_back(pair<int,long>(u, a));
        Gs[u].push_back(pair<int,long>(v, b));
        Gs[v].push_back(pair<int,long>(u, b));
    }

    vector<long> costy(n, 1e18), costs(n, 1e18);
    {
        priority_queue<pair<long,int>> q;
        q.push(pair<long,int>(-0, s));

        while(!q.empty()) {
            auto c = -q.top().first;
            auto v = q.top().second;
            q.pop();

            if(costy[v] != 1e18) continue;
            costy[v] = min(c, costy[v]);

            for(auto &x: Gy[v])
                if(costy[x.first] == 1e18)
                    q.push(pair<long,int>(-(c+x.second), x.first));
        }
    }
    {
        priority_queue<pair<long,int>> q;
        q.push(pair<long,int>(-0, t));

        while(!q.empty()) {
            auto c = -q.top().first;
            auto v = q.top().second;
            q.pop();

            if(costs[v] != 1e18) continue;
            costs[v] = min(c, costs[v]);

            for(auto &x: Gs[v])
                if(costs[x.first] == 1e18)
                    q.push(pair<long,int>(-(c+x.second), x.first));
        }
    }

    vector<long> ress(n);
    long res = 1e18;
    for(int i=n-1; i>=0; i--) {
        res = min(res, costy[i]+costs[i]);
        ress[i] = res;
    }
    for(auto &x: ress) cout << (long)1e15 - x << endl;
}


Measured memory_bytes: 16116
n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
count = 0
flag = 0

loop do
  if a.length == 1
    flag == 0 ? count = 1 : count
    break
  end
  flag = 1
  a.pop(k)
  a.push(1)
  count += 1
end

puts count

Measured memory_bytes: 31892
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     int 	    long long
#define 	pb 	        push_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%d",&i)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define 	mapp 	    map<int,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>s
#define 	set_it 	    set<int>::iterator si
#define     map_it      map<int,int> :: reverse_iterator mi
#define 	yes 	    cout<<"YES"<<endl
#define 	no 	        cout<<"NO"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          iNT_MAX
#define     lmx         LLONG_MAX
#define     mn          iNT_MiN
#define     lmn         LLONG_MiN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
  // freopen ("(input).txt" , "r",  stdin) ;
  // string st,stt ;
  // int low=0,high=0;
  // int l,r;
    int n,k,t,b,c,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;
    cin>>n>>k>>x>>y;  ; vect v ,a  ; sett ; set_it ; mapp m,mp; pairr p; map_it;
    if(n<=k)
        cout<<x*n<<endl;
    else
        cout<<x*k+y*(n-k)<<endl;


}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}


Measured memory_bytes: 3556
def makeinsert(s):
	left = 0
	inserttop = ''
	for i in range(0, len(s)):
		if s[i] == '(':
			left += 1
		else:
			if left > 0:
				left -= 1
			else:
				inserttop = '(' + inserttop
	insertbottom = ''
	for i in range(0, left):
		insertbottom = insertbottom + ')'
	return inserttop + s + insertbottom

raw_input()
s = raw_input()

print makeinsert(s)


Measured memory_bytes: 2568
n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a[::2])
a.sort()
now = 0
ans = 0
br = len(b)
for k,v in enumerate(a):
  if b[now] == v:
    if k % 2:
      ans += 1
    now += 1
  if now == br:
    break
print(ans)

Measured memory_bytes: 8060
#include <cstdio>
#include <algorithm>
#include <cmath>

using std::sort;
using std::abs;

const int MAXN=1e5+5;
int n;
int t[MAXN];

struct point{
	int x,y;
	bool operator < (const point &that)const{
		return x<that.x || (x==that.x && y<that.y);
	}
}d[MAXN];

inline int mht_dis(int a,int b){
	return abs(d[a].x-d[b].x)+abs(d[a].y-d[b].y);
}

inline bool jud(int tm){
	if(mht_dis(tm,tm+1)>t[tm+1]-t[tm])
		return false;
	if((t[tm+1]-t[tm]-mht_dis(tm,tm+1))&1)
		return false;
    return true;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d%d%d",&t[i],&d[i].x,&d[i].y);
	for(int i=0;i<n;++i){
		if(!jud(i)){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1280
N = int(input())
import collections

Ls = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    Ls[a - 1].append(b - 1)
    Ls[b - 1].append(a - 1)

Cs = sorted(map(int, input().split()))
print(sum(Cs) - max(Cs))

sw = [-1] * N
stk = collections.deque([0])
while len(stk) > 0:
    crN = stk.popleft()
    if sw[crN] < 0:
        sw[crN] = Cs.pop()
        for l in Ls[crN]:
            stk.append(l)

print(*sw)

Measured memory_bytes: 50520
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}
	return B;
}

ll _gcd(ll A, ll B) {
	return (B == 0) ? A : gcd(A % B, B);
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}

int same_vec(vector<int> a, vector<int> b) {
	int res = 1, num = a.size();
	for (int i = 0; i < num; i++) {
		if (a[i] != b[i]) {
			res = 0;
			break;
		}
	}
	return res;
}


ll fibs[100] = { 0 };
ll fib(int n) {
	if (fibs[n] == 0) {
		return fibs[n] = fib(n - 1) + fib(n - 2);
	}
	return fibs[n];
}

vector<ll> prime_factor(int64_t n) {
	//map< ll, ll > ret;
	vector<ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			//ret[i]++;
			ret.push_back(i);
			n /= i;
		}
	}
	if (n != 1)ret.push_back(n);// ret[n] = 1;
	return ret;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << to_string(!(a == c)) << endl;


ProgramEndPointLabel:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG


	return 0;
}




Measured memory_bytes: 504
r, c = map(int, input().split())
table = []
sum_column = [0 for i in range(c)]
for row in range(r):
    table.append(list(map(int, input().split())))
    table[row].append(sum(table[row]))
    for i in range(c):
        sum_column[i] += table[row][i]
sum_column.append(sum(sum_column))
table.append(sum_column)
for row in table:
    print(" ".join(map(str, row)))



Measured memory_bytes: 5704
#include <iostream>
using namespace std;
int main(){
	long int a,b;
	long int x,y,z;
	cin >> a >> b;
	x = a + b;
	y = a * b;
	z = a - b;
	if (x >= y && x >= z)
	{
		cout << x << endl;
	}else if (y >= x && y >= z)
	{
		cout << y << endl;
	}else{
		cout << z << endl;
	}

}

Measured memory_bytes: 256
s = list(input())
k = int(input())
ans = 0

if s[0] != s[-1]:
    for i in range(len(s)-1):
        if s[i] == s[i + 1]:
            s[i+1] = "OK"
            ans += 1
    print(ans * k)

else:
    if len(set(s)) == 1:
        if len(s) % 2 == 0:
            print((len(s) // 2) * k)
        else:
            print(len(s) * (k // 2) if k %
                  2 == 0 else len(s) * (k // 2) + (len(s) // 2))
    else:
        mae = 1
        for i in range(len(s) - 1):
            if s[i] == s[i + 1]:
                mae += 1
            else:
                break

        ushiro = 1
        for i in range(len(s) - 1, 0, -1):
            if s[i] == s[i - 1]:
                ushiro += 1
            else:
                break

        for i in range(len(s)-1):
            if s[i] == s[i + 1]:
                s[i+1] = "OK"
                ans += 1

        ans_ = 0
        for i in range(mae, len(s) - ushiro):
            if s[i] == "OK":
                ans_ += 1
        print(((mae + ushiro) // 2 * (k - 1)) + ans_ * (k - 1) + ans)

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

int main(){
  int n,a,b,c,x;
  int k;
  int count;
  vector<int> y;
  int s;

  while(cin >> n >> a >> b >> c >> x){
    if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0){
      break;
    }
    y.clear();
    count = -1;
    for(int i = 0;i < n; i++){
      cin >> k;
      y.push_back(k);
    }
    reverse(y.begin(),y.end());
    while(!y.empty()){
      if(x == *(y.end()-1)){
        y.pop_back();
      }
      x = (a*x + b) % c; 
      count++;
      if(count > 10000){
        break;
      }
    }

    if(count > 10000){
      cout << -1 << endl;
    }else{
      cout << count << endl;
    }
  }
      


      

}

Measured memory_bytes: 3108
#, = map(int, input().split(" "))
alpha = input()
komoji_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
if alpha in komoji_list:
    print('a')
else:
    print("A")

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

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

    int maxv = 0;
    for(int i = 1; i * i <= m; i++){
        if(m % i == 0){
            int a = i;
            int b = m / i;
            if(a * n <= m) maxv = max(maxv, a);
            if(b * n <= m) maxv = max(maxv, b);
        }
    }
    cout << maxv << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int a, b;

	cin >> a >> b;

	if (a < 10 && b < 10) {
		cout << a * b << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int x,y,z;
int main(void){
  scanf("%d\n",&x);
  scanf("%d\n",&y);
  scanf("%d\n",&z);
  if((x==y&&x!=z)||(x==z&&x!=y)||(y==z&&y!=x))
     printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 1664
# x < yでyが不要とする。y抜きで[K-y,K)を作れる。
# このときにxを使っていないのならば、xも不要。
# xを使っているのならば、xy抜きで[K-x-y,K-x)を作れる。
# yを加えて、x抜きで[K-x,K)を作れる。
# よってy不要ならばx不要。
import numpy as np
import itertools

N,K = map(int,input().split())
A = [int(x) for x in input().split()]
A.sort()

# カードは[0,N)-indexed

def test(i):
  # i番目のカードは不要
  dp = np.zeros(K,dtype=np.bool)
  dp[0] = True
  for a in itertools.chain(A[:i],A[i+1:]):
    dp[a:] = np.logical_or(dp[a:],dp[:-a])
  return not dp[-A[i]:].any()

left = -1 # 不要だと判明
right = N # 不要でないと判明
while right - left > 1:
  mid = (left+right)//2
  if test(mid):
    left = mid
  else:
    right = mid

   
answer = left+1
print(answer)

Measured memory_bytes: 14552