akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll ans=0;
  int N;
  cin >> N;
  int h[100010];
  for(int i=1;i<=N;i++){
    cin >> h[i];
  }
  int dp[100010]={0};
  dp[1]=0;
  dp[2]=abs(h[1]-h[2]);
  for(int i=1;i<=N;i++){
    dp[i+2]=min(dp[i]+abs(h[i]-h[i+2]),dp[i+1]+abs(h[i+1]-h[i+2]));
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1)*18;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
/*
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
*/
int main(void){
	llint n,i;cin>>n;
	//桁DP!
	//aで0のbit->bでもbitは0
	//これを守りさえすればdistinct
	llint kriu=0,krid=0,mtou=0,mtod=1;
	//下の桁がnよりおおきい ->u 以下->d
	//繰り上がり発生中->kri してない->mto
	for(i=0;i<60;i++){
		llint sku=0,skd=0,smu=0,smd=0;
		if(n&(1LL<<i)){//1
			//0 0
			smu+=kriu;smd+=krid;smd+=mtou;smd+=mtod;
			//1 0
			skd+=kriu;skd+=krid;smu+=mtou;smd+=mtod;
			//1 1
			sku+=kriu;skd+=krid;skd+=mtou;skd+=mtod;
		}else{//0
			//0 0
			smu+=kriu;smu+=krid;smu+=mtou;smd+=mtod;
			//1 0
			sku+=kriu;skd+=krid;smu+=mtou;smu+=mtod;
			//1 1
			sku+=kriu;sku+=krid;sku+=mtou;skd+=mtod;
		}
		kriu=sku%mod;krid=skd%mod;mtou=smu%mod;mtod=smd%mod;
	}
	cout<<mtod<<endl;RE;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
#define PI 3.1415926535897932384626433832795
#define coutfix(i) cout << fixed << setprecision(i)
using namespace std;

int main()
{
	int64 nn, ans = 1;
	cin >> nn;
	vector<int64> hh(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> hh[ii];
	}
	for(int64 ii = 1;ii < nn;ii++)
	{
		if(hh[ii - 1] <= hh[ii])
		{
			ans++;
		}
		else
		{
			hh[ii] = hh[ii - 1];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3532
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;
typedef pair<int, int> P;
const int MAX = 2*123500;

/** Problem1144 : Curling 2.0 **/
int w, h, ans;

typedef struct {
	int field[20][20];
	P pos;
	int cost;
} S;

void dfs(S t) {
		int x = t.pos.first, y = t.pos.second;
		
		if (t.cost>10)
			return;
		
		rep(i, 4) {
			int nx = x, ny = y;
			if (t.field[nx+dx[i]][ny+dy[i]]==1)
				goto next;
			while(1) {
				nx+=dx[i]; ny+=dy[i];
				if (0<=nx&&nx<w&&0<=ny&&ny<h) {
					if (t.field[nx][ny]==3) {
						ans = min(ans, t.cost+1);
					}
					if (t.field[nx][ny]==1) {
						t.field[nx][ny]=0;
						break;
					}
				} else {
					goto next;
				}
			}
			t.cost++;
			t.pos = P(nx-dx[i], ny-dy[i]);
			dfs(t);
			t.cost--;
			t.pos = P(x, y);
			t.field[nx][ny]=1;
		next:;
		}
}

int main()
{
	while (cin>>w>>h, w||h) {
		ans = INF;
		S s = {{0}, P(0, 0), 0};
		rep(y, h) rep(x, w) {
			cin>>s.field[x][y];
			if (s.field[x][y]==2)
				s.pos = P(x, y);
		}
		
		dfs(s);
	
		if (ans<=10)
			cout << ans << endl;
		else
			cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let n = stdin.lock().gets().parse::<usize>().unwrap();
    let a = stdin.lock().gets().split(' ').map(|x| x.parse().unwrap())
        .collect::<Vec<i32>>();
    let mean = (a.iter().sum::<i32>() as f64 / n as f64).round() as i32;
    let cost = a.iter().map(|x| (x - mean).pow(2)).sum::<i32>();
    println!("{}", cost);
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


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

const int MAX_in=300010;
vector<int> list;

void make_list(){
  bool prime[MAX_in];
  prime[0]=prime[1]=0;
  for(int i=2;i<MAX_in;i++){
    prime[i]=1;
  }
  for(int i=2;i<MAX_in;i++){
    if(prime[i]==1)
    switch(i%7){
    case 1:
    case 6:
      list.push_back(i);
      for(int j=i+i;j<MAX_in;j+=i){
        prime[j]=0;
      }
      break;
    default:
      prime[i]=0;
    }
  }
}


void solve(int n){
  for(int i=0;i<list.size();i++){
    if(n%list[i]==0){
     cout<<" "<<list[i];
    }
  }
}


int main(){
  make_list();
  long long n;
  while(cin>>n,n!=1){
    cout<<n<<":";
    solve(n);
    cout<<endl;
  }
}

Measured memory_bytes: 1640
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long int ulli;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
/* TUMSE NAA HO PAAYEGA HAR DO DIN MAI LAGEGA
   LEKIN RUKNE KA NAHI :P */

int main() {
	// your code goes here
	FASTIO
	int x;
	cin >> x;
	x=!x;
	cout << x;
	return 0;
}


Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int a=sc.nextInt();
			int d=sc.nextInt();
			int n=sc.nextInt();
			if((a==0&&d==0)&&n==0) break;
			int[] sosu = new int[500000];
			int[] tansaku = new int[1000001];
			for(int i=0;i<=1000000;++i){
				if((i!=0&&i!=1)&&i%2!=0){
					tansaku[i]=1;
				}
			}
			int end=(int)Math.sqrt((double)1000000);
			sosu[0]=2;
			for(int i=3;i<=end;i+=2){
				if(tansaku[i]==1){
					for(int j=i+i;j<=1000000;j+=i){
						if(tansaku[j]==1) tansaku[j]=0;
					}
				}
			}
			int m=1;
			for(int i=3;i<=1000000;++i){
				if(tansaku[i]==1){
					sosu[m]=i;
					++m;
				}
			}
			int count=0;
			Arrays.sort(sosu);
			while(true){
				if(a>1000000) break;
				if(Arrays.binarySearch(sosu,a)>=0){
					count++;
				}
				if(count==n){
					System.out.println(a);
					break;
				}
				a+=d;
			}
		}
	}
}



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

using namespace std;

typedef long long ll;
typedef long double ld;

map <ll, int> gde;

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    ll x;
    cin >> x;
    for(ll i=-300; i<=300; i++){
        gde[i*i*i*i*i] = i;
    }
    for(ll a=1; ; a++){
        ll g = a*a*a*a*a-x;
        if(gde[g] || g == 0){
            cout << a << " " << gde[g] << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3712
n,c,k=map(int,input().split())
t=[int(input()) for x in range(n)]
t.sort()

i=0
cnt=0
while i<n:
  departure=t[i]+k
  p=0
  for j in range(i,n):
    if t[j] > departure or p==c:
      break
    p+=1
  i+=p
  cnt+=1
print(cnt)

Measured memory_bytes: 13308
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    a = I()
    b = I()
    print(6 - a - b)
    return


# B
def B():
    n = I()
    s, t = input().split(' ')
    ans = []
    for i in range(n):
        ans.append(s[i])
        ans.append(t[i])
    print(''.join(ans))
    return


# C
def C():
    def GCD(a, b):
        if (b == 0):
            return a
        else:
            return GCD(b, a % b)

    a, b = LI()
    print(a * b // GCD(a, b))
    return


# D
def D():
    n = I()
    a = LI()
    cnt = 0
    for i in range(n):
        if a[i] == cnt + 1:
            cnt += 1
    if cnt == 0:
        print(-1)
    else:
        print(n - cnt)
    return


# E
def E():
    n = I()
    if n % 2 != 0:
        print(0)
        return
    ans = 0
    i = 10
    while 1:
        if i > n:
            break
        ans += n // i
        i *= 5
    print(ans)
    return


# F
def F():
    return


# Unittest
def resolve():
    E()
    return


# Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define rep(I, N) for (int I = 1; I <= (N); ++I)
#define repp(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORR(I, A, B) for (int I = (A); I >= (B); I--)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-7;
const int mod = 1e9 + 7;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
int a[N];
int main() {
    int n, l;
    cin >> n >> l;
    int sum = 0;
    rep(i, n){a[i] = l + i - 1;
        sum += a[i];
    }
    int ans = 1e9;
    int x = 0;
    rep(i,n)
    {
        int _ = 0;
        rep(j,n)
        {
            if(i == j)
                continue;
            _ += a[j];
        }
        if(abs(_ - sum) < ans)
        {
            ans = abs(_ - sum);
            x = i;
        }
    }
    int __ = 0;
    for (int i = 1; i <= n;i++) 
    {
        if(i != x)
            __ += a[i];
    }
        cout << __ << endl;
    return 0;
}
 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int N = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        System.out.println(Math.min(N * A, B));
    }
}


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

using namespace std;

typedef long long LL;
#define N (1<<19)
#define M 100005
#define K (1<<9)

LL n,m,q,a[N],b[N],c[N],f[K+5][M];

int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;++i){
		scanf("%lld%lld",a+i,b+i);
	}
	m=100000;
	for (LL i=1;i<=K&&i<=n;++i){
		LL t=0;
		for (LL j=i;j;j/=2) c[t++]=j;
		for (LL j=0;j<1<<t;++j){
			LL w=0,v=0;
			for (LL k=0;k<t;++k){
				if (j>>k&1){
					v+=a[c[k]]; w+=b[c[k]];
				}
			}
			if (w<=m) f[i][w]=max(f[i][w],v);
		}
		for (LL j=1;j<=m;++j) f[i][j]=max(f[i][j],f[i][j-1]);
	}
	scanf("%lld",&q);
	while (q--){
		LL x,y; scanf("%lld%lld",&x,&y);
		LL t=0,ans=0;
		for (;x>K;x/=2) c[t++]=x;
		for (LL i=0;i<1<<t;++i){
			LL w=0,v=0;
			for (LL k=0;k<t;++k){
				if (i>>k&1){
					v+=a[c[k]]; w+=b[c[k]];
				}
			}
			if (w<=y) ans=max(ans,f[x][y-w]+v);
		}
		printf("%lld\n",ans);
	}
	
	return 0;
}
				

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

int main()
{
	int N;
	cin>>N;
	int A,B;
	int count = 0;
	bool flag = false;
	while(N--){
		cin>>A>>B;
		if(A==B){
			count +=1;
			if(count == 3){
				flag = true;
			}
		}
		if(A != B)
			count = 0;
	}
	if(flag)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

}

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

int N, C1 = 0, C2 = 0, C3 = 0;
static double DP[310][310][310] = {};
static bool flag[310][310][310] = {};

double Func(int X, int Y, int Z) {
	if (flag[X][Y][Z]) return DP[X][Y][Z];
	flag[X][Y][Z] = true;
	double COUNT = 0, ZERO = 1 - (double)(N - X - Y - Z) / N;
	COUNT += 1 / ZERO;
	if (X != 0) COUNT += Func(X - 1, Y, Z) * X / N / ZERO;
	if (Y != 0) COUNT += Func(X + 1, Y - 1, Z) * Y / N / ZERO;
	if (Z != 0) COUNT += Func(X, Y + 1, Z - 1) * Z / N / ZERO;
	return DP[X][Y][Z] = COUNT;
}

int main() {
	cin >> N;
	DP[0][0][0] = 0;
	flag[0][0][0] = true;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (A == 1) C1++;
		if (A == 2) C2++;
		if (A == 3) C3++;
	}
	printf("%.12lf\n", Func(C1, C2, C3));
}

Measured memory_bytes: 256256
N, *rest = $stdin.read.split.map(&:to_i)
PLAN = [[0, 0, 0]] + rest.each_slice(3).to_a

def ok?(t1, x1, y1, t2, x2, y2)
  dt = t2 - t1
  return false if (x1-x2).abs + (y1-y2).abs > dt
  return false if (x1+y1+x2+y2)%2 != dt%2
  true
end

PLAN.each_cons(2) do |a, b|
  unless ok?(*a, *b)
    puts 'No'; exit
  end
end
puts 'Yes'


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

#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)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/

int main(){

	int n;
	cin >> n;
	cout << n * n*n << endl;






	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  if(s[0] == '1')ans++;
  if(s[1] == '1')ans++;
  if(s[2] == '1')ans++;
  
  cout << ans << endl;
  
}

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

bool is_lunlun (ll n) {
	bool res = true;
	int pre = -1;
	while(n) {
		if(pre != -1) {
			if(abs(n%10 - pre) > 1) {
				res = false;
				break;
			}
		}
		pre = n % 10;
		n /= 10;
	}
	return res;
}

int main() {
	ll k;
	cin >> k;
	vector<ll> a;
	rep(i, 9) a.push_back(i+1);
	while(1) {
		if(k <= a.size()) {
			cout << a[k-1] << endl;
			break;
		}
		k -= a.size();
		vector<ll> b;
		swap(a, b);
		for(ll now: b) {
			for(int i = -1; i <= 1; i++) {
				ll d = now%10 + i;
				if(d < 0 || d > 9) continue;
				ll nw = now*10 + d;
				a.push_back(nw); 
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, K, i, p[1001];

    cin >> N >> K;

    for(i=1; i<=N; i++){
        cin >> p[i];
    }

    sort(p+1, p+N+1);

    ll sum=0;

    for(i=1; i<=K; i++){
        sum += p[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const ll INF = 1LL << 60;

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

int n, k;
vector<int> h;

void input() {
    cin >> n >> k;
    h = vector<int>(n);
    for(int i = 0; i < n; i++) {
        cin >> h.at(i);
    }
}

void solve() {
    vector<ll> cost(n, INF);
    cost.at(0) = 0;
    cost.at(1) = abs(h.at(1) - h.at(0));
    for(int i = 2; i < n; i++) {
        for(int j = 1; j <= min(i, k); j++) {
            cost.at(i) = min(cost.at(i-j) + abs(h.at(i) - h.at(i-j)), cost.at(i));
            //cout << "i: " << i << ", cost[i]: " << cost.at(i) << endl;
        }
    }
    cout << cost.at(n-1) << endl;
}



int main() {
    input();
    solve();
}


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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

int n, m, q;
vi a, b, c, d;

void backtracking(vi &A, int &res, int lst)
{
    if (A.size() == n)
    {
        int local = 0;
        REP(i, 0, q)
        {
            if (A[b[i] - 1] - A[a[i] - 1] == c[i])
            {
                local += d[i];
            }
        }
        res = max(res, local);
        return;
    }
    REP(i, lst, m + 1)
    {
        A.push_back(i);
        backtracking(A, res, i);
        A.pop_back();
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    cin >> n >> m >> q;
    a.resize(q), b.resize(q), c.resize(q), d.resize(q);
    REP(i, 0, q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    int res = 0;
    vi A;
    backtracking(A, res, 1);
    cout << res;
    return 0;
}

Measured memory_bytes: 3604
def main():
    s = input()
    k = int(input())
    print(solve(s, k))

def solve(s, k):
    ans = 0
    if len(set(s)) == 1:
        ans += replace_count(len(s)*k)
    else:
        same = 1
        for i in range(0, len(s)-1):
            if s[i] == s[i+1]:
                same += 1
            else:
                ans += replace_count(same) * k
                same = 1
        ans += replace_count(same) * k
        if s[0] == s[i]:
            a = 1
            b = 1
            a_idx = 0
            b_idx = -1
            while s[a_idx] == s[a_idx+1]:
                a += 1
                a_idx += 1
            while s[b_idx] == s[b_idx-1]:
                b += 1
                b_idx -= 1
            dup = (replace_count(a) + replace_count(b) - replace_count(a+b)) * (k-1)
            ans -= dup

    return ans


def replace_count(n):
    return n//2

main()




Measured memory_bytes: 3064
s = raw_input()
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(tuple([(0<int(s[2*i:2*i+2]) <= 12)	for i in range(2)]))))]

Measured memory_bytes: 28012
//
//diverta 2019
//B
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int R,G,B,N;
    cin >> R >> G >> B >> N;

    int ans=0;
    REP(r,N+1){
        REP(g,N+1){
            int b = N - (r*R + g*G);
            if (b<0) continue;
            if (b%B==0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
import sys

#+++++

def naiseki(va,vb):
	return sum([a*b for a,b in zip(va,vb)])

def main():
	n , c = map(int, input().split())
		
	ccc=[0]*c
	for i in range(c):
		ccc[i]=[0]*c
	for i in range(c):
		temp=list(map(int,input().split()))
		#ccc[i]=temp
		for j,v in enumerate(temp):
			ccc[j][i]=v
		
	pa(ccc)
		
	ddl=[0,0,0]
	for i in range(3):
		ddl[i]=[0]*c
		
	for i in range(1,n+1):
		ll=list(map(int, input().split()))
		for j, color_v in enumerate(ll,start=1):
			group=(i+j)%3
			ddl[group][color_v-1]+=1
			
	pa('_____ddl_____')
	for i in range(3):
		pa(ddl[i])
		
	rrb=[0]*3
	for i in range(3):
		rrb[i]=[0]*c	
		for j in range(c):
			rrb[i][j]=(naiseki(ddl[i], ccc[j]),j)
			
	pa('____rrb_____')
	for i in range(3):
		pa(rrb[i])
	
	c=[0]	* 3
	for i in range(3):
		rrb[i].sort()
		aa=rrb[i][:3]
		c[i]=aa
		
	pa('____ c _____')
	for i in range(3):
		pa(c[i])
		
	mm=None
	for i in range(3):
		for j in range(3):
			for k in range(3):
				ii=c[0][i][1]
				ji=c[1][j][1]
				ki=c[2][k][1]
				if ii !=ji and ji!=ki and ki!=ii:
					temp=c[0][i][0]+c[1][j][0]+c[2][k][0]
					#pa(temp)
					mm = temp if mm is None else min(mm,temp)
					
	return mm
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

using namespace std;

int cost[100005];
int dp[100005] = { 0 };
int main(){
    ios::sync_with_stdio(0); cin.tie();
    int N, a;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a;
        cost[i] = a;
    }
    for(int i = 1 ; i < N ; i++){
        if( i - 2 >= 0 ){
        dp[i] = min( dp[i-1] + abs( cost[i] - cost[i-1]), dp[i-2] + abs( cost[i] - cost[i-2]) );}
        else{
            dp[i] = dp[i-1]  + abs( cost[i] - cost[i-1]);
        }
    }
    cout << dp[N-1];   
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    string s; cin >> s;
    cout << (s[0]!=s[1]||s[1]!=s[2] ? "Yes" : "No") << endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

void solve()
{
  int n, c, c_input;
  cin >> n >> c;
  vector< vector<int> > cost(c, vector<int>(c));
  vector< vector<int> > grid(3, vector<int>(c, 0));

  for(int i = 0; i < c; ++i)
  {
    for(int j = 0; j < c; ++j)
    {
      cin >> cost[i][j];
    }
  }

  for(int i = 1; i <= n; ++i)
  {
    for(int j = 1; j <= n; ++j)
    {
      cin >> c_input;
      c_input--;
      grid[(i + j) % 3][c_input]++;
    }
  }

  ll ans = 1LL << 60;
  for(int c1 = 0; c1 < c; ++c1)
  {
    for(int c2 = 0; c2 < c; ++c2)
    {
      if (c1 == c2) continue;
      for(int c3 = 0; c3 < c; ++c3)
      {
        if (c1 == c3) continue;
        if (c2 == c3) continue;

        ll score = 0;
        for(int i = 0; i < c; ++i)
        {
          score += grid[0][i] * cost[i][c1];
          score += grid[1][i] * cost[i][c2];
          score += grid[2][i] * cost[i][c3];
        }
        ans = min(ans, score);
      }
    }
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin >> K;
    K--;
    cout << a[K] << endl;

    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

Measured memory_bytes: 256
def getlist():
	return list(map(int, input().split()))

N, M = getlist()

light = [[0 for i in range(N)] for j in range(M)]
for i in range(M):
	A = getlist()
	k = A[0]
	for j in range(k):
		light[i][A[1 + j] - 1] = 1

p = getlist()

ans = 0
for i in range(1 << N):
    output = []
    for j in range(N):
        if ((i >> j) & 1) == 1:
            output.append(0)
        else:
        	output.append(1)

    judge = "YES"
    for j in range(M):
    	c = 0
    	for k in range(N):
    		if output[k] == 1 and light[j][k] == 1:
    			c += 1
    	if c % 2 != p[j]:
    		judge = "NO"
    		break

    if judge == "YES":
    	ans += 1


print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    int n,x,ans=0;
    cin>>n>>x;
    vector<long long> v(n);
    REP(i,n) cin>>v[i],v[i]-=x;
    ans=abs(v.at(0));
    REP(i,n)ans=gcd(ans,abs(v[i]));
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

ll gcd(ll a, ll b){
	if (a < b){
		ll temp = a;
		a = b;
		b = temp;
	}
	if (a % b) return gcd(b, a%b);
	else return b;
}

int main(){
	ll a, b, ans = 0;
	cin >> a >> b;
	ll gcdab = gcd(a, b);
	for (ll i = 2; i*i <= gcdab; i++){
		if (gcdab%i == 0) ans++;
		while (gcdab%i == 0) gcdab/=i;
	}
	if (gcdab != 1) ans++;
	cout << ans+1 << endl;
	return 0;
}




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

int n;
int ans = 0;

void dfs(int c, int u, vector<bool> used, bool M[10][10]){
    if(u == n - 1){
        ans++;
        return;
    }
    rep(i,n){
        if(M[c][i] == 1 && used[i] == false){
            used[c] = true;
            dfs(i,u + 1,used,M);
        }
    }
}

int main(){
    int m;
    vector<bool> used(10);
    bool M[10][10] = {0};
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        M[a][b] = M[b][a] = 1;
    }
    dfs(0,0,used,M);
    cout << ans << endl;
}


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

#define ll long long

int main()
{
    string s, t;
    cin>>s>>t;
    int n = s.length();
    for (int i = 0; i<n; i++)
    {
        bool check = true;
        for (int j = 0; j<n; j++) if (s[j]!=t[(i+j)%n]) check = false;
        if (check == true) {cout<<"Yes"; return 0;}
    }
    cout<<"No";
}

Measured memory_bytes: 256
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    RS int
    |>Array.sum
    |>fun c -> (if c>=22 then "bust" else "win")
    |>stdout.WriteLine
    0


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

typedef long long ll;
const int maxn = 100010;
int X, Y, Z;
ll ans = LLONG_MIN, sumx, pre[maxn], suf[maxn];
pair<ll, ll> p[maxn];

int main() {
    scanf("%d %d %d", &X, &Y, &Z);
    int n = X + Y + Z;
    for (int i = 1, x, y, z; i <= n; i++) {
        scanf("%d %d %d", &x, &y, &z);
        sumx += x, p[i] = {y - x, z - x};
    }
    sort(p + 1, p + n + 1, [&](pair<ll, ll> a, pair<ll, ll> b) {
        return a.first - a.second > b.first - b.second;
    });
    priority_queue<ll, vector<ll>, greater<ll>> Q;
    for (int i = 1; i <= Y; i++) {
        Q.push(p[i].first), pre[Y] += p[i].first;
    }
    for (int i = Y + 1; i <= n; i++) {
        pre[i] = pre[i - 1];
        if (Q.top() < p[i].first) {
            pre[i] += p[i].first - Q.top();
            Q.pop(), Q.push(p[i].first);
        }
    }
    while (!Q.empty()) Q.pop();
    for (int i = n; i >= n - Z + 1; i--) {
        Q.push(p[i].second), suf[n - Z + 1] += p[i].second;
    }
    for (int i = n - Z; i; i--) {
        suf[i] = suf[i + 1];
        if (Q.top() < p[i].second) {
            suf[i] += p[i].second - Q.top();
            Q.pop(), Q.push(p[i].second);
        }
    }
    for (int i = Y; i <= n - Z; i++) {
        ans = max(ans, pre[i] + suf[i + 1]);
    }
    printf("%lld\n", ans + sumx);
    return 0;
}

Measured memory_bytes: 6724
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

char s[4];
char t[4];

int main() {
    scanf("%s", s);
    scanf("%s", t);

    int n = strlen(s);
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if(s[i] == t[i]) {
            ++cnt;
        }
    }
    printf("%d\n", cnt);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(i) ((i)&(-(i)))
#define lson(i) ((i)<<1)
#define rson(i) ((i)<<1|1)
#define fi first
#define se second
#define MP(x,y) make_pair((x),(y))
using namespace std;

typedef long long ll;typedef unsigned long long ul;
typedef pair<int,int> pii;typedef pair<ll,ll> pll;
typedef vector<string> vss;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef queue<int> qii;typedef queue<pii> qpi;

const int inf=0x3f3f3f3f;
const int maxn=100007;

int n,res;

int main()
{
// 	freopen("","r",stdin);
// 	freopen("","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		static int x;
		scanf("%d",&x);
		while(x%2==0){
			x/=2;
			res++;
		}
	}
	printf("%d\n",res);
}



Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  ll n;
  cin >> n;

  if(n == 0){
    cout << '0' << endl;
    return 0;
  }

  string ans;
  int k1 = -1;
  do{
    int k;
    ll sum = 0, d;
    if(n >= 0){
      d = 1; k = 0;
      while(true){
        sum += d;
        if(sum >= n) break;
        d *= 4l;
        k += 2;
      }
    }
    else{
      d = -2; k = 1;
      while(true){
        sum += d;
        if(sum <= n) break;
        d *= 4l;
        k += 2;
      }
    }

    for(int i = k + 1; i < k1; i++){
      ans.push_back('0');
    }
    ans.push_back('1');
    k1 = k;

    n -= d;
  }while(n != 0);

  if(k1 != 0){
    for(int i = 0; i < k1; i++){
      ans.push_back('0');
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	int i,a,b,count=0;
  	cin>>a>>b;
  
  	for(i=a/10000;i<=b/10000;i++){
      for(int j=0;j<=9;j++){
		for(int k=0;k<=9;k++){
			if((10001*i+1010*j+100*k-a)*(10001*i+1010*j+100*k-b)<=0){
				count++;
            }
        }
      }
    }

  	cout<<count<<endl;
}

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

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

    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    ll count = 0;
    for(int i = 2; i < s.size() - 1; i++){
        if(s[i] == 'C')
            count++;
    }

    if(count != 1){
        cout << "WA" << endl;
        return 0;
    }

    for(int i = 1; i < s.size(); i++){
        if(s[i] != 'C' && s[i] <= 'Z'){
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << endl;
    return 0;
}


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

int main() {
    const int MOD = 1000000007;

    std::string S;
    std::cin >> S;

    int N = S.size();

    std::vector<
        std::vector<int>
    > dp(N + 1, std::vector<int>(13));
    
    dp[0][0] = 1;

    int p = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 13; j++) {
            if (S[N - 1 - i] == '?') {
                for (int k = 0; k < 10; k++) {
                    int& x = dp[i + 1][(j + p * k) % 13];
                    x += dp[i][j];
                    x %= MOD;
                }
            }
            else {
                int k = S[N - 1 - i] - '0';
                int& x = dp[i + 1][(j + p * k) % 13];
                x += dp[i][j];
                x %= MOD;
            }
        }

        p = p * 10 % 13;
    }

    std::cout << dp[N][5] << "\n";
}

Measured memory_bytes: 8960
/**
 *    author: kalyan       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;
 
void solve(){
    int n;
    cin >> n;
    int cnt=0;
    while(n--){
        int x,y;
        cin >> x>>y;
        if(x == y) cnt++;
        else cnt = 0;
        if(cnt >= 3){
            cout << "Yes";
            return;
        }

    }
    cout <<"No";
    
}
 
int main(){
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t;
    t = 1;
    // cin >> t;
    while(t--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3608
N,M,X,Y = map(int,input().split())

xs = list(map(int,(input().split())))
ys = list(map(int,(input().split())))

xs.append(X)
ys.append(Y)

xs = sorted(xs)
ys = sorted(ys)

if xs[0] < ys[0]:
  if xs[-1] < ys[0]:
    print("No War")
  else:print("War")
elif ys[0] < xs[0]:
  if ys[-1] < xs[0]:
    print("No War")
  else:print("War")

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

ll solve() {
    ll N, T;
    cin >> N >> T;
    ll ans = 0, t, tl = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> t;
        if ( t < tl + T ) {
            ans += t - tl;
        } else {
            ans += T;
        }
        tl = t;
    }
    ans += T;
    
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main(){
	int N; string S; cin>>N>>S;
	int ans = 0;
	for(int i=0; i<1000; i++)
		for(int p=-1, d=100, c=i/d%10+'0'; d; d/=10, c=i/d%10+'0'){
			p = S.find(c,p+1); if(p<0) break;
			if(d==1){ ans++; break; }
		}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  int n, a, b; cin >> n >> a >> b;
  int s = abs(a-b);

  if (s%2 != 0) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
d = [0] * (n+1)
mod = 1000000007
for i in range(1, n+1):
    num = i
    cnt = 0
    m = 2
    while(num != 1):
        while(num % m == 0):
            cnt += 1
            num /= m
        d[m] += cnt
        m += 1
        cnt = 0
ans = 1
for i in range(1,n+1):
    if(d[i] == 0):
        continue
    #print("i:", i, " value:", d[i])
    ans *= (d[i]+1)
    ans %= mod

print(ans)

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var N int

	fmt.Scanf("%d", &N)

	l := make([]int32, N)
	r := make([]int32, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d", &l[i], &r[i])
	}

	prime := Primes(100000)
	check := make([]bool, len(prime))

	for i := range check {
		check[i] = prime[i] && prime[(i+1)/2]
	}

	count := make([]int, len(check))
	for i := 1; i < len(check); i++ {
		count[i] = count[i-1]
		if check[i] {
			count[i]++
		}
	}

	for i := 0; i < N; i++ {
		fmt.Println(count[r[i]] - count[l[i]-1])
	}
}

func Primes(n int) []bool {
	prime := make([]bool, n+1)

	for i := 2; i <= n; i++ {
		prime[i] = true
	}

	for i := 2; i <= n; i++ {
		for j := 2 * i; j <= n; j += i {
			prime[j] = false
		}
	}

	return prime
}


Measured memory_bytes: 5888
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    cnt = 1
    ans = A[0]
    if cnt == N - 1:
        print(ans)
        exit()
    flag = False
    for i in range(1,N):
        if cnt + 1 == N - 1:
            ans += A[i]
            break
        ans += A[i] * 2
        cnt += 2
        if cnt == N - 1:
            break

    print(ans)
    


if __name__ == "__main__":
    main()

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

int count(int n,int x){
int cnt = 0;
for(int i=1;i<=n-2;i++){
for(int j=i+1;j<=n-1;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==x) cnt++;
}
}
}
return cnt;
}

int main(){
int n,x;
while(1){
cin >>n >>x;
if(n==0 && x==0) break;
cout << count(n,x) <<endl;
}
return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();

    double aab_x =  a*a*b -x;

    double ans =0;
    if(aab_x!=0){
      double c =  2.0d * aab_x / (double)(a*a);

      if(c>b){
        c = (double)x*2.0d / ((double) a * b);
        ans = Math.toDegrees(Math.atan( ((double)b/c)));
      }else{
        ans = Math.toDegrees(( Math.atan( c /a )));
      }


    }
    System.out.println(ans);
  }

}

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

int main(){
  string s;
  cin>>s;
  for(int i=s.size()-1;;){
    if(i>=4&&s.substr(i-4,5)=="dream"){
      i-=5;
    }else if(i>=5&&s.substr(i-5,6)=="eraser"){
      i-=6;
    }else if(i>=6&&s.substr(i-6,7)=="dreamer"){
      i-=7;
    }else if(i>=4&&s.substr(i-4,5)=="erase"){
      i-=5;
    }else{
      cout<<"NO"<<endl;
      return 0;
    }
    if(i==-1){
      cout<<"YES"<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 512
module Main where

import Control.Applicative
import Text.Printf
import Numeric

main :: IO ()
main = do
  { [r] <- getDoubles
  ; let area = pi * r ^ 2
  ; let peri = 2 * pi * r
  ; putDoubles [area, peri]
  }

--
  
getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords .map showDouble

showDouble :: Double -> String
showDouble x = showFFloat Nothing x ""



Measured memory_bytes: 4108
N = int(input())
B = list(map(int, input().split(" ")))
A = [float('inf') for i in range(N)]

for i in range(len(B)):
  A[i] = min(A[i], B[i])
  A[i + 1] = min(A[i + 1], B[i])

print(sum(A))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a == b) {
			System.out.println(c);
		}else if(b == c) {
			System.out.println(a);
		}else {
			System.out.println(b);
		}

	}

}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>

using namespace std;


int main() {

	vector<string> ary;
	string v;
	while (cin >> v)
	{
		ary.push_back(v);
	}
	stack<int>  stk;

	int sum = 0; int v1 = 0; int v2 = 0;
	for (int i = 0;i < ary.size();i++) {
		string val = ary[i];
		if (val == "+") {

			int v1 = stk.top();
			stk.pop();
			int v2 = stk.top();
			stk.pop();
			stk.push(v1 + v2);
		}
		else if (val == "-") {

			int v1 = stk.top();
			stk.pop();
			int v2 = stk.top();
			stk.pop();
			stk.push(v2 - v1);

		}
		else if (val == "*") {

			int v1 = stk.top();
			stk.pop();
			int v2 = stk.top();
			stk.pop();
			stk.push(v1 * v2);
		}
		else
		{
			stk.push(stoi(val));
		}
	}

	cout << stk.top() << endl;
	return 0;
}



Measured memory_bytes: 3200
void main(){
	int a, b, c;
	readf("%d %d %d\n", &a, &b, &c);
	if(a==b)writeln(c);
	else if(b==c)writeln(a);
	else writeln(b);
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2796
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, m;
    cin >> n >> m;
    int nm[n][m];
    int m1[m];
    rep(i, n){
        rep(j, m) {
            cin >> nm[i][j];
        }
    }
    rep(i, m) cin >> m1[i];
    rep(i, n) {
        int c = 0;
        rep(j, m) {
            c += nm[i][j] * m1[j];
        }
        cout << c << endl;
    }

    return 0;
}


Measured memory_bytes: 3124
# -*- coding: utf-8 -*-


def main():
    from collections import Counter
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = Counter(map(int, input().split()))
    keys = a.keys()

    for i in range(1, n + 1):
        if i in keys:
            print(a[i])
        else:
            print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45608
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define INF 1LL << 55
#define MAX (1LL << 31) -1
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;
typedef pair<pair<int,int>,ll> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};
//#define F function<T(T,T)>

struct sieve{

    vector<bool> is_prime;
    vector<int> prime;
    int count=0;

    sieve(int N){
        is_prime.assign(N+1,true);

        is_prime[0]=is_prime[1]=false;

        for(int i=2;i<=N;i++){
            if(is_prime[i]){
                count++;
                prime.push_back(i);
                for(int j=2*i;j<=N;j+=i) is_prime[j]=false;
            }
        }
    }

    bool judge(int x){
        return is_prime[x];
    }

    int size(){
        return count;
    }
};


signed main(){
    sieve sv(1000000);
    while(true){
        int a,d,n;
        cin>>a>>d>>n;
        if(a==0 && d==0 && n==0) return 0;
        int count=0;
        while(true){
            if(sv.judge(a)){
                count++;
                if(count==n){
                    cout<<a<<endl;
                    break;
                }
            }
            a+=d;
        }
    }
}


Measured memory_bytes: 3416
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  int sum = 0;
  for (int i = 0; i < s.length(); i++) {
    sum += s[i] - '0';
    if (sum % 9 == 0)
      sum = 0;
  }
  cout << (!sum ? "Yes" : "No") << '\n';

  return 0;
}



Measured memory_bytes: 3376