akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

bool check(const vector<vector<int>>& b) {
	for (int i = 0; i < 3; i++) {
		if (b[i][0] == 0 && b[i][1] == 0 && b[i][2] == 0) return true;
	}
	for (int j = 0; j < 3; j++) {
		if (b[0][j] == 0 && b[1][j] == 0 && b[2][j] == 0) return true;
	}
	if (b[0][0] == 0 && b[1][1] == 0 && b[2][2] == 0) return true;
	if (b[2][0] == 0 && b[1][1] == 0 && b[0][2] == 0) return true;
	return false;
}

int main() {
	ios_base::sync_with_stdio(false);
	vector<vector<int>> b(3, vector<int>(3, 0));
	for (int  i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin>>b[i][j];
		}
	}
	int n;
	cin>>n;
	for (int k = 0; k < n; k++) {
		int t;
		cin>>t;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (b[i][j] == t) {
					b[i][j] = 0;
					if (check(b)) {
						cout<<"Yes"<<endl;
						return 0;
					}
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bitset<5010> can;
int fa[5010],a[5010],f[5010];
vector <int> des[5010];
int main()
{
	int n;scanf("%d",&n);
	for (int i=2;i<=n;i++) {scanf("%d",&fa[i]);des[fa[i]].push_back(i);}
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int s=n;s>=1;s--)
	{
		int all=0,ad=0;
		for (int k=0;k<des[s].size();k++)
		{
			all+=min(a[des[s][k]],f[des[s][k]]);
			ad+=max(a[des[s][k]],f[des[s][k]])-min(a[des[s][k]],f[des[s][k]]);
		}
		if (a[s]<all) {puts("IMPOSSIBLE");return 0;}
		can.reset();can[0]=1;
		for (int k=0;k<des[s].size();k++)
			can|=(can<<(max(a[des[s][k]],f[des[s][k]])-min(a[des[s][k]],f[des[s][k]])));
		for (int i=a[s]-all;i>=0;i--) if (can[i]) {f[s]=ad-i;break;}
		//cout<<s<<' '<<f[s]<<endl;
	}  
	puts("POSSIBLE");
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

void solve(int n){
	vb b(n+1,true);
	cout<<n<<":";
	for(int i=6;i<=n;i++){
		if((i%7==1||i%7==6)&&n%i==0&&b[i]){
			cout<<" "<<i;
			for(int j=i;j<=n;j+=i){
				b[j]=false;
			}
		}
	}
	cout<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n,n!=1)solve(n);
}


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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    map<int,ll> mp;
    rep(i,n){
        cin >> v[i];
        mp[v[i]]++;
    }
    ll ans = 0;
    for(int i = 1;i <= n;i++){
        ans += mp[i]*(mp[i]-1)/2;
    }
    rep(i,n){
        int a = mp[v[i]];
        cout << ans - a*(a-1)/2 + (a-1)*(a-2)/2 << endl;
    }
}

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

int main(){
 
 char servepoint[101];

 int Apoint,Bpoint;

 while(1){

   cin >> servepoint;
 
   if(servepoint[0] == '0') break;

   int i;

   i = 1;
 
   while(1){
       
       if(servepoint[i] =='\0') {

            if(Apoint >= 10 && Bpoint >= 10){

              if(servepoint[i-1]=='A') {Apoint++;}
          
              else Bpoint++;
             }

            else if(Apoint == 10 && Bpoint !=10) Apoint ++;
            else if(Bpoint == 10 && Apoint !=10) Bpoint ++;
  
           break;
       } 

       if(servepoint[i] == 'A') Apoint++;
     
       else if(servepoint[i] == 'B') Bpoint++;

      /* if(Apoint==10 && Bpoint !=10) break;
 
       else if (Apoint!=10 && Bpoint ==10) break;

       if(Apoint>=10&&Bpoint>=10){
     
          if(Apoint - Bpoint == 2 || Bpoint - Apoint == 2) break;
        } */
       
       i++;
    }

   

   cout << Apoint <<" "<< Bpoint <<endl;

   Apoint = 0; Bpoint = 0;

 }

 return 0;

}

Measured memory_bytes: 1140
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  


void solve(void)
{
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  cout<<char(s1[0] - ('a' - 'A'))<<char(s2[0] - ('a' - 'A'))<<char(s3[0] - ('a' - 'A'))<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>

#define sqr(x) ((x)*(x))
#define sqr3(x) ((x)*(x)*(x))
using namespace std;
int main(){
  int n;
  cin>>n;
  double maxx=-1;
  double x[n],y[n],dis[n],ans1=0,ans2=0,ans3=0,ansinf=0;
  for(int i=0;i<n;i++)
    cin>>x[i];
  for(int i=0;i<n;i++){
    cin>>y[i];
    if(x[i]>y[i]){
      dis[i]=(x[i]-y[i]);
    }else{
      dis[i]=(y[i]-x[i]);  
    }
    maxx=max(dis[i],maxx);
    ans1+=dis[i];
    ans2+=sqr(dis[i]);
    ans3+=sqr3(dis[i]);
  }
  printf("%.6lf\n",ans1);
  printf("%.6lf\n",sqrt(ans2));
  printf("%.6lf\n",pow(ans3,1.0/3.0));
  printf("%.6lf\n",maxx);
  return 0;
}

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

int main(){
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int x = max(0, s - 2 * k); x <= min(k , s); ++x){
        for (int y = max(0, s - x - k); y <= min(k, s - x); ++y) ++ans;
    }
    cout << ans << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,k,ans;

signed main() {
    cin >> n >> k;
    for(int i = k+1;i<=n;i++) ans += n/i*(i-k) + min(max((int)0,(n%i)-k+min((int)1,k)),i-1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    ll N,L;
    cin>>N>>L;
    vector<ll> a(N);
    rep(i,N)cin>>a[i];
    ll idx = 0;
    bool f = false;
    rep(i,N-1){
        if(a[i] + a[i+1] >= L){
            idx = i;
            f = true;
            break;
        }
    }
    if(!f){
        cout<<"Impossible"<<endl;
        return 0;
    }
    vector<int> ans;
    for(int i = idx; i < N-1; i++){
        ans.push_back(i);
    }
    for(int i = idx - 1; i >= 0; i--){
        ans.push_back(i);
    }
    reverse(all(ans));
    cout<<"Possible"<<endl;
    rep(i,N-1){
        cout<<ans[i] + 1<<endl;
    }
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll n;
    while (cin >> n) {
        if (n == 0) {
            break;
        } else {
            ll sum = 0;
            rep(i, 9) {
                ll a;
                cin >> a;
                sum += a;
            }
            cout << n-sum << endl;
        }
    }
}


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
# ALDS1_4_C_Dictionary

def main():
    d = set()
    for l in open(0).readlines()[1:]:
        o, k = l.split()
        if o == "insert":
            d.add(k)
            continue
        if k in d:
            print("yes")
        else:
            print("no")

main()


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

const int NMAX = 1e5 + 1;
vector<int> a[NMAX];
int n, m, nr, x, y;
bool vis[NMAX];

void dfs(int nod) {
    vis[nod] = 1;
    for(int i = 0; i < (int)a[nod].size(); i++) {
        int next = a[nod][i];
        if(!vis[next]) {
            dfs(next);
        }
    }
}
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++) {
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for(int i = 1; i <= n; i++) {
        if(!vis[i]) {
            nr++;
            dfs(i);
        }
    }
    cout << nr - 1;
    return 0;
}

Measured memory_bytes: 9648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vector<vector<int> > a(10, vector<int>());

  a[0].push_back(0);
  rep(i, 9){
    for(int x : a[i]){
      a[i+1].push_back(x*10 + 3);
      a[i+1].push_back(x*10 + 5);
      a[i+1].push_back(x*10 + 7);
    }
  }

  vector<int> b;
  REP(i, 3, 9){
    for(int x : a[i]){
      string s = to_string(x);
      int cnt3=0, cnt5=0, cnt7=0;
      for(char c : s){
        if(c == '3') cnt3++;
        if(c == '5') cnt5++;
        if(c == '7') cnt7++;
      }
      if(cnt3+cnt5+cnt7==s.size() && cnt3*cnt5*cnt7!=0){
        b.push_back(x);
      }
    }
  }

  int ans = 0;
  int i=0;
  while(b[i] <= n && i< b.size()){
    ans++;
    i++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
from functools import lru_cache
import sys
sys.setrecursionlimit(1000000)
n = int(input())
list1 = [''.join(sorted(input())) for i in range(n)]
dict1 = dict()
cout = 0
@lru_cache(maxsize = None)
def func(s):
	if s == 2:
		return 1 #2個の場合は1パターン
	return s-1 + func(s-1)

for i in range(n):
	if list1[i] in dict1:
		dict1[list1[i]] += 1
	else:
		dict1[list1[i]] = 1

for i in dict1:
	if dict1[i] != 1:
		cout += func(dict1[i])

print(cout)

Measured memory_bytes: 266304
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
	int N;
	cin>>N;
	ll ans=0;
	for(ll i=1;i<=N-1;i++){
		ll tmp=0;
		for(ll j=0;j<1000;j++)tmp+=i;
		if(tmp==0){
			tmp=100;
		}
		ans+=tmp/1000;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3648
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/08/20 03:55:25
// -----------------------------------

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;

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

  int n,d; cin>>n>>d;
  vector<array<int, 2>> Q(n);
  for (int i = 0; i < n; i++) {
    int x,y; cin>>x>>y;
    Q[i] = {x, y};
  }

  atcoder::two_sat ts(n);
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      for (int k = 0; k < 2; k++) {
        for (int l = 0; l < 2; l++) {
          if (abs(Q[i][k] - Q[j][l]) < d)
            ts.add_clause(i, k^1, j, l^1);
        }
      }
    }
  }
  if (ts.satisfiable()) {
    cout << "Yes" << endl;
    auto ans = ts.answer();
    for (int i = 0; i < n; i++) {
      cout << Q[i][ans[i]] << endl;
    }
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int A,B,V,W,T;
  cin >> A >> V;
  cin >> B >> W;
  cin >> T;

  int dif = abs(A-B);
  int difV = V-W;
  
  if((difV * T) >= dif){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3636
n = int(input())
x = sorted(list(map(int, input().split())))

min_sum = float('inf')
for i in range(x[0], x[len(x) - 1] + 1):
    sum = 0
    for j in range(n):
        sum += (x[j] - i) ** 2
    if sum < min_sum:
        min_sum = sum

print(min_sum)


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

#define ll long long 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()

ll sqr(ll x) {
	return x * x;
}

int main(){

	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
		
	ios::sync_with_stdio(0); cin.tie(0);

	int n; cin >> n;
	int x[n];
	double num, sum = 0;
	int num1, num2;
	for(int i = 0; i < n; i++){
		cin >> x[i];
		sum += x[i];
	}
	sum /= n;
	num1 = (int)(floor(sum));
	num2 = (int)(ceil(sum));

	ll st1 = 0, st2 = 0;
	for(int i = 0; i < n; i++) {
		st1 += sqr(x[i] - num1);
		st2 += sqr(x[i] - num2);
	}

	cout << min(st1, st2);

	return 0; 
}

Measured memory_bytes: 256
public class Main{
	public static void main(String[] args){
		//
		String input = new java.util.Scanner(System.in).nextLine();
		String[] words = input.split("\\s");
		int[] data = new int[words.length];
		for(int i=0; i < words.length; i++){
			data[i] = Integer.parseInt(words[i]);
                //        System.out.println(data[i]);
		}
		// W, H, x, y, r
		int w = data[0];
		int h = data[1];
		int x = data[2];
		int y = data[3];
		int r = data[4];
		if( (w >= x+r) && (x-r >= 0) ){
                    //System.out.println("pass");
			if( (h >= y+r) && (y-r >= 0) ){
				System.out.println("Yes");
			}else{
                            System.out.println("No");
                        }
		}else{
			System.out.println("No");
		}
		//
	}
}

Measured memory_bytes: 26264
import os
import sys

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def mod_invs(max, mod):
    """
    逆元のリスト 0 から max まで
    :param int max:
    :param int mod:
    """
    invs = [1] * (max + 1)
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


N = int(sys.stdin.buffer.readline())
X = list(map(int, sys.stdin.buffer.readline().split()))

invs = mod_invs(max=N + 10, mod=MOD)
invs[0] = 0
# invs_cum[i]: 1/1 + 1/2 + 1/3 + ... + 1/i
invs_cum = np.cumsum(invs).tolist()

D = np.diff(X)
ans = 0
for i in range(len(D)):
    # スライムごとに各道を使う期待値を考えると、
    # 道 i を使う期待値は 1/1 + 1/2 + ... + 1/i だと分かる
    ans += D[i] * invs_cum[i + 1]
    ans %= MOD
# ans *= (N-1)!
for i in range(1, N):
    ans *= i
    ans %= MOD
print(ans)


Measured memory_bytes: 25496
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN
 main() {
int n;
string s;
cin >> n >>s;
int ans =1;
for(int i=1;i<n;i++){
 if(s.at(i-1)!=s.at(i)) ans++;
}
cout << ans <<endl;
 }




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

int main() {
  int n;
  cin>>n;
  int s=0;
  int x=n;
  while(n>=1){
    s+=n%10;
    n/=10;
  }
  if(x%s==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<String>();
  let b = read::<String>();

  println!(
    "{}",
    if a == "H" && b == "D" {
      "D"
    } else if a == "H" && b == "H" {
      "H"
    } else if a == "D" && b == "H" {
      "D"
    } else {
      "H"
    }
  );
}



Measured memory_bytes: 4352
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {

    val s = read()
    var min = 1000
    for(i in 0 until s.length-2) {
        val tmp = Math.abs(s.slice(i until i+3).toInt() - 753)
        min = Math.min(min, tmp)
    }
    println(min)
    
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 33528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
int main()
{
  //  fopen();
    int h,n,p;
    int s=0;
    cin>>h>>n;
    rep(i,n) {cin>>p;s+=p;}
    if(s>=h){cout<<"Yes";}
    else{cout<<"No";}
    
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int XOR(int a, int b);

int main()
{
    
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    int sum=0;
    
    for(int i=0;i<N;i++)
    {
        cin >> a[i];
        sum = XOR(sum, a[i]);
    }
    if(sum != 0)
    {
        cout << "No" << endl;
        return 0;
    }
    // むちゃくちゃ
    else
    {
        cout << "Yes" << endl;
        return 0;
    }
    
    sort(a.begin(), a.end());
    
    b[0] = a[0];
    b[1] = a[1];
    int next;
    int cannot = 0;
    for(int i=2;i<N;i++)
    {
        next = XOR(b[i-2], b[i-1]);
        auto itr = find(a.begin(), a.end(), next);
        if(itr == a.end())
        {
            cannot = 1;
            break;
        }
        else
        {
            b[i] = *itr;
            *itr = -1;
        }
    }
    
    if(cannot) cout << "No" << endl;
    else{
//        for(int i=0;i<N;i++) cout << b[i] << " " << endl;
        cout << "Yes" << endl;
    }
    
    return 0;
}


int XOR(int a, int b)
{
    int ans=0;
    int mod;
    int x=0,y=0;
    for(int i = 0 ; i <= max(log2(a) + 1 , log2(b)) ; i++)
    {
        x=0;
        y=0;
        mod = pow(2, i + 1);
        if(a % mod != 0)
        {
            x = 1;
            a -= mod/2;
        }
        if(b % mod != 0)
        {
            y = 1;
            b -= mod/2;
        }
        ans += (mod / 2) * ( (x | y) - (x & y) );
    }
    return ans;
}


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

char a[5000][5000],b[5000][5000];
int h,w;



int main(){
    cin>>h>>w;
    for(int i=10;i<h+10;i++){
        for(int u=10;u<w+10;u++){
            cin>>a[i][u];
        }
    }
    for(int i=10;i<h+10;i++){
        for(int u=10;u<w+10;u++){
            b[i][u]='0';
        }
    }
    for(int i=10;i<h+10;i++){
        for(int u=10;u<w+10;u++){
            if(a[i][u]=='#'){
                b[i+1][u+1]+=1;
                b[i+1][u]+=1;
                b[i+1][u-1]+=1;
                b[i][u+1]+=1;
                b[i][u-1]+=1;
                b[i-1][u+1]+=1;
                b[i-1][u]+=1;
                b[i-1][u-1]+=1;
            }
        }
    }
    for(int i=10;i<h+10;i++){
        for(int u=10;u<w+10;u++){
            if(a[i][u]=='#'){
                b[i][u]='#';
            }
        }
    }

    for(int i=10;i<h+10;i++){
        for(int u=10;u<w+10;u++){
            cout<<b[i][u];
        }cout<<endl;
    }


}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;
int arr[100001];
int main()
{

   ll k; cin >>k;
   vector<ll> a;
   for(int i = 1 ;i<=9 ; i++)
        a.push_back(i);

  while(1){


    if( k <= a.size())
    {
        cout << a[k-1] << endl;
        return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old,a);
    for(auto x : old){

        for(int i = -1 ; i<=1 ; i++){
            ll d = x%10 + i;
            if(d < 0 || d>9)continue;
            ll nx = 10*x + d;
            a.push_back(nx);
        }

    }
  }

   return 0;
}







Measured memory_bytes: 1712
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <regex>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
ll N;
#define pow5(x) ((x)*(x)*(x)*(x)*(x))


int main()
{
	ll a;
	string bs;
	cin >> a; 
	cin >> bs;
	string b = std::regex_replace(bs, std::regex("\\."), "");
	if ( b.length() < 3 )
	{
		int l = b.length();
		rep(i, 3 - l) b += "0";
	}

	cout << (a * atoi(b.c_str())) / 100 << endl;

	return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

bool InBounds(const vector<string> &mat, int x, int y) {
    return 0 <= x && x < (int)mat.size() && 0 <= y && y < (int)mat[x].size();
}

void Fill(const vector<string> &mat, vector<vector<int>> &dp,
            int x, int y, int cost, queue<pair<int, int>> &qq) {
    queue<pair<int, int>> q;
    q.push({x, y});
    dp[x][y] = cost;

    while (!q.empty()) {
        x = q.front().first;
        y = q.front().second;
        q.pop();

        const vector<pair<int, int>> kMods = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
        for (const auto &mod : kMods) {
            auto nx = x + mod.first;
            auto ny = y + mod.second;

            if (InBounds(mat, nx, ny) && mat[nx][ny] == '.' && dp[nx][ny] > cost) {
                dp[nx][ny] = cost;
                q.push({nx, ny});
                qq.push({nx, ny});
            }
        }
    }
}

int Solve(const vector<string> &mat, int sx, int sy, int dx, int dy) {
    int rows = mat.size();
    int cols = mat[0].size();

    const auto kInf = (1 << 30);
    vector<vector<int>> dp(rows, vector<int>(cols, kInf));
    dp[sx][sy] = 0;

    queue<pair<int, int>> q;
    q.push({sx, sy});

    vector<vector<bool>> in_q(rows, vector<bool>(cols, false));
    in_q[sx][sy] = true;

    while (!q.empty()) {
        auto x = q.front().first;
        auto y = q.front().second;
        q.pop();

        for (int mx = -2; mx <= 2; mx += 1) {
            for (int my = -2; my <= 2; my += 1) {
                auto nx = x + mx;
                auto ny = y + my;
                if (nx < 0 || ny < 0 || rows <= nx || cols <= ny) {
                    continue;
                }
                if (mat[nx][ny] != '.') {
                    continue;
                }

                auto cost = dp[x][y] + (abs(mx) + abs(my) > 1 ? 1 : 0);
                if (cost < dp[nx][ny]) {
                    dp[nx][ny] = cost;
                    Fill(mat, dp, nx, ny, cost, q);
                    if (!in_q[nx][ny]) {
                        q.push({nx, ny});
                    }
                }
            }
        }
    }
    return dp[dx][dy] < kInf ? dp[dx][dy] : -1;
}

int main() {
    int rows, cols;
    cin >> rows >> cols;

    int sx, sy;
    cin >> sx >> sy;

    int dx, dy;
    cin >> dx >> dy;
    cin.get();

    vector<string> mat(rows);
    for (auto &row : mat) {
        getline(cin, row);
    }

    auto res = Solve(mat, sx - 1, sy - 1, dx - 1, dy - 1);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 9720
#include <bits/stdc++.h>
#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

#define FOR(i,n) for(ll i=0;i<n;i++)

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   int D,N;
   cin >> D >> N;
   if(N == 100){
      if(D==0)cout << 101 << endl;
      else if(D==1)cout << 10100 << endl;
      else if(D==2)cout << 1010000 << endl;
   }
   else if(D == 0)cout << N << endl;
   else if(D == 1)cout << N << "00" << endl;
   else if(D == 2)cout << N << "0000" << endl;
   return 0;
}


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

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

    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

const char LOWER = '1', UPPER = '1';
int R, C, Q;
char grid[2005][2005];
int sum[1][3][2005][2005];

int query(char k, int id, int t, int l, int b, int r){
    if(t > b || l > r) return 0;
    return sum[k][id][b][r] - sum[k][id][t-1][r] - sum[k][id][b][l-1] + sum[k][id][t-1][l-1];
}

int main(){

    ios :: sync_with_stdio(false);
    cin >> R >> C >> Q;
    FOR(i,R){
        FOR(j,C){
            cin >> grid[i][j];
        }
    }

    FOR(i,R){
        FOR(j,C){
            for(char ch = LOWER; ch <= UPPER; ch++){
                int k = ch - LOWER;
                sum[k][0][i][j] = sum[k][0][i-1][j] + sum[k][0][i][j-1] - sum[k][0][i-1][j-1] + (grid[i][j]==ch);
                sum[k][1][i][j] = sum[k][1][i-1][j] + sum[k][1][i][j-1] - sum[k][1][i-1][j-1] + (grid[i][j]==ch && j<C && grid[i][j+1]==ch);
                sum[k][2][i][j] = sum[k][2][i-1][j] + sum[k][2][i][j-1] - sum[k][2][i-1][j-1] + (grid[i][j]==ch && i<R && grid[i+1][j]==ch);
            }
        }
    }

    FOR(q,Q){
        int t, l, b, r;
        cin >> t >> l >> b >> r;
        int ans = 0;

        for(char ch = LOWER; ch <= UPPER; ch++){
            int k = ch - LOWER;
            ans += query(k, 0, t, l, b, r);
            ans -= query(k, 1, t, l, b, r-1);
            ans -= query(k, 2, t, l, b-1, r);
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 52864
N = int(input())
A = list(map(int, input().split()))

B = set(A)
Answer = 1
if 0 in B:
    print(0)
    exit()
for i in range(N):
    Answer *= A[i]
    if Answer > 1000000000000000000:
        print(-1)
        exit()
print(Answer)


Measured memory_bytes: 21648
data = sorted(list(range(10**5+1)))
prime_bool = [True]*(10**5+1)
prime_bool[0] = False
prime_bool[1] = False
for i in range(2, len(data)):
  p = data[i]
  if prime_bool[p]:
    k = 2
    while k*p <= 10**5:
      prime_bool[k*p] = False
      k += 1

count_list = [0]*(10**5+1)
for i in range(1, 10**5+1):
  count_list[i] = count_list[i-1]
  if prime_bool[i] and prime_bool[(i+1)//2]:
    count_list[i] += 1

q = int(input())
for i in range(q):
  l,r=map(int, input().split())
  print(count_list[r]-count_list[l-1])
  


Measured memory_bytes: 79648
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    n=int(''.join(input().split()))
    if n%4 == 0:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <utility>

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

using namespace std;
typedef pair<ll, int> mc;

int main(){
    int N;
    cin >> N;
    for(int h = 1; h <= 3500; h ++){
        for(int n = 1; n <= 3500; n ++){
            ll tmp1 = 4 * n * h - N * (n + h);
            ll  tmp2 = 1L * N * n * h;
            if(tmp1 > 0 && tmp2 % tmp1 == 0){
                ll w = tmp2 / tmp1;
                cout << h << " " << n << " " << w;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
if a + b <= 2*c:
    print(a*x + b*y)
elif max(a,b) < 2*c:
    if x > y:
        print(c*y*2 + a*(x-y))
    else:
        print(c*x*2 + b*(y-x))
elif min(a,b) < 2*c:
    if (a < b and x < y) or (a > b and x >y):
        print(c*max(x,y)*2)
    else:
        print(c*min(x,y)*2 + min(a,b)*abs(x-y))
else:
    print(c*max(x,y)*2)

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

using namespace std;

int main()
{
    char a[3][3];
    int i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin >> a[i][j];
        }
    }
    cout << a[0][0] << a[1][1] << a[2][2];
    return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;

const long long mod = 1e9 + 7;

long long power(long long a, long long k) {
	long long res = 1;
	while (k) {
		if (k & 1) res = (long long)res * a % mod;
		a = (long long)a * a % mod;
		k >>= 1;
	}
	return res;
}


int C(int a, int b) {
	int res = 1;
	for (int i = 1, j = a; i <= b; i++, j--) {
		res = (long long)res * j % mod;
		res = (long long)res * power(i, mod - 2) % mod;
	}
	return res;
}


int lucas(long long a, long long b) {
	if (a < mod && b < mod) return C(a, b);
	return (long long)C(a % mod, b % mod) * lucas(a / mod, b / mod) % mod;
}

int main() {
	long long n, a, b;
	cin >> n >> a >> b;

	cout << (power(2, n) + mod * 2 - 1 - lucas(n, a) - lucas(n, b)) % mod << endl;

	return 0;
}

Measured memory_bytes: 384
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = map(int, readline().split())
    a = list(map(int, readline().split()))

    for i in range(k, n):
        if a[i - k] < a[i]:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 105840
#include<bits/stdc++.h>
using namespace std;
int main(){
  	long n,k;
  	string ans = "No";
      
    cin >> n >> k;
  	
  	vector<int>a(n);
  
  	for(int i = 0;i < n;i++)
      cin >> a.at(i);
  	
  	for(int i = 0;i < n - k;i++){
      if(a.at(i) < a.at(i + k))
        ans = "Yes";
      else
        ans = "No";
      
      cout << ans << endl;
    }
  
}

Measured memory_bytes: 3956
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12


int main(void)
{
	//変数の宣言
	int a,b;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	llong int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	//データの読み込み
	scanf("%d %d",&a,&b);
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	
//	printf("計算部分終了\n");
	//出力
	
	if(a*b%2==0){
		printf("Even");
	}else{
		printf("Odd");
	}
	
	
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
N = int(input())
d_dict = {}
D = list(map(int, input().split()))
for d in D:
  if not d in d_dict:
    d_dict[d] = 1
  else:
    d_dict[d] += 1

M = int(input())
T = list(map(int, input().split()))
for t in T:
  if not t in d_dict or d_dict[t] == 0:
    print('NO')
    exit()
  else:
    d_dict[t] -= 1
print('YES')
  

Measured memory_bytes: 135308
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    ll X,N;
    cin>>X>>N;
    v p(N);
    rep(i,0,N)cin>>p[i];
    sort(all(p));
    ll now = 0, now_abs = INF;
    rep(i,-300,300){
        bool ok = true;
        rep(j,0,N){
            if(i == p[j])ok = false;
        }
        if(ok && now_abs > abs(i-X)){
            now_abs = abs(i-X);
            now = i;
        }
    }
    cout<<now;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<pair<int,char>> vec(2*n);
    rep(i,0,n){
        int a;
        cin>>a;
        vec[i]=make_pair(a,'a');
    }
    rep(i,0,n){
        int b;
        cin>>b;
        vec[n+i]=make_pair(b,'b');
    }
    sort(all(vec));
    
    ll cnt_a=0,cnt_b=0;
    ll ans=1;
    rep(i,0,2*n){
        if(vec[i].second=='a'){
            if(cnt_b>0){
                ans*=cnt_b;
                ans%=MOD;
                cnt_b--;
            }
            else cnt_a++;
        }
        if(vec[i].second=='b'){
            if(cnt_a>0){
                ans*=cnt_a;
                ans%=MOD;
                cnt_a--;
            }
            else cnt_b++;
        }
        //cout<<cnt_a<<" "<<cnt_b<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn=100000;
int cnt=0;
int a[100010];
int prime[100010];
void init();
int main()
{
    ios::sync_with_stdio(false);
    int l,r;
    init();
    scanf("%d %d",&l,&r);
        int ans=0;
        for(int i=l;i<=r;i++)
        {
                int sum=0,n=i;
                for(int j=0;prime[j]*prime[j]<=n;j++)
                {
                    while(!(n%prime[j]))
                    {
                        n/=prime[j];
                        sum++;
                    }
                }
                if(n!=1)
                    sum++;
                if(!a[sum])
                    ans++;
        }
        printf("%d\n",ans);
    return 0;
}
void init()
{
    a[1]=1;
    a[0]=1;

    for(ll i=2; i<=100000; i++)
    {
        if(!a[i])
        {
            prime[cnt++]=i;
            for(ll j=i*i; j<=100000; j+=i)
            {
                a[j]=1;
            }
        }
    }
}




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

int main() {
  int n;
  cin >> n;
  vector<int> a(3 * n + 1);
  a.at(0) = 0;
  for (int i = 1; i < 3 * n + 1; i++) {
    int aa;
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int64_t sum = 0;
  int count = 1;
  for (int i = 1; i < 3 * n + 1; i++) {
    if (i > n) {
      count++;
      if (count % 2 == 0) {
        sum += a.at(i);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1408
#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 FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int a,b;
    cin>>a>>b;
    if(a<=9 && b<=9) cout<<a*b<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 256
#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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 10000005
constexpr int inf = 100000000;

struct Node {
	int key;
	Node* prev, * next;
};

Node *nil;

void init() {
	nil = (Node*)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

Node* listsearch(int key) {
	Node* cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}


void printlist() {
	Node* cur = nil->next;
	int isf = 0;
	while (1) {
		if (cur == nil)break;
		if (isf++ > 0)printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deletenode(Node* t) {
	if (t == nil)return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deletefirst() {
	deletenode(nil->next);
}

void deletelast() {
	deletenode(nil->prev);
}

void deletekey(int key) {
	deletenode(listsearch(key));
}

void insert(int key) {
	Node* x = (Node*)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main() {
	int key, n, i;
    int size=0;
	char com[20];
    int np=0,nd=0;
	scanf("%d", &n);
	init();
    for(i=0;i<n;i++){
        scanf("%s %d",com,&key);
        if(com[0]=='i'){
            insert(key);size++;np++;
        }
        else if(com[0]=='d'){
            if(strlen(com)>6){
                if(com[6]=='F'){
                    deletefirst();
                }
                else if(com[6]=='L'){
                    deletelast();
                }
            }
            else{
                    deletekey(key);nd++;
            }
                             size--;
        }
    }
    printlist();
	return 0;
}


Measured memory_bytes: 34400
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
int main() {
	int n;
	rd(n);
	printf("%d\n",(n-2)*180);
	return 0;
}

Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;

int main() {
	IOS
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b/a, c);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(map(int, input().split()))
t = list(set(s))

for i in range(len(t)):
    s.remove(t[i])

if len(s) % 2 == 0:
    x = len(s)
else:
    x = len(s) + 1

print(n - x)

Measured memory_bytes: 14204
using System;
using System.Linq;

class AtCoder {
  public static void Main() {
    var A = int.Parse(Console.ReadLine().Trim());
    var B = int.Parse(Console.ReadLine().Trim());
    var answer = 0;
    for(var i = 1; i < 4; i++) {
      if(i != A && i != B) {
        answer = i;
      }
    }
    Console.WriteLine(answer);
  }
}

Measured memory_bytes: 11220