akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }

int main(){
    ll N;
    cin >> N;
    ll a[N+1];
    umap<ll,ll> x,y;
    vector<ll> v;
    ll ans = 0;
    for(int i=1;i<=N;++i){
        cin >> a[i];
        ll s = a[i]+i;
        ll t = i-a[i];
        ans += x[t];
        ++x[ s ];    
    }

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

Measured memory_bytes: 20020
#include<stdio.h>
#include<iostream>
using namespace std;
int main (){
    int n,x,sum;
    cin >> n;
    x = n;
    for(int i=0; i<9; i++) {
        sum += n % 10;
        n /= 10;
    }
    if ( x % sum == 0 ) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
function main(input) {
  const args = input.split('\n').map(n => parseInt(n, 10));
  const a = args[0],
        e = args[4],
        k = args[5];
  if (e - a <= k) {
    console.log('Yay!');
  } else {
    console.log(':(');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
    int N, M;
    cin >> N >> M;

    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;

    return 0;
}

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        s: chars,
    }
    let ans: usize = s[..s.len() / 2]
        .iter()
        .zip(s[(s.len() + 1) / 2..].iter().rev())
        .map(|(x, y)| if x != y { 1 } else { 0 })
        .sum();
    println!("{}", ans);
}


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

using namespace std;

int main()
{
	// Value
	int rabbit_size = -1;
	vector<int> rabbits_like_list;
	int friend_count = 0;

	// Input
	cin >> rabbit_size;
	rabbits_like_list.resize(rabbit_size);
	for(int i=0;i<rabbit_size;++i){
		cin >> rabbits_like_list.at(i);
		rabbits_like_list.at(i)-=1;
	}

	// Cal
	for(int i=0;i<rabbit_size;++i){
		if(i < rabbits_like_list.at(i) && i == rabbits_like_list.at(rabbits_like_list.at(i))){
			friend_count++;
		}
	}

	// Output
	cout << friend_count << endl;

	// Fin
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> a;
vector<vector<ll>> fMemo, gMemo;

ll INIT = 4e12;

ll f(int i, int j);
ll g(int i, int j);

ll f(int i, int j) {
  if (i == j) return a[i];
  if (fMemo[i][j] != INIT) return fMemo[i][j];
  return fMemo[i][j] = max(a[i] + g(i + 1, j), a[j] + g(i, j - 1));
}

ll g(int i, int j) {
  if (i == j) return -a[i];
  if (gMemo[i][j] != INIT) return gMemo[i][j];
  return gMemo[i][j] = min(-a[i] + f(i + 1, j), -a[j] + f(i, j - 1));
}

int main() {
  cin >> N;
  a.resize(N);
  fMemo.resize(N, vector<ll>(N, INIT));
  gMemo.resize(N, vector<ll>(N, INIT));
  rep(i, N) cin >> a[i];

  cout << f(0, N - 1) << endl;
  return 0;
}


Measured memory_bytes: 141312
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
const int mx = 1000 * 100 + 5;
vector < int > ad[mx];
bool col[mx];
void dfs(int v, int par){
	for(auto u : ad[v]){
		if(u != par){
			dfs(u , v);
			if(col[u])
				continue;
			else if(col[v]){
				cout << "First" << endl;
				exit(0);
			}
			else
				col[u] = col[v] = 1;
		}
	}
	return;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
 	cout.tie(0);
	int n, u, v;
	cin >> n;
	for(int i = 0; i < n - 1; i++){
		cin >> u >> v;
		ad[u].pb(v);
		ad[v].pb(u);
	}
	if(n % 2 == 1){
		cout << "First" << endl;
		return 0;
	}
	col[0] = 1;
	dfs(1 , 0);
	cout << "Second" << endl;
	return 0;
}



Measured memory_bytes: 6400
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int a,b;
	cin>>a>>b;
	if(b==1)cout<<0<<endl;
	else cout<<a-b<<endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

vector<PII> v;

bool cmp(PII x,PII y) {
	return min(x.second,x.first+y.second)>min(y.second,y.first+x.second);
}

int main() {
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++) {
		string s;
		int cnt=0,mn=0;//Reason why mn initializes with 0, because cnt should be negative
		cin>>s;
		for(int j=0;j<s.size();j++) {
			if(s[j]=='(') {
				cnt++;
			}else {
				cnt--;
			}
			mn=min(mn,cnt);
		}
		v.push_back(make_pair(cnt,mn));
		sum+=cnt;
	}
	if(sum!=0) {
		cout<<"No";
		return 0;
	}
	sort(v.begin(),v.end(),cmp);
	int s=0;
	for(int i=0;i<v.size();i++) {
		if(s+v[i].second<0) {
			cout<<"No";
			return 0;
		}
		s+=v[i].first;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 11604
from sys import stdin
from collections import deque

N, K = [int(x) for x in stdin.readline().rstrip().split()]
S = deque([int(x) for x in stdin.readline().rstrip()])

# 0の始点と終点のインデックスリスト
# 始点→終点→始点→終点→...の順
# 従って、必ず偶数個になる（インデックスが偶数の場合は始点で、奇数の場合は終点）
index_list = []
if S[0] == 0:
    index_list.append(0)
    
res = []

for i in range(1, len(S)):
    if S[i] != S[i-1]:
        if S[i] == 0:
            index_list.append(i)
        else:
            index_list.append(i-1)

if S[-1] == 0:
    index_list.append(len(S)-1)

if K < len(index_list) // 2:
    for i in range(len(index_list)//2 - K + 1):
        start = 0
        end = 0
        if i == 0:
            start = 0
        else:
            # 1から始まるところ
            # index_list[2*i-1]は0の終点のインデックス
            start = index_list[2*i-1] + 1
        
        if i == len(index_list)//2 - K:
            end = len(S) - 1
        else:
            # 1で終わるところ
            # index_list[2*(i+K)]は0の始点
            end = index_list[2*(i+K)] - 1

        res.append(end-start+1)


# 全部反転できる
if K >= len(index_list)//2:
    res.append(len(S))

print(max(res))


Measured memory_bytes: 51036
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
using ll = long long;
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}
 ll gcd(ll a, ll b) {
	 if (b == 0) return a;
	 return gcd(b, a % b);
	
}

 ll lcm(ll a, ll b) {
	 ll g = gcd(a, b);
	 return a / g * b; 
 }

//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	double ans = 0, n = 0, m=1, count=0, sum = 0, ch = 0;
	
	bool check = false;
	string s;
	vector<llint> array;
	char c;
	cin >> n;
	ans = n * 2 * 3.1415;
	std::cout << ans << endl;
	
	please AC;
}


Measured memory_bytes: 3832
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
	class Program
	{
		static void Main(string[] args)
		{


			//テンプレート
			//// 整数の入力
			//int a = int.Parse(Console.ReadLine());

			//// スペース区切りの整数の入力
			//string[] input = Console.ReadLine().Split(' ');
			//int b = int.Parse(input[0]);
			//int c = int.Parse(input[1]);

			//// 文字列の入力
			//string s = Console.ReadLine();

			////出力
			//Console.WriteLine(a + b + c + " " + s);

			//A

			string[] input = Console.ReadLine().Split(' ');
			int s = int.Parse(input[0]);
			int w = int.Parse(input[1]);

			if (s <= w)
			{
				Console.WriteLine("unsafe");
			}
			else
			{
				Console.WriteLine("safe");
			}

			Console.ReadLine();

		}
	}
}

Measured memory_bytes: 27528
#include <iostream>
using namespace std;
int main(){
  int p[100000];
  fill(p,p+100000,1);
  p[0]=p[1]=0;
  for(int i = 2 ; i*i < 100000 ; i++){
    if(p[i])for(int j = i*2 ; j < 100000 ; j+=i)p[j] = 0;
  }

  int n;
  while(cin >> n,n){
    for(int i = n ; i >= 5 ; i--){
      if(p[i] == 1 && p[i-2] == 1 ){
	cout << i-2 << " " << i << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1552
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 

int a[LIM]; 
 
int32_t main()
{
	IOS;
	cin>>n;
	forsn(i,1,n+1) cin>>a[i];
	v32 dp(n+1,0),prefix(n+1,0);
	prefix[1]=a[1];
	for(int i=3;i<=n;i+=2) prefix[i]=prefix[i-2]+a[i];

	dp[1]=0;
	for(int i=2;i<=n;i++){
		if(i&1){
			dp[i]=max(dp[i-1],dp[i-2]+a[i]);
		}
		else{
			dp[i]=max(dp[i-2]+a[i],prefix[i-1]);
		}
	}
	cout<<dp[n]<<ln;
}


Measured memory_bytes: 7928
A=[]
B=[]
a=0
i=0
for c in input():
 if"\\"==c:
  A+=[i]
 elif"/"==c and A:
  j=A.pop()
  t=i-j
  a+=t
  while B and B[-1][0]>j:t+=B[-1][1];B.pop()
  B+=[(j,t)]
 i+=1
print(a)
if B:print(len(B),*list(zip(*B))[1])
else:print(0)


Measured memory_bytes: 6504
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N, M;
  cin >> N >> M;

  vll P(N);
  map<ll, ll> m;
  rep(i, N) {
    ll p;
    cin >> p;
    p--;
    P[i] = p;
    m[p] = i;
  }

  vector<vll> to(N);
  rep(i, M) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    to[x].pb(y);
    to[y].pb(x);
  }

  ll ans = 0;
  vll done(N, -1);
  rep(i, N) {
    if (done[i] != -1) continue;

    queue<ll> q;
    q.push(i);

    vll original_index;
    vll numbers;
    while (!q.empty()) {
      ll num = q.front();
      q.pop();

      if (done[num] != -1) continue;
      done[num] = i;

      numbers.pb(num);
      original_index.pb(m[num]);

      rep(j, to[num].size()) {
        q.push(to[num][j]);
      }
    }

    SORT(original_index);
    SORT(numbers);

    vll result;
    set_intersection(ALL(original_index), ALL(numbers),
                     inserter(result, end(result)));
    ans += result.size();
  }
  COUT(ans);

  return 0;
}

Measured memory_bytes: 19696
import collections

def count(s):
    return collections.Counter(s).most_common()

N = int(input())
S = []
for i in range(N):
    S.append(input())

ret = count(S)

max_ = 0
for i in ret:
    max_ = max(i[1], max_)
    
ans = []
for i in ret:
    if i[1] == max_:
        ans.append(i[0])
        
ans = sorted(ans)
for i in ans:
    print(i)

Measured memory_bytes: 120272
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[300][300];
	bool owari = 0;
	rep(i, N) rep(j, N) A[i][j] = getint();
	rep(i, N) A[i][i] = 1e9;

	ll kotae = 0;
	rep(i, N) {
		rep(j, i) {
			auto a = A[i] + j;
			auto b = A[i];
			auto c = A[j];
			bool B = 1;
			rep(k, N) {
				if (*a > b[k] + c[k]) {
					printf("-1");
					return 0;
				}
				else if (*a == b[k] + c[k]) B = 0;
			}
			if (B) kotae += *a;
		}
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<ll, ll> P;

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

  multiset<ll> st1, st2;
  ll B = 0;
  ll mn = 0;
  vector<P> ans;

  int q;
  ll a, b;

  for(int i = 0; i < Q; i++){
    cin >> q;
    if(q == 1){
      cin >> a >> b;
      B += b;

      //aをセットについか
      if(i == 0){
        st1.insert(a);
        continue;
      }

      if((int)st1.size() == (int)st2.size() + 1){
        //st1の一番大きい数c
        auto itr = st1.end();
        itr--;
        ll c = *itr;
        if(c <= a) st2.insert(a);
        else {
          st1.erase(itr);
          st1.insert(a);
          st2.insert(c);
        }

        mn += abs(a - c);
      }
      else {
        //st2の先頭c
        auto itr = st2.begin();
        ll c = *itr;

        if(a < c){
          st1.insert(a);
          auto it2 = st1.end();
          it2--;
          ll d = *it2;
          mn += abs(a - d);
        } else {
          st2.erase(itr);
          st1.insert(c);
          st2.insert(a);
          mn += abs(a - c);
        }
      }
    }
    else {
      ll ind = *(--st1.end());
      ans.push_back(P(ind, mn + B));
      //cout << *(--st1.end()) << " " << mn + B << endl;
    }
  }

  for(auto it = ans.begin(); it != ans.end(); it++){
    cout << it -> first << " " << it -> second << endl;
  }

  return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str1=scan.next();
		String str2=scan.next();
		int a=Integer.parseInt(str1);
		int b=Integer.parseInt(str2);
		System.out.println(a*b +" "+ 2*(a+b));
	}

}


Measured memory_bytes: 26012
#include<stdio.h>
#include<string.h>
#define rep(i,n) for(i=0;i<n;i++)
int main(void)
{
  int a[10],s,n,i,j,k,ss;
  for(;;){
    scanf("%d",&n);if(!n)break;
    memset(a,0,sizeof(a));
    ss=0;
    rep(i,n){
      s=0;
      rep(j,n){
	scanf("%d",&k);
	printf("%5d",k);
	s+=k;a[j]+=k;
      }
      printf("%5d\n",s);
      ss+=s;
    }
    rep(i,n)printf("%5d",a[i]);
    printf("%5d\n",ss);
  }
  return 0;
}

Measured memory_bytes: 0
kuchi, needed_kuchi_num= map(int,input().split())
if needed_kuchi_num != 1:
    socket_num = 1

    con_flg = 1
    available_kuchi_num = 0

    while con_flg == 1:
        available_kuchi_num = (kuchi - 1)*(socket_num - 1) + kuchi
        if needed_kuchi_num <= available_kuchi_num:
            con_flg = 0
        else:
            socket_num += 1
else:
    socket_num = 0

print(socket_num)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? ((x) : -(x)))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
char str[105];

int main()
{
	int i, j;
	scanf("%s", str);
	N = 0;
	while (str[N] != 0) ++N;
	int cnt = 0;
	for (i = 0; i < N/2; ++i) {
		if (str[i] != str[N  - 1 - i]) ++cnt;
	}
	printf("%d", cnt);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200005],t[200005];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	t[0]=0;
	int ans=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]>a[i-1])
			t[i]=t[i-1]+1;
		else
			t[i]=0;
		if(t[i]>=k-1)
			ans=1;
	}
	set<int>s;
	for(int i=0;i<k;i++)
		s.insert(a[i]);
	if(t[k-1]!=k-1)
		ans++;
	for(int i=k;i<n;i++)
	{
		s.insert(a[i]);
		if(*s.begin()!=a[i-k]||*s.rbegin()!=a[i])
		{
			if(t[i]<k-1)
				ans++;
		}
		s.erase(a[i-k]);
	}
	cout<<ans;
 
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<sstream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
using namespace std;
long v[12]={1,3,1,2,1,2,1,1,2,1,2,1};
int main()
{
    long a,b;
 
    cin>>a>>b;
    if(v[a-1]==v[b-1])cout<<"Yes";
    else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
string s;
  int n,a=0;
  cin>>n>>s;
  if(n%2!=0){
    cout<<"No\n";
  }else{
    for(int i=0;i<n/2;i++){
      if(s[i]==s[n/2+i]){
         a++;
      }
    }
   if(a==n/2){
     cout<<"Yes\n";
   }else{
     cout<<"No\n";
   }
  }
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
typedef unsigned long long int64;

inline int64 solve(int64 n) {
    int64 i, x, ans = 0;
    if (n <= 0)
        return 0;
    else if ((n & 3) == 1 or (n & 3) == 2)
        ans |= 1;
    for (i = 2; i << 1; i <<= 1) {
        x = n % (i << 1);
        if (x >= i and !(x & 1))
            ans |= i;
    }
    return ans;
}

int main() {
    int64 i, a, b, x, ans = 0;

    scanf("%lld %lld", &a, &b);
    printf("%lld\n", solve(b) ^ solve(a - 1));
}
/*
1	2	3	4	5	6	7	8
001 010 011 100 101 110 111 000
0	1	2	3	4	5	6	7
000 001 010 011 100 101 110 111
*/

Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int N=0,i,k=0,j,M=0,L=0;
  char c[100],d[100];
  for(i=0;i<100;i++){
    c[i]='0';
  }
  for(i=0;i<100;i++){
    d[i]='0';
  }
  scanf("%s", c);
  scanf("%s", d);
  for(i=0;i<100;i++){
    if(c[i]=='0'){
      N=i-1;
      break;
    }
  }
  if(N==0){
    N=100;
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(c[i]!=d[j]){
      }
      else if(c[i]==d[j]){
        for(k=0;k<N;k++){
          if(c[i+k-M]!=d[j+k-L]){
            break;
          }
          if(i+k==N-1){
            M=N;
          }
          if(j+k==N-1){
            L=N;
          }
        }
        if(k==N){
          printf("Yes\n");
          return 0;
        }
      }
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define SZ(s) ((int)(s.size()))
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ALL(a) (a).begin(), (a).end()
typedef pair<int,int> PI;

const int MAX_N = 1e5 + 10;


struct BIT{
  vector<int> bit;
  const int n;
  BIT(int N):bit(N), n(N){};
  void add(int i, int v){
    for(; i < n; i |= i+1)
      bit[i] += v;
  }

  int sum(int i){
    int res = 0;
    --i;
    for(; i >= 0; i = (i & (i+1)) -1)
      res += bit[i];
    return res;
  }

  int sum(int a, int b){
    return sum(b) - sum(a);
  }

  int get(int a){
    return sum(a+1) - sum(a);
  }

  void setv(int i, int v){
    add(i, v- get(i));
  }
};

int in[MAX_N];

vector<pair<PI,PI> > query[MAX_N];

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  vector<int> so;
  rep(i, n){
    cin >> in[i];
    so.pb(in[i]);
  }
  sort(ALL(so));
  so.erase(unique(ALL(so)), so.end());

  int q;
  cin >> q;
  const int blocksz = 400;
  
  rep(i, q){
    int l, r, e;
    cin >> l >> r >> e;
    --l;
    query[r/blocksz].pb(mp(mp(-l,r),mp(i,e)));
  }
  
  vector<int> ans(q);

  rep(i, n){
    if(query[i].empty()) continue;
    sort(ALL(query[i]));
    BIT bi(n+10);
    int sidx = i * blocksz;
    // [sidx, block * i)
    for(auto e : query[i]){
      int l = -e.F.F;
      int r = e.F.S;
      int aidx = e.S.F;
      int err = e.S.S;
      int a = min(in[l], in[r-1]);
      int b = max(in[l], in[r-1]);
      while(l < sidx){
        --sidx;
        int idx = lower_bound(ALL(so), in[sidx]) - so.begin();
        bi.add(idx, 1);
      }
      int cl = max(l, i * blocksz);
      int nhazure = 0;
      while(cl < r){
        nhazure += a - err <= in[cl] && in[cl] <= b + err;
        ++cl;
      }

      int minidx = lower_bound(ALL(so), a-err) - so.begin();
      int maxidx = lower_bound(ALL(so), b+err) - so.begin();
      while(minidx > 0 && so[minidx-1] >= a-err) --minidx;
      while(minidx < n && so[minidx] < a-err) ++minidx;
      while(maxidx >= 0 && so[maxidx] > b + err) --maxidx;
      while(maxidx + 1 < n && so[maxidx+1] <= b + err) ++maxidx;
      nhazure += bi.sum(minidx, maxidx+1);
      ans[aidx] = r - l - nhazure;
    }
  }

  rep(i, q) cout << ans[i] << endl;
  
  return 0;
}

Measured memory_bytes: 7312
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M, vector<int>());
    for (int m = 0; m < M; m++) {
        int k;
        cin >> k;
        for (int i = 0; i < k; i++) {
            int t;
            cin >> t;
            t--;
            s[m].push_back(t);
        }
    }

    vector<int> p(M);
    for (int m = 0; m < M; m++) {
        cin >> p[m];
    }

    int ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        int n = i;
        vector<int> on(N, false);
        for (int j = 0; j < N; j++) {
            if (n % 2 == 1)
                on[j] = true;
            n /= 2;
        }

        int cnt = 0;
        for (int m = 0; m < M; m++) {
            int tmp = 0;
            for (int t : s[m]) {
                if (on[t]) {
                    tmp++;
                }
            }
            if (tmp % 2 == p[m]) {
                cnt++;
            }
        }
        if (cnt == M) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<set>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

int n;
int a[200010];

bool cmp(int a,int b)
{
    return a>b;
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    sort(a+1,a+n+1,cmp);
    int c=0;
    ll ans=0;
    for(int i=1;i<=n;++i)
    {
        if(c!=n-1)
        {
            ans+=a[i];
            c++;
        }
        if(c!=n-1&&i!=1)
        {
            ans+=a[i];
            c++;
        }
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 4356
from bisect import bisect_right, bisect_left
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    B = [int(i) for i in readline().split()]
    C = [int(i) for i in readline().split()]

    A.sort()
    B.sort()
    C.sort()

    ans = 0
    for b in B:
        ans += bisect_left(A, b) * (N - bisect_right(C, b))

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22592
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
ll fac[8010],inv[8010],ans=0;
int n;
int a[200010],b[200010],f[4010][4010];
ll C(int x,int y){return fac[x]*inv[y]%mod*inv[x-y]%mod;}
int main()
{
    fac[0]=fac[1]=inv[0]=inv[1]=1;
    for (int i=2;i<=8000;i++) fac[i]=i*fac[i-1]%mod,inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    for (int i=2;i<=8000;i++) inv[i]=inv[i]*inv[i-1]%mod;
    scanf("%d",&n);
    for (int i=1;i<=n;i++) 
    {
        scanf("%d%d",&a[i],&b[i]);
        f[2000-a[i]][2000-b[i]]++;
    }
    for (int i=0;i<=4000;i++) for (int j=0;j<=4000;j++)
    {
        if (i) f[i][j]+=f[i-1][j];if (f[i][j]>=mod) f[i][j]-=mod;
        if (j) f[i][j]+=f[i][j-1];if (f[i][j]>=mod) f[i][j]-=mod;
    }
    for (int i=1;i<=n;i++) 
    {
        ans+=f[2000+a[i]][2000+b[i]];if (ans>=mod) ans-=mod;
        ans-=C((a[i]+b[i])<<1,a[i]<<1);
        if (ans<0) ans+=mod;
    }
    ans=ans*inv[2]%mod;
    cout<<ans;
}

Measured memory_bytes: 64768
from sys import stdin
 
N = int(input())
H = [int(x) for x in stdin.readline().rstrip().split()]
 
c = 1
for i in reversed(range(1,N)):
  if H[i] - H[i-1] >= 0 and H[i] == max(H[:i+1]):
    c += 1
 
print(c)

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
     ifstream in("input.txt");
     cin.rdbuf(in.rdbuf());
  //*/
  int N, D, X;
  cin >> N >> D >> X;
  int ans = 0;
  D--;
  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    ans++;
    ans += D / A;
  }
  cout << ans + X <<endl;
}


Measured memory_bytes: 3620
local h, w = io.read("*n", "*n", "*l")
local a, b = {}, {}
for i = 1, h do
  a[i], b[i] = {}, {}
  local s = io.read()
  for j = 1, w do
    local z = s:sub(j, j) == "#"
    if i == 1 then
      a[i][j] = true
      b[i][j] = false
    elseif i == h then
      a[i][j] = false
      b[i][j] = true
    else
      if j % 2 == 0 then
        a[i][j] = true
        b[i][j] = z
      else
        a[i][j] = z
        b[i][j] = true
      end
    end
  end
end
for i = 1, h do
  for j = 1, w do
    io.write(a[i][j] and "#" or ".")
  end
  io.write("\n")
end
io.write("\n")
for i = 1, h do
  for j = 1, w do
    io.write(b[i][j] and "#" or ".")
  end
  io.write("\n")
end


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

typedef struct P {
	int x, y;
	P operator+(const P &r) {
		return{ x + r.x,y + r.y };
	}
} P;

int H, W, ans;
char ch[101][101];
bool dp[101][101];
P D[4] = { {-1,0},{0,-1},{0,1},{1,0} };

inline bool imp(P p) {
	if (p.x >= H || p.x < 0 || p.y >= W || p.y < 0)
		return true;
	return false;
}
int rec(P p, char c) {
	if (dp[p.x][p.y] || imp(p) || c != ch[p.x][p.y]) {
		return 0;
	}
	dp[p.x][p.y] = true;
	for (int i = 0; i < 4; i++) {
		rec(p + D[i], c);
	}
	return 1;
}

int main(){
	while (scanf("%d%d", &H, &W), H != 0) {
		ans = 0;
		for (int i = 0; i < H; i++) {
			scanf("%s", ch[i]);
			fill(dp[i], dp[i] + 101, false);
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				ans += rec({ i,j }, ch[i][j]);
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,t=0,x;
    cin>>n>>m;
    int a[n+1];
    for(int i=1;i<=n;++i)cin>>a[i];
    for(int i=1;i<n;++i)
    {
        for(int j=i+1;j<=n;++j)
        {
            if(a[i]<a[j])
            {
                x=a[i];
                a[i]=a[j];
                a[j]=x;
            }
        }
    }
    for(int i=1;i<=m;++i)t+=a[i];
    cout<<t;
    return 0;
}

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

int main() {
    //cout<<endl;
    int f=0,n,a[100000]={},ans=1,cnt[100000]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    for(int i=0;i<n;i++){
        if(cnt[a[i]]!=2&&a[i]!=0){
            f=1;
            //cout<<cnt[a[i]]<<"__"<<a[i]<<endl;
            break;
        }
    }
    if(f==0){
        for(int i=0;i<n/2;i++){
            ans*=2;
            ans%=1000000007;
        }
    }else{
        ans=0;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
int calc(int x)
{
	int sum=0;
	while(x>0) {
		sum+=x%10;
		x/=10;
	}
	return sum;
}
void solve(long long N){
	int ans=9999;
	for(int a=1; a<N; ++a)  {
		int b=N-a;
		ans=min(ans,calc(a)+calc(b));
	}	
	cout<<ans<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}



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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll w,h,n;cin>>w>>h>>n;
    ll xl = 0,yd = 0,xr = w,yu = h;
    rep(i,n){
        ll x,y,a;cin>>x>>y>>a;
        if(a==1)xl=max(xl,x);
        if(a==2)xr=min(xr,x);
        if(a==3)yd=max(yd,y);
        if(a==4)yu=min(yu,y);  
    }
    ll res = max(0LL,(xr-xl)*(yu-yd));
    if(xr<xl && yu < yd)res=0;
    out(res);
}


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

int main()
{
  int A,B,C,K;
  std::cin>>A>>B>>C>>K;
  
  int64_t result;
  
  if(A>=K)
  {
    result=K;
  }
  else if(A+B>=K)
  {
    result=A;
  }
  else
  {
    result=A-(K-(A+B));
  }
  
  std::cout<<result<<std::endl;
  
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
double r;
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	scanf("%lf",&r);
	printf("%.12lf\n",2.0*pi*r);
	return 0;
}
//do smt instead of nothing! never give up!


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define ul unsigned long long

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

        rep(i,S.length()) if(S[i] != T[i]) dif++;

        cout << dif << endl;

}

Measured memory_bytes: 3860
#include <bits/stdc++.h>  
#define lli long long 
using namespace std; 
long long mod2=1e9+7,mod=998244353;
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 1;
//     if(r<0)return 0;
//     if(n<0)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
long long dp[1<<20],sum[1<<20];
int main() 
{ 
    // fact[0]=1;
    // for(int i=1;i<=2000005;i++)fact[i]=(i*fact[i-1])%mod;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        long long n,k;cin>>n>>k;
        long long l[k],r[k];
        for(int i=0;i<k;i++)cin>>l[i]>>r[i];
        dp[1]=sum[1]=1;
        for(int i=2;i<=n;i++){
            for(int j=0;j<k;j++){
                if(i>l[j])
                dp[i]=(dp[i]+sum[i-l[j]])%mod;
                if(i>r[j]+1)dp[i]=(dp[i]-sum[i-r[j]-1])%mod;
            }
            sum[i]=(sum[i-1]+dp[i]); 
        }        
        if(dp[n]<0)dp[n]+=mod;
        cout<<dp[n]<<"\n";
    }
    return 0; 
} 

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

int main()
{
	int N;
	cin >> N;
	vector<ll> a(N);
	rep(i, N)cin >> a[i];

	map<ll, ll> cnt;
	for (auto num : a)cnt[num]++;

	bool res = false;
	vector<pair<ll, ll>> v;
	for (auto itr : cnt)v.push_back({ itr.second,itr.first });
	sort(v.begin(), v.end());

	if (cnt.size() == 1) {
		if (v[0].second == 0) {
			res = true;
		}
	}

	if (cnt.size() == 2) {
		if (v[0].first * 2 == v[1].first && v[0].second == 0) {
			res = true;
		}
	}

	if (cnt.size() == 3) {
		if (v[0].first == v[1].first && v[0].first == v[2].first
			&& ((v[0].second^v[1].second) == v[2].second)
			) {
			res = true;
		}
	}
	cout << (res ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 7924
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
int a[200005],num[1000006];
int n,ans;
signed main()
{
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		num[a[i]]++;
	}
	for (int i=0;i<n;i++){
		int ok=1;
		for (int j=1;j*j<=a[i];j++){
			if (a[i]%j)  continue;
			//cout<<j<<' '<<a[i]/j<<' '<<num[j]<<' '<<num[a[i]/j]<<'\n';
			if (num[j]>=2 || (num[j]==1 && j!=a[i]))  ok=0;
			if (num[a[i]/j]>=2 || (num[a[i]/j]==1 && j!=1))  ok=0;
		}
		ans+=ok;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 12956
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define INF 10000000
using namespace std;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

signed main(){
    int r;
    cin >> r;
    if(r < 1200) cout << "ABC" << endl;
    else if(r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
deg = {1 : 0, 2: 0, 3: 0, 4: 0}

for i in range(3):
    a, b = map(int, input().split())
    deg[a] += 1
    deg[b] += 1

cnt = 0
for i in range(1, 5):
    if deg[i] % 2 == 1:
        cnt += 1

if cnt == 2:
    print("YES")
else:
    print("NO")


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

const int maxn = 300000, P = 1000000007;
int H, ans, a[maxn], b[maxn];

int main() {
    scanf("%d", &H);
    int L = 1 << (H - 1);
    for (int i = 1; i <= L; i++) {
        scanf("%d", &a[L + i - 1]), a[L + i - 1] += L - 1;
    }
    for (int i = 1; i < L; i++) {
        vector<int> V;
        function<void(int, int)> dfs1 = [&](int pos, int cur) {
            if (pos >= L) {
                for (pos = a[pos]; pos; pos >>= 1) {
                    (b[pos] += cur) %= P, V.push_back(pos);
                    cur = 1LL * cur * pos % P;
                }
                return;
            }
            dfs1(pos << 1, 1LL * cur * (pos << 1) % P);
            dfs1(pos << 1 | 1, 1LL * cur * (pos << 1 | 1) % P);
        };
        dfs1(i << 1, 1LL * i * (i << 1) % P);
        function<void(int, int)> dfs2 = [&](int pos, int cur) {
            if (pos >= L) {
                int sum = 0;
                for (pos = a[pos]; pos; pos >>= 1) {
                    cur = 1LL * cur * pos % P;
                    ans = (ans + 1LL * b[pos] * cur % P) % P;
                    ans = (ans - 1LL * pos * sum % P + P) % P;
                    sum = (1LL * sum * pos % P * pos % P + (1LL * b[pos] * cur %
                        P - 1LL * pos * sum % P + P) * pos) % P;
                }
                return;
            }
            dfs2(pos << 1, 1LL * cur * (pos << 1) % P);
            dfs2(pos << 1 | 1, 1LL * cur * (pos << 1 | 1) % P);
        };
        dfs2(i << 1 | 1, i << 1 | 1);
        for (int x : V) b[x] = 0;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 13172
a, b, m = STDIN.gets.split.map(&:to_i)
a_price = STDIN.gets.split.map(&:to_i)
b_price = STDIN.gets.split.map(&:to_i)
min_price = a_price.min + b_price.min

m.times do
  m_list = STDIN.gets.split.map(&:to_i)
  v = a_price[m_list[0]-1] + b_price[m_list[1]-1] - m_list[2]
  min_price = v if min_price > v
end
puts min_price




Measured memory_bytes: 18588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define X first
#define Y second
#define pb push_back
#define sz(a) (int)a.size()

void solve();

signed main() {
#ifdef ONPC
    freopen("in.txt", "r", stdin);
#endif // ONPC
    //freopen("time.in", "r", stdin);
    //freopen("time.out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
    return 0;
}

const int N = 1e5 + 5;
int n, m, kek, dist[N];
vector<pair<int, int>> g[N], gr[N];
bool used[N];
vector<int> ord;

void dfs(int v) {
    used[v] = 1;
    for (auto d : g[v]) {
        if (!used[d.X]) {
            dfs(d.X);
        }
    }
    ord.pb(v);
}

void dfs2(int v) {
    used[v] = 1;
    for (auto d : gr[v]) {
        if (!used[d.X]) {
            dfs2(d.X);
        }
    }
    ++kek;
}

void solve() {
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        g[l].pb({r, d});
        gr[r].pb({l, d});
    }
    for (int i = 1; i <= n; ++i) {
        if (!used[i]) {
            dfs(i);
        }
    }
    reverse(ord.begin(), ord.end());
    memset(used, 0, sizeof used);
    for (auto d : ord) {
        if (!used[d]) {
            kek = 0;
            dfs2(d);
            if (kek > 1) {
                cout << "No\n";
                return;
            }
        }
    }
    for (auto d : ord) {
        if (d == ord[0]) continue;
        dist[d] = -1;
        for (auto t : gr[d]) {
            int nw = dist[t.X] + t.Y;
            if (dist[d] != -1 && nw != dist[d]) {
                cout << "No\n";
                return;
            }
            dist[d] = dist[t.X] + t.Y;
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 16764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    string s,t;
    cin >> s >> t;
    int ans=0;
    rep(i,s.size()){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    int left,right;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==1){
            left=i;
            right=n-i-1;
        }
    }
    int ans=0;
    ans+=(left+k-2)/(k-1);
    ans+=(right+k-2)/(k-1);
    cout<<(left+right+k-2)/(k-1)<<endl;
    return 0;
}


Measured memory_bytes: 3892