akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9 + 7;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;



int main() {
    int x, y;
    cin >> x >> y;
    ++x; ++y;
    if ((x + y - 2) % 3 != 0) {
        cout << 0 << endl;
        exit(0);
    }
    int n = (x + y - 2) / 3;
    if (x < n + 1 || 2 * n + 1 < x) {
        cout << 0 << endl;
        exit(0);
    }
    int r = x - (n + 1);

    modint a = 1;
    for (int i = n; i >= 1; --i) {
        a *= i;
    }
    modint b = 1;
    for (int i = 1; i <= r; ++i) {
        b *= i;
    }
    b = b.pow(mod - 2);
    modint c = 1;
    for (int i = 1; i <= n - r; ++i) {
        c *= i;
    }
    c = c.pow(mod - 2);
    modint ans = a * b * c;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a,b;
  cin >> a >> b;
  if(a=='H' && b=='H'){
    cout << 'H';
  }else if(a=='D' && b=='D'){
    cout << 'H';
  }else{
    cout << 'D';
  }
}


Measured memory_bytes: 256
X, Y, A, B, C = [int(i) for i in input().split()]
reds = sorted([int(i) for i in input().split()], reverse=True)
greens = sorted([int(i) for i in input().split()], reverse=True)
clears = sorted([int(i) for i in input().split()], reverse=True)

clear_acc = [0]

for i in clears:
    clear_acc.append(clear_acc[-1]+i)
        
reds = reds[:X]
greens = greens[:Y]

all_apples = sorted(reds+greens)

apple_sum = [sum(all_apples)]


for i in all_apples:
    apple_sum.append(apple_sum[-1]-i)
    

output = []

for i in range(min(X+Y, C+1)):
    output.append(apple_sum[i] + clear_acc[i])

print(max(output))

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

using namespace std;

int main()
{
	int n, m, a;

	while (true)
	{
		cin >> n >> m >> a;

		if (n == 0 && m == 0 && a == 0) { break; }

		vector<int> amida1(m), amida2(m), amida3(m);

		for (int i = 0; i < m; i++) { cin >> amida1[i] >> amida2[i] >> amida3[i]; }

		int maxh, maxpos, pos = a, posh = 869120;

		while (true)
		{
			maxh = -1, maxpos = -1;

			for (int i = 0; i < m; i++)
			{
				if (amida2[i] == pos)
				{
					if (maxh < amida1[i] && amida1[i] < posh)
					{
						maxh = amida1[i]; maxpos = amida3[i];
					}
				}

				if (amida3[i] == pos)
				{
					if (maxh < amida1[i] && amida1[i] < posh)
					{
						maxh = amida1[i]; maxpos = amida2[i];
					}
				}
			}

			if (maxh == -1)
			{
				break;
			}

			pos = maxpos; posh = maxh;
		}

		cout << pos << endl;
	}

	return 0;
}

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if(N[0] > N[1])
            {
                Console.WriteLine(N[0] - N[1]);
            }
            else
            {
                Console.WriteLine("0");
            }
            
        }
    }
}

Measured memory_bytes: 11092
# A - HonestOrDishonest

# a, bにそれぞれ文字'H','D'が入力されるので、'H'か'D'を判定し出力する


a, b = input().split()

if a == 'H':
    if b == 'H':
        print('H')
    elif b == 'D':
        print('D')
elif a == 'D':
    if b == 'H':
        print('D')
    elif b == 'D':
        print('H')


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



int main(){
  long long a;
  cin >> a;
  string s;
  int keta = 1;
  long long tmp;
  if(a>0){
    s="1";
    tmp=1;
    while (a>tmp){
      keta +=2;
      s="10"+s;
      tmp +=pow(2,keta-1);
    }
  }
  else if(a<0){
    s="10";
    tmp=-2;
    keta=2;
    while(a<tmp){
      keta += 2;
      tmp -= pow(2,keta-1);
      s="10"+s;
    }
  }
  else{
    cout << 0 << endl;
    return 0;
  }
  long long res=abs(tmp-a);
  
  stringstream ss;
  ss<<bitset<64>(res);
  string sabunretu = ss.str();
  int p = s.size();
  int q = sabunretu.size();
  int r = min(p,q);
  string t = s;
  for (int i=0; i<r; i++){
    if(sabunretu[q-1-i]=='1'){
      if(s.at(p-1-i)=='1') s.at(p-1-i)='0';
      else if(s.at(p-1-i)='0') s.at(p-1-i)='1';
    }
  }
  cout << s << endl;    
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main() {
	while(1){
		int n;
		cin >> n;
		if(n == 0)
			break;
	
		vector<string> svec;
		string s;
		cin.ignore();
		for(int i = 0; i < n; ++i){
			getline(cin, s);
			
			stringstream l(s);
			while(l >> s)
				svec.push_back(s);
		}
		sort(svec.begin(), svec.end());
		char c;
		cin >> c;
		map<string, int> count;
		for(unsigned int i = 0; i < svec.size(); ++i){
			if(*svec[i].data() == c)
				count[svec[i]]++;
		}
		
		int r = 0, num = svec.size();
		map<string, bool> is_out;
		while(num > 0 && r < 5){
			for(unsigned int i = 0; i < svec.size(); ++i){
				if(count[svec[i]] == num && !is_out[svec[i]]){
					if(r)
						cout << " ";
					cout << svec[i];
					is_out[svec[i]] = true;
					r++;
				}
				if(r >= 5)
					break;
			}
			num--;
		}
		if(r == 0)
			cout << "NA";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 998244353;
vel kai(4001, 1);
vel ink(4001, 1);
template<typename T>
V<T> uni(V<T> &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	V<T> ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 4000) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 4001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
signed main() {
	string s; cin >> s;
	int ans = 15 - s.size();
	rep(i, s.size()) { if (s[i] == 'o') { ans++; } }
	if (ans >= 8) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>


using namespace std;


template <class ...Args>
void Input(Args &...args)
{
	(cin >> ... >> args);
}

template <class T>
void InputArray(std::size_t size, T &t)
{
	t.resize(size);
	for (auto &e : t) {
		cin >> e;
	}
}

template <class ...Args>
void InputArray(std::size_t size, Args &...args)
{
	(InputArray(size, args), ...);
}

template <class ...Args>
void InputVerticalArray(std::size_t size, Args &...args)
{
	(args.resize(size), ...);
	for (int i = 0; i < size; i++) {
		((cin >> args[i]), ...);
	}
}

template <class ...Args>
void Output(const Args &...args)
{
	((cout << args << ' '), ...) << endl;
}

template <class ...Args>
void OutputVertical(const Args &...args)
{
	((cout << args << endl), ...);
}

template <class T>
void OutputArray(const T &t)
{
	for (const auto &e : t) {
		cout << e << ' ';
	}
	cout << endl;
}

template <class ...Args>
void OutputArray(const Args &...args)
{
	(OutputArray(args), ...);
}

template <class ...Args>
void OutputVerticalArray(const Args &...args)
{
	for (int i = 0; i < min({ args.size()... }); i++) {
		((cout << args[i] << ' '), ...) << endl;
	}
}


#define inp(type, ...) \
	type __VA_ARGS__; \
	Input(__VA_ARGS__)

#define inpa(type, size, ...) \
	type __VA_ARGS__; \
	InputArray((size), __VA_ARGS__)

#define inpva(type, size, ...) \
	type __VA_ARGS__; \
	InputVerticalArray((size), __VA_ARGS__)

#define otp(...) \
	Output(__VA_ARGS__)

#define otpv(...) \
	OutputVertical(__VA_ARGS__)

#define otpa(...) \
	OutputArray(__VA_ARGS__)

#define otpva(...) \
	OutputVerticalArray(__VA_ARGS__)

#define rep(counter, range) \
	for (int (counter) = 0; (counter) < (range); (counter)++)

#define repi(range) \
	rep(i, range)

#define rrep(counter, range) \
	for (int (counter) = (range) - 1; (counter) >= 0; (counter)--)

#define rrepi(range) \
	rrep(i, range)

#define repc(element, container) \
	for (auto &(element) : (container))

#define repe(container) \
	repc(e, container)

#define all(container) \
	(container).begin(), (container).end()

#ifdef __CCR__
#	define dlog(x) clog << #x " = " << x << endl
#else
#	define dlog(x)
#endif



int main()
{
	inp(int, n);
	inpa(vector<int>, n, a);
	
	long long sum = accumulate(all(a), 0ll) % 1000000007;
	long long result = 0;
	repi(n - 1) {
		sum -= a[i];
		if (sum < 0) sum += 1000000007;
		result += a[i] * sum;
		result %= 1000000007;
	}
	
	otp(result);
	
	return 0;
}


Measured memory_bytes: 3672
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main()
{
    IOS;
    int k;
    cin>>k;
    string s="ACL";
    while(k--)
        cout<<s;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




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

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

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.lang.Character;

public class Main {

	public static void main(String[] args) 
	throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String data = TempReaderCall.getStdInRead(br);
		
		char[] cdata = data.toCharArray();
		
		for (int i=0; i<cdata.length; i++){
			if (Character.isLowerCase(cdata[i]))
					cdata[i] = Character.toUpperCase(cdata[i]);
			else if (Character.isUpperCase(cdata[i]))
				cdata[i] = Character.toLowerCase(cdata[i]);
		}
		
		System.out.println(new String(cdata));
	}

}

class TempReaderCall{
	
	static ArrayList<String> getStdInReadlines(BufferedReader br, int line) throws IOException {
		ArrayList<String> list = new ArrayList<String>();
		for (int i = 0; i < line; i++)
			list.add(br.readLine());
		return list;
	}
	
	static String getStdInRead(BufferedReader br) throws IOException {
		return (br.readLine());
	}
	
	
	static int[] splitIntArrayFromString(String st) {
		String[] sts = st.split(" ");
		int[] data = new int[sts.length];
		
		for (int i=0;i<sts.length;i++){
			data[i] = Integer.parseInt(sts[i]);
		}
		
		return data;
	}
}

Measured memory_bytes: 24172
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

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

       
}



Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORS(i,a,b) for(int i=a+1;i<=b;i++)
#define REP(i,N) FOR(i,0,N)
#define REPS(i,N) FORS(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){REP(i,N){REP(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
typedef long long ll;
const int INF=100000000;
//--------------------------------------//

int n,l;
string str[100];
int main(){
	cin>>n>>l;
	REP(i,n) cin>>str[i];
	sort(str,str+n);
	REP(i,n) cout<<str[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc122/tasks/abc122_b

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


int main() {
    string S;
    cin >> S;
    S += 'K';
    int ans = 0;
    int j = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != 'A' && S[i] != 'T' && S[i] != 'G' && S[i] != 'C') {
            ans = max(ans, i - j);
            j = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  vector<pair<int, int>> v(s.size()+1, pair<int, int>(0, 0));
  int cnt = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    char c = s.at(i);
    if (c == '<') {
      cnt++;
    } else {
      cnt = 0;
    }
    v.at(i+1).first = cnt;
  }
  cnt = 0;
  for (int i = (int)s.size()-1; 0 <= i; i--) {
    char c = s.at(i);
    if (c == '>') {
      cnt++;
    } else {
      cnt = 0;
    }
    v.at(i).second = cnt;
  }
  long long res = 0;
  for (const auto& p : v) {
    res += max(p.first, p.second);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 4740
S_list = list(map(int,input().split()))

if  S_list[1] - S_list[0] >= 0 and S_list[2]- S_list[0] >=0 and S_list[1] - S_list[2] >=0:
    result = "Yes"
else:
    result = "No"
print(result)


Measured memory_bytes: 8932
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N, K;
    cin >> N >> K;
    // N = m * K + l
    // N' = l
    cout << min(N%K, K - N%K) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

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

    int div2 = 0;
    rep(i, N) {
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            div2++;
        }
    }

    write(div2);
}

Measured memory_bytes: 256
use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let (mut first, mut second) = (0, n + 1);
    let mut set = HashSet::new();
    let mut reserve = 0;
    for _t in 0..m {
        first += 1;
        second -= 1;
        let (sub, mod_sub) = (abs_sub(first, second), abs_sub(n + first, second));
        let (exist_sub, exist_mod_sub) = (set.insert(sub), set.insert(mod_sub));
        if (!exist_sub && !exist_mod_sub) || sub == mod_sub {
            reserve = second;
            second -= 1;
        };
        println!(
            "{} {}",
            first,
            if second == first { reserve } else { second }
        );
    }
}

fn abs_sub(a: usize, b: usize) -> usize {
    if a > b {
        a - b
    } else {
        b - a
    }
}


Measured memory_bytes: 5480
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define fi first
#define sec second
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;
void solve()
{
    ll n;
    cin>>n;
    cout<<n + n*n +n*n*n;
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    //cin>>t;
    //while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int W, H, N;
	vector<int> X, Y, A;
	int x, y, a;
	cin >> W >> H >> N;
	int i;
	for (i = 0; i < N; i++) {
		cin >> x >> y >> a;
		X.push_back(x);
		Y.push_back(y);
		A.push_back(a);
	}
	int xh, xl, yl, yh;
	xl = 0; xh = W; yl = 0; yh = H;
	for (i = 0; i < N; i++) {
		if (A[i] == 1) {
			xl = max(xl, X[i]);
		}
		else if (A[i] == 2) {
			xh = min(X[i], xh);
		}
		else if (A[i] == 3) {
			yl = max(yl, Y[i]);
		}
		else if(A[i]==4){
			yh = min(yh, Y[i]);
		}
	}

	if ((xh - xl) > 0 && (yh - yl) > 0)
		cout << (xh - xl)*(yh - yl);
	else
		cout << 0;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  vector<int> p(N);
  for(int i = 0; i < N; i++) cin >> p[i];

  int sum = 0;
  for(int i = 0; i < N; i++){
    if(i+1 != p[i]) sum++;
  }

  if(sum == 0 || sum == 2) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}



Measured memory_bytes: 888
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

	readChars(): string[] {
		let S = this.readLine();
		return new Array(S.length).fill(null).map((_, i) => S.charAt(i));
	}

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
} 

function solve() {
	let reader = new Reader();
	let [N, C] = reader.readInts();
	let colourCount: number[][] = new Array(3).fill(null).map(() => new Array(C).fill(0));
	let D: number[][] = [];

	for(let i=0; i<C; i++) {
		D.push(reader.readInts());
	}

	if (N==1) {
		console.log(0);
		return;
	}

	for(let i=0; i<N; i++) {
		let row = reader.readInts().map((c) => c-1);
		for(let j=0; j<N; j++) {
			colourCount[(i+1+j+1)%3][row[j]] += 1;
		}
	}

	let colourCost: number[][] = new Array(3).fill(null).map(() => new Array(C).fill(0));
	for(let i=0; i<3; i++) {
		for(let targetColour=0; targetColour<C; targetColour++) {
			for(let colour=0; colour<C; colour++) {
				colourCost[i][targetColour] += colourCount[i][colour]*D[colour][targetColour];
			}
		}
	}

	let G: number[][][] = new Array(3).fill(null);
	for(let i=0; i<3; i++) {
		let costAndColours = colourCost[i].map((value, index) => [value, index]).sort((a, b) => a[0]-b[0]).slice(0, 3);
		G[i] = costAndColours;
	}

	let minimumCost = Number.POSITIVE_INFINITY;

	for(let i=0; i<3; i++) {
		for(let j=0; j<3; j++) {
			for(let k=0; k<3; k++) {
				if (G[0][i][1] != G[1][j][1] &&
					G[1][j][1] != G[2][k][1] &&
					G[0][i][1] != G[2][k][1]) {
					minimumCost = Math.min(minimumCost, G[0][i][0]+G[1][j][0]+G[2][k][0]);
				}
			}
		}
	}

	console.log(minimumCost);
}

solve();


Measured memory_bytes: 36620
s = input()
A = s.split(' ')
B = [int(i) for i in A]
a, b, c = B[0], B[1], B[2]

if c-a-b <= 0:
    print('No')
else:
    L = 4 * a * b
    R = (c-a-b) ** 2
    print('Yes' if (L < R) else 'No')


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

using namespace std;

int main(){
	string s; cin >> s;
	int n; n=s.size();
	long long ans=0;
	vector<int> dp(n,0);
	for(int i=n-1;i>=0;i--){
		if(s[i]=='A'){
			int j;
			for(j=i+1;j<n && (s[j]!='A');j++){
				if(s[j]!=('C'-((j-i)&1))){
					break;
				}
			}
			if(j<n && s[j]=='A' && ((j-i-1)&1)==0){
				dp[i]=dp[j]+(j-i-1)/2;
			}
			else{
				dp[i]=(j-i-1)/2;
			}
			ans+=dp[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1412
h,w=io.read("*n","*n")
grid={}
for i=1,h+2 do
    grid[i]={}
    if i~=1 and i~=h+2 then
        s=io.read()
    end
    for j=1,w+2 do
        if i==1 or i==h+2 then
            grid[i][j]="."
        else
            if j==1 or j==w+2 then
                grid[i][j]="."
            else
                grid[i][j]=s:sub(j-1,j-1)
            end
        end
    end
end

feasible=true
for i=2,h+1 do
    for j=2,w+1 do
        if grid[i][j-1]..grid[i][j]..grid[i][j+1]==".#." and grid[i-1][j]..grid[i][j]..grid[i+1][j]==".#." then
            feasible=false
        end
    end
end
if feasible then
    print("Yes")
else
    print("No")
end

Measured memory_bytes: 880
#include <bits/stdc++.h>
using namespace std;
int N,K,cnt,ans;
pair<int,int> m[1111][1111];
pair<int,int> dp[1111][1111];
int main(){
    cin>>N>>K;
    for(int i=0;i<N;i++){
        int a,b;
        string c;
        cin>>a>>b>>c;
        if((a/K+b/K+(c=="W"))%2)m[a%K+1][b%K+1].first++;
        else m[a%K+1][b%K+1].second++;
    }
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            dp[i][j].first=m[i][j].first
                +dp[i-1][j].first
                +dp[i][j-1].first
                -dp[i-1][j-1].first;
            dp[i][j].second=m[i][j].second
                +dp[i-1][j].second
                +dp[i][j-1].second
                -dp[i-1][j-1].second;
        }
    }
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            ans=max(ans,
            dp[K][K].first
            -dp[i][K].first
            -dp[K][j].first
            +2*dp[i][j].first
            +dp[i][K].second
            +dp[K][j].second
            -2*dp[i][j].second);
            ans=max(ans,
            dp[K][K].second
            -dp[i][K].second
            -dp[K][j].second
            +2*dp[i][j].second
            +dp[i][K].first
            +dp[K][j].first
            -2*dp[i][j].first);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 18688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
	class Program
	{
		static void Main(string[] args)
		{
			string n;

			n = Console.ReadLine();

			if (n[0] == '9' || n[1] == '9')
				Console.WriteLine("Yes");
			else
				Console.WriteLine("No");

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 13140
#include<stdio.h>
int main() {
    int a,b,e;
    scanf("%d%d",&a,&b);
    e=a%500;
    if(e<=b){
        printf("Yes\n");
    }
    else if(a<500&&a<=b){
        printf("Yes\n");
    } else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // 主処理
        String result = s.replaceAll(".", "x");

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, k, s;
	cin >> n >> k >> s;
	for (int i = 0; i < n; i++){
		if (i < k) cout << s << " ";
		else if (s != 1e9){
			if (i == n-1) cout << s+1 << endl;
			else cout << s+1 << " ";
		} else {
			if (i == n-1) cout << s-1 << endl;
			else cout << s-1 << " ";
		}
	}

}


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

int main() {
 int n;
 cin >> n;
 
 vector<int> a(n);
 rep(i,n) {
  cin >>a.at(i);
  }
  
  int count = 0;
  bool v = true;
   while(v == true) {
    v = false;
     for(int i = n - 1; i >0; i--){
     int b = 0;
      if(a.at(i) < a.at(i-1)) {
      b = a.at(i);
      a.at(i) = a.at(i-1);
      a.at(i-1) = b;
      count++;
      v = true;
       }
       }
     }
 if(n != 1){    
 rep(i,n-1) {
  cout << a.at(i) << ' ';
  }
  cout << a.at(n-1) << endl;
  cout << count << endl;;
  }
  else {
   cout << a.at(0) << endl << 0 << endl;;
   }
}


Measured memory_bytes: 3128
#include <iostream>
#include <cmath>
using namespace std;
const int N=1002;
typedef long long LL;
int n;
LL x[N],y[N];
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
char op[4]={'R','L','U','D'};
void solve(LL x,LL y){
    // 2^k  [0,2^{k+1}-1]
    string ans=""; 
    bool fg=0;
    if((x+y)%2==0)--x,fg=1;
    for(int k=30;k>=0;k--){
        //printf("k=%d,x=%lld,y=%lld\n", k,x,y);
        for(int i=0;i<4;i++){
            LL nx=x+dx[i]*(1LL<<k);
            LL ny=y+dy[i]*(1LL<<k);
            //printf("nx=%lld,ny=%lld\n", nx,ny);
            if(abs(nx)+abs(ny)<=((1LL<<k)-1)) {
                //printf("k=%d\n", k);
                x=nx, y=ny; ans=op[i]+ans;
                break;
            }
        }
    }   
    //printf("%d %d\n", x, y);
    if(fg){
        ans=ans+'R';
    }
    cout<<ans<<endl;

    LL px=0,py=0;
    for(int i=0;ans[i];i++){
        int o=0;
        if(ans[i]=='R')o=1;
        if(ans[i]=='U')o=3;
        if(ans[i]=='D')o=2;
        px+=dx[o]*(1LL<<i);
        py+=dy[o]*(1LL<<i);
    }
    //printf("# %lld %lld\n", px,py);
}
int main() {    
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%lld%lld",&x[i],&y[i]);
    for(int i=1;i<=n;i++){
        if( ((x[i]+y[i])%2==0) != ((x[1]+y[1])%2==0) ) return !printf("-1\n");
    }
    if((x[1]+y[1])%2!=0) {
        printf("31\n");
        for(int i=0;i<=30;i++)printf("%lld ", 1LL<<i);
        printf("\n");
    } else {
        printf("32\n");
        for(int i=0;i<=30;i++)printf("%lld ", 1LL<<i);
        printf("1\n");
    }
    for(int i=1;i<=n;i++){
        solve(x[i],y[i]);
    } 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main() {
  int n;
  cin>>n;
  vector<ll> t(n),x(n),y(n);
  ll tp=0,xp=0,yp=0;
  rep(i,n){
    cin>>t[i]>>x[i]>>y[i];
    if(i==0){
      if(t[i]<x[i]+y[i]){
        cout<<"No"<<endl;
        return 0;
      }
      tp=t[i]; xp=x[i]; yp=y[i];
      continue;
    }
    if(t[i]-tp<abs(x[i]-xp)+abs(y[i]-yp)){
      cout<<"No"<<endl;
      return 0;
    }
    if((t[i]-tp)%2!=(abs(x[i]-xp)+abs(y[i]-yp))%2){
      cout<<"No"<<endl;
      return 0;
    }
    tp=t[i]; xp=x[i]; yp=y[i];
  }
  cout<<"Yes"<<endl;
}

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

int main() {
  int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
  cout<< x2-(y2-y1)<< " "<<y2-(x1-x2)<<" "<<x1-(y2-y1) <<" "<< y1-(x1-x2)<< endl;
}


Measured memory_bytes: 256
N = input()
dp = [[0] * 2 for _ in range(len(N) + 1)]
dp[0][1] = 1

for i in range(len(N)):
    n = int(N[i])
    dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + 10 - n)
    dp[i + 1][1] = min(dp[i][0] + n + 1, dp[i][1] + 10 - (n + 1))

print(dp[-1][0])


Measured memory_bytes: 189924
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;
    auto g = make_vec<int>(n, 0);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (auto v : g[0]) for (auto u : g[v]) if (u == n-1) {
                puts("POSSIBLE");
                return 0;
            }
    puts("IMPOSSIBLE");
}


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

 
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 string s;
 cin>>s;
 int n = s.length();
//  if(s.length)
 int m =0;
 int sum=0;
 while(m!=n){
     int x = s[m]-'0';
    //  cout<<x<<" ";
     m++;
     sum += x;

 }
//  cout<<sum<<" ";
 if(sum%9==0){
     cout<<"Yes"<<endl;
 }else{
     cout<<"No"<<endl;
 }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

const double PI = acos(-1.0);

#define EPS 1.0e-8
#define INF 1.0e12
typedef complex<double> P;
namespace std{bool operator<(const P& a, const P& b){
  return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);
}}
double inP(const P& p, const P& q){ return real(conj(p)*q); } //dot
double outP(const P& p, const P& q){ return imag(conj(p)*q); } //cross
struct L : public vector<P> {
  L(const P& a, const P& b){ push_back(a); push_back(b); }
};
typedef vector<P> G;
int ccw(P a, P b, P c){
  b-=a; c-=a;
  if(outP(b,c)>0) return +1; //counter clockwise
  if(outP(b,c)<0) return -1; //clockwise
  if(inP(b,c)<0) return +2; //c-a-b on line
  if(norm(b)<norm(c)) return -2; //a-b-c on line
  return 0;
}

G convex_hull(vector<P> &ps){
  int n=ps.size(),k=0;
  sort(ps.begin(),ps.end());
  vector<P> ch(2*n);
  for(int i=0;i<n;ch[k++]=ps[i++])
    while(k>=2&&ccw(ch[k-2],ch[k-1],ps[i])<=0)--k;
  for(int i=n-2,t=k+1;i>=0;ch[k++]=ps[i--])
    while(k>=t&&ccw(ch[k-2],ch[k-1],ps[i])<= 0)--k;
  ch.resize(k-1);
  return ch;
}

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

  map<vector<int>, int> memo;
  vector<P> ps;
  rep(i,N){
    int x, y;
    cin >> x >> y;
    ps.push_back(P(x,y));
    memo[{x,y}] = i;
  }
  
  G ch = convex_hull(ps);
  vector<double> ret(N,0);
  int M = ch.size();
  rep(i,M){
    int x = (int)(real(ch[i])), y = (int)(imag(ch[i]));
    int id = memo[{x,y}];

    double x_prev = real(ch[(i-1+M)%M]), y_prev = imag(ch[(i-1+M)%M]);
    double x_next = real(ch[(i+1)%M]), y_next = imag(ch[(i+1)%M]);
    
    double r1 = atan2((double)(y-y_prev), (double)(x-x_prev)) - PI/2.0;
    while(r1<-PI) r1 += 2*PI;
    while(PI<r1) r1 -= 2*PI;
    double r2 = atan2((double)(y_next-y), (double)(x_next-x)) - PI/2.0;
    while(r2<-PI) r2 += 2*PI;
    while(PI<r2) r2 -= 2*PI;

    //cout << id << "\t" << r1 << "\t" << r2 << endl;

    double range = 0;
    if(r1>=0 && r2>0) range = r2-r1;
    else if(r1<0 && r2>=0) range = -r1+r2;
    else if(r1>=0 && r2<0) range = (PI-r1)+(PI+r2);
    else range = r2-r1;
    
    ret[id] = range/(2*PI);
  }
  rep(i,N){
    printf("%.20lf\n", ret[i]);
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;
}

Measured memory_bytes: 256
import heapq

n, *aa = map(lambda x: -int(x), open(0).read().split())

aa.sort(reverse=True)

ans = 0

a = aa.pop()
b = aa.pop()
ans += min(a,b)

hq = [max(a,b)] * 2

heapq.heapify(hq)

while len(aa):
    ans += heapq.heappop(hq)
#     print(ans)
    tmp = aa.pop()
    heapq.heappush(hq, tmp)
    heapq.heappush(hq, tmp)

print(-ans)

Measured memory_bytes: 103944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  //int X; cin >> X;
  int t; cin >> t;
  for(int X=1;X<=179;X++){
    double px=0,py=0;
    int ans = 0;
    double deg = X;
    do{
      px += cos(deg*2*acos(-1)/360);
      py += sin(deg*2*acos(-1)/360);
      deg += X;
      ans++;
    }while(abs(px)>0.00001 || abs(py)>0.00001);
    int ans2=0;
    int now=0;
    rep(i,1000){
      now += X;
      ans2++;
      if(now%360==0) break;
    }
    if(ans^ans2) cout << "!";
    if(X==t) cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3956
W,H,N=map(int,input().split())
x=[0]*N
y=[0]*N
a=[0]*N
for i in range(N):
    x[i],y[i],a[i]=map(int,input().split())
b=[0]
c=[W]
d=[0]
e=[H]
for i in range(N):
    if a[i]==1:
        b.append(x[i])
    if a[i]==2:
        c.append(x[i])
    if a[i]==3:
        d.append(y[i])
    if a[i]==4:
        e.append(y[i])
w=min(c)-max(b)
h=min(e)-max(d)
if w<=0 or h<=0:
    print(int(0))
else:
    print(w*h)

Measured memory_bytes: 3064
#include <cstdio>

#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
int main()
{
	int K, a, b; scanf("%d%d%d", &K, &a, &b);
	long long ans = 1;
	if (b - a > 2)
	{
		int opt = dmin(a - 1, K);
		K -= opt; ans += opt;
		if (ans >= a)
		{
			opt = K / 2;
			ans += 1ll * opt * (b - a);
			K -= opt * 2;
			K ? ++ans : 0;
		}
		printf("%lld\n", ans );
	}
	else printf("%d\n", K + 1 );
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int sumSB(int n,int s[]){

int i,re,min = s[0],max = s[0];

for(i = 0;i < n;i++){
	if(min > s[i]){
		min = s[i];
	}
	
	else if(max < s[i]){
		max = s[i];
	}
	
}

return(min + max);
}

int main(void){
	int n,i,sum = 0,score[128],ave;
	
	while(1){
		sum = 0;
		scanf("%d",&n);
		if(n == 0) break;
		
		for(i = 0;i < n;i++){
			scanf("%d",&score[i]);
			sum += score[i];
		}
		sum -= sumSB(n,score);
		
		ave = sum / (n - 2);
		
		printf("%d\n",ave);
	}	
		return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	string S;
	cin >> N >> S;
	vector<ll> sum(N + 1);
	for (int i = 0; i < N; i++)sum[i + 1] = sum[i] + (S[i] == 'M');


	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int k;
		cin >> k;
		
		ll cursum = 0;
		ll cursz = 0;
		ll ans = 0;
		for (int right = 0; right < k; right++) {
			if (S[right] == 'C') { cursum += sum[right]; cursz++; }
		}
		if (S[0] == 'D')ans += cursum - cursz*sum[1];

		for (int left = 1; left < N; left++) {
			if (left + k - 1 < N && S[left + k - 1] == 'C') { cursum += sum[left + k - 1]; cursz++; }
			if (S[left - 1] == 'C') { cursum -= sum[left - 1]; cursz--; }
			if (S[left] != 'D')continue;
			ans += cursum - cursz * sum[left+1];
		}
		puts(ans);
	}

	return 0;
}

Measured memory_bytes: 9244
N, M = map(int,input().split())

ab = []
for i in range(N):
    ab.append(list(map(int,input().split())))

cd = []
for i in range(M):
    cd.append(list(map(int,input().split())))

ans = [0 for i in range(N)]
for i in range(N):
    d = 1000000000
    for j in range(M):
        if d > abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1]):
            ans[i] = j+1
            d = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])

for i in range(N):
    print(ans[i])

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

int max(int a, int b){
    return (a>b) ? a : b;
}


int main(){
    int n, m;
    cin>>n>>m;
    int l[n] = {0};
    int h[n];
    for(int i=0;i<n;i++)cin>>h[i];
    while(m--){
        int a, b;
        cin>>a>>b;
        a--; b--;
        l[a] = max(l[a], h[b]);
        l[b] = max(l[b], h[a]);
    }
    int res = 0;
    for(int i=0;i<n;i++){
        // cout<<h[i]<<l[i]<<endl;
        if(h[i]>l[i])res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4436
#include <stdio.h>

int main(void)
{
	int n, k, x, y;
	int i, sum = 0;
	
	scanf("%d%d%d%d", &n, &k, &x, &y);
	for(i = 1; i <= n; i++) {
		if(i <= k) {
			sum += x;
		}
		else {
			sum += y;
		}
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int s;
    cin >> s;
    //cout << s / 3600 << ":" << s / 36000 << ":" << s << endl;
    cout << s / 3600 << ":" << (s % 3600) / 60 << ":" << s % 60 << endl;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))


#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 1987654321
#define IINF 987654321987654321

#define MAX_V 1005
int N,K,M;
int main()
{
	geti(N);
	int o = 0;
	int e = 0;
	repp(i,N){
		int x; geti(x); 
		if ( x % 2 == 1 ) o++;
		else e++;
	}
	int cnt = 0;
	if( o > 1 ) e++;
	if( o%2 == 1 ){
		cnt++;
	}
	if( e > 0 ){
		cnt++;
	}
	if( cnt > 1 ){
		cout << "NO" << endl;
	}
	else{
		cout << "YES" << endl;
	}
}


Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(let ((table (make-hash-table))
	  (ans t)
	  (s (concatenate 'list (read-line))))
  (mapc (lambda (x)
		  (if (gethash x table)
			(setf ans nil)
			(setf (gethash x table) t)))
		s)
  (princ (if ans
		   "yes"
		   "no")))


Measured memory_bytes: 11828
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
using namespace std;

long long f(long long n)
{
	if (n <= 0)
	{
		return 0;
	}
	switch (n % 4)
	{
	case 0:
		return n;
	case 1:
		return 1;
	case 2:
		return n + 1;
	case 3:
		return 0;
	}
}

int main()
{
	long long a, b;
	cin >> a >> b;

	cout << (f(a-1)^f(b)) << endl;

	return 0;
}

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

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

    int ans = 0;
    for (int i = 1; i < S.size(); i++)
    {
        if (S[i] != S[i - 1])
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
// AOJ 2399

#include <iostream>
#include <algorithm>
using namespace std;

int main(void)
{
	int n;
	while (cin >> n, n){
		bool secret[n][n];
		int m, num;
		for (int i = 0; i < n; i++){
			fill(secret[i], secret[i] + n, false);
			cin >> m;
			for (int j = 0; j < m; j++){
				cin >> num;
				secret[i][num-1] = true;
			}
		}
		int k; cin >> k;
		bool leak[n]; fill(leak, leak + n, false);
		for (int i = 0; i < k; i++){
			cin >> num;
			leak[num-1] = true;
		}
		int cnt = 0, ret = 0;
		for (int i = 0; i < n; i++){
			bool flag = true;
			for (int j = 0; j < n; j++){
				if (!secret[i][j] && leak[j]) flag = false;
			}
			if (flag){
				cnt++;
				ret = i + 1;
			}
		}
		if (cnt == 1){
			cout << ret << endl;
		}
		else {
			cout << "-1" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1168
def resolve():
  N, K = map(int, input().split(" "))
  A = [int(x) for x in input().split(" ")]
  
  for i in range(K, N):
    if A[i-K] < A[i]:
      print("Yes")
    else:
      print("No")

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 31432