akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  if ((n % 2 == 0) ^ (s[0] == s.back())) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n,m;
  cin>>n>>m;
  vector<int> a(m),b(m);
  rep(i,m){
    cin>>a[i]>>b[i];
  }
  int l = *max_element(a.begin(),a.end());
  int r = *min_element(b.begin(),b.end());
  if(l<=r)cout<<r-l+1<<endl;
  else cout<<0<<endl;

}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	rep(i, n) {
		int e;
		cin >> e;
		e--;
		vec.at(e) = i+1;
	}
	rep(i, n) {
		cout << vec.at(i) << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1152
# 隣接リスト表現　with weight
from collections import deque

def DFS(ls,start):
    que = deque([])
    que.append(start)
    visited = [0 for _ in range(len(ls))]

    while len(que):
        now = que.popleft()
        for nex in ls[now]:

            if visited[nex[0]]==0:
                que.append(nex[0])
                visited[nex[0]] = visited[now] + nex[1]

    return visited




def main():
    n = int(input())
    ls = [[] for _ in range(n+1)]
    for _ in range(n-1):
        a,b,c = map(int,input().split())
        ls[a].append([b,c])
        ls[b].append([a,c])
    q,k = map(int,input().split())
    x,y = [0 for _ in range(q)],[0 for _ in range(q)]
    for i in range(q):
        x[i],y[i] = map(int,input().split())
    
    memo = DFS(ls,k)

    for i in range(q):
        print(memo[x[i]]+memo[y[i]])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 96984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
	int a,b,c,d;cin>>a>>b>>c>>d;
  	if(a+b>c+d) cout<<"Left"<<endl;
  	else if(a+b==c+d) cout<<"Balanced"<<endl;
  	else cout<<"Right"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
class c
{
  static void Main()
  {
    int[] NM=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int[] fav=new int[NM[1]];
    int count=0;
    for(int i = 0; i<NM[0];i++)
    {
      int[]ans=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
      for(int j=1;j<ans.Length;j++)fav[ans[j]-1]++;
    }
    for(int i=0;i<NM[1];i++)if(fav[i]==NM[0])count++;
    Console.WriteLine(count);
  } 
}

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


int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for( int i = 0; i < N; ++i ) cin >> a[i];


    bool oddAppeared = false;
    for( int i = 0; i < N; ++i ){
        if( a[i]%2 != 0 ){
            oddAppeared = true;
            break;
        }
    }
    if( oddAppeared ) cout << "first" << endl;
    else              cout << "second" << endl;

    return 0;
}


Measured memory_bytes: 640
class UnionFind:
    def __init__(self, length):
        self.parent_indexes = [-1]* length
        
    def union(self, i, j):
        if self.are_in_the_same_group(i, j):
            return
        # iが所属する集団のサイズ>=jが所属する集団のサイズにする
        if self.get_group_size(i) < self.get_group_size(j):
            i, j = j, i
        self.parent_indexes[self.find(i)] = - self.get_group_size(i) - self.get_group_size(j)
        self.parent_indexes[self.find(j)] = self.find(i)
        
    # i番目の要素が所属する集団の親nodeのindexを返す
    # メモ化もする
    def find(self, i):
        if self.parent_indexes[i] < 0:
            return i
        parent_index = self.find(self.parent_indexes[i])
        self.parent_indexes[i] = parent_index
        return parent_index

    def get_group_size(self, i):
        return - self.parent_indexes[self.find(i)]
    
    def are_in_the_same_group(self, i, j):
        return self.find(i) == self.find(j)
    
    
n, q = list(map(lambda x: int(x), input().split()))
uf = UnionFind(n)
for _ in range(q):
    t, u, v = list(map(lambda x: int(x), input().split()))
#     print(uf.parent_indexes)
    if t == 0:
        uf.union(u, v)
        continue
    print('1') if uf.are_in_the_same_group(u, v) else print('0')

Measured memory_bytes: 11720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-8;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int n;
vector<VI> s;
void dfs(VI t, int MAX) {
    if (t.size() == n)s.push_back(t);
    else {
        eFOR(i, 0, MAX) {
            VI d = t;
            d.push_back(i);
            dfs(d, MAX);
        }
        if (MAX != 25) {
            VI d = t;
            d.push_back(MAX + 1);
            dfs(d, MAX + 1);
        }
    }
}

int main() {
    init();

    cin >> n;
    dfs(VI(), -1);
    each(i, s) {
        each(j, i)cout << char('a' + j);
        cout << "\n";
    }
}


Measured memory_bytes: 9648
N=int(input())
A_list=list(map(int,input().split()))
diff=0
step=[]
for a in range(1,len(A_list)):
    diff=A_list[a]-A_list[a-1]
    if diff<0:
        A_list[a]=A_list[a]-diff
        step.append(-diff)
# A_replace=[for a in A_list]
print(sum(step))

Measured memory_bytes: 32228
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

int main() {
    int a, b;
    cin >> a >> b;
    
    bool able = a <= 8 && b <= 8;
    cout << (able ? "Yay!" : ":(");
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<vector<int>,int>P;
vector<int>v[13],s(13),t(13);
map<vector<int>,int>m;
 
int has[14];
 
 
void init(){
 
    v[0].push_back(2);
 
    v[1].push_back(2);
    v[1].push_back(5);
 
    v[2].push_back(0);
    v[2].push_back(1);
    v[2].push_back(3);
    v[2].push_back(6);
 
    v[3].push_back(2);
    v[3].push_back(7);
 
    v[4].push_back(5);
 
    v[5].push_back(1);
    v[5].push_back(4);
    v[5].push_back(6);
    v[5].push_back(9);
 
    v[6].push_back(2);
    v[6].push_back(5);
    v[6].push_back(7);
    v[6].push_back(10);
 
    v[7].push_back(3);
    v[7].push_back(6);
    v[7].push_back(8);
    v[7].push_back(11);
 
    v[8].push_back(7);
 
    v[9].push_back(5);
    v[9].push_back(10);
 
    v[10].push_back(6);
    v[10].push_back(9);
    v[10].push_back(11);
    v[10].push_back(12);
 
    v[11].push_back(7);
    v[11].push_back(10);
 
    v[12].push_back(10);
 
    int a=20;
    int p=1;
 
    r(i,13){
        has[i]=p;
        p*=a;
    }
}
 
int ha(vector<int> &x){
 
    int re=0;
 
    r(i,13){
        re+=x[i]*has[i];
    }
 
    return re;
}
 
vector<int> ah(int x){
    vector<int>y(13);
    r(i,13){
        y[i]=x%20;
        x/=20;
    }
    return y;
}
 
void BFS1(){
    s[0]=0;
    s[12]=0;
    r(i,11)s[i+1]=i+1;
    set<vector<int> >st;
    st.insert(s);
    m[s]=0;
    queue<P>q;
    q.push(P(s,0));
    while(1){
        vector<int> now=q.front().first;
        int cost=q.front().second;
        q.pop();
        if(cost==13)break;
        //cout<<m.size()<<' '<<cost<<endl;
        r(i,13)if(now[i]==0){
            r(j,v[i].size()){
                swap(now[i],now[v[i][j]]);
                if(!st.count(now)){
                    st.insert(now);
                    m[now]=cost+1;
                    q.push(P(now,cost+1));
                }
                swap(now[i],now[v[i][j]]);
            }
        }
    }
}
 
void BFS2(){
    set<vector<int> >st;
    st.insert(t);
    queue<P>q;
    q.push(P(t,0));
    while(1){
        vector<int>now=q.front().first;
        int cost=q.front().second;
        q.pop();
        if(m.count(now)){
            cout<<m[now]+cost<<endl;
            return ;
        }
        if(cost==7)break;
        r(i,13)if(now[i]==0){
            r(j,v[i].size()){
                swap(now[i],now[v[i][j]]);
                if(!st.count(now)){
                    st.insert(now);
                    if(m.count(now)){
                        cout<<m[now]+cost+1<<endl;
                        return ;
                    }
                    q.push(P(now,cost+1));
                }
                swap(now[i],now[v[i][j]]);
            }
        }
    }
    cout<<"NA"<<endl;
}
 
 
signed main(){
    init();
    BFS1();
    while(cin>>t[0],t[0]!=-1){
        r(i,12)cin>>t[i+1];
        BFS2();
    }
}


Measured memory_bytes: 25348
#include<stdio.h>
int main()
{
    char str[100];
    scanf("%s",str);
    int i,l,count=0;
    
    l=strlen(str);
    
    for(i=1;i<=l/2;i++)
    {
        if(str[i-1]!=str[l-i])
        {
            count++;
        }
    }
    printf("%d", count);
    
    return 0;
}

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

public class Main {

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

		int N = sc.nextInt();

		HashMap<String, Integer> cardMap = new HashMap<String, Integer>();
		for (int i = 0; i < N; i++) {
			String tmp = sc.next();
			if (!cardMap.containsKey(tmp)) {
				cardMap.put(tmp, 1);
			} else {
				int value = cardMap.get(tmp);
				cardMap.put(tmp, ++value);
			}
		}

		int M = sc.nextInt();
		for(int i =0;i<M;i++) {
			String key = sc.next();
			if(cardMap.containsKey(key)) {
				int value = cardMap.get(key);
				cardMap.put(key, --value);
			}
		}
		int Max = 0;
		for(String key:cardMap.keySet()) {
			Max = Math.max(Max, cardMap.get(key));
		}
		System.out.println(Max);

	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
const int _=10000011;
int minn[_], n, tot, prime[_]; ll d[_];
bool np[_];

int read() {
	int s = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

int main() {
    n = read();
    d[1] = 1;
    for (int i = 2; i <= n; i++) {
        if (np[i] == 0) prime[++tot] = i, d[i] = 2, minn[i] = 1;
        for (int j = 1; prime[j] * i <= n && j <= tot; j++) {
            np[i * prime[j]] = 1;
            if (i % prime[j] == 0) {
                minn[i * prime[j]] = minn[i] + 1;
                d[i * prime[j]] = d[i] / (minn[i] + 1) * (minn[prime[j] * i] + 1);
                break;
            }
            minn[i * prime[j]] = 1;
            d[i * prime[j]] = d[i] * 2;
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    	ans = ans + i * d[i] * 1ll;
    cout << ans;
}

Measured memory_bytes: 133144
/*input
100000 5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int n,k;
	cin>>n>>k;
	long double ans=0;

	for(int i=1;i<=n;i++){
		int tmp=i;
		long double p=1;
		while(tmp<k){
			tmp<<=1;
			p/=2;
		}
		ans+=p/n;
	}
	cout<<fixed<<setprecision(14)<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll n;
	cin>>n;
	ll a[n];
	
	ll s = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s ^= a[i];
	}

	for(int i=0;i<n;i++)
		cout<< (s^a[i]) <<" ";
	cout<<endl;
}

Measured memory_bytes: 5212
#include <iostream>
#define R(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    double b,c;
    int a[4][2]={0};
    while(cin>>b>>c){
        if(b>1.0) a[0][0] ++;
        else if(b>0.5) a[1][0] ++;
        else if(b>0.1) a[2][0] ++;
        else a[3][0] ++;
        
        if(c>1.0) a[0][1] ++;
        else if(c>0.5) a[1][1] ++;
        else if(c>0.1) a[2][1] ++;
        else a[3][1] ++;
        }
        R(i,4)cout<<a[i][0]<<' '<<a[i][1]<<endl;
}



Measured memory_bytes: 3052
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

signed main(){
    int m;
    cin >> n >> m;
    vector<vector<int>> a(m);
    REP(i,m){
        int k;
        cin >> k;
        REP(j,k){
            int t;
            cin >> t;
            t--;
            a[i].push_back(t);
        }
    }
    vec(b,m);
    REP(i,m){
        cin >> b[i];
    }
    int ans = 0;
    for(int bit = 0;bit < (1 << n); ++bit){
        bool bo = true;
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }
        
        REP(i,m){
            int tmp = 0;
            REP(j,(a[i]).size()){
                auto result = find(S.begin(),S.end(),a[i][j]);
                if(result != S.end()){
                    tmp++;
                }
            }
            
            if(tmp % 2 != b[i]){
                bo = false;
            }
        }
        
        
        if(bo){
            ans++;
        }

    }
    print(ans)
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

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

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

#define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

constexpr int max_n = 2000 + 5;
int n;
vector<pair<int,int>> as;
// dp[i][j] = [i,j)以外の場所にas[0]からas[i+n-j-1]を置くときの最大値
vector<vector<ll>> dp(max_n, vector<ll>(max_n));
ll res;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin>>n;
    as.resize(n);
    rep(i,n) {
        int a; cin>>a;
        as[i] = {a, i};
    }
    sort(as.rbegin(), as.rend());

    dp[0][n] = 0;
    for (int l = n - 1; l >= 0; l--) {
        for (int i = 0, j = l; j <= n; i++, j++) {
            // j - i == l
            int k = n - l - 1; // 置いた個数
            ll a = as[k].first, pos = as[k].second;
            dp[i][j] = 0;
            if (i-1 >= 0) { dp[i][j] = max(dp[i][j], dp[i-1][j] + a * abs(i-1 - pos)); }
            if (j+1 <= n) { dp[i][j] = max(dp[i][j], dp[i][j+1] + a * abs(j - pos)); }
            debug(dp[i][j], i, j);
        }
    }
    rep(i, n+1) {
        res = max(res, dp[i][i]);
    }
    cout << res << '\n';

    return 0;
}


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

using namespace std;

namespace {

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

    int N;
    map< pair<int, int>, int > M;
    void input() {
        cin >> N;
        for (int i = 0; i < N; i++) {
            int x, y, w; cin >> x >> y >> w;
            M[make_pair(x, y)] += w;
        }
    }

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

    void solve() {
        int ans = 0;
        for (map< pair<int, int>, int >::iterator it = M.begin(); it != M.end(); it++) {
            int x = it->first.first;
            int y = it->first.second;
            for (int i = 0; i < 4; i++) {
                int w = 0;
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (M.count(make_pair(x, y))) w += M[make_pair(x, y)];
                if (M.count(make_pair(nx, y))) w += M[make_pair(nx, y)];
                if (M.count(make_pair(x, ny))) w += M[make_pair(x, ny)];
                if (M.count(make_pair(nx, ny))) w += M[make_pair(nx, ny)];
                ans = max(ans, w);
            }
        }
        cout << ans << " / " << 1 << endl;
    }
}

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

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int const N = 200 * 1010;

/********************i**********************************/
void solve(){
	int n;
	cin >> n;
	vector<int> vec(n);
	for(auto &a : vec)cin >> a;
	vector<int> dp(n+1, 1e9);
	dp[n-1] = 0;
	dp[n-2] = abs(vec[n-2] - vec[n-1]);
	for(int x = n-3; x>=0; x--){
		dp[x] = min(dp[x+2] + abs(vec[x] - vec[x+2]), dp[x+1] + abs(vec[x] - vec[x+1]));
	}
	cout << dp[0] << "\n";
}

/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl;
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	int n;
	cin>>n;
	vll v(n);
	rep(i,0,n)cin>>v[i];
	vll v1(v);
	srt(v);
	ll c=0;
	rep(i,0,n)if(v[i]!=v1[i])c++;
	if(c==0||c==2)
	cout<<"YES";
	else
	cout<<"NO";
}



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

/**
|||||||||||||       |||||     |||||    ||||||||||
||||||||||||||      |||||     |||||  |||||
|||||     |||||     |||||     |||||  |||||
||||||||||||||||    |||||||||||||||    ||||||||||
|||||||||||||||||   |||||||||||||||           |||||
|||||        |||||  |||||     |||||           |||||
|||||         ||||| |||||     |||||    ||||||||||
AHMED;HASSAN;SAEED;
*/

using namespace std;
int n,m;
vector<vector<int> >schs(11);
vector<int>sns;
int ans=0;
void sch(vector<int>v,int k,int c=0,int ls=0){
    if(c==k){
            int cnt2=0;
        for(int i=0;i<m;i++){
            int cnt=0;
            for(int j=0;j<schs[i].size();j++){
                if(find(v.begin(),v.end(),schs[i][j])!= v.end()){
                    cnt++;
                }
            }
            if(cnt%2==sns[i]){
                cnt2++;
            }
        }
        if(cnt2==m){
            ans++;
        }
        return ;
    }
    for(int i=ls+1;i<=n;i++){
        v.push_back(i);
        sch(v,k,c+1,i);
        v.pop_back();
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int t;
            cin>>t;
            schs[i].push_back(t);
        }
    }
    for(int i=0;i<m;i++){
        int sn;
        cin>>sn;
        sns.push_back(sn);
    }
    vector<int>v;
    for(int i=0;i<=n;i++)
        sch(v,i);
    cout << ans << endl;
    return 0;
}


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

bool is (int c)
{
	for(int i=0;i<400;i++)
	{
		if(i*i==c)
		return true;
	}
	return false;
}

int main()
{
	int a,b;
	cin>>a>>b;
	int c;
	if(b>=1&&b<10)
	c=a*10+b;
	else if(b<100)
	c=a*100+b;
	else
	c=a*1000+b;
	if(is(c))
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
//Atcoder Begineer Contest050
//A - Multiple of 2 and N
//2018/07/01/ 20:38

#include<stdio.h>

int main(void)
{
  int N;
  int res;

  scanf("%d",&N);

  if(N%2==0){
    res = N;
  }
  else{
    res = N*2;
  }

  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 128
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <time.h>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::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;
}

template<typename T>
std::vector<T> vec(int len, T elem) {return std::vector<T>(len, elem);}

template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i] <<std:: endl;
		else std::cout << da[i] << ' ';
	}
}
template<typename T>
void vvdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
}

using namespace std;

int main(){
	int n;cin >> n;
	vector<int> da(n);rip(i,n,0) cin >> da[i];
	int ans = 0, now = n+1;
	rip(i,n,0){
		if(chmin(now,da[i])){
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> l(N);
  int i,j,k;
  long long ans = 0;
  for(i=0;i<N;i++)cin >> l[i];
  sort(l.begin(),l.end());
  vector<pair<long long,int>> L(1,pair<long long,int>(l[0],1));
  for(i=1;i<N;i++) {
    if(l[i] != l[i-1])L.push_back(pair<long long,int>(l[i],1));
    else L[L.size()-1].second++;
  }
  N = L.size();
  for(i=0;i<N-2;i++)for(j=i+1;j<N-1;j++)for(k=j+1;k<N;k++) {
    if(L[k].first-L[j].first < L[i].first) {
      ans += L[i].second*L[j].second*L[k].second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
//void swap(ll a,ll b){
//	ll d;
//	d=a;
//	a=b;
//	b=d;
//	return;
//}
ll mypow(ll x,int m){
	if(m==0)return 1;
	if(m%2==0){
		int x2=mypow(x,m/2);
		return x2*x2;
	}else{
		int x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
//    	cout<<b<<endl;
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll dp[3003][3003]={};

ll n,t;
P p[3003];
ll a[3003],b[3003];
int main() {
	cin>>n>>t;
	rep(i,0,n){
		cin>>a[i]>>b[i];
		p[i]=P(a[i],b[i]);
	}
	sort(p,p+n);
	rep(i,0,n){
		//cout<<p[i].first<<" "<<p[i].second<<endl;
		a[i]=p[i].first;
		b[i]=p[i].second;
	}
	rep(i,0,t){
		rep(j,0,n){
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
			dp[min(t,i+a[j])][j+1]=max(dp[min(t,i+a[j])][j+1],dp[i][j]+b[j]);
		}
	}
	rep(i,0,n){
		dp[t][n]=max(dp[t][n],dp[t][i]);
	}
	cout<<dp[t][n]<<endl;
	return 0;
}


Measured memory_bytes: 70784
n = int(input())
a = list(map(int,input().split()))
def gcd(m,n):
  if m > n: m,n = n,m
  while m != 1:
    if n%m == 0: return m
    m,n = n%m , m
  return m
ans = a[0]
for i in range(n-1):
  ans = gcd(ans,a[i+1])
print(ans)

Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 100000;

typedef long long ll;


// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    // 前処理    
    int n, k;
    int max_gcd;
    long long int answer = 0;
    cin >> n >> k;
    max_gcd = k;// / n;
    if (max_gcd == 0) {
        max_gcd = 1;
    }
    vector<long long> gcd_table(max_gcd+1);
    for (int cur_gcd = max_gcd; cur_gcd >= 1; cur_gcd--) {
        gcd_table[cur_gcd] = modpow(k / cur_gcd, n, MOD) * cur_gcd;
        for (int i = 2; i <= k; i++) {
            if (cur_gcd * i > k) {
                break;
            }
            gcd_table[cur_gcd] -= gcd_table[cur_gcd * i] / i;
        }
    }
    for (int i = 1; i <= max_gcd; i++) {
        answer += gcd_table[i];
        answer %= MOD;
    }
    cout << answer << endl;
}

Measured memory_bytes: 3976
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define MAXN 800
#define INF 0x3FFFFFFF
using namespace std;
struct Point
{
	int x,y;
	Point(){};
	Point(int _x,int _y):x(_x),y(_y){};
};
int ans=INF,n,m,K;
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
char Map[MAXN+5][MAXN+5];
bool vis[MAXN+5][MAXN+5];
queue<Point> que;
queue<int> step;
void BFS(int x,int y)
{
	que.push(Point(x,y));
	step.push(0);
	vis[x][y]=true;
	int nx,ny,stn;
	while(que.empty()==false)
	{
		x=que.front().x;
		y=que.front().y;
		stn=step.front();
		que.pop();step.pop();
		ans=min(ans,(x-1+K-1)/K+1);
		ans=min(ans,(n-x+K-1)/K+1);
		ans=min(ans,(y-1+K-1)/K+1);
		ans=min(ans,(m-y+K-1)/K+1);
		if(stn==K)
			continue;
		for(int p=0;p<4;p++)
		{
			nx=x+dir[p][0];
			ny=y+dir[p][1];
			if(nx<=0||ny<=0||nx>n||ny>m)
				continue;
			if(vis[nx][ny]==false&&Map[nx][ny]=='.')
			{
				vis[nx][ny]=true;
				que.push(Point(nx,ny));
				step.push(stn+1);
			}
		}
	}
}
int main()
{
//	freopen("room.in","r",stdin);
//	freopen("room.out","w",stdout);
	scanf("%d %d %d",&n,&m,&K);
	for(int i=1;i<=n;i++)
		scanf("%s",Map[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(Map[i][j]=='S')
			{
				BFS(i,j);
				if(i==1||j==1||i==n||j==m)
					ans=0;
			}
	printf("%d\n",ans);
	return 0;
}
/*
3 3 1
...
S..
...

*/

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

ll n,a,b;

void solve(){
    cin >> n >> a >> b;
    if(a<b)swap(a,b);
    if(a%2==b%2){
        cout << (a-b)/2 << endl;
    }
    else{
        cout << min(b+(a-b-1)/2,n-a+1+(a-b-1)/2) << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
#include<stdio.h>

int cup[15],n;

long beki(int a,int b){
	int i;
	long ans=1;
	for(i=0;i<b;i++){
		ans*=a;
	}
	return ans;
}

long mini(int min,int c){
	if(min==(n-1)){
		switch(cup[min]-c){
			case 0:
			return 0;
			case 1:
			case -1:
			return 1;
			case 2:
			case -2:
			return 2;
		}
	}else{
		switch(cup[min]){
			case 0:
			if(c==0){
				return mini(min+1,0);
			}else if(c==1){
				return mini(min+1,2)+1+(beki(3,n-min-1)-1)/2;
			}else{
				return mini(min+1,2)+(2*beki(3,n-min-1));
			}
			case 1:
			if(c==0){
				return mini(min+1,2)+beki(3,n-min-1);
			}else if(c==1){
				return mini(min+1,1);
			}else{
				return mini(min+1,0)+beki(3,n-min-1);
			}
			case 2:
			if(c==0){
				return mini(min+1,0)+(2*beki(3,n-min-1));
			}else if(c==1){
				return mini(min+1,0)+1+((beki(3,n-min-1)-1)/2);
			}else{
				return mini(min+1,2);
			}
		}
	}
}

int main(){
	int i,j,c,cc;
	long m,amin,bmin;
	scanf("%d %lld",&n,&m);
	while(n!=0){
	for(i=0;i<3;i++){
		scanf("%d",&c);
		for(j=0;j<c;j++){
			scanf("%d",&cc);
			cup[cc-1]=i;
		}
	}
	amin=mini(0,0);
	bmin=mini(0,2);
	if(amin>=bmin){
		if(m<bmin) printf("-1\n");
		else printf("%ld\n",bmin);
	}else{
		if(m<amin) printf("-1\n");
		else printf("%ld\n",amin);
	}
	scanf("%d %ld",&n,&m);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
#define INF 1e9


typedef pair<int, int> P;

/* 　"assert"    assert(A：条件式)で　Aが真なら処理は続行、偽ならプログラムを終了する　*/

/*　　ラムダ式　　 auto a = [キャプチャ](パラメータ){ 処理 }  */

/* string型　メンバ関数　substr()    replace()  */

int main(){
    string s; cin >> s;
    
    int n = s.size();
    string ans;
    rep(i,n) {
        if(s[i] != 'B'){
            ans += s[i];
            continue;
        }
        else{
            if(ans == "") continue;
            ans.erase(ans.end()-1);
        }
        

    }
    cout << ans << endl;
    


}


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


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

    """
    ■ 解法
    N = p^{e1} * p^{e2} * p^{e3} ...
    と因数分解できるとき、
    z = p_i^{1}, p_i^{2}, ...
    としていくのが最適なので、それを数えていく

    (例) N = 2^2 * 3^2 * 5 * 7
    のとき、
    2,3,5,7の4回割れる。（6で割る必要はない）

    ■ 計算量
    素因数分解するのに、O(√N)
    割れる回数を計算するのはたかだか素因数分解するより少ないはずなので、
    全体としてはO(√N+α)くらいでしょ（適当）
    """
    def prime_factor(n):
        """素因数分解する"""
        i = 2
        ans = {}
        while i*i <= n:
            while n%i == 0:
                if not i in ans:
                    ans[i] = 0
                ans[i] += 1
                n //= i
            i += 1
        if n != 1:
            ans[n] = 1
        return ans

    pf = prime_factor(N)

    ans = 0
    for key, value in pf.items():
        i = 1
        while value-i >= 0:
            value -= i
            ans += 1
            i += 1
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 8992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

ll mod(ll x){
    ll res=x%MOD;
    return res+(res<0?MOD:0);
}
ll inv(ll x){
    ll b=MOD,u=1,v=0;
    while(b){
        ll t=x/b;
        x-=t*b;swap(x,b);
        u-=t*v;swap(u,v);
    }
    return mod(u);
}
vector<ll> prods(int x){
    vector<ll> res(x+1);
    res[0]=1;
    for(int i=1; i<=x; i++)res[i]=mod(i*res[i-1]);
    return res;
}
vector<ll> pows(ll a,int x){
    vector<ll> res(x+1);
    res[0]=1;
    a=mod(a);
    for(ll i=1; i<=x; i++)res[i]=mod(a*res[i-1]);
    return res;
}
ll power(ll a, ll n){
    ll res=1;
    a=mod(a);
    for(;n>0;n>>=1){
        if(n&1)res=mod(res*a);
        a=mod(a*a);
    }
    return res;
}

vector<ll> p;//p=prods(MAX_n)
ll comb(ll a, ll b){
    if(b<0||b>a)return 0;
    return mod(mod(p[a]*inv(p[b]))*inv(p[a-b]));
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    ll ans = 0;

        p = prods(500000);
    if(k>=n-1)ans = comb(2*n-1,n);//comb あとで
    else{//1を超えた数がk,k-1,k-2,...を足す？
    //そのとき0がk個なのでn-kかしょでkを分ける
    //0の選び方も入れるとC(n,k)*C(n-1,k)?
        if(k==1)ans=-1;
        while(k>=0){
            ans += mod(comb(n,k)*comb(n-1,k));
            ans = mod(ans);
            k-=1;
        }
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <vector>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k;
    cin >> k;
    if (k <= 500) {
        printf("%d\n", k);
        for (int i = 1; i <= k; ++i) {
            for (int j = 1; j <= k; ++j) {
                printf("%d%c", i, "\n "[j < k]);
            }
        }
        return 0;
    }
    int n = ((k + 1) / 2 + 1) / 2 * 2;
    int col[501][2] = {};
    for (int i = 1; i <= n; ++i) {
        col[i][0] = i;
    }
    for (int i = n + 1; i <= k; ++i) {
        col[i - n][1] = i;
    }
    printf("%d\n", n);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            int C = (i + j) % n + 1;
            int p = col[C][0];
            if ((j & 1) && col[C][1]) p = col[C][1];
            printf("%d%c", p, "\n "[j < n]);
        }
    }
    return 0;
}

Measured memory_bytes: 1280
fun main(arr:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val road = (1..m).map { readLine()!!.split(" ").map { it.toInt() - 1 } }
    val cnt = IntArray(n)
    road.forEach {
        cnt[it[0]]++
        cnt[it[1]]++
    }
    cnt.forEach { println(it) }
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, K;
	cin >> N >> K;
	int64 res = 0;
	while (N) {
	  res++;
	  N /= K;
	}
	cout << res << endl;
}


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

int main()
{
  int n;
  cin>>n;
  long long int s=0;
  for(int i=1;i<=n;++i)
    for(int j=1;j<=n;++j)
      for(int k=1;k<=n;++k)
        s+=__gcd(__gcd(j,k),i);
  cout<<s;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <stack>
using namespace std;
int main(void){
   long N; int n[10]; int rep=0;
   cin>>N;
   while(N>0){
       n[rep]=N%10;
       N=N/10;
       rep++;
   }
int number[10];

for(int i=0;i<rep;i++){
    number[i]=n[rep-i-1];
}
   int min=100000;
   for(int i=0;i<rep-2;i++){
       int a=number[i];
       int b=number[i+1];
       int c=number[i+2];
       int num=a*100+b*10+c;
       int gap=abs(num-753);
       if(gap<min) {min=gap;}
   }
   cout<<min;
   return 0;
}


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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int x;
	cin >> x;
	cout << !x;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3648
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int A, B;
    cin >> A >> B;
    int cnt = 0;
    for (int i = A; i <= B; i++) {
        if (i / 1000 == (i % 10) * 10 + (i % 100) / 10)cnt++;
    }
    print(cnt);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> edge[100001];
vector<int> root;

bool dfs(int u, int v){
    if(v == n){
        root.push_back(n);
        return true;
    }
    else{
        for(auto p=edge[v].begin(); p!=edge[v].end(); p++){
            if(*p == u) continue;
            if(dfs(v,*p)){
                root.push_back(v);
                return true;
            }
        }
    }
   return false; 
}


int main(){
    cin >> n;
    for(int i=0; i<n-1; i++){
        int a,b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dfs(1,1);
    queue<int> que;
    int check[n+1];
    fill(check,check+n+1,-1);
    int cnt[2];
    fill(cnt,cnt+2,0);
    for(int i=0; i<root.size()/2; i++){
        que.push(root[i]);
        check[root[i]] = 1;
        cnt[1]++;
    }
    for(int i=root.size()/2; i<root.size(); i++){
        que.push(root[i]);
        check[root[i]] = 0;
        cnt[0]++;
    }
    while(!que.empty()){
        int u = que.front();
        que.pop();
        for(auto p=edge[u].begin(); p!=edge[u].end(); p++){
            if(check[*p] == -1){
                check[*p] = check[u];
                cnt[check[u]]++;
                que.push(*p);
            }
        }
    }
    if(cnt[0] > cnt[1]) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    return 0;
}


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

int main() {
  int N, Ni;
  cin >> N;
  vector<int> count(101,0);
  
  for (int i=0; i<N; i++){
    cin >> Ni;
    ++count.at(Ni);
  }
  
  int ans = 0, M = 1;
  for (int i=100; i>0; i--){
    if(count.at(i)%2==1){
      ans=ans+i*M;
      M=-M;
    }
  }
 cout << ans << endl;
}
 


Measured memory_bytes: 256