akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

bool isIncluding( string p, char a, char b )
{
    for( int i = 0; i < p.size(); i++ )
        if( a <= p[i] && p[i] <= b )
            return true;
    return false;
}

int main()
{
    string p;

    cin >> p;

    if( p.size() >= 6 && isIncluding( p, '0', '9' ) && isIncluding( p, 'a', 'z' ) && isIncluding( p, 'A', 'Z' ) )
        cout << "VALID" << endl;
    else
        cout << "INVALID" << endl;

    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll N=200005, inf=1e18;
void solve(){
	ll k, a, b;
	cin>>k>>a>>b;
	rep(i,a,b+1){
		if(i%k==0){
			cout<<"OK";
			return;
		}
	}
	cout<<"NG";
}	
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

const double eps = 1e-6;

int main(){
	/*
		 sq(a) + sq(b) < sq(c)
	<==> ( sq(a)+sq(b))^2 < c
	<==> 2_sq(ab) < c-a-b
	
	<==> c-a-b > 0 && 4ab < (c-a-b)^2	解説見て泣いた。不等式ニガテですorz

	*/

	long long a,b,c;	cin>>a>>b>>c;

	long long d=c-a-b;
	if(d>0 && 4*a*b<d*d)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

int main(){
	int n,s;
	while(cin >> n >> s){
		if(n == 0 && s == 0)break;
		int num = 0;
		for(int zero = 0; zero <= 1; zero++){
			for(int one = 0; one <= 1; one++){
				for(int two = 0; two <= 1; two++){
					for(int three = 0; three <= 1; three++){
						for(int four = 0; four <= 1; four++){
							for(int five = 0; five <= 1; five++){
								for(int six = 0; six <= 1; six++){
									for(int seven = 0; seven <= 1; seven++){
										for(int eight = 0; eight <= 1; eight++){
											for(int nine = 0; nine <= 1; nine++){
												if(zero + one + two + three + four + five + six + seven + eight + nine == n && one + two * 2 + three * 3 + four * 4 + five * 5 + six * 6 + seven * 7 + eight * 8 + nine * 9 == s)num++;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		cout << num << endl;
	}
}


Measured memory_bytes: 3072
//When I wrote this, only God and I understood what I was doing
//Now, God only knows :-)
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ch char
#define vc vector
#define mod 1000000007
int main() {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    ll a[t],dp[t];
    for(int i=0;i<t;i++)cin>>a[i];
    dp[1]=abs(a[0]-a[1]);
    dp[2]=abs(a[0]-a[2]);
    for(int i=1;i<t-1;i++)
    {
    	if(i!=t-2)
    	dp[i+2]=dp[i]+abs(a[i+2]-a[i]);
    	dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
	}
	//for(int i=0;i<t;i++)cout<<dp[i]<<" ";
	cout<<dp[t-1];

}


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

long l[100][100], r[100][100];
long v[100], s[100];

int main(void) {
    int n, k;
    cin >> n >> k;
    for(int i=0; i<n; i++) {
        cin >> v[i];
        s[i] = v[i];
    }
    sort(s, s+n);

    for(int i=0; i<k; i++)
        for(int j=0; j<n; j++)
            l[i][j] = r[i][j] = -1e9;

    {
        for(int j=0; j<n; j++)
            r[0][j] = 0;

        for(int i=0; i<=n; i++) {
            priority_queue<long> q;
            long sum = 0;
            for(int j=0; j<i; j++) {
                sum += v[n-1-j];
                q.push(-v[n-1-j]);
            }
            r[i][i] = sum;
            for(int j=1; j<=i; j++) {
                long p = -q.top(); q.pop();
                sum -= p;
                r[i+j][i] = max(r[i+j][i], sum);
            }
        }
    }
    {
        for(int j=0; j<n; j++)
            l[0][j] = 0;

        for(int i=0; i<=n; i++) {
            priority_queue<long> q;
            long sum = 0;
            for(int j=0; j<i; j++) {
                sum += v[j];
                q.push(-v[j]);
            }
            l[i][i] = sum;
            for(int j=1; j<=i; j++) {
                long p = -q.top(); q.pop();
                sum -= p;
                l[i+j][i] = max(l[i+j][i], sum);
            }
        }
    }

    long res = -1e9;
    for(int i=0; i<=k; i++) {
        for(int j=0; i+j<=k; j++) {
            for(int ii=0; ii<n; ii++)
                for(int jj=0; ii+jj<=n; jj++) {
                    res = max(res, l[i][ii]+r[j][jj]);
                }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
     
main()
{
  int X;
  cin >> X;
  int tmp;
  if( X > 10000000 ) tmp = X / 10;
  else if( X > 100000000 ) tmp = X / 100;
  else tmp = X;

  //cout << tmp << endl;

  while( 1 ) {
    int sum = tmp * (1 + tmp) / 2;
    int sum2 = (tmp-1) * (1 + tmp-1) / 2;
    if( sum >= X && sum2 < X ) {
      cout << tmp << endl;
      break;
    }
    tmp--;
  }  
 
}

Measured memory_bytes: 384
l,r=map(int,input().split())
if(r-l+1)>2019:
  print(0)
else:
  mod=[]
  ans=[]
  for i in range(r-l+1):
    mod.append((l+i)%2019)
  for i in range(r-l):
    for j in range(i+1,r-l+1):
      ans.append((mod[i]*mod[j])%2019)
  print(min(ans))



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

void  solve(){
unordered_map<int,int> cnt;
int n;
cin>>n;
vector<int> v(n);
long long sum=0;
for(int i=0;i<n;i++){
	cin>>v[i];
	cnt[v[i]]++;
	sum=sum+v[i];
}
int q;
cin>>q;

while(q--)
{
	int a,b;
	cin>>a>>b;
	sum=sum+cnt[a]*(b-a);
	cout<<sum<<endl;
	cnt[b]=cnt[a]+cnt[b];
	cnt[a]=0;
}


}

int  main(){

	
		solve();


 
}


Measured memory_bytes: 7456
s=input()
for _ in[0]*int(input()):
 a=input().split()
 o=a[0];i,j=map(int,a[1:3]);j+=1
 if'p'==o[0]:print(s[i:j])
 else:s=s[:i]+(a[3]if'p'==o[2]else s[i:j][::-1])+s[j:]


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

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


Measured memory_bytes: 256
bun = input()
lst = input().split()
nlst = []
for i in range(1000000):
    nlst.append(0)
for i in range(len(lst)):
    nlst[int(lst[i])-1] += 1
for i in range(1000000):
    if nlst[i] > 0:
        for j in range((i+i+1),1000000,i+1):
            nlst[j] = 0
count = 0
for i in range(1000000):
    if nlst[i] == 1 :
        count += 1
print(count)

Measured memory_bytes: 33128
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(new BufferedInputStream(System.in));
		List<String> output = new ArrayList<String>();
		while (scan.hasNext()) {
			String input = scan.nextLine();
			String[] in = input.split(" ");
			int H = Integer.parseInt(in[0]);
			int W = Integer.parseInt(in[1]);
			if (H == 0 && W == 0) {
				break;
			} else {
				if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
					for (int i = 1; i <= H; i++) {
						String result = "";
						for (int j = 1; j <= W; j++) {
							if (i == 1 || i == H) {
								result += "#";
							} else {
								if (j == 1 || j == W) {
									result += "#";
								} else {
									result += ".";
								}
							}
						}
						output.add(result);
					}
					output.add("");
				}
			}
		}
		for (String out : output) {
			System.out.println(out);
		}
	}
}

Measured memory_bytes: 49040
from itertools import permutations

# 入力
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

# (i + j) % 3 = k のマスを色cに塗り替える際の違和感の和
dp = {
    k: [
        sum(
            D[c[i][j] - 1][k - 1] if (i + j) % 3 == m else
            0
            for i in range(N)
            for j in range(N)
        )
        for m in range(3)
    ]
    for k in range(1, C + 1)
}

# dpを用いて全探索し解を得る
ans = min(
    dp[i][0] + dp[j][1] + dp[k][2]
    for i, j, k in permutations(range(1, C + 1), 3)
)

# 出力
print(ans)


Measured memory_bytes: 46556
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;

    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    multiset<ll> s;

    rep(i, n) s.insert(v[i]);

    int ans = 0;
    rep(i, n) {
        ll a = v[i];
        s.erase(s.find(a));

        bool ok = [&] {
            for (int j = 1; j * j <= a; j++) {
                if (a % j != 0) continue;
                if (s.find(j) != s.end()) return true;
                if (s.find(a / j) != s.end()) return true;
            }
            return false;
        }();
        if (!ok) ans++;
        s.insert(a);
    }
    cout << ans << endl;
}


Measured memory_bytes: 14012
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

int main() {
    int A, B, C;
    int x;
    std::cin >> A >> B >> C;
    x=min(A, B+C);
    std::cout << B+C-x << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll r;
    cin>>r;
    cout<<fixed<<setprecision(20)<<2*PI*r<<"\n";
}


Measured memory_bytes: 3800
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long int TInt;
typedef std::vector<TInt> TList;
TList GetDivisor(TInt X)
{
    TList Divisor;
    TInt Max = std::sqrt(X);
    for(TInt i = 1; i <= Max; ++i){
        if(X % i == 0){
            Divisor.push_back(i);
            if(i != Max){
                Divisor.push_back(X / i);
            }
        }
    }
    return Divisor;
}
template<typename T>
std::vector<T> Unite(const std::vector<T>& A, const std::vector<T>& B)
{
    std::vector<T> Temp = A;
    Temp.insert(Temp.end(), B.begin(), B.end());
    return Temp;
}
template<typename T>
T GetGreatestCommon(const std::vector<T>& A, const std::vector<T>& B)
{
    std::vector<T> Temp = Unite(A, B);
    std::sort(Temp.begin(), Temp.end());
    return *(std::adjacent_find(Temp.rbegin(), Temp.rend()));
}
int main()
{
    TInt x, y;
    std::cin >> x;
    std::cin >> y;
    if(x < y) std::swap(x, y);
    x = x % y;
    if(x == 0){
        std::cout << y << std::endl;
        return 0;
    }
    
    TList DivisorX = GetDivisor(x);
    TList DivisorY = GetDivisor(y);
    TInt A = GetGreatestCommon(DivisorX, DivisorY);
    std::cout << A << std::endl;
    
    return 0;
}

Measured memory_bytes: 1220
n = int(input())
Taro_ten = 0
Hanako_ten = 0
for i in range(n) :
    a, b = list(input().split())
    Taro = list(a)
    Hanako = list(b)
    length = min(len(Taro), len(Hanako))
    for i in range(length) :
        if ord(Taro[i]) > ord(Hanako[i]) :
            Taro_ten += 3
            break
        elif ord(Taro[i]) < ord(Hanako[i]) :
            Hanako_ten += 3
            break
        if i == length -1 :
            if len(Taro) > length :
                Taro_ten += 3
            elif len(Hanako) > length :
                Hanako_ten += 3
            else :
                Taro_ten += 1
                Hanako_ten += 1
print(Taro_ten, Hanako_ten)


Measured memory_bytes: 5600
from decimal import Decimal
n = int(input())
a = []
r = {}
for i in range(n):
    d = int(float(input())*10**9+0.01)
    d2 = 0
    d5 = 0
    while True:
        if d % 2 != 0 and d % 5 != 0:
            break
        if d % 2 == 0:
            d //= 2
            d2 += 1
        if d % 5 == 0:
            d //= 5
            d5 += 1
    a.append((d2,d5))
    r[(d2,d5)] = r.get((d2,d5),0) + 1
ans = 0
for x , y in r.keys():
    for i , j in r.keys():
        if min(x+i,y+j) >= 18:
            ans += r[(x,y)]*r[(i,j)]
            if x == i and y == j:
                ans -= r[(x,y)]
                
print(ans//2)

Measured memory_bytes: 99220
N = int(input())
S = input()
R = S.count('R')
G = S.count('G')
B = S.count('B')
ans = R*G*B
for i in range(N):
    for d in range(N):
        j = i + d
        k = i + 2*d
        if k >= N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1
print(ans)

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

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll x;
    cin >> x;
    cout << x/500 * 1000 +(x%500/ 5 * 5) << "\n";
    
    
    return 0;
}


Measured memory_bytes: 384
N = int(input())
a = [int(i) for i in input().split()]
color = [0] * 9
ans1, ans2 = 0, 0
for i in a:
    if i <= 399:
        color[0] = 1
    elif i <= 799:
        color[1] = 1
    elif i <= 1199:
        color[2] = 1
    elif i <= 1599:
        color[3] = 1
    elif i <= 1999:
        color[4] = 1
    elif i <= 2399:
        color[5] = 1
    elif i <= 2799:
        color[6] = 1
    elif i <= 3199:
        color[7] = 1
    else:
        color[8] += 1

ans1 = sum(color)
ans2 = sum(color[:8])
if ans2 == 0:
    ans2 = 1
print(ans2, ans1)

Measured memory_bytes: 3064
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
ll A,B,C;
cin>>A>>B>>C;
if((A%2==0)||(B%2==0)||(C%2==0)){
    cout<<0<<endl;
    return 0;
}
ll min_mult=(ll)powl(10,18);
min_mult=min(min_mult,A*B);
min_mult=min(min_mult,B*C);
min_mult=min(min_mult,C*A);
cout<<min_mult<<endl;

return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int a = sin.nextInt();
    String op = sin.next();
    int b = sin.nextInt();

    while( !op.equals("?") ) {
      switch(op) {
       case "+" : System.out.println(a + b); break;
       case "-" : System.out.println(a - b); break;
       case "*" : System.out.println(a * b); break;
       case "/" : System.out.println(a / b); break;
       default  : break;
      }

      a  = sin.nextInt();
      op = sin.next();
      b  = sin.nextInt();
    }

    sin.close();
  }
}


Measured memory_bytes: 26168
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
    ll a, b, c, d, res;
	cin >> a >> b >> c >> d;

    if (a >= 0 && b >= 0){
        if (c >= 0 && d >= 0){
            res = b * d;
        } else if ( c < 0 && d >= 0 ){
            res = b * d;
        } else if ( c < 0 && d < 0 ){
            res = a * d;
        }
    } else if (a < 0 && b >= 0){
        if (c >= 0 && d >= 0){
            res = b * d;
        } else if ( c < 0 && d >= 0 ){
            res = max(a*c, b*d);
        } else if ( c < 0 && d < 0 ){
            res = a * c;
        }
    } else if (a < 0 && b < 0){
        if (c >= 0 && d >= 0){
            res = b * c;
        } else if ( c < 0 && d >= 0 ){
            res = a * c;
        } else if ( c < 0 && d < 0 ){
            res = a * c;
        }
    }

    cout << res << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int a, b, c, x; cin >> a >> b >> c >> x;
    int cnt = 0;
    rep(i, 0, a+1) {
        rep(j, 0, b+1) {
            rep(k, 0, c+1) {
                int t = i*500 + j*100 + k*50;
                if (t == x) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3660
#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))
using namespace std;
signed main(){
	int a,b,c;
	cin >> a >> b >> c;
	a *= 100;
	b *= 10;
	int ans = a + b + c;
	(ans%4 == 0)? cout << "YES" << endl : cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10) cout << a * b;
    else cout << -1;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define  ren(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) ren(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
 
int main()
{
    string s;
    cin>>s;
    int L=s.size();
    rep(i,L) if(s[i]=='A') for(int j=L-1;j>=i;j--) if(s[j]=='Z') cout<<j-i+1<<endl,exit(0);
}


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

int main()
{
  char b;
  cin >> b;
  char c;
  if(b == 'A')
  {
    c = 'T';
  }
  if(b == 'T')
  {
    c = 'A';
  }
  if(b == 'G')
  {
    c = 'C';
  }
  if(b == 'C')
  {
    c = 'G';
  }
  cout << c << endl;
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var ans = [];
  for(var i = 0; i < 365; i++){
    ans[i] = i%26+1;
  }
  return ans.join("\n");
}

Measured memory_bytes: 30568
#include<stdio.h>
int main()
{
    int n, m, s=0;
    scanf("%d %d",&n,&m);
    int A[m], i;
    for(i=0;i<m;i++)
    {
        scanf("%d", &A[i]);
        s+=A[i];
    }
    if(s>n) printf("-1");
    else printf("%d", n-s);
}


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

using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
const ll INF=1000000000000000;

int main(){
	map<string,int> stmap;
	ll N; cin>>N;
	rep(i,N){
		string s; cin>>s;
		sort(s.bg,s.ed);
		stmap[s]++;
	}
	ll ans=0;
	for(auto itr=stmap.bg;itr!=stmap.ed;itr++){
		ll t=itr->second;
		ans+=(t-1)*t/2;
	}
	cout<<ans;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, a;
  cin >> n >> a;
  cout << (n%500 <= a ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 384
import Control.Applicative

import Text.Printf
    (printf)
    
solve :: Int -> Int -> (Int, Int, Double)

solve a b
    = (d, r, f) where
        d = div a b
        r = mod a b
        f = fromIntegral a / fromIntegral b

input :: Read a => IO [a]

input
    = map read.words <$> getLine

output :: (Int, Int, Double) -> String

output (d, r, f)
    = printf "%d %d %.5f" d r f
    
main :: IO ()
    
main
    = do
        [a, b] <- input
        putStrLn $ output $ solve a b

Measured memory_bytes: 3880
/* 
Vacation
巡回セールスマン同様に次の選択uを考えるのに
それまでの部分集合Sの最後vがなにであるかの仮定が必要なタイプ
今回はvによってはv-uの経路が存在しない形式
*/

#include<iostream>
#include<vector>
using namespace std;

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

const long long INF=1LL<<60;

int n;
int happy[100100][3];
long long dp[100010][3];

int main()
{

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

    for(int i=0;i<n;++i)
    {   
        //dp[i][j]に用いるj
        for(int j=0;j<3;++j)
        {
            //dp[i][j]+a[i][k](or b or c)に用いるk
            for(int k=0;k<3;++k)
            {
                //i+1にk(=0ならa,１ならb,2ならc)を行ったときの幸福度更新
                if(j!=k) chmax(dp[i+1][k],dp[i][j]+happy[i][k]);
            }
        }
    }

    long long res=0;
    for(int i=0;i<3;++i) chmax(res,dp[n][i]);
    cout<<res<<"\n";

}

Measured memory_bytes: 3712
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    S = in_s()
    S = S.replace('eraser', '')
    S = S.replace('erase', '')
    S = S.replace('dreamer', '')
    S = S.replace('dream', '')

    if len(S) == 0:
        ans = 'YES'
    else:
        ans = 'NO'
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9268
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int dfs(int depth,int a,int b, int c,int l[],int A,int B,int C,int N){
    if (depth==N){
    if(a==0 ||b==0 ||c==0)return INF;
    else return abs(a-A)+abs(b-B)+abs(c-C)-30;
    }
    int x,y,z,w,min1,min2;
    x=dfs(depth+1,a,b,c,l,A,B,C,N);
    y=dfs(depth+1,a+l[depth],b,c,l,A,B,C,N)+10;
    z=dfs(depth+1,a,b+l[depth],c,l,A,B,C,N)+10;
    w=dfs(depth+1,a,b,c+l[depth],l,A,B,C,N)+10;
    min1=min(x,y);
    min2=min(z,w);
    return min(min1,min2);

}
int main() {
    int N,A,B,C;
    int l[10];
    cin>>N>>A>>B>>C;
    for(int i=0;i<N;i++){
        cin>>l[i];
    }

    
    cout<<dfs(0,0,0,0,l,A,B,C,N)<<endl;

    return 0;
}



Measured memory_bytes: 256
/*  
*  Sachin Mittal
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';


void solve()
{
  int n;
  cin >> n;
  if(n % 1000 == 0){
    cout << 0;
  } else {
    cout << 1000 - n % 1000;
  }
}

int32_t main(){
ios_base::sync_with_stdio(false); 
cin.tie(0); cout.tie(0);
int tst = 1;
//cin >> tst;
while(tst--)
{
  solve();
}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  
  if(s=="Sunny"){
    cout << "Cloudy" <<endl;
    return 0;
  }else if(s=="Cloudy"){
    cout << "Rainy" <<endl;
    return 0;
  }else{
     cout << "Sunny" <<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main(){
  int x;
  cin>>x;
  for(int i=1;;i++){
    if((i*x)%360==0){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3616
N = int(input())
L = [0] + list(map(int,input().split()))
D = {}
D[0] = [0,0]
for i in range(1,N+1):
    if L[i] not in D:
        D[L[i]] = [i,1]
    else:
        D[L[i]][1] += 1

A = list(D.items())
A.sort(reverse=True)
#print(A)

ans=0
ANS = [0 for i in range(N+1)]

for i in range(1,len(D)):
    ANS[A[i-1][1][0]] += (A[i-1][0] - A[i][0]) * A[i-1][1][1]
    A[i][1][0] = min(A[i-1][1][0],A[i][1][0])
    A[i][1][1] += A[i-1][1][1]

for i in range(1,len(ANS)):
    print(ANS[i])

Measured memory_bytes: 88120
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll k;
  cin >> k;
  string s;
  cin >> s;

  if (s.size() <= k)
    cout << s << endl;
  else
    cout << s.substr(0, k) + "..." << endl;
  
  

  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = min(a, k);
  k = max(k-a, 0);
  if (k)
    k = max(k-b, 0);
  if (k)
    ans -= k;
  cout << ans << endl;
  return 0;
}

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

ll chmax(ll x,ll y){
    if(x > y){
        return x;
    }
    else{
        return y;
    }
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> hp (n,vector<int>(3));
    vector<vector<ll>> dp (n,vector<ll>(3));
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            cin >> hp.at(i).at(j);
        }
    }

    dp.at(0).at(0) = hp.at(0).at(0);
    dp.at(0).at(1) = hp.at(0).at(1);
    dp.at(0).at(2) = hp.at(0).at(2);

    for(int i=0; i<n-1; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(j != k){
                    dp.at(i+1).at(j) = chmax(dp.at(i+1).at(j),dp.at(i).at(k) + hp.at(i+1).at(j));
                }
            }
        }
    }
    ll ans = chmax(chmax(dp.at(n-1).at(0),dp.at(n-1).at(1)),dp.at(n-1).at(2));
    cout << ans << endl;
} 

Measured memory_bytes: 11136
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
pttrn = 0
for gohyaku in 0..a do
  for hyaku in 0..b do
    for goju in 0..c do
      if 0 == x - (gohyaku*500 + hyaku*100 + goju*50) then
        pttrn+= 1
      end
    end
  end
end
puts pttrn

Measured memory_bytes: 1788
n,x,m=map(int,input().split())

f=1
w=[]
d=[0]*(m+2)
t=[0]
chk=n
p=x
for i in range(m+1):
    if i!=0: p=p*p%m
    if d[p]: break
    d[p]=1
    w.append(p)
    t.append(t[-1]+p)
    #f*=2
    chk-=1
    if chk==0:
        print(t[-1])
        exit()
ans=0
a=w.index(p)
ans+=t[a]
n-=a
loo=len(w)-a
if n%loo==0:
    ans+=(t[-1]-t[a])*(n//loo)
else:
    ans+=(t[-1]-t[a])*(n//loo)
    ans+=t[a+n%loo]-t[a]
print(ans)

Measured memory_bytes: 71732
from heapq import heapify, heappop, heappush
n, m = map(int, input().split())
list_A = list(map(int, input().split()))
for i in range(n):
    list_A[i] = (-1)*list_A[i]
heapify(list_A)
for _ in range(m):
    a = heappop(list_A)*(-1)
    a //= 2
    a *= (-1)
    heappush(list_A, a)

print((-1)*sum(list_A))

Measured memory_bytes: 20436
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
  string s,k;
  cin>>s;
  if(s=="Sunny"){k="Cloudy";}
  if(s=="Cloudy"){k="Rainy";}
  if(s=="Rainy"){k="Sunny";}
  cout<<k<<endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	cout << "square1001" << endl;
}


Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    vector<string> S(N); cin >> S;

    int tot = 0;
    v_Pii vp, vm;
    REP(i, N){
        int tmp = 0, mm = 0;
        for(char x: S[i]){
            if(x == '(') tmp++;
            else tmp--;
            Min(mm, tmp);
        }
        tot += tmp;
        if(tmp >= 0) vp.pb(Pii(-mm, tmp));
        else vm.pb(Pii(tmp - mm, -tmp));
    }
    if(tot){
        Out("No");
        return 0;
    }

    Sort(vp);
    Sort(vm);
    int t = 0;
    bool ans = true;
    for(Pii q: vp){
        if(t < q.fi) ans = false;
        t += q.se;
    }
    t = 0;
    for(Pii q: vm){
        if(t < q.fi) ans = false;
        t += q.se;
    }
    Ans(ans, "Yes", "No");

    return 0;
}


Measured memory_bytes: 50312
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  string s;
  cin>>n>>s;
  ll f=0;
  if(n%2==0){
    for(ll i=0;i<n/2;i++){
      if(s[i]!=s[i+n/2])f=1;
    }
  }
  else f=1;
  if(f==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n, Mod = 1000000007, F[1010000], InvF[1010000], res;
int Pow(int a, int b) {
	int r = 1;
	while (b) {
		if (b & 1)r = 1ll * r*a%Mod;
		a = 1ll * a*a%Mod; b >>= 1;
	}
	return r;
}
int Comb(int a, int b) {
	return 1ll * F[a] * InvF[b] % Mod*InvF[a - b] % Mod;
}
int main() {
	int i;
	scanf("%d", &n);
	if (n == 2) {
		puts("1");
		return 0;
	}
	F[0] = 1;
	for (i = 1; i <= n+1; i++) {
		F[i] = 1ll * F[i - 1] * i%Mod;
	}
	InvF[n+1] = Pow(F[n+1], Mod - 2);
	for (i = n+1; i >= 1; i--)InvF[i - 1] = 1ll * InvF[i] * i%Mod;
	int p = 0;
	for (i = (n+1)/2; i < n; i++) {
		int t = 1ll * Comb(i - 1, n - 2 - (i - 1))*F[i] % Mod*F[n - 1 - i]%Mod;
		res = (res +1ll*(t-p+Mod)*i)%Mod;
		p = t;
	}
	printf("%d\n", res);
}

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

int main() {
	int N, A;
	cin >> N >> A;
	
	if(N <= A) cout << "Yes" << endl;
	else {
		N = N % 500;
		if(N <= A) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

int main() {
    bool unko[30] = {};
    string s;
    cin >> s;
    for (char c: s) {
        if (unko[c - 'a']) {
            puts("no");
            return 0;
        } else
            unko[c - 'a'] = true;
    }
    puts("yes");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	#define LOCAL_INPUT_FILE
#else
	//#define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int module = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	int n; cin >> n;
	map<int, int> cnts;
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		++cnts[x];
	}
	if (n % 3 != 0) {
		cout << (cnts[0] == n ? "Yes" : "No") << endl;
		return 0;
	}
	int h = n/3;
	vector<int> dif;
	for (auto &it : cnts) {
		dif.push_back(it.first);
	}
	if (dif.size() > 3) {
		cout << "No" << endl;
		return 0;
	}
	for (int i : dif) {
		for (int j : dif) {
			int k = i ^ j;
			map<int, int> knt2;
			knt2[i] += h;
			knt2[j] += h;
			knt2[k] += h;
			if (cnts == knt2) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <map>
#include <vector>
using namespace std; using P=pair<int,int>; using ll=long long;
struct tp {int x,y,i; bool operator<(const tp tt) const {if (x==tt.x) return y<tt.y; else return x<tt.x;}};

int gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}
const ll m = 1e9+7; vector<ll> sm(200005), inv(200005);
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % m; x = x * x % m; a >>= 1;} return an;}
void sm_bulid() {
	sm[0]=1;for(ll i=1;i<200005;i++) sm[i]=sm[i-1]*i%m;
	inv[200004]=mod_pow(sm[200004],m-2);for(ll i=200003;i>=0;i--) inv[i]=inv[i+1]*(i+1)%m;
}
ll ncr(ll n, ll r) {return sm[n] * inv[n-r] % m * inv[r] % m;}
ll ncr2(ll n, ll r) {return sm[n] * mod_pow(sm[n-r], m-2) % m * mod_pow(sm[r], m-2) % m;}

int main() {
  sm_bulid();
  ll n,k; cin>>n>>k;
  ll b[k+1]; fill(b,b+k+1,0);
  ll an=0;
  for(int i=1;i<=k;i++) {
    ll plus=m+i-b[i];
    ll sm=mod_pow(k/i,n)*plus%m; //cout<<i<<" "<<(i-b[i])<<" "<<sm<<endl;
    an+=sm; an%=m;
    ll idx=i;
    while(idx<=k) {
      b[idx]+=plus; idx+=i;
    }
  }
  cout<<an<<endl;
}

Measured memory_bytes: 7192
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


s = input()[::-1]
index = s.find('W')
s = s[index:]
cnt = 0
b_cnt = 0
for i, b in enumerate(s):
    if b == 'B':
        cnt += i - b_cnt
        b_cnt += 1
print(cnt)



Measured memory_bytes: 70636
fun main(args: Array<String>) {

    val calc = { N: Long, L: Long, U: Long ->
        //        println(N)
//        println("($N - ($N / $L + $N / $U - $N / ($L * $U)))")
        (N - (N / L + N / U - N / lcm(L, U)))
    }

    val (A, B, C, D) = readLine()!!.split(" ").map(String::toLong)


//    println(calc(B, C, D))
//    println(calc(A - 1, C, D))
    println(calc(B, C, D) - calc(A - 1, C, D))
}

fun lcm(a: Long, b: Long): Long{
    return a * b / gcd(a, b)
}

fun gcd(a: Long, b: Long): Long{
    return if (b > 0) gcd(b, a % b) else a
}

Measured memory_bytes: 38092
from heapq import heappop,heappush

def dijkstra(s):
    d = [float("inf") for i in range(n)]
    d[s] = 0
    q = [(0,s)]
    while q:
        dx,x = heappop(q)
        for c,y in v[x]:
            if dx+c < d[y]:
                d[y] = dx+c
                heappush(q,(d[y],y))
    return d

while 1:
    n,m,s,g1,g2 = map(int, input().split())
    if n == m == s == g1 == g2 == 0:
        break
    s -= 1
    g1 -= 1
    g2 -= 1
    v = [[] for i in range(n)]
    for i in range(m):
        a,b,c = map(int, input().split())
        v[a-1].append((c,b-1))
    d = [dijkstra(i) for i in range(n)]
    ans = d[s][g1]+d[s][g2]
    for i in range(n):
        if d[s][i]+d[i][g1]+d[i][g2] < ans:
            ans = d[s][i]+d[i][g1]+d[i][g2]
    print(ans)



Measured memory_bytes: 6644
/*input
5 2
3 1 2 5
2 2 3
1 0
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main() {
	IOS;
	int n,m;
	cin>>n>>m;
	int a[n+1];
	memset(a,0,sizeof(a));
	int p[m+1];
	memset(p,0,sizeof(p));
	for(int i=0;i<m;i++){
		int k;
		cin>>k;
		for(int j=1;j<=k;j++){
			int x;
			cin>>x;
			x--;
			a[x]|=(1<<i);
		}
	}
	int k = 0 ; 
	for(int i=0;i<m;i++){
		cin>>p[i];
	}
	int ans = 0 ;
	for(int i=0;i<(1<<n);i++){
		int cur[m];
		memset(cur,0,sizeof(cur));
		for(int j=0;j<n;j++){	
			if(i&(1<<j)) continue;
			for(int k=0;k<m;k++){
				if((1<<k)&a[j]) cur[k]++;
				cur[k]%=2;
			}
		}
		bool flag = 1 ;
		for(int i=0;i<m;i++){
			if(cur[i]!=p[i])flag = 0 ;
		}
		ans+=flag;
	}
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 256