akhauriyash/Code-Regression huggingface dataset:
/*
                                        //     //     //\\\\\\\\\
                                        \\    //      \\        \\
                                        //   //       //         \\
                                        \\  //        \\          \\
                                        // //         //           \\
                                        \\//          \\            \\       
                                        //\\          //            //
                                        \\ \\         \\           //
                                        //  \\        //          //
                                        \\   \\       \\         //
                                        //    \\      //        //
                                        \\     \\     \\/////////
*/

#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vint vector <int>
#define vll vector <long long int>
#define endl cout<<'\n'
#define fre(i,l,n) for(long long int i=l;i<n;++i)
#define fr(i,l,n) for(long long int i=l;i<=n;i++)
#define rfre(i,n,l) for(long long int i=n-1;i>=l;i--)
#define rfr(i,n,l) for(long long int i=n;i>=l;--i)
#define tab '\t'
#define debug cout<<'*';
#define s(a) cin>>a
#define p(a) cout<<a
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef pair<int,pair<int,int> > tii;
typedef vector<int> vec;
typedef vector<long long> vecll;
typedef vector<pair<int,int> > vec_pii;
typedef vector<pair<long long int,long long int> > vec_pll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<pair<int,int> > > vvpii;
typedef vector<vector<pair<ll,ll> > > vvpll;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define Pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define sf(n) scanf("%lld",&(n))
#define pf(n) printf("%lld\n",(n))
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define w(t) while(t--)
#define flt(a) cout<<fixed<<setprecision(a)
#define cntSetBits(n) __builtin_popcountll(n)
/*****************************
*****************************/




void solve()
{
    char str;
    s(str);
    if(str >= 'a')
    {
        p("a");endl;
    }
    else
    {
        p("A");endl;
    }
}



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll t=1;
    // s(t);
    w(t)
    {
        solve();
    }
    return 0;
}









Measured memory_bytes: 3656
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	s := nextStr()
	if s == "Sunny" {
		fmt.Println("Cloudy")
		return
	}
	if s == "Cloudy" {
		fmt.Println("Rainy")
		return
	}
	fmt.Println("Sunny")
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1772
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }static int res=int.MaxValue;
    static void Solve()
    {
        var abcde = Enumerable.Repeat(0, 5).Select(v => Input.num).ToArray();
        for (var i = 0; i < 5; i++)
            dfs(0, abcde, i, new bool[5]);
        WriteLine(res);

    }
    private static void dfs(int time,int[] ae,int index,bool[] th)
    {
        time += ae[index];
        th[index] = true;
        if (th.Count(v => v) == 5)
        {
            res = Min(res, time);
            th[index] = false;
            return;
        }
        for (var i = 0; i < 5; i++)
            if (!th[i]) dfs((time+9)/10*10, ae, i, th);
        th[index] = false;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13524
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

ll MOD;

vector<int> path[100010];
ll dp[100010], ans[100010];

ll dfs(int v, int r) {
    dp[v] = 1;
    for (int sv : path[v]) {
        if (sv == r) continue;
        dp[v] *= dfs(sv, v) + 1;
        dp[v] %= MOD;
    }
    return dp[v];
}

void edfs(int v, int r, ll par) {
    ans[v] = dp[v] * (par + 1) % MOD;

    vector<int> chv = {-1};
    for (int sv : path[v]) {
        if (sv == r) continue;
        chv.push_back(sv);
    }
    int L = chv.size() - 1;

    ll fore[L + 2], back[L + 2];
    fore[0] = back[L + 1] = 1;
    for (int i = 1; i <= L; ++i) fore[i] = fore[i - 1] * (dp[chv[i]] + 1) % MOD;
    for (int i = L; i >= 1; --i) back[i] = back[i + 1] * (dp[chv[i]] + 1) % MOD;

    for (int i = 1; i <= L; ++i) {
        edfs(chv[i], v, fore[i - 1] * back[i + 1] % MOD * (par + 1) % MOD);
    }
}

int main() {
    int N;
    cin >> N >> MOD;
    for (int i = 0; i < N - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        path[u].push_back(v);
        path[v].push_back(u);
    }

    dfs(0, -1);
    for (int v = 0; v < N; ++v) cerr << dp[v] << endl;

    edfs(0, -1, 0);
    for (int v = 0; v < N; ++v) cout << ans[v] << endl;
    return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll N,M;
    cin>>N>>M;
    vll day(N),pay(N);
    rep(i,0,N)cin>>day[i]>>pay[i];
    using pll =pair<ll,ll>;
    priority_queue<pll> q;
    rep(i,0,N)q.emplace(pay[i],day[i]);

    vb occpy(M+1,false);
    set<ll> ok;
    rep(i,0,M)ok.insert(i+1);
    ll ans=0;

    while(!q.empty()){
        auto p=q.top(); q.pop();
        if(ok.lower_bound(p.second)==ok.end())continue;

        if(occpy[p.second]){
            auto itr=ok.lower_bound(p.second);
            ok.erase(*itr);
            occpy[*itr]=true;
        }
        else{
            occpy[p.second]=true;
            ok.erase(p.second);
        }
        ans+=p.first;
   }
    cout<<ans<<endl;
    return 0;
}




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

using namespace std;

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

set<int> state[100000];

int main() {
	int n;
	cin >> n;
	
	int ans = 0;
	REP(i, n) {
		int num;
		scanf("%d", &num);
		num--;
		
		state[num].insert(i);
		if (state[i].find(num) != state[i].end()) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n; vector<int>v(n);
	rep(i, 0, n)cin >> v[i];
	rep(i, 1, *min_element(all(v))) {
		bool f(true);
		rep(j, 0, n)if (v[j] % i != 0) {
			f = false;
			break;
		}
		if (f)cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define _GLIBCii_DEBUG // ArrajOutofBounds
#define rep(i, N) for (int i = 0; i < N; i++) //制御変数iを用いてN回転
using namespace std;
using ll = long long;

//0:上 1:左 2:下 3:右
const int di[] = { -1, 0, 1, 0};
const int dj[] = { 0, -1, 0, 1};

int main() {
    int H, W, Ch, Cw, Dh, Dw;
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    vector<string> S(H);
    vector<vector<int>> ans(H, vector<int>(W, 999999));
    rep(i, H) cin >> S[i];
    Ch--; Cw--; Dh--; Dw--;
    ans[Ch][Cw] = 0;
    deque<pair<int, int>> q;
    q.push_front(pair<int, int>(Ch, Cw));
    while (!q.empty()) {
        int i = q.front().first;
        int j = q.front().second;
        int count = ans[i][j];
        q.pop_front();
        for (int k = 0; k < 4; k++) {
            int new_i = i + di[k];
            int new_j = j + dj[k];
            if (new_i < 0 || new_i >= H || new_j < 0 || new_j >= W) continue;
            if (S[new_i][new_j] == '#') continue;
            if (ans[new_i][new_j] <= count) continue;
            ans[new_i][new_j] = count;
            q.push_front(pair<int, int>(new_i, new_j));
        }
        for (int ji = -2; ji <= 2; ji++) {
            for (int jj = -2; jj <= 2; jj++) {
                int new_i = i + ji;
                int new_j = j + jj;
                if (new_i < 0 || new_i >= H || new_j < 0 || new_j >= W) continue;
                if (S[new_i][new_j] == '#') continue;
                if (ans[new_i][new_j] <= count + 1) continue;
                ans[new_i][new_j] = count + 1;
                q.push_back(pair<int, int>(new_i, new_j));
            }
        }
    }
    rep(i, H) rep(j, W)
    if (ans[i][j] == 999999) ans[i][j] = -1;

    cout << ans[Dh][Dw] << endl;
    return 0;
}

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

using namespace std;

int n, m;

char ch[233][233];

unsigned char F[185 * 186 / 2][185 * 186 / 2];

int S1[233], S2[233], Sum[233][233], O1[233][233], O2[233][233];

int calc1(int a, int b) {
	return S1[a - 1] + b - a;
}

int calc2(int a, int b) {
	return S2[a - 1] + b - a;
}

int Do(int a, int b, int c, int d) {
	if(a == b && c == d) return 0;
	int w1 = O1[a][b], w2 = O2[c][d];
	if(F[w1][w2] != 255) return F[w1][w2];
	//int s = Sum[b][d] - Sum[a - 1][d] - Sum[b][c - 1] + Sum[a - 1][c - 1];
	//if(s == 0 || s == (b - a + 1) * (d - c + 1)) return 0;
	int ans = 233;
	for(int l = a, r = b - 1; l <= r; ) {
		int md = (l + r) / 2;
		int A = Do(a, md, c, d), B = Do(md + 1, b, c, d);
		ans = min(ans, max(A, B) + 1);
		if(ans == 1) break;
		if(A < B) l = md + 1; else if(A > B) r = md - 1; else break;
	}
	for(int l = c, r = d - 1; l <= r; ) {
		int md = (l + r) / 2;
		int A = Do(a, b, c, md), B = Do(a, b, md + 1, d);
		ans = min(ans, max(A, B) + 1);
		if(ans == 1) break;
		if(A < B) l = md + 1; else if(A > B) r = md - 1; else break;
	}
	//for(int i = a; i < b; i++) ans = min(ans, max(Do(a, i, c, d), Do(i + 1, b, c, d)) + 1);
	//for(int i = c; i < d; i++) ans = min(ans, max(Do(a, b, c, i), Do(a, b, i + 1, d)) + 1);
	if(ans == 1 && ch[a][c] == ch[b][d]) ans = 0;
	return F[w1][w2] = ans;
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) scanf("%s", ch[i] + 1);
	/*for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) ch[i][j] = rand() & 1 ? '.' : '#';*/
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			Sum[i][j] = Sum[i - 1][j] + Sum[i][j - 1] + (ch[i][j] == '.') - Sum[i - 1][j - 1];
	memset(F, 255, sizeof F);
	for(int i = 1; i <= n; i++) S1[i] = S1[i - 1] + (n - i + 1);
	for(int i = 1; i <= m; i++) S2[i] = S2[i - 1] + (m - i + 1);
	for(int i = 1; i <= n; i++)
		for(int j = i; j <= n; j++)
			O1[i][j] = calc1(i, j);
	for(int i = 1; i <= m; i++)
		for(int j = i; j <= m; j++)
			O2[i][j] = calc2(i, j);
	printf("%d\n", Do(1, n, 1, m));
	return 0;
}

Measured memory_bytes: 290048
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
ll min(ll a, ll b){ return (a > b) ? b : a;}
ll max(ll a, ll b){ return (a < b) ? b : a;}
int main(){
    cout << fixed << setprecision(10);
    ll x,k,d;
    cin >> x >> k >> d;
    if( x < 0) x = -1 * x;
    ll y = x / d;
    if(y >= k) cout << x - k * d << endl;
    else{
        if((k - y)%2 == 0) cout << x - y * d << endl;
        else cout << d - (x - y * d) << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
from collections import defaultdict, Counter
N = int(input())
A = list(map(int, input().split()))

d = defaultdict(int)
c = Counter(A)
total = sum(x * (x - 1) // 2 for x in c.values())

ans = []
for a in A:
    v = c[a]
    subt = v * (v - 1) // 2
    v -= 1
    add = v * (v - 1) // 2
    ans.append(total - subt + add)

print(*ans, sep="\n")


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

#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));

int main(){
	ll a,b,c;
	while(cin >> a>>b>>c){
		
		
		if(c>=min(a,b)&&c<=max(a,b)){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}

}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n, m;
	int i, j;
	int val;
	int sum;
	int matrix_a[100][100] = { 0 };
	int matrix_b[100] = { 0 };

	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			val = 0;
			scanf(" %d", &matrix_a[i][j]);
		}
	}
	for (j = 0; j < m; j++) {
		val = 0;
		scanf(" %d", &matrix_b[j]);
	}

	for (i = 0; i < n; i++) {
		sum = 0;
		for (j = 0; j < m; j++) {
			sum += matrix_a[i][j] * matrix_b[j];
		}
		printf("%d\n", sum);
	}
	
	return 0;
}


Measured memory_bytes: 2096
using System;
using System.Linq;

class E
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = h[0], k = h[1], c = h[2];
		var s = Console.ReadLine();

		var d1 = new int[k];
		for (int j = 0, i = 0; j < k; j++)
		{
			while (i < n && s[i] == 'x') i++;
			d1[j] = i;
			i += c + 1;
		}

		var d2 = new int[k];
		for (int j = k - 1, i = n - 1; j >= 0; j--)
		{
			while (i >= 0 && s[i] == 'x') i--;
			d2[j] = i;
			i -= c + 1;
		}

		Console.WriteLine(string.Join("\n", d1.Zip(d2, (x, y) => x == y ? x + 1 : 0).Where(x => x > 0)));
	}
}


Measured memory_bytes: 42588
import sys
readline = sys.stdin.readline

def main():
  N, a, b, c = map(int, readline().split())
  A = {"A":a, "B":b, "C":c}
  S = []
  for i in range(N):
    l = readline().strip()
    S.append([l[0], l[1]])

  ans = ""
  ret = False
  for i in range(N):
    if A[S[i][0]] == 0 and A[S[i][1]] == 0:
      break
    if i == N-1:
      if A[S[i][0]] > 0:
        ans += S[i][1]
      else:
        ans += S[i][0]
      ret = True
      break
    if A["A"] + A["B"] + A["C"] == 1:
      if A[S[i][0]] == 1:
        if S[i][0] in S[i+1] and S[i][1] not in S[i+1]:
          break
        else:
          A[S[i][0]] -= 1
          A[S[i][1]] += 1
          ans += S[i][1]
          continue
      else:
        if S[i][1] in S[i+1] and S[i][0] not in S[i+1]:
          break
        else:
          A[S[i][0]] += 1
          A[S[i][1]] -= 1
          ans += S[i][0]
          continue
    if A[S[i][0]] == 0:
      A[S[i][0]] += 1
      A[S[i][1]] -= 1
      ans += S[i][0]
      continue
    elif A[S[i][1]] == 0:
      A[S[i][0]] -= 1
      A[S[i][1]] += 1
      ans += S[i][1]
      continue
    elif S[i][0] in S[i+1]:
      A[S[i][0]] += 1
      A[S[i][1]] -= 1
      ans += S[i][0]
      continue
    else:
      A[S[i][0]] -= 1
      A[S[i][1]] += 1
      ans += S[i][1]
      continue

  if ret:
    print("Yes")
    for i in range(N):
      print(ans[i])
  else:
    print("No")

if __name__ == '__main__':
  main()

Measured memory_bytes: 17880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const ll inf = 1LL<<60;

int main()
{
  int a, b; cin >> a >> b;
  for (int i=0; i<10001; i++) {
    int aa = i*0.08;
    int bb = i*0.1;
    if (a == aa && b == bb) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  if(abs(b-a) % 2 == 0) cout << "Alice" << endl;
  else cout << "Borys" << endl;
}

Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int a, b, c;
    cin >> a >> b >>c;
    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());

    int ans = 0;
    if(v[0]==v[1] && v[1]==v[2]) {
        cout << ans << endl;
        return 0;
    }
    while(1) {
        if(v[2] != v[1]) {
            v[0]++;
            v[1]++;
        }else {
            v[0] += 2;
        }
        ans++;
        if(v[0]==v[1] && v[1]==v[2]) {
            break;
        }
        sort(v.begin(), v.end());
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
def lcm(m, n):
    return int(m * n/gcd(m,n))

print(lcm(a,b))

Measured memory_bytes: 3060
n, m = [int(el) for el in input().split(' ')]
ships = []
for _ in range(m):
    ships.append([int(el) for el in input().split(' ')])

S = set()
T = set()

for ship in ships:
    a = ship[0]
    b = ship[1]
    if a == 1:
        S.add(b)
    if b == n:
        T.add(a)

if S.intersection(T):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')



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

const int mod = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  vector<ll> A(3 * N);
  for (int i = 0; i < 3 * N; i++) {
    cin >> A[i];
  }

  priority_queue<ll, vector<ll>, greater<ll>> Q1;
  priority_queue<ll> Q2;
  vector<ll> ma(N + 1), mi(N + 1);

  ll sum = 0;
  for (int k = 0; k < N; k++) {
    Q1.push(A[k]);
    sum += A[k];
  }

  ma[0] = sum;
  for (int k = N; k < 2 * N; k++) {
    sum += A[k];
    Q1.push(A[k]); 

    sum -= Q1.top();
    Q1.pop();

    ma[k - N + 1] = sum;
  }

  sum = 0;
  for (int k = 3 * N - 1; k >= 2 * N; k--) {
    Q2.push(A[k]);
    sum += A[k];
  }

  mi[N] = sum;
  for (int k = 2 * N - 1; k >= N; k--) {

    sum += A[k];
    Q2.push(A[k]); 

    sum -= Q2.top();
    Q2.pop();

    mi[k - N] = sum;
  }

  ll ans = -(1LL << 62);
  for (int k = 0; k < N + 1; k++) {
    ans = max(ans, ma[k] - mi[k]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6516
using System;
using System.Linq;
using System.Collections.Generic;

class Program {

    const int inf = 2 << 29;
    const int MAX = 10000;
    const int wht = 0;
    const int gry = 1;
    const int blk = 2;
    static int[] stt = new int[MAX];
    static int[] dst = new int[MAX];
    static int[] pth = new int[MAX];

    static int[,] g = new int[MAX, MAX];

    static void Main(string[] args) {
    
        for (int i = 0; i < MAX; i++) {
            dst[i] = inf;
            for (int j = 0; j < MAX; j++) {
                g[i, j] = inf;
            }
        }

        var n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++) {
            var a = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();

            for (int j = 2; j < a.Length; j += 2) {
                g[a[0], a[j]] = a[j + 1];
            }
        }

        dijkstra(0);

        for (int i = 0; i < n; i++) {
            string s = i.ToString() + " " + dst[i].ToString();
            Console.WriteLine(s);
        }


    }


    static void dijkstra(int s) {

        dst[s] = 0;
        stt[s] = gry ;

        int mn = inf;
        while (true) {
            mn = inf;
            int u = -1;
            for (int i = 0; i < MAX; i++) {
                if (stt[i] != blk && dst[i] < mn) {
                    mn = dst[i];
                    u = i;
                }
            }
            if (u == -1) break;
            stt[u] = blk;

            for (int v = 0; v < MAX; v++) {
                if (stt[v] != blk && g[u, v] != inf) {
                    if (dst[v] > dst[u] + g[u, v]) {
                        dst[v] = dst[u] + g[u, v];
                        stt[v] = gry;
                    }
                }
            }
        }
    }
}



Measured memory_bytes: 470564
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author CompuWare
 */

#include <iostream>
#include <fstream>

#include <iostream>

class BBiteEating {
public:
    void solve(std::istream &in, std::ostream &out) {
        int64_t N, L, sum = 0;
        in >> N >> L;
        bool f = 1;
        for (int i = 1; i <= N; i++) {
            if ((L + i - 1 >= 0 && f) || (f && i == N)) {
                f = 0;
            } else sum += (L + i - 1);
//	         out << (L+i-1) << " ";
        }
        out << sum;
    }
};


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


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

using namespace std;

int main() {
	string s, t; cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); ++i)
		if (s[i] != t[i]) ++ans;
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int N;
int A[100001];
int dp[100001][5];

int main()
{
    scanf("%d", &N);
    for(int i=1; i<=N; i++)
        scanf("%d", A+i);
    long long ans=0;
    for(int i=1; i<=N; i++) if(A[i]>4)
    {
        int b=A[i]%4;
        if(b==0)
            b=4;
        ans+=(A[i]-b)/2;
        A[i]=b;
    }
    for(int i=1; i<5; i++)
        dp[0][i]=-0x3f3f3f3f;
    for(int i=1; i<=N; i++)
    {
        for(int j=4; j>=0; j--)
        {
            dp[i][j]=-0x3f3f3f3f;
            if(j<=A[i])
                dp[i][j]=dp[i-1][0];
            if(j+2<=A[i])
                dp[i][j]=max(dp[i][j], dp[i][j+2]+1);
            if(j+1<=A[i])
                dp[i][j]=max(dp[i][j], dp[i-1][1]+1);
            if(j+1<=4)
                dp[i][j]=max(dp[i][j], dp[i][j+1]);
        }
    }
    printf("%lld\n", ans+dp[N][0]);
    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		sc.close();
		
		int ans = Integer.MAX_VALUE;
		for(int k = -100; k <= 100; k++) {
			int cost = 0;
			for(int i = 0; i < n; i++) {
				cost += (a[i] - k) * (a[i] - k);
			}
			ans = Math.min(ans, cost);
		}
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 9556
#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 2e9
#define ll long long
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(v) v.begin(), v.end()

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

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

int main(){
    int H, W; cin >> H >> W;
    int h, w; cin >> h >> w;
    cout << (H-h)*(W-w) << endl;
}



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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  rep (i, n) {
    cin >> c[i];
    rep (j, m) cin >> a[i][j];
  }
  int ans = INF;
  rep (i, 1 << n) {
    vector<int> res(m, 0);
    int total = 0;
    rep (j, n) {
      if ((1 << j) & i) {
        rep (k, m) res[k] += a[j][k];
        total += c[j];
      }
    }
    bool ok = true;
    rep (j, m) if (res[j] < x) ok = false;
    if (ok) ans = min(ans, total);
  }
  cout << (ans == INF ? -1 : ans) << endl;
  return 0;
}

Measured memory_bytes: 3656
#!/usr/bin/env python3
from math import *
import heapq

def disktra(g,s):
    n=len(g)
    dist = [inf]*n
    dist[s] = 0
    hq=[]
    heapq.heappush(hq,(dist[s],s))
    while hq:
        cost,u =heapq.heappop(hq)
        if dist[u] < cost:
            continue
        for v,c in g[u]:
            if dist[v] <= dist[u] +c:
                continue
            dist[v] = dist[u] + c
            heapq.heappush(hq,(dist[v],v))
    return dist
while True:
    n, k = map(int, input().split())
    if n == 0 and k == 0:
        break
    G = [[]*n for i in range(n)]
    used = [0]*n

    E = [[float('inf')]*n for i in range(n)]
    for i in range(k):
        inp = tuple(map(int, input().split()))
        if inp[0] == 1:
            c, d, e = inp[1:]
            c -= 1
            d -= 1
            G[c].append((d,e))
            G[d].append((c,e))
            # E[c][d] = min(E[c][d], e)
            # E[d][c] = min(E[d][c], e)

        else:
            # for i in G:
            #     print(i)
            a, b = inp[1:]
            a-=1
            b-=1
            d=disktra(G,a)
            print(-1 if d[b]==inf else d[b])

        # dis = [float('inf')]*n
        # dis[a] = 0
        # mv = a
        # for v in G[a]:
        #     m = float('inf')
        #     if not used[v]:
        #         if m >dis[v]:
        #             m = dis[v]
        #             mv = v
        # used[mv]=1
        #     # print(dis)
        # for i in G[mv]:
        #     dis[i] = min(dis[i],dis[mv]+E[mv][i])
        # print(dis)
        # print(-1 if dis[b] == float('inf') else dis[b])


# while True:
#     n, k = map(int, input().split())
#     if n == 0 and k == 0:
#         break
#     G = [[]*n  for i in range(n)]
#     used = [0]*n
#     dis = [float('inf')]*n
#     E = [[float('inf')]*n for i in range(n)]
#     dis[0]=0
#     for i in range(k):
#         inp = tuple(map(int, input().split()))
#         if inp[0] == 1:
#             c, d, e = inp[1:]
#             c -= 1
#             d -= 1
#             G[c].append(d)
#             G[d].append(c)
#             E[c][d] = min(E[c][d], e)
#             E[d][c] = min(E[d][c], e)

#         else:
#             a, b = inp[1:]
#             a-=1;b-=1
#             mv=a
#             for v in G[a]:
#                 m=float('inf')
#                 if not used[v]:
#                     if m>dis[v]:
#                         m=dis[v]
#                         mv=v
#             for i in G[mv]:
#                 dis[i]=min(dis[i],dis[mv]+E[mv][i])
#             # print(dis)
                # print(-1 if dis[b]==float('inf') else dis[b])

    




Measured memory_bytes: 6352
#include <iostream>
#include <cmath>
#include <vector>
#include <complex>
#include <cassert>
#include <algorithm>
using namespace std;

typedef complex<double> point;
typedef vector<point> polygon;

struct line : public vector<point> {
	line(point a, point b) { push_back(a); push_back(b); }
};

namespace std {
	bool operator<(const point& a, const point& b) {
		return a.real()!=b.real() ? a.real()<b.real() : a.imag()<b.imag();
	}
}

const double eps = 1e-10;
bool   equal(const double a, const double b) { return abs(a-b)<eps; }
bool   equal(const point& a, const point& b) { return abs(a-b)<eps; }
double dot  (const point& a, const point& b) { return (a*conj(b)).real(); }
double cross(const point& a, const point& b) { return (conj(a)*b).imag(); }
point  vec  (const line&  l)                 { return l[1]-l[0]; }
point  unit (const point& v)                 { return v/abs(v);  }
point  ortho(const point& v)                 { return v*point(0,1); }

int ccw(const point& a, const point& b, const point& c) {
	point u=b-a, v=c-a;
	if(cross(u,v) > 0 ) return +1; // ccw
	if(cross(u,v) < 0 ) return -1; // cw
	if(  dot(u,v) < 0 ) return +2; // cab
	if(norm(u)<norm(v)) return -2; // abc
	return 0;                      // acb
}

int ccw(const line& s, const point& p) {
	return ccw(s[0], s[1], p);
}

point crosspoint(const line& l, const line& m) {
	double A = cross(vec(l), vec(m));
	double B = cross(vec(l), l[1]-m[0]);
	if(abs(A)<eps) {			// parallel
		assert(abs(B)<eps);
		return m[0];			// sameline
	}
	return m[0] + B/A*vec(m);
}

polygon convex_cut(const polygon& g, const line& l, int f=0) {
	polygon h;
	line m(l[f%2], l[(f+1)%2]);

	for(int i=0; i<g.size(); i++) {
		const point& a = g[i];
		const point& b = g[(i+1)%g.size()];
		if(ccw(m,a) != -1) h.push_back(a);
		if(ccw(m,a)*ccw(m,b) < 0) {
			point p = crosspoint(line(a,b), m);
			if((!equal(a,p)) && (!equal(b,p))) {
				h.push_back(p);
			}
		}
	}
	return h;
}

int main()
{
	int N;
	while(cin>>N, N) {
		polygon g;
		while(N--) {
			double x,y;
			cin>>x>>y;
			g.push_back(point(x,y));
		}

		double low=0,high=5000;
		while(high-low > 1e-6)
		{
			polygon h;
			h.push_back(point(    0,    0));
			h.push_back(point(10000,    0));
			h.push_back(point(10000,10000));
			h.push_back(point(    0,10000));

			double d = (low+high)/2.0;

			for(int i=0; i<g.size(); i++) {
				point& a = g[i];
				point& b = g[(i+1)%g.size()];
				point  v = unit(ortho(b-a));

				h = convex_cut(h, line(a+d*v, b+d*v));
			}

			if(h.size()) low  = d;
			else         high = d;
		}
		cout.setf(ios::fixed);
		cout.precision(6);
		cout << (low+high)/2.0 << endl;
	}
}

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

int main()
{
  int64_t H, W, ans = 0;
  cin >> H >> W;
  vector<vector<int64_t>> G(H, vector<int64_t>(W, 0));
  char c;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> c;
      if (c == '#')
        G.at(i).at(j) = -1;
    }
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (G.at(i).at(j) == -1)
        continue;
      int64_t tmp = 0;
      for (int k = j; k <= W; k++)
      {
        if (k == W || G.at(i).at(k) == -1)
        {
          for (int l = j; l < k; l++)
            G.at(i).at(l) += tmp; // 連続分を加算する
          j = k;                  // 次はk+1からスタート
          break;
        }
        tmp++; // 連続分を加算する
      }
    }
  }
  for (int i = 0; i < W; i++)
  {
    for (int j = 0; j < H; j++)
    {
      if (G.at(j).at(i) == -1)
        continue;
      int64_t tmp = 0;
      for (int k = j; k <= H; k++)
      {
        if (k == H || G.at(k).at(i) == -1)
        {
          for (int l = j; l < k; l++)
            G.at(l).at(i) += tmp; // 連続分を加算する
          j = k;                  // 次はk+1からスタート
          break;
        }
        tmp++; // 連続分を加算する
      }
    }
  }

  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      ans = max(ans, G.at(i).at(j));
    }
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s[0]==s[1]){
        if(s[1]==s[2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner sc = new Scanner(is);
        int N = sc.nextInt();
        Map<Integer, Integer> mapi = new HashMap<>();

        long ans = 0;
        for (int i = 0; i < N; i++) {
            int A = sc.nextInt();
            mapi.put(i + A, mapi.getOrDefault(i + A, 0) + 1);
            ans += mapi.getOrDefault(i - A, 0);
        }

        os.println(ans);
    }

}

Measured memory_bytes: 60928
def solve():
    P.sort(reverse = True)
    M.sort()
    P.append(-1)
    M.append(1) # add endpoint
    p, m = [], []
    while len(p) + len(m) < k:
        if P[len(p)] < -M[len(m)]:
            m.append(M[len(m)])
        else:
            p.append(P[len(p)])

    if len(m)%2 == 0: return p + m

    exist_p = len(p) > 0
    exist_m = len(m) > 0
    remain_P = len(P) - 1 > len(p)
    remain_M = len(M) - 1 > len(m)
    if exist_p & exist_m & remain_P & remain_M:
        if abs(p[-1] * P[len(p)]) < abs(m[-1] * M[len(m)]):
            p.pop()
            m.append(M[len(m)])
        else:
            m.pop()
            p.append(P[len(p)])
    elif exist_m & remain_P:
        m.pop()
        p.append(P[len(p)])
    elif exist_p & remain_M:
        p.pop()
        m.append(M[len(m)])
    elif k%2:
        M.pop()
        m = sorted(M, reverse = True)[:k]
    return p + m

n, k = map(int, input().split())
P, M = [], [] # plus, minus
for a in map(int, input().split()):
    if a < 0: M.append(a)
    else: P.append(a)
ans, MOD = 1, 10**9 + 7
for a in solve(): ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


Measured memory_bytes: 31968
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){
    int m1, d1, m2, d2;

    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if(d1 + 1 != d2){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }

}

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

void call(int n)
{
    for(int i = 1; i <= n; i++) {
        int x = i;
        if(x % 3 == 0) {
            cout << " " << i;
            continue;
        }
        while(x) {
            if(x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
}
 
int main()
{
    int n;
    cin >> n;
    call(n);
    return 0;
}

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

int main() {
	ll n, m, d;
	cin >> n >> m >> d;
	cout << fixed << setprecision(20);
	double ans = 0;
	for (int i = 0; i < m - 1; i++) {
		ans += (double)((double)(2 * n - 2 * d) / n) / n;
	}
	if (d == 0)ans *= 0.5;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
  stack<int> S;
  S.push(r);
  color[r] = c;
  while (!S.empty()) {
    int u = S.top(); S.pop();
    for (int i = 0; i < G[u].size(); i ++) {
      int v = G[u][i];
      if (color[v] == NIL) {
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor() {
  int id = 1;
  for (int i = 0; i < n; i ++) color[i] = NIL;
  for (int u = 0; u < n; u ++) {
    if (color[u] == NIL) dfs(u, id++);
  }
}

int main() {
  int s, t, m, q;
  cin >> n >> m;
  for (int i = 0; i < m; i ++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;
  for (int i = 0; i < q; i ++) {
    cin >> s >> t;
    if (color[s] == color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}



Measured memory_bytes: 8960
N, M = map(int, input().split())
A = []
C = []
for _ in range(M):
    a, _ = map(int, input().split())
    A.append(a)
    C_ = list(map(int, input().split()))
    c = 0
    for c_ in C_:
        c |= 1<<c_-1
    C.append(c)
dp = [float("inf")] * (1<<N)
dp[0] = 0
for a, c in zip(A, C):
    dp_new = dp[:]
    for s, d in enumerate(dp):
        dp_new[s|c] = min(d+a, dp_new[s|c])
    dp = dp_new
#print(dp)
ans = dp[(1<<N)-1]
print(ans if ans != float("inf") else -1)


Measured memory_bytes: 50264
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

#define MAX 1000002
typedef unsigned char byte;
byte mask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};

int Lv[MAX];
int n, k;

bool cmp_Lv(const int i, const int j){ return Lv[i] < Lv[j]; }

bool cmp(const int i, const int j){
    if(Lv[i] != Lv[j]){ return Lv[i] < Lv[j]; }
    int L_i = (i + k >= n ? -1 : Lv[i + k]);
    int L_j = (j + k >= n ? -1 : Lv[j + k]);

    return L_i < L_j;
}

int main()
{
    int A[MAX];
    std::string T;
    std::cin >> T;
    n = T.size();
	byte *t;
	t = new byte [(n >> 3) + 1];

    int i;
    for(i = 0; i < n; i++){ A[i] = i; }
    for(i = 0; i < n; i++){ Lv[i] = T[i]; }
    std::sort(A, A + n, cmp_Lv);

	for(i = 1; i < n; i++){
		t[i >> 3] = (Lv[A[i]] != Lv[A[i - 1]] ? t[i >> 3] | mask[i & 7] : t[i >> 3] & ~mask[i & 7]);
	}

    Lv[A[0]] = 0;
    for(i = 1; i < n; i++){
        Lv[A[i]] = Lv[A[i - 1]] + !!(mask[i & 7] & t[i >> 3]);
    }

    k = 1;
    while(1){
        if(k > n) break;

        std::sort(A, A + n, cmp);

		for(i = 1; i < n; i++){
			t[i >> 3] = (cmp(A[i - 1], A[i]) ? t[i >> 3] | mask[i & 7] : t[i >> 3] & ~mask[i & 7]);
		}
		Lv[A[0]] = 0;
		for(i = 1; i < n; i++){
			Lv[A[i]] = Lv[A[i - 1]] + !!(mask[i & 7] & t[i >> 3]);
		}

        if(Lv[A[n - 1]] == n - 1) break;
        k <<= 1;
    };

    std::string P;
    int q, left, right, mid, crit;
    bool exist;
    scanf("%d", &q);

    A[n] = n;

    while(q){
        std::cin >> P;
        left = 0, right = n, exist = false;
        while(left < right){

            if(n < P.size()){ exist = false; break; }

            mid = (left + right) / 2;
            crit = T.compare(A[mid], P.size(), P);

            if(crit > 0){ right = mid; }
            else if(crit < 0){ left = mid + 1; }
            else{ exist = true; break; }
        };
        if(T.compare(A[right], P.size(), P) == 0) exist = true;
        if(exist){ printf("1\n"); }else{ printf("0\n"); }
        q--;
    }
    return 0;
}

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

int fact(int n) { 
    int factorial=1;
    for(int i = 1; i <=n; ++i)
    {
        factorial *= i;
    }
    return factorial;
}


int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> v;
    vector<double> distance;
    for (int i=0; i<n; i++)
        {
            int x,y;
            cin >> x >> y;
            v.push_back(make_pair(x,y));
        }
    for (int i=0; i<n-1; i++)
        for (int j=i+1; j<n; j++)
        {
            distance.push_back(sqrt(pow(v[i].first - v[j].first,2)+pow(v[i].second - v[j].second,2)));
        }
    double sum = 0;
    for (int k=0; k<distance.size(); k++)
        {
            sum += distance[k];
        }
    double res = sum * fact(n-1) * 2 / fact(n);
    printf("%9.6f", res);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin >> n >> k;
  ll cnt=0;
  if(k==0){
    cout << n*n << endl;
    return 0;
  }
  for(ll i=k+1;i<=n;i++){
    cnt+=(i-1-k+1)*(n/i)+max(ll(0),n%i-k+1);
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<string> t(n); REP (i, n) cin >> t[i];
  int ans = 0;
  int a = 0, b = 0, c = 0;
  for (auto& s: t) {
    if (s[0] == 'B' && s.back() == 'A') c++;
    else if (s[0] == 'B') b++;
    else if (s.back() == 'A') a++;

    REP (i, (int)s.size() - 1) {
      if (s[i] == 'A' && s[i + 1] == 'B') ans++;
    }
  }
  ans += max(0LL, c - 1);
  if (c && a) {
    ans++;
    a--;
  }
  if (c && b) {
    ans++;
    b--;
  }
  ans += min(a, b);
  cout << ans << endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

long long calc(long long A) {
	long long cnt1 = (A + 1) / 2;
	long long ans = cnt1 % 2;
	if (A % 2 == 0) ans ^= A;
	return ans;
}

int main() {
	long long A, B;
	cin >> A >> B;
	long long ans = calc(B) ^ calc(A - 1);
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
long long n;
struct Edge{
	long long u,v,w,next;
}e[2000000];
struct node{
	long long maxx_1,maxx_2;
}tr[600000];
long long dep[600000];
long long h[600000];
void make(long long st,long long nd,long long w){
	long long temp=tr[nd].maxx_1+w;
	if(temp>tr[st].maxx_2)tr[st].maxx_2=temp;
	if(tr[st].maxx_2>tr[st].maxx_1) swap(tr[st].maxx_1,tr[st].maxx_2);
	/*
	if(temp>tr[st].maxx_1){
		tr[st].maxx_2=tr[st].maxx_1;
		tr[st].maxx_1=temp;
	}
	else if(temp>=tr[st].maxx_2){
		tr[st].maxx_2=temp;
	}*/
	return ;
}
void dfs(long long x){
	for(long long i=h[x];i;i=e[i].next){
		long long v=e[i].v,w=e[i].w;
		if(!dep[v]){
			dep[v]=dep[x]+1;
			dfs(v);
			make(x,v,w);
		}
	}
}
long long cnt=0;
int main(){
	cin>>n;
	memset(tr,0,sizeof(tr));
	for(long long i=1;i<n;i++){
		long long u,v,w;
		scanf("%lld%lld%lld",&u,&v,&w);
		u++;v++;
		e[++cnt]=(Edge){u,v,w,h[u]};h[u]=cnt;
		e[++cnt]=(Edge){v,u,w,h[v]};h[v]=cnt;
	}
	dep[1]=1;
	dfs(1);
	long long ans=0;
	for(long long i=1;i<=n;i++){
		ans=max(ans,tr[i].maxx_1+tr[i].maxx_2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 25088