akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
  ll n, p;
  cin >> n >> p;
  ll ans = 1;
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  
  ll a = 1;
  while (pow(a, n) <= p) {
    ll kake = pow(a, n);
    if (p % kake == 0) ans = a;
    a++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

ll dp[101][2][4];

void work() {
    string s; int K; cin>>s>>K;
    int n = s.size();
    dp[n-1][0][0] = 1LL; dp[n-1][0][1] = 9LL; dp[n-1][0][2] = dp[n-1][0][3] = 0LL;
    dp[n-1][1][0] = 1LL; dp[n-1][1][1] = s[n-1] - '0'; dp[n-1][1][2] = dp[n-1][1][3] = 0LL;
    for (int i = n-2; i >= 0; --i) {
        dp[i][0][0] = dp[i+1][0][0];
        dp[i][0][1] = 9LL * dp[i+1][0][0] + dp[i+1][0][1];
        dp[i][0][2] = 9LL * dp[i+1][0][1] + dp[i+1][0][2];
        dp[i][0][3] = 9LL * dp[i+1][0][2] + dp[i+1][0][3];
        dp[i][1][0] = dp[i][1][1] = dp[i][1][2] = dp[i][1][3] = 0LL;
        for (int j = (i == 0 ? 1 : 0); j < s[i] - '0'; ++j) {
            if (j == 0) {
                dp[i][1][0] += dp[i+1][0][0];
                dp[i][1][1] += dp[i+1][0][1];
                dp[i][1][2] += dp[i+1][0][2];
                dp[i][1][3] += dp[i+1][0][3];
            } else {
                dp[i][1][0] += 0LL;
                dp[i][1][1] += dp[i+1][0][0];
                dp[i][1][2] += dp[i+1][0][1];
                dp[i][1][3] += dp[i+1][0][2];
            }
        }
        dp[i][1][0] += (s[i] == '0') ? dp[i+1][1][0] : 0LL;
        dp[i][1][1] += (s[i] == '0') ? dp[i+1][1][1] : dp[i+1][1][0];
        dp[i][1][2] += (s[i] == '0') ? dp[i+1][1][2] : dp[i+1][1][1];
        dp[i][1][3] += (s[i] == '0') ? dp[i+1][1][3] : dp[i+1][1][2];
    }
    cout << dp[0][1][K] + dp[1][0][K] << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    work();
    return 0;
}


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

int main() {
  int n, k;
  cin>>n>>k;
  int x[n];
  for (int i=0; i<n; i++) cin>>x[i];
  int ans = 0;
  for (int i=0; i<n; i++) {
    ans += min(x[i], k - x[i]);
  }
  cout<<2 * ans<<endl;
}

Measured memory_bytes: 256
N, M, P = map(int, input().split())
INF = 10**18

edges = []
E = [[] for _ in range(N)]
R = [[] for _ in range(N)]
for _ in range(M):
    fr, to, c = map(int, input().split())
    fr -= 1
    to -= 1
    edges.append((fr, to, -(c - P)))
    E[fr].append(to)
    R[to].append(fr)

def existsPath(s, edges):
    visited = [False] * N
    visited[s] = True
    st = [s]
    while st:
        now = st.pop()
        for to in edges[now]:
            if visited[to]:
                continue
            st.append(to)
            visited[to] = True
    return visited

canGoFrom1 = existsPath(0, E)
canGoFromN = existsPath(N - 1, R)

minDist = [INF] * N
minDist[0] = 0
for i in range(N):
    for fr, to, c in edges:
        d = minDist[fr] + c
        if minDist[to] > d:
            if i == N - 1 and canGoFrom1[fr] and canGoFromN[to]:
                print('-1')
                exit()
            minDist[to] = d

print(max(0, -minDist[N - 1]))


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

int main()
{
  string tanka;
  getline(cin, tanka);

  if (tanka == "5 5 7" || tanka == "5 7 5" || tanka == "7 5 5")
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

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

int main(){
    int n; cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++) cin>>d[i];
    sort(d.begin(),d.end());
    cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 640
// In the Name of God
#include<bits/stdc++.h>

#define test(t) int t; cin>>t; while(t--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long int
#define em emplace_back
#define pb push_back
#define INF 1e7+5
#define MOD int(1e9+7)
#define print printf
#define in scanf
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

template<class type>
void displaySingle(type &arr)
{
	for(auto i:arr)
		cout<<i<<" ";
	cout<<endl;
}

template<class type>
void displayDouble(type &arr)
{
	for(auto &&i : arr) 
	{
		for(auto &&j : i) 
			cout << j << " ";
		cout << std::endl;
	}
}

vector <vector <int>> adj;
vector <int> visited;
vector <int> dp;

void dfs(int x)
{
	visited[x] = 1;
	REP(i,adj[x].size())
	{
		if(!visited[adj[x][i]])
		{
			dfs(adj[x][i]);
		}
		dp[x] = max(dp[x],1+dp[adj[x][i]]);
	}
}

int main()
{
	fast
	int n,m;
	cin>>n>>m;
	adj.resize(n);
	dp.resize(n);
	visited.resize(n);
	int x,y;
	REP(i,m)
	{
		cin>>x>>y;
		x--;
		y--;
		adj[x].pb(y);
	}
	//cout<<adj.size()<<endl;
	//displayDouble(adj);
	REP(i,n)
	{
		if(!visited[i])
		{
			dfs(i);
		}
	}
	int ans = 0;
	REP(i,n)
		ans = max(ans,dp[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 12020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a, b;
  cin >> a >> b;
  if (a + b == 15) cout << "+" << endl;
  else if (a * b == 15) cout << "*" << endl;
  else cout << "x" << endl;  

  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;
const lint INF = 1LL << 60;

const double PI = acos(-1);
const double Rad2Deg = 180.0 / PI;
const double Deg2Rad = PI / 180.0;

int main() {
    lint A, B;
    cin >> A >> B;

    int g = 1;
    for (int i = 2; i <= min(A, B); i++) {
        if (A % i == 0 && B % i == 0) {
            g = i;
        }
    }
    lint ans = A * B;
    cout << ans / g << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  ll n, k, ans = 0, tot0 = 0, tot1 = 0, t;
  cin >> n >> k;
  vector<ll> a(n), cnt(n), cnts(n);
  rep(i, n) cin >> a[i];
  rep(i, n) for (int j = i + 1; j < n; ++j) if (a[i] > a[j]) tot0++;
  rep(i, n) rep(j, n) if (a[i] > a[j]) tot1++;

  ans += tot0 * k;
  ans %= MOD;
  t = (k - 1) * k / 2 % MOD;
  t *= tot1;
  t %= MOD;
  ans += t;
  ans %= MOD;

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


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

vector<vector<int>> g(4);
int visited[4] = { 0 };
bool ok = false;
int ans = 0;

void dfs(int cnt, int now){

	visited[now] = 1;

	if (cnt >= 3){
		ans++;
		return;
	}

	for (int i = 0; i < g[now].size(); i++){
		int next = g[now][i];
		if (visited[next] == 1){
			continue;
		}
		dfs(cnt + 1, next);
	}

}

int main(void){
	
	for (int i = 0; i < 3; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	dfs(0, 0);

	if (ans >= 1){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
} 


Measured memory_bytes: 256
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
    while (true) {
	var l = lines.shift().trim();
	if (l==="-") {
	    break;
	}
	const s = l.split('');
	const n = Number(lines.shift());
	let ops = [];
	for (var i=0; i<n; i++) {
	    ops.push(Number(lines.shift()))
	}
	console.log(aux(s,ops).join(''))
    }
});

function aux(s,ops)
{
    const len=s.length;
    //console.log('s: ', s);
    while (ops.length>0) {
	let op=ops.shift()
	var s=s.slice(op,len).concat(s.slice(0,op));
	//console.log('s: ', s);
    }

    return(s);
}


Measured memory_bytes: 16828
#!/usr/bin/env python3
#ABC145 C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
xy = [LI() for _ in range(n)]
ans = 0
for i in permutations(range(n),n):
    i = list(i)
    tx,ty = xy[i[0]]
    for j in i[1:]:
        sx,sy = xy[j]
        ans += ((tx-sx)**2 + (ty-sy)**2)**(0.5)
        tx,ty = sx,sy
ans = ans/math.factorial(n)
print(ans)

Measured memory_bytes: 41452
#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long int lint;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B >= C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



	


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll dp[100010][4];

int main(){
    string S; cin >> S;
    int N = S.size();
    dp[0][0] = 1;
    rep(i,N){
        rep(j,4){
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= MOD;
        }
        if(S[i] == 'A'){
            dp[i+1][1] += dp[i][0];
            dp[i+1][1] %= MOD;
        }
        if(S[i] == 'B'){
            dp[i+1][2] += dp[i][1];
            dp[i+1][2] %= MOD;
        }
        if(S[i] == 'C'){
            dp[i+1][3] += dp[i][2];
            dp[i+1][3] %= MOD;
        }
        if(S[i] == '?'){
            dp[i+1][1] += dp[i][0];
            dp[i+1][1] %= MOD;
            dp[i+1][2] += dp[i][1];
            dp[i+1][2] %= MOD;
            rep(j,4){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
            dp[i+1][3] += dp[i][2];
            dp[i+1][3] %= MOD;
            rep(j,4){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
        }
    }
    cout << dp[N][3] << endl;
}



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

using namespace std;

#define int 	long long

const int N = 1e5+5;

int n, a, b, d;
pair< pair< long long, long long >, int> p[N];

long long sz[N];
int up[N];
int cnt[N];

int Find(int x) {
	return up[x] == x ? x : up[x] = Find(up[x]);
}

#define x first.first
#define y first.second
#define id second

vector< pair<long long, int> > v;

void Luvoratory(bool fff) {
	v.clear();
	vector< pair<long long, int> >::iterator f, l;
	int pre = 1;
	bool is;
	for (int i = 1; i <= n; i++) {
		if (p[i].x != p[i-1].x) v.clear(), is = 1;
		while (p[i].x - p[pre].x > d && pre <= n) {
			pre++;
		}
		while (p[i].x - p[pre].x == d && pre <= n) {
			v.push_back({p[pre].y, p[pre].id});
			pre++;
		}
		f = lower_bound(v.begin(), v.end(), make_pair(p[i].y - d + fff, 0ll));
		if (is) {
			is = 0;
			l = v.begin();
		}
		int xx, yy;
		l = max(l, f);
		if (f == v.end() || f->first > p[i].y+d-fff) continue;
		for (; l != v.end() && l->first <= p[i].y + d - fff; l++) {
			xx = Find(l->second); 
			yy = Find(p[i].id);
			if (xx != yy) {
				up[xx] = yy;
			}
		}
		cnt[p[i].id] += (l - f);
		if (l != f) l--;
	}
}

void Bandit_s_Crescendo() {
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &p[i].x, &p[i].y);
	}
	d = abs(p[a].x - p[b].x) + abs(p[a].y - p[b].y);
	for (int i = 1; i <= n; i++) {
		int xx, yy;
		up[i] = i;
		xx = p[i].x;
		yy = p[i].y;
		p[i].x = xx - yy;
		p[i].y = xx + yy;
		p[i].id = i;
	}
	sort(p+1, p+n+1);
	Luvoratory(0);
	for (int i = 1; i <= n; i++) {
		swap(p[i].x, p[i].y);
	}
	sort(p+1, p+n+1);
	Luvoratory(1);
	for (int i = 1; i <= n; i++) {
		sz[Find(i)] += cnt[i]; 
	}
	cout << sz[Find(a)] << '\n';
}

signed main() {
	Bandit_s_Crescendo();
}

Measured memory_bytes: 6004
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y,z;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	x=a+b+c+d;
	y=x%60;
	z=x/60;
	printf("%d\n",z);
	printf("%d\n",y);
	return 0;
}

Measured memory_bytes: 1816
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int H=sc.nextInt();
        int N=sc.nextInt();
      //  int [] moves=new int[N];
        int sum_of_moves=0;
        for(int i=0;i<N;i++)
           // moves[i]=sc.nextInt();
            sum_of_moves+=sc.nextInt();
        String output=(sum_of_moves>=H)?"Yes":"No";
        System.out.print(output);
    }
}

Measured memory_bytes: 49744
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  
  int cnt = 0;
  REP(i,n) cnt ^= a[i];

  if(cnt == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 1024
a,b,k=map(int,input().split())
if (b-a+1)>=2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
# 整数の入力
import sys
s = input()
k = int(input())
# print (s,k)
n=len(s)
# print (s[0],s[n-1])

skip=0
if n == 1: 
    print((k-1) // 2 + (k-1) % 2 )
    sys.exit(0)

flag=0
for i in range(1,n):
    #print("loop",i)
   if s[i] != s[i-1]:
       flag =1
       break

if flag == 0: 
    print((k*n-1) // 2 + (k*n-1) % 2 )
    sys.exit(0)
p=0
q=0
if s[0] == s[n-1]:
    l=1 
    # Start 
    for i in range(1,n):
        #print("loop",i)
        if s[i] == s[i-1]:
            p +=1
        else:
            break
    if l < n:
        for i in range(n-2,0,-1):
            if s[i] == s[i+1]:
                q +=1
            else:
                break
    l = 1 + p + q
    # print("Ring ", l, p,q)
    op = ((l // 2) + (l % 2)) * (k-1)
    op += ((p // 2) + (p % 2)) 
    op += ((q // 2) + (q % 2))
else: 
    op = 0     

# print("OP",op)

if s[0] == s[n-1]:
    s2 = s[p+1:n-1-q] 
else:
    s2 = s
#print("s2",s2)
n=len(s2)
            

l = 0
for i in range(1,n):
    # print(s2[i],i,l,op)
    if s2[i-1] != s2[i]:
        op += (l // 2 + l % 2) * k
        l = 0 
    else:
        l += 1 
if l != 0:
    op += (l // 2 + l % 2) * k

        
print(op)

Measured memory_bytes: 3188
#ABC-129-C
N, M = map(int, input().split())
# N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

dp = [0] * (N+1)
#どうやってもスタート地点から始まるから、0に行く方法は1通りのみ
dp[0] = 1

#1が壊れていなければ1に行く方法は0->1の1通りのみ
if 1 not in a:
    dp[1] = 1
    not_broken_stairs = set(range(2, N+1)) - set(a)
else:
    not_broken_stairs = set(range(1, N+1)) - set(a)    

#i=2or3から始まる。
#１が壊れていなければ2に行く方法は(0->2の1通り)+(1->2の1通り)で2通り。
for i in not_broken_stairs:
    dp[i] = dp[i-2] + dp[i-1]
    
print(dp[-1] % (10 ** 9 + 7))

Measured memory_bytes: 467428
#include <iostream>
#include <string>

using namespace std;

int main(void){
    string s;
    cin >> s;
    int counter = 0;
    if(s[0] == 'o') ++counter;
    if(s[1] == 'o') ++counter;
    if(s[2] == 'o') ++counter;
    cout << 700 + (100 * counter) << endl;
}

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

typedef pair<int, int> P;
typedef pair<P, int> PP;

int main() {
    int N, M;
    cin >> N >> M;
    vector<PP> C(M);
    for (int i = 0; i < M; i++) {
        int p, y;
        cin >> p >> y;
        C[i] = PP(P(p, y), i);
    }

    sort(C.begin(), C.end());
    vector<P> res(M);
    int cnt = 0, pre = 0;
    for (int i = 0; i < M; i++) {
        P c = C[i].first;
        if (c.first == pre) {
            cnt++;
        } else {
            cnt = 1;
        }
        pre = c.first;

        res[C[i].second] = P(pre, cnt);
    }

    for (int i = 0; i < M; i++) {
        printf("%.6d%.6d\n", res[i].first, res[i].second);
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

ll a, b, n;

ll calc(ll x) {
    return (a * x) / b - a * (x / b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cin >> a >> b >> n;
    ll res = 0;
    ll ng = -1, ok = n + 1, mid;
    while (abs(ok - ng) > 1) {
        mid = (ok + ng) / 2;
        ll tmp = calc(mid);
        if (tmp < res) {
            ok = mid;
        } else {
            ng = mid;
            res = max(res, tmp);
        }
    }
    cout << res << endl;
    
    return 0;
}



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

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    dbg_out(T...);
}
#ifdef LOCAL
    #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", dbg_out(__VA_ARGS__)
#else
    #define dbg(...) 42
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int h, n;
    cin >> h >> n;
    int sum = 0;
    fr(i, 0, n){
        int x; cin >> x; sum += x;
    }
    if(sum >= h) cout << "Yes";
    else cout << "No";
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

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

using namespace std;

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

    long long n, ans = 0;
    cin >> n;
    set<long long> s, s2;

    for (long long i = 2; i * i <= n; i++)
        if (n % i == 0)
            s.insert(i), s.insert(n / i);

    for (long long i = 2; i * i < n; i++)
        if ((n - 1) % i == 0)
            s2.insert(i), s2.insert((n - 1) / i);

    for (auto x : s) {
        long long tmp = n;
        while (tmp % x == 0)
            tmp /= x;
        ans += (tmp % x == 1);
    }

    for (auto x : s2)
        if (s.find(x) == s.end())
            ans++;
    ans += (n > 2) + 1;

    cout << ans << "\n";

    return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
    int N, A, B, X[MAX];
    cin >> N >> A >> B;
    rep(i, N) {
        cin >> X[i];
    }
    
    ll ans = 0;
    rep(i, N - 1) {
        if ((ll)(X[i + 1] - X[i]) * A < B) {
            ans += (ll)(X[i + 1] - X[i]) * A;
        } else {
            ans += B;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if (s[i]==',') cout<<' ';
    else cout<<s[i];
  }
  cout<<endl;
  return 0;
}

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

int main(){
    int a, b, c;
    string op ;
    cin >> a >> op >> b ;
    while(op != "?"){
        if(op == "+") c = a + b ;
        if(op == "-") c = a - b ;
        if(op == "*") c = a * b ;
        if(op == "/") c = a / b ;
        cout << c << endl ;
        cin >> a >> op >> b ;
    }
    return 0 ;
}


Measured memory_bytes: 3140
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = [0] * N
    for i in range(N-1,-1,-1):
        if sum(b[i::i+1]) % 2 != a[i]:
            b[i] += 1
    print(b.count(1))
    for i in range(len(b)):
        if b[i] == 1:
            print(i+1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9032
#!/usr/bin/env python3

def main():
    H, W = map(int, input().split())

    c = []
    for i in range(10):
        c.append(list(map(int, input().split())))

    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k]+c[k][j])

    A = []
    for i in range(H):
        A.extend(list(map(int, input().split())))

    print(sum(map(lambda i: c[i][1] if i >= 0 else 0, A)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3496
// 2015/05/19 Tazoe

#include <iostream>
using namespace std;

int main()
{
	bool is_prime[1000000];		// 素数かどうかのテーブル

	is_prime[0] = is_prime[1] = false;
	for(int i=2; i<1000000; i++){
		is_prime[i] = true;
	}

	for(int i=2; i*i<1000000; i++){
		if(is_prime[i]){
			for(int j=i*i; j<1000000; j+=i){
				is_prime[j] = false;
			}
		}
	}

	int n_prime[1000000];		// 素数の個数のテーブル

	int cnt = 0;
	for(int i=0; i<1000000; i++){
		if(is_prime[i]){
			cnt++;
		}
		n_prime[i] = cnt;
	}

	while(true){
		int n;
		cin >> n;

		if(cin.eof())
			break;

		cout << n_prime[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 6040
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - (y2 - y1)
y3 = y2 + x2 - x1
x4 = x1 - (y2 - y1)
y4 = y1 + x2 - x1
print(f"{x3} {y3} {x4} {y4}")

Measured memory_bytes: 9016
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int l = 0;
    int r = 0;
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        if (a < x) l++;
        if (x < a) r++;
    }
    cout << min(l, r) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

ll f(ll n, ll x)
{
    if (n == -1) return 0;
    return n / x+1;
}

int main()
{
    ll a, b, x; cin >> a >> b >> x;
    cout << f(b, x) - f(a-1, x) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
long double a,b,c,delta;
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b>>c;
	//sqrt(a)+sqrt(b)<sqrt(c)
	//a+2*sqrt(ab)+b<c
	delta=a*b;
	delta=sqrt(delta);
	delta*=2;
	if(a+b+delta<c){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    string s;
    cin >> s;
    
    auto check = [](string s) -> bool {
        repeat (i, s.length()) {
            char c = s[i];
            if (c == 'A' or c == 'C' or c =='G' or c == 'T') continue;
            return false;
        }
        return true;
    };
    
    int ans = 0;
    repeat (i, s.length()) {
        repeat_from (j, 1, s.length() + 1) {
            if (i + j > (lint)s.length()) break;
            string ss = s.substr(i, j);
            if (check(ss)) ans = max(ans, (int)ss.length());
        }
    }
    cout << ans << endl;
}

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

int gcd(int x, int y) {
    if (x < y) {
        return gcd(y, x);
    } else if (x >= y && y!=0) {
        return gcd(y, x % y);
    } else {
        return x;
    }
}

int main()
{
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}

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

int main() {
    char b;
    cin >> b;
    if (b == 'A')
        cout << 'T' << endl;
    else if (b == 'C')
        cout << 'G' << endl;
    else if (b == 'G')
        cout << 'C' << endl;
    else 
        cout << 'A' << endl;
    return 0;
}

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

//#define DEBUG
typedef long long LL;
const int maxn = 55;
LL a[maxn];
LL C[maxn][maxn];
int n, l, r;

void init() {
	for (int i=1; i<maxn; ++i) {
		C[i][i] = C[i][0] = 1;
		for (int j=1; j<i; ++j)
			C[i][j] = C[i-1][j] + C[i-1][j-1];
	}

	#ifdef DEBUG
	for (int i=1; i<=50; ++i) {
		for (int j=0; j<=i; ++j)
			printf("%lld ", C[i][j]);
		putchar('\n');	
	}
	#endif
}

inline LL calc(int n, int m) {
	return C[n][m];
}

int main() {
	#ifdef DEBUG
		freopen("data.in", "r", stdin);
		freopen("data.out", "w", stdout);
	#endif

	init();
	double ans = 0;

	scanf("%d %d %d", &n, &l, &r);
	for (int i=0; i<n; ++i)
		scanf("%lld", &a[i]);
	sort(a, a+n, greater<LL>());
	for (int i=0; i<l; ++i)
		ans += a[i];
	ans /= l;

	printf("%.10lf\n", ans);

	LL x = a[l-1];
	int c = 0, pc = 0;
	for (int i=0; i<n; ++i) {
		if (a[i] == x)
			++c;
		else if (a[i] > x)
			++pc;
	}
	
	LL kind = 0;

	if (a[0] != x) {
		for (int i=l; i<=l; ++i) {
			int nc = i - pc;
			if (nc > c) continue;

			kind += calc(c, nc);
		}
	} else {
		for (int i=l; i<=r; ++i) {
			int nc = i - pc;
			if (nc > c) continue;

			kind += calc(c, nc);
	//		cout << kind << endl;
		}
	}

	cout << kind << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long x, a, b;

int main(){
    scanf("%ld%ld%ld", &x, &a, &b);
    printf("%ld\n", (x-a)%b);
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a, b;  cin >> x >> a >> b;
    if (abs(x - a) > abs(x - b)) {
      cout << "B" << '\n';
    } else {
      cout << "A" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node{
  struct Node *right;
  struct Node *left;
  struct Node *parent;
  int key;
};

struct Node *root,*NIL;

void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

while(x!=NIL){
y=x;
if(z->key < x->key){
  x=x->left;
}
else{
  x=x->right;
}
}
z->parent=y;
if(y==NIL){
  root=z;
}
else{
  if(z->key < y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }
}
}

void inorder(struct Node *u){
if(u==NIL)return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(struct Node *u){
if(u==NIL)return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if (strcmp(com,"insert")==0 ){
      scanf("%d", &x);
insert(x);
  }
  else if(strcmp(com,"print")==0){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
  }
}
  return 0;
}



Measured memory_bytes: 25140
import sys
from collections import Counter, deque, defaultdict, OrderedDict
from math import factorial
from fractions import Fraction
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))

n = INT()
x = [0]*n
y = [0]*n
res = 0
for i in range(n):
    xx, yy = MAP()
    x[i] = xx
    y[i] = yy
dist = [[0]*n for i in range(n)]
for i in range(n):
    for j in range(n):
        dist[i][j] = math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)

p_list = list(itertools.permutations([i for i in range(n)], n))
for per in p_list:
    temp = list(per)
    for i in range(n-1):
        res += dist[temp[i]-1][temp[i+1]-1]

print(res/len(p_list))



Measured memory_bytes: 72808
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
cnt = 0
while A:
    a, b = A.pop(), B.pop()
    cnt += -(a + cnt) % b
print(cnt)

Measured memory_bytes: 11048
S = gets.chomp

p 0 and exit if S.length == 1

s1 = ''
s2 = ''
if S.length.even?
  s1 = S[0..(S.length/2)-1]
  s2 = S[(S.length/2)..-1].reverse
else
  s1 = S[0..(S.length/2)-1]
  s2 = S[(S.length/2)+1..-1].reverse
end

cnt = 0
s1.length.times do |i|
  cnt += 1 if s1[i] != s2[i]
end

p cnt

Measured memory_bytes: 1788
// C - Scc Puzzle
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define irp(i,n) for(int i=(n);i>=0;i--)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
// #define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define vecmax(v) (*max_element(v.begin(),v.end()))
#define range(v,x) (iota((v).begin(),(v).end(),(x)))
void bye(auto x, int code=0){cout<<(x)<<endl;exit(code);}
// int in(){int x;cin>>x;return x;}
int in(){int x;scanf("%d",&x);return x;}
// template<class T> T in(){T x;cin>>x;return x;}

void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
void vvprn(vector<vector<int>> &vv){ for(auto v:vv) vprn(v); }

// template<class T> void vprn(T &v, string s, string m, string e)
// {cout<<s;for(int i=0;i<v.size();i++)cout<<v[i]<<m;cout<<e;}
// template<class T> void vvprn(T &vv, string s, string m, string e)
// {for(auto v:vv) vprn(v,s,m,e);}

int main(){
	ll s,c; cin>>s>>c;
	ll ans = 0;

	// cout<<s<<","<<c<<","<<ans<<"\n";//
	if(s*2<=c){
		ans += s;
		c -= s*2;
		s = 0;
	}
	// cout<<s<<","<<c<<","<<ans<<"\n";//

	ll c2 = c/2;
	if(s>=c2){
		ans += c2;
		s -= c2;
		c -= c2*2;
	}
	// cout<<s<<","<<c<<","<<ans<<"\n";//

	ans += c/4;

	ote(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
 
using namespace std;
 
typedef unsigned long long ull;
 
int t[100000];
 
bool judge(int N, string s)
{
    for (int i = 2; i < N; i++)
    {
        auto isBothAnimal = s[i - 1] == 'o' ? true : false;
        
        // 羊, 羊, X
        if (t[i - 2] == 0 && t[i - 1] == 0)
        {
            t[i] = isBothAnimal ? 0 : 1;
        }
        // 羊, 狼, X
        else if (t[i - 2] == 0 && t[i - 1] == 1)
        {
            t[i] = isBothAnimal ? 1 : 0;
        }
        // 狼, 羊, X
        else if (t[i - 2] == 1 && t[i - 1] == 0)
        {
            t[i] = isBothAnimal ? 1 : 0;
        }
        // 狼, 狼, X
        else if (t[i - 2] == 1 && t[i - 1] == 1)
        {
            t[i] = isBothAnimal ? 0 : 1;
        }
    }
    
    bool isFirstOk = false;
    if (t[0] == 0)
    {
        if (s[0] == 'o' && t[N - 1] == t[1])
        {
            isFirstOk = true;
        }
        else if (s[0] == 'x' && t[N - 1] != t[1])
        {
            isFirstOk = true;
        }
    }
    else
    {
        if (s[0] == 'o' && t[N - 1] != t[1])
        {
            isFirstOk = true;
        }
        else if (s[0] == 'x' && t[N - 1] == t[1])
        {
            isFirstOk = true;
        }
    }
    
    bool isEndOk = false;
    if (t[N - 1] == 0)
    {
        if (s[N - 1] == 'o' && t[N - 2] == t[0])
        {
            isEndOk = true;
        }
        else if (s[N - 1] == 'x' && t[N - 2] != t[0])
        {
            isEndOk = true;
        }
    }
    else
    {
        if (s[N - 1] == 'o' && t[N - 2] != t[0])
        {
            isEndOk = true;
        }
        else if (s[N - 1] == 'x' && t[N - 2] == t[0])
        {
            isEndOk = true;
        }
    }
    
    return isFirstOk && isEndOk;
}
 
void print(int N)
{
    for (int i = 0; i < N; i++)
    {
        printf("%s", t[i] == 0 ? "S" : "W");
    }
    printf("\n");
}
 
int main()
{
    int N;
    string s;
    
    cin >> N;
    cin >> s;
    
    // 羊、羊
    t[0] = 0;
    t[1] = 0;
    if (judge(N, s))
    {
        print(N);
        return 0;
    }
    
    // 羊、狼
    t[0] = 0;
    t[1] = 1;
    if (judge(N, s))
    {
        print(N);
        return 0;
    }
 
    // 狼、羊
    t[0] = 1;
    t[1] = 0;
    if (judge(N, s))
    {
        print(N);
        return 0;
    }
 
    // 狼、狼
    t[0] = 1;
    t[1] = 1;
    if (judge(N, s))
    {
        print(N);
        return 0;
    }
    
    printf("-1\n");
    
    return 0;
}


Measured memory_bytes: 896
N, K = map(int, input().split())
R, S, P = map(int, input().split())
dic = {'r': P, 's': R, 'p': S}
ans_dic = {'r': 'p', 's': 'r', 'p': 's'}
T = list(input())

result = 0
ans = []

for t in range(N) :
  if t < K :
    result += dic[T[t]]
    ans.append(ans_dic[T[t]])
  else :
    if ans[t-K] == ans_dic[T[t]] :
      if t+K < N :
        ans.append(T[t+K])
      else :
        continue
    else :
      result += dic[T[t]]
      ans.append(ans_dic[T[t]])

print(result)


Measured memory_bytes: 4792
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}


immutable real EPS = 1e-9;

struct Point {
    real x, y;
    Point opBinary(string op)(in Point p) const if (op == "+" || op == "-") {
        return Point(mixin("x" ~ op ~ "p.x"), mixin("y" ~ op ~ "p.y"));
    }
    Point opBinary(string op)(real k) const if (op == "*" || op == "/") {
        return Point(mixin("x" ~ op ~ "k"), mixin("y" ~ op ~ "k"));
    }
};
real dot(in Point a, in Point b) { return a.x * b.x + a.y * b.y; }
real cross(in Point a, in Point b) { return a.x * b.y - a.y * b.x; }
real norm(in Point a) { return sqrt(dot(a, a)); }
Point rot90(in Point p) { return Point(-p.y, p.x); }
real angle(in Point a) { return atan2(a.y, a.x); }

const int CW = -1;
const int CCW = 1;
int ccw(Point a, Point b, Point c){
    b = b - a; c = c - a;                                          
    if (cross(b, c) > EPS) return +1;      // a,b,c????????????????¨???¨???
    if (cross(b, c) < -EPS) return -1;     // a,b,c?????????????¨???¨???                       
    if (dot(b, c) < 0) return +2;          // c--a--b ??´???                       
    if (norm(b) < norm(c)) return -2;      // a--b--c ??´???                       
    return 0;                              // a--c--b ??´???
}

struct Segment {
    Point a, b;
};
bool contains(in Segment s, in Point p) {
    return ccw(s.a, s.b, p) == 0;
}

struct Polygon {
    Point[] vs;
}
bool intersects(in Segment s, in Segment t) {
    return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
bool contains(in Polygon polygon, in Point p) { // ?????????p???????????´????????????
    auto vs = polygon.vs;
    int N = cast(int)vs.length;
    int next(int i) { return (i + 1) % N; }
    auto t = Segment(p, Point(1e8 + 7, 2e7 + 9));
    int count = 0;
    foreach (i; 0 .. N) {
        auto s = Segment(vs[i], vs[next(i)]);
        if (t.intersects(s)) {
            count++;
        }

    }
    return count % 2 == 1;
}

void main() {
    int N; readf("%d\n", &N);
    auto vs = new Point[N];
    foreach (ref v; vs) {
        readf("%s %s\n", &v.x, &v.y);
    }
    int Q; readf("%d\n", &Q);
    auto poly = Polygon(vs);
    foreach (q; 0 .. Q) {
        Point p; readf("%s %s\n", &p.x, &p.y);
        int f() {
            foreach (i, v; vs) {
                if (Segment(v, vs[(i + 1) % N]).contains(p)) return 1;
            }
            if (poly.contains(p)) {
                return 2;
            }
            return 0;
        }
        writeln(f());
    }
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define pb push_back
#define mk make_pair
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    fastIO;
    //ll n;
    //cin>>n;
    string str;
    cin>>str;
    ll val;
    vector<string>v;
    v.pb("SUN");v.pb("MON");v.pb("TUE");v.pb("WED");v.pb("THU");v.pb("FRI");v.pb("SAT");
    ll pos=find(v.begin(),v.end(),str)-v.begin();
    val=7-pos;
    cout<<val<<'\n';
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int sum=0;
  int t[N+1];
  for(int i=1;i<N+1;i++){
    cin >> t[i];
    sum+=t[i];
  }
  int M;
  cin >> M;
  for(int i=0;i<M;i++){
    int p,x;
    cin >> p >> x;
    cout << sum-t[p]+x << endl;
  }
}
      

Measured memory_bytes: 256
N, K = map(int, input().split())
A1 = list(map(int, input().split()))
A2 = A1 * 2
cnt1 = 0
cnt2 = 0
mod = 10**9+7
for i in range(2*N-1):
    for j in range(i+1, 2*N):
        if i <= N-2 and j <= N-1:
            if A1[i] > A1[j]:
                cnt1 += 1
        if A2[i] > A2[j]:
            cnt2 += 1
print((cnt1*K%mod + (cnt2-cnt1*2)*(K-1)*K//2%mod)%mod)

Measured memory_bytes: 42476
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
    cin>>n;
    vector<int> a(n);
    for(int i= 0;i<n;i++){
        cin>>a.at(i);
    }

    int tmp = 0;
    while(a.at(0)%2 ==0){
        a.at(0) /=2;
        tmp+=1;
    }

    if(n==1){
        cout<<tmp<<endl;
    }
    else{
        int cnt = tmp;
        for(int i=1;i<n;i++){
            tmp = 0;
            while(a.at(i)%2==0){
                a.at(i) /=2;
                tmp +=1;
            }
            if(tmp<cnt){
                cnt = tmp;
            }
        }
        cout <<cnt<<endl;
    }
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int check(string s) {
    if (s == "Male") return 1;
    if (s == "Female") return 2;
    return 0;
}

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

    string s;
    cout << 0 << endl;
    cin >> s;
    int e = check(s);

    if (e == 0) return 0;

    ll r = n, l = -1;
    while (1) {
        ll mid = (l + r) / 2;
        cout << mid << endl;
        cin >> s;
        int res = check(s);
        if (res == 0) return 0;
        if (mid&1) {
            if (e == res) r = mid;
            else l = mid;
        }
        else {
            if (e == res) l = mid;
            else r = mid;
        }
    }

    return 0;
}

Measured memory_bytes: 852
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#define EPS (1e-7)
using namespace std;






int main() {


	int N;
	cin >> N;
	vector<int> a(100000,0);
	int temp;
	int ans = 0;
	for (auto i = 0; i < N; i++)
	{
		cin >> temp;
		a[temp] += 1;
 	}


		for (auto i = 0; i < 100000 - 2; i++)
		{
			ans = max(ans, a[i] + a[i + 1] + a[i + 2]);

		}



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

Measured memory_bytes: 640