akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            String S = reader.readLine();

            for (int i = 1; i <= S.length(); i++) {
                char c = S.charAt(i - 1);

                if (i % 2 == 1) {
                    if (c == 'R' || c == 'U' || c == 'D') {
                    } else {
                        System.out.println("No");
                        System.exit(0);
                    }
                } else {
                    if (c == 'L' || c == 'U' || c == 'D') {
                    } else {
                        System.out.println("No");
                        System.exit(0);
                    }
                }
            }

            System.out.println("Yes");
        }
    }

}


Measured memory_bytes: 22484
H, W = gets.split.map(&:to_i)

min = Float::INFINITY
[ [H, W], [W, H] ].each do |x, y|
  (1..x-1).each do |dx|
    rx = x - dx
    rx1 = rx / 2
    rx2 = rx - rx1
    
    area1 = dx * y
    area2 = rx1 * y
    area3 = rx2 * y
    min = [ min, [area1, area2, area3].max - [area1, area2, area3].min ].min
    
    ry1 = y / 2
    ry2 = y - ry1
    
    area1 = dx * y
    area2 = rx * ry1
    area3 = rx * ry2
    min = [ min, [area1, area2, area3].max - [area1, area2, area3].min ].min
  end
end
puts min

Measured memory_bytes: 1788
package main

import (
	"fmt"
)

func main() {
	var n, c int
	var m = make(map[int]int)

	fmt.Scan(&n)
	t := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&t[i])

		// 3200以上は後で考える
		if 3200 <= t[i] {
			c++
		} else {
			for j := 0; j < 8; j++ {
				if 400*j <= t[i] && t[i] < 400*(j+1) {
					_, isExist := m[j]
					if !isExist {
						m[j] = 1
					}
				}
			}
		}
	}

	// 3200以上がいないなら終わり
	// 最大値
	max := len(m) + c

	// 最小値
	min := len(m)
	if 0 == len(m) {
		min = 1
	}

	fmt.Println(min, max)
}


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

int abs(int x, int y){
  if(x >= y){
    return x-y;
  }else{
    return y-x;
  }
}
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a, c)<=d){
    cout << "Yes" << endl;
  }else if(abs(a,b)<=d && abs(b,c)<=d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main() {
  int num_query; cin >> num_query;
  set<int> integers;
  
  for (int loop = 0; loop < num_query; loop++) {
    int command, x; scanf("%d %d", &command, &x);
    
    switch (command) {
      case 0:
        integers.insert(x);
        printf("%d\n", integers.size());
        break;
        
      case 1:
        printf("%d\n", integers.count(x));
        break;
        
      case 2:
        integers.erase(x);
        break;
    }
  }
}


Measured memory_bytes: 12524
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <algorithm>

#define MAX_N 100002
using ll = long long;
using namespace std;
priority_queue< ll, vector<ll> > maxque;
priority_queue< ll, vector<ll> , greater<ll> > minque;
ll left_max[MAX_N];
ll right_min[MAX_N];
ll res = -100000000000001;

int data[MAX_N*3];
int n;
void solve()
{
    ll currsum=0;
    //clear heap
    while(!minque.empty())minque.pop();
    //put 0~n-1 to heap 
    for(int i = 0;i<n;i++){minque.push(data[i]);currsum+=data[i];}
    for(int i = n;i<=2*n;i++){
        left_max[i-n] = currsum;
        if(minque.top()<data[i]){
            currsum+=(data[i]-minque.top());
            minque.pop();
            minque.push(data[i]);
        }
    }
    currsum = 0;
    while(!maxque.empty())minque.pop();
    //put 2n~3n-1 to heap
    for(int i = 2*n;i<3*n;i++){maxque.push(data[i]);currsum+=data[i];}
    for(int i = 2*n-1;i>=n-1;i--){
        right_min[i-(n-1)] = currsum;
        if(maxque.top()>data[i]){
            currsum-=(maxque.top()-data[i]);
            maxque.pop();
            maxque.push(data[i]);
        }
    }
    for(int i = 0;i<=n;i++){
        res = max(res,left_max[i]-right_min[i]); 
    }
}


int main()
{
    cin>>n;
    for(int i = 0;i<3*n;i++)cin>>data[i];
    solve();
    cout<<res<<endl;
}


Measured memory_bytes: 4724
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int n=in(),m,i,j,ans=0,x;
	char s[100][15],t[100][15];
	rep(i,n)chin(s[i]);
	m=in();
	rep(i,m)chin(t[i]);
	rep(i,n){
		x=0;
		rep(j,n)if(strcmp(s[i],s[j])==0)x++;
		rep(j,m)if(strcmp(s[i],t[j])==0)x--;
		ans=max(ans,x);
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> a(n);
    for (int i = 0; i < m; ++i) {
        int p, q, r;
        cin >> p >> q >> r;
        a[p].emplace_back(q, r);
        a[q].emplace_back(p, r);
    }
    vector<vector<long long>> b(n, vector<long long>(2, 1ll << 62));
    for (int i = 0; i < 2; ++i) {
        b[i ? n - 1 : 0][i] = 0;
        using P = pair<long long, int>;
        priority_queue<P, vector<P>, greater<P>> q;
        for (q.emplace(0, i ? n - 1 : 0); q.size(); ) {
            auto p = q.top();
            q.pop();
            if (p.first > b[p.second][i]) continue;
            for (auto r : a[p.second]) {
                long long d = p.first + r.second;
                if (b[r.first][i] > d) {
                    b[r.first][i] = d;
                    q.emplace(d, r.first);
                }
            }
        }
    }
    sort(b.begin(), b.end());
    int l = int(sqrt(n));
    vector<long long> c;
    vector<vector<pair<long long, long long>>> d(1);
    for (auto& p : b) {
        d.back().emplace_back(p[1], p[0]);
        if (d.back().size() == l) {
            d.emplace_back();
            c.emplace_back(p[0]);
        }
    }
    if (d.back().size()) {
        c.emplace_back(b.back()[0]);
    } else {
        d.pop_back();
    }
    for (auto& e : d)
        sort(e.begin(), e.end());
    int q;
    cin >> q;
    while (q--) {
        long long a, b;
        cin >> a >> b;
        int sm = 0;
        int j = 0;
        for (; j < c.size() && c[j] <= a; ++j)
            sm += d[j].end() - lower_bound(d[j].begin(), d[j].end(), b,
                [](const pair<long long, long long>& m, long long v) {
            return m.first < v;
        });
        if (j < c.size()) {
            for (auto& p : d[j])
                sm += p.first >= b && p.second <= a;
        }
        cout << sm << endl;
    }
    return 0;
}

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

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

	if (S == T) {
		cout << "No" << endl;
	}
	else {
		for (int i = 0; i < S.size(); i++) {
			if (S[i] != T[i]) {
				cout << "No" << endl;
				return 0;
			}
		}

		cout << "Yes" << endl;
	}
}

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

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

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

  sort(A.begin(), A.end());
  int ans = A[0];
  for (int i = 1; i < N; i++)
  {
    ans = gcd(ans, A[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <queue>
using namespace std;

int N, K;
string S;

int main() {
    cin >> N >> K;
    cin >> S;
    if (S[K-1] == 'A') S[K-1] = 'a';
    if (S[K-1] == 'B') S[K-1] = 'b';
    if (S[K-1] == 'C') S[K-1] = 'c';

    cout << S << endl;

    return 0;
}

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

 using namespace std;

int main()
{
    int n,k,i;
    char a[15];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    cin>>k;
    for(i=0;i<n;i++)
    {
        if(a[i]==a[k-1])
            cout<<a[i];
        else cout<<"*";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
N = int(input())
D = list(map(int, input().split()))
D = sorted(D)

counter = 0
for i in range(D[N // 2], D[N // 2 - 1], -1):
    counter += 1

print(counter)



# def main():

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


Measured memory_bytes: 14536
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

    int n,m; cin >> n >> m;
    int a[2][m];
    rep(i,m) cin >> a[0][i] >> a[1][i];
    
    int lmax = 0;
    int rmin = 1e9;
    
    rep(i,m) chmax(lmax, a[0][i]);
    rep(i,m) chmin(rmin, a[1][i]);
    
    if(rmin -lmax < 0) cout << 0 << ln;
    else  cout << rmin - lmax + 1 << ln;
    
    return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <boost/range/algorithm.hpp>
#include <boost/integer/common_factor_rt.hpp>

using namespace std;

int N, D;
int main() {
    while (cin >> N >> D) {
        cout << (N + 2 * D) / (2 * D + 1)  << endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  
  int sum = 0;
  sort(L.begin(), L.end());
  for (int i = 0; i < N - 2; i++) {
    for (int j = i+1; j < N - 1; j++) {
      for (int k = j+1; k < N; k++) {
        if (L.at(i) + L.at(j) > L.at(k)) {
          sum++;
        } else {
          break;
        }
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
using namespace std;
const int INF=LLONG_MAX-1e10;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;
int Pow(int a, int b) {
    int ans = 1, base = a;
    while (b != 0) {
        if (b & 1 != 0)
            ans *= base;
        base *= base;
        b >>= 1;
    }
    return ans;
}
vc<P> have;
main()
{
    IOS
    cin>>n;
    fu(i,-300,300)
    {
        have.pb({Pow(i,5),i});
    }
    fa(i,have)
    {
        fa(j,have)
        {
            if(i.fi-j.fi==n)
            {
                cout<<i.se<<" "<<j.se;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3692
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]
ans = []
for i in range(h):
    for j in range(w):
        c = 0
        if s[i][j]=='.':
            for k in range(-1,2):
                for l in range(-1,2):
                    if 0<=i+k<h and 0<=j+l<w:
                        if s[i+k][j+l]=='#':c+=1
        else:c='#'
        ans.append(str(c))
for i in range(h):
    print(''.join(ans[i*w:(i+1)*w]))

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

#define NMAX 100
#define MMAX 20
vector<int> b[NMAX];
int _parent[NMAX];
int _d[NMAX];
int _isin[NMAX]; 

void search(int c, int p, int d)
{
    _d[c] = d;
    _parent[c] = p;
    for( auto itr = b[c].begin(); itr != b[c].end(); itr++ )
    {
        if( *itr != p ) 
        {
            search(*itr, c, d + 1);
        }
    }
}

void check(int p1, int p2, int j)
{
    if( p1 == p2 ) return;
    int d = max( _d[p1], _d[p2] );
    int n1 = p1; int n2 = p2;
    if( _d[p1] == d )
    {
        _isin[p1] |= (1 << j);
        n1 = _parent[p1];
    }
    if( _d[p2] == d )
    {
        _isin[p2] |= (1 << j);
        n2 = _parent[p2];
    }    
    check( n1, n2, j);
}
 
int main()
{
    _LL n;
    cin >> n;
    for(int i = 0; i < n - 1; i++ )
    {
        int u, v;
        cin >> u >> v;
        u--; v--;
        b[u].push_back(v);
        b[v].push_back(u);
    }
    search(0, -1, 0);
    int m;
    cin >> m;
    rep(i, n) _isin[i] = 0;

    rep( j , m )
    {
        int u, v;
        cin >> u >> v;
        u--; v--;
        check(u, v, j);
    }

    _LL ans = (1LL << (n - 1));

    rep(bit, 1 << m)
    {
        if( bit == 0 ) continue;
        _LL count = 0;
        rep(i, n - 1)
            if( (_isin[i + 1] & bit) ) count++;
        _LL bitcount = 0;
        rep(i, m)
            if( bit & (1 << i) ) bitcount++;
        
        if( bitcount % 2 == 1 )
        {
            ans -= (1LL << (n - count - 1));
        }
        else
        {
            ans += (1LL << (n - count - 1));
        }    
    }
    cout << ans;
}

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

namespace ALDS1_10_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            Console.WriteLine(Fib(n).ToString());
        }

        private static long Fib(int n)
        {
            long[] dp = new long[n+1];
            for (int i = 0 ; i <= n ; i++)
            {
                if (i == 0 || i == 1)
                {
                    dp[i] = 1;
                }
                else
                {
                    dp[i] = dp[i - 1] + dp[i - 2];
                }
            }
            return dp[n];
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



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

int main(){
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(s==u)
    cout<<a-1<<' '<<b<<endl;
    if(t==u)
    cout<<a<<' '<<b-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    for(vi l(3); cin >> l[0], l[0];){
        COUNT(i, 2) cin >> l[i];
        sort(ALL(l));
    
        int n; cin >> n;
        while(n --){
            int r; cin >> r;
            cout << ((pow(l[0] / 2, 2.) + pow(l[1] / 2, 2.) < pow(r, 2.)) ? "OK":"NA") << endl;
        }
    }
 
    return 0;
}

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


int main()
{
	int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	c *= 2;
	cout << min(a+b,c)*min(x,y)+(x>y?min(a,c):min(b,c))*abs(x-y) << endl;
}



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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define in_range(x,l,r) (lb(all(x),r+1)-lb(all(x),l))
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define Rep(i,n) for (int i=0;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define fore(i,x) for (auto &i:x)
#define cmax(x,y) x=max(x,y)
#define cmin(x,y) x=min(x,y)
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;

string s;
int c;

int main(){
	cin>>s;
	fore(i,s){
		if (i=='x') c++;
	}
	if (c>7) cout<<"NO"<<endl; else cout<<"YES"<<endl;
	re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q, W, H, L, R, C;
string S;

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

    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i) >> B.at(i);
        sum += A[i];
    }

    ll tmp = 1e18;
    bool flag = true;
    for (int i = 0; i < N; i++) {
        if (A[i] != B[i]) flag = false;
        if (A[i] > B[i]) {
            chmin(tmp, B[i]);
        }
    }
    if (flag) {
        cout << 0 << endl;
    } else {
        cout << sum - tmp << endl;
    }

    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------

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

	int m;cin>>m;
	cout<<48-m<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
vector<pair<int,int> > pi;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    itn a,b;
    cin>>a>>b;
    for(int i=0;i<max(a,b);i++){
      cout<<min(a,b);
    }
    cout<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
	if(a<b){
		printf("a < b\n");
	}
	return 0;
}

Measured memory_bytes: 2604
n= int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n-1,-1,-1):
    ab[i][0]+=ans
    if ab[i][0]%ab[i][1]!=0:
        ans+=ab[i][1]-(ab[i][0]%ab[i][1])
print(ans)

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

using namespace std;

template <std::uint_fast64_t Modulus> class ModInt {
  using u64 = std::uint_fast64_t;

public:
  u64 x;

  constexpr ModInt(const u64 x = 0) noexcept : x(x % Modulus){};

  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    x += rhs.x;
    if (x >= Modulus) {
      x -= Modulus;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (x < rhs.x) {
      x += Modulus;
    }
    x -= rhs.x;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    x = x * rhs.x % Modulus;
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt rhs) noexcept {
    u64 n = Modulus - 2;
    while (n) {
      if (n & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      n /= 2;
    }
    return *this;
  }

  friend std::istream &operator>>(std::istream &is, ModInt &rhs) {
    is >> rhs.x;
    return is;
  }
  friend std::ostream &operator<<(std::ostream &os, const ModInt &rhs) {
    os << rhs.x;
    return os;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  using mint = ModInt<1000000007>;
  int N, X;
  cin >> N >> X;
  vector<int> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  vector<vector<mint>> dp(N + 1, vector<mint>(X + 1));
  for (int i = 0; i < X + 1; i++) {
    dp[0][i] = i;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < X + 1; j++) {
      dp[i + 1][j] = dp[i][j] * i + dp[i][j % S[i]];
    }
  }
  cout << dp[N][X] << '\n';
  return 0;
}


Measured memory_bytes: 158592
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        UnionFind uf = new UnionFind(n+1);
        for(int i = 0; i < m; i++){
            uf.unite(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
        }
        var set = new HashSet<Integer>();
        for(int i = 1; i <= n; i++){
            set.add(uf.root(i));
        }
        System.out.println(set.size() -1);
    }
    
    static class UnionFind {
        int[] parent, size;
        
        public UnionFind(int n) {
            parent = new int[n];
            size = new int[n];
            for(int i = 0; i < n; i++){
                parent[i] = i;
                size[i] = 1;
            }
        }
        int root(int x){
            if(parent[x] == x){
                return x;
            }else{
                return parent[x] = root(parent[x]);
            }
        }
        void unite(int x, int y){
            x = root(x);
            y = root(y);
            if(x == y) return;
            
            if(size[x] < size[y]){
                parent[x] = y;
                size[y] += size[x];
            }else{
                parent[y] = x;
                size[x] += size[y];
            }
        }
        boolean same(int x, int y){
            return root(x) == root(y);
        }
    }
}

Measured memory_bytes: 60024
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())

using namespace std;
using ll = int64_t;

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

  int H, W, N;
  cin >> H >> W >> N;
  int ans = min((H + N - 1) / H, (W + N - 1) / W);
  cout << ans << endl;

  return 0;
}


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


const int len = 2 * 1e5+5;

int h[len];

int main(void)
{
	long long H;
	int cnt = 0;
	scanf("%lld", &H);
	while (H)
	{
		++cnt;
		H >>= 1;
	}
	printf("%lld", (long long)(pow(2, cnt) - 1));

}

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

int main()
{
    int n, m, p, x;
    cin >> n;
    int t[n+2] = {};
    for(int i = 1; i <= n; i++) cin >> t[i];
    cin >> m;
    while(m--)
    {
        int sum = 0;
        cin >> p >> x;
        for(int i = 1; i <= n; i++){
            if(i == p) sum += x;
            else sum += t[i];
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <cstdio>
#include <float.h>
#include <ctype.h>
using namespace std;
int main(void) {
	int joha,johb,mata,matb,scia,scib,enga,engb,totala,totalb;
	scanf("%d %d %d %d", &joha, &mata, &scia, &enga);
	scanf("%d %d %d %d", &johb, &matb, &scib, &engb);
	totala = joha + mata + scia + enga;
	totalb = johb + matb + scib + engb;
	if (totala >= totalb) {
		printf("%d\n", totala);
	}
	else {
		printf("%d\n", totalb);
	}
	
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int n,m;
int uf[100005];
int q[100005];
pair<int,int> a[100005];
bool u[100005];
int find(int x){
	if(uf[x]<0)return x;
	return uf[x]=find(uf[x]);
}
void join(int x, int y){
	x=find(x);y=find(y);
	if(x==y)return;
	if(uf[x]>uf[y])swap(x,y);
	uf[x]+=uf[y];
	uf[y]=x;
}

int main(){
	memset(uf,-1,sizeof(uf));
	scanf("%d%d",&n,&m);
	fore(i,0,n){
		int x;
		scanf("%d",&x);
		a[i]=mp(x,i);
	}
	sort(a,a+n);
	fore(_,0,m){
		int x,y;
		scanf("%d%d",&x,&y);
		join(x,y);
	}
	if(m==n-1){puts("0");return 0;}
	int t=0;ll s=0;
	fore(i,0,n)if(!q[find(a[i].snd)]){
		t++;q[find(a[i].snd)]++;s+=a[i].fst;u[i]=true;
	}
	fore(i,0,n){
		if(t==2*(n-1-m))break;
		if(u[i])continue;
		if(q[find(a[i].snd)]<n-1-m){
			t++;q[find(a[i].snd)]++;s+=a[i].fst;
		}
	}
	if(t<2*(n-1-m))puts("Impossible");
	else printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 1920
import numpy as np
N = int(input())
restaurants_list = []
for i in range(N):
  name,score = map(str,input().split())
  score = int(score)
  restaurants_list.append([name,score,i+1])
restaurants_list.sort(key = lambda x:x[1],reverse=True) 
restaurants_list.sort(key = lambda x:x[0]) 
for i in range(N):
  print(restaurants_list[i][2])

Measured memory_bytes: 12496
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		int n = sca.nextInt();
		int k = sca.nextInt();
		int[] dk = new int[k];
		boolean[] flag = new boolean[n];
		for(int i = 0; i < n; i++) {
			flag[i] = true;
		}
		int sunume_num = 0;

		for(int i = 0; i < k; i++) {
			dk[i] = sca.nextInt();
			for(int j = 0; j < dk[i]; j++) {
				sunume_num = sca.nextInt();
				flag[sunume_num-1] = false;
			}
		}

		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(flag[i]) {
				ans++;
			}
		}

		System.out.println(ans);

		// 後始末
		sca.close();
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    pair<int, int> MAX(0,0);
    pair<int, int> nextMAX(0,0);
    for (int i = 0; i < N; i++) {
        if (A[i] > MAX.second) {
            MAX = make_pair(i, A[i]);
        }
    }

    for (int i = 0; i < N; i++) {
        if (A[i] > nextMAX.second && i != MAX.first) {
            nextMAX = make_pair(i, A[i]);
        }
    }

    for (int i = 0; i < N; i++) {
        if (i == MAX.first) {
            printf("%d\n", nextMAX.second);
        } else {
            printf("%d\n", MAX.second);
        }
    }

    return 0;
}

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

int main()
{
    int n, x, a[100002], i, b;
    long long sum = 0;
    scanf("%d%d", &n, &x);
    for(i = 0; i<n; i++)
        scanf("%d", &a[i]);
    for(i = 0; i<n-1; i++)
    {
        if(a[i]+a[i+1]>x) break;
    }
    if(i == n-1)
        printf("%d\n", 0);
    else
    {
        for(i = 0; i<n-1; i++)
        {
            if(a[i]+a[i+1]>x)
            {
                b = a[i]+a[i+1]-x;
                a[i+1] -= b;
                if(a[i+1] < 0) a[i+1] = 0;
                sum += b;
            }
        }
        printf("%lld\n", sum);
    }
    return 0;
}


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

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

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2 == 1) cnt++;
    }

    double ans = 1.0 * cnt / n;
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

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

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;
constexpr int MAX = 100000;

struct Graph {
    void addEdge(int from, int to)
    {
        edge[from].push_back(to);
    }
    vector<int> edge[MAX];
};

int N;
Graph g_;
Graph g;

ll grundy(int root)
{
    if (g.edge[root].empty()) {
        return 1;
    } else if (g.edge[root].size() == 1) {
        return grundy(g.edge[root][0]) + 1;
    } else {
        ll num = 0;
        for (const int p : g.edge[root]) {
            num ^= grundy(p);
        }
        return num + 1;
    }
}

int main()
{
    cin >> N;
    for (ll i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g_.addEdge(x, y);
        g_.addEdge(y, x);
    }
    bool check[MAX];
    fill(check, check + MAX, false);
    queue<int> q;
    q.push(0);
    while (not q.empty()) {
        const int p = q.front();
        q.pop();
        check[p] = true;
        for (const int to : g_.edge[p]) {
            if (not check[to]) {
                g.addEdge(p, to);
                q.push(to);
            }
        }
    }

    const ll grundynum = grundy(0);
    if (grundynum == 1) {
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }

    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'


class UnionFind {
public:
  vector<int> parent, size;
  
  UnionFind(int n) {
    parent.resize(n);
    iota(parent.begin(), parent.end(), 0);
    size.resize(n, 1);
  }  
  
  int Find(int x) {
    return x == parent[x] ? x : parent[x] = Find(parent[x]);
  }
  bool Merge(int x, int y) {
    int px = Find(x), py = Find(y);
    if (px == py) return false;
    if (size[px] < size[py]) swap(px, py);
    parent[py] = px;
    size[px] += size[py];
    return true;
  }
};

 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n,m;
  cin >> n >> m;
  vector<vector<int>> adj(n);
  UnionFind uf(n);
  int ans = n-1;
  for (int i = 0; i < m; ++i) {
    int u,v;
    cin >> u >> v;
    --u, --v;
    if (uf.Merge(u,v)) {
      --ans;
    }
  }
  cout << ans << endl;


}


Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,zx,xc;
string s;
map <string, int> m;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    m["SUN"]=1;
    m["MON"]=2;
    m["TUE"]=3;
    m["WED"]=4;
    m["THU"]=5;
    m["FRI"]=6;
    m["SAT"]=7;
    cin>>s;
    cout<<8-m[s];
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 5000

int main(){

 int n,i,j;
 int A[MAX];
 int MaxEndingHere;
 int MaxSoFar;

 while(1){

  scanf("%d",&n);
  if(n==0)break;
  MaxEndingHere=0;
  MaxSoFar=-10000000;


  for(i=0;i<n;i++){
    scanf("%d",&A[i]);

    MaxEndingHere+=A[i];
    if(MaxEndingHere > MaxSoFar)MaxSoFar=MaxEndingHere;
    if(MaxEndingHere < 0)MaxEndingHere=0;


  }

  printf("%d\n",MaxSoFar);

 }

return 0;
}


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

using ll=long long;
using P=pair<int,int>;

const int MOD=1e9+7;
const int INF=1<<30;
const int MAX=1e5;

int n;

template<class T>
inline void xmin(T &a, T b){a=(a<b)?a:b;}
template<class T>
inline void xmax(T &a, T b){a=(a>b)?a:b;}

double a,b,x;
double L;
double d;
double digX;

bool isOK1(double mid){
    double V=a*a*mid+a*a*(b-mid)/2.0;
    //cout<<V<<" "<<x<<endl;
    if(V<=x)return true;
    else return false;
}

double bins1(double ng=b, double ok=0){
    for(int i=0; i<1000; i++){
        double mid=(ng+ok)/2;
        //cout<<mid<<endl;
        if(isOK1(mid))ok=mid;
        else ng=mid;
        //cout<<ok<<" "<<ng<<endl;
    }
    return ok;
}


bool isOK2(double mid){
    double V=mid*b*a/2.0;
    if(V<=x)return true;
    else return false;
}

double bins2(double ng=a, double ok=0){
    for(int i=0; i<200; i++){
        double mid=(ng+ok)/2;
        if(isOK2(mid))ok=mid;
        else ng=mid;
    }
    return ok;
}

void solve(){
    double ans;
    cin>>a>>b>>x;
    double L=x/(a*a);
    double d=sqrt(a*a+b*b);
    double digX=a*a*b/2.0;
    //cout<<digX<<endl;
    if(digX<=x){
        //cout<<"a"<<endl;
        ans=bins1();
        //cout<<ans<<endl;
        //cout<<b<<endl;
        //cout<<(b-ans)/d<<endl;
        //cout<<acos((b-ans)/d)<<endl;
        ans=atan((b-ans)/a)*45.0/(atan(1));
    }
    else{
        //cout<<"b"<<endl;
        ans=bins2();
        ans=(atan(b/ans))*45.0/(atan(1));
    }
    printf("%.8f\n", ans);
}

signed main(){
    //while(1)
    solve();
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
class Union():
    def __init__(self, n):
        self.par = [i for  i in range(n+1)]
        self.rank = [0]*(n+1)
        self.weight = [0]*(n+1) #子から親までの距離
        
    def find(self, x):
        if self.par[x] == x:
            return x
        y = self.find(self.par[x])
        self.weight[x] += self.weight[self.par[x]]
        self.par[x] = y
        return y
    
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
        
    def same(self, x, y):
        return (self.find(x) == self.find(y))
    
    #ｘからｙへの距離
    def diff(self, x, y):
        if self.same(x,y):
            return self.weight[x] - self.weight[y]
        else:return '?'

n ,q = map(int, input().split())
unite = Union(n)
for i in range(q):
    a, b, c, *d = map(int, input().split())
    if a == 0:unite.union(b,c,d[0])
    else:print(unite.diff(b,c))


Measured memory_bytes: 12540
#include<bits/stdc++.h>
#define ll long long
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
#define Forn(i,x,y) for(int i=x;i<y;i++)
#define oo 1000000
#define zyy 1000000007
#define M 1000000
#define N 200005
using namespace std;
inline int read(){int x=0,f=0;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;return f?-x:x;}
inline void write(ll x){if(x<10) putchar(x+48);else write(x/10),putchar(x%10+48);}
inline void writeln(ll x){if(x<0) putchar('-'),x=-x;write(x);putchar('\n');}
ll ans=1;
int main(){
	int n=read(),m=read();
	if(abs(n-m)>1) return puts("0")&0;
	For(i,1,n) ans=ans*i%zyy;
	For(i,1,m) ans=ans*i%zyy;
	if(n==m) ans=(ans<<1)%zyy;
	writeln(ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,i;
	char c[1000];
	scanf("%d %d",&a,&b);
	for(i=1;i<=b+2;i++)
	printf("#");
	printf("\n");
		for(i=1;i<=a;i++)
	{
	scanf("%s",c);

	printf("\n#%s#\n",c);
}
	for(i=1;i<=b+2;i++)
	printf("#");
	printf("\n");
	return 0;	
} 


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int all = 0;
    int tle = 0;
    
    int power_of_two = 2;
    //(tle * 1900) + ( (all - tle ) * 100) ) * ( 2 ^ tle)
    
    cin >> all;
    cin >> tle;
    
    for(int i = tle - 1;i > 0;i--){
        
        power_of_two *= 2;
        
    }
    
    cout << ( tle * 1900 + (all - tle) * 100 ) * power_of_two << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
#define vi vector<long long>
#define vs  vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
/*bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
*/
int main()
{
    ll x,y,a,W,H,N,t,n,k,p,q,r,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    map<ll,ll>mp;
    vector<ll>v;
      cin>>W>>H>>N;
      ll Xmax=0, Xmin=W;
      ll Ymax=0, Ymin=H;
     while(N--)
    {
      cin>>x>>y>>a;
      if(a==1)
      {
          Xmax=max(Xmax,x);
      }
      else if(a==2)
      {
          Xmin=min(Xmin,x);
      }
      else if(a==3)
      {
          Ymax=max(Ymax,y);
      }
      else if(a==4)
      {
          Ymin=min(Ymin,y);
      }
    }
    p=W-(Xmax+(W-Xmin));
    q=H-(Ymax+(H-Ymin));
      if(p>0 && q>0) cout<<p*q<<endl;
      else cout<<0<<endl;
}





Measured memory_bytes: 3640
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

	//------------------------------------------

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

	//------------------------------------------



	public void exec() throws Exception{
		final int N = sc.nextInt();
		final int A[] = new int[N];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		for(int i=1;i<N;i++) {
			if(A[i-1]==A[i]) {
				out.println("NO");
				return;
			}
		}
		out.println("YES");
	}
}


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

int main() {

  long N, K;
  cin >> N >> K;
  
  vector<long> n(100100);

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

  for (int i = 1; i < 100100; i++) {
    if (K <= n[i]) {
      cout << i << endl;
      break;
    }
    K -= n[i];
  }

}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl; 

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		for (int i = s.length()-1; i >= 2; i--) {
			if (i % 2 != 0) continue;
			if(s.substring(0, i/2).equals(s.substring(i/2,i))){
				System.out.println(i);
				return;
			}
		}
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
//////////////////////////////////

int main() {
    int n; cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    long long ans = 0;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) { cin >> b[i]; ans += b[i]; }
    for(int i=0; i<n-1; i++) cin >> c[i];
    for(int i=0; i<n-1; i++){
        if(a[i]+1 == a[i+1]) {
            ans += c[a[i]-1];
        }
    }
    cout << ans << endl;

    return 0;
}

// EOF


Measured memory_bytes: 256