akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
#include<queue>
#include<functional>
using namespace std;

int main(void)
{
	int K;
	cin >> K;

	typedef pair<int, int> State;
	vector<vector<State>> table(K, vector<State>());
	for(int i=0; i<K; i++){
		table[i].push_back(make_pair(1, (i+1)%K));
		table[i].push_back(make_pair(0, (i*10)%K));
	}

	priority_queue<State, vector<State>, greater<State>> task;
	task.push(make_pair(1, 1));
	vector<bool> flag(K, true);
	while(task.empty() != true){
		auto p = task.top();
		task.pop();

		int cost = p.first;
		int pos = p.second;
		if(pos == 0){
			cout << cost << endl;
			break;
		}
		else if(flag[pos] == false)
			continue;

		flag[pos] = false;
		for(auto it=table[pos].begin(); it!=table[pos].end(); it++){
			State next = make_pair(cost+it->first, it->second);
			task.push(next);
		}
	}

	return 0;
}


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

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}

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

    ll base = 0;
    int X, Y, Z;
    cin >> X >> Y >> Z;
    int N = X + Y + Z;
    vector<pii> AB(N);
    REP(i, N) {
        int A, B, C;
        cin >> A >> B >> C;
        base += C;
        A -= C;
        B -= C;
        // C = 0;
        AB[i] = make_pair(A, B);
    }
    sort(all(AB), [](pii x, pii y) { return x.second - x.first < y.second - y.first; });

    priority_queue<ll, vector<ll>, greater<ll>> q;
    vector<ll> v(N + 1, 0);
    REP(i, N) {
        int A = AB[i].first;
        q.push(A);
        if (i < X) {
            v[X] += A;
        } else {
            v[i + 1] = v[i] + A - q.top();
            q.pop();
        }
    }

    q = priority_queue<ll, vector<ll>, greater<ll>>();
    vector<ll> w(N + 1, 0);
    REP(i, N) {
        int j = N - 1 - i;
        int B = AB[j].second;
        q.push(B);
        if (i < Y) {
            w[Y] += B;
        } else {
            w[i + 1] = w[i] + B - q.top();
            q.pop();
        }
    }

    ll result = LLONG_MIN;
    FOR(i, X, N - Y + 1) {
        int j = N - i;
        amax(result, v[i] + w[j]);
    }

    result += base;

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 6636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  char c;
  cin >> c;
  cout << (char)(c+1) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		System.out.println(n < k ? 0 : 10);
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100010];
    cin>>n;
    set<ll> st;
    map<ll,ll> mp;
    rep(i,n){
        cin>>a[i];
        st.insert(a[i]);
        mp[a[i]]++;
    }
    if(mp.size()==1){
        if(mp[0]==n) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else if(mp.size()==2){
        if(n%3!=0) cout<<"No"<<endl;
        else if(mp[0]==n/3){
            auto itr=st.begin();itr++;
            if(mp[*itr]==n/3*2) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
        else cout<<"No"<<endl;
    }
    else if(mp.size()==3){
        if(n%3!=0) cout<<"No"<<endl;
        else{
            auto itr=st.begin();
            ll b=*itr;itr++;
            ll c=*itr;itr++;
            ll d=*itr;
            ll e=(b^c);
            if(mp[b]==n/3&&mp[c]==n/3&&mp[d]==n/3&&(e==d)){
                cout<<"Yes"<<endl;
            }
            else cout<<"No"<<endl;
        }
    }
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 105;

int n, m, q, ans = 0;
int a[N], b[N], c[N], d[N];
int cur[N];

void gen(int idx)
{
	if(idx > n)
	{
		int val = 0;
		for(int i = 1; i <= q; i++)
		{
			if(cur[b[i]] - cur[a[i]] == c[i])
				val += d[i];
		}
		ans = max(ans, val);
		return;
	}
	for(int i = cur[idx - 1]; i <= m; i++)
	{
		cur[idx] = i;
		gen(idx + 1);
	}
}

int32_t main()
{
	IOS;
	cin >> n >> m >> q;
	for(int i = 1; i <= q; i++)
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	cur[0] = 1;
	gen(1);
	cout << ans;
	return 0;
}


Measured memory_bytes: 3660
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def func(S):
    tmp = ""
    ret = 0
    for s in S:
        if tmp == s:
            ret += 1
            tmp = '1' if s == '0' else '0'
        else:
            tmp = s
    return ret


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    ret = func(S)
    SS = S[::-1]
    ret = min(ret, func(SS))
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a,b;
  cin >> a >> b;
  pr(a/__gcd(a,b)*b);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
// Problem : F - Range Set Query
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
struct Node
{
	int l,r,ind;
};
bool comp(Node &n1,Node &n2)
{
	return n1.r<n2.r;
}
vector<int> Bit;
void Update(int ind,int n,int val)
{
	while(ind<=n)
	{
		Bit[ind]+=val;
        ind=ind+(ind&-ind);
	}
	return;
}
int Query(int ind)
{
	int ans=0;
	while(ind>0)
	{
		ans+=Bit[ind];
        ind=ind&(ind-1);
	}
	return ans;
}
void solve()
{
	int n,q,i;
	cin>>n>>q;
	int C[n+1];
	for(i=1;i<=n;i++)
		cin>>C[i];
	int Index[n+1];
	Bit.resize(n+1,0);
	memset(Index,-1,sizeof(Index));
	vector<Node> V(q);
	for(i=0;i<q;i++)
	{
		cin>>V[i].l>>V[i].r;
		V[i].ind=i;
	}
	sort(V.begin(),V.end(),comp);
	int j=0;
	int l=V[j].l,r=V[j].r,ind=V[j].ind;
	int Ans[q];
	for(i=1;i<=n && j<q;i++)
	{
		l=V[j].l,r=V[j].r,ind=V[j].ind;
		if(Index[C[i]]==-1)
		{
			// trace(C[i]);
			Index[C[i]]=i;
			Update(Index[C[i]],n,1);
		}
		else
		{
			Update(Index[C[i]],n,-1);
			Index[C[i]]=i;
			Update(Index[C[i]],n,1);
		}
		while(j<q && r==i)
		{
			l=V[j].l,r=V[j].r,ind=V[j].ind;
			Ans[ind]=Query(r)-Query(l-1);
			j++;
			if(j<q)
			{
				l=V[j].l,r=V[j].r,ind=V[j].ind;
			}
		}
	}
	// trace(i,j);
	for(i=0;i<q;i++)
		cout<<Ans[i]<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


Measured memory_bytes: 31128
// 1_agc033_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

vector<vector<char>> m;
vector<vector<int>> d;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    m.resize(h, vector<char>(w));
    d.resize(h, vector<int>(w));

    queue<pair<int, int>> q;

    rep(i, h){
        rep(j, w){
            d[i][j] = -1;
            cin >> m[i][j];
            if(m[i][j] == '#'){
                d[i][j] = 0;
                q.push(make_pair(i, j));
            }
        }
    }

    while(!q.empty()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        if(x > 0 && d[x - 1][y] == -1){
            d[x - 1][y] = d[x][y] + 1;
            q.push(make_pair(x - 1, y));
        }
        if(x < h - 1 && d[x + 1][y] == -1){
            d[x + 1][y] = d[x][y] + 1;
            q.push(make_pair(x + 1, y));
        }
        if(y > 0 && d[x][y - 1] == -1) {
            d[x][y - 1] = d[x][y] + 1;
            q.push(make_pair(x, y - 1));
        }
        if(y < w - 1 && d[x][y + 1] == -1){
            d[x][y + 1] = d[x][y] + 1;
            q.push(make_pair(x, y + 1));
        }
    }

    int ans = 0;
    rep(i, h){
        rep(j, w){
            if(d[i][j]> ans) ans = d[i][j];
        }
    }

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


Measured memory_bytes: 13456
N, C = map(int, input().split())
stc = [[int(x) for x in input().split()] for _ in range(N)]

im = [[0] * (10**5 + 1) for _ in range(C + 1)]
for x in stc:
    s,t,c = x
    im[c][s] += 1
    im[c][t] -= 1

for c in range(1, C + 1):
    v = 0
    for i in range(1, 10**5 + 1):
        n = im[c][i]
        v += n
        if n > 0:
            im[c][i - 1] += 1
        im[c][i] = v
print(max([sum(x) for x in zip(*im[1:])]))

Measured memory_bytes: 46376
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, m;
    cin >> n >> m;
    vec a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<int>());

    auto s = accumulate(all(a), 0.0);

    int c = 0;
    rep(i, n) if (a[i] >= s / (4 * m)) c++;

    if (c >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

const ll N = 100005, mod = 1e9 + 7;
vector<ll> g[N];
ll ans = 0, dp[N][2];
bool used[N][2];

// 1 --> black
// 0 --> white

ll dfs(ll v, ll p, ll cl){
    if(used[v][cl]){return dp[v][cl];}
    ll tmp = 1; used[v][cl] = 1;
    for(auto to : g[v]){
        ll tmp2 = 1;
        if(to != p){
            tmp2 = dfs(to, v, 0);
            if(!cl){tmp2 = (tmp2 + dfs(to, v, 1)) % mod;}
        }
        tmp = (tmp * tmp2) % mod;
    }
    return dp[v][cl] = tmp;
}

int main() {
    ll n; cin>>n;
    for(ll i = 1; i < n; i++){
        ll x, y; cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    ans = (dfs(1, -1, 0) + dfs(1, -1, 1)) % mod;
    cout<<ans;
	return 0;
}

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

vector<int> stk;
vector<int> vis(100001);
int pd[100001];

int ciclo = 0;

int cam(int v, vector<int> *adj) {
	int maxi = -1;
	
	if (adj[v].size() == 0) {
		return 0;
	} else {
		for (int u : adj[v])
			maxi = max(maxi, pd[u] + 1);
	}
		
	return maxi;
}

void dfs(int v, vector<int> *adj) {
	vis[v] = 1;
	
	for (int u : adj[v]) {
		if (vis[u] == 0) dfs(u, adj);
		if (vis[u] == 1) ciclo++;
	}
	
	vis[v] = 2;
	stk.push_back(v);
}

int main() {
	int n, e;
	cin >> n >> e;
	vector<int> adj[n + 1];
	
	for (int i = 0; i < e; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		pd[a] = 0;
	}
	
	for (int i = 1; i <= n; i++)
		if (vis[i] == 0) dfs(i, adj);

	int r = -1;
	for (int v : stk)
		 r = max(r, pd[v] = cam(v, adj));
	
	cout << r << endl;
	return 0;
}


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

int main() {
  int n,k,s=0;
  cin>>n>>k;
  for(int i=0; i<n; i++){
    int x;
    cin>>x;
    if(x>k-x){
      s+=2*(k-x);
    }
    else{
      s+=2*x;
    }
  }
  cout<<s;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        String S = sc.next();
        String T = sc.next();

        String[] Sarray = S.split("", 0);
        String[] Tarray = T.split("", 0);

        String ans = "";

        for (int i = 0; i < n; i++) {
            ans = ans + Sarray[i]; 
            ans = ans + Tarray[i];
        }

        System.out.println(ans);
    }
}

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

int calc(string n, string op) {
	int sum=n[0] -'0';
	for(int i=1; i<=n.length(); i++) {
		if (op[i-1] == '+')
			sum += n[i] - '0';
		else
			sum -= n[i] - '0';
	}
	return sum;
}

int main() {
	string S;
	cin >> S;
	
	string eq;
	int N = 3;
	int sum;

	for(int bit=0; bit < (1<<(N)); ++bit) {
		eq  = S[0]; 
		sum = S[0] - '0';
		for(int i=0; i < N; ++i) {
			if (bit&(1<<i)) {		
				eq = eq + "+" + S[i+1]; 
				sum += S[i+1] -'0';
			} else {
				eq = eq + "-" + S[i+1]; 
				sum -= S[i+1] -'0';
			}	
		}
		if (sum == 7) {
			cout << eq << "=7" << endl;	
			break;
		}
		eq = "";
	}
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

void solve() {
    string s; cin >> s;

    int ptr = 0;
    auto parse = [&](auto &&self) -> int {
        int depth = 0;
        if(s[ptr] == '[') {
            assert(s[ptr++] == '[');
            vector<int> nums;
            while(s[ptr] != ']') {
                nums.emplace_back(self(self));
            }
            assert(s[ptr++] == ']');
            sort(nums.begin(), nums.end());
            return accumulate(nums.begin(), nums.begin() + (nums.size()+1)/2, 0);
        }
        else {
            int res = 0;
            while(ptr < s.size() and isdigit(s[ptr])) res = res*10 + (s[ptr++]-'0');
            return (res + 1) / 2;
        }
    };
    int ans = parse(parse);
    printf("%d\n", ans);
}

int main() {
    int N; scanf("%d", &N);
    while(N--) solve();
    return 0;
}



Measured memory_bytes: 3328
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	K := Int(s)
	cnt := 0
	for i := 1; i <= N; i++ {
		n := K - i%K
		if (n+n)%K == 0 {
			pt := (N-(K-i%K))/K + 1
			cnt = cnt + pt*pt
		}
	}
	fmt.Println(cnt)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int N = input[0];
        int K = input[1];
        string S = Read();
        string ans = "";
        ans += S.Substring(0, K - 1);
        ans += S.Substring(K - 1, 1).ToLower();
        ans += S.Substring(K);
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

int main()
{
  int N;
  cin >> N; // 本数 : N - 2
  queue<pair<int, int>> Q;
  if (N % 2)
  {
    for (int n = 1; n < N; n++)
    {
      for (int i = n + 1; i < N; i++)
      {
        if (n == i || n == (N - i))
          continue;
        Q.push({n, i});
      }
    }
    for (int i = 1; i < N; i++)
    {
      Q.push({N, i});
    }
  }
  else
  {
    for (int n = 1; n <= N; n++)
    {
      for (int i = n + 1; i <= N; i++)
      {
        if (n == i || n == (N + 1 - i))
          continue;
        Q.push({n, i});
      }
    }
  }
  cout << Q.size() << endl;
  while (Q.size())
  {
    cout << Q.front().first << ' ' << Q.front().second << endl;
    Q.pop();
  }
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define  sf  scanf
#define  pf  printf
#define  ll  long long
int main()
{
    int n,m,i,j;
    sf("%d",&n);
    if(n<1000)
    {
        pf("ABC\n");
    }
    else
    {
        pf("ABD\n");
    }
    return 0;
}


Measured memory_bytes: 256
import sys

def main(N, M, Xs):
    Xs.sort()

    if N >= M:
        return 0

    assert M == len(Xs)

    diffs = []
    # find max gaps between visiting points
    for i in range(1, M):
        # index after gap, gap length
        diffs.append((i, Xs[i] - Xs[i-1]))
    diffs.sort(key=lambda x: x[1], reverse=True)

    # index of the first places
    positions = [0] + [diff[0] for diff in diffs[:N-1]]

    # moves = sum of (end point - start point)
    moves = [ Xs[-1] - Xs[positions[-1]] ] # the last
    for i in range(1, N):
        moves.append(Xs[positions[i]-1] - Xs[positions[i-1]])

    return sum(moves)

line = sys.stdin.readline()
N,M = [int(x) for x in line.strip().split(' ')]

line = sys.stdin.readline()
Xs = [int(x) for x in line.strip().split(' ')]

print(main(N, M, Xs))

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int) 1e5 + 7;
int n, m, d[N];
vector<int> g[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 2; i <= n; i++) {
    d[i] = -1;
  }
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int a = q.front();
    q.pop();
    for (auto &b : g[a]) {
      if (d[b] == -1) {
        d[b] = 1 + d[a];
        q.push(b);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (d[i] == -1) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  for (int i = 2; i <= n; i++) {
    for (auto &j : g[i]) {
      if (d[j] + 1 == d[i]) {
        cout << j << "\n";
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 10560
high,width = map(int, input().split())
s_list = [list(input()) for _ in range(high)]
tmp_list = [[0 for _ in range(width)] for _ in range(high)]
dir = [[-1,-1],[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0]]
for h in range(high):
    for w in range(width):
        if s_list[h][w] == '#':
            tmp_list[h][w] = '#'
            for x,y in dir:
                tate = h+x
                yoko = w+y
                if tate >= 0 and yoko >= 0 and tate < high and yoko < width:
                    if s_list[tate][yoko]=='.':
                        tmp_list[tate][yoko] += 1

for tmp in tmp_list:
    t = map(str, tmp)
    print(''.join(t))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;
const int MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


map<ll, ll> primeFactor(ll N) {
    map<ll,ll> res;
    for(ll i = 2; i*i<=N; ++i) {
        while(N%i==0) {
            res[i] ++;
            N /= i;
        }
    }
    if(N != 1) res[N] = 1;
    return res;
}

int main() {
    ll n,m; cin >> n >> m;
    COMinit();
    map<ll, ll> p = primeFactor(m);
    ll ans = 1;
    for(auto x : p) {
        ans *= COM(x.second+n-1, n-1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
typedef vector<int> vi;
typedef long long ll;
const int inf = int(1e9);
const int mod = inf + 7;

void solve(){
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string ans;
	cin>>ans;
	if(ans==s)a--;
	if(ans==t)b--;
	cout<<a <<" "<<b;

}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.10f", num)
end

n = input_n

puts output_f(((n + 1) / 2) / n.to_f)


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

#define mod 1000000007

int n,m;
ll x[101010],y[101010];
ll xx[101010],yy[101010];
ll sx[101010],sy[101010];
ll ssx,ssy;
ll sssx,sssy;

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>m;
  rep(i,n)cin>>x[i];
  rep(i,m)cin>>y[i];
  rep(i,n-1){
    xx[i]=(x[i+1]-x[i])%mod;
  }
  rep(i,n-1)sx[i+1]=(sx[i]+xx[i])%mod;
  rep(i,n)ssx=(ssx+sx[i])%mod;
  rep(i,n-1){
    sssx=(sssx+ssx)%mod;
    ssx=(ssx+mod-((n-1-i)*xx[i])%mod)%mod;
  }
  rep(i,m-1){
    yy[i]=(y[i+1]-y[i])%mod;
  }
  rep(i,m-1)sy[i+1]=(sy[i]+yy[i])%mod;
  rep(i,m)ssy=(ssy+sy[i])%mod;
  rep(i,m-1){
    sssy=(sssy+ssy)%mod;
    ssy=(ssy+mod-((m-1-i)*yy[i])%mod)%mod;
  }
  cout<<sssx*sssy%mod<<endl;
	return 0;
}


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

int main() {
  int n, even = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (tmp % 2 == 0) even++;
  }

  if (even == 0)
    cout << pow(3, n) - 1;
  else
    cout << pow(3, n) - pow(2, even);

  return 0;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'


struct SegmentTree{
  private:
    int n;
    vector<int64> dat;
  public:
    SegmentTree(vector<int64> v) {
      int SIZE = v.size();
      n = 1;
      while (n < SIZE) n <<= 1;
      dat.resize(2 * n - 1, 0);
      for (int i = 0; i < SIZE; ++i) dat[i + n - 1] = v[i];
      for (int i = n - 2; i >= 0; --i) dat[i] = __gcd(dat[2 * i + 1], dat[2 * i + 2]);
    }

    void update(int pos, int val){
      pos += n - 1;
      dat[pos] = val;
      while (pos > 0){
        pos = (pos - 1) / 2;
        dat[pos] = __gcd(dat[2 * pos + 1], dat[2 * pos + 2]);
      }
    }

    int64 query(int a, int b, int k = 0, int l = 0, int r = -1){
      if (r < 0) r = n;
      if (r <= a || b <= l) return 0;
      if (a <= l && r <= b) return dat[k];
      int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return __gcd(vl, vr);
    }
};

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

  int n; cin >> n;
  vector<int64> v(n); rep(i, n) cin >> v[i];
  SegmentTree seg(vector<int64>(n, 0));
  
  for (int i = 0; i < n; ++i){
    seg.update(i, v[i]);
  }

  int64 ans = max(seg.query(1, n), seg.query(0, n - 1));

  for (int i = 1; i <= n - 2; ++i){
    ans = max(ans, __gcd(seg.query(0, i), seg.query(i + 1, n)));
  }

  print(ans);
  
  return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define all(c) (c).begin(), (c).end()
const int N = 1299709;

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

void sieve(vector<int>& v, int n){
    v.assign(n, 0); iota(all(v), 2);
    for(auto div=v.begin(); sqr(*div)<=v.back(); ++div){
        v.erase(remove_if(div+1, v.end(), [&](int x){return x % *div == 0;}), v.end());
    }
}

int main(){
    vector<int> primes;
    sieve(primes, N);
    for(int k; cin >> k, k;){
        auto itr = equal_range(all(primes), k);
        cout << (*itr.second == *itr.first? *itr.second - *(--itr.first): 0) << '\n';
    }
    return 0;
}

Measured memory_bytes: 6144
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
l=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    l[a-1]+=b
s=0
for i in range(10**5):
    if s+l[i]>=k:print(i+1);break
    else: s+=l[i]


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll ans = 0;
	int k; cin >> k;
	rep(i, 1, k + 1) rep(j, 1, k + 1) rep(t, 1, k + 1) ans += __gcd(i, __gcd(j, t));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
    int a, b, c, cont = 0;
    scanf("%d %d %d", &a, &b, &c);
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
        {
            cont += 1;
        }
    }
    printf("%d\n", cont);
}


Measured memory_bytes: 2120
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define int ll
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=500010,Mod=1e9+7;
int lowbit(int x){return x&(-x);}
struct BIT{
	int c[N],n;
	void Add(int x,int d){while(x<=n){c[x]=(c[x]+d)%Mod;x+=lowbit(x);}}
	int query(int x){int ret=0;while(x){ret=(ret+c[x])%Mod;x-=lowbit(x);}return ret;}
}f,g;
int n,A,B,s[N];
signed main(){
	n=gi();A=gi();B=gi();
	for(int i=1;i<=n;i++)s[i]=gi();s[0]=-1e18;
	f.n=g.n=n+1;
	f.Add(1,1);g.Add(1,1);
	int lsta=1,lstb=1;
	for(int i=1;i<n;i++){
		int x=upper_bound(s,s+n+1,s[i+1]-A)-s,y=upper_bound(s,s+n+1,s[i+1]-B)-s;
		f.Add(i+1,g.query(min(i,x)));g.Add(i+1,f.query(min(i,y)));
		if(s[i+1]-s[i]<A){
			for(int j=lsta;j<=i;j++)f.Add(j,Mod-f.query(j));
			lsta=i+1;
		}
		if(s[i+1]-s[i]<B){
			for(int j=lstb;j<=i;j++)g.Add(j,Mod-g.query(j));
			lstb=i+1;			
		}
	}
	printf("%lld\n",(f.query(n+1)+g.query(n+1))%Mod);
	return 0;
}

Measured memory_bytes: 9216
string = input()
a, b, c, d = [int(string[i]) for i in range(4)]
op_dict = {"1": "+", "0": "-"}

for i in range(8):
    ops = bin(i)[2:].zfill(3)
    res = a
    if op_dict[ops[0]] == "+":
        res += b
    else:
        res -= b
    if op_dict[ops[1]] == "+":
        res += c
    else:
        res -= c
    if op_dict[ops[2]] == "+":
        res += d
    else:
        res -= d

    if res == 7:
        print("".join([str(a), op_dict[ops[0]], str(b), op_dict[ops[1]], str(c), op_dict[ops[2]], str(d), "=7"]))
        exit()


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;

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

    ll N, M;
    cin >> N >> M;
    vector<ll> boxes(N + 1, 1);
    vector<bool> polluted(N + 1, false);
    polluted[1] = true;

    for (ll i = 0; i < M; i++) {
        ll x, y;
        cin >> x >> y;
        if (polluted[x]) {
            polluted[y] = true;
        }
        boxes[x]--;
        boxes[y]++;
        if (boxes[x] == 0) {
            polluted[x] = false;
        }
    }

    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        if (polluted[i] && boxes[i] != 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



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

int main(){
    deque<int> deq;
    int q;
    cin >> q;
    
    int query_num;
    int d,x,p;

    for(int i=0;i<q;i++){
        cin >> query_num;
        if(query_num==0){
            cin >> d >> x;
            if(d==0){
                deq.push_front(x);
            }else{
                deq.push_back(x);
            }
        }else if(query_num==1){
            cin >> p;
            cout << deq.at(p) << endl;
        }else{
            cin >> d;
            if(d==0){
                deq.pop_front();
            }else{
                deq.pop_back();
            }
        }
    }
}


Measured memory_bytes: 4572
n = int(input())
x = list(map(int, input().split()))
x_sort = sorted(x)
half_l = x_sort[(n-1)//2]
half_r = x_sort[(n)//2]

for i in range(n):
    if x[i] <= half_l:
        print(half_r)
    else:
        print(half_l)


Measured memory_bytes: 30904
#!/usr/bin/env python3
import sys

def solve(H: int, W: int, S: "List[str]"):
    tab = [0 for i in range(H*W)]
    for i in range(W):
        acc0, acc1 = 0, 0
        for j in range(H):
            j2 = H-1-j
            tab[W*j+i] += acc0
            tab[W*j2+i] += acc1
            acc0 = 0 if S[j][i] == "#" else acc0+1
            acc1 = 0 if S[j2][i] == "#" else acc1+1
    for j in range(H):
        acc2, acc3 = 0, 0
        for i in range(W):
            i2 = W-1-i
            tab[W*j+i] += acc2
            tab[W*j+i2] += acc3
            if S[j][i] == "#":
                tab[W*j+i] = -10**10
            else:
                tab[W*j+i] += 1
            acc2 = 0 if S[j][i] == "#" else acc2+1
            acc3 = 0 if S[j][i2] == "#" else acc3+1
    
    print(max(max(tab), 0))

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    solve(H, W, S)

if __name__ == '__main__':
    main()


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

int main(){
	int n,x,y;
	cin >> n >> x >>y;
	vector<int> k(n-1);
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			int d;
			if((i<x&&j<=x)||(y<=i&&y<j)){
				d=j-i;
			}else if(i<=x&&y<=j){
				d=j-y+1+x-i;
			}else if(i<=x&&x<j&&j<y){
				d=min(j-i,x-i+1+y-j);
			}else if(x<i&&i<y&&y<=j){
				d=min(j-i,i-x+1+j-y);
			}else if(x<i&&j<y){
				d=min(j-i,i-x+1+y-j);
			}
			k.at(d-1)++;
		}
	}
	for(int i=0;i<n-1;i++){
		cout << k.at(i) << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;

typedef long long ll;
#define pb push_back

#define rep(i, n) for (int i=0;i<(n);++i)
#define rep2(i, s, n) for (int i=s;i<(n);++i)
#define INF (1e9)

/* Adjacent List */
// cf. http://www.prefield.com/algorithm/graph/graph.html
class Edge {
public:
    int u, v; // (u,v)
    int cost;
    Edge(int u, int v, int cost):
        u(u), v(v), cost(cost) {}
    bool operator < (const Edge& e) {
        return cost != e.cost ? cost < e.cost : 
            u != e.u ? u < e.u : v < e.v;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

/* Union-Find Tree */
class UnionFind {
public:
    vector<int> p,r; // parent, rank
    UnionFind(int n) {
        p.resize(n); r.resize(n);
        iota(p.begin(), p.end(), 0);
        fill(r.begin(), r.end(), 0);
    }
    int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); }
    void unite(int a, int b) {
        int x = find(a), y = find(b);
        if (x == y) return;
        if(r[x] > r[y]) p[y] = x;
        else if (r[x] < r[y]) p[x] = y;
        else { p[y] = x; ++r[x]; } 
    }
    bool same(int x, int y) { return find(x) == find(y); }
};

/* Kruskal's Algorithm */
pair<int,Edges> kruskal(Graph& G, int V, int E)
{
    Edges edg, A;
    int sum = 0;
    UnionFind uf(V);

    rep(i,V) for(auto& e:G[i]) edg.pb(e);
    
    // sort w.r.t weights 
    sort(edg.begin(), edg.end());

    for(auto& e:edg) {
        if (!uf.same(e.u, e.v)) {
            A.pb(e);
            sum += e.cost;
            uf.unite(e.u, e.v);
        }
    }

    return pair<int,Edges>(sum, A);
}

int main()
{
    int V,E; cin>>V>>E;
    Graph G(V);
    
    rep(i,E){
        int u,v,c; cin>>u>>v>>c;
        G[u].pb(Edge(u,v,c));
    }

    pair<int,Edges> MST = kruskal(G,V,E);
    cout << MST.first << endl;
}

Measured memory_bytes: 6796
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;

vector<vector<int> > g;
vector<int> d1, d2;

void dfs(int pos, int p) {
    d2[pos] = 1;
    int m1 = 0, m2 = 0;
    for (int i = 0; i < g[pos].size(); ++i) {
        int to = g[pos][i];
        if (to == p)
            continue;
        dfs(to, pos);
        d2[pos] = max(d2[pos], d2[to] + 1);
        d1[pos] = max(d1[pos], d1[to]);
        if (d2[to] > m1) {
            m2 = m1;
            m1 = d2[to];
        }
        else {
            if (d2[to] > m2)
                m2 = d2[to];
        }
    }
    d1[pos] = max(d1[pos], m1 + m2 + 1);
}

void solve() {
    int n;
    cin >> n;
    g.assign(n, vector<int>());
    int a, b;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    d1.assign(n, 0);
    d2.assign(n, 0);
    dfs(0, -1);
    //cout << d1[0] << endl;
    if ((d1[0] % 3) == 2)
        cout << "Second\n";
    else {
        cout << "First\n";
    }
    
}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 27776
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())

    res = 0

    for i in range(1,N+1):
        if (i % 3 != 0) & (i % 5 != 0):
            res += i

    print(res)



main()


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;
ll a[N],b[N],z;int A,B;
inline ll C2(int x){return ((ll)x)*(x-1);}
ll solve(ll m){
	int i;
	if(m<0ll){
		ll s=0ll;
		m=-(m+1ll);
		rep(i,1,A)s+=(b+B+1)-upper_bound(b+1,b+B+1,m/a[i]);
		return s;
	}else{
		ll s=0ll;
		rep(i,1,B)s+=upper_bound(b+1,b+B+1,m/b[i])-(b+1);
		rep(i,1,A)s+=upper_bound(a+1,a+A+1,m/a[i])-(a+1);
		rep(i,1,A)if(a[i]*a[i]<=m)--s;
		rep(i,1,B)if(b[i]*b[i]<=m)--s;
		//printf("solve m=%lld s=%lld z=%lld\n",m,s,z);
		return (s>>1)+z;
	}
}
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n;ll x,cn,k,l=-1000000000000000000ll,r=1000000000000000000ll,m,s;
    scanf("%d%lld",&n,&k);cn=C2(n);
    while(n--){
		scanf("%lld",&x);
		if(x){
			if(x>0)a[++A]=x;
			else b[++B]=-x;
		}
	}
	//printf("%lld - %lld - %lld\n",cn,C2(A),C2(B));
	z=(cn-(C2(A)+C2(B)))>>1;
	sort(a+1,a+A+1);
	sort(b+1,b+B+1);
	while(l<=r){
		m=(l+r)>>1;
		if(solve(m)<k)l=m+1ll;
		else r=(s=m)-1ll;
	}
	printf("%lld",s);
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define MAXN 305
using namespace std;

int n, num[MAXN][MAXN], ans;
char temp[MAXN], mmp[MAXN][MAXN];

int check(int a)
{
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(mmp[(i+a)%n][j]!=mmp[(j+a)%n][i]) return 0;
        }
    }
    return n;
}

int main()
{
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        scanf("%d", &n);
        scanf("%s", temp);
        for(int j=0; j<n; j++) mmp[i][j]=temp[j];
    }
    for(int a=1; a<=n; a++) ans+=check(a);
    printf("%d\n", ans);
}

Measured memory_bytes: 384
s = gets.chomp
given_word = %w(dreamer dream eraser erase)

s.reverse!
given_word.map! do |w|
  w.reverse
end

def remove_word(s, s_index, given_word)
  if s_index == s.length
    return "YES"
  end
  s_temp = s[s_index, 7]

  given_word.each do |w|
    if (s_temp =~ /^#{w}/) == 0
      s_index += w.length
      return remove_word(s, s_index, given_word)
    end
  end

  return "NO"
end

s_index = 0
  puts remove_word(s, s_index, given_word)


Measured memory_bytes: 52056