akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

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


int main() {
    int N;
    string S;
    cin>>N>>S;
    for (int i = 0; i < S.length(); ++i) {
        S[i]='A'+(S[i]-'A'+(char)N)%26;
    }
    cout<<S<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
const ll INF = 1000000007;

int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	for (int i = 0; i <= n; i+=r) {
		for (int j = 0; j <= n; j+=g) {
			if (i + j > n) continue;
			else if ((n - i - j)%b==0 ) ans++;
		}
	}
	cout << ans << endl;
}

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

signed main(){
  int k,s;
  cin>>k>>s;

  int ans=(s%3==0);

  for(int x=0;x<=k;x++)
    for(int y=0;y<=k;y++)
      if(x!=y&&x*2+y==s) ans+=3;

  for(int x=0;x<=k;x++)
    for(int y=0;y<x;y++)
      for(int z=0;z<y;z++)
        if(x+y+z==s) ans+=6;

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


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

int GCD(int x, int y){
    /*int n, m;
    if(x<y){n=y; m=x;}
    else   {n=x; m=y;}

    for(int i=m;i>0;i--){
        if(m%i==0 && (n%m)%i==0)return i;
    }*/
    int small, big, amari;
    if(x<y){small=x; big=y;}
    else   {small=y; big=x;}
    while(1){
    /*int small, big, amari;
    if(x<y){small=x; big=y;}
    else   {small=y; big=x;}*/
    

    amari=big%small;
    
    if(amari==0)break;
    else {big=small; small=amari;}
    }
    return small;
}

int main(){
    int x, y; cin >> x >> y;

    cout << GCD(x, y) << endl;
}


Measured memory_bytes: 3120
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){

    ll a,b,x;
    cin >> a >> b >> x;

    ll ans = (ll)b/x - (ll)a/x;

    if(a%x == 0) ans++;

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

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

int main(){
    string s;
    cin >> s;
    ll sum = 0, cnt = 0;
    for(auto e : s){
        if(e == 'B') cnt++;
        else sum += cnt;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    TreeMap<Integer,Integer> tm = new TreeMap<>();
    for(int i = 0;i<n;i++){
      int a = sc.nextInt();
      if(tm.containsKey(a)){
        tm.put(a,tm.get(a)+1);
      }else{
        tm.put(a,1);
      }
    }
    long ans = 0l;
    for(int aa:tm.keySet()){
      if(aa<tm.get(aa)){
        ans += tm.get(aa) - aa;
      }else if(aa>tm.get(aa)){
        ans += tm.get(aa);
      }
    }
    System.out.println(ans);
  }
}


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

int main()
{
  unsigned long long int a,b;
  int i=0;
  cin>>a;
  b=100;
  while(b<a)
  {
    b=b+0.01*b;
    i++;
  }
  cout<<i<<'\n';
  return 0;
}
  


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    vector<int> a(N);

    rep(i,N){
       cin >> a.at(i);
    }
    int ans=1000000000;
    int tmp=0;
    // cout << a.size() << endl;
    rep2(i,-100,101){
        tmp=0;
        rep(j,N){
            tmp+=(a.at(j)-i)*(a.at(j)-i);
        }
    ans=min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, L = map(int, input().split())






ans = 0
if L < 0 and N + L - 1 > 0:
    print(int((2 * L + N - 1) * N / 2))
elif L < 0:
    print(int((2 * L + N - 1) * N / 2 - (N + L - 1)))
else:
    print(int((2 * L + N - 1) * N / 2 - L))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <unordered_map>
#include <cmath>

int main() {
	int n,d;
	std::cin >> n >> d;
	auto per_unit = d * 2 + 1;
	double result = std::ceil(((double)n / (double)per_unit));
	std::cout << (int)result << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
struct UnionFind {
  vector<int> a;
  UnionFind(int n) : a(n) {
    for(int i = 0; i < n; i++) a[i] = i;
  }

  int root(int x) { 
    if (a[x] == x) return x;
    return a[x] = root(a[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    a[rx] = ry;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  } 
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep (i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a, b);
  }

  map<int, int> mp;
  rep (i, n) {
    mp[uf.root(i)]++;
  }

  vector<int> a;
  for (auto v : mp) a.push_back(v.second);
  sort(a.begin(), a.end());
  ll minus = 0;
  int ans = 0;
  for (int i = 0; i < a.size(); i++) {
    a[i] -= minus;
    minus += a[i];
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int n,a[111111];
long long ans,l[111111],r[111111],cur,x,y;
int main()
{
	scanf("%d",&n);
	for (int i=0;i<=n;i++) scanf("%d",&a[i]);
	l[n]=r[n]=a[n];
	for (int i=n-1;i>=0;i--)
	{
		l[i]=(l[i+1]+1)/2+a[i];
		r[i]=r[i+1]+a[i];
	}
	if (l[0]<=1 && r[0]>=1);
	else 
	{
		printf("-1\n");
		return 0;
	}
	ans=cur=1;
	for (int i=1;i<=n;i++)
	{
		x=cur;y=cur*2;
		y=min(y,r[i]);ans+=y;
		cur=y-a[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5776
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pr pair<int,int>
#define endl "\n"
#define MOD 1000000007 // 10^9 + 7
#define sz(x) (int)(x).size()
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
#define all(c) (c).begin(), (c).end()

#define FOR(i,b) for (int i = 0; i < (b); i++)
#define FORR(i,a,b) for (int i = a; i < (b); i++)
#define FORB(i,b) for (int i = (b); i >= (0); i--)
#define FORRB(i,a,b) for (int i = (a);i>= (b); i--)
#define MAXN 1010
using namespace std;

int h,w;
char grid[MAXN][MAXN];
int dp[MAXN][MAXN];

int solve(int i,int j){
	if(i >= h || j >= w) return 0;
	if(i == h-1 && j == w-1) return 1;
	if(dp[i][j] != -1) return dp[i][j];
	if(grid[i][j] == '#') return 0;
	dp[i][j] = 0;
	dp[i][j] = (solve(i+1,j)%MOD + solve(i,j+1)%MOD)%MOD;
	return dp[i][j];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	//freopen("addin.txt","r",stdin);
	//freopen("addout.txt","w",stdout);
	cin >> h >> w;
	for(int i = 0 ;i < h;i++){
		for(int j = 0 ;j<w;j++){
			cin >> grid[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 5376
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s == "abc") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  
  cout << fixed << setprecision(10);
  double c;
  if( b < 10 ){
    c = a * 10 + b;
  }else if( 10 <= b && b < 100 ){
    c = a * 100 + b;
  }else if( b == 100 ){
    c = a * 1000 + b;
  }
  
  for( int i = 0; i < 1000; i++ ){
    if( i * i == c ){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <tuple>
# include <functional>
# include <utility>
# define INF 1000000000
# define MOD 1000000000+7
using namespace std;

int main() {
	pair< int, int > Q[6];
	for (int i = 0; i < 6; i++) {
		cin >> Q[i].first >> Q[i].second;
		if (Q[i].first > Q[i].second) swap(Q[i].first, Q[i].second);
	}
	sort(Q, Q + 6);

	if (Q[0] == Q[1] && Q[2] == Q[3] && Q[4] == Q[5] && Q[0].first == Q[2].first&&Q[2].second == Q[4].second && Q[0].second == Q[4].first) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
}

Measured memory_bytes: 3072
#include <iostream>

using namespace std;

int main()
{
    int x=0,i,a,b,c;
    //read the input and loop according to the input
    cin>>a>>b>>c;
   for(i=a;i<=b;i++){
       if(c%i==0)
       x++;
   
       
   }
   
   cout<< x <<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)

typedef long long ll;

int main() { 
    ll n,m;
    cin >>n;
    m=n;
    if(n%2==1){
        cout<<0<<endl;
        return 0;
    }
    ll ans =0;
    m=10;
    while(1){
        ans += n/m;
        m*=5;
        if(n/m==0) break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'

/////////////////////////////////////
//コピペスペース//////////////////////

//定数
const INF  =  900719925474099 // Math.floor(Number.MAX_SAFE_INTEGER / 10);

//スペース区切りの数字列を数字の配列にして返す
function mapint(line){return line.split(' ').map((v)=>parseInt(v));}

function lower_bound(d,a,b,e){
    for(var c;1<b-a;)
        d[c=0|(a+b)/2]<e ? a=c : b=c;
    return d[a]<e?b:a
};

const MOD = 1000000007;
//コピペスペース//////////////////////
/////////////////////////////////////

function dfs(cur,a,b,c){
	if(cur == N){
		let mp = Math.abs(a-A) + Math.abs(b-B) + Math.abs(c-C) - 30;

		//console.log(a,b,c,mp);
		if(Math.min(a,b,c)<=0) return INF;
		return mp;
	}
	let ret0 = dfs(cur+1,a,b,c);
	let ret1 = dfs(cur+1,a+l[cur],b,c)+10;
	let ret2 = dfs(cur+1,a,b+l[cur],c)+10;
	let ret3 = dfs(cur+1,a,b,c+l[cur])+10;

	return Math.min(ret0,ret1,ret2,ret3);
}

let N,A,B,C;
let l;

function Main(input){
	let temp = input.trim().split('\n');
	let abc = mapint(temp[0]);
	N = abc.shift();
	A = abc.shift();
	B = abc.shift();
	C = abc.shift();

	l = new Array(N);
	for(let i=1;i<=N;i++){
		l[i-1] = parseInt(temp[i]);
	}

	console.log(dfs(0,0,0,0));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22408
a, b, k = map(int, input().split())
while k > 0:
    if a % 2 == 1:
        a -= 1
    b += int(a / 2)
    a -= int(a / 2)
    k -= 1
    if k == 0:
        break

    if b % 2 == 1:
        b -= 1
    a += int(b / 2)
    b -= int(b / 2)
    k -= 1
print(a, b)


Measured memory_bytes: 3060
from subprocess import*
call(('pypy3','-c',"""
h,n=[int(j) for j in input().split()]
ab=[[int(j) for j in input().split()] for i in range(n)]
dp=[10**18]*(h+1)
dp[0]=0
ans=10**18
for a,b in ab:
    for i in range(h+1):
        if dp[i]!=10**18:
            if i+a<h:
                if dp[i]+b<dp[i+a]:
                    dp[i+a]=dp[i]+b
            else:
                if dp[i]+b<ans:
                    ans=dp[i]+b
 
print(ans)

"""))

Measured memory_bytes: 46276
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M, Q = MAP()
LR = [LIST() for _ in range(M)]
pq = [LIST() for _ in range(Q)]

x = [[0]*(N+1) for _ in range(N+1)]

for L, R in LR:
	x[L][R] += 1

for l in range(N+1):
	x[l] = list(accumulate(x[l]))
		
for p, q in pq:
	ans = 0
	for i in range(p, q+1):
		ans += x[i][q] - x[i][p-1]
	print(ans)




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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

int a, b;
int n;

int f(double x) {
    return (int) (floor((a * x) / b) - a * floor(x / b));
}

void solve() {
    cin >> a >> b >> n;
    cout << f(min(n, b - 1)) << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define si set <ll>
#define vi vector <ll>
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define ll long long
#define sc second
#define pb push_back
#define mp make_pair
#define ff(i,a,n) for(int i=a;i<n;i++)
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else
        cout<<"safe";
    return 0;
}


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

int main() {
    int a, b, k;
    int cnt = 0;
    int ans;
    
    cin >> a >> b >> k;
    
    for (int i = min(a, b); i > 0; i--) {
        if (((a % i) == 0) && ((b % i) == 0)) {
            cnt++;
            
            if (cnt == k) {
                ans = i;
                break;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
  char c;
  int value;
} Card;

int main(){
  int N,n1,n2,i,j,minj,flag = 0;
  Card C[36],C1[36],C2[36],c;

  scanf("%d",&N);

  for(i=0; i < N; i++){
    scanf(" %c%d",&C[i].c,&C[i].value);
    C1[i] = C[i];
    C2[i] = C[i];
  }

  for(i=0; i < N; i++){
    for(j=N-1; j > i; j--){
      if(C1[j].value < C1[j-1].value){
	c = C1[j];
	C1[j] = C1[j-1];
	C1[j-1] = c;
      }
    }
  }

  for(i=0; i < N-1; i++){
    if(C1[i].value == C1[i+1].value){
      for(j=0; j < N; j++){
	if(C1[i].c == C[j].c && C1[i].value == C[j].value){
	  n1 = j;
	}
	if(C1[i+1].c == C[j].c && C1[i+1].value == C[j].value){
	  n2 = j;
	}
      }
      if(n1 > n2){
  	flag = 1;
      }
    }
  }

  for(i=0; i < N; i++){
    printf("%c%d",C1[i].c,C1[i].value);
    if(i != N-1){
      printf(" ");
    }
  }
  printf("\n");

  if(flag == 0){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  flag = 0;
  
  for(i=0; i < N; i++){
    minj = i;
    for(j=i; j < N; j++){
      if(C2[j].value < C2[minj].value){
	minj = j;
      }
    }
    c = C2[i];
    C2[i] = C2[minj];
    C2[minj] = c;
  }
  
  for(i=0; i < N-1; i++){
    if(C2[i].value == C2[i+1].value){
      for(j=0; j < N; j++){
	if(C2[i].c == C[j].c && C2[i].value == C[j].value){
	  n1 = j;
	}
	if(C2[i+1].c == C[j].c && C2[i+1].value == C[j].value){
	  n2 = j;
	}
      }
      if(n1 > n2){
  	flag = 1;
      }
    } 
  }
  
  for(i=0; i < N; i++){
    printf("%c%d",C2[i].c,C2[i].value);
    if(i != N-1){
      printf(" ");
    }
  }
  printf("\n");

  if(flag == 0){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}



Measured memory_bytes: 2124
N=int(input())
number={}
for i in range(N):
    a,b=map(int,input().split())
    number[a] = b
number_max = max(number.values())
answer = []
for v,m in number.items():
    if m==number_max:
        answer.append(v)
print(min(answer),number_max)


Measured memory_bytes: 5600
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <cassert>
using namespace std;

#define ran(i, a, b) for ((i) = (a); (i) < (b); (i)++)
#define rep(i, a) ran ((i), 0, (a))
#define rep1(i, a) ran ((i), 1, (a)+1)
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
#if defined(SHIROKO1_LOCAL) && !defined(NDEBUG)
template <typename T>
static void DEBUG(T&& s) { cerr << s << endl; }
template <typename T, typename... Ts>
static void DEBUG(T&& a, Ts&&... as)
{
	cerr << a << ' ';
	DEBUG(as...);
}
#else
#define DEBUG(...) ((void)0)
#endif

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	if ((a-b)&1)
		puts("Borys");
	else
		puts("Alice");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<list>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<iterator>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

signed main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1;i <= n;i++) {
		int cnt = 0;
		if (i % 2 == 1) {
			for (int j = 1;j <= i;j++) {
				if (i%j == 0)cnt++;
			}
		}
		if (cnt == 8)ans++;

	}
	cout << ans << endl;
}

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

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}

int Solver::solve() {
	string n; cin >> n;
	int md9 = 0;
	for (char c : n) md9 = (md9 * 10 + (c - '0')) % 9;
	cout << (md9 == 0 ? "Yes" : "No") << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solver.solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3744
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n, l;
    cin >> n >> l;

    vector<string> v;
    
    REP(i, n) {
        string si;
        cin >> si;
        v.push_back(si);
    }

    sort(ALL(v));

    REP(i, n)
        cout << v[i];
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
X, Y, A, B, C = gets.split.map(&:to_i)
P = gets.split.map(&:to_i).sort.last(X)
Q = gets.split.map(&:to_i).sort.last(Y)
R = gets.split.map(&:to_i).sort

loop do |r|
  paint = false
  if P.first < Q.first
    if P.first < R.last
      P.shift
      P << R.pop
      paint = true
    end
  else
    if Q.first < R.last
      Q.shift
      Q << R.pop
      paint = true
    end
  end

  if !paint || R.size == 0
    break
  end
end

puts P.inject(&:+) + Q.inject(&:+)

Measured memory_bytes: 26472
#include<bits/stdc++.h>
using namespace std;
int main(){
int s,k;
int count =0;
cin >>k>>s;
for(int x=0;x<=k;x++)
{
for( int y=0;y<=k;y++)
{
int z=s-(x+y);
if(z>=0&&z<=k)
count ++;
}
}
cout<<count <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
int ans[4];
string label[4] = {"AC x ", "WA x ", "TLE x ", "RE x "};

int main() {
  INCANT;
  cin >> N;
  string s;
  rep(i, N) {
    cin >> s;
    if (s[0]=='A') ans[0]++;
    if (s[0]=='W') ans[1]++;
    if (s[0]=='T') ans[2]++;
    if (s[0]=='R') ans[3]++;
  }
  
  rep(i, 4) {
    cout << label[i] << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int my_mid(int x, int y, int z) {
    if ((x > y && x < z) || (x < y && x > z)) {
        return x;
    }
    else if ((y > x && y < z) || (y < x && y > z)) {
        return y;
    }
    else if ((z > x && z < y) || (z < x && z > y)) {
        return z;
    }
    else
    {
        return 0;
    }
}
int main() {
    int N; cin >> N;
    vector<int> P(N, 0);
    for (int i = 0; i < N; ++i) cin >> P[i];
    int cnt = 0;
    for (int i = 1; i < N - 1; ++i) if (my_mid(P[i - 1], P[i], P[i + 1]) == P[i]) cnt++;
    printf("%d\n", cnt);
}


Measured memory_bytes: 3680
#include <cstdio>
#include <cstring>

int main(void)
{
	#if DEBUG 
	freopen("_in","r",stdin);
	#endif
	#if WATCH_RUNTIME
	startTime=clock();
	#endif
	bool winFlag;
	int i,j,N;
	char msg[200],patten[100];
	scanf("%s",msg);
	scanf("%s",patten);
	N=strlen(msg);
	for(i=0;i<N;i++)
	{
		msg[N+i]=msg[i];
	}
	msg[N+i]='\0';
	for(i=0;i<N;i++)
	{
		winFlag=true;
		for(j=0;patten[j];j++)
		{
			if(patten[j]!=msg[i+j])
			{
				winFlag=false;
				break;
			}
		}
		if(winFlag)
			break;
	}
	printf("%s\n",winFlag?"Yes":"No");

	#if WATCH_RUNTIME
	printf("----------\n");
	printf("\n+===============+\n");
	printf("|RUNTIME =%3dms.|\n",clock()-startTime);
	printf("+===============+\n");
	#endif

	return 0;
}

Measured memory_bytes: 128
N, M = map(int,input().split())
X = list(map(int,input().split()))
if N < len(X):
    D =[]
    S = 0
    X.sort()
    for i in range(M-1):
        D.append(X[i+1]-X[i])
    E =sorted(D,reverse = True)
    S = sum(E)
    for j in range(N-1):
        S -= E[j]
    print(S)
else:
    print("0")

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
int n,a[100005],cnt;

int main(){
    cin >> n;
    cnt = 0;
    for(int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        int t = i;
        bool check = false;
        for(int j = i; j < n; j++)
            if (a[t] > a[j]) {
                 t = j;
                 check = true;
            }
        if (check) cnt++;
        swap(a[i],a[t]);
    }
    for(int i = 0; i < n-1; i++) cout << a[i] << " ";
    cout << a[n-1];
    cout << '\n';
    cout << cnt << '\n';
}



Measured memory_bytes: 3136
import java.util.*;

class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		Integer a[]=new Integer[n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();
		Arrays.sort(a,Comparator.reverseOrder());
		int x=0,y=0;
		for(int i=0;i<n;i++)
		{
			if(i%2==0)
				x+=a[i];
			else
				y+=a[i];
		}

		System.out.println(x-y);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath> 
#include <vector> 
#include <queue>
using ll = long long;
using namespace std;
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
int main() {
    int N;cin>>N;
    int ans;ans=0;
    int a[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a,a+N);
    ans=a[N/2]-a[N/2-1];

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

Measured memory_bytes: 640
N = int(input())
X = list(map(int, input().split()))

# _sum = sum(X)
buff_x = X.copy()


X.sort()
mm = X[N//2-1]
mx = X[N//2]
for i in range(N):
    if buff_x[i] < mx:
        print(mx)
    else:
        print(mm)

Measured memory_bytes: 25620
n = int(input())
a = list(map(int,input().split())) 
ans = 0
a.sort(reverse=True)
ans += a[0]
k = 0
if n%2 == 0:
    for i in range((n-1)//2):
        ans += 2*a[i+1]
else:
    for k in range((n-1)//2-1):
        ans += 2*a[k+1]
    ans += a[k+2]
if n == 3:
    ans += a[1]
    ans -= a[2]
print(ans)
                

Measured memory_bytes: 94112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using PL = pair<ll,ll>;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
constexpr int INF = (1 << 29);
constexpr ll INF_ = (1LL << 58);
constexpr ld EPS = (1e-10);
constexpr ld PI_ = 3.141592653589793238;//46264338327950288
constexpr ld E_ = 2.71828182845904523;//5360287471352
constexpr ll MOD = 1000000007;
//// functions (integer)_________________________________
ll modpow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a % m;
		a = a * a%m; n >>= 1;
	}
	return res;
}
long long modinv(long long a, long long p, long long mod){
  return modpow(a,p-2,mod);
}
////-----------------------------------------------------



int main(){
  int N;vector<ll> A; set<ll>P; map<ll,ll> B;
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  RPT(i,0,N){
    ll a; cin >> a;
    A.push_back(a);
  }
  sort(A.begin(),A.end());

  FOR(i,2,1000003){
    bool ynprime = true;
    for(auto x : P){
      if(i % x == 0){ ynprime = false; break; }
      if( x*x > i ) break;
    }
    if(ynprime) P.insert(i);
  }

  RPT(i,0,N){
    ll ttl = A[i];
    set<ll>::iterator it = P.find(A[i]);
    if(it!=P.end()){
      ttl = 1;
      if(B[A[i]]<1) B[A[i]] = 1;
    }
    for(auto x : P){
      ll cnt = 0;
      if(x > A[i] || ttl == 1) break;
      while(ttl % x == 0){
        ttl /= x;
        cnt++;
      }
      if(cnt){
        if(B[x]<cnt) B[x] = cnt;
      }
    }
    if(ttl != 1) {
      P.insert(A[i]);
      B[A[i]] = 1;
    }
  }

  ll L=1, Ainv = 0;
  for(auto x : P){
    L = ((L * (modpow(x,B[x],MOD))%MOD)) % MOD;
  }
  RPT(i,0,N){
    Ainv = (Ainv + ((modpow(A[i],MOD-2,MOD)%MOD)%MOD) ) % MOD;
  }
  ll ans = (Ainv * L) % MOD;
  //ll ans = (Ainv % MOD);
  cout << ans << endl; 
  //cout << L << endl << Ainv << endl;for(auto x: P) if(B[x]) cout << x << "^" << B[x] << " ";
  return 0;
}

Measured memory_bytes: 8960
// atcoder/abc155/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> reverse(pair<P, Q> p) { return make_pair(p.second, p.first); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  lli k;
  while (cin >> n >> k) {
    vector<lli> a(n);
    cin >> a;
    sort(a.begin(), a.end());

    const lli z = count(a.begin(), a.end(), 0);
    vector<lli> p, m;
    each (i, a) {
      if (i < 0) m.push_back(i);
      if (0 < i) p.push_back(i);
    }

    auto fn = [&] (lli x) {
      lli sum = 0;
      const lli ms = m.size();
      const lli ps = p.size();

      if (0 <= x) {
        sum += (ms * ps);
        sum += z * ps;
        sum += z * ms;
        sum += (z - 1) * z / 2;
      }

      if (x < 0) {
        each (i, p) {
          lli y = x / i;
          if (x % i == 0) ++y;
          auto itr = lower_bound(m.begin(), m.end(), y);
          sum += (itr - m.begin());
        }
      }

      if (0 < x) {
        for (int i = 0; i + 1 < p.size(); ++i) {
          lli y = x / p[i];
          auto itr = upper_bound(p.begin() + i + 1, p.end(), y);
          sum += itr - (p.begin() + i + 1);
        }
        for (int i = 0; i + 1 < m.size(); ++i) {
          lli y = x / m[i];
          auto itr = lower_bound(m.begin() + i + 1, m.end(), y);
          sum += m.end() - itr;
        }
      }

      return sum;
    };

    const lli inf = 1e18 + 2;

    lli small = -inf;
    lli large = +inf;
    while (small + 1 < large) {
      lli mid = (small + large) / 2;
      if (fn(mid) < k) small = mid;
      else large = mid;
    }

    cout << large << endl;
  }

  return 0;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

using Graph = vector<vector<int>>;

int n, m;

// 深さ優先探索
vector<bool> seen;	// 探索したか記録

int main() {
	cin >> n >> m;
	Graph G(n);
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back({b});
		G[b].push_back({a});
	}

	seen.assign(n, false);
	int ans = 2;
	for(int i = 0; i < n; i++) {
		if(!seen[i]) {
			queue<int> que;
			que.push(i);
			int cnt = 0;
			while(!que.empty()) {
				cnt++;
				int v = que.front();
				que.pop();

				for(int nv : G[v]) {
					if(seen[nv]) continue;
					seen[nv] = true;
					que.push(nv);
				}
			}

			ans = max(ans, cnt);
		}
	}
	cout << ans - 1 << endl;

	return 0;
}

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

int main() {
  int K,N;
  cin >> K >> N;
  vector<int>A(N+1);
  vector<int>B(N+1);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  A.at(N)=A.at(0)+K;
  B.at(0)=A.at(0);
  for(int i=1;i<N+1;i++){
    B.at(i)=A.at(i)-A.at(i-1);
  }
  sort(B.begin(),B.end());
  cout << K-B.at(N) << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

void func(int N){

	char buf[101];
	int info[N][2];

	scanf("%s",buf);

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

	for(int i = N-1; i >= 0; i--){
		if(buf[info[i][0]] + info[i][1] - info[i][0] <= 'z'){
			buf[info[i][0]] += info[i][1] - info[i][0];
		}else{
			buf[info[i][0]] = 'a' + (buf[info[i][0]] - 'a' + info[i][1] - info[i][0])%26;
		}

		if(buf[info[i][1]] + info[i][1] - info[i][0] <= 'z'){
			buf[info[i][1]] += info[i][1] - info[i][0];
		}else{
			buf[info[i][1]] = 'a' + (buf[info[i][1]] - 'a' + info[i][1] - info[i][0])%26;
		}

		swap(buf[info[i][0]],buf[info[i][1]]);
	}

	printf("%s\n",buf);

}


int main(){

	int N;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func(N);
	}

	return 0;
}

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

int main()
{
   char input[10],output[10];
   int l=-1;
   cin >> input;
   for(int i=0;input[i]!='\0';i++)
   {
      if(input[i]=='B' && l!=-1)
         {
            l--;
         }
         else if (input[i]=='0')
         {
            output[++l]='0';
         }
         else if (input[i] == '1')
         {
            output[++l] = '1';
         }
   }
   output[++l]='\0';
   cout<< output;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

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

    vector<int> ss(26, 0), tt(26, 0);


    rep(i, s.size()){
        int j = 0;
        for(char c = 'a'; c <= 'z'; c++){
            if(s[i] == c) ss[j]++;
            if(t[i] == c) tt[j]++;
            j++;
        }
    }
    sort(ss.begin(), ss.end());
    sort(tt.begin(), tt.end());
    bool flag = true;
    rep(i, 26){
        if(ss[i] != tt[i]) flag = false;
    }
    cout << (flag ? "Yes" : "No") << endl;
}



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


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

    int N, T; cin >> N >> T;
    vector<int> A(N); rep(i, N) cin >> A[i];

    A.push_back(0);
    int min_a = A[0];
    int max_diff = 0, cnt = 0;
    for (auto a : A) {
        int diff = a - min_a;
        if (diff >= 0) {
            if (diff > max_diff) {
                max_diff = diff;
                cnt = 1;
            } else if (diff == max_diff) {
                cnt++;
            }
        } else { // diff < 0 <=> a < min_a
            min_a = a;
        }
    }
    cout << cnt << '\n';

    return 0;
}

Measured memory_bytes: 3972
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AShiritori {
public:
	void solve(istream& in, ostream& out) {
        string a,b,c;
        in >> a >> b >> c;
        int na = a.size(),nb = b.size();
        if(a[na - 1] == b[0] && b[nb - 1] == c[0]) out << "YES" << endl;
        else out << "NO" << endl;
	}
};

int main() {
	AShiritori solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
int main(){
  int n,m=0,a[16],f,c,l,r;
  std::pair<int, int> p;
  std::vector<std::vector<std::pair<int, int>>> v(16);
  std::cin>>n;
  for(int i=0;i!=n;++i){
    std::cin>>a[i];
    for(int j=0;j!=a[i];++j){
      std::cin>>l>>r;
      p = {l,r};
      v[i].push_back(p);
    }
  }
  for(int i=0;i!=1<<n;++i){
    f=1;
    c=0;
    int s[16]={};
    for(int j=0;j!=n;++j){
      if(i>>j&1){s[j]=1;++c;}
      else{s[j]=-1;}
    }
    for(int j=0;j!=n;++j){
      if(i>>j&1){
        for(auto x:v[j]){
          if(x.second==1){
            if(s[x.first-1]==-1){f=0;break;}
          }
          else{
            if(s[x.first-1]==1){f=0;break;}
          }
        }
      }
    }
    if(f)m=(m<c?c:m);
  }
  std::cout<<m<<"\n";
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	s := sc.NextInt()
	cnt := make(map[int]bool)
	cnt[s] = true
	for i := 2; i <= 1000000; i++ {
		s = f(s)
		if cnt[s] {
			fmt.Println(i)
			return
		}
		cnt[s] = true
	}
}

func f(n int) int {
	if n%2 == 0 {
		return n / 2
	}
	return 3*n + 1
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 N;
  cin >> N;
  string S;
  cin >> S;

  i64 R=0, G=0, B=0;
  i64 i;
  REP(0, N, i) {
    switch(S[i]) {
    case 'R':
      R++; break;
    case 'G':
      G++; break;
    case 'B':
      B++; break;
    }
  }

  i64 Rl = 0, Gl = 0, Bl = 0;
  i64 ans = 0;
  REP(0, N, i) {
    i64 Rr = R - Rl;
    i64 Gr = G - Gl;
    i64 Br = B - Bl;

    switch(S[i]) {
    case 'R': ans += Gl * Br + Gr * Bl; break;
    case 'G': ans += Bl * Rr + Br * Rl; break;
    case 'B': ans += Rl * Gr + Rr * Gl; break;
    }

    i64 d = 1;
    while(i - d >= 0 && i + d < N) {
      i64 j = i - d, k = i + d;
      if(S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) {
	ans--;
      }
      ++d;
    }
    
    switch(S[i]) {
    case 'R':
      Rl++; break;
    case 'G':
      Gl++; break;
    case 'B':
      Bl++; break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
def comb(n):
    if (n <= 1):
        return 0
    return (n - 1) * n / 2

N = int(input())
A = list(map(int, input().split()))

cnt = [0 for i in range(N + 1)]
for a in A:
    cnt[a] += 1
comb1 = [comb(cnt[a]) for a in A]
comb2 = [comb(cnt[a] - 1) for a in A]

Sum = sum([comb(c) for c in cnt])

for i in range(len(A)):
    print(int(Sum - comb1[i] + comb2[i]))


Measured memory_bytes: 30464
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, maxwt;
	cin>>n>>maxwt;
	vector<vector<long long int> >dp(n+1, vector<long long int>(maxwt+1));
	int wt[n], val[n];
	for(int i = 0; i<n; i++)
	cin>>wt[i]>>val[i];
	for(int i = 0; i<n+1; i++){
		for(int j = 0; j<maxwt+1; j++){
			if(i == 0|| j == 0){
				dp[i][j] = 0;
				continue;
			}
			if(j-wt[i-1]>=0){
				dp[i][j] = max(dp[i-1][j], val[i-1] + dp[i-1][j-wt[i-1]]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout<<dp[n][maxwt];
	return 0;
}

Measured memory_bytes: 80256
# from pprint import pprint as pprint
import copy

def findrecipe(rec,ite,obj):
    # pprint(rec)
    # print("obj: ",obj)
    # print("=-")
    try:
        mat = rec[obj]
        rec2 = copy.copy(rec)
        del rec2[obj]
        price = min(ite[obj],sum([findrecipe(rec2,ite,m) for m in mat]))
        # print(price,obj)
        return price
    except:
        return ite[obj]

while(True):
    try:
        item = {}
        n = int(input())
        for _ in range(n):
            s,p = input().split()
            p = int(p)
            item[s] = p
        recipe = {}
        m = int(input())
        for _ in range(m):
            o,k,qs = input().split(" ",2)
            recipe[o] = qs.split()

        t = input()
        print(findrecipe(recipe,item,t))
    except:
        break


Measured memory_bytes: 6332
import copy
def get_list(n):
  l = []
  for _ in range(6):
    if n & 0x01: l.append(1)
    else:l.append(0)
    n=n >> 1
  #l.reverse()
  return l

def count_black(l,h,w):
  res=0
  for _h in range(h):
    for _w in range(w):
      if l[_h][_w]=='#':res+=1
#    res+=l[_h].count('#')
  return res

def main():
  H,W,K=map(int,input().split())
  c=[list(input()) for _ in range(H)]
  max_h,max_w=2**H-1,2**W-1
  ans=0
  for h2 in range(max_h):
    for w2 in range(max_w):
      count_black=0
      for h in range(H):
        for w in range(W):
          if (h2 >> h & 1) or (w2 >> w & 1):
            # to Red
            pass
          else:
            if c[h][w]=='#':
              count_black+=1
      if count_black==K: ans+=1
  print(ans)
  pass
if __name__ == '__main__':
  main()




Measured memory_bytes: 9352
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
total = 0
for j in range(2,N):
    if x[j-2] == y[j-2] and x[j-1] == y[j-1] and x[j] == y[j]:
        total += 1
if total == 0:
    print('No')
else:
    print('Yes')

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

int main() {
  int a, b, c, x, counter = 0;

  cin >> a >> b >> c >> x;

  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (i * 500 + j * 100 + k * 50 == x) {
          counter++;
        }
      }
    }
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 3612
x, n = map(int, input().split())
p = list(map(int, input().split()))

dmin = 10 ** 9
ans = 0

for i in range(0, 102):
    if i not in p:
        d = (x - i) * (x - i)
        if d < dmin:
            dmin = d
            ans = i

print(ans)

Measured memory_bytes: 61932
#include<iostream>
#include<cmath>
#include<bits/stdc++.h>
#include<string.h>
#include<stdio.h>
using namespace std;

int main()
{
    int n,m;string a;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
        cin>>a;
        cout<<a<<endl;
        cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256