akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 305


ll N,M,L;
ll min_dist[SIZE][SIZE];
ll min_dist2[SIZE][SIZE];

int main(){

	scanf("%lld %lld %lld",&N,&M,&L);

	int from,to;
	ll dist;

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			if(i == k){

				min_dist[i][k]= 0;
				min_dist2[i][k] = 0;

			}else{

				min_dist[i][k] = HUGE_NUM;
				min_dist2[i][k] = HUGE_NUM;
			}
		}
	}

	for(int i = 0; i < M; i++){

		scanf("%d %d %lld",&from,&to,&dist);
		from--;
		to--;

		min_dist[from][to] = min(min_dist[from][to],dist);
		min_dist[to][from] = min(min_dist[to][from],dist);
	}

	for(int mid = 0; mid < N; mid++){
		for(int start = 0; start < N; start++){
			if(min_dist[start][mid] == HUGE_NUM)continue;
			for(int goal = 0; goal < N; goal++){
				if(min_dist[mid][goal] == HUGE_NUM)continue;

				min_dist[start][goal] = min(min_dist[start][goal],min_dist[start][mid]+min_dist[mid][goal]);
			}
		}
	}

	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){
			if(min_dist[i][k] <= L){
				min_dist2[i][k] = 1;
				min_dist2[k][i] = 1;
			}
		}
	}

	for(int mid = 0; mid < N; mid++){
		for(int start = 0; start < N; start++){
			if(min_dist2[start][mid] == HUGE_NUM)continue;
			for(int goal = 0; goal < N; goal++){
				if(min_dist2[mid][goal] == HUGE_NUM)continue;

				min_dist2[start][goal] = min(min_dist2[start][goal],min_dist2[start][mid]+min_dist2[mid][goal]);
			}
		}
	}


	int num_query;
	scanf("%d",&num_query);

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		if(min_dist2[from][to] == HUGE_NUM){

			printf("-1\n");

		}else{

			printf("%lld\n",min_dist2[from][to]-1);
		}
	}

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

bool rev(string s){
    string t=s;
    reverse(s.begin(),s.end());
    return s==t;
}
int main() {
    //COMinit();
    IOS;
    prec;
    Int a=0,b=0,n,m,x,k,y=0,ans=0;
    string str,s,t,u;
    cin>>a>>b>>k;
    n=max(a-k,(Int)0);
    if(n==0)m=max(b-(k-a),(Int)0);
    else m=b;
    cout<<n<<" "<<m;








    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


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

signed main(void)
{
	int n;
	cin >> n;
	int h[n];

	cin >> h[0];
	rep (i, 1, n)
	{
		cin >> h[i];
		if (h[i - 1] <= h[i] - 1)
			h[i]--;
	}
	rep(i, 1, n)
	{
		if (!(h[i - 1] <= h[i]))
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            if (aaa[0] * aaa[1] < aaa[2])
            {
                Console.WriteLine(aaa[0] * aaa[1]);
            }
            else
            {
                Console.WriteLine(aaa[2]);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
#define X first
#define Y second

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** Problem1347 : Shopping **/
int main()
{
	int N, m;
	cin>>N>>m;
	vector<P> list(m);
	rep(i, m) {
		cin>>list[i].first>>list[i].second;
	}
	
	bool repeat[1000] = {0};
	rep(i, m) {
		for (int j=list[i].first; j<list[i].second; j++) {
			repeat[j] = true;
		}
	}
	
	int ans=N+1;
	rep(i, 1000) {
		if (repeat[i]) ans+=2;
	}
	
	cout << ans << endl;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

struct Aho{
  // failure link is slways 0.
  static const int FAIL = 0;
  static const int SIZE = 26 + 1;
  static int idx(char c){
	return c-'a' + 1;
  }
  
  struct Node{
	vector<Node*> chd;
	vector<int> accept;
	Node(){ chd.assign(SIZE, nullptr); }
	//~Node(){ FOR(i,1,SIZE){ delete chd[i]; chd[i] = nullptr; } }
  };

  Node* root;
  int kind;
  Aho(){ root = nullptr; }
  
  void build(const vector<string>& vs){
	//delete root;
	root = new Node();
	kind = vs.size();
	for(int i=0;i<kind;++i){
	  Node* crt = root;
	  for(char c: vs[i]){
		int ix = idx(c);
		if(!crt->chd[ix])
		  crt->chd[ix] = new Node();
		crt = crt->chd[ix];
	  }
	  crt->accept.push_back(i);
	}

	queue<Node*> q;
	for(int i=1;i<SIZE;++i)
	  if(root->chd[i]){
		root->chd[i]->chd[FAIL] = root;
		q.push(root->chd[i]);
	  }
	  else
		root->chd[i] = root;

	while(!q.empty()){
	  Node* t = q.front();
	  q.pop();
	  for(int i=1;i<SIZE;++i)
		if(t->chd[i]){
		  q.push(t->chd[i]);
		  Node* p = t->chd[FAIL];
		  while(!p->chd[i]) p = p->chd[FAIL];
		  t->chd[i]->chd[FAIL] = p->chd[i];
		  t->chd[i]->accept.insert(t->chd[i]->accept.end(), p->chd[i]->accept.begin(), p->chd[i]->accept.end());
		}
	}
  }

  int match(const string& s){
	int res = 0;
	Node* crt = root;
	for(char c: s){
	  int ix = idx(c);
	  while(!crt->chd[ix]) crt = crt->chd[FAIL];
	  crt = crt->chd[ix];

	  if(!crt->accept.empty()){
		++res;
		crt = root;
	  }
	}
	return res;
  }

  Node* next(Node* crt, char c){
	int ix = idx(c);
	while(!crt->chd[ix]) crt = crt->chd[FAIL];
	crt = crt->chd[ix];
	return crt;
  }
};

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

  string S;
  cin >> S;
  int N;
  cin >> N;

  VS vs(N);
  cin >> vs;

  Aho aho;
  aho.build(vs);

  cout << aho.match(S) << endl;
  
  return 0;
}



Measured memory_bytes: 26876
#include<iostream>
using namespace std;
using uint = unsigned int;

int main() {
	uint N;
	cin >> N;
	
	string S;
	cin >> S;
	
	uint pos = S.find("ABC");
	uint ans = 0;
	
	while (pos != std::string::npos && pos < N) {
		ans++;
        pos = S.find("ABC", pos + 3);
    }
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;


int main(void) {
    int64_t N, X, M;
    cin >> N >> X >> M;

    vector<int64_t> v(M), v2(M);
    while(!v[X] && N) {
        --N;
        v[X] = 1;
        X = X*X % M;
    }

    if(N <= 0) {
        int64_t ans = 0;
        for(int64_t j=0; j<M; j++) {
            ans += j * v[j];
        }
        cout << ans << endl;
        return 0;
    }

    int64_t cnt = 0;
    while(!v2[X] && N) {
        --N;
        ++cnt;
        v2[X] = 1;
        X = X*X % M;
    }

    if(N <= 0) {
        int64_t ans = 0;
        for(int64_t j=0; j<M; j++) {
            ans += j * (v[j] + v2[j]);
        }
        cout << ans << endl;
        return 0;
    }

    int64_t tmp = N/cnt;
    for(auto &e: v2) {
        e *= (tmp + 1);
    }

    N %= cnt;
    while(N) {
        --N;
        v2[X] ++;
        X = X*X % M;
    }

    int64_t ans = 0;
    for(int64_t j=0; j<M; j++) {
        ans += j * v[j];
        ans += j * v2[j];
    }

    cout << ans << endl;
    return 0;
}


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

int main(){
  
  int x[5];
  
  for(int i = 0;i < 5;i++){
    cin>>x[i];
    
    if(x[i] == 0){
      cout<<i+1;
      break;
    
    }
  
  }
  
  
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);
    int i,j;
    for(i = 0;i < n;++i){
        cin >> a.at(i) >> b.at(i);
    }
    for(i = 0;i < m;++i){
        cin >> c.at(i) >> d.at(i);
    }
    int minmode = 0;
    int temp1,temp2;
    vector<int> e(m,0);
    for(i = 0;i < n;++i){
        for(j = 0;j < m;++j){
            temp1 = c.at(j) - a.at(i);
            temp2 = d.at(j) - b.at(i);
            if(temp1 < 0){temp1 *= -1;}
            if(temp2 < 0){temp2 *= -1;}
            e.at(j) = temp1+temp2;
        }
        for(j = 1;j < m;++j){
            if(e.at(minmode) > e.at(j)){
                minmode = j;
            }
        }
        cout << minmode+1 << endl;
        minmode = 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n,k,count=0;
    cin>>n>>k;
    int h;
    rep(i,n)
    {
        cin>>h;
        if(h>=k)count++;
    }
    cout<<count<<endl;
    
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int left = stoi(s.substr(0, 2));
  int right = stoi(s.substr(2, 2));
  if(left >= 1 && left <= 12){
    if (right >= 1 && right <= 12){
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" << endl;
    }
  }else{
    if (right >= 1 && right <= 12){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
  
  // string a = "00";
  // string b = "01";
  // string c = "09";
  // string d = "10";
  // string e = "19";
  // cout << stoi(a) << endl;
  // cout << stoi(b) << endl;
  // cout << stoi(c) << endl;
  // cout << stoi(d) << endl;
  // cout << stoi(e) << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		final int A = scan.nextInt();
		final int B = scan.nextInt();
		final int C = scan.nextInt();
		scan.close();

		int remain1 = A - B;

		if (remain1 > C) {
			System.out.println(0);
		} else {
			System.out.println(C - remain1);
		}

	}

}


Measured memory_bytes: 22868
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   int T = sc.nextInt();
   int B = sc.nextInt();
 

   if(N*T>=B)System.out.println(B);
   else System.out.println(N*T);
 }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007

ll n,m,k;
// ll ans = 0;
// vector<ll> a(N);
// const int M = 2;
// void dfs(vector<int> &A) {
//     // 終端条件 --- 10 重ループまで回したら処理して打ち切り
//     ll sum = std::accumulate(A.begin(), A.end(), 0LL);
//     if (sum > k) {
//       if(sum.size() > ans){
//         ans = sum.size();
//       }
//       return;
//     }

//     for (int v = 0; v < M; ++v) {
//         A.push_back(v);
//         dfs(A);
//         A.pop_back(); // これが結構ポイント
//     }
// }

int main(){
  
  cin>>n;
  // vector<ll> a(n),b(m);
  // ll sum = 0;
  // rep(i, n){
  //   cin >> a[i];
  // }
  // rep(i,m){
  //   cin >> b[i];
  // }

  ll ans = 0;
  rep(i, 10){
    
    if(n-1000<0) break;
    n -= 1000;

  }

  if(n != 0) n = 1000 - n;

  cout << n;
  


  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,P;
string S;
int num[100010];

signed main(){
	cin>>N>>P;
	cin>>S;
	int e=1;
	int sum=0;
	int ans=0;
	if(P==2){
		for(int i=N-1;0<=i;i--){
			int r=S[i]-'0';
			if(r%2==0){
				ans+=i+1;
			}
		}
		cout<<ans<<endl;
		return 0;
	}
	if(P==5){
		for(int i=N-1;0<=i;i--){
			int r=S[i]-'0';
			if(r%5==0){
				ans+=i+1;
			}
		}
		cout<<ans<<endl;
		return 0;
	}
	num[0]++;
	for(int i=N-1;0<=i;i--){
		int r=S[i]-'0';
		r*=e;
		r%=P;
		sum+=r;
		sum%=P;
		num[sum]++;
		e*=10;
		e%=P;
		DEB(sum)END
	}
	REP(i,P){
		ans+=num[i]*(num[i]-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 644
s = int(input())

prev = s // 100
late = s % 100

flag1 = False
flag2 = False

if prev >= 1 and prev <= 12:
    flag1 = True
if late >= 1 and late <= 12:
    flag2 = True

if flag1 and flag2:
    print('AMBIGUOUS')
elif flag1:
    print('MMYY')
elif flag2:
    print('YYMM')
else:
    print('NA')

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

int main(){
  string a;
  cin>>a;
  int b;
  int ans=0;
  b=a.length();
  for(int i=0;i<b/2;i++){
    if(a.at(i)==a.at(b-1-i))continue;
    ans++;
  }
  cout<<ans;    
}

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

int main(){
    double x1, x2, y1, y2;
    cin >> x1 >> x2 >> y1 >> y2;
    printf("%.5f\n", sqrt(pow(y1 - x1, 2) + pow(y2 - x2, 2)));
    return 0;
}


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

int N, A[100000], t;
int64_t sum;

int main() {
    cin >> N;
    rep(i, N) cin >> A[i];

    sort(A, A + N);
    rep(i, N) {
        if (A[i] > sum * 2) {
            t = i;
        }
        sum += A[i];
    }
    cout << N - t << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    int A, B;
    cin >> A >> B;
    if (A > 9 || B > 9)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << A * B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main(){
        string w,t;
        int num = 0;
        cin >> w;
        while(cin >> t){
                if( t == "END_OF_TEXT") break;
                for(int i = 0;i < t.size();i++){
                        t[i] = tolower(t[i]);
                }
                if(w == t){
                        num++;
                }
        }
        cout << num << endl;
        return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<vector>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
	int n, m;
	cin >> n >> m;
	Graph graph(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].emplace_back(b);
		graph[b].emplace_back(a);
	}
	for (int i = 0; i < n; i++) {
		cout << graph[i].size() << endl;
	}
}

Measured memory_bytes: 256
n= int(input())
data = input().split()
data = [int(x) for x in data]
ans = 0
for i in range(1,n):
    if(data[i]<data[i-1]):  
        ans = ans + data[i-1] -data[i]
        data[i] = data[i-1]
print(ans)        

Measured memory_bytes: 32340
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	long long dis=abs(a-b);
	if((v-w)*t>=dis) cout<<"YES";
	else cout<<"NO"; 
	return 0;
} 

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define reps(i,s,n) for(int i=s; i<n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

int cnt[86400];

int main() {
    int n;
    while( scanf("%d", &n), n ) {
        memset( cnt, 0, sizeof(cnt) );
        rep(i,n) {
            int sh, sm, ss, eh, em, es;
            scanf("%d:%d:%d %d:%d:%d", &sh, &sm, &ss, &eh, &em, &es);
            int st = sh*3600+sm*60+ss;
            int et = eh*3600+em*60+es;
            for(int t=st; t<et; t++) {
                cnt[t]++;
            }
        }
        int maxi = 0;
        rep(i, 86400) {
            if( maxi < cnt[i] )
                maxi = cnt[i];
        }
        cout << maxi << endl;
    }
    return 0;
}

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


using namespace std;


int main(){
    vector<vector<int>> a(3,vector<int>(3));
    
    for(int i =0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>a.at(i).at(j);
        }
    }
     
    int x[3];
    int y[3];
    x[0] = 0;
    for(int i=0; i<3; i++) y[i] = a[0][i]-x[0];
    for(int i=0; i<3; i++) x[i] = a[i][0]-y[0];
    bool good = true;
    for(int i = 0; i<3; i++){
        for(int j = 0; j<3; j++){
            if(x[i]+y[j] != a[i][j]){
                good = false;
            }
        }
    }

    if(good == true){
        cout<<"Yes"<<endl;
    }else if(good == false){
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iK = int.Parse(sS[0]);
            sS = System.Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);


            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "NG";
            if (iA % iK == 0) { sOut = "OK"; }
            else if (iB % iK == 0) { sOut = "OK"; }
            else { if (iA / iK != iB / iK) { sOut = "OK"; }; }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 27500
import sys
input = sys.stdin.readline

def solve():
    n=int(input())
    count=0
    for _ in range(n):
        a,b=map(int,input().split())
        if a==b:
            count+=1
            if count==3:
                print('Yes')
                sys.exit()
        else:
            count=0
    else:
        print('No')



if __name__=="__main__":
    solve()



Measured memory_bytes: 9104
//wherever you are,whatever you do, be in love

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	double d,t,s;
	cin>>d>>t>>s;
	if((d/s)<=t) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3712
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;

ll GCD(ll x, ll y) {
  if (x < y) swap(x, y);

  return y == 0 ? x : GCD(y, x % y);
}

ll LCM(ll x, ll y, ll gcd) {
  return x / gcd * y;
}

int main()
{
  int a, b;

  while (scanf("%d%d", &a, &b) != EOF) {
    ll gcd = GCD(a, b);
    printf("%lld %lld\n", gcd, LCM(a, b, gcd));
  }
  
  return 0;
}


Measured memory_bytes: 2596
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<pii, lint> ppl;
typedef complex<double> xy_t;
typedef pair<xy_t, int> pci;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

bool isprime(lint n){
    for(lint i=2; i*i<=n; ++i){
        if(n%i==0) return false;
    }
    return true;
}

int main(){
    lint x;
    scanf("%lld", &x);
    for(lint i=x; i<x+MAX; ++i){
        if(isprime(i)){
            printf("%lld\n", i);
            return 0;
        }
    }
}

Measured memory_bytes: 256
// from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("[line({})] {}: {:?}", line!(), stringify!($x), $x) };}
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};
#[allow(unused_imports)]
use std::mem::swap;

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    #[allow(unused_macros)]
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    #[allow(unused_macros)]
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    
    input! {
        n: usize,
    }
    let mut n = n;
    let mut ans = 0;
    while n != 0 {
        if n >= 9 {
            ans += 9;
            n -= 9;
        } else {
            ans += n;
            n = 0;
        }
        n /= 10;
    }
    printfln!("{}", ans);
}


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

int main() {

  int a;
  cin >> a;
  int ans = 0;
  
  for(int j = 1; j < a+1; j += 2) {
    
    int sum = 0;
    
  	for(int i = 1; i < j+1; i += 2) {
    	if(j%i == 0) sum += 1;
  	}
    if(sum == 8) ans++;
    
  }
  
  cout << ans << endl;
  
}


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 1e6 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int a[N];
int cnt[N];
int pw(int a, int n){
    int res = 1;
    while(n > 0){
        if(n & 1){
            res = res * 1ll * a % mod;
        }
        a = a * 1ll * a % mod;
        n >>= 1;
    }
    return res;
}
int inv(int x){
    return pw(x, mod - 2);
}
int mult(long long a, int b){
    return (a * 1ll * b) % mod;
}
int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        int x = a[i];
        for(int j = 2; j * j <= x; j ++){
            int ans = 0;
            while(x % j == 0){
                ans ++;
                x /= j;
            }
            cnt[j] = max(cnt[j], ans);
        }
        if(x != 1){
            cnt[x] = max(cnt[x], 1);
        }
    }
    int s = 1;
    for(int i = 2; i < N; i ++){
        s = mult(s, pw(i, cnt[i]));
    }
    int res = 0;
    for(int i = 1; i <= n; i ++){
        res = (res + mult(s, inv(a[i]))) % mod;
    }
    cout << res << "\n";
}



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

int main() {
  using pii = pair<int, int>;
  using tsii = tuple<string, pii>;
  int n;
  cin >> n;
  
  vector<tsii> r(n);
  rep(i, n) {
    cin >> get<0>(r.at(i)) >> get<1>(r.at(i)).first;
    get<1>(r.at(i)).second = i+1;
  }
  
  sort(r.begin(), r.end());
  vector<vector<pii>> re;
  string name, pre="";
  pii p;
  vector<pii> vp;
  int pos=-1;
  rep(i, n) {
    tie(name, p) = r.at(i);
    if (pre != name) {
      pre = name;
      vp.push_back(p);
      re.push_back(vp);
      vp.pop_back();
      pos++;
    } else {
      re.at(pos).push_back(p);
    }
  }
  
  rep(i, re.size()) {
    sort(re.at(i).begin(), re.at(i).end());
    reverse(re.at(i).begin(), re.at(i).end());
  }
  
  rep(i, re.size()) {
    rep(j, re.at(i).size())
      cout << re.at(i).at(j).second << 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++)
typedef int64_t Int;

const int INF = 100000;

int main(){ 
    Int H, W, K;
    cin >> H >> W >> K;
    vector<vector<bool>> wh(H, vector<bool>(W,false));
    rep(i,H) {
        string S;
        cin >> S;
        rep(j,W) {
            if (S[j] == '1') wh[i][j] = true;
        }
    }

    vector<int> cuts(1<<(H-1),INF);

    for (int bit = 0; bit < (1<<(H-1)); ++bit) {
        int n = __builtin_popcount(bit) + 1;
        vector<vector<int>> v(n);
        int cnt = 0;
        rep(i,H) {
            v[cnt].push_back(i);
            if (bit & (1<<i)) cnt++;
        }

        int m = 0;
        vector<int> cut;
        bool flag = false;
        cut.push_back(-1);


        vector<vector<int>> whs(n, vector<int>(W,0));
        rep(j,W) {
            rep(i,n) {
                rep(k,v[i].size()) {
                    if(wh[v[i][k]][j]) whs[i][j]++;
                }
            }
        }

        vector<int> temp(n,0);

        rep(j,W) {
            rep(i,n) temp[i] += whs[i][j];
            int L = 0;
            rep(i,n) L = max(L, temp[i]);
            if (L > K) {
                if (j == cut[cut.size()-1] + 1) {
                    flag = true;
                    break;
                }
                else {
                    cut.push_back(j-1);
                    rep(i,n) temp[i] = whs[i][j];
                }

            }
        }

        if (!flag) {
            cuts[bit] = n + cut.size() - 2;
        }




    }

    int ans = INF;
    for (int bit = 0; bit < (1<<(H-1)); ++bit) ans = min(ans,cuts[bit]);

    cout << ans << endl;
}




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
double arr[50];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%lf", &arr[i]);
    double res;
    sort(arr, arr+N);
    res = arr[0];
    for (int i = 1; i < N; i++) {
        res = (res + arr[i]) / 2;
    }
    printf("%.6lf\n", res);
    return 0;
}


Measured memory_bytes: 1732
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	// ABC074C
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	double ma = 0;
	int answ, anss;
	for (int i = 0; 100 * a*i <= f; i++) {
		for (int j = 0; 100 * b*j <= f; j++) {
			for (int k = 0; c*k <= f; k++) {
				for (int l = 0; d*l <= f; l++) {
					int w = 100 * a*i + 100 * b*j;
					int s = c*k + d*l;
					if (w + s <= f && 100 * s <= w*e) {
						double can = (double)100 * s / (w + s);
						if (ma <= can) {
							answ = w + s;
							anss = s;
							ma = can;
						}

					}
				}
			}
		}
	}
	cout << answ<<" "<<anss << endl;
	return 0;
}





Measured memory_bytes: 384
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n;
    scan(n);

    int ans;

    foreach (i ; 0 .. n) {
        int li, ri;
        scan(li, ri);
        ans += ri - li + 1;
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

 const int AMAX = 100000;
 long long cnt[AMAX + 1];
 
int main(){
    int N;
    long long K;
    cin >> N >> K;
    for(int i=0; i< N; ++i) {
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }
    
    for(int i=1; i<= AMAX; ++i) {
        if(K <= cnt[i]){
            cout << i << endl;
            return 0;
        }
        K -= cnt[i];
    }

    return 0;
}

Measured memory_bytes: 1024
/*** Author: Dhruv Rastogi ***/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<ll,ll>
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mint map<int,int> 
#define int long long
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>

int vis[(int)1e6+2];
void solve(){  
	int n;
	cin>>n;
	rep(i,1,1000){
		vis[i*(i+1)/2]=i;
	}
	if(!vis[n]){
		cout<<"No"<<endl;
		return;
	}
	cout<<"Yes"<<endl;
	vll v[2000];
	int num=1;
	rep(i,1,vis[n]+2){
		rep(j,i+1,vis[n]+2){
			v[i].pb(num);
			v[j].pb(num);
			++num;
		}
	}
	cout<<vis[n]+1<<endl;
	rep(i,1,vis[n]+2){
		cout<<sz(v[i])<<' ';
		for(auto j:v[i]) cout<<j<<' ';
		cout<<endl;
	}
}

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

Measured memory_bytes: 7168
///
// File:  d.cpp
// Author: ymiyamoto
//
// Created on Tue Oct  3 19:31:52 2017
//

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;
static vector<pair<int64_t, int64_t>> rects;
static uint64_t counts[10];

int32_t main()
{
  int64_t H, W, N;
  cin >> H >> W >> N;
  for (int64_t i = 0; i < N; i++) {
    int64_t a, b;
    cin >> a >> b;
    for (int64_t i = 0; i < 3; i++) {
      for (int64_t j = 0; j < 3; j++) {
        int64_t x = a - i;
        int64_t y = b - j;
        if (1 <= x && x <= H - 2) {
          if (1 <= y && y <= W - 2) {
            rects.push_back({x, y});
          }
        }
      }
    }
  }

  int64_t has_black = 0;

  if (N > 0) {
    sort(rects.begin(), rects.end());

    pair<int64_t, int64_t> rect = rects[0];
    uint64_t count = 0;
    for (uint64_t i = 0; i < rects.size(); i++) {
      if (rect == rects[i]) {
        count++;
      } else {
        counts[count]++;
        has_black++;
        rect = rects[i];
        count = 1;
      }
    }

    counts[count]++;
    has_black++;
  }

  for (uint32_t i = 0; i < 10; i++) {
    if (i == 0) {
      cout << (H - 2) * (W - 2) - has_black << endl;
    } else {
      cout << counts[i] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 18664
#include<stdio.h>
 #include<string.h>
 int main(void)
 {
     char S[100];
     int N,j,c=0,i=0,k,l,d=0,e=0;
     scanf("%s",S);
     N=strlen(S);
     for(j=0;j<=N-1;j++)
       if(S[j]==S[N-1-j]) c++;
     if(c==N){
       k=(N-1)/2-1;
       for(j=0;j<=k;j++)
         if(S[j]==S[k-j]) d++;
     }
     if(d==(k+1)){
       l=(N+3)/2-1;
       for(j=l;j<=N-1;j++)
         if(S[j]==S[N-1-i]) { i++; e++; }
     }
   
     if(e==(N-l)) printf("Yes\n");
     else     printf("No\n");
     return 0;
 }
   

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
vector<int>vec;
int main()
{
    int a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    for(int i=min(a,b);i>=1;i--)
    {
        if(a%i==0 && b%i==0)--k;
        if(k==0)
        {
            printf("%d\n",i);
            break;
        }
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define error(x) cout << #x << " = " << x << endl


int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,m,i,j,k,sum=0;
    cin>>n>>m;
    if(n>9||m>9){
        cout<<-1;
    }
    else{
        cout<<n*m;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=2e5+5;
struct node{
	int x,op;
	inline bool operator <(const node &b)const{return x<b.x;}
}a[N];int n,res,ca,cb;
int main(){
	scanf("%d",&n),res=1;
	fp(i,1,n)scanf("%d",&a[i].x),a[i].op=0;
	fp(i,1,n)scanf("%d",&a[i+n].x),a[i+n].op=1;
	sort(a+1,a+1+(n<<1));
	fp(i,1,n<<1)if(a[i].op==0){
		if(!cb)++ca;
		else res=mul(res,cb--);
	}else{
		if(!ca)++cb;
		else res=mul(res,ca--);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int n;
char s[500][500];
int diff[1500];

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> s[i][j];
		}
		/*
		for (int j = 0; j < n; j++) {
			alps[s[j] - 'a'].insert(P(i, j));
			alp[s[j] - 'a'].push_back(P(i, j));
		}
		*/
	}
	/*
	int odd = 0;
	for (int i = 0; i < 26; i++) {
		if ((int)alp[i].size() % 2 != 0)odd++;
	}
	if (odd > n) {
		cout << "0" << endl;
		return 0;
	}
	*/
	int ans = 0;
	for (int a = 0; a < n; a++) {
		for (int b = 0; b < n; b++) {
			int diffrence = a - b;
			diff[diffrence + 500]++;
		}
	}
	

	for(int dif = -n+1;dif<n;dif++) {
			//cout << "a/b" << " " << a << " " << b << endl;
			//vector<P> hanpa;
			//set <P> hanpas;
			int ope = 0;

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					int cx = j + dif;
					int cy = i - dif;
					if (cx < 0)cx += n;
					if (cy < 0)cy += n;
					if (cx >= n)cx -= n;
					if (cy >= n)cy -= n;
					if (s[i][j] != s[cx][cy]) {
						ope++; break;
					}
				}
			}
			/*
			for (int k = 0; k < 26; k++) {
				for (int l = 0; l < alp[k].size();l++) {
					int x = alp[k][l].first;
					int y = alp[k][l].second;

					//cout << x << " " << y << endl;
					
					int cx = y + dif, cy = x - dif;
					if (cx < 0)cx += n;
					if (cy < 0)cy += n;
					if (cx >= n)cx -= n;
					if (cy >= n)cy -= n;

					//cout << "cx/cy:";
					//cout<< cx << " " << cy << endl;
					if (alps[k].find(P(cx,cy)) == alps[k].end()) {
						ope++;
						//hanpa.push_back(P(x, y));
						//hanpas.insert(P(x, y));

					}
				}
			}

			/*
			if ((int)hanpa.size() <= n) {

				int num = 0;
				for (int i = 0; i < hanpa.size(); i++) {
					int x = hanpa[i].first;
					int y = hanpa[i].second;

					cout << "hanpa" << i << ":";
					cout << x << " " << y << endl;


					int cx = y + dif, cy = x - dif;
					if (cx < 0)cx += n;
					if (cy < 0)cy += n;
					if (cx >= n)cx -= n;
					if (cy >= n)cy -= n;
					
					cout << "hanpa:cx/cy" << i << ":";
					cout << cx << " " << cy << endl;

					
					if (hanpas.find(P(cx, cy)) == hanpas.end()) {
						num++;
						break;
					}
				}
				if (num == 0) {
					ans += diff[dif + 500];
					cout << dif << endl;
					cout << dif + 500 << endl;
					cout << "a" << endl;
				}
			}
			*/
			//cout <<"ans:"<< ans << endl;
			if (ope == 0) ans += diff[dif + 500];
		
	}
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX_V 100001
#define INF 1e18
struct edge{int to,cost;};
typedef pair<int ,int> P;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P> > que;
  fill(d,d+MAX_V,INF);
  d[s]=0;
  que.push(P(0,s));
  while(!que.empty()){
    P p=que.top();
    que.pop();
    int v=p.second;
    if(d[v]<p.first)continue;
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
	d[e.to]=d[v]+e.cost;
	que.push(P(d[e.to],e.to));
      }
    }
  }
}

signed main(){
  cin>>V;
  int m,s,t,a,b,c,D;
  cin>>m>>s>>t;
  for(int i=0;i<m;i++){
    cin>>a>>b>>c>>D;
    G[a].push_back((edge){b,D});
    G[b].push_back((edge){a,D});
    G[c].push_back((edge){b,D});
    G[b].push_back((edge){c,D});
    G[a].push_back((edge){c,D});
    G[c].push_back((edge){a,D});
  }
  dijkstra(s);
  cout<<d[t]<<endl;
  return 0;
}



Measured memory_bytes: 23860
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> P(N);

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

    int minimum = P[0];
    int answer=0;
    for(int i=0; i<N; i++){
        if(minimum>=P[i])
            answer++;
        minimum=std::min(minimum,P[i]);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1152
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())
T = [[0] * (W + 1) for _ in range(H + 1)]
U = [[0] * (W + 1) for _ in range(H + 1)]


for y in range(H):
    for x in range(W):
        if S[y][x] == '.':
            if x == 0 or S[y][x - 1] == '#':
                start = x
            if x == W - 1 or S[y][x + 1] == '#':
                end = x
                long = end - start + 1
                T[y][start] += long
                T[y][end + 1] -= long
#print(T)
for y in range(H):
    for x in range(W):
        T[y][x + 1] += T[y][x]
#print(T)

for x in range(W):
    for y in range(H):
        if S[y][x] == '.':
            if y == 0 or S[y - 1][x] == '#':
                start = y
            if y == H - 1 or S[y + 1][x] == '#':
                end = y
                long = end - start + 1
                U[start][x] += long
                U[end + 1][x] -= long
#print(U)
for x in range(W):
    for y in range(H):
        U[y + 1][x] += U[y][x]
#print(U)

M = 0
for x in range(W):
    for y in range(H):
        M = max(M, T[y][x] + U[y][x] - 1)
print(M)

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

vector<ll> h;

const ll INF = 1000000000000000000 + 7;

ll cost(ll i, ll j) { return abs(h.at(i) - h.at(j)); }

int main() {
  ll n, k;
  cin >> n >> k;
  h.resize(n);

  for (auto &x : h) {
    cin >> x;
  }

  vector<ll> dp(n, INF);
  dp.at(0) = 0;

  for (long long i = 0; i < n; i++) {
    for (long long j = 1; j <= k && i + j < n; j++) {
      dp.at(i + j) = min(dp.at(i + j), dp.at(i) + cost(i, i + j));
    }
  }

  cout << dp.at(n - 1) << endl;
}


Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int h,w,k;
    cin >> h >> w >> k;
    char m[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cin >> m[i][j];
    }
    int ans=0;
    for(int mi=0;mi<(1<<h);mi++){
        for(int mj=0;mj<(1<<w);mj++){
            int cnt=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(mi&(1<<i) and (mj&(1<<j)) and m[i][j]=='#')
                        cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }
    cout << ans;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}



int main(){
  rep(i,5){
    ll x;
    cin >> x;
    if(x!=(i+1)){
      cout << (i+1) << endl;
    }
  }

  return 0;
} 



Measured memory_bytes: 3636
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	if N % 2 == 0:
		print(N // 2)
	else:
		print(N // 2 + 1)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3444
n = int(input())
x = []
y = []

for i in range(n):
    a, b = list(map(int, input().split()))
    x.append(a)
    y.append(b)

total = 0
for i in range(n-1):
    for j in range(i+1, n):
        total += ((x[i]-x[j])**2 + (y[i]-y[j])**2) ** 0.5
        
print(total*2/n)

Measured memory_bytes: 3064
import java.util.Scanner;

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

		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

		int a = x;
		int b = y;
		int c = z;

		int mix;

		mix = a;
		a = b;
		b = mix;

		mix = a;
		a = c;
		c = mix;

		System.out.println(a + " " + b + " " + c);

		sc.close();
	}
}


Measured memory_bytes: 26968