akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#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 rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

const int MAX_V = 310;
int d[MAX_V][MAX_V]; // d[u][v]は辺e=(u, v)のコスト（存在しない場合はINF、ただし[i][i]=0とする）
int ans_d[MAX_V][MAX_V];
int V;

void warshall_floyd(int N){
	V = N;
    rep(i, V){
        rep(j, V){
            d[i][j] = INTINF;
        }
    }
    rep(i, V) d[i][i] = 0;
	bool ok = true;
    for(int k=0; k<V; k++){
        for(int i=0; i<V; i++){
            for(int j=0; j<V; j++){
				if(ans_d[i][j] > ans_d[i][k] + ans_d[k][j]){
					ok = false;
				}
            }
        }
    }

	if(!ok){
		cout << -1 << endl;
		return;
	}

	ll ans = 0;
	rep(i, V) rep2(j, i+1, V) ans += ans_d[i][j];
	// print(ans);
	for(int i=0; i<V; i++){
		for(int j=i+1; j<V; j++){
			for(int k=0; k<V; k++){
				if(k == i || j == k) continue;
				if(ans_d[i][j] == ans_d[i][k] + ans_d[k][j]){
					ans -= ans_d[i][j];
					break;
				}
            }
        }
    }
	cout << ans << endl;
}


int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n; cin >> n;

	rep(i, n){
		rep(j, n){
			cin >> ans_d[i][j];
		}
	}

	warshall_floyd(n);

	return 0;
}


Measured memory_bytes: 4280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<int> dp(1<<n,1);
    rep(mask,1<<n){
        int s = 0;
        rep(i,n)if(mask>>i&1) s += a[i];
        if(s == k) dp[mask] = 0;
    }

    rep(mask,1<<n)if(dp[mask] == 0){
        rep(i,n)if(!(mask>>i&1)){
            int nx = mask|(1<<i);
            dp[nx] = 0;
        }
    }

    int ans = n;
    rep(mask,1<<n)if(dp[mask]) ans = min(ans, n-__builtin_popcount(mask));
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 7068
#include <queue>
#include <string>
#include <iostream>
using namespace std;
int main() {
	string cmd; // while????????´????????????????????????????????°???????????¨??????
	int num;
	priority_queue<int> Q;
	while (cin >> cmd && cmd != "end") {
		if (cmd == "insert") { // ????????????
			cin >> num;
			Q.push(num);
		} else if (cmd == "extract") { // ????????????
			num = Q.top();
			Q.pop();
			cout << num << endl;
		} 
	}
	return 0;
}

Measured memory_bytes: 7076
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int a, b, x = 0;
    cin >> a >> b;
    
    for (int i = 1; i <= b - a; i++) {
        x += i;
    }
    x -= b;
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
A= list(map(int,input().split()))


for k in range(K):
    if all(a==N for a in A):
        break
    D=[0]*(N+1)
    for i,d in enumerate(A):
        left=max(0,i-d)
        right= min(N-1,i+d)
        D[left]+=1
        D[right+1]-=1
    for i in range(N):
        D[i+1]+=D[i]
    A= D[:-1]

print(" ".join(map(str,A)))


Measured memory_bytes: 169012
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }


int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	cin >> n;
	vector<string> x(n); map<string, int> p; bool y = true;
	rep(i, n)
	{
		cin >> x[i];
		p[x[i]]++;
		if(p[x[i]]>1)
		{
			y = false;
		}
	}
	if (y) {
		rep(i, n - 1)
		{
			if (x[i][sz(x[i]) - 1] != x[i + 1][0])
				y = false;
		}
	}
		Cout(Yes(y));
	


	return 0;
}


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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n, c, k;
  cin >> n >> c >> k;

  int a[n + 1];
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  sort (a + 1, a + n + 1);

  int ans = 0;
  for (int i = 1; i <= n; ) {
    int j = i+1;
    while (a[j] <= a[i] + k && j < i + c && j <= n)
      j++;
    i = j;
    ans++;
  }
  cout << ans;
  return 0;
}






// Coded by Z..

Measured memory_bytes: 640
#include<cstdio>
#define int long long
int D;
int calc(int A,int t,int first){
	if(!t)return A==0;
	int v=(A%10+10)%10;
	int res=0;
	res+=(10-v-first)*calc((A-t*v)/10,t/100,0);
	res+=(v-first)*calc((A+(10-v)*t)/10,t/100,0);
	return res;	
}
signed main() {
    scanf("%lld",&D);
    if(D%9)return puts("0"),0;
	D/=9;
	int ans=0,p10=10;
	for(int i=2;i<=18;i++){
		int tot=(i%2)*9+1;
		ans+=tot*calc(D,p10/9,1);
		p10*=10;
	} 
	printf("%lld\n",ans);
}

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<int> dp(n, INT32_MAX);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
  }
  cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main()
{
    int n,x;scanf("%d",&n);
    int maxa=0,mina=999999999;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(x>maxa) maxa=x;
        if(x<mina) mina=x;
    }
    cout<<maxa-mina<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if (S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)){
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,d,cc=0;
	cin>>a>>b>>c>>d;
	long long lcm,gcd;
	long long C=c,D=d,r;
	if(c>d){
		C=d;
		D=c;
	}
	r=C%D;
	while(r!=0){
		C=D;
		D=r;
		r=C%D;
	}
	gcd=D;
	lcm=(c*d)/gcd;
	cc+=((b/c)+(b/d)-(b/lcm));
	cc-=(((a-1)/c)+((a-1)/d)-((a-1)/lcm));
	cc=(b-a+1)-cc;
	cout<<cc<<endl;
}


Measured memory_bytes: 256
import numpy as np

n, m, x = map(int, input().split())

C = []
A = [[] for _ in range(n)]
for i in range(n):
    li = list(map(int, input().split()))
    C.append(li[0])
    A[i] = li[1:]

C = np.array(C)
A = np.array(A)

# 全探索

ans = n * 10 ** 5
flag = False
for bit in range(2 ** n):  # bit 1000101010
    money = 0
    levels = np.array([0] * m)
    for j in range(n):  # 0 <= j < n
        if bit >> j & 1:
            money += C[j]
            levels += A[j]
    # すべて x 以上なら
    if np.all(levels >= x):
        flag = True
        ans = min(ans, money)

if flag:
    print(ans)
else:
    print(-1)


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

int main()
{
    int n ,k;
    cin >> n >> k;
    int x[n];
    rep(i, n) cin >> x[i];
    int ans = 0;
    for (int i :x){
        ans += 2*min(i, abs(k-i));
    }
    cout << ans << endl;
}

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


  
int main(){
  

  int m,f,b;
  cin >> m >> f >> b  ;
  
  
    if (m+f>=b && m<b){
      cout << b-m << "\n";
    }else if (m+f<b ){
      cout << "NA\n";
    }
    else if (m>=b){
    cout << "0" << "\n";
  }
  
  
 return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main()
{
    int n, q;
    cin >> n >> q;
    map<int, vector<int> > tree;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
    }
    vector<int> cnt_dummy(n, 0);
    vector<int> cnt(n, 0);
    for (int i = 0; i < q; i++)
    {
        int p, x;
        cin >> p >> x;
        cnt_dummy[p - 1] += x;
        cnt[p - 1] += x;
    }
    
    for (auto &&t : tree)
    {
        for (auto &&x : t.second)
        {
            cnt_dummy[x - 1] += cnt_dummy[t.first - 1];
            cnt[x - 1] += cnt_dummy[t.first - 1];
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << cnt[i];
        if (i != n)
            cout << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 27392
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BOneClue {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int K, X;
        cin >> K >> X;
        int l = max(X - K + 1, -1000000LL);
        int r = min(X + K - 1, 1000000LL);
        FOR(i, l, r) {
            cout << i << " ";
        }
        cout << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BOneClue solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {
   
   int M1,M2,D1,D2;
   
   scanf("%d %d",&M1, &D1);
   scanf("%d %d",&M2, &D2);
   
   if (M1 != M2) {
      printf("1\n");
   }
   else {
      printf("0\n");
   }
   
   return 0;
}


Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n,m,k; cin >> n >> m >> k;
    vector<int> a(n),b(m);
    for(int i = 0;i < n;i ++) cin >> a.at(i);
    for(int i = 0;i < m;i ++) cin >> b.at(i);

    vector<int> asum(n+1),bsum(m+1);
    for(int i = 1;i < n+1;i ++) asum.at(i) = asum.at(i-1) + a.at(i-1);
    for(int i = 1;i < m+1;i ++) bsum.at(i) = bsum.at(i-1) + b.at(i-1);

    int ans = 0;

    for(int i = n;i >= 0;i --){
        if(asum.at(i) > k) continue;

        auto iter = lower_bound(bsum.begin(),bsum.end(),k-asum.at(i)+1);
        int temp = iter - bsum.begin();

        ans = max(ans, i+temp-1);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 9512
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<sstream>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

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

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


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

void divisor(ll n,vector<ll> &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.begin(), ret.end());
	
}//約数求める


ll kaijou(int n) {
	ll temp = 1;
	for (int i = 2; i <= n; i++) {
		temp *= i;
		temp %= MOD;
	}
	return temp;
}

int coun[2][100010];


int main() {
	int n;
	cin >> n;
	int* v = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		coun[i % 2][v[i]]++;
	}
	int max[2] = { 0 ,0};
	for (int i = 0; i < 100010; i++) {
		if (max[0] < coun[0][i]) { 
			max[0] = coun[0][i];
		}
		else if (max[1] < coun[1][i]){
			max[1] = coun[1][i];
		}
	}
	int max2[2] = { 0,0 };
	for (int i = 0; i < 100010; i++) {
		if (max2[1] < coun[1][i]) {
			max2[1] = coun[1][i];
		}else if (max2[0] < coun[0][i]) {
			max2[0] = coun[0][i];
		}
		
	}
	if (n - max[0] - max[1] < n - max2[0] - max2[1]) {
		cout << n - max[0] - max[1];
	}
	else {
		cout << n - max2[0] - max2[1];
	}
	return 0;
}

Measured memory_bytes: 1408
len = int(input())
ret = input()
count_max = 0
for i in range(1, len):#全ての場所での分割を試す
  count = 0
  for k in range(97, 123):#それぞれのアルファベットがそれぞれの部分に含まれるか検証(アスキーコードを用いる）
    if ((chr(k) in ret[:i]) and (chr(k) in ret[i:])):
      count += 1
  if count > count_max:
    count_max = count
print(count_max)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m;

map<string,int> mp;

signed main()
{
    string s1,s2,s3;
    cin>>s1>>s2;
    int a,b;
    cin>>a>>b;
    mp[s1] = a;mp[s2] = b;
    cin>>s3;
    mp[s3]--;
    cout<<mp[s1]<<' '<<mp[s2]<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
N=int(input())
A=list(map(int,input().split()))

if N == 2:
  if (A[0]+A[1])  % 2 == 1 or (A[0] < A[1]):
    print(-1) 
  else:
    print((A[0]-A[1]) //2)
  sys.exit()

S=A[0]+A[1]
X=0
for i in range(2,N):
  X = X^A[i]
D=(S-X)//2
if ((S-X) % 2) == 1 or (S-X < 0) or (D & X != 0) or (D>A[0]):
  print(-1)
  sys.exit()
#print(S,X,bin(X))
Y = 0
for i in range(2,len(bin(X))):
  if bin(X)[i] != "0":
    tmp = 2 ** (len(bin(X))-i-1) #立っているビット分足す
    if D^(tmp+Y) <= A[0]: #小さければ
#      print('add')
      Y += tmp #update
#    else:
#      print('exceed!')
else:
  if Y:
    ans = A[0]-(D^Y)
    print(ans)
  else:
    print(-1)

Measured memory_bytes: 62400
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans = 0;
    for i in 0..n {
        if i % 2 == 0 && a[i] % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
#define CLR(a)     memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)    cerr << #x << " = " << (x) << endl;//debug
#define debug(x)   cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define EPS        1e-10//sample:if((double)>=(double)+EPS)
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);
#define MAX 100
using namespace std;
int n,A[MAX][MAX];
bool r[101][101]={};
#define WHITE 0
#define GRAY 1
#define BLACK 2
int prim(){
  int u;
  int d[MAX],pi[MAX],color[MAX];
  int mincost;
  rep(i,n){
    d[i]=INT_MAX;
    pi[i]=-1;
    color[i]=0;
  }
  d[0]=0;

  while(1){
    mincost=INT_MAX;
    u=-1;
    rep(i,n)
      if(mincost>d[i]&&color[i]!=BLACK){
	u=i;
	mincost=d[i];
      }
    if(u==-1)break;
    color[u]=BLACK;
    rep(v,n){
      if(color[v]!=BLACK&&A[u][v]!=INT_MAX){
	if(d[v]>A[u][v]){
	  d[v]=A[u][v];
	  pi[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  int sum=0;
  rep(i,n)if(pi[i]!=-1)sum+=A[i][pi[i]];
  return sum;
}
int main(){
  int a;
  cin>>n;
  rep(i,n)rep(j,n){
    cin>>a;
    if(a==-1)A[i][j]=INT_MAX;
    else A[i][j]=a;
  }
  cout<<prim()<<endl;

  return 0;
}


Measured memory_bytes: 3160
n=int(input())
a=list(map(int,input().split()))
print(*a)
for i in range(1,n):
	v=a[i]
	j=i-1
	while j>=0 and a[j]>v:
		a[j+1]=a[j]
		j-=1
	a[j+1]=v
	print(*a)


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

const int ALPHABET = 26;
int main() {
	string w;
	cin >> w;
	bool beautiful[ALPHABET];
	for (int i = 0;i < ALPHABET;i ++) beautiful[i] = true;
	for (int i = 0;i < w.length();i ++) {
		beautiful[w[i] - 'a'] = !beautiful[w[i] - 'a']; // 毎回美しいと美しくないが交互に入れ替わる
	}
	for (int i = 0;i < ALPHABET;i ++) {
		if (!beautiful[i]) { // もし美しくない文字列なら
			cout << "No";
			return 0;
		}
	} // 美しい
	cout << "Yes";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

偶数回出現系はbool型を使って出現する度に真偽入れ替えととらえ直すことができるよ
これで、偶数回なら真、奇数回なら偽になるから、後は全部真かそうでないかを判定すれば良いね
*/

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

long gcd(long a, long b){
    long v0 = a, v1 = b, v2 = v0 % v1;
    while(v2 != 0){
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    }
    return v1;
}

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

int main() {
    long N, M;
    cin>>N>>M;
    long a[N];
    for(int i=0;i<N;++i){
        cin>>a[i];
    }
    long tmplcm = a[0];
    for(int i=1;i<N;++i){
        tmplcm = lcm(tmplcm, a[i]);
    }
    tmplcm /= 2;
    int two = 0;
    while(a[0] % 2 == 0){
        two++;
        a[0] /= 2;
    }
    bool tmpans = true;
    int two1;
    for(int i=1;i<N;++i){
        two1 = 0;
        while(a[i] % 2 == 0){
            two1++;
            a[i] /= 2;
        }
        if(two!=two1)tmpans = false;
    }
    if(M<tmplcm)cout<<0<<endl;
    else if(!tmpans)cout<<0<<endl;
    else cout<<(M/(tmplcm)+1)/2<<endl;
    //else cout<<(M-tmplcm)/(tmplcm*2)+1<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#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++)
int main() {
	int tar; string s;
	while (cin >> tar >> s, tar) {
		int len = s.length() - 1;
		int ma = -1;
		rep(i, 1 << len) {
			int now = 0;
			vector<string>t;
			rep(j, len) {
				if ((i >> j) & 1) {
					t.push_back(s.substr(now, j + 1 - now));
					now = j + 1;
				}
			}
			t.push_back(s.substr(now, len+1 - now));
			int sum = 0; int l = t.size();
			rep(j, l) {
				sum += stoi(t[j]);
			}
			if (sum <= tar)ma = max(ma, sum);
		}
		if (ma == -1) {
			cout << "error" << endl; continue;
		}
		int cnt = 0; vector<string> out;
		rep(i, 1 << len) {
			int now = 0;
			vector<string>t;
			rep(j, len) {
				if ((i >> j) & 1) {
					t.push_back(s.substr(now, j + 1 - now));
					now = j + 1;
				}
			}
			t.push_back(s.substr(now, len + 1 - now));
			int sum = 0; int l = t.size();
			rep(j, l) {
				sum += stoi(t[j]);
			}
			if (sum == ma) {
				cnt++; out = t;
			}
		}
		if (cnt > 1) {
			cout << "rejected" << endl;
		}
		else {
			cout << ma;
			int l = out.size();
			rep(i, l) {
				cout << " " << out[i];
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3012
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}
function rep(n: number) {
  let a = [];
  for (let i = 0; i < n; i++) a.push(i);
  return a;
}

function Main({ int, str, strs, ints }: NormalInput) {
  const [H, W] = ints(2);
  const s = strs(H);
  const dp = rep(H).map(() => []);
  dp[0][0] = s[0][0] == "#" ? 1 : 0;
  for (let i = 0; i < H; i++)
    for (let j = 0; j < W; j++) {
      if (i == 0 && j == 0) continue;
      const up =
        i > 0
          ? dp[i - 1][j] + (s[i][j] == "#" && s[i - 1][j] == "." ? 1 : 0)
          : Infinity;
      const left =
        j > 0
          ? dp[i][j - 1] + (s[i][j] == "#" && s[i][j - 1] == "." ? 1 : 0)
          : Infinity;
      dp[i][j] = Math.min(up, left);
      // console.log(i, j, dp[i][j]);
    }
  console.log(dp[H - 1][W - 1]);
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    string s; cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}

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

int fn(vector<int>& vec)
{
  int i = 0;
  while(vec.at(i % vec.size()) % 2 == 0){
    vec.at(i % vec.size()) /= 2;
    i++;
  }
  return i / vec.size();
}

int main()
{
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i < N; i++) {
    cin >> vec.at(i);
  }
  cout << fn(vec) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int* max(int a[3]){
    if(a[0] >= a[1] && a[0] >= a[2]) return &a[0];
    else if(a[1] >= a[0] && a[1] >= a[2]) return &a[1];
    else return &a[2];
}

int find_even(int ar[3]){
    int num = 0;
    for(int i = 0; i < 3; i++){
        if(ar[i] % 2 == 0) num++;
    }
    return num;
}

int main(void){
    int a[3];
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    
    int *target;
    target = max(a);
    int num_even = find_even(a);
    int ans;
    if(num_even == 3 || num_even == 0){
        ans = ((*target) * 3 - a[0] - a[1] - a[2]) / 2;
    }else{
        if((*target) % 2 != num_even % 2){
            ans = (*target - a[0]) / 2 + (*target - a[1]) / 2 + (*target - a[2]) / 2 + 1;
        }else{
            for(int i = 0; i < 3; i++){
                if(a[i] != (*target) && a[i] % 2 == 0){
                    a[i]++;
                    break;
                }
            }
            (*target)++;
            ans = 1 + ((*target) * 3 - a[0] - a[1] - a[2]) / 2;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#define int long long
#define MOD 1000000007
using namespace std;

vector<int> G[1000];
bool cflag[1000];
int mark[1000];

int dfs(int v){
	int res = 1;
	mark[v] = 0;
	for(int to : G[v]) res = res * dfs(to) % MOD;
	return (res + 1) % MOD;
}

bool cyc(int v,int par){
	mark[v] = par;
	for(int to : G[v]){
		if(mark[to] == par) return cflag[v] = true;
		else if(mark[to] != -1) continue;
		if(cyc(to,par)) return cflag[v] = true;
	}
	return false;
}

signed main(){
	int n,m,ans = 1;
	bool in[1000] = {};
	cin >> n >> m;
	for(int i = 0;i < n;i++) mark[i] = -1;
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		in[a] = true;
		G[b].push_back(a);
	}
	for(int i = 0;i < n;i++){
		if(!in[i]) ans = ans * dfs(i) % MOD;
	}
	for(int i = 0;i < n;i++){
		if(mark[i] == -1){
			for(int j = 0;j < n;j++) cflag[j] = false;
			int res = 1;
			if(!cyc(i,i)) continue;
			for(int j = 0;j < n;j++){
				if(cflag[j]){
					for(int to : G[j]){
						if(!cflag[to]) res = res * dfs(to) % MOD;
					}
				}
			}
			ans = ans * (res + 1) % MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3216
n, a, b = map(int, input().split())
mod = 10**9 + 7

def comb(n, r, mod):
    X = 1
    Y = 1
    for i in range(1, r+1):
        X = X * (n - i + 1) % mod
        Y = (Y * i) % mod
    return (X * pow(Y, mod-2, mod)) % mod

ans = (pow(2, n, mod) - 1 - comb(n, a, mod) - comb(n, b, mod)) % mod

print(ans)



Measured memory_bytes: 3064
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<ll> a(n + 1);
	rep(i, n + 1)scanf("%lld", &a[i]);
	sort(all(a));
	ll ans = 1;
	ans = a[1] - a[0];
	rep(i, n - 1)ans = gcd(ans, a[i + 2] - a[i + 1]);
	printf("%lld\n", ans);

	Please AC;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
const int N = 100100;
int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	int cur = -a + b;
	if (cur <= 0)
		cout << "delicious\n";
	else if (cur <= x)
		cout << "safe\n";
	else
		cout << "dangerous\n";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    int res = 0;
    rep(i, s.size() / 2) {
        if(s[i] != s[s.size() - i - 1])
            res++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100
int main()
{
    int a[N][N];
    int n,u,v,k,i,j;
    scanf("%d",&n);
    for( i = 0;i < n;i++){
        for(j = 0;j < n;j++){
            a[i][j] = 0;
        }
    }
    for(i = 0;i < n;i++){
        scanf("%d%d",&u,&v);
        u--;
        for(j = 0;j < v;j++){
            scanf("%d",&k);
            k--;
            a[u][k] = 1;
        }
    }
    for(i = 0;i < n;i++){
        for(j = 0;j < n;j++){
            if(j)putchar(' ');
            printf("%d",a[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int n,k;
  cin >> n>> k;
  if(n%k ==0){
    cout << "0" << endl;
  }else{
    cout << "1" << endl;
  }
  return 0;
}

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

int main() {
    int N;
    while (1) {
        cin >> N;
        if (N == 0) break;
        vector<int> score(N);

        for (int i = 0; i < N; i++) {
            cin >> score[i];
        }
        sort(score.begin(), score.end());

        int h = 0;
        for (int i = 1; i < N - 1; i++) {
            h += score[i];
        }
        cout << h / (N - 2) << endl;
    }
}


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double area = r * r * Math.PI;
        double circumference = r * 2 * Math.PI;
        System.out.printf("%f %f",area,circumference);
        sc.close();
    }
}


Measured memory_bytes: 28264
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  string s;
  cin >> s;
  if(s[0]==s[1] && s[1]==s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;
 
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        //ArrayList<Integer> array = new ArrayList<Integer>();
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(i%2 == 0){
                        if(j%2 == 0){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }else{
                        if(j%2 == 1){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }
                    
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



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

#define    ll     long long int

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

const int N = 1e9 + 9;
ll h, w;
set< pair<int, int> > st, bl;
int n;
vector< pair<int, int> > v;
ll ans[11];
ll total = 0;

int isvalid(int x, int y)
{
     if (x >= 1 && y >= 1 && x + 2 <= h && y + 2 <= w)
        return 1;
     return 0;
}

void kaj(int x, int y)
{
    if (isvalid(x, y) == 0) {
        return ;
    }
    int c = 0, i, j;
    for (i = 0; i < 3; i++) {
        for (j = 0; j < 3; j++) {
            if (bl.find(make_pair(i + x, j + y)) != bl.end()) {
                c++;
            }
        }
    }
    st.insert(make_pair(x, y));
    ans[c]++;
    total++;
}

void solve(int x, int y)
{
    int c = 0, i, j, k, tx, ty;
    kaj(x, y);
    if (st.find(make_pair(x, y - 1)) == st.end()) {
        kaj(x, y - 1);
    }
    if (st.find(make_pair(x, y - 2)) == st.end()) {
        kaj(x, y - 2);
    }
    if (st.find(make_pair(x - 1, y)) == st.end()) {
        kaj(x - 1, y);
    }
    if (st.find(make_pair(x - 1, y - 1)) == st.end()) {
        kaj(x - 1, y - 1);
    }
    if (st.find(make_pair(x - 1, y - 2)) == st.end()) {
        kaj(x - 1, y - 2);
    }
    if (st.find(make_pair(x - 2, y)) == st.end()) {
        kaj(x - 2, y);
    }
    if (st.find(make_pair(x - 2, y - 1)) == st.end()) {
        kaj(x - 2, y - 1);
    }
    if (st.find(make_pair(x - 2, y - 2)) == st.end()) {
        kaj(x - 2, y - 2);
    }
}

int main( )
{
    cin >> h >> w >> n;
    ll i, x, y;
    for (i = 0; i < n; i++) {
        cin >> x >> y;
        v.push_back(make_pair(x, y));
        bl.insert(make_pair(x, y));
    }
    sort(v.begin(), v.end());
    for (i = 0; i < n; i++) {
        solve(v[i].first, v[i].second);
    }
    cout << ((h - 2) * (w - 2) - total) << '\n';
    for (i = 1; i <= 9; i++) {
        cout << ans[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 47860
if __name__ == '__main__':
    # ??????????????\???
    num_of_orders = int(input())
    data = []
    for d in range(num_of_orders):
        data.append(tuple(input().split(' ')))

    # ??¨???????????????????¨?
    orders = dict()
    for p_name, p_count in data:
        if p_name in orders:
            orders[p_name] += int(p_count)
        else:
            orders[p_name] = int(p_count)

    results = []
    for k, v in orders.items():
        results.append(tuple([k, v]))
    results.sort(key=lambda x:(len(x[0]), x[0])) # ?£????????????????????????¨?£????????????¢???????????????????????§?????????

    # ???????????????
    for r in results:
        print('{0} {1}'.format(r[0], r[1]))

Measured memory_bytes: 9280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		int h=sc.nextInt();
		int w=sc.nextInt();
		
		int ans = ( H - h ) * ( W - w );

		System.out.println(ans);

	}
}

Measured memory_bytes: 25172
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int n, m;
vvi G;
vi cou;
int ma;

bool check(int i) {
    cou[i] = 1;
    bool KK = false;
    if(ma == n) {
        KK = true;
    }
    for(int next:G[i]) {
        if(next == -1) continue;
        if(cou[next]) {
            continue;
        }
        ma++;
        cou[next] = 1;
        if(check(next)) {
            KK = true;
        }    
    }
    return KK;
}

int main() {
    cin >> n >> m;
    G.resize(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans=0;
    rep(i, n) {
        
        
        for(int &x:G[i]) {
            cou.assign(n, 0);
            ma = 1;
            int x_ = x;
            for(int &y:G[x]) {
                int y_ = y;
                if(i == y) {
                    x = -1;
                    y = -1;
                    if(i && !check(0)) ++ans;
                    else if(!i && !check(1)) ++ans;
                    x = x_;
                    y = y_;
                    break;
                }
            }
            
        }
        
    }

    cout << ans/2 << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type edge struct {
	to   int
	cost int
}

var G [][]edge
var N int
var a, b, c int
var Q, K int
var x, y []int
var dist []int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	G = make([][]edge, N)
	for i := 0; i < N-1; i++ {
		a, b, c = nextInt()-1, nextInt()-1, nextInt()
		G[a] = append(G[a], edge{to: b, cost: c})
		G[b] = append(G[b], edge{to: a, cost: c})
	}

	Q, K = nextInt(), nextInt()-1
	x = make([]int, Q)
	y = make([]int, Q)
	for q := 0; q < Q; q++ {
		x[q], y[q] = nextInt()-1, nextInt()-1
	}
	dist = make([]int, N)
	rec(K, -1, 0)
	for q := 0; q < Q; q++ {
		fmt.Println(dist[x[q]] + dist[y[q]])
	}
}

func rec(v, p, sum int) {
	dist[v] = sum
	for _, e := range G[v] {
		if e.to == p {
			continue
		}
		rec(e.to, v, sum+e.cost)

	}
}


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

template<class T> inline bool chmax(T &a, T b) {
	if (a < b) { a = b; return true; }
	return false;
}

template<class T> inline bool chmin(T &a, T b) {
	if (a > b) { a = b; return true; }
	return false;
}

int main() {
	int q;
	cin >> q;
	while (q--) {
		string x, y;
		cin >> x >> y;
		int xsz = x.size();
		int ysz = y.size();
		//vector<vector<int>> dp(xsz + 1, vector<int>(ysz + 1));
	    int dp[1001][1001] = { 0 };
		for (int i = 0; i < xsz; i++) {
			for (int j = 0; j < ysz; j++) {
				if (x[i] == y[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
				chmax(dp[i + 1][j + 1], dp[i][j + 1]);
				chmax(dp[i + 1][j + 1], dp[i + 1][j]);
			}
		}
		cout << dp[xsz][ysz] << endl;
	}
	return 0;
}


Measured memory_bytes: 7104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

//lcs
vector<vector<ll>>c;
string x,y;

ll lcs(ll m, ll n) {//m,nはstring x,yのサイズ
	ll maxv = 0;
	for (int i = 0; i <m; ++i) {
		for (int j = 0; j <n; ++j) {
			if (x[i] == y[j]){
        c[i+1][j+1] = c[i][j] + 1;
      }
			else c[i+1][j+1] = max(c[i][j+1], c[i+1][j]);
			maxv = max(maxv, c[i+1][j+1]);
		}
	}
	return maxv;
}

int main(){
  cin>>x>>y;
  c.resize(x.size()+5,vector<ll>(y.size()+5,0));
  lcs(x.size(),y.size());
  string ans="";
  int i=x.size(),j=y.size();
  while(i>0&&j>0){
      if(c[i][j]==c[i][j-1])--j;
      else if(c[i][j]==c[i-1][j])--i;
      else {
          ans=x[i-1]+ans;
          i--;j--;
      }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
    int n; cin >> n;
    vector<pair<int, int>> coor(n);
    for(int i = 0; i < n; i++){
        int x, l; cin >> x >> l;
        coor.at(i).first = x - l;
        coor.at(i).second = x + l;
    }

    sort(coor.begin(), coor.end(), [](pair<int, int> l, pair<int, int> r){
        return l.second < r.second;
    });

    int count = 1;
    int s = coor.at(0).first,t = coor.at(0).second;
    rep(i, n){
        if(t > coor.at(i).first) {
            continue;
        }
        s = coor.at(i).first;
        t = coor.at(i).second;
        count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 4056
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstring>
#include<string>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

int N;

int main() {
	
	scanf("%d", &N);
	int x = N % 10;
	if (x == 3) puts("bon");
	else if (x == 0 || x == 1 || x == 6 || x == 8) puts("pon");
	else puts("hon");

	return 0;
}		

Measured memory_bytes: 3196
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int64_t n;
  cin >> n;
  string s;
  cin >> s;
  int64_t count=0;
  int64_t testcount=0;
  int64_t c = 0;
  int64_t sa = 0;
  for(int a=0; a<=n-3; a++){
    for(int b=a+1; b<=n-2; b++){
      sa = b - a;
      if(b + sa < n){
        if(s.at(a)!=s.at(b) && s.at(b)!=s.at(b+sa) && s.at(b+sa)!=s.at(a)) count++;
      }
    }
  }
  int64_t Rcount=0;
  int64_t Gcount=0;
  int64_t Bcount=0;
  rep(i,n) if(s.at(i)=='R') Rcount++;
  rep(i,n) if(s.at(i)=='G') Gcount++;
  rep(i,n) if(s.at(i)=='B') Bcount++;
//  cout << Rcount << endl;
//  cout << Gcount << endl;
//  cout << Bcount << endl;
  int64_t num = Rcount * Gcount * Bcount;
//  cout << num << endl;
//  cout << count << endl;
  cout << num - count << endl;
//  cout << testcount <<endl;
}

Measured memory_bytes: 3596
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x, a = list(map(int,ipti().split()))
    print(0) if x < a else print(10)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import itertools

def kyori(Y,Z):
    sum = 0
    for i in range(D):
        sum+= (Y[i]-Z[i])**2
    return pow(sum,0.5)

N,D=map(int,input().split())
X=list()
for i in range(N):
    X.append(list(map(int,input().split())))

candidList = list(itertools.combinations(X,2))
ans=0
for cand in candidList:
    if float.is_integer(kyori(cand[0],cand[1])):
        ans+=1
    else:
        continue

print(ans)




Measured memory_bytes: 3188