akhauriyash/Code-Regression huggingface dataset:
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
  
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
   
label = list(map(int,input().split()))
d0 = dice(label)
d1 = list(map(int,input().split()))
for op in 'EEENEEENEEESEEESEEENEEEN':
    if d0.get_label() == d1:
        print('Yes')
        break
    d0.roll(op)
else:
    print('No')



Measured memory_bytes: 5608
import java.util.Arrays;
import java.util.Scanner;

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

    int A = scanner.nextInt() - 1;
    int B = scanner.nextInt() - 1;
    int H = 100;
    int W = 100;
    char[][] map = new char[H][W];
    for (int i = 0; i < H / 2; i++) Arrays.fill(map[i], '.');
    for (int i = H / 2; i < H; i++) Arrays.fill(map[i], '#');

    for (int i = 0; i < B; i++) {
      int x = i / (W / 2) * 2;
      int y = i % (W / 2) * 2;
      map[x][y] = '#';
    }
    for (int i = 0; i < A; i++) {
      int x = i / (W / 2) * 2 + H / 2 + 1;
      int y = i % (W / 2) * 2;
      map[x][y] = '.';
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) sb.append(map[i][j]);
      sb.append('\n');
    }
    System.out.printf("%d %d\n", H, W);
    System.out.print(sb.toString());
  }
}


Measured memory_bytes: 23764
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e5+1;
int n,m,k,r[7],c[7],res;
char grid[7][7];
map<pair<set<int>,set<int>>,int>vis;

void sol(set<int>x,set<int>y){
    if(vis.count({x,y})){
        return;
    }
    vis[{x,y}]=1;

    char temp[7][7];
    lp(i,0,n)
        lp(j,0,m)
            temp[i][j]=grid[i][j];
    for(auto i:x){
        lp(j,0,m)
            temp[i][j]='.';
    }
    for(auto j:y){
        lp(i,0,n)
            temp[i][j]='.';
    }
    int cnt=0;
    lp(i,0,n)
        lp(j,0,m)
            cnt+=temp[i][j]=='#';
    res+=cnt==k;

    if(sz(x)==n&&sz(y)==m)
        return;

    lp(i,0,n){
        if(x.find(i)==x.end()){
            x.insert(i);
            sol(x,y);
            lp(j,0,m){
                if(y.find(j)==y.end()){
                    y.insert(j);
                    sol(x,y);
                    y.erase(j);
                }
            }
            x.erase(i);
            lp(j,0,m){
                if(y.find(j)==y.end()){
                    y.insert(j);
                    sol(x,y);
                    y.erase(j);
                }
            }
        }
    }
    return ;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    cin>>n>>m>>k;
    lp(i,0,n)
        lp(j,0,m)
            cin>>grid[i][j];
    set<int>q,w;
    sol(q,w);
    cout<<res;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int k;
  cin>>k;
  cout<<(k/2)*(k-(k/2))<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define mod 10000000007
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";

int main(){
  int H,N;cin>>H>>N;
  int max_a=0,a_l[N],b_l[N];
  REP(n,0,N){
    cin>>a_l[n]>>b_l[n];
    max_a=max(max_a,a_l[n]);
  }

  int INF=1000000000;
  int dp[H+max_a+1];
    REP(h,0,H+max_a+1){
      dp[h]=INF;
  }

  int ans=INF;
  dp[0]=0;
  REP(h,1,H+max_a+1)REP(n,0,N){
    if(h<a_l[n])continue;
     dp[h]=min(dp[h],dp[h-a_l[n]]+b_l[n]);
     if(h>=H)ans=min(ans,dp[h]);
  }

    // REP(h,0,H+max_a+1){
    //   cout<<dp[h]<<" ";
    // }

  print(ans)
  
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		a: usize,
		b: usize,
		x: usize,
	}

	if x < a {
		println!("NO");
		return;
	}

	if x - a <= b {
		println!("YES");
	}
	else {
		println!("NO");
	}
}



Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
int main(){
	int n;
	vector<ll> a;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.pb(x);
	}
	ll ans = 1;
	stack<ll> sta;
	for(int i=0;i<n;i++){
		sta.push(a[i]);
		int k = sta.size();
		if( 2*k-1 > sta.top() ){
			ans *= k;
			ans %= inf;
			sta.pop();
		}
	}
	int c = sta.size();
	for(int i=1;i<=c;i++){
		ans *= i;
		ans %= inf;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
int n,l;
vector <string> s;
int main(){
    cin >> n >> l;
    s = vector<string>(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    for(int i = 0; i < n; i++){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

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

typedef int64_t s64;

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int a = ri();
	int b = ri();
	std::cout << "100 100" << std::endl;
	a--;
	b--;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			bool fill;
			if (i == 0 || i == 49) fill = false;
			else if (i == 50 || i == 99) fill = true;
			else if (i < 50 && (!j || j == 99)) fill = false;
			else if (!j || j == 99) fill = true;
			else if (i < 50 && i % 2 && j % 2 && b) b--, fill = true;
			else if (i < 50) fill = false;
			else if (i % 2 && j % 2 && a) a--, fill = false;
			else fill = true;
			printf("%c", fill ? '#' : '.');
		}
		puts("");
	}
	return 0;
}


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

int main()
{
        int w, h, x, y, r;
        cin >> w >> h >> x >> y >> r;

        if(x>=r && x<=w-r && y>=r && y<=h-r) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        };
        return 0;
}

Measured memory_bytes: 3040
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc =new Scanner(System.in);
		int[] highests={0,0,0};
		for(int i=0;i<10;i++){
			int height=Integer.parseInt(sc.nextLine());

			if(highests[0]<=height){
				highests[2]=highests[1];
				highests[1]=highests[0];
				highests[0]=height;

			}else if(highests[1]<=height){
				highests[2]=highests[1];
				highests[1]=height;
			}else if(highests[2]<=height){
				highests[2]=height;
			}
		}

		System.out.println(highests[0]);
		System.out.println(highests[1]);
		System.out.println(highests[2]);

	}
}

Measured memory_bytes: 25992
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define inf  1000001
#define ind  -1000001
typedef int long long ll;


int main(){
    vector<ll> v;
    int n;
    cin>>n;
    ll mx=ind;
    ll mxp=0;
    ll mip=0;
    ll mi=inf;
    
    rep(i,n){
        ll x;
        cin>>x;
        if(x<mi){mi=x;mip=i;}
        if(x>mx){mx=x;mxp=i;}
        v.push_back(x);
    }
    if(mip==mxp){
        cout<<0<<endl;
        return 0;
    }
    cout<<2*n-1<<endl;
    int flag=0;
    
    if(abs(mi)<abs(mx)){
        for(int i=0;i<v.size();i++){
            cout<<mxp+1<<" "<<i+1<<endl;
            flag=1;
        }
    }else{
        for(int i=0;i<v.size();i++){
            cout<<mip+1<<" "<<i+1<<endl;
            flag=2;
        }
    }
    
    if(flag==1){
        for(int i=1;i<n;i++){
           
            cout<<i<<" "<<i+1<<endl;
        }
        
    }else{
        for(int i=n-1;i>0;i--){
            cout<<i+1<<" "<<i<<endl;
        }
    }
    
    
    
   
    
    
    
return 0;
}


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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
#define int ll
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define vi vector<int>
#define pii pair<int,int>
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define MAX 100005
#define initialize(arr,elem) memset(arr,elem,sizeof(arr))
#define sz size
const int MOD = 1e9+7;

// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,k,arr[105], dp[MAX];
int solve(int i ){
	if (i<0) return 1;
	if (i<arr[1]) return dp[i] = 0;
	if (dp[i] != -1) return dp[i];

	int res = 1;
	For(j,1,n+1) res &= solve(i-arr[j]); 
	if(res) return dp[i] = 0;
	return dp[i] = 1;

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		


	cin>>n>>k;
	For(i,1,n+1) cin>>arr[i];
	initialize(dp,-1);
	if (solve(k)) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	// For(i,1,k+1){
	// 	cout<<dp[i]<< " ";
	// }
	return 0;
}


Measured memory_bytes: 4224
N = int(input())
S = input()

ans = 0
for n in range(1000):
    c = [n // 100, (n // 10) % 10, n % 10]
    f = 0
    for i in range(N):
        if S[i] == str(c[f]):
            f += 1
        if f == 3:
            break
    
    if f == 3:
        ans += 1
        
print(ans)


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

#define __INIT_CC__ ios::sync_with_stdio(false); \
	cin.tie(0);

#ifdef __WIN32__
	char getchar_unlocked() {return getchar();}
#endif

#define FOR(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i<(_t);++(_i))
#define FORN(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i<=(_t);++(_i))
#define FORD(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i>=(_t);--(_i))
#define FORLL(_i,_n,_m) for(long long (_i)=(_n),_t=(_m);_i<(_t);++(_i))
#define FORNLL(_i,_n,_m) for(long long (_i)=(_n),_t=(_m);(_i)<=(_t);++(_i))
#define FORDLL(_i,_n,_m) for(long long (_i)=(_n),_t=(_m);(_i)>=(_t);--(_i))
#define FOREACH(_i,_a) for (__typeof(_a.begin()) _i=_a.begin();_i!=_a.end();++_i)
#define RESET(_a,_value) memset(_a,_value,sizeof(_a))
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ff first
#define ss second
#define mp make_pair
#define SIZE(_a) (int)_a.size()
#define VSORT(_a) sort(_a.begin(),_a.end())
#define SSORT(_a,_val) sort(_a,_a+(_val))
#define ALL(_a) _a.begin(),_a.end()
#define mt make_tuple
#define _get(_tuple,_i) get<_i>(_tuple)
#define eb emplace_back
 
using namespace std;
 
const int dr[] = { 1, 0,-1, 0, 1, 1,-1,-1};
const int dc[] = { 0, 1, 0,-1, 1,-1,-1, 1};
const double eps = 1e-9;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;
typedef pair<double,double> pdd;
typedef vector<pdd> vpdd;
const int INF = 0x7FFFFFFF;
const ll INFLL = 0x7FFFFFFFFFFFFFFFLL;
const double pi = acos(-1);

template <class T> T take(queue<T> &O) {T tmp=O.front();O.pop();return tmp;}
template <class T> T take(stack<T> &O) {T tmp=O.top();O.pop();return tmp;}
template <class T> T take(priority_queue<T> &O) {T tmp=O.top();O.pop();return tmp;}
template <class T> inline void getint(T &num)
{
	bool neg = 0;
	num = 0;
	char c;
	while ((c = getchar_unlocked()) && (!isdigit(c) && c != '-'));
	if (c == '-')
	{
		neg = 1;
		c = getchar_unlocked();
	}
	do num = num * 10 + c - '0';
	while ((c = getchar_unlocked()) && isdigit(c));
	if (neg) num = -num;
}

template <class T> inline bool inRange(T z, T a, T b){return a <= z && z <= b;}

void OPEN(string in = "input.txt",string out = "output.txt")
{
	freopen(in.c_str(), "r", stdin);
	freopen(out.c_str(), "w", stdout);
	return ;
}

//using sokokaleb's template v3.1

int h, w;

ll coba(int w, int h) {
	int hi = (w + 2) / 3;
	int lo = w / 3;
	return 1LL * (hi - lo) * h;
}

ll coba2(int w, int h) {
	ll res = INFLL;
	FORN (i, 1, w - 1) {
		int sisa = w - i;
		ll mi = 1LL * i * h;
		ll ma = 1LL * i * h;
		int hi = (h + 1) / 2;
		int lo = h / 2;
		FORN (j, max(1, lo - 3), min(h - 1, hi + 3)) {
			ll mi2 = min(1LL * j * sisa, 1LL * (h - j) * sisa);
			ll ma2 = max(1LL * j * sisa, 1LL * (h - j) * sisa);
			res = min(res, max(ma2, ma) - min(mi2, mi));
		}
	}
	return res;
}

int main(int argc, char** argv) {
	__INIT_CC__
	cin >> h >> w;
	ll ans = INFLL;
	ans = min(ans, coba(h, w));
	ans = min(ans, coba(w, h));
	ans = min(ans, coba2(w, h));
	ans = min(ans, coba2(h, w));
	cout << ans << "\n";
}


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

int main(){
  string s;
  cin >> s;
  if(s[0] == 'S') cout << "Cloudy" << endl;
  if(s[0] == 'C') cout << "Rainy" << endl;
  if(s[0] == 'R') cout << "Sunny" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
s = [input() for i in range(N)]

A = 0
B = 0
AB = 0
Ans = 0

for i in s:
  if i[0] == "B" and i[-1] == "A":
    AB += 1
  elif i[0] == "B":
    B += 1
  elif i[-1] == "A":
    A += 1
  f = False
  for j in i:
    if j == "B" and f:
      Ans += 1
    if j == "A":
      f = True
    else:
      f = False

if AB != 0:
  Ans += AB - 1
  if A != 0:
    A -= 1
    Ans += 1
  if B != 0:
    B -= 1
    Ans += 1
Ans += min(A, B)

print(Ans)


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

int main(){
  long x = 0;
  long i = 0;
  
  scanf("%ld",&x);
  for(i=0;i<1000000000+1;i++){
    if(x <= i*(i+1)/2){
      break;
    }
  }
  printf("%ld",i);
  return 0;
}
    

Measured memory_bytes: 128
N=input()
L=len(N)
dp=[[0,0] for _ in range(L+1)]
# dp[i][j]:i桁目まで決まっていて、
# jなら0~9何入れてもよく
# そうでないなら0~int(N[i])までで、
# ここまでの最大値を格納
dp[1]=[int(N[0]),int(N[0])-1]
for i in range(1,L):
    for j in range(2):
        for d in range(10 if j else int(N[i])+1):
            dp[i+1][int(j or d<int(N[i]))]=max(dp[i][j]+d,dp[i+1][int(j or d<int(N[i]))])
print(max(dp[-1]))

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int k = sc.nextInt();
        String s = sc.next();
        
        if(s.length() <= k) {
            System.out.println(s);
        }else{
            for(int i = 0; i < k; i++){
                System.out.print(s.charAt(i));
            }
            System.out.print("...");
        }
    }
}


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

int main() {
  int N, M, Max;
  cin >> N;
  vector<string> B(N);
  Max = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  
  cin >> M;
  vector<string> R(M);
  
  for (int i = 0; i < M; i++) {
    cin >> R.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    int count = 0;
    
    for (int j = 0; j < N; j++) {
      if (B.at(i) == B.at(j)) {
        count++;
      }
    }
    
    for (int k = 0; k < M; k++) {
      if (B.at(i) == R.at(k)) {
        count--;
      }
    }
    
    if(Max < count) {
      Max = count;
    }
  }
  
  cout << Max << endl;
}

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

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

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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

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

using ll = long long;


class UnionFind {
public:
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x!=y;
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

using PII = pair<int, int>;

struct Edge {
  int from, to, cost;
};

bool operator < (const Edge &e, const Edge &f) {
  return e.cost < f.cost;
}

bool operator > (const Edge &e, const Edge &f) {
  return e.cost > f.cost;
}

int main() {
  int n; cin >> n;
  vector<PII> xs(n), ys(n);
  REP(i,n) {
    int x, y;
    cin >> x >> y;
    xs[i] = make_pair(x, i);
    ys[i] = make_pair(y, i);
  }
  whole(sort, xs); whole(sort, ys);
  UnionFind UF(n);
  priority_queue<Edge, vector<Edge>, greater<Edge>> Q;
  REP(i,n-1) {
    Q.push({xs[i].second, xs[i+1].second, xs[i+1].first - xs[i].first });
    Q.push({ys[i].second, ys[i+1].second, ys[i+1].first - ys[i].first });
  }
  int ans = 0;
  while(!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (UF.unite(e.from, e.to)) {
      ans += e.cost;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6900
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
/*
	Source: AtCoder Beginner Contest 054
	Author: fts2001 (the_silliest)
 */
using namespace std;
int n,m,ans;
bool vis[10];
vector<int> g[10];
void dfs(int x){
    vis[x]=true;
    bool flag=true;
    for(int i=0;i<n;i++){
        flag&=vis[i];
        if(!flag)break;
    }
    if(flag){
        ans++;
        vis[x]=false;
        return;
    }
    for(int i=0;i<g[x].size();i++){
        int v=g[x][i];
        if(!vis[v])dfs(v);
    }
    vis[x]=false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u;
        --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque


def create_factorial(n):
    """
    階乗を事前計算した配列を作成します。
    :param n: [0, n]の配列を作成します
    """
    f = list()
    for i in range(n + 1):
        if i in [0, 1]:
            f.append(1)
        else:
            f.append(f[i - 1] * i % MOD)
    return f


MOD = 10 ** 9 + 7

N, K = map(int, input().split())
f = create_factorial(K)
adj = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(lambda s: int(s) - 1, input().split())
    adj[a].append(b)
    adj[b].append(a)

ans = K
q = deque()
q.append((0, -1))
while len(q) > 0:
    v, p = q.popleft()
    c = 0
    for nxt in adj[v]:
        if nxt != p:
            q.append((nxt, v))
            c += 1
    n = K - 1 if p == -1 else K - 2
    r = n - c
    if c > n:
        print(0)
        exit()
    ans = ans * (f[n] % MOD) * pow(f[r], MOD - 2, MOD) % MOD

print(ans)



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

int main() {
  int n;
  cin >> n;
  
  vector<vector<int>> cnt(10, vector<int>(10));
  for(int i = 1; i <= n; i++){
    for(int j = 100000; j > 0; j /= 10){
      if(i / j > 0 && i / j < 10){
        cnt.at(i/j).at(i%10)++;
      }
    }
  }
  
  long long ans = 0;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      long long a = cnt.at(i).at(j), b = cnt.at(j).at(i);
      ans += a * b;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve() {
    string N;
    cin >> N;

    int sum = 0;
    FORE(c, N) sum += c - '0';

    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
    const auto in_stream = freopen("../in.txt", "r", stdin);
    if (in_stream == nullptr) {
        cerr << "ERROR!" << endl;
        return 1;
    }
#endif

    solve();

#ifndef ONLINE_JUDGE
    fclose(in_stream);
#endif
}


Measured memory_bytes: 3732
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int n = 0;
        for (int i =101; i >= 1; i--){
          if(a % i == 0 && b % i == 0){
            n++;
            if(n == k) System.out.println(i);
          }
        }
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,a,b;
  cin>>n>>a>>b;
  ll ans=n/(a+b);ans=ans*a;
  ll rem=n%(a+b);
  ans=ans+min(rem,a);
  cout<<ans;
  
}

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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second

using namespace std;

const int N = 2000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-6;
const double pi = atan2(0, -1);

vector<int> g[N];

int dfs(int u, int p, int h, int mh)
{
    int cnt = 0;
    if (h > mh)
        cnt++;
    for (int v : g[u])
        if (v != p)
            cnt += dfs(v, u, h + 1, mh);
    return cnt;
}

int main()
{
    //freopen("adriatic.in", "r", stdin);
    //freopen("adriatic.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //int TL = 1.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, k;
    cin >> n >> k;
    rep(i, 0, n - 1)
    {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans = inf;
    if (k % 2 == 0)
    {
        rep(i, 0, n)
        {
            int ans1 = 0;
            for (int j : g[i])
                ans1 += dfs(j, i, 0, k / 2 - 1);
            ans = min(ans, ans1);
        }
    }
    else
    {
        rep(i, 0, n)
            for (int j : g[i])
                ans = min(ans, dfs(i, j, 0, (k - 1) / 2) + dfs(j, i, 0, (k - 1) / 2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
//    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
//    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector<set<int> > kek(30);
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        kek[s[i] - 'a'].insert(i);
    }
    int q;
    cin >> q;
    int t, l, r;
    char nw;
    while (q--) {
        cin >> t;
        if (t == 1) {
            cin >> l >> nw;
            l--;
            kek[s[l] - 'a'].erase(l);
            kek[nw - 'a'].insert(l);
            s[l] = nw;
        } else {
            cin >> l >> r;
            l--, r--;
            int ans = 0;
            for (int i = 0; i < 30; i++) {
                auto ptr = kek[i].lower_bound(l);
                if (ptr != kek[i].end() && *ptr <= r) {
                    ans++;
                }
            }
            cout << ans << "\n";
        }
    }
}
/*

*/


Measured memory_bytes: 24220
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

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

    int cnt1=b/c;
    cnt1-=(a-1)/c;

    int cnt2=b/d;
    cnt2-=(a-1)/d;

    // cout<<cnt1<<" "<<cnt2<<endl;
    int lcm=(c*d)/__gcd(c,d);
    int cnt3=(b)/lcm;
    cnt3-=(a-1)/lcm;

    // cout<<lcm<<"   "<<cnt3<<endl;
    cout<<(b-a+1)-(cnt1+cnt2-cnt3)<<endl;

    return 0;
}

Measured memory_bytes: 3644
def main():
    N = int(input())
    a = [int(x) for x in input().split()]

    mins = [0] * N
    mins[0] = a[0]
    for i in range(1, N):
        mins[i] = min(mins[i-1], a[i])
    # print(mins)
    ans = 0
    for i in range(N):
        ans += a[i] <= mins[i]
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 25768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;

int main() {
    char s[4];
    scanf("%s", s);
    char days[8][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    int count = 0;
    while (strcmp(days[count], s)) count++;
    printInt(7 - count);
    return 0;
}

Measured memory_bytes: 3796
#include <stdio.h>
 
int main(void)
{
  int h, m, s, S;
  scanf("%d", &S);
  h=S/3600;
  m=(S%3600)/60;
  s=(S%3600)%60;
 
    printf("%d:%d:%d\n",h,m,s);
  return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll fact[200000], invFact[200000]; 

long long power(long long x, long long c) {
    if(c==0) return 1;
    if(c==1) return x;
    if (c%2==1) return (power( (x*x)%MOD, c/2)*x)%MOD;
    else return power( (x*x)%MOD, c/2)%MOD;
}

void make_combT(ll n){
    fact[0]=1;
    rep1(i,n) fact[i]= fact[i-1]*i%MOD;
    
    invFact[n] = power(fact[n],MOD-2);
    rrep(i,n-1) invFact[i] = invFact[i+1] * (i+1) %MOD;
}

ll comb(ll n, ll m){
    if(n<m||n<0||m<0) return 0;
    return (fact[n] * invFact[m] %MOD) * invFact[n-m] %MOD;
}

int N,s,t;
map<int,int> dic;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make_combT(100009);
    
    cin>>N;
    rep(i,N){
        int a;cin>>a;
        if(dic.count(a)){
            s=dic[a];
            t=N-i;
        }
        dic[a]=i;
    }
    
    rep1(i,N+1){
        ll tmp=comb(N+1,i);
        if(i-1<=s+t){
            tmp-=comb(s+t,i-1);
            if(tmp<0) tmp+=MOD;
        }
        cout1(tmp)
    }
}

Measured memory_bytes: 7424
a,b,h,m=map(int, input().split())
ang_a=(360/12)*h+30*m/60
ang_b=(360/60)*m
ang=abs(ang_a-ang_b)
if ang>180:
  ang=360-ang
else:
  ang=ang

import math
cosA=math.cos(math.radians(ang))
ans=(a**2+b**2-2*a*b*cosA)**0.5
print(f'{ans:.09f}')

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

long long GCD(long long x, long long y) {
    if ( y == 0) return x;
    else return GCD(y, x % y);
}

long long solve(int N, long long M, vector<long long> &a) {
    // 2 で割れるだけ割る (割れる回数が異なったらダメ)
    bool same = true;
    while (a[0] % 2 == 0) {
        for (int i = 0; i < N; ++i) {
            if (a[i] % 2 != 0) return 0;
            a[i] /= 2;
        }
        M /= 2;
    }
    for (int i = 0; i < N; ++i) if (a[i] % 2 == 0) return 0;

    // lcm
    long long lcm = 1;
    for (int i = 0; i < N; ++i) {
        long long g = GCD(lcm, a[i]);
        lcm = lcm / g * a[i];
        if (lcm > M) return 0;
    }
    return (M / lcm + 1) / 2;
}

int main() {
    int N; long long M;
    cin >> N >> M;
    vector<long long> a(N);

    // あらかじめ a は一回 2 で割っておく
    for (int i = 0; i < N; ++i) cin >> a[i], a[i] /= 2;
    cout << solve(N, M, a) << endl;
}
    


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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int N;

// *********************************************************
int main(){



    for(int i=0; i<5; i++){
        cin >> N; 

        if(N==0){
            cout << i+1;
            return 0;
        }
    } 


    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 
const int N = 2e5+5;

ll a[N],b[N];

int main()
{	
	ll n,m,x,k;
	scanf("%lld%lld%lld",&n,&m,&k);
	a[0] = b[0] = 0;
	
	for(int i = 1;i <= n;++i) scanf("%lld",&x),a[i] = a[i-1] + x;
	for(int i = 1;i <= m;++i) scanf("%lld",&x),b[i] = b[i-1] + x;
	
	ll res,num,ans = 0;
	for(int i = 1;i <= n;++i){
		if(a[i] > k){
			num = 0;
			res = k;
		}
		else{
			num = i;
			res = k-a[i];
		}
		
		ll pos = lower_bound(b+1,b+m+1,res)-b;
		while((b[pos] > res && pos > 0) || pos > m) pos--;
		ans = max(ans,num+pos);
	}
	for(int i = 1;i <= m;++i){
		if(b[i] > k){
			num = 0;
			res = k;
		}
		else{
			num = i;
			res = k-b[i];
		}
		
		ll pos = lower_bound(a+1,a+n+1,res)-a;
		while((a[pos] > res && pos > 0) || pos > n) pos--;
		ans = max(ans,num+pos);
	}
	printf("%lld\n",ans);
	return 0;
}

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

const int INF = 100000000;

int main(){

    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<int> p(n + 1, 0);
        vector<int> t(n + 1, 0);
        for(int i = 1; i <= n; i++) cin >> p[i] >> t[i];
        vector<vector<int> > dp(n + 1, vector<int> (4, INF));
        dp[0][0] = 0;

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

            
            for(int j = 0; j < 4; j++){

                //家に一旦おきに行く
                if(j != 0){
                    int dis = p[i] + p[i + 1];
                    int take = p[i] * (j + 1) + p[i + 1];

                    //間に合うなら
                    if(take <= t[i + 1] - t[i]) dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + dis);
                }

                //直でとりに行く
                if(j != 3){
                    int dis = (int)abs(p[i + 1] - p[i]);
                    int take = dis * (j + 1);

                    //間に合うなら
                    if(take <= t[i + 1] - t[i]) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + dis);
                }
            }
        }

        /*for(int i = 0; i <= n; i++){
            for(int j = 0; j < 4; j++){
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }*/

        int ans = INF;
        for(int j = 1; j < 4; j++){
            ans = min(ans, dp[n][j] + p[n]);
        }

        if(ans != INF) cout << "OK " << ans << endl;
        else{

            for(int i = n; i >= 0; i--){

                bool ok = false;
                for(int j = 0; j < 4; j++){
                    if(dp[i][j] != INF) ok = true;
                }

                if(ok){
                    cout << "NG " << i + 1 << endl;
                    break;
                }
            }
        }

    }
        
    return 0;
}


Measured memory_bytes: 2968
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005], b[100005], c[100005];

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

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

    vector<vector<int>> dp(n + 1, vector<int>(3));
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            if (j == 0) dp[i][j] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
            if (j == 1) dp[i][j] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
            if (j == 2) dp[i][j] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
        }
    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << '\n';
}


Measured memory_bytes: 6912
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	int W, H, N;
	cin >> W >> H >> N;
	int minX = 0;
	int maxX = W;
	int minY = 0;
	int maxY = H;
	for( int i = 0; i < N; ++i )
	{
		int x, y, a;
		cin >> x >> y >> a;
		switch( a )
		{
		case 1: minX = max( minX, x ); break;
		case 2: maxX = min( maxX, x ); break;
		case 3: minY = max( minY, y ); break;
		case 4: maxY = min( maxY, y ); break;
		}
	}
	cout << max( maxX - minX, 0 ) * max( maxY - minY, 0 ) << endl;
	return 0;
}


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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		int val = int.Parse(Console.ReadLine());
		int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int val = int.Parse(Console.ReadLine());
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];
		int guu = 0, ki = 0;
		for (int i = 0; i < val; i++) {
			if (( vals[i] & 1 ) == 1) { ki++; } else { guu++; }
		}

		string re="NO";
		if (( ki & 1 ) == 1) {
			//if (( (guu+(ki/2)) & 1 ) == 0) { re = "YES"; }
		} else {
			re = "YES";
		
		}



			Console.WriteLine(re);

		
		return;
	}

		

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 12120
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    string S;
    cin >> S;
    int len = S.size();
    string bw = "", wb = "";
    for(int i = 0; i < len; i++){
        if(i % 2 == 0) bw = bw + "0", wb = wb + "1";
        else bw = bw + "1", wb = wb + "0";
    }
   int countbw = 0, countwb = 0;
   rep(i, len){
       if(S[i] != bw[i]) countbw++;
   }
   rep(i, len){
       if(S[i] != wb[i]) countwb++;
   }
   cout << min(countbw, countwb) << endl;
   return 0;
}

Measured memory_bytes: 1148
#include <stdio.h>
int main(){
int a,b,c,d,x,y, Mini;
scanf("%d %d  %d %d",&a,&b,&c,&d);
if(a>b){
    x=b;
}
else{
    x=a;
}
if(c>d){
    y=d;
}
else{
    y=c;
}
Mini=x+y;
printf("%d",Mini);








}


Measured memory_bytes: 1728
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      mut vs: [usize; n],
    }
    vs.sort();
    let vs: Vec<_> = vs.into_iter().map(|v| v as f64).collect();

    let mut cur = vs[0];
    for i in 1..n {
        cur = (cur + vs[i]) / 2.0;
    }
    puts!("{}\n", cur);
}


Measured memory_bytes: 4352
n=int(input())
s=input()
lens=len(s)

ec=[0]*lens
wc=[0]*lens
if s[0]=="W":
    wc[0]=1
else:
    ec[0]=1
for i in range(1,len(s)):
    if s[i]=="W":
        wc[i]=wc[i-1]+1
        ec[i]=ec[i-1]
    else:
        wc[i]=wc[i-1]
        ec[i]=ec[i-1]+1
        
cmin=min(ec[lens-1]-ec[0],wc[lens-2])
for i in range(1,n-1):
    c=ec[lens-1]-ec[i]+wc[i-1]    
#    print(i,c,cmin,ec[lens-1]-ec[i],wc[i-1])    
    cmin=min(cmin,c)
print(cmin)

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

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

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

	int sum=0;
	for (int i=0; i<n-1; i++)
		sum+=sides[i];
	if (sides[n-1]<sum) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "tmp.cpp"

int main() {

  ll n;
  cin >> n;
  map<ll, ll> mp;
  REP(i, n) {
    ll a;
    cin >> a;
    mp[a]++;
  }

  ll ans = 0;

  for (auto i = mp.begin(); i != mp.end(); i++) {
    if (i->first > i->second) {
      ans += i->second;
    } else {
      ans += min(i->second - i->first, i->second);
    }
  }

  cout << min(ans, n) << endl;

  return 0;
}


Measured memory_bytes: 6272
n = gets.chomp.to_i
arr = Array.new(n).map{Array.new(26,0)}
n.times do |i|
	s = gets.chomp
	s.chars.each do |c|
		arr[i][c.ord - "a".ord] += 1
	end
end
cnt = 0
hash = {}
arr.each do |a|
	if hash.has_key?(a)
		cnt += hash[a]
		hash[a] += 1
	else
		hash[a] = 1
	end
end
puts cnt



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

int N;
set<int> st;

int main(){
    cin>>N;

    for (int i = 0; i < N; i++)
    {
        int x;
        cin>>x;
        st.insert(x);
    }
    
    cout << st.size() << endl;
    return 0;
}


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

LL power(int a, int x){
    LL res = 1;
    while(x){
        if(a&1) res *= a;
        a *= a, x /= 2;
    }
    return res;
}

int main(){
    LL range[12] = {};
    for(int i=1; i<12; i++){
        range[i] = range[i-1] + power(26, i);
    }
    LL n, i; cin>>n;

    for(i=1; i<12; i++){
        if(n/range[i] < 1) break; 
    }
    string ans = "";
    for(LL j=i-1; j>=0 and n>0; j--){
        n--;
        char c = 'a' + n%26;
        n /= 26;
        ans += c;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans;
}

Measured memory_bytes: 3604