akhauriyash/Code-Regression huggingface dataset:
import queue

H, W = map(int, input().split())
S = [input() for i in range(H)]
q = queue.Queue()
longest_path = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            g = [[0 if S[k][l] == '.' else -1 for l in range(W)] for k in range(H)]
            q.put((i,j))
            g[i][j] = 0
            while not(q.empty()):
                x, y = q.get()
                for nx, ny in [(x+1, y),(x-1, y),(x, y+1),(x, y-1)]:
                    if nx < 0 or nx > H-1 or ny < 0 or ny > W-1: continue
                    if g[nx][ny] != 0: continue
                    if nx == i and ny == j: continue
                    g[nx][ny] = g[x][y] + 1
                    q.put((nx,ny))
            '''
            print('===========')
            for line in g:
                print(line)
            '''     
            longest_path = max(longest_path, max(map(max, g)))
print(longest_path)


Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include<stack>
#include<string>
#include<algorithm> 
#include <set>
#include<list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <iomanip>
#include <queue>
#include <initializer_list>
typedef long long int ll;
using namespace std;
int main() {
	int N, M; cin >> N >> M;
	if (N == M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3052
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <vector>
#define inf 0x3f3f3f3f
#define maxn 100000
#define maxe 200010
using namespace std;
typedef long long ll;
vector<int> v;
int cnt=0;
int fac[maxn];
int num[maxn];
void cal(int m)
{
    for(int i=2;i*i<=m;i++)
    {
        if(m%i==0)
        {
            fac[cnt]=i;
            while(m%i==0)
            {
                num[cnt]++;
                m/=i;
            }
            cnt++;
        }
    }
    if(m!=1)
    {
        fac[cnt]=m;
        num[cnt++]=1;
    }
}

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)==2)
    {
        if(m%n==0)
        {
            printf("%d\n",m/n);
            continue;
        }
        cal(m);

        v.push_back(1);
        for(int i=0;i<cnt;i++)
        {
            int t=1;
            int siz=v.size();
            for(int j=0;j<num[i];j++)
            {
                t*=fac[i];
                for(int k=0;k<siz;k++)
                {
                    v.push_back(t*v[k]);
                }
            }

        }
        int ans=0;
        int siz=v.size();
        for(int i=0;i<siz;i++)
        {
            //cout<<v[i]<<endl;
            if(v[i]>=n)
            {
                ans=max(ans,m/v[i]);
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

int ch(string s){
	int a = 0;
	if(!s.empty()){
		for(int i = 0; i < s.size(); i++){
			a *= 10;
			a += (s[i] - 48);
		}
	}
	
	return a;
}

int main(){
	string str1, str2;
	int res, n;
	
	cin >> res;
	while(true){
		cin >> str1;
		if(str1[0] == '=') break;
		
		cin >> str2;
		n = ch(str2);
		if(str1[0] == '+'){
			res += n;
		}
		else if(str1[0] == '-'){
			res -= n;
		}
		else if(str1[0] == '*'){
			res *= n;
		}
		else if(str1[0] == '/'){
			res /= n;
		}
	}
	
	cout << res << endl;
	
	return 0;
}

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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin >> n >> m;
	vii graph(n+1,vector<int>());
	for(int i = 0; i < m; i++) {
		int u,v;
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	bool gotoddcirc = false;
	vector<bool> was (n+1,false);
	queue<int> st;
	st.push(1);
	was[1] = true;
	vi lvl(n+1,0);
	vector<ll> lvlcnts(n+10,0);
	vi par(n+1,-1);
	lvlcnts[0] = 1;
	while(!st.empty()) {
		int v = st.front();
		st.pop();
		for(int u : graph[v]) {
			if(!was[u]) {
				was[u] = true;
				lvl[u] = lvl[v]+1;
				lvlcnts[lvl[u]]++;
				par[u] = v;
				st.push(u);
			} else {
				if(u != par[v] && abs(lvl[u]-lvl[v])%2 == 0) {
					gotoddcirc = true;
				}
			}
		}
	}
	if(gotoddcirc) {
		ll ans = n;
		ans*= (n-1);
		ans/= 2;
		ans-= m;
		cout << ans;
	} else  {
		ll add = 0;
		ll sum1 = 0;
		ll sum2 = 0;
		for(int i = 0; i <= n; i++) {
			if(i%2 == 0) {
				sum1+= lvlcnts[i];
			} else {
				sum2+= lvlcnts[i];
			}
		}
		for(int i = 0; i <= n; i++) {
			if(i%2 == 0) {
				add+= lvlcnts[i]*(sum2);
				sum1-= lvlcnts[i];
			} else {
				add+= lvlcnts[i]*(sum1);
				sum2-= lvlcnts[i];
			}
		}
		cout << add-m;
	}
	return 0;
}



Measured memory_bytes: 7424
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt

getInt = readInt <$> BS.getLine

-- https://qiita.com/little_Haskeller/items/614a3ae20a517c19bb1f
primes :: Integral a => [a]
primes = map fromIntegral $ [2, 3] ++ primes'
  where
    primes' = [5] ++ f 1 7 primes'
    f m s (p : ps) = [n | n <- ns, gcd m n == 1] ++ f (m * p) (p * p) ps
      where
        ns = [x + y | x <- [s, s + 6 .. p * p - 2], y <- [0, 4]]

divn :: Int -> Int -> Int
divn x a
  | divided > 0 && x `mod` a == 0 = 1 + divn divided a
  | otherwise = 0
  where
    divided = x `div` a

fac :: Int -> [Int] -> Int -> [(Int, Int)]
fac 1 _ _ = []
fac x (p : ps) n
  | p > n = [(x, 1)]
  | otherwise = tup ++ fac x' ps n
  where
    count = divn x p
    (tup, x') =
      if count == 0
        then ([], x)
        else ([(p, count)], x `div` p ^ count)

calc :: [Int] -> Int
calc [] = 0
calc (t : ts) = length (takeWhile (<= t) [i * (i + 1) `div` 2 | i <- [1 ..]]) + calc ts

main = do
  n <- getInt
  if n == 1
    then print 0
    else do
      let s = floor (sqrt (fromIntegral n))
      print $ calc (map snd (fac n primes s))


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;
//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
} comb(200005);


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, K;
    cin >> N >> M >> K;
    mint p = M;
    mint ans = 0;
    for (int i=N-1;i>=0;i--){
        mint x = 1;
        x*=p;
        x*=comb(N-1,i);
        if (i <= K) ans += x;
        p*=M-1;
    }

    cout << ans << "\n";
}

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

int main()
{
  	int n=0;
  	cin>>n;
	vector<int> items(n);
  	for(int i=0 ; i<n ; ++i)
    cin>>items[i];
  	sort(items.begin(),items.end());
  	int ans=0;
  	for(int i=0 ; i<n-1 ; ++i)
    ans+=items[i];
  	cout<<ans+items[n-1]/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

    lol a, b, c;
  	cin >> a >> b >> c;
  	cout << min(min(a*b*(c%2), b*c*(a%2)), c*a*(b%2)) << '\n';
    return 0;
}


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

int main(){

    int q; cin >> q;
    for(int nn = 0; nn < q; nn++){
        int n; cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        int now = a[0];
        int up = 0, down = 0;

        for(int i = 1; i < n; i++){
            int d = a[i] - now;
            if(d >= 0){
                up = max(up, d);
            }else{
                down = min(down, d);
            }

            now = a[i];
        }
        cout << up << " " << -down << endl;
    }

    return 0;
}


Measured memory_bytes: 2976
#include <stdio.h>

int main(void)
{
	
	int H;
	int W;
	int a;
	int b;
	
	for(;;){
		scanf("%d %d", &H, &W);
		if(H==0&&W==0){
			break;
		}
	
	for(a = 1; a <= H; a++){
		for (b = 1; b <= W; b++){
			printf("#");
		}
		printf("\n");
		}
		printf("\n");
	}
	return (0);
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace::std;

int main() {
	string S;
	cin >> S;

	char last = S[0];
	int ans = 0;
	for (int i = 1; i < S.length(); i++) {
		if (S[i] == last) {
			S[i] = last == '0' ? '1' : '0';
			ans++;
		}
		last = S[i];
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int comp(const void *a, const void *b){return *(int*)a - *(int*)b;}

int main(void){
	int n, m;
	int *x;
	int sum = 0;
	scanf("%d %d", &n, &m);
	x = malloc(sizeof(int) * m);
	for(int i = 0; i < m; i++)
		scanf("%d", x + i);
	if(n >= m){
		printf("0\n");
		return 0;
	}
	qsort(x, m, sizeof(int), comp);
	int max = x[m - 1] - x[0];
	for(int i = 0; i < m - 1; i++)
		x[i] = x[i + 1] - x[i];
	qsort(x, m - 1, sizeof(int), comp);
	for(int i = m - n; i < m - 1; i++)
		sum += x[i];
	/*
	for(int i = m - 2; i >= 0; i--)
		printf("%d\n", diff[i]);
		*/
	printf("%d\n", max - sum);
	return 0;
}


Measured memory_bytes: 1012
#include <iostream>

using namespace std;

 int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
       cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
       cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
       cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
       cout << b << " " << c << " " << a << endl;
     else if(c <= a && a <= b)
       cout << c << " " << a << " " << b << endl;
     else if(c <= b && b <= a)
       cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int debug = 0;

class ANumber{
private:
	int have[10];
	int place[10];
	int hit;
	int blow;
public:
	ANumber(){
		int i;
		for(i=0;i<=9;i++){
			have[i] = 0;
			place[i] = 0;
		}
		hit = 0;
		blow = 0;
	}

	void clearNum(){
		int i;
		for(i=0;i<=9;i++){
			have[i] = 0;
			place[i] = 0;
		}
		hit = 0;
		blow = 0;
		if(debug) cout << "all reset! " << hit << " " << blow << endl;
	}

	void addNum(int num, int placeNum){
		have[num] = 1;
		place[num] = placeNum;
		if(debug) cout << num << "is placed #" << placeNum << endl;
	}

	void chkNum(int b1, int b2, int b3, int b4){
		if(debug) cout <<"chk"<< b1 << b2 << b3 << b4 << endl;
		if(have[b1] == 1){
			if(place[b1] == 1){
				if(debug) cout << "b1 hit" <<endl; 
				hit++;
			}else{
				if(debug) cout << "b1 blow" <<endl;
				blow++;
			}
		}
		if(have[b2] == 1){
			if(place[b2] == 2){
				if(debug) cout << "b2 hit" <<endl;
				hit++;
			}else{
				if(debug) cout << "b2 blow" <<endl;
				blow++;
			}
		}
		if(have[b3] == 1){
			if(place[b3] == 3){
				if(debug) cout << "b3 hit" <<endl;
				hit++;
			}else{
				if(debug) cout << "b3 blow" <<endl;
				blow++;
			}
		}
		if(have[b4] == 1){
			if(place[b4] == 4){
				if(debug) cout << "b4 hit" <<endl;
				hit++;
			}else{
				if(debug) cout << "b4 blow" <<endl;
				blow++;
			}
		}

		cout << hit << " " << blow << endl;
	}
};

int main(void){
	ANumber A;
	int a1, a2, a3, a4;
	int b1, b2, b3, b4;

	while(cin >> a1 >> a2 >> a3 >> a4){
		A.addNum(a1, 1);
		A.addNum(a2, 2);
		A.addNum(a3, 3);
		A.addNum(a4, 4);
		cin >> b1 >> b2 >> b3 >> b4;
		A.chkNum(b1, b2, b3, b4);
		A.clearNum();
	}

	return 0;
}

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

int main(void){
  int a,b;
  cin >> a >> b;
  int number = a+b;
  if(number%3 == 0){
    cout << "Possible" << '\n';
  }
  else if(a%3 == 0){
    cout << "Possible" << '\n';
  }
  else if(b%3 == 0){
    cout << "Possible" << '\n';
  }
  else{
    cout << "Impossible" << '\n';
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	char c;
  cin>>c;
  switch(c){
    case 'a':
    case 'i':
    case 'u':
    case 'e':
    case 'o':
      cout<<"vowel"<<endl;
      break;
    default:
      cout<<"consonant"<<endl;
  }
	return 0;
}


Measured memory_bytes: 256
N,*A=`dd`.split.map &:to_i
h=Hash.new(0)
A.map{|a|h[a]+=1}
f=h.select{|k,v|v>1}.keys.sort
if f.size>0 && h[g=f[-1]]>3
  p g*g
elsif f.size>1
  p g*f[-2]
else
  p 0
end

Measured memory_bytes: 16640
#include "bits/stdc++.h"
#include <string>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
// #define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
// const int inf = (int)1e18 + 10;
const int mod = 1e9 + 7;

const int inf = 1e15;
int a[200] = {0};
int arr[200] {0};
vec v;
void pre(){
    for(int i = 2 ; i <= 100 ; i++){
      if(a[i] == 0){
         v.pb(i);
         a[i] = i;
         for(int j = i*i ; j<= 100; j+=i)
             if(a[j] == 0) a[j] = i;
      }
    }
}
signed main(){
  fast;
 
  int n , f = 0 , t = 0 , tf = 0 , ft = 0 , sf = 0;
  cin >> n;
  pre();
  
      for(int j = 2 ; j<=n ; j++){
           int x = j , cnt = 0;
          while(x > 1){
            arr[a[x]]++;
            x  /= a[x];

          }

      }
      

      for(int i = 0 ; i <  v.size() ; i++){
          if(arr[v[i]] >= 74) sf++;
          if(arr[v[i]] >= 24) tf++;
          if(arr[v[i]] >= 14) ft++;
          if(arr[v[i]] >= 4) f++;
          if(arr[v[i]] >= 2) t++;
      }
  
  
  
  int ans = (sf > 0);
  ans += tf * (t - tf) + (tf *(tf - 1));
  ans += ft * (f - ft ) + (ft *(ft - 1));
  ans += f*(f - 1)* (t - f)/2 + f*(f-1)*(f-2)/2;


  cout << ans << endl;








}


Measured memory_bytes: 256
X,N = map(int,input().split())

min = 100

if N !=0:
  Plist = list(map(int,input().split()))
  anslist = [i for i in range(102)]
  anslist.append(-1)
  #anslist.remove(0)
  Plist = sorted(Plist)
  #print (anslist)
  for i in range(N):
    anslist.remove(Plist[i])
    temp =100
  for i in range(len(anslist)):
    if min >abs(anslist[i]-X) :
      min = abs(anslist[i]-X)
      temp = anslist[i]
  print (temp)
else :
  print (X)

Measured memory_bytes: 9164
gets
a = gets.split.map(&:to_i)
h = [0]
a.each{|i|
    h += h.clone.map{|j| j + i}
    h.uniq!
}

gets
m = gets.split.map(&:to_i)
m.each{|i|
    if h.include?(i) then
        puts "yes"
    else
        puts "no"
    end
}


Measured memory_bytes: 7000
#include<bits/stdc++.h>
using namespace std;
using Long = long long;

#define forn(i,n) for( int i = 0 ; i < n ; ++i )
#define pb push_back
#define pf push_front
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define forll(it, cnt) for( auto &it : cnt )
#define endl '\n'
#define debug(x) cout << "[" << #x <<" = " << " ]" << endl
#define ff first
#define ss second
#define fast ios::sync_with_stdio(false); cin.tie(NULL)


int main(){
    fast;
    int n;
    cin >> n;
    int ans = 0;
    for( int i = 1 ; i <= n ; ++i ){
        int how = (n - 1) / i;
        ans += how;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int dp[50050];
int main(){
  int n,m;
  int c[20];
  cin>>n>>m;
  REP(i,n)cin>>c[i];
  for(int i=0;i<=n;i++)dp[i]=1e9;
  dp[0]=0;
  for(int i=0;i<m;i++){
    for(int j=c[i];j<=n;j++){
      dp[j]=min(dp[j],dp[j-c[i]]+1);
    }
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 3272
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
#define MM(a,b) memset(a,b,sizeof(a));
const double eps = 1e-10;
const int  inf =0x7f7f7f7f;
const double pi=acos(-1);
const int maxn=40000;

struct node {
   int x,y;
   bool operator<(const node&a) const{
       return this->x<a.x;
   }
};
vector<node> A,B;
char s[10000];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        A.clear();B.clear();
        for(int i=1;i<=n;i++)
        {
            scanf("%s",s);
            int l=0,r=0;
            for(int j=0;s[j]!='\0';j++)
            {
                 if(s[j]=='(') r++;
                 else if(!r) l++;
                 else r--;
            }
            if(l>r) B.push_back((node){r,l-r});
            else  A.push_back((node){l,r-l});
        }

        sort(A.begin(),A.end());
        sort(B.begin(),B.end());
        int cntA=0,cntB=0;

        bool flag=true;
        for(int i=0;i<A.size();i++)
        {
            if(A[i].x>cntA) {flag=false;break;}
            cntA+=A[i].y;
        }

        for(int i=0;i<B.size();i++)
        {
            if(B[i].x>cntB) {flag=false;break;}
            cntB+=B[i].y;
        }

        if(cntA!=cntB) flag=false;
        printf("%s\n",flag?"Yes":"No");
    }
    return 0;
}

Measured memory_bytes: 2700
import math
def main():

    a, b, x = map(int, input().split())
    if x <= a*a*b/2:
        y = 2*x/a/b
        # print(a, y)
        # print(math.atan(b/y))
        return 180*math.atan(b/y) / (math.atan(1) * 4)
    else:
        y = (x - b*a*a/2)/(a*a/2)
        # print(a*a*b-(b-y)*a*a/2)
        # print(y)
        return 180*math.atan((b-y)/a) / (math.atan(1) * 4)


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=1e5+5;

ll vis[600][600];

ll n,m,s,cnt,k;

//cnt goes from 1 to s-k.

char ch[600][600];

bool valid(ll x,ll y){
  if(vis[x][y])return false;
  if(ch[x][y]=='#')return false;
  if(x<1||x>n||y<1||y>m)return false;
  return true;
}

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

void dfs(ll x,ll y){
  cnt++;
  if(cnt>s-k)return;
  //cnt++;
  vis[x][y]=1;

  FOR(i,4){
    ll nx=x+dx[i],ny=y+dy[i];
    if(valid(nx,ny))dfs(nx,ny);
  }

}


int main()
{ 

IOS;

ll n;cin>>n;
//ll ans=0;


vl a(n),b(n);

ll ans=0;

vl score(n);

FOR(i,n)cin>>a[i]>>b[i],score[i]=a[i]+b[i],ans-=b[i];

sort(all(score),greater<>());

FOR(i,n){
  //if(i&1)ans-=2*b[i];
  if(i%2==0)ans+=score[i];
}

d1(ans);

//end_routine();

return 0;
 
 }


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
long long n, ans = 1ll;
int main()
{
    scanf("%lld", &n);
    for (long long i = 1ll; i <= n; i++)
        ans = ans * i % 1000000007ll;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#N = int(input())
#A = [int(x) for x in input().split()]
#a, b, c = map(int, input().split())
#name1 = str(input())
#alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
a, b = map(int, input().split())
if a+b>=10:
    print("error")
else:
    print(a+b)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int q = Integer.parseInt(sa[1]);

		DSU dsu = new DSU(n);
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			int t = Integer.parseInt(sa[0]);
			int u = Integer.parseInt(sa[1]);
			int v = Integer.parseInt(sa[2]);
			if (t == 0) {
				dsu.merge(u, v);
			} else {
				pw.println(dsu.same(u, v) ? 1 : 0);
			}
		}
		pw.flush();
		br.close();

		List<List<Integer>> groups = dsu.groups(); // TLEしないか確認
	}
}

/**
 * Disjoint Set Union（Union Find）
 */
class DSU {
	private int n;
	private int[] parentOrSize;
	private int num;

	/**
	 * n頂点0辺の無向グラフを作る。<br>
	 * O(n)
	 * 
	 * @param n 頂点数
	 */
	public DSU(int n) {
		this.n = n;
		this.parentOrSize = new int[n];
		Arrays.fill(parentOrSize, -1);
		num = n;
	}

	/**
	 * 辺(a, b)を足す。<br>
	 * ならしO(α(n))
	 * 
	 * @param a 頂点番号（0≦a＜n）
	 * @param b 頂点番号（0≦b＜n）
	 * @return 代表元
	 */
	int merge(int a, int b) {
		assert 0 <= a && a < n : "a=" + a;
		assert 0 <= b && b < n : "b=" + b;

		int x = leader(a);
		int y = leader(b);
		if (x == y) {
			return x;
		}
		if (-parentOrSize[x] < -parentOrSize[y]) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		parentOrSize[x] += parentOrSize[y];
		parentOrSize[y] = x;
		num--;
		return x;
	}

	/**
	 * 頂点a, bが連結かどうか。<br>
	 * ならしO(α(n))
	 * 
	 * @param a 頂点番号（0≦a＜n）
	 * @param b 頂点番号（0≦b＜n）
	 * @return true：連結　false：非連結
	 */
	boolean same(int a, int b) {
		assert 0 <= a && a < n : "a=" + a;
		assert 0 <= b && b < n : "b=" + b;

		return leader(a) == leader(b);
	}

	/**
	 * 頂点aの属する連結成分の代表元を返す。<br>
	 * ならしO(α(n))
	 * 
	 * @param a 頂点番号（0≦a＜n）
	 * @return 代表元
	 */
	int leader(int a) {
		assert 0 <= a && a < n : "a=" + a;

		if (parentOrSize[a] < 0) {
			return a;
		} else {
			return parentOrSize[a] = leader(parentOrSize[a]);
		}
	}

	/**
	 * 頂点aの属する連結成分の要素数を返す。<br>
	 * ならしO(α(n))
	 * 
	 * @param a 頂点番号（0≦a＜n）
	 * @return 要素数
	 */
	int size(int a) {
		assert 0 <= a && a < n : "a=" + a;

		return -parentOrSize[leader(a)];
	}

	/**
	 * 連結成分の数を返す。<br>
	 * O(1)
	 * 
	 * @return 連結成分数
	 */
	int num() {
		return num;
	}

	/**
	 * グラフを連結成分に分けた情報を返す。<br>
	 * O(n)
	 * 
	 * @return 「1つの連結成分の頂点番号のリスト」のリスト
	 */
	List<List<Integer>> groups() {
		int[] leaderBuf = new int[n];
		int[] groupSize = new int[n];
		for (int i = 0; i < n; i++) {
			leaderBuf[i] = leader(i);
			groupSize[leaderBuf[i]]++;
		}
		List<List<Integer>> result = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			result.add(new ArrayList<>(groupSize[i]));
		}
		for (int i = 0; i < n; i++) {
			result.get(leaderBuf[i]).add(i);
		}
		result.removeIf(List::isEmpty);
		return result;
	}
}


Measured memory_bytes: 61948
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n):
    for j in range(i+1,n):
        ma = max(l[i],l[j])
        mi = min(l[i],l[j])
        a = ma - mi + 1
        b = ma + mi - 1
        s = bisect.bisect_left(l,a)
        t = bisect.bisect_right(l,b)
        c = t - max(j+1,s + 1)
        if c <= 0:
            continue
        count += c
print(count)

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

int main(){
  int table[55000]={};
  for(int i=2; i*i<55000; ++i){
    if(!table[i]){
      for(int j=i*2; j<=55000; j+=i){
        table[j]=1;
      }
    }
  }

  int n;
  while(cin >> n){
    int i;
    for(i=n-1; table[i]; --i);
    cout << i << " ";
    for(i=n+1; table[i]; ++i);
    cout << i << endl;
  }
  return 0;
}



Measured memory_bytes: 3264
#include<iostream>
#include<cmath>

using namespace std;
typedef unsigned long long ullong;

ullong power(ullong x,ullong n,ullong M){
  ullong res = 1;
  if(n>0){
    res = power(x,n/2,M);
    if(n%2==0) res = (res*res)%M;
    else res = (((res*res)%M) *x) % M;
  }
  return res;
}

int main(){
  int m,n;
  cin >> m >> n;
  cout << power(m,n,1000000007) << endl;
  return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
//No change above here

const ll maxi = (2 * 1e5 + 3);
ll mod = (1e9 + 7);

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }

//declare needed things here

int main()
{
	IOS;
	int n ,k;
	cin >> n>>k;
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	sort(v.begin(), v.end());
	ll ans = 0;
	for (int i = 0; i < k; ++i)
		ans += v[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

ll f(ll n) {return n * (n+1) / 2;}

int main() {
  int n;
  cin >> n;
  int a = n % 1000;
  if (a == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1000 - a << endl;
}



Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
using namespace std;

bool ans[35];
void init(){
  for(int i=0;i<35;i++){
    ans[i]=false;
  }
}

bool input(){
  int tmp;
  for(int i=0;i<28;i++){
    cin>>tmp;
    ans[tmp]=true;
  }
  return true;
}



pair<int,int> solve(){
  pair<int,int> res;
  bool c=true;
  for(int i=1;i<31;i++){
    if(ans[i]==false){
      if(c){
        res.first=i;
        c=false;
      }else{
        res.second=i;
        break;
      }
    }
  }
  return res;
}


int main(){
  init(),input();
  pair<int,int> ans=solve();
  cout<<ans.first<<endl<<ans.second<<endl;  
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int ans = 0;
  int h,a;
  cin >> h >> a;
  while(h>0){
    h-=a;
    ans++;
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

int main() {
  string s;
  cin >> s;
  REP(i, s.size() - 1) {
    if (s[i] != s[s.size() - 2 - i] || s[0] == '0' || s.back() == '1') {
      cout << -1 << endl;
      return 0;
    }
  }

  ll root = 1;

  REP(i, s.size() - 1) {
    cout << root << " " << i + 2 << endl;
    if (s[i] == '1') {
      root = i + 2;
    }
  }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,t;cin>>n>>t;
	vector<pair<int,int>> a(n);
	int x,y;
	for(int i = 0; i < n; i++) {
		cin>>x>>y;
		a[i] = mp(x,y);
	}
	sort(ALL(a));
	vector<vector<int>> dp(n + 1,vector<int>(t + 1,0));
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= t - 1; j++) {
			if (a[i - 1].fs > j){
				dp[i][j] = dp[i - 1][j];
			}
			else{
				dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - a[i - 1].fs] + a[i - 1].sc);
			}
			ans = max(dp[i][j] + a[i].sc,ans);
		}
	}

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

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll MAXN = 

ll cnt[10];
/********** Good Luck :) **********/
int main()
{
    IOS();
    REP (i,3) {
        ll a,b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    REP1 (i,4) {
        if (cnt[i] >= 3) {
            cout << "NO" << endl;
            return 0;
        } 
    }

    cout << "YES" << endl;
    return 0;
}


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

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

using ll = long long;
using namespace std;

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

    map<string, int> m;
    rep (n, _) {
      string s;
      cin >> s;
      m[s] += 1;
    }

    vector<pair<string, int>> v(m.begin(), m.end());
    stable_sort(v.begin(), v.end(), [](const auto & a, const auto & b){
                return a.second > b.second;
                });

    int top = v[0].second;
    for_each(m.begin(), m.end(), [=](const auto & a){
                if ( a.second != top) return;
                cout << a.first << endl;
                });
}


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

int main () {
    int n, m;
    cin >> n >> m;
    int a[100][100];
    int b[100];
    int c[100];

    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++) cin >> a[i][j];
    for (int i=0; i<m; i++) cin >> b[i];

    for (int i=0; i<n; i++) {
        c[i] = 0;
        for (int j=0; j<m; j++) {
            c[i] += a[i][j] * b[j];
        }
    }

    for (int i=0; i<n; i++) cout << c[i] << endl;
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k; //入力値
  int cnt = 0; //回文数格納 
  
  //入力値の取得
  cin >> n >> k;
   
  //範囲内を繰り返し判定
  for(int i = n; i <= k; i++){
    string s = std::to_string(i);
    //回文判定(1文字目と5文字目・2文字目と4文字目一致)
    if((s.at(0) == s.at(4)) && (s.at(1) == s.at(3))){
      cnt++;
    } 
  }
  //結果を出力
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin>>s;
	int ans=0,cur=0;
	for (int i=0;i<s.size();i++){
		if (s[i]=='S') cur=0; else 
		{
			cur++;
			ans=max(ans,cur);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;



int main(void) {

    int n;
cin>>n;
vi v(n);
rep(i,n)cin>>v[i];
    ll ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=v[i]*v[j];
        }
    }
    fin(ans);


}



Measured memory_bytes: 256
K, S = map(int, input().split())

# a = []
ans = 0
for i in range(K + 1):
    for j in range(i + 1):
        k = S - i - j
        if k >= 0 and k <= j:
            # print(i, j, k)
            if i == j and j == k:
                ans += 1
            elif i == j or j == k:
                ans += 3
            else:
                ans += 6

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int N; cin >> N;
  vector <int> A(N), B(N);

  ll kaijou[N + 1]; kaijou[0] = 1;
  for (ll i = 1; i < N + 1; i++){
    kaijou[i] = kaijou[i - 1] * i;
    kaijou[i] %= nmax;
  }
  
  vector < pair<int, int> > AB(2 * N);

  for (int i = 0; i < 2 * N; i++){
    int K; cin >> K;
    if (i < N){
      AB[i] = make_pair(K, 1);
    }else{
      AB[i] = make_pair(K, 2);
    }
  }
  sort(AB.begin(), AB.end());

  ll cnt = 0, ans = 1;
  for (int i = 0; i < 2 * N; i++){
    if (AB[i].second == 1){
      if (cnt > 0){
        ans = ans * cnt;
      }
      cnt--;
    }else{
      if (cnt < 0){
        ans = ans * (-1 * cnt);
      }
      cnt++;
    }
    ans = ans % nmax;
  }
  
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 3328
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n, k; cin >> n >> k;
	vector<LL> v(n+2);

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

	vector<vector<LL>> dpr(n+1, vector<LL>(k+1,-INF));
	dpr[0][0] = 0;

	for (int i = 1; i < n+1; i++) {
		for (int j = 1; j < k+1; j++) {

			//1回使って、宝石をとる
			if (j >= 1) {
				dpr[i][j] = max(dpr[i][j], dpr[i - 1][j - 1] + v[i]);
			}

			//2回使って、宝石をとって、捨てる
			if (j >= 2) {
				dpr[i][j] = max(dpr[i][j], dpr[i - 1][j - 2]);
			}
			
		}
	}

	vector<vector<LL>> dpl(n + 1, vector<LL>(k + 1,-INF));
	dpl[0][0] = 0;

	reverse(v.begin(), v.end());


	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < k + 1; j++) {

			//1回使って、宝石をとる
			if (j >= 1) {
				dpl[i][j] = max(dpl[i][j], dpl[i - 1][j - 1] + v[i]);
			}

			//2回使って、宝石をとって、捨てる
			if (j >= 2) {
				dpl[i][j] = max(dpl[i][j], dpl[i - 1][j - 2]);
			}

		}
	}

	//結果の集計

	
	//全部取らないをいつでも選択できるので、とりあえず0で初期化
	LL ans = 0;
	
	//操作回数を左右に振り分け
	for (int r = 0; r < k+1; r++) {
		for (int l = 0; l < k+1; l++) {
			if (r + l > k)continue;

			
			for (int i = 0; i < n+1; i++) {
				for (int j = 0; j < n+1; j++) {
					if (i + j > n)continue;
					
					ans = max(ans, dpr[i][r] + dpl[j][l]);

				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
  static const double pi = acos(-1);
  int A,B,H,M;
  cin >> A >> B >> H >> M;

  double X = (30*H+0.5*M);
  double Y = (6*M);
  double x1 = A * cos(pi/2-pi/180*X);
  double y1 = A * sin(pi/2-pi/180*X);
  double x2 = B * cos(pi/2-pi/180*Y);
  double y2 = B * sin(pi/2-pi/180*Y);

  //cout << x1 << y1 << x2 << y2 << endl;

  double a = pow(x1-x2,2);
  double b = pow(y1-y2,2);

  double c = sqrt(a+b);

  cout << fixed << setprecision(10) << c << endl;


}


Measured memory_bytes: 3964
#include<iostream>
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	ll nf = 1, mf = 1;
	ll ans;
	for (int i = 1; i <= n; ++i) {
		nf *= i;
		nf %= mod;
	}
	for (int i = 1; i <= m; ++i) {
		mf *= i;
		mf %= mod;
	}
	if (abs(n - m) >1)ans = 0;
	else {
		ans = (nf * mf) % mod;
		if (n == m) {
			ans *= 2;
			ans %= mod;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        mut a: i64,
        mut b: i64,
        mut c: i64,
    };
    let mut count = 0_i64;
    let mut p_a = None;
    let mut p_b = None;
    let mut p_c = None;
    while a % 2 == 0 && b % 2 == 0 && c % 2 == 0 {
        if p_a == Some(a) && p_b == Some(b) && p_c == (Some(c)) {
            println!("-1");
            return;
        }
        p_a = Some(a);
        p_b = Some(b);
        p_c = Some(c);
        count += 1;

        let h_a = a / 2;
        let h_b = b / 2;
        let h_c = c / 2;
        a = h_b + h_c;
        b = h_a + h_c;
        c = h_a + h_b;
    }
    let ans = count;
    println!("{}", ans);
}


Measured memory_bytes: 2120
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	ll N;
	cin>>N;
	string S;
	cin>>S;
	ll ans=0;
	char now=0;
	rep(i,N){
		if(S[i]!=now){
			ans++;
			now=S[i];
		}
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

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

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

    sort(v.begin(), v.end());

    for (int i = 0; i < k; i++) {
        s += v[i];
    }

    cout << s;

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<ll,ll,ll> tll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  if(n)COUT(0);
  else COUT(1);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i=0; i<n; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end(), greater<int>());
    int ans = 0;

    for (int i=0; i<n; i++) {
        if (i % 2 == 0) {
            ans += vec.at(i);
        }
        else {
            ans -= vec.at(i);
        }
    }
    cout << ans << endl;
}

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

long long come_and_go(int *a, int n) {
    
    long long ans = 0;
    int c = n/2;
    
    for (int i = 0; i < n; i++) {
        if (i != c) ans += (long long)abs(a[i] - a[c]);
    }
    ans *= 2ll;
    
    if (n % 2 == 0) {
        ans -= abs(a[c-1] - a[c]);
    } else {
        ans -= min(abs(a[c-1] - a[c]), abs(a[c+1] - a[c]));
    }
    
    return ans;
}

int main() {
    
    int n;
    cin >> n;
    
    int a[n];
    for (int i = n; i--;) cin >> a[i];
    if (n == 2) {
        cout << abs(a[0] - a[1]) << endl;
        return 0;
    }
    
    sort(a, a + n);
    
    cout << come_and_go(a, n) << endl;
    
}


Measured memory_bytes: 768