akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
//#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
vector <vector <pair<int, int> > > edge;
map <pair<int, int>, int> have;
int last;
inline int copy_past (int v, int color) {
    if (have.count({v, color})) return have[{v, color}];
    have[{v, color}] = last++;
    edge[v].pb({last - 1, 0});
    edge[last - 1].pb({v, 1});
    return last - 1;
}
const int INF = 1e9;
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    last = n;
    edge.resize(n + m + m);
    int a, b, c;
    for (int i = 0; i < m; i++) {
        cin >> a >> b >> c;
        --a, --b;
        a = copy_past(a, c);
        b = copy_past(b, c);
        edge[a].pb({b, 0});
        edge[b].pb({a, 0});
    }
    vector <int> d(n + m + m, INF);
    d[0] = 0;
    deque <int> q;
    q.push_front(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop_front();
        for (auto &i : edge[v]) {
            int to = i.x, len = i.y;
            if (d[to] == INF) {
                d[to] = d[v] + i.y;
                if (i.y == 0) q.push_front(to);
                else q.push_back(to);
            }
        }
    }
    cout << (d[n - 1] == INF ? -1 : d[n - 1]) << '\n';
}


Measured memory_bytes: 57216
class SegmentTree():
    """
    update, get を提供するSegmentTree

    Attributes
    ----------
    __n : int
        葉の数。2 ^ i - 1
    __dot :
        Segment function
    __e: int
        単位元
    __node: list
        Segment Tree
    """
    def __init__(self, A, dot, e):
        """
        Parameters
        ----------
        A : list
            対象の配列
        dot :
            Segment function
        e : int
            単位元
        """
        n = 2 ** (len(A) - 1).bit_length()
        self.__n = n
        self.__dot = dot
        self.__e = e
        self.__node = [e] * (2 * n)
        for i in range(len(A)):
            self.__node[i + n] = A[i]
        for i in range(n - 1, 0, -1):
            self.__node[i] = self.__dot(self.__node[2 * i], self.__node[2 * i + 1])
    
    def update(self, i, c):
        i += self.__n
        node = self.__node
        node[i] = c
        while i > 1:
            i //= 2
            node[i] = self.__dot(node[2 * i], node[2 * i + 1])

    def get(self, l, r):
        vl, vr = self.__e, self.__e
        l += self.__n
        r += self.__n
        while (l < r):
            if l & 1:
                vl = self.__dot(vl, self.__node[l])
                l += 1
            l //= 2
            if r & 1:
                r -= 1
                vr = self.__dot(vr, self.__node[r])
            r //= 2
        return self.__dot(vl, vr)


N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
max_A = max(A)

st = SegmentTree([N] * (max_A + 1), min, N)
edge = [set() for _ in range(N)]
for i, a in enumerate(reversed(A)):
    j = N - 1 - i
    p1 = st.get(a, min(max_A + 1, a + K + 1))
    if p1 < N:
        edge[j].add(p1)
    p2 = st.get(max(0, a - K), a)
    if p2 < N:
        edge[j].add(p2)
    st.update(a, j)

dp = [1] * N
for i in range(N - 1):
    here = dp[i]
    for ni in edge[i]:
        if ni < N:
            dp[ni] = max(dp[ni], dp[i] + 1)

print(max(dp))


Measured memory_bytes: 195352
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int count = 0;

        for (int i = 1; i <= N; i++) {
            if (String.valueOf(i).length() == 1) {
                count++;
            } else if (String.valueOf(i).length() % 2 != 0) {
                count++;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(count);
        out.flush();
        sc.close();
    }
}

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

using ll=long long;

int main(){
    int N; cin >> N;
    set<string> ans;
    for (int i = 0; i < N; i++)
    {
        string S;
        cin >> S;
        ans.insert(S);
    }
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 19128
// AOJ Volume 0 Problem 0010

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

float len(float x1, float y1, float x2, float y2)
{
	return (sqrt(
	             (x1 - x2) * (x1 - x2) +
				 (y1 - y2) * (y1 - y2)
				)
			);
}


int main(void)
{
	int n;
	int i;
	float x1, y1, x2, y2, x3, y3;
	float a, b, c;
	float a1, b1, c1, a2, b2, c2;
	float xp, yp, r;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%f%f%f%f%f%f", &x1, &y1, &x2, &y2, &x3, &y3);

		a = len(x1, y1, x2, y2);
		b = len(x2, y2, x3, y3);
		c = len(x3, y3, x1, y1);
		
		r = (a * b * c) /
		    sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));

		
		a1 = 2 * (x2 - x1);
		b1 = 2 * (y2 - y1);
		c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
		a2 = 2 * (x3 - x1);
		b2 = 2 * (y3 - y1);
		c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		
		xp = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
		yp = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
			
		printf("%.3f %.3f %.3f\n", xp, yp, r);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n,k;
	cin >> n >> k;
	vector<ll> test(n+1,1);
	FOR(i,1,n+1){
		cin >> test[i];
	}
	FOR(i,k+1,n+1){
		cout << (test[i-k] < test[i] ? "Yes\n" : "No\n");
	}
}


Measured memory_bytes: 4780
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M;
	int con1 = 0, con2 = 0;
	int res = 0;
	vector<int> A;
	
	cin>>M>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		
		if(A[i] != i%2 + 1) con1++;
		if(A[i] == i%2 + 1) con2++;
	}
	
	if(M == 2){
		cout<<min(con1, con2)<<endl;
		return 0;
	}
	
	for(int i = 0; i < N; i++){
		
		if(i && A[i] == A[i-1]) {
			if(i+1 != N) {
				if(A[i+1] == A[i] + 1) A[i] = (A[i] + 2)%M+1;
				else A[i] = (A[i] + 1)%M+1;
			} else A[i] = (A[i] + 1)%M+1;
			
			res++;
		}
	}
	// for(int i = 0; i < N; i++)cout<<A[i]<<endl;
	cout<<res<<endl;
	
	return 0;
}


Measured memory_bytes: 3624
#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>
#include <climits>

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

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


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int X,A,B;
    cin >> X >> A >> B;
    X -= A;
    X %= B;
    cout << X << endl;


    return 0;
}


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

int main(){
    string s;
    cin >> s;
    if(s=="SUN")cout << 7 << endl;
    if(s=="MON")cout << 6 << endl;
    if(s=="TUE")cout << 5 << endl;
    if(s=="WED")cout << 4 << endl;
    if(s=="THU")cout << 3 << endl;    
    if(s=="FRI")cout << 2 << endl;
    if(s=="SAT")cout << 1 << endl;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define MOD 1000000007
#define PI acos(-1)
int main()
{
	IOS
	int k,a,b;
	cin>>k>>a>>b;
	int flag=0;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		flag=1;
	}
	if(flag)
	cout<<"OK";
	else
	cout<<"NG";
}

Measured memory_bytes: 3612
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/
#include <bits/stdc++.h>
using namespace std;
 
// #define ll long long int
// #define fi first
// #define se second
// #define pb push_back
// #define all(a) (a).begin(), (a).end()
// #define debug(a) cout << #a << " = " << a << " ";
// #define endl "\n"

// const int  MOD=1000000007 ;

int main() {
    string s;
    cin>>s;
    if(s=="SUN"){
        cout<<"7\n";
    } else if(s=="MON"){
        cout<<"6\n";
    } else if(s=="TUE"){
        cout<<"5\n";
    } else if(s=="WED"){
        cout<<"4\n";
    } else if(s=="THU"){
        cout<<"3\n";
    } else if(s=="FRI"){
        cout<<"2\n";
    } else {
        cout<<"1\n";
    }
    return 0;
}

// int main() {
//     ios_base::sync_with_stdio(false);
//     cin.tie(NULL);
//     long int t = 1;
//     // cin>>t;
//     for (long int tt = 1; tt <= t; tt++) {
//         solve();
//     }
//     return 0;
// }

Measured memory_bytes: 3564
K,N = gets.chomp.split(' ').map(&:to_i)
A = gets.chomp.split(' ').map(&:to_i)
d = []
max_dis = 0

(N-1).times do |n|
  d << (A[n+1] - A[n])
end
d << K - (A[-1]-A[0])
d.each do |dis|
  if max_dis < dis
    max_dis = dis
  end
end
puts K-max_dis

Measured memory_bytes: 30528
def gcd(a,b):
    while b!=0:
        a,b = b,a%b
    return a
def lcm(a,b):
    return (a*b)//gcd(a,b)

N,X = map(int,input().split())
x = list(map(int,input().split()))
x = list(map(lambda q:abs(q-X),x))
ans = x[0]
for xx in x:
    ans = gcd(ans,xx)
print(ans)


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

N = int(input())
red = [tuple(map(int, input().split())) for _ in range(N)]
blu = [tuple(map(int, input().split())) for _ in range(N)]

red.sort(key=lambda x:x[1], reverse=True)
blu.sort(key=lambda x:x[0])

pairs = []
for b in blu:
    for r in red:
        if r[0] < b[0] and r[1] < b[1] and not r in pairs:
            pairs.append(r)
            break

print(len(pairs))


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;

    char cur = S[0];
    int s = 0;
    vector< int > v0, v1;
    for (int i = 1; i < N; i++) {
        if (S[i] != cur) {
            if (cur == '0') {
                v0.push_back(i - s);
                cur = '1';
            } else {
                v1.push_back(i - s);
                cur = '0';
            }
            s = i;
        }
    }
    if (cur == '0') {
        v0.push_back(N - s);
    } else {
        v1.push_back(N - s);
    }

    if (v0.size() == 0 || v0.size() <= K || v1.size() == 0) {
        cout << N << endl;
        return 0;
    }

    int tot_v0[v0.size() + 1];
    tot_v0[0] = 0;
    for (int i = 1; i <= v0.size(); i++) {
        tot_v0[i] = tot_v0[i - 1] + v0[i - 1];
    }
    int tot_v1[v1.size() + 1];
    tot_v1[0] = 0;
    for (int i = 1; i <= v1.size(); i++) {
        tot_v1[i] = tot_v1[i - 1] + v1[i - 1];
    }
    int ans = 0;

    if (S[0] == '0') {
        for (int i = 0; i + K <= v0.size(); i++) {
            int n0 = tot_v0[i + K] - tot_v0[i];
            int s, e;
            s = i == 0 ? 0 : i - 1;
            e = i + K <= v1.size() ? i + K : v1.size();
            int n1 = tot_v1[e] - tot_v1[s];
            ans = max(ans, n0 + n1);
        }
    } else {
        for (int i = 0; i + K <= v0.size(); i++) {
            int n0 = tot_v0[i + K] - tot_v0[i];
            int s, e;
            s = i;
            e = i + K + 1 <= v1.size() ? i + K + 1 : v1.size();
            int n1 = tot_v1[e] - tot_v1[s];
            ans = max(ans, n0 + n1);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1404
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

ll n;
ll d[200010];
ll m;
ll t[200010];

int main() {
    
    cin >> n;
    imfor(i, n) {
        cin >> d[i];
    }
    cin >> m;
    imfor(i, m) {
        cin >> t[i];
    }
    sort(d, d + n);
    sort(t, t + m);
    int pos = -1;
    imfor(i, m) {
        while (1) {
            pos++;
            if (t[i] == d[pos]) {
                break;
            }
            if (pos == n) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 3328
/*
考虑si = p1^e1 * p2^e2 * ... * pk^ek，后面把所有e都放在mod 3意义下考虑，可以得到一个长度是无限的幂次数组
那么si和sj(i != j)不能共存，当且仅当所有质数对应的幂次之和在mod 3意义下均为0。满足这样条件的幂次数组只有1个，如果能处理出对应的数直接贪心即可
设F(s)满足F(s) * s是一个立方数，显然F(s)是一个积性函数，F(p^e) = p^(3 - e)
考虑预处理出<= max{s}^(1 / 3)的所有质数，对于每个s把这些质数筛去后，显然最多还剩2个> max{s}^(1 / 3)的质因子，设筛去后的数是x，分情况讨论：
(1)x是完全平方数，F(x) = F(p^2) = p = x^(1 / 2)
(2)x不是完全平方数，F(x) = F(p * q) = p^2 * q^2 = x^2 
*/

#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long int LL;
const int Max_P(10000);

int N, Ans;
bool flag, have;
map<pair<LL, LL>, int> S;
bool Prime[Max_P + 5];

int main()
{
	scanf("%d", &N);
	memset(Prime, true, sizeof(Prime)), Prime[0] = Prime[1] = false;
	for (int i = 2;i * i <= Max_P;++i)
		if (Prime[i])
			for (int j = i * i;j <= Max_P;j += i)
				Prime[j] = false;
	for (LL input, a, f, sq;N--;)
	{
		scanf("%lld", &input), a = 1LL, f = 1LL;
		for (int i = 2, e;i <= Max_P;++i)
			if (Prime[i] && input % i == 0LL)
			{
				e = 0;
				while (input % i == 0LL)
					input /= i, (++e) %= 3;
				for (int j = 1;j <= e;++j)
					a *= i;
				e = ((3 - e) % 3 + 3) % 3;
				for (int j = 1;j <= e;++j)
					f *= i;
			}
		sq = static_cast<LL>(sqrt(input * 1.0)) - 1LL;
		for (;(sq + 1LL) * (sq + 1LL) <= input;++sq)
			;
		a *= input;
		if (sq * sq == input)
			f *= sq;
		else
			f *= input * input;
		++S[make_pair(a, f)];
	}
	if (S.count(make_pair(1LL, 1LL)))
		have = true, S.erase(make_pair(1LL, 1LL));
	pair<LL, LL> v;
	for (map<pair<LL, LL>, int>::iterator it = S.begin();it != S.end();++it)
		if (S.count(v = make_pair((it -> first).second, (it -> first).first)) == 0 || make_pair(it -> second, (it -> first).first) > make_pair(S[v], (it -> first).second))
		{
			Ans += it -> second;
			if ((it -> first).second == 1LL)
				flag = true;
		}
	printf("%d", Ans + (flag == false && have));
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
long long a[N],l[N],r[N];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	long long d,ret=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		ret+=a[i];
	}
	ret+=(n-1)*d;
	r[1]=a[1];
	for(int i=2;i<=n;i++)
		r[i]=min(a[i],r[i-1]+d);
	l[n]=a[n];
	for(int i=n-1;i>=1;i--)
		l[i]=min(a[i],l[i+1]+d);
	for(int i=2;i<n;i++)
		ret+=min(l[i],r[i]);
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    string S;
    cin >> S;

    if (N % 2) {
        cout << "No" << endl;
        return 0;
    }
    REP(i, N / 2) if (S[i] != S[i + N / 2]) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
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*(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;
}
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;
}
};
ll n,k;
mint dp_sum[110][100010];
mint dp[110][100010];
vl a(110);
int main(){
    cin>>n>>k;
    rrep(i,n)cin>>a[i];
    dp[0][0]=1;
    rep(i,k+1)dp_sum[0][i]=1;
    rrep(i,n){
        rep(j,k+1){
            dp[i][j]=dp_sum[i-1][j];
            if(j-a[i]-1>=0)dp[i][j]-=dp_sum[i-1][j-a[i]-1];
            if(j-1>=0)dp_sum[i][j]=dp_sum[i][j-1]+dp[i][j];
            else dp_sum[i][j]=dp[i][j];
        }
    }
    cout<<dp[n][k].x<<endl;
    return 0;
}

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

using namespace std;

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

// #define int long long

int main(){
    int a,b,n;
    int now=1;
    int count=0;
    int k=0;

    cin>>a>>b>>n;

    int ans[b];
    int num[n];


    for(int i=0;i<n;i++){
        cin>>num[i];
    }

    for(int i=0;i<a;i++){
        
            // cout<<"i="<<i<<endl;

            for(int j=0;j<b;j++){
                ans[j]=now;
            // cout<<now<<" ";
                count++;
            if(count==num[k]){
                now++;
                k++;
                count=0;
            }
        }
        if(i%2==0){
            for(int k=0;k<b;k++){
                cout<<ans[k]<<" ";
            }
        }else{
            for(int k=b-1;k>=0;k--){
                cout<<ans[k]<<" ";
            }
        }
        
        
        cout<<endl;

    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int N, Q;
vector<int> G[200010];
int a[200010];
bool used[200010];
void cal(int s = 1) {
    for (auto t: G[s]) {
        if (!used[t]) {
            a[t] += a[s];
            used[t] = 1;
            cal(t);
        }
    }
}
int main () {
    cin >> N >> Q;
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        a[p] += x;
    }
    used[1] = 1;
    cal();
    for (int i = 1; i <= N; i++) {
        cout << a[i] << ((i == N) ? '\n' : ' ');
    }
}

Measured memory_bytes: 20608
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MIN -10000000
#define MAX 10000000
#define debug printf("%d",__LINE__)
using namespace std;
int main()
{
	string s;
	cin >> s;
	if(s[0] != 'R' && s[1] != 'R' && s[2] != 'R') return puts("0"), 0;
	if(s[0] == 'R' && s[1] != 'R' && s[2] != 'R') return puts("1"), 0;
	if(s[0] != 'R' && s[1] == 'R' && s[2] != 'R') return puts("1"), 0;
	if(s[0] != 'R' && s[1] != 'R' && s[2] == 'R') return puts("1"), 0;
	if(s[0] == 'R' && s[1] == 'R' && s[2] != 'R') return puts("2"), 0;
	if(s[0] != 'R' && s[1] == 'R' && s[2] == 'R') return puts("2"), 0;
	if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') return puts("3"), 0;
	if(s[0] == 'R' && s[1] == 'S' && s[2] == 'R') return puts("1"), 0; 
	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void){
	int N,C,i,j;
	scanf("%d%d",&N,&C);
	int s[N],t[N],c[N];
	for(i=0;i<N;i++)scanf("%d%d%d",&s[i],&t[i],&c[i]);
	int time[200002];
	int ans=0,S[200002]={0};
	for(i=1;i<=C;i++){
		for(j=0;j<200002;j++)time[j]=0;
		for(j=0;j<N;j++){
			if(c[j]==i){
				time[s[j]*2-1]++;
				time[t[j]*2]--;
			}
		}
		for(j=1;j<200002;j++)time[j]+=time[j-1];
		for(j=0;j<200002;j++)if(time[j]>0)S[j]++;
	}
	for(i=0;i<200002;i++)ans = ans<S[i]?S[i]:ans;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1e6 + 11;
const double eps=1e-14;
int dp[N][2][2][2];
int a[N];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
    {
        int x = a[i];
        dp[i][x][0][0] = dp[i - 1][!x][0][0] + 1;
        dp[i][x][0][1] = max(dp[i - 1][!x][1][1], dp[i - 1][!x][0][1]) + 1;
        dp[i][!x][1][1] = max(dp[i - 1][x][0][0], dp[i - 1][x][1][1]) + 1;
    }
    int res = 0;
    for (int i = 1; i <= n; i++)
    {
        res = max(res, max(dp[i][a[i]][0][1], dp[i][!a[i]][1][1]));
    }
    printf("%d\n",res);
    return 0;
}
/*
30
1 0 0 1 1 0 1 0 0 1 0 1 0 0 0 1 1 0 0 1 1 1 0 0 0 1 0 1 0 1

*/



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

int solve(int h,int w){
    vector<vector<int>> e(h,vector<int>(w));
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>e[i][j];
    int res=0;
    auto calc=[&](int t,int b,int l,int r){
        int wall=10;
        for(int i=l;i<=r;i++){
            wall=min(wall,e[t][i]);
            wall=min(wall,e[b][i]);
        }
        for(int i=t;i<=b;i++){
            wall=min(wall,e[i][l]);
            wall=min(wall,e[i][r]);
        }
        int res=0;
        for(int i=t+1;i<b;i++){
            for(int j=l+1;j<r;j++){
                if(wall>e[i][j]) res+=wall-e[i][j];
                else return 0;
            }
        }
        return res;
    };
    for(int t=0;t<h;t++){
        for(int b=t+2;b<h;b++){
            for(int l=0;l<w;l++){
                for(int r=l+2;r<w;r++){
                    res=max(res,calc(t,b,l,r));
                }
            }
        }
    }
    return res;
}

int main(){
    int h,w;
    while(cin>>h>>w,h){
        cout<<solve(h,w)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
typedef pair<double , double> pdd ;
const int inf = 0x3f3f3f3f ;
const ll mod = 998244353 ;
const int maxn = 1e5 + 5 ;
const int maxm = 30 ;
const double eps = 1e-6 ;
const double pi = acos(-1.0) ;
int main()
{
	int k , a , b ;
	r(k) , rr(a , b) ;
	rep(i , a , b)  if(i % k == 0)  {puts("OK") ; return 0 ;}
	puts("NG") ;    
	return 0 ;
} 

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll r,c,k;
  cin>>r>>c>>k;
  swap(r,c);
  vector<vector<ll>>items(r,vector<ll>(c,0));
  rep(i,k){
    ll a,b,v;cin>>a>>b>>v;
    swap(a,b);
    a--;b--;
    items[a][b]=v;
  }

  vector<vector<vector<ll>>>dp(r+1,vector<vector<ll>>(c+1,vector<ll>(5,0)));
  rep(i,r)rep(j,c)rep(k,5)dp[i][j][k]=0;
  rep(j,c)rep(i,r)rep(k,4){
    //use
    if(i+1<r and k<3)chmax(dp[i+1][j][k+1],dp[i][j][k]+items[i][j]);
    if(j+1<c and k<3)chmax(dp[i][j+1][0],dp[i][j][k]+items[i][j]);

    //notuse
    if(i+1<r)chmax(dp[i+1][j][k],dp[i][j][k]);
    if(j+1<c)chmax(dp[i][j+1][0],dp[i][j][k]);
  }

  // rep(i,r)rep(j,c)cout<<i<<" "<<j<<" "<<dp[i][j][0]<<endl;

  ll ans=0;
  rep(k,3)chmax(ans,dp[r-1][c-1][k]+items[r-1][c-1]);
  chmax(ans,dp[r-1][c-1][3]);
  
  cout<<ans<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 706612
a,b = [int(i) for i in input().split()]
ans='No'

y = b/2-a #animal de 4 patas
x = -b/2 + 2*a

if x>=0 and y>=0 and b%2==0:
    if x==int(x) and y==int(y):
        ans='Yes'
print(ans)


Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] a= {{1,5},{6,2},{4,3},{5,1},{3,5},{1,6},{6,6}};
        for(;;) {
            char[] l=sc.next().toCharArray();
            if(l[0]=='#') {
                break;
            }
            int t=0;
            for(char c:l) {
                t=a[t][c-'0'];
            }
            System.out.println(t==3?"Yes":"No");
        }
    }
}


Measured memory_bytes: 26056
n = int(input())
a = [int(i) for i in input().split()]

flag = True
cnt = 0
while True:
  for i in range(n):
    if a[i]%2 != 0:
      flag = False
  if flag:
    for i in range(n):
      a[i] = a[i] // 2
    cnt += 1
  else:
    print(cnt)
    break
  

Measured memory_bytes: 8992
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;
#define MAX (ll)(1e18)

int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for (auto &ai:a)
        cin >> ai;
    sort(a, a+n);
    ll l = -MAX, r = MAX;
    while (r - l > 1) {
        ll m = (l + r) / 2,
           sum = 0;
        for (int i=0; i<n; i++) {
            if (a[i] >= 0) {
                auto pp = partition_point(a+i+1, a+n, [&](ll x) { return x * a[i] <= m; });
                sum += pp - (a+i+1);
            }
            else {
                auto pp = partition_point(a+i+1, a+n, [&](ll x) { return x * a[i] > m; });
                sum += (a+n) - pp;
            }
        }
        if (sum < k) l = m;
        else r = m;
    }
    cout << r << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    double a,b; cin >> a >> b;
    cout << a / b;
}


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;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define int ll

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  rep(i, n) {
    if (s[i] == '1')
      cnt++;
  }
  if (!cnt) {
    rep(i, n)
      cout << 1 << '\n';
    return 0;
  }
  if (cnt == 1) {
    vector<int> num0(n);
    num0[n-1] = 1;
    for (int i = n-2; i >= 0; i--)
      num0[i] = num0[i+1]*2%(cnt+1);
    vector<int> l0(n), r0(n);
    rep(i, n-1) {
      if (s[i] == '1')
        l0[i+1] = num0[i];
      if (i)
        (l0[i+1] += l0[i])%(cnt+1);
    }
    for (int i = n-1; i > 0; i--) {
      if (s[i] == '1')
        r0[i-1] = num0[i];
      if (i < n-1)
        (r0[i-1] += r0[i])%(cnt+1);
    }
    vector<pair<int, int>> res(n);
    rep(i, n) {
      if (s[i] == '0') {
        res[i].first = (l0[i]+r0[i]+num0[i])%(cnt+1);
        res[i].second++;
      }
    }
    rep(i, n) {
      while (res[i].first) {
        res[i].first %= __builtin_popcount(res[i].first);
        res[i].second++;
      }
    }
    rep(i, n)
      cout << res[i].second << '\n';
    return 0;
  }
  vector<int> num0(n), num1(n);
  num0[n-1] = num1[n-1] = 1;
  for (int i = n-2; i >= 0; i--) {
    num0[i] = num0[i+1]*2%(cnt+1);
    num1[i] = num1[i+1]*2%(cnt-1);
  }
  vector<int> l0(n), r0(n), l1(n), r1(n);
  rep(i, n-1) {
    if (s[i] == '1')
      l0[i+1] = num0[i];
    if (i)
      (l0[i+1] += l0[i])%(cnt+1);
  }
  for (int i = n-1; i > 0; i--) {
    if (s[i] == '1')
      r0[i-1] = num0[i];
    if (i < n-1)
      (r0[i-1] += r0[i])%(cnt+1);
  }
  rep(i, n-1) {
    if (s[i] == '1')
      l1[i+1] = num1[i];
    if (i)
      (l1[i+1] += l1[i])%(cnt-1);
  }
  for (int i = n-1; i > 0; i--) {
    if (s[i] == '1')
      r1[i-1] = num1[i];
    if (i < n-1)
      (r1[i-1] += r1[i])%(cnt-1);
  }
  vector<pair<int, int>> res(n);
  rep(i, n) {
    if (s[i] == '0')
      res[i].first = (l0[i]+r0[i]+num0[i])%(cnt+1);
    else
      res[i].first = (l1[i]+r1[i])%(cnt-1);
    res[i].second++;
  }
  rep(i, n) {
    while (res[i].first) {
      res[i].first %= __builtin_popcount(res[i].first);
      res[i].second++;
    }
  }
  rep(i, n)
    cout << res[i].second << '\n';
  return 0;
}

Measured memory_bytes: 16028
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else: self.par[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

N, M = map(int, input().split())
p = list(map(int, input().split()))

tree = UnionFind(N)

for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    tree.union(x, y)

count = 0
for i in range(N):
    if (tree.same_check(i, p[i]-1)):
        count += 1

print(count)

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

using namespace std;

int main(){
  int A,B,C,K;
  int a,b,c;
  cin>> A >> B>> C >> K;

  a = min(A,K);
  K-=a;
  b = min(B,K);
  K-=b;
  c = min(C,K);
  K-=c;

  cout << a*1+b*0+c*(-1)<<endl;

  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define all(x) (x.begin(),x.end())
#define pii pair<int,int> 
#define vi vector<int> 
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define fi first
#define se second
using namespace std;
int n,m;
map<int,vector<int > > adj;
map<int,bool> vis;
int dfs(int x)
{
	int ans=1;
	for(int i=0;i<adj[x].size();i++)
	{
		if(!vis[adj[x][i]])
		{
			vis[adj[x][i]]=1;
			ans+=dfs(adj[x][i]);
		}
	}
	return ans;
}
void solve()
{
	
	cin>>n>>m;
	map<pair<int,int>,bool> vis1;
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		if(!vis1[{u,v}])
		{
			vis1[{u,v}]=1;
			vis1[{v,u}]=1;
		adj[u].pb(v);
		adj[v].pb(u);}
	}
	int scc=0;
	// cout<<dfs(1)<<endl;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			vis[i]=1;
			int x=dfs(i);
			scc=max(scc,x);
		}
	}
	cout<<scc<<endl;
}
int32_t main()
{
	int t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
// Problem : D - Friends
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



Measured memory_bytes: 84704
#include<bits/stdc++.h>
using lint=long long;
void cmx(double&x,double y){if(x<y)x=y;}
void cmn(double&x,double y){if(x>y)x=y;}
void debug_impl(){std::cerr<<'\n';}
template<class Head,class...Tail>void debug_impl(Head head, Tail... tail){std::cerr << " " << head;debug_impl(tail...);}
    template<class Container,class Value=typename Container::value_type,std::enable_if_t<!std::is_same<Container,std::string>::value,std::nullptr_t> = nullptr>
std::ostream&operator<<(std::ostream&os,Container const&v)
{os<<"{";for(auto it=v.begin();it!=v.end();it++){os<<(it!=v.begin()?",":"")<<*it;}return os<<"}";}
    template<template<class...>class Tuple,class...Args,std::size_t...Inds,std::size_t=std::tuple_size<Tuple<Args...>>::value>
std::ostream&tuple_output_impl(std::ostream&os,const Tuple<Args...>&tuple,std::integer_sequence<std::size_t,Inds...>)
{os<<"(";(void)std::initializer_list<int>{((void)(os<<(Inds>0?",":"")<<std::get<Inds>(tuple)),0)...};return os<<")";}
    template<template<class...>class Tuple,class...Args,std::size_t=std::tuple_size<Tuple<Args...>>::value>
std::ostream&operator<<(std::ostream&os,const Tuple<Args...>&tuple)
{return tuple_output_impl(os,tuple,std::index_sequence_for<Args...>());}
#define DEBUG 1
#if DEBUG
#define debug(...)do{std::cerr<<std::boolalpha<<"["<<#__VA_ARGS__<<"]:";debug_impl(__VA_ARGS__);std::cerr<<std::noboolalpha;}while(false)
#else
#define debug(...) {}
#endif
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    using complex=std::complex<double>;
    std::vector<complex>data(n);
    for(lint i=0;i<n;i++){
        double x,y;std::cin>>x>>y;
        data.at(i)={x,y};
    }
    auto sin2arg=[&](complex o,complex p,complex q){
        p-=o,q-=o;
        p/=std::abs(p),q/=std::abs(q);
        complex r=q/p;
        return 2*std::real(r)*std::imag(r);
    };
    auto cal=[&](complex p){
        double ans=0;
        for(complex&q:data){
            cmx(ans,std::abs(p-q));
        }
        return ans;
    };
    double ans=std::numeric_limits<double>::infinity();
    for(lint i=0;i<n;i++){
        for(lint j=i+1;j<n;j++){
            cmn(ans,cal((data.at(i)+data.at(j))/2.0));
        }
    }
    double eps=1e-10;
    for(lint i=0;i<n;i++){
        for(lint j=i+1;j<n;j++){
            for(lint k=j+1;k<n;k++){
                double I=sin2arg(data.at(i),data.at(j),data.at(k));
                double J=sin2arg(data.at(j),data.at(k),data.at(i));
                double K=sin2arg(data.at(k),data.at(i),data.at(j));
                if(std::abs(I)+std::abs(J)+std::abs(K)<eps)continue;
                cmn(ans,cal((data.at(i)*I+data.at(j)*J+data.at(k)*K)/(I+J+K)));
            }
        }
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, i, j;

	scanf("%d", &n);

	int t_cards[4][14];

	for (i = 0; i < 4; i++) {
		for (j = 1; j < 14; j++) {
			t_cards[i][j] = 0;
		}
	}

	for (i = 0; i < n; i++) {
		char suit;
		int num;
		scanf("%*c%c%*c%d", &suit, &num);
		if (suit == 'S') t_cards[0][num] = 1;
		else if (suit == 'H') t_cards[1][num] = 1;
		else if (suit == 'C') t_cards[2][num] = 1;
		else  t_cards[3][num] = 1;
	}

	for (i = 0; i < 4; i++) {
		for (j = 1; j < 14; j++) {
			if (t_cards[i][j] == 0) {
				switch (i) {
					case 0 : printf("S %d\n", j); break;
					case 1 : printf("H %d\n", j); break;
					case 2 : printf("C %d\n", j); break;
					case 3 : printf("D %d\n", j); break;
				}
			}
		}
	}

	return 0;
}

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

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




    int main(){
        int n, m;
        std::cin >> n >> m;
        std::vector<int> ac(n), pena(n);
        rep(i, m){
            int p;
            string s;
            std::cin >> p >> s;
            --p;
            if (ac[p]) continue;
            if (s == "AC")
            {
                ac[p] = 1;
            }else{
                pena[p]++;
            }
        }
        int AC = 0, PENA =0;
        rep(i, n){
            AC += ac[i];
            if(ac[i]) PENA += pena[i];
        }
        std::cout << AC << " " <<PENA << "\n";
        return 0;
    }


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

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n - 1; i++) {
		if (s.substr(i, 2) == "AC") {
			cout << "Yes" << endl;
			return 0;
		}
		
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int A, B, flag = 0;
    cin >> A >> B;
    string S;
    cin >> S;

    if (S[A] != '-')
    {
        cout << "No";
    }

    if (S[A] == '-')
    {

        sort(S.begin(), S.end());

        for (int i = 1; i < A + B + 1; i++)
        {

            if (S[i] == '-')
            {
                cout << "No";
                break;
            }

            else
            {
                flag = 1;
            }
        }

        if (flag == 1)
        {
            cout << "Yes";
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<stack>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 998244353;
const ll INF = (1LL << 60);
string s, t, u; ll n, m = 6, k, q, ans, sum =0,b,c; 
int main() {
    cin >> n;
    vector<int> a(26, 50);
    rep(i, n) {
        cin >> s; int sz = s.size();
        vector<int> tmp(26, 0);
        rep(i, sz) tmp[s[i] - 'a']++;
        rep(i, 26) a[i] = min(a[i], tmp[i]);
    }
    rep(i, 26) {
        char c = 'a' + i;
        rep(j, a[i]) {
            cout << c;
        }
    }puts("");
}

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

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

	if (s == "Sunny") cout << "Cloudy" << endl;
	else if (s == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define testfor(T) ll T; cin>>T; while(T--)
using namespace std;
int main(){
	vector<int> v(5);
	for(int i=0;i<5;i++){
		cin>>v[i];
		if(v[i]==0){
			cout<<i+1<<endl;
			break;
		}
	}
	return 0;
}

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

namespace ConsoleApp3
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var list = Console.ReadLine().Split().Select((order, index) => new { Order = int.Parse(order), Number = index + 1 })
				.OrderBy(stu => stu.Order).Select(stu => stu.Number);
			var str = string.Join(" ", list);
			Console.WriteLine(str);
		}
	}
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;

int cnt;
int q(int a,int b){
    cnt++;
    if(cnt>2*N){
        for(;;);
    }
    cout<<"? "<<a<<" "<<b<<endl;
    char c;cin>>c;
    return c=='Y';
}


vint calc(vint v){
    vint ret(N);
    if(v.size()<=2){
        rep(i,v.size())ret[v[i]]=1;
        return ret;
    }

    vpint ei;

    vint x,y;
    for(int i=0;i+1<v.size();i+=2){
        int f=q(v[i],v[i+1]);
        int g=q(v[i+1],v[i]);
        if(f&&g){
            x.pb(v[i]);
            y.pb(v[i+1]);
        }
        else{
            ei.pb({v[i],v[i+1]});
        }
    }

    if(v.size()%2&&y.size()%2==0){
        x.pb(v.back());
    }

    vint r=calc(x);
    rep(i,y.size()){
        r[y[i]]=r[x[i]];
    }

    if(v.size()%2&&y.size()%2){
        int k=v.back();
        int l;
        rep(i,N)if(r[i])l=i;
        r[k]=q(l,k);
    }

    int l;
    rep(i,N)if(r[i])l=i;
    for(auto p:ei){
        r[p.fi]=q(l,p.fi);
        r[p.se]=q(l,p.se);
    }

    return r;
}

signed main(){
    int A,B;
    cin>>A>>B;
    N=A+B;
    if(A<=B){
        cout<<"Impossible"<<endl;
        return 0;
    }

    vint v(N);
    rep(i,N)v[i]=i;

    vint x=calc(v);

    cout<<"! ";
    rep(i,N)cout<<x[i];cout<<endl;
    return 0;
}


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

int main(){
  long long A,B,N,x,y;
  cin>>N>>A>>B;
  if(B<A){
    cout<<0<<endl;
    return 0;
  }
  else if(A==B){
    cout<<1<<endl;
  return 0;
  }
  else{
    if(N==1){
      cout<<0<<endl;
      return 0;
    }
    else{
      cout<<(B-A)*(N-2)+1<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256