akhauriyash/Code-Regression huggingface dataset:
import Data.List

main = do
  n <- readLn :: IO Int
  as <- fmap (map read . words) getLine :: IO [Int]
  print . solve . sort $ zipWith (\x y -> x - y) as [1..]

snk :: [Int] -> Int -> Int
snk as b = sum $ map (\a -> abs(a - b)) as

solve :: [Int] -> Int
solve bs = minimum $ map (snk bs) candidates
  where
    n = length bs
    optb = bs !! (div n 2)
    candidates = [(optb - 1)..(optb + 1)]



Measured memory_bytes: 83196
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
if n%2 == 0:
  s = sum(l[:((n-1)//2)+1])*2 - l[0]
else:
  s = sum(l[:(((n-1)//2))])*2 - l[0] + l[((n-1)//2)]
print(s)

Measured memory_bytes: 31448
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

int n, m, q, N, Mod, g;
vector<int> uf;
vector<int> A, B, C;
vector<boolean> f[2];

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}
int _abs(int x) {
	return x < 0 ? -x : x;
}

int find(int x) {
	return uf[x] == x ? x : (uf[x] = find(uf[x]));
}
void unit(int x, int y) {
	x = find(x), y = find(y);
	(x ^ y) && (uf[x] = y);
}

void init(vector<boolean>& f, int r) {
	f.resize(Mod, false);
	while (!f[r]) {
		f[r] = true;
		r = 4 * r % Mod;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> m >> q >> Mod;
	uf.resize(N = 6 * n);
	A.resize(m);
	B.resize(m);
	C.resize(m);
	for (int i = 0; i < m; i++) {
		cin >> A[i] >> B[i] >> C[i];
		if (i) {
			g = gcd(g, _abs(C[i] - C[0]));
		}
	}
	if (!g)
		g = Mod;
	Mod = gcd(3 * g, Mod);
	int R = C[0] % g;
	for (int i = 0; i < N; i++)
		uf[i] = i;
	for (int i = 0; i < m; i++) {
		--A[i], --B[i], C[i] = (C[i] - R) / g;
		for (int k = 0; k < 3; k++) {
			for (int r = 0; r < 2; r++) {
				int cs = (k << 1) | r;
				int ns = (((k << 1) + C[i]) % 3) << 1 | (r ^ 1);
				unit(A[i] * 6 + cs, B[i] * 6 + ns);
				unit(A[i] * 6 + ns, B[i] * 6 + cs);
			}
		}
	}
	init(f[0], R);
	init(f[1], R * 2 % Mod);
	while (q--) {
		int s, t, r;
		cin >> s >> t >> r;
		boolean res = false;
		--s, --t;
		for (int k = 0; k < 3; k++) {
			int nv = (r + R - k * g) % Mod;
			(nv < 0) && (nv += Mod);
			for (int p = 0; p < 2; p++) {
				if (find(t * 6) == find(s * 6 + k * 2 + p)) {
					res = res || f[p][nv];
				}
			}
		}
		cout << ((res) ? ("YES") : ("NO")) << '\n';
	}
	return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>
 
int main(){
    int i, j, r, c;
    int chart[100][100];
    int row[100]={0}, column[100]={0};
    int sum=0;
     
    scanf(" %d %d", &r, &c);
    for(i=0; i<r; ++i){
        for(j=0; j<c; ++j){  
            scanf(" %d", &chart[i][j]);
            row[i] += chart[i][j];
        }
    }
     
    for(i=0; i<c; ++i){
        for(j=0; j<r; ++j){  
            column[i] += chart[j][i];
        }
        sum+=column[i]; 
    }
     
    for(i=0; i<r; ++i){
        for(j=0; j<c; ++j){  
            printf("%d ", chart[i][j]);
        }
        printf("%d\n", row[i]);
    }
     
    for(i=0; i<c; ++i)
        printf("%d ", column[i]);
    printf("%d\n", sum);
     
    return 0;
}


Measured memory_bytes: 2056
from sys import stdin
n = int(stdin.readline())
a = []
b = []
for _ in xrange(n):
 x,y = map(int,stdin.readline().split())
 a.append(x)
 b.append(y)
x = a[0]
y = b[0]
for i in xrange(1,n):
 fir = a[i]
 sec = b[i]
 if fir>=x and sec >= y:
  x = fir;y=sec
 elif fir>=x:
  k = y/sec
  if y%sec:
   k+=1
  x = fir * k
  y = sec * k
 elif sec>=y:
  k = x/fir
  if x%fir:
   k += 1
  x = fir * k
  y = sec * k
 else:
  u = x/fir
  if x%fir:
   u+=1
  v = y/sec
  if y%sec:
   v+=1
  k = u
  if v > k:
   k = v
  x = fir * k
  y = sec * k
 
 
 
print x + y

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

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

  int ans = 0;
  for (int i = 1; i <= N; i += 2)
  {
    int d = 0;
    for (int j = 1; j <= i; j++)
    {
      if (i % j == 0) d++;
    }
    if (d == 8) ans++;
  }
  
  cout << ans << endl;
}

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

//const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

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

  ll k;
  cin >> k;
  cout << 50 << endl;
  ll a[50];
  for (int i = 0; i < 50; i++) {
    a[i] = i+k/50;
  }
  for (int i = 0; i < k%50; i++) {
    a[49-i]++;
  }
  for (int i = 0; i < 50; i++) {
    cout << a[i];
    if (i != 49) cout << " ";
    else cout << endl;
  }
  return 0;
}


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

int main(){
    int l,r,d;
    cin >> l >> r >> d;
    int count = 0;
    for(int i=l; i<=r; i++){
        if(i % d == 0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

#define INFINITY 2000000000

using namespace std;

int main(){

	int V,E,from,to,dist;

	scanf("%d %d",&V,&E);
	long long int table[V][V];

	for(int i = 0; i < V; i++){
		for(int k = 0; k < V; k++){
			if(i != k){
				table[i][k] = INFINITY;
			}else{
				table[i][k] = 0;
			}
		}
	}

	for(int i = 0; i < E; i++){
		scanf("%d %d %d",&from,&to,&dist);
		table[from][to] = dist;
	}

	for(int k = 0; k < V; k++){
		for(int i = 0; i < V; i++){
			if(table[i][k] == INFINITY)continue;
			for(int j = 0; j < V; j++){
				if(table[k][j] == INFINITY)continue;
				table[i][j] = min(table[i][j],table[i][k]+table[k][j]);
			}
		}
	}

	bool FLG = true;

	for(int i = 0; i < V; i++){
		if(table[i][i] < 0){
			FLG = false;
			break;
		}
	}

	if(!FLG)printf("NEGATIVE CYCLE\n");
	else{
		for(int i = 0; i < V; i++){
			if(table[i][0] == INFINITY)printf("INF");
			else{
				printf("%lld",table[i][0]);
			}

			for(int k = 1;k < V; k++){
				if(table[i][k] == INFINITY)printf(" INF");
				else{
					printf(" %lld",table[i][k]);
				}
			}
			printf("\n");
		}
	}

    return 0;
}

Measured memory_bytes: 2820
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int H, A;
	cin >> H >> A;
	cout << (H + A - 1) / A << endl;
}

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

int dis[2010];
int ans[2010];
int main() {
  int n,x,y;
  cin >> n >> x >> y;
  --x;--y;
  dis[x]=0;
  dis[y]=1;
  for(int i=0;i<n;i++){
    dis[i]=min(abs(x-i),abs(y-i)+1);
  }
  rep(i,n){
    rep(j,i){
      int now=min(dis[i]+dis[j],i-j);
      ans[now]+=1;
    }
  }
  for (int i=1;i<n;i++){
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define fi first
#define se second
 
const ll MOD = 1000000007;

int main() {
   int n; scanf("%d", &n);
   vector<pi> j(n);
   for (auto& i : j)
      scanf("%d%d", &i.se, &i.fi);
   sort(j.begin(), j.end());
   int cur = 0;
   bool ans = true;
   for (auto i : j) {
      cur += i.se;
      if (cur > i.fi)
         ans = false;
   }
   puts(ans ? "Yes" : "No");
}

Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
import math

N, D = map(int, input().split())
List = [list(map(int, input().split())) for i in range(N)]

ans=0
for i in range(N):
    if D>=math.sqrt(((List[i][0])**2)+((List[i][1])**2)):
        ans+=1

print(ans)
    
    
    

Measured memory_bytes: 45464
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b;
    cin >> a >> b;
    if (a == b) cout << 2 * a << endl;
    else if (a > b) cout << 2 * a - 1 << endl;
    else cout << 2 * b - 1 << endl;
}

int main() {
    solve();
    
    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll x, y, z;
    cin >> x >> y >> z;
    ll res = x / (y + z);
    // dump(res);
    // dump(res % (y + z));
    if (x % (y + z) < z)
        cout << res - 1 << endl;
    else
        cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// Um_nik氏
// https://atcoder.jp/contests/agc041/submissions/9181788
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const int N = 1010;
int n;
char s[N][N];
char a[4][5] = {
    "aabc",
    "ddbc",
    "efgg",
    "efhh"
};
char b[5][6] = {
    "aabbc",
    "dee.c",
    "d..fg",
    "h..fg",
    "hiijj"
};
char c[7][8] = {
    "aabbc..",
    "d...cee",
    "dffgg..",
    "hh...ij",
    "..k..ij",
    "..k..lm",
    "...nnlm"
};

void solve(vector<int> w){
    int p = 0;
    for(int x : w){
        if(x == 4)      rep(i, x) rep(j, x) s[p + i][p + j] = a[i][j];
        else if(x == 5) rep(i, x) rep(j, x) s[p + i][p + j] = b[i][j];
        else if(x == 7) rep(i, x) rep(j, x) s[p + i][p + j] = c[i][j];
        p += x;
    }
}

int main(){
    scanf("%d", &n);
    if(n == 2){
        printf("-1\n");
        return 0;
    }
    rep(i, n) rep(j, n) s[i][j] = '.';
    if(n % 3 == 0){
        repex(i, 0, n, 3) s[i][i] = s[i][i + 1] = s[i + 1][i + 2] = s[i + 2][i + 2] = 'a';
    }else{
        if(n == 7){
            solve({7});
        }else if (n == 11){
            solve({4, 7});
        }else{
            vector<int> w;
            int x = n;
            while(x % 4 != 0){
                w.push_back(5);
                x -= 5;
            }
            if(x < 0) throw;
            while(x > 0){
                w.push_back(4);
                x -= 4;
            }
            solve(w);
        }
    }
    rep(i, n){
        s[i][n] = '\0';
        printf("%s\n", s[i]);
    }
    return 0;
}

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

#define ll long long
#define mod 1000000007

int main() {
    ll n;
    cin>>n;
    ll h[n+1];
    for(ll i=0;i<n;i++){
        cin>>h[i+1];
    }
    ll dp[n+1][2];
    for(ll i=0;i<=n;i++)
        for(ll j=0;j<2;j++)dp[i][j]=0LL;
    h[0]=h[1];
    for(ll i=2;i<=n;i++){
        dp[i][0]=min(dp[i-1][0] ,dp[i-1][1] ) + abs(h[i]-h[i-1]) ;
        dp[i][1]=min(dp[i-2][1],dp[i-2][0] ) +abs(h[i]-h[i-2]);
    }
    cout<<min(dp[n][0],dp[n][1]);
    return 0 ;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    long long ans=0;
    string s;
    cin>>s;
    for (int j=0;j<(1<<(s.size()-1));j++) {
        long long ps=0;
        for (int i=0;i<s.size();i++) {
            ps=ps*10+s[i]-'0';
            if (i==s.size()-1||j>>i&1){
                ans+=ps;
                ps=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    //start from here

    readb(n, m)
    int a[n+2] = {}, l , r;

    fori (i, 1, m)
    {
        cin >> l >> r;
        a[l]++; a[r+1]--;
    }

    fori (i, 1, n) a[i] += a[i-1];

    int cnt = 0;

    fori (i, 1, n) if(a[i] == m) cnt++;

    print(cnt)

    return 0;
}


Measured memory_bytes: 1024
// AOJ 1239: Viva Confetti
// 2017.12.18 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define EPS 1e-20

typedef struct { double x, y, r; } C;
C c[101]; int n;

double dist(double x1, double y1, double x2, double y2)
{
	return hypot(x1-x2, y1-y2);
}

int intersect(C c1, C c2, double *cx1, double *cy1, double *cx2, double *cy2)
{
	double x1 = c1.x, y1 = c1.y, r1 = c1.r;
	double x2 = c2.x, y2 = c2.y, r2 = c2.r;
	double d = dist(x1, y1, x2, y2);
	double w, n, x, y, p, q;
	double u, v;

	u = r1+r2, v = fabs(r1-r2);

	if ((fabs(d-u) > EPS && d >= u) || fabs(v-d) > EPS && d <= v) return 0;
	w = ((r1*r1 - r2*r2)/d + d) / 2;
	n = sqrt(r1*r1 - w*w);
	x = x1 + (x2-x1)*w / d;
	y = y1 + (y2-y1)*w / d;
	p = (y2-y1)*n / d;
	q = (x2-x1)*n / d;

	*cx1 = x+p, *cx2 = x-p;
	*cy1 = y-q; *cy2 = y+q;
	if (fabs(d-u) <= EPS) return 1;
	if (d == r1+r2) return 1;
	return 2;
}

int include_circle(int i, int j)
{
	double d = hypot(c[i].x-c[j].x, c[i].y-c[j].y);
	double x = c[i].r - (d + c[j].r);
	if (fabs(x) <= EPS || x >= 0) return 1;
	return 0;
}

int include_point(int i, double x, double y)
{
	double d = c[i].r - hypot(c[i].x - x, c[i].y - y);
	if (fabs(d) <= EPS || d >= 0) return 1;
	return 0;
}

int find_c(double x, double y, int i, int j)
{
	for (; i <= j; j--) {
		if (include_point(j, x, y)) return j;
	}
	return -1;
}

int cross_method()
{
	int i, j, k, b, n1, ans = 0;
	double x[2], y[2];
	int gc[101];
	char mk[101];

	for (i = 0; i < n; i++) {
		gc[i] = 0, mk[i] = 0;
		for (j = i+1; j < n; j++) {
			n1 = intersect(c[i], c[j], x, y, x+1, y+1);
			gc[i] += n1;
			for (k = 0; k < n1; k++) {
				if (find_c(x[k], y[k], i+1, j-1) < 0 &&
					find_c(x[k], y[k], j+1, n-1) < 0) {
					mk[i] = 1;
					b = find_c(x[k], y[k], 0, i-1);
					if (b >= 0) mk[b] = 1;
				}
			}
		}
	}

	ans = 0;
	for (i = 0; i < n; i++) {
		if (mk[i]) ans++;
		else if (!gc[i]) {
			for (j = i+1; j < n; j++) {
				if (include_circle(j, i)) break;
			}
			if (j >= n) ans++;
		}
	}
	return ans;
}

int main()
{
	int i;

	while(scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) {
			scanf("%lf%lf%lf", &c[i].x, &c[i].y, &c[i].r);
		}
		printf("%d\n", cross_method());
	}
	return 0;
}

Measured memory_bytes: 1824
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    int k,n;
    cin >>k >>n;

    int maxdist = 0;

    int prev = 0;
    int tmp;
    int first;
    int last;
    for(int i = 0; i < n; i++){

        cin >>tmp;
        maxdist = max(maxdist, tmp - prev);
        prev = tmp;
        if(i == 0) first = tmp;
        if(i == n-1) last = tmp;
    }
    maxdist = max(maxdist, k - last + first);

    printf("%d\n", k - maxdist);
    return 0;
}

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

int main() {
    int n, a, b; cin >> n >> a >> b;
    if ((b-a)&1) cout << "Borys" << endl;
    else cout << "Alice" << endl;
}

Measured memory_bytes: 3552
s=input()

mod=10**9+7

ans=[[0]*13 for _ in range(len(s))]

if s[-1]=="?":
    for i in range(10):
        ans[-1][i%13]+=1
else:
    ans[-1][int(s[-1])%13]+=1

#print(ans)

ten=1
for ii in range(1,len(s)):
    ten=(ten*10)%13

    i=len(s)-ii-1
    
    if s[i]!="?":
        tmp=(int(s[i])*ten)%13
        for j in range(13):
            ans[i][(tmp+j)%13]+=(ans[i+1][j])%mod
    else:
        for k in range(10):
            tmp=(k*ten)%13
            for j in range(13):
                ans[i][(tmp+j)%13]+=(ans[i+1][j])%mod

print(ans[0][5]%mod)





Measured memory_bytes: 95608
#include <bits/stdc++.h>
#include <cmath>
// #include <boost/multiprecision/cpp_int.hpp>
//
// using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  long double a, b, x;
  cin >> a >> b >> x;
  cout<<setprecision(15);
  if(x/a >= a * b / 2.0){
    long double h = ((a*b - x/a)*2) / a;
    cout << atan2(h, a) * 180 / M_PI << endl;
  }else{
    long double w = 2 * (x/a) / b;
    cout << atan2(b, w) * 180 / M_PI << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int num,i,q,o,sign=0;
    char map[100][4],line[50];
    for(;scanf("%d\n",&num),num;){
        for(i=0;i<num;i++){
            fgets(map[i],5,stdin);
        }
        scanf("%d\n",&q);
        for(i=0;sign=0,i<q;i++){
            fgets(line,3,stdin);
            for(o=0;o<num;o++)
                if(map[o][0]==line[0]){
                    printf("%c",map[o][2]);
                    sign=1;
                }
            if(sign==0)
                printf("%c",line[0]);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define revrep(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define pii pair<int, int>

int INF = 1e14;
int mod = 1e9 + 7;

signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int arr[n];
        int xr = 0;
        rep(i, 0, n)
        {
            cin >> arr[i];
            xr ^= arr[i];
        }
        for (int i : arr)
            cout << (xr ^ i) << " ";
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll a; cin >> a;
  cout << 3*a*a; 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***



const ll maxn = 2e5+5;
ld ar[maxn+5];
ld pre[maxn+5];
ld epi = 1e-12;

void solve()
{
    int n,k;rd(n,k);
    read((ar+1),n);
    fo(i,1,n)ar[i]=pre[i]=log(ar[i]);
    fo(i,1,n)pre[i]+=pre[i-1];

    fo(i,k,n){
        ar[i] = pre[i]-pre[i-k];
    }
    fo(i,k+1,n){
        if(ar[i]>ar[i-1]+epi)cout<<"Yes\n";
        else cout<<"No\n";
    }

    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

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

void Main() {
    // input
    int N;
    cin >> N;


    // translate


    // output
    cout << N / 2 + N % 2 << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

#define pi 3.141592653589
#define repeat(i,n) for(int i=0;i<n;i++)

int main()
{
	string array;
	string right;
	int n1,n2;
	bool ans=false;

	cin >> array;
	cin >> right;

	n1 = array.length();
	n2 = right.length();
	
	for (int i = 0; i < n1; i++)
	{
		if (array[i] == right[0])
		{
			for (int j = 0; j < n2; j++)
			{
				if (right[j] != array[(i + j)%n1]) break;
				if (j == n2 - 1) ans = true;
			}
		}
	}
	if (ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1184
from itertools import accumulate
n = 10**5 + 1
primes = set(range(3, n+1, 2))

for i in range(3, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes.add(2)


def like_2017(n):
    return n in primes and (n + 1) // 2 in primes


result = [0] * 10**5
for i in range(1, 10**5 + 1, 2):
    result[i] = like_2017(i)


cumsum = list(accumulate(result))

q = int(input())

for _ in range(q):
    l, r = map(int, input().split())
    print(cumsum[r] - cumsum[l - 1])

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


void solve(){
  int x;
  cin>>x;
  if(x==0) cout<<"1"<<endl;
  else cout<<"0";
}


int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
#ifndef ONLINE_JUDGE
      freopen("in.txt", "r", stdin);
     // freopen("ou1.txt","w",stdout);

#endif
  
//   time_t start, end; 
  
   
//     time(&start); 
      int  t;
      t=1;
      while (t--)
            solve();

      // time(&end); 
  
   
//     double time_taken = double(end - start); 
//     cout << "Time taken by program is : " << fixed 
//          << time_taken << setprecision(5); 
//     cout << " sec " << endl; 

      return 0;
}


Measured memory_bytes: 3644
#include <iostream>
    #include <math.h>
    #include <vector>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    using namespace std;

int main() {
    int n,m,ans=0; cin >> n >> m;
    vector<vector<int>> SwInf(m);
    for(int i = 0; i < m; i++){
        int k;cin>>k;
        vector<int> tvec(k);
        for(int j=0;j<k;j++){
            cin >> tvec[j];
        }
        SwInf[i] = (tvec);
    }
    vector<int> p(m);
    for(int i=0; i<m;i++){
        cin>>p[i];
    }

    //start algo

    for(int i=0;i<pow(2,n);i++){
        bool is_allcndOK = true;
        //cout << "state" << i <<endl;
        for(int j=0;j<SwInf.size();j++){
            int tmp_bitsum=0;
            //cout << "size of Swinf[j] " <<SwInf[j].size()<<endl;
            for(int k=0;k < SwInf[j].size() ; k++){
                //cout << (1 << (SwInf[j][k]-1) )<<endl; 
                if(i & (1 << (SwInf[j][k]-1) )){
                    tmp_bitsum++;
                }
            }
            //cout << "bitsum " << tmp_bitsum << endl;
            if( (tmp_bitsum%2) != p[j] ) is_allcndOK = false;
        }
        if (is_allcndOK == true) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from typing import List


def cross(a: complex, b: complex) -> float:
    return a.real * b.imag - a.imag * b.real


def convex_hull(coordinates: List[complex]) -> List[complex]:
    sorted_coordinates = sorted(coordinates, key=lambda x: (x.imag, x.real))
    n = len(sorted_coordinates)
    ans: List[complex] = [0] * (n + 1)
    j = 0
    for i in range(n):
        while j > 1 and (cross(ans[j - 1] - ans[j - 2],
                         sorted_coordinates[i] - ans[j - 1])) < 0:
            j -= 1
        ans[j] = sorted_coordinates[i]
        j += 1
    k = j
    for i in range(n - 2, -1, -1):
        while j > k and (cross(ans[j - 1] - ans[j - 2],
                         sorted_coordinates[i] - ans[j - 1])) < 0:
            j -= 1
        ans[j] = sorted_coordinates[i]
        j += 1
    return ans[0: j - 1]


if __name__ == "__main__":
    n = int(input())
    coordinates = [complex(*map(int, input().split())) for _ in range(n)]

    ans = convex_hull(coordinates)
    print(len(ans))
    for coordinate in ans:
        print(int(coordinate.real), int(coordinate.imag))



Measured memory_bytes: 24788
s = input() + 'R'
n = len(s)
ans = [0] * n
even = 0
odd = 0
i = 0
flag = [False, -1]
while i < n:
    if s[i] == 'L' and not flag[0]:
        flag = [True, i]
    if s[i] == 'R' and flag[0]:
        if flag[1] % 2 == 0:
            ans[flag[1]] = even
            ans[flag[1]-1] = odd
        else:
            ans[flag[1]] = odd
            ans[flag[1]-1] = even
        even = 0
        odd = 0
        flag = [False, -1]
    if i % 2 == 0:
        even += 1
    else:
        odd += 1
    i += 1
print(' '.join(map(str, ans[:-1:])))


Measured memory_bytes: 11124
A, B = input().split()
a = int(A)
C = []
for c in B:
    C.append(c)
del C[1]
b = 0
b += int(C[0]) * 100
b += int(C[1]) * 10
b += int(C[2])

ans = (a * b) // 100
print(ans)

Measured memory_bytes: 9196
# ABC171 E 

import itertools

n = int(input())
a_l = [list(format(int(x), "030b")) for x in input().split()]

for _d,_tp in enumerate(zip(*a_l)):
    if "1" not in _tp:
        continue
    if "0" not in _tp:
        continue
    else:
        _num = _tp.count("0")
        if _num % 2 == 1:
            for i in range(n):
                if a_l[i][_d] == "0":
                    a_l[i][_d] = "1"
                else:
                    a_l[i][_d] = "0"

print(*[int("".join(x), 2) for x in a_l])

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

int main() {
    int N,T,A;
    cin>>N;
    cin>>T>>A;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin>>vec.at(i);
    }
    int bango;
    double heikin,sabun,saisyou=10000;

    for(int i=0;i<N;i++){
        heikin=T-vec.at(i)*0.006;
        if(A>=heikin)sabun=A-heikin;
        else sabun=heikin-A;
        if(sabun<saisyou){
            saisyou=sabun;
            bango=i+1;
        }
    }
    cout<<bango<<endl;
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    string s,s1;
    cin>>s;
    s1=s.substr(0,3);
    cout<<s1;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    int x,y;

    cin>>x>>y;

    if(y%2!=0)
        cout<<"No"<<endl;
    else
    {
        int fr=y/4,rem=y%4;

        if(rem!=0)
            rem=1;

        if(fr+rem<=x && x<=(fr*2)+rem)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }










    return 0;
}


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

int top, S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];

    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else{
            push(stoi(s));
        }
    }
    cout << pop() << endl;
}


Measured memory_bytes: 3308
n,k = map(int, input().split())
d = []
A = []
for _ in range(k):
    d.append(int(input()))
    A.append(list(map(int, input().split())))
    
import collections

Okashi = []
for i in range(k):
    for j in range(len(A[i])):
        Okashi.append(A[i][j])
c = collections.Counter(Okashi)

print(n-len(c))

Measured memory_bytes: 9480
// AOJ 1100 "Area of Polygons" (ICPC国内予選 1998 Problem 1)
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int numOfSet = 0;
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            numOfSet++;
            double area = 0.0;
            Vektor[] v = new Vektor[n];
            
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                int y = sc.nextInt();
                v[i] = new Vektor(x, y, 0);
                
                if (i > 0) {
                    area += v[i-1].exteriorProduct(v[i]).z;
                }
            }
            area += v[v.length-1].exteriorProduct(v[0]).z;
            area /= 2;
            System.out.println(numOfSet + " " + Math.abs(area));
        }
    }
}

// 3次元ベクトルを表すクラス(可変長配列のVectorとの混同を避けるため、ドイツ語)
class Vektor {
    int x;
    int y;
    int z;
    
    public Vektor(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
    
    // このベクトルaと引数のベクトルvの外積axvを返すメソッド
    public Vektor exteriorProduct(Vektor v) {
        int x = this.y * v.z - this.z * v.y;
        int y = this.z * v.x - this.x * v.z;
        int z = this.x * v.y - this.y * v.x;
        
        return new Vektor(x, y, z);
    }
}

Measured memory_bytes: 21012
N, M = map(int, input().split())
a = []
for i in range(N):
    a += [list(map(int, input().split()))]
a.sort(key=lambda x: x[0])
i, ans = 0, 0
while M != 0 or i < N:
    if M > a[i][1]:
        M -= a[i][1]
        ans += a[i][0]*a[i][1]
    else:
        ans += a[i][0]*M
        M = 0
        break
    i += 1
print(ans)


Measured memory_bytes: 28568
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int mul(int a,int b){
    return (long long) a * b % mod;
}

int my_pow(int a,int b){
    int res = 1;
    while(b){
        if(b % 2 == 0){
            b /= 2;
            a = mul(a,a);
        }
        else{
            b--;
            res = mul(a,res);
        }    
    }
    return res;
}

int my_inv(int a){
    return my_pow(a,mod-2);
}

int main(){  
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i = 0;i<n;i++){
        cin>>v[i];
    }
    unordered_map<int,int> fact;
    for(int i = 0;i<n;i++){
        unordered_map<int,int> cnt;
        int x = v[i];
        for(int j = 2;j*j <= x;j++){
            while(x % j == 0){
                cnt[j]++;
                x /= j;
            }
        }
        if(x != 1){
            cnt[x]++;
        }
        for(pair<int,int> p:cnt){
            fact[p.first] = max(fact[p.first],p.second);
        }
    }
    int lcm = 1;
    for(pair<int,int> p:fact){
        int prime = p.first;
        int times = p.second;
        for(int i = 1;i<=times;i++){
            lcm = mul(lcm,prime);
        }
    }
    int sum = 0;
    for(int x:v)
    {
        sum = (sum + mul(lcm,my_inv(x))) % mod;
    }
    cout<<sum;
    return 0;
}


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

long long n,a,m,b,c,qq;
string ss;
int main() {
    cin>>n;
    for (int i=0; i<n; i++){
        cin>>a;
        if (a%2==0 and a%3!=0 and a%5!=0){
            b=1;
        }
    }
    if (b==1){
        cout<<"DENIED";
    }
    else{
        cout<<"APPROVED";
    }
}


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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, A, B;
	
	cin >> N >> A >> B;
	
	if(abs(B - A)%2 == 0){
		cout << "Alice";
		return 0;
	}else{
		cout << "Borys";
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void) {
    int sx,sy,gx,gy;
    scanf("%d %d %d %d",&sx,&sy,&gx,&gy);
    sx+=1000;sy+=1000;gx+=1000;gy+=1000;
    int x=gx-sx;
    int y=gy-sy;
    string s="";
    s+='L';
    rep(i,y+1)s+='U';
    rep(i,x+1)s+='R';
    s+='D';

    rep(i,y)s+='D';
    rep(i,x)s+='L';

    rep(i,y)s+='U';
    rep(i,x)s+='R';

    s+='R';
    rep(i,y+1)s+='D';
    rep(i,x+1)s+='L';
    s+='U';
    fin(s);
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in(),a=in(),b=in();
    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
    }else{
        cout<<min(a-1,n-b)+1+(b-a-1)/2<<endl;
        /*if(a-1<n-b){
            cout<<(a-1)+1+(b-a-1)/2<<endl;
        }else{
            cout<<(n-b)+1+(b-a-1)/2<<endl;
        }*/
    }
}


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

#define int long long
#define ff first
#define ss second
#define endl '\n'
#define ii pair<string, string>
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1

using namespace std;

inline int mod(int n){ return (n%1000000007); }

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

string red, blue;

map< ii, int> l, r;
string lleft, rright;

void generate_left(int i, int n){
  if(i == n){
    reverse(blue.begin(), blue.end());
    l[ii(red, blue)]++;
    reverse(blue.begin(), blue.end());
    return;
  }
  //paint red
  red += lleft[i];
  generate_left(i+1, n);
  red.pop_back();
  //paint blue
  blue += lleft[i];
  generate_left(i+1, n);
  blue.pop_back();
} 

void generate_right(int i, int n){
  if(i == n){
    reverse(blue.begin(), blue.end());
    r[ii(red, blue)]++;
    reverse(blue.begin(), blue.end());
    return;
  }
  //paint red
  red += rright[i];
  generate_right(i+1, n);
  red.pop_back();
  //paint blue
  blue += rright[i];
  generate_right(i+1, n);
  blue.pop_back();
}

int32_t main(){
	DESYNC;
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
	  char c;
	  cin >> c;
	  lleft += c;
	}
	for(int i=0; i<n; i++){
	  char c;
	  cin >> c;
	  rright += c;
	}
	generate_left(0, n);
	generate_right(0,n);
	int ans = 0;
	for(auto p : l){
	  string pred = p.first.first;
	  string pblue = p.first.second;
	  int val = p.second;
	  //cout << "strings (" << pred << ", " << pblue << ") has clash with " << r[ii(pblue, pred)] << " strings " << endl;
	  ans += val*r[ii(pblue, pred)];
	}
	cout << ans << endl;
}



Measured memory_bytes: 100736
#include <stdio.h>
#include <stdlib.h>

int main() {
	int k, s;
	int sum;
	int i, j;
	scanf("%d %d", &k, &s);

	sum = 0;
	for (i = 0; i < s + 1; i ++) {
		for (j = i + 1; j < s + 2; j ++) {
			if (i <= k && j - i - 1 <= k && s+1 - j <= k) {
				sum ++;
			}
		}
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+10;
ll a[N];
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		if(i%3==0||i%5==0) a[i]=0;
		else a[i]=i;
	}
	for(int i = 1; i <= n; i++)
	a[i]+=a[i-1];
	printf("%lld\n",a[n]);
	return 0;
}

Measured memory_bytes: 11504
#include<bits/stdc++.h>
#define ll long long

using namespace std;
ll n,a[100009],dp[3009][3009],ps[100009];

ll f(ll l, ll r){
    if(l>r)return 0;
    if(dp[l][r]==-1){
        dp[l][r]=max(ps[r]-ps[l-1]-f(l+1,r), ps[r]-ps[l-1]-f(l,r-1));
    }
    return dp[l][r];
}

int main(){
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        ps[i]=a[i]+ps[i-1];
    }
    cout << 2*f(1,n)-ps[n] << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> S(N);
  for (int i=0;i<N;i++){
    cin >> S.at(i);
  }
  
  sort(S.begin(),S.end());
  int count = 0;
  for (int i=0;i<N;i++){
    for (int j=i+1;j<N;j++){
      for (int k=j+1;k<N;k++){ 
        if ( S.at(k)<S.at(j)+S.at(i))
      count++;
      }
    }
  }
  
  cout << count << endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
////////////////////////////////////////////////////////////


signed main() {
  int n;
  cin>>n;
  vector<int>a(n);
  
  rep(i,n)cin>>a[i];

  map<int,int>ai;
  map<int,int>aj;
  rep(i,n){
    ai[a[i]+i]++;
    aj[i-a[i]]++;
  }
  int ans=0;
  for(auto&& x : ai){
    int key,value;
    key=x.first;
    value=x.second;
    ans+=aj[key]*value;
  }
  cout<<ans;
}


Measured memory_bytes: 39104
N = int(input())
F = [[] for _ in range(N)]
P = [[] for _ in range(N)]
for i in range(N):
    F[i] = list(map(int,(input().split())))
for i in range(N):
    P[i] = list(map(int,(input().split())))

ans = []

# 全探査
K = 2 # 選択肢の数
M = 10 # 問題の個数
for i in range(K**M):
    TF=[0]*M

    for j in range(M):
        TF[M-j-1] = i % K
        i //= K
    
    benefit = 0
    if sum(TF) != 0:
        for j in range(N):
            c = 0
            for k in range(10):
                if TF[k] == 1 and F[j][k] == 1:
                    c += 1
            benefit += P[j][c]
        ans.append(benefit)

print(max(ans))

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

int N;
int data[1000][10];
bool ans;

bool solve(int num) {
  stack<int> b, c;
  b.push(data[num][0]);
  for (int i = 1; i < 10; i++) {
    if (c.empty()) {
      int bt = b.top();
      (data[num][i] > bt ? b : c).push(data[num][i]);
    }
    else {
      int bt = b.top(), ct = c.top();
      if (data[num][i] > bt && data[num][i] > ct) (bt > ct ? b : c).push(data[num][i]);
      else if (data[num][i] > bt) b.push(data[num][i]);
      else if (data[num][i] > ct) c.push(data[num][i]);
      else return false;
    }
  }
  return true;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> data[i][j];
    }
  }

  for (int i = 0; i < N; i++) {
    ans = solve(i);
    cout << (ans ? "YES" : "NO") << endl;
  }


  return 0;
}

Measured memory_bytes: 3116
using System;
using System.Collections;
using System.Collections.Generic;

namespace JKTX_AOJ2015
{
    class Student
    {
        public int M { get; set; }
        public int F { get; set; }
        public int R { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            List<Student> studentList = new List<Student>();

            while (true)
            {
                Student student = new Student();

                string[] str = Console.ReadLine().Split(' ');

                student.M = int.Parse(str[0]);
                student.F = int.Parse(str[1]);
                student.R = int.Parse(str[2]);

                if (str[0].Equals("-1") && str[1].Equals("-1") && str[2].Equals("-1"))
                {
                    break;
                }

                studentList.Add(student);
            }

            foreach (var item in studentList)
            {
                if(item.M == -1 || item.F == -1){
                    Console.WriteLine("F");
                }
                else if (80 <= item.M + item.F)
                {
                    Console.WriteLine("A");
                }
                else if (65 <= item.M + item.F && item.M + item.F < 80)
                {
                    Console.WriteLine("B");
                }
                else if (50 <= item.M + item.F && item.M + item.F < 65)
                {
                    Console.WriteLine("C");
                }
                else if (30 <= item.M + item.F && item.M + item.F < 50)
                {
                    if (50 <= item.R)
                    {
                        Console.WriteLine("C");
                    }
                    else
                    {
                        Console.WriteLine("D");
                    }
                }
                else if (30 > item.M + item.F)
                {
                    Console.WriteLine("F");
                }
            }
        }
    }
}

Measured memory_bytes: 5408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a>k)
  cout<<":("<<endl;
  else{
    cout<<"Yay!"<<endl;
  }
}
    

   
  
   

  
   


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>
using namespace std;


int main(int argc, char* argv[]){
	int n,k;
	scanf("%d %d",&n,&k);
	int A[n];
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	for(int i=0;i<n-k;i++){
		int old_index = i;
		int new_index = i+k;
		if(A[old_index]<A[new_index]){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}



}


Measured memory_bytes: 4540