akhauriyash/Code-Regression huggingface dataset:
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

template<int jt> struct ModInt {
	int x;
	ModInt(int v = 0) {x = v; if(x >= jt || x < 0) {x %= jt; if(x < 0) x += jt;}}
	ModInt(ll v) {x = v % jt; if(x < 0) x += jt;}
	operator int() const {return x;}
	friend inline ModInt &operator+=(ModInt &a, const ModInt &b) {a.x += b.x; if(a.x >= jt) a.x -= jt; return a;}
	friend inline ModInt operator+(ModInt a, const ModInt &b) {return a += b;}
	friend inline ModInt operator+(ModInt a, int b) {return a += ModInt(b);}
	friend inline ModInt operator+(int a, ModInt b) {return b += ModInt(a);}
	friend inline ModInt &operator++(ModInt &a) {return a += 1;}
	friend inline ModInt &operator-=(ModInt &a, const ModInt &b) {a.x -= b.x; if(a.x < 0) a.x += jt; return a;}
	friend inline ModInt operator-(ModInt a, const ModInt &b) {return a -= b;}
	friend inline ModInt operator-(ModInt a, int b) {return a -= ModInt(b);}
	friend inline ModInt operator-(int a, ModInt b) {return ModInt(a) - b;}
	friend inline ModInt &operator--(ModInt &a) {return a -= 1;}
	friend inline ModInt &operator*=(ModInt &a, const ModInt &b) {a.x = (ll)a.x * b.x % jt; return a;}
	friend inline ModInt operator*(ModInt a, const ModInt &b) {return a *= b;}
	friend inline ModInt operator*(ModInt a, int b) {return a *= ModInt(b);}
	friend inline ModInt operator*(int a, ModInt b) {return b *= ModInt(a);}
	static inline void exgcd(ll a, ll b, ll &x, ll &y) {b ? (exgcd(b, a % b, y, x), y -= a / b * x) : (x = 1, y = 0);}
	friend inline ModInt inv(const ModInt &a) {ll x, y; exgcd(a, jt, x, y); return x;}
	friend inline ModInt operator/(const ModInt &a, const ModInt &b) {return a * inv(b);}
	friend inline ModInt operator/(ModInt a, int b) {return a * inv(ModInt(b));}
	friend inline ModInt operator/(int a, ModInt b) {return ModInt(a) * inv(b);}
	friend inline ModInt operator/=(ModInt &a, const ModInt &b) {return a = a / b;}
};
const int jt = 1000000007;
typedef ModInt<jt> mint;

mint dp[2005];
int s;

int main() {
	cin >> s;
	dp[0] = 1;
	cont(i, s) {
		loop(j, i - 2) dp[i] += dp[j];
	}
	cout << dp[s] << endl;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REP3(i, f, n) for (int(i) = (f); (i) < (n); (i)++)
using namespace std;

// int digit_sum(int i){
//     int ret=0;
//     string s;
//     s=to_string(i);
//     REP(k,s.size()){
//         ret+=(s[k]-'0');
//     }
//     // cout<<"s:"<<s<<endl<<"ret:"<<ret<<endl;
//     return ret;
// }

int digit_sum(int n)
{
    int sum = 0;
    while (n > 0)
    {
        sum += (n % 10);
        n /= 10;
    }
    return sum;
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int cnt = 0;
    REP3(i, 1, n + 1)
    {
        int s = digit_sum(i);
        if (s >= a and s <= b)
        {
            cnt += i;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
C = [list(map(int,input().split())) for _ in range(M)]
for i in range(N):
    check = 0
    point = abs(A[i][0]-C[0][0])+abs(A[i][1]-C[0][1])
    change = point
    for j in range(1,M):
        point = min(point,abs(A[i][0]-C[j][0])+abs(A[i][1]-C[j][1]))
        if point != change:
            check = j
            change = point
    print(check+1)
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N;
  d = N % 10;
  c = ((N - d) % 100) / 10;
  b = ((N - c*10 - d) % 1000) / 100;
  a = (N - b*100 - c*10 - d) / 1000;
  if (a==b && b==c)
    cout << "Yes";
  else if (b==c && c==d)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

		int target = cin.nextInt();
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		int tmp;
		for(int i=0;i<target;i++){
			tmp=cin.nextInt();
			if(map.containsKey(tmp)){
				map.put(tmp, map.get(tmp)+1);
			}else{
				map.put(tmp, 1);
			}
		}

		int count = map.size();
		int result;
		int sum=0;
		if(count==1){
			result=1;
		}else{
			for(int key : map.keySet()){
				sum += map.get(key)-1;
			}
			if(sum%2==0){
				result = count;
			}else{
				result = count-1;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 61756
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
ll answer(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return 2*answer(n/2)+1;
    }
}
int main(){
    ll h;
    cin >> h;
    cout << answer(h) << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;

using namespace std;

#define ll  long long

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef unordered_map<int,int> um;
typedef unordered_set<int> us;
typedef priority_queue<int> pq;
typedef deque<int> dq;
typedef queue<int> q;
typedef stack<int> st;

#define f first
#define s second
#define pb push_back
#define mp make_pair

#define rep(i,a,b) for (auto i = a; i < b; i++)
//#define bitset<n> b<n>

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

//indexed_set s;
	//s.insert(2);
	//s.insert(3);
	//s.insert(7);
	//s.insert(9);

	//auto x = s.find_by_order(2);
	//s.order_of_key(7)
	
	//c_p_c();

	//__builtin_clz(x): the number of zeros at the beginning of the number
   // __builtin_ctz(x): the number of zeros at the end of the number
   // __builtin_popcount(x): the number of ones in the number
   // __builtin_parity(x): the parity (even or odd) of the number of ones

void c_p_c()
{
	
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void max_self(ll& a, ll b) {
    a = max(a, b);
}

// O(n * W)

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<ll> dp(W + 1); // 0 ... W
    // dp[i] - the maximum total value of items with total weight exactly i
    for(int item = 0; item < n; ++item) {
        int weight, value;
        scanf("%d%d", &weight, &value);
        // dp[0] -> dp[3] -> dp[6]
        for(int weight_already = W - weight; weight_already >= 0; --weight_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            max_self(dp[weight_already+weight], dp[weight_already] + value);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= W; ++i) {
        max_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}
		

Measured memory_bytes: 1024
N, M = map(int, input().split())

pre_list = []
for _ in range(M):
    sw = list(map(int, input().split()))[1:]
    pre_list.append(sw)
    
binary_sw =  list(map(int, input().split()))

import itertools

binary_list = [0, 1]

all_comb = list(itertools.product(binary_list, repeat=N))

count = 0

for sw_state in all_comb:
    flag = False
    
    for lamp, lamp_sw in zip(pre_list, binary_sw):
        swvalue = 0
        for lamp_single in lamp:
            swvalue += sw_state[lamp_single - 1]
        
        if swvalue % 2 == lamp_sw:
            continue
        
        else:
            flag = True
            break
        
        if flag:
            break

    if not flag:
        count += 1
        
print(count)

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

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

const long long MOD = 1000000007;

int main(){
  int x,y,z;
  cin >> x>>y>>z;
  cout << z<<" "<<x<<" "<<y;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(begin(a), end(a));
	
	std::vector<std::pair<i64, int>> latte;
	for(int i = 0; i < m; i++) {
		int b, c; scanf("%d%d", &b, &c);
	
		latte.push_back({c, b});
	}
	sort(begin(latte), end(latte), std::greater<>());
	
	i64 ans = 0;
	int cur = 0;
	for(auto v: latte) {
		while(cur < n and a[cur] < v.first and v.second > 0) {
			v.second--;
			ans += v.first;
			cur++;
		}
	}
	for(int i = cur; i < n; i++) ans += a[i];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3188
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
w=gets.to_i
ans=""
S.size.times do|i|
    ans+=S[i] if((i%w).zero?)
end
puts ans

Measured memory_bytes: 2172
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

/*--------switch header--------*/
#define ALGORITHM   1
#define CASSERT     1
#define CMATH       1
#define DEQUE       1
#define FUNCTIONAL  1
#define IOMANIP     1
#define IOSTREAM    1
#define LIST        1
#define MAP         1
#define QUEUE       1
#define SET         1
#define STRING      1
#define UTILITY     1
#define VECTOR      1
#define VEC_DEBUG   1

using namespace std;

#pragma region headers
#if VEC_DEBUG
#define _GLIBCXX_DEBUG
#endif
#if ALGORITHM
#include <algorithm>
#endif
#if CASSERT
#include <cassert>
#endif
#if CMATH
#include <cmath>
#endif
#if DEQUE
#include <deque>
#endif
#if FUNCTIONAL
#include <functional>
#endif
#if IOMANIP
#include <iomanip>
#endif
#if IOSTREAM
#include <iostream>
#endif
#if LIST
#include <list>
#endif
#if MAP
#include <map>
#endif
#if QUEUE
#include <queue>
#endif
#if SET
#include <set>
#endif
#if STRING
#include <string>
#endif
#if UTILITY
#include <utility>
#endif
#if VECTOR
#include <vector>
#endif
#pragma endregion


/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, a, b; cin >> n >> a >> b;
    vector<int> p(n);
    REP(i, n) cin >> p[i];

    sort(ALL(p));
    int cnt[3] = {0, 0, 0};

    for(int i = 0; i < n; i++){
        if(p[i] <= a) cnt[0]++;
        if(a+1 <= p[i] && p[i] <= b) cnt[1]++;
        if(b+1 <= p[i]) cnt[2]++;
    }

    int ans = INF9;
    REP(i, 3) chmin(ans, cnt[i]);
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

int n, c[200001], dp[200001] = {0}, sm[200001] = {0};

signed main()
{
	
 	FLASH

 	cin>>n;

 	fr(i, 1, n + 1) cin>>c[i];

 	dp[1] = 1;
 	sm[c[1]] = 1;

 	fr(i, 1, n + 1)
 	{
 		dp[i] = dp[i - 1]; 
 		if(c[i] == c[i - 1]) continue;
 		dp[i] += sm[c[i]];
 		sm[c[i]] += dp[i - 1];

 		dp[i] %= mod;
 		sm[c[i]] %= mod;
 	}
 	cout<<dp[n]%mod;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

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

		// 整数の入力
		int n = sc.nextInt();
		boolean bl1 = false;
		boolean bl2 = false;
		boolean bl3 = false;

		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			//値が同じ場合
			if(a == b){
				//1度目のヒット
				if(!bl1){
					bl1 = true;
				}else{
					//2度目のヒット
					if(!bl2){
						bl2 = true;
					}else{
						//3度目のヒット
						bl3 = true;
					}
				}
			}else{
				//3度未達の場合
				if(!bl3){
					//違う場合全部リセット
					bl1 = false;
					bl2 = false;
					bl3 = false;
				}
			}
		}

		if(bl3){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

		sc.close();
	}
}


Measured memory_bytes: 36128
a, b , c, d = map(int, input().split())
def num_cm(a, b, m):
    if a % m == 0:
        return (b//m) - (a//m) + 1 
    else:
        return (b//m) - (a//m)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a    
lcm = (c * d) // gcd(c, d)
ans =  b - a + 1 - num_cm(a, b, c) - num_cm(a, b, d) + num_cm(a, b, lcm)
print(ans)

Measured memory_bytes: 3064
N=int(input())
A=list(map(int,input().split()))
p=[-1]*N
x=0
for i in range(N):
    if p[A[i]-1]==-1:
        p[A[i]-1]=i
    else:
        x=p[A[i]-1]+N-i
        break
m=10**9+7
print(N)
a,b=N+1,1
def sub(a,b):
    return (a-b)%m
def mul(a,b):
    return ((a%m)*(b%m))%m
def div(a,b):
    return mul(a,pow(b,m-2,m))
for k in range(2,N+2):
    a=div(a*(N+2-k),k)
    b=div(b*(x+2-k),k-1)
    print(sub(a,b))

Measured memory_bytes: 13812
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 110000
using namespace std;

int main() {
	string S, eo;
	cin >> S;
	int i, ans1 = 0, ans2, ans, N;
	N = S.length();
	for (i = 0; i < N; i++)
	{
		if (i % 2 == 0)
			eo = "0";
		else eo = "1";
		if (eo[0] == S[i])
			ans1++;
	}
	ans2 = N - ans1;
	ans = min(ans1, ans2);
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n,y; cin >>n>>y;

    for (int i = 0; i < n+1; i++) {
        for (int j = 0; j < n+1; j++) {
            int k = n - i - j;
            if (k >= 0 && 10000 * i + 5000 * j + 1000 * k == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            } 
        }
    }
    cout << -1 << " " << -1 << " " << -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 l = sc.nextInt();
        String[] s = new String[n];
        for(int i = 0; i < n; i++){
            s[i] = sc.next();
        }
        Arrays.sort(s);
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(s[i]);
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 37248
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;


void solve()
{
	string s,t;
	cin>>s>>t;
	int i,ans=0,n=s.length();
	for(i=0;i<n;i++)
	{
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans<<endl;
}

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

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef long long ull;
typedef long double ld;

int main(){
    int b;
    cin >> b;
    string a;
    cin.ignore();
    cin >> a;
    int count = 0;
    for(int i= 0;i<b-2;i++){
        if(a.substr(i,3)=="ABC")
            count++;

    }
cout << count;

    return 0;
}








Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
#define all(vec) vec.begin(), vec.end()
namespace mp = boost::multiprecision;
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};

class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}

	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)
				continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

	int find(int e) {
		return d[e];
	}
};

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

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

bool prime(int a) {
	if (a == 1)
		return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0)
			return false;
	}
	return true;
}

class Union_Find {
  private:
	vector<int> t, s;

  public:
	Union_Find(int max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(int x, int y) {
		if (same(x, y))
			return;
		int tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}

	int Find(int n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(int x, int y) {
		return Find(x) == Find(y);
	}

	int get_Size(int a) {
		return s[a];
	}
};

set<int> prime_num_factor(int n) {
	if (n < 2)
		return set<int>();
	set<int> prime;
	prime.insert(2);
	for (int i = 3; i <= n; i++) {
		for (int it : prime) {
			if (it * it > i) {
				prime.insert(i);
				break;
			}
			if (i % it == 0)
				break;
		}
	}
	return prime;
}
vector<int> primeFactorization(int n) {
	vector<int> re;
	int cnt = 2;
	while (n != 1) {
		if (n % cnt != 0) {
			cnt++;
			continue;
		}
		n /= cnt;
		re.push_back(cnt);
	}
	return re;
}
signed main() {
	string s;
	cin >> s;
	int ans[100000], before_l = -1;
	fill(ans, ans + s.size(), 0);
	REP(i, 1, s.size()) {
		if (s[i - 1] == 'R' && s[i] == 'L') {
			REP(j, before_l + 1, i) {
				if ((i - j - 1) % 2 == 0)
					ans[i - 1]++;
				else
					ans[i]++;
			}
			for (int j = i; s[j] != 'R' && j < s.size(); j++) {
				if ((j - i) % 2 == 0)
					ans[i]++;
				else
					ans[i - 1]++;
				if (s[j + 1] == 'R'){
					i = j + 1;
					before_l=j;
				}
			}
		}
	}
	rep(i, s.size()) {
		cout << ans[i];
		if (i + 1 == s.size())
			cout << endl;
		else
			cout << ' ';
	}
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
long long MOD=1e9+7;
int main(){
    long long n,k;
    cin >> n >> k;
    vector<long long> vec(n);
    for(int i=0;i<n;i++){
        long long x;
        cin >> x;
        vec[i]=x;
    }
    long long lp0 = (k+1)*k/2;
    long long lp = k*(k-1)/2;
    lp0 %= MOD;
    lp %= MOD;
  //  cout<<" " <<lp0<<" "<<lp<<endl;
    vector<long long> reg(n,0);
    vector<long long> reg1(n,0);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
        //    cout<<vec[i]<<" "<<vec[j]<<endl;
            if(vec[i]>vec[j]){
                if(i<j){
                    reg[i]++;
                 //   cout<<"うち足し"<<endl;
                }else{
                    reg1[i]++;
                   // cout<<"外足し"<<endl;
                }
            }
        }
    }
   // cout<<lp0<<endl;
    long long ans=0;
    for(int i=0;i<n;i++){
        reg[i] %= MOD;
        reg1[i] %= MOD;
     //   cout<<reg[i]<<" "<<reg1[i]<<endl;
        int Ans = ((reg[i]*lp0)%MOD+(reg1[i]*lp)%MOD)%MOD;
        ans += Ans;
    }
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

typedef unsigned long long ull;
#define B1 100000007
#define B2 1000000007
#define MOD ((1<<61)-1)

bool rolling_hash(string const& s, int t_start, int m){
    ull power_of_B_1 = 1;
    ull power_of_B_2 = 1;
    for(int k = 0; k < m; k++){
      power_of_B_1 *= B1;
      power_of_B_2 *= B2;
    }

    // S[i:]とTの先頭m文字のハッシュ値sh,thを計算
    ull sh1 = 0, sh2 = 0, th1 = 0, th2 = 0;
    for(int k = 0; k < m; k++){
      sh1 = sh1 * B1 + s[t_start + m + k];
      sh2 = sh2 * B2 + s[t_start + m + k];
      th1 = th1 * B1 + s[t_start + k];
      th2 = th2 * B2 + s[t_start + k];
    }

    for(int k = 0; k + m <= s.length() - t_start ; k++){
      if(sh1 == th1 && sh2 == th2) return true;
      if(k + m < s.length() - t_start){
        sh1 = sh1 * B1 + s[t_start + m + m + k] - s[t_start + m + k] * power_of_B_1;
        sh2 = sh2 * B2 + s[t_start + m + m + k] - s[t_start + m + k] * power_of_B_2;
      }
    }
  return false;
}

int main(){
  int n;
  string s;
  // 入力
  cin >> n >> s;

  // 大きい文字数から探索
  int ng = n+1;
  int ok = 0;
  int mid = 0;
  while(ng - ok > 1){
    mid = (ng + ok) / 2;
    bool f = false;
    // Sのi文字目をtの先頭として
    for(int i = 0; i < n; i++){
      if(i + mid*2 > n) break;
      if(rolling_hash(s, i, mid)){
        f = true;
        break;
      }
    }
    if(f){
      ok = mid;
    }
    else{
      ng = mid;
    }
  }
  cout << ok << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
using namespace std;
const int N = 1e5 + 5;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	int i = a;
	while (i <= c)
	{
		//cout << i << endl;
		ans += b;
		i += a;
	}
	printf("%d\n", ans);

    //std::cout << "Hello World!\n";
}

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

int main()
{
	int x[2];
	while(cin >> x[0] >>x[1])
	{
		if (x[0] == 0 && x[1] == 0)break;
		sort(x, x + 2);
		cout << x[0] << " " << x[1] <<   endl;
	}
}

Measured memory_bytes: 1172
//Giorgi Kldiashvili

#include <bits/stdc++.h>

#define fr first
#define sc second

using namespace std;

int n;
int a[200020];
bool b[200020], c[200020];

bool check(int x)
{
  for(int i = 1; i <= 2 * n - 1; ++ i)
    b[i] = (a[i] > x) ? true : false;
  b[0] = b[1];
  b[2 * n] = (b[2 * n - 1]);
  for(int i = 1; i <= 2 * n - 1; ++ i)
    if(b[i - 1] != b[i] && b[i + 1] != b[i])
      c[i] = true;
    else
      c[i] = false;
  if(!c[n])
    return b[n];

  int l, r;
  for(int i = n; i >= 1; -- i)
    if(c[i])
      l = i;
    else
      break;
  for(int i = n; i < 2 * n; ++ i)
    if(c[i])
      r = i;
    else
      break;
  if(r - n > n - l)
    b[n] = b[l - 1];
  else
    b[n] = b[r + 1];
  return b[n];
}
/*

*/

int main()
{
  scanf("%d", &n);
  for(int i = 1; i <= 2 * n - 1; ++ i)
    scanf("%d", &a[i]);
  int l, r;
  l = 1; r = 2 * n;
  while(l < r)
  {
    int mid = l + r >> 1;
    if(check(mid))
      l = mid + 1;
    else
      r = mid;
  }

  printf("%d\n", l);
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  int X = nextInt();
  int Y = nextInt();

  vector<int> ans(N);
  for (int i = 1; i <= N; i++) {
    queue<int> q;
    vector<int> memo(N+1, 1001001001);
    q.push(i);
    memo[i] = 0;
    while (!q.empty()) {
      int cur = q.front(); q.pop();

      vector<int> nxt;
      if (cur + 1 <= N) nxt.push_back(cur+1);
      if (cur - 1 >= 1) nxt.push_back(cur-1);
      if (cur == X) nxt.push_back(Y);
      if (cur == Y) nxt.push_back(X);
      for (int v : nxt) {
        if (memo[v] > memo[cur] + 1) {
          memo[v] = memo[cur] + 1;
          q.push(v);
        }
      }
    }
    for (int i = 1; i <= N; i++) ans[memo[i]]++;
  }

  for (int d = 1; d < N; d++) {
    cout << ans[d] / 2 << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//全头文件
using namespace std;//命名空间
int main(){
string a;//定义两个字符串
string s;
cin>>a;//输入
cin>>s;//输入*2
reverse(s.begin(),s.end());//反转大法
if (a==s) //比较是否相同 

printf("YES");//华丽输出

else printf("NO");//华丽输出*2

return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

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

	int n, s = 0, res = 0;
	cin >> n;
	while (n--) {
		int a;
		cin >> a;
		res += a * s;
		s += a;
	}
	cout << res << endl;

	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll infl = 1LL<<60;
template <typename X>
struct BellmanFord{
  int node;
  vector<vector<pair<int,X>>> edge;
  vector<X> d;
  bool update;

  BellmanFord(int _n){
    node = _n;
    d.assign(node,-infl);
    edge.resize(node);
  }
  
  //辺の追加
  void add_edge(int from,int to,X cost){
    edge[from].push_back(make_pair(to,cost));
  }
 
  void bellmanford(int s){
    d[s] = 0;
    rep(i,node-1){
      rep(j,node){
	if(d[j]==-infl) continue;
	for(auto& k:edge[j]){
	  d[k.first] = max(d[k.first],d[j]+k.second);
	}
      }
    }
    
    vector<bool> pos(node,0);
    rep(i,node){
      rep(j,node){
	if(d[j]==-infl) continue;
	for(auto& k:edge[j]){
	  if(d[k.first]<d[j]+k.second){
	    pos[k.first] = true;
	    d[k.first] = d[j] + k.second;
	  }
	  if(pos[j]) pos[k.first] = true; 
	}
      }
    }

    rep(i,node) if(pos[i]) d[i] = infl;
    
  }

};

int main()
{
  int n,m,p;
  cin >> n >> m >> p;
  vector<int> a(m),b(m);
  vector<ll> c(m);
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    c[i] -= p;
  }

  BellmanFord<ll> bf(n);

  rep(i,m) bf.add_edge(a[i],b[i],c[i]);

  bf.bellmanford(0);

  cout << (bf.d[n-1]!=infl?(max(bf.d[n-1],(ll)0)):-1) << "\n";

  
  return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

main(){
	int A,B;
	scanf("%d%d",&A,&B);
	
	if(A== 1&& B== 2 ){
		printf("3");
	}
	else if(A == 1 && B == 3){
		printf("2");
	}
	else if(A == 2 && B == 1){
		printf("3");
	}
	else if(A == 2 && B ==3){
		printf("1");
	}
	else if(A == 3 && B == 1){
		printf("2");
	}
	else if(A == 3 && B == 2){
		printf("1");
	}
	
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int r;
	cin >> r;
	if(r<1200) cout << "ABC" << endl;
	else if(r>=2800) cout << "AGC" << endl;
	else cout << "ARC" << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    x1, y1, x2, y2 = map(int, input().split())

    delta_x = x2 - x1
    delta_y = y2 - y1
    x3, y3 = x2 - delta_y, y2 + delta_x
    x4, y4 = x3 - delta_x, y3 - delta_y

    print(x3, y3, x4, y4)


if __name__ == "__main__":
    main()


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

int main() {
  int N, T; cin >> N >> T;
  vector<pair<int, int>> X(N);
  rep(i, N) {
    int A, B; cin >> A >> B;
    X.emplace_back(A, B);
  }

  sort(X.rbegin(), X.rend());

  vector<int> dp(3010, 0);

  for (auto p : X) {
    int w = p.first, v = p.second;
    for (int i = T - 1; i >= 0; i--) {
      if (i + w < T) {
        dp[i + w] = max(dp[i + w], dp[i] + v);
      }
    }
    dp[0] = max(dp[0], v);
  }

  int ans = 0;
  rep(i, T) {
    ans = max(ans, dp[i]);
  }

  cout << ans << endl;
}

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

int main() {
	long long X, Y;
	cin >> X >> Y;
	if (X == 1 && Y == 1) {
		cout << 1000000 << endl;
		return 0;
	}
	long long ANS = 0;
	if (X <= 3) ANS += 400000 - X * 100000;
	if (Y <= 3) ANS += 400000 - Y * 100000;
	cout << ANS << endl;
}

Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long
 
#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)
 
#define sl          cout<<' '
#define ps          printf(" ")
 
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
 
#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())
 
#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound
 
#define MX1     100000
#define MX2     1000000
#define MX3     10000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Count[MX1+1];

lli Power(lli a,lli b)
{
    lli result=1;
 
    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }
 
        b=b>>1;
        a=(a*a)%mod;
    }
 
 return result;
}
 
int main()
{
    opt;
 
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli N,i;
    cin>>N;
    
    lli cnt[3]={0};
    
    rep(i,0,N)
    {
        lli x;
        cin>>x;
        
        Count[x]++;
    }
    
    lli cnt1=0,cnt2=0;
    
    rep(i,0,MX1+1)
    {
        lli x=i;
        
        while(Count[x]>=3)
        {
            Count[x]=Count[x]/3+Count[x]%3;
        }
        
        if(Count[x]==1)
        {
            cnt1++;
        }
        
        if(Count[x]==2)
        {
            cnt2++;
        }
    }
    
    cout<<cnt1+cnt2-cnt2%2;
    
    
    
    
    
 
 return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

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

    i64 ans = INF;
    for (char c = 'a'; c <= 'z'; c++) {
        string a = s;
        i64 can = 0;
        for (i64 i = s.size(); i > 0; i--) {
            if (all_of(begin(a), begin(a) + i, [&](char d) { return d == c; })) break;
            for (i64 j = 0; j + 1 < i; j++) {
                if (a[j] != c && a[j + 1] != c) continue;
                a[j] = c;
            }
            can++;
        }
        ans = min(ans, can);
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool pal(string s)
{
    int i=0;
    int j=s.length()-1;
    while(i<j)
    {
        if(s[i]!=s[j])
        return false;
        i++;
        j--;
    }
    return true;
}
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    if(pal(s) && pal(s.substr(0,n/2)) && pal(s.substr((n+1)/2,n/2)))
    cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod =1e9+7;

int main() {
	// your code goes here
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	long i,j,h,w,k;
	cin>>h>>w;
	char A[h][w];
	
	for(i=0;i<h;i++)
	{
	    for(j=0;j<w;j++)
	    {
	        cin>>A[i][j];
	    }
	}
	
	long dp[h][w]={0};
	dp[0][1]=dp[1][0]=1;
	for(i=0;i<h;i++)
	{
	    for(j=0;j<w;j++)
	    {
	        if(A[i][j]=='.')
	        {
	            if((i+1)<h)
	            {
	                dp[i+1][j]=((dp[i+1][j])%mod + (dp[i][j])%mod)%mod;
	            }
	            if((j+1)<w)
	            {
	                dp[i][j+1]=((dp[i][j+1])%mod + (dp[i][j])%mod)%mod;
	            }
	        }
	    }
	}
	
	
	
	cout<<dp[h-1][w-1];
	
	return 0;
}


Measured memory_bytes: 9088
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        String T = scan.next();
        char[] d_s = S.toCharArray();
        char[] d_t = T.toCharArray();
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i <= d_s.length - d_t.length; i++) {
            int temp = 0;
            for (int j = 0; j < d_t.length; j++) {
                if (d_s[i+j] != d_t[j]) {
                    temp += 1;
                }
            }
            ans = Math.min(ans, temp);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35708
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  s = input().strip()
  x = 1 <= int(s[:2]) <= 12
  y = 1 <= int(s[2:]) <= 12

  if x and y:
    print('AMBIGUOUS')
  elif x and not y:
    print('MMYY')
  elif not x and y:
    print('YYMM')
  else:
    print('NA')


if __name__ == '__main__':
  main()



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

int main(){
    string s;
    cin >> s;
    int ans=0;
    int si=s.size();
    if(si%2==0){
       for(int i=0; i<(s.size())/2;i++){
        if(s[(si-1)/2+i+1]!=s[(si-1)/2-i]){
            ans+=1;
        }
       }
       cout << ans << endl;
       return 0;
    }
    else{
        for(int i=1; i<(s.size())/2+1;i++){
 //           cout << s[(si-1)/2-i] << s[(si-1)/2+i] << endl;
        if(s[(si-1)/2-i]!=s[(si-1)/2+i]){
            ans+=1;
        }
       }
       cout << ans << endl;
       return 0;
    } 
}

Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
adjL = [set(range(N)) for _ in range(N)]
for v in range(N):
    adjL[v].remove(v)
for _ in range(M):
    A, B = map(int, input().split())
    A, B = A-1, B-1
    adjL[A].remove(B)
    adjL[B].remove(A)

def getSizes(adjList):
    def bfs(vSt):
        colors[vSt] = 1
        nums[1] += 1
        Q = deque([vSt])
        while Q:
            vNow = Q.popleft()
            color = colors[vNow]
            for v2 in adjList[vNow]:
                if colors[v2] == color:
                    return False
                elif colors[v2] == 0:
                    colors[v2] = -color
                    nums[-color] += 1
                    Q.append(v2)
        return True

    numV = len(adjList)
    colors = [0] * numV
    anss = []
    for vSt in range(numV):
        if colors[vSt] != 0: continue
        nums = {-1: 0, 1: 0}
        if not bfs(vSt):
            return []
        anss.append((nums[-1], nums[1]))
    return anss

sizes = getSizes(adjL)

if not sizes:
    print(-1)
else:
    bitset = 1<<N
    for A, B in sizes:
        bitset = (bitset>>A) | (bitset>>B)

    minDiff = N
    iMinDiff = -1
    for i in reversed(range(N+1)):
        if bitset & 1:
            diff = abs(i-N/2)
            if diff < minDiff:
                minDiff = diff
                iMinDiff = i
        bitset >>= 1

    print(iMinDiff*(iMinDiff-1)//2 + (N-iMinDiff)*(N-iMinDiff-1)//2)


Measured memory_bytes: 36204
#include <stdlib.h>
#include <iostream>
using namespace std;

int main(){
	long n;
	cin >> n;
	long mod = 1000000007;
	long ans = 1;
	for(long i = 1; i <= n; ++i){
		ans = (ans*i)%mod;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

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

i64 N, K; cin >> N >> K;
VI A(N); invec(A);
int D = max((int)log2(K) + 1, (int)log2(*max_element(ALL(A))) + 1);
VI cnt0(D, 0);
for(i64 a: A){
    rep(digit, 0, D){
        cnt0[digit] += ((a & (1LL << digit)) == 0);
    }
}
i64 X = 0, f = 0;
Rrep(digit, D-1, 0){
    if (cnt0[digit] > N/2 && (X |= (1LL << digit)) > K) X ^= (1LL << digit);
}
for(i64 a: A) f += X ^ a;

cout << f << "\n";

return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

using namespace std;

const int INF = 1 << 30;

int main()
{
  int N, W;
  int dp[10001] = {}, deq[10001], deqv[10001];

  cin >> N >> W;
  for(int i = 0; i < N; i++) {
    int v, w, m;
    cin >> v >> w >> m;
    for(int k = 0; k < w; k++) {
      int s = 0, t = 0;
      for(int l = 0; l * w + k <= W; l++) {
        int val = dp[l * w + k] - l * v;
        while(s < t && deqv[t - 1] <= val) --t;
        deq[t] = l;
        deqv[t++] = val;
        dp[l * w + k] = deqv[s] + l * v;
        if(deq[s] == l - m) ++s;
      }
    }
  }

  cout << dp[W] << endl;
}

Measured memory_bytes: 3156
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  IN(n);
  IN(a); a--;
  IN(b); b--;
  IN(c); c--;
  IN(d); d--;
  string s;
  cin>>s;
  bool ans1 = true;//true->Yes false->No
  bool ans2 = false;

  if(c>b){
    FOR(i,a,max(c,d)){
      if(s[i]=='#'&&s[i+1]=='#')
	ans1=false;
    }
  }
  else{
    FOR(i,a,c){
      if(s[i]=='#'&&s[i+1]=='#')
	ans1=false;
    }
    FOR(i,b,d){
      if(s[i]=='#'&&s[i+1]=='#')
	ans1=false;
    }
  }  
  if (d>c){
    ans2=true;
  }
  else{
    FOR(i,b,d+1){
      if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
	ans2=true;
    }
  }
  
  cout<<(ans1&&ans2?"Yes":"No");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e6+100,mod=1e9+7;
int cnt[maxn],n;
bool vis[maxn];
int gcd(int x,int y)
{
    return y==0?x:gcd(y,x%y);
}
int main()
{
    int res=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        cnt[x]++;
        res=gcd(res,x);
    }
    bool f=0;
    for(int i=2;i<maxn;i++)
    {
        if(vis[i])
        continue;
        int ff=0;
        for(int j=i;j<maxn;j+=i)
        {
            ff+=cnt[j];
            vis[j]=1;
        }
        if(ff>1)
        f=1;
        if(f)
        break;
    }
    if(!f)
    cout<<"pairwise coprime";
    else if(f and res==1)
    cout<<"setwise coprime";
    else
    cout<<"not coprime";
    return 0;
}


Measured memory_bytes: 8512
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
	int n;double d;
	cin>>n>>d;int ans=0;
	for(int i=1;i<=n;i++){
		double x,y;cin>>x>>y;
		if(sqrt(x*x+y*y)<=d) ans++;
	}
	cout<<ans;
	return 0;	
} 

Measured memory_bytes: 3212
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    string s, t;
    cin >> N >> s >> t;
    reverse(all(s));
    int ret = N;
    while(ret < 2 * N){
        string ss = s.substr(0, 2 * N - ret);
//        cout << ss << "," << t.substr(0, 2 * N - ret) << endl;

        reverse(all(ss));
        if(t.substr(0, 2 * N - ret) == ss){
            
            output(ret);
            return 0;
        }
        ret++;
    }
    output(ret);
    
    return 0;
}

Measured memory_bytes: 256
#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;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}


int N,A,B,C,D;
string S;

bool uku(int a,int c){
    for(int i=a+1;i+1<c;i++)if(S[i]=='#'&&S[i+1]=='#')return false;
    return true;
}

bool ukuku(int l,int r){
    for(int i=l;i+2<=r;i++)if(S[i]==S[i+1]&&S[i+1]==S[i+2]&&S[i]=='.')return true;
    return false;
}

signed main(){
    cin>>N>>A>>B>>C>>D;
    cin>>S;
    
    A--;B--;C--;D--;
    bool ok=true;
    if(!uku(A,C)||!uku(B,D))ok=false;
    if(D<C){
        if(!ukuku(B-1,D+1))ok=false;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 640
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    bool ok = true;
    ll N = S.size();
    rep(i,0,N){
        if(S[i] != S[N-1-i]) ok = false;
    }
    rep(i,0,(N-1)/2){
        if(S[i] != S[(N-1)/2-1-i]) ok = false;
    }
    rep(i,(N+3)/2-1, N){
        ll end = i - (N+3)/2 + 1;
        if(S[i] != S[N-1-end]) ok = false;
    }
    if(ok){
        print("Yes");
    }else{
        print("No");
    }

    

}

Measured memory_bytes: 256