akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        //Random rnd = new Random();
        //Stopwatch sw = new Stopwatch();
        int N = cin.Nextint;
        int[] A = new int[N];

        for(int i=0; i<N; i++)
        {
            A[i] = cin.Nextint;
        }

        // 訪れた
        bool[] B = new bool[N];

        int cnt = 0;
        int current = 0;
        for(int i = 0; i<N ; i++)
        {
            if(B[current])
            {
                Console.WriteLine(-1);
                return;
            }

            if(current==1)
            {
                Console.WriteLine(cnt);
                return ;
            }

            B[current] = true;

            current = A[current] - 1;
            cnt++;
        }

        Console.WriteLine(-1);


        // A B C
        /*
        int A = cin.Nextint;
        int B = cin.Nextint;
        int C = cin.Nextint;
        */

        // N
        // a1 a2 ... aN
        /*
        int N;
        int[] A;

        N = cin.Nextint;
        A = cin.Scanint;
        */

        // N M
        // a1 b1
        // ...
        // aM bM
        /*
        int N;
        int M;
        int[] A = new int[M];
        int[] B = new int[M];

        N = cin.Nextint;
        M = cin.Nextint;

        for(int i=0; i<M; i++)
        {
            A[i] = cin.Nextint;
            B[i] = cin.Nextint;
        }
         */




        /** ここに記述 */

        //Console.WriteLine(result ? "Yes" : "No");
        Console.Out.Flush();
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length)
            {
                return s[i++];
            }
            string st = Console.ReadLine();
            while (st == "")
            {
                st = Console.ReadLine();
            }

            s 
            = st.
                Split
                (cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

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






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

int main(){
    int n,k,s = 0;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&l.at(i));
    }

    sort(l.begin(), l.end(), greater<int>() );

    for (int i = 0; i < k; i++)
    {
        s += l.at(i);
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  ll c0=0, c1=0;
  REP(i,s.size()){
    if (s[i] == '0') c0++;
    else
      c1++;
  }
  cout << min(c0, c1) * 2 << endl;
  return 0;
}


Measured memory_bytes: 3744
#pragma region Template
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

template<typename T> inline T sqr(T x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b) * (static_cast<int>(a > b)*2 - 1); }
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion

template<typename T> void prime_factorization(T num, std::vector<std::pair<T, T>>& prime_factor) {
	using namespace std;
	T L = static_cast<T>(ceil(sqrt(num))), i = 0;
	prime_factor = vector<pair<T, T>>(L, make_pair(0, 0));
	for (T x = 2; x <= L; x++) {
		while (num % x == 0) {
			if (prime_factor[i].first) prime_factor[i].second++;
			else prime_factor[i] = make_pair(x, 1);
			num /= x;
		}
		if (num == 1) break;
		if (prime_factor[i].first) i++;
	}
	if (num > 1) prime_factor[i] = make_pair(num, 1);
}

signed main()
{
	LL N;
	cin >> N;

	vector<std::pair<LL, LL>> prime_factor;
	prime_factorization(N, prime_factor);

	LL ans = 0;
	rbf(p, prime_factor) {
		if (p.first == 0LL) break;
		LL e = 1LL;
		while (1) {
			p.second -= e++;
			if (p.second < 0LL) break;
			ans++;
		}
	}

	COL(ans);
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int a,b,c;
    VI v(3);
    rep(i,3){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    if((v[0] + v[1]) == v[2]){
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  int ans = -1;
  vector<int> light(N);
  light.at(0) = 1;
  for(int i=1; i<N; i++){
    light.at(i) = a.at(light.at(i-1)-1);
    if(light.at(i)==2){
      ans = i;
      break;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 4016
using System;
public class Program{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        Array.Sort(input);
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        Console.WriteLine(c*10+b+a);
    }
}

Measured memory_bytes: 11360
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;
#define lli long ling int;

int main()
{
    int A, B, C, D;
    scanf("%d %d %d %d", &A, &B, &C, &D);

    while(1) {

        // takahashi atack
        C = C - B;
        if (C <= 0) {
            printf("Yes\n");
            break;
        }

        // aoki atack
        A -= D;
        if (A <= 0) {
            printf("No\n");
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

const double eps = 1e-9;
double board[101],depth[100];
vector<int> B,H,F,A;

void pour(int l, int r, int f, double& flow){//l??¨r???????£??????????
    int b=-1,h=0;
    if(flow<eps) return;
    for(int i=l+1;i<r;i++){
        if(h<board[i]){
            h=board[i];b=i;
        }
    }
    // cout<<l<<' '<<r<<' '<<b<<' '<<h<<endl;
    if(h){//????????±???
        if(f<b){//?????´??????????°´?????\???
            pour(l,b,f,flow);
            pour(b,r,f,flow);
        }else{//?????´??????????°´?????\???
            pour(b,r,f,flow);
            pour(l,b,f,flow);
        }
    }
    if(flow<eps) return;

    //???????????????????????¨????????±???
    h=min(board[l],board[r]);
    double maxflow=(r-l)*(h-depth[l])*30;
    if(flow>maxflow){
        flow-=maxflow;
        for(int i=l;i<r;i++) depth[i]=h;
    }else{
        for(int i=l;i<r;i++){
            depth[i]+=flow/(30*(r-l));
        }
        flow=0;
    }
}

int main(){
    int D;
    cin>>D;
    cout<<fixed;
    cout.precision(5);
    while(D--){
        int N;
        cin>>N;
        B.clear(); B.resize(N);
        H.clear(); H.resize(N);
        for(int i=0;i<N;i++){
            cin>>B[i]>>H[i];
        }
        int M;
        cin>>M;
        F.clear(); F.resize(M);
        A.clear(); A.resize(M);
        for(int i=0;i<M;i++){
            cin>>F[i]>>A[i];
        }

        fill(board,board+101,0);
        board[0]=board[100]=100000000;
        for(int i=0;i<N;i++){
            board[B[i]]=H[i];
        }

        int L;
        cin>>L;
        while(L--){
            int P,T;
            cin>>P>>T;
            fill(depth,depth+100,0);
            for(int i=0;i<M;i++){
                double flow = A[i]*T;
                // cout<<"f:"<<flow<<endl;
                pour(0,100,F[i],flow);
                /*
                for(int j=0;j<=N;j++){
                    cout<<depth[B[j]-1]<<' ';
                }
                cout<<endl;*/
            }
            cout<<min(depth[P],50.0)<<endl;
        }

    }
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k);

	i64 ans = 0;
	const int MOD = 1e9 + 7;
	for(i64 i = k; i <= n + 1; i++) {
		i64 R = (2 * n - i + 1) * i / 2;
		i64 L = (0 + i - 1) * i / 2;
		ans += R - L + 1;
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3816
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

A=list(map(float, input().split()))

low=0
high=10**9+1

while high-low!=1:
    mid=(high+low)//2
    cut_temp=0
    ans=-1
    
    for a in A:
        cut_temp+=-(-a//mid)-1
    if cut_temp>K:
        low=mid
    else:
        high=mid
    
print(high)

Measured memory_bytes: 30840
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void dfs(int now, vector<vector<pair<long long, long long>>> &tree, vector<long long> &place, vector<bool> &check, vector<bool> &write, bool &flag) {
    if (check.at(now)) return;
    if (!flag) return;
    check.at(now) = true;
    for (pair<long long, long long> x : tree.at(now)) {
        if (!write.at(now)) {
            place.at(now) = 0;
            write.at(now) = true;
        }
        if (!write.at(x.first)) {
            place.at(x.first) = place.at(now) + x.second;
            write.at(x.first) = true;
            dfs(x.first, tree, place, check, write, flag);
        }
        else {
            if (place.at(now) + x.second != place.at(x.first)) {
                flag = false;
                return;
            }
            else {
                dfs(x.first, tree, place, check, write, flag);
            }
        }
    }  
}

int main() {
    int n = 0, m = 0;
    cin >> n >> m;
    vector<vector<pair<long long, long long>>> tree(n);
    long long l = 0, r = 0, d = 0;
    for (int i=0; i<m; i++) {
        cin >> l >> r >> d;
        l--;
        r--;
        tree.at(l).push_back(make_pair(r, d));
        tree.at(r).push_back(make_pair(l, -d));
    }
    vector<long long> place(n);
    vector<bool> check(n);
    vector<bool> write(n, false);
    for (int i=0; i<n; i++) {
        if (tree.at(i).size() == 0) check.at(i) = true;
        else check.at(i) = false;
    }
    bool flag = true;
    while (true) {
        int start = -1;
        for (int i=0; i<n; i++) {
            if (check.at(i) == false) {
                start = i;
                break;
            }
        }
        if (start == -1) break;
        dfs(start, tree, place, check, write, flag);
        if (!flag) break;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

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

int main() {
  ll x, y;
  cin >> x >> y;
  ll cnt = 0;
  while (x <= y) {
    cnt++;
    x *= 2;
  }
  cout << cnt << endl;
  return 0;
}


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

typedef vector<int> vi;
typedef pair<int, int> pii;
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)
#define debug(val) printf("check%d\n", val)
#define all(v) v.begin(), v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val, 0, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

ll n, k;
vector<ll> ara;

bool is_ok(ll mid)
{
    ll kk = k;
    ll total = 0;

    if (mid == 0)
        return false;

    for (ll i = 0; i < n; i++)
    {
        if (ara[i] <= mid)
            continue;

        int t = ara[i] / mid;
        kk -= t;
    }

    return (kk >= 0);
}

ll bin_srch()
{
    ll lo = 0, hi = 1e9 + 10, mid;

    while (lo < hi)
    {
        mid = lo + (hi - lo) / 2;

        if (is_ok(mid))
        {
            hi = mid;
        }

        else
        {
            lo = mid + 1;
        }
    }

    return lo;
}

int main()
{
    cin >> n >> k;
    ll x;
    for (ll i = 0; i < n; i++)
    {
        cin >> x;
        ara.push_back(x);
    }

    cout << bin_srch() << endl;

    return 0;
}

Measured memory_bytes: 5284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
const int mod = 1e6 + 3;
long power(long a,long b){return b?power(a*a%inf,b/2)*(b%2?a:1)%inf:1;}

struct Node {
    vector<int> near;
    int cost = 0;
};
int reached[10000];
Node node[10000];
int sum_cost;
int count_ = 1;
int c[10000];
void dfs(int now) {
    rep(i, node[now].near.size()) {
        int next = node[now].near[i];
        if (reached[next]) continue;
        reached[next] = 1;
        node[next].cost = c[count_++];
        dfs(next);
    }
}
int main() {
    int n; cin >> n;
    rep(i, n - 1) {
        int a, b; cin >> a >> b; a--; b--;
        node[a].near.push_back(b);
        node[b].near.push_back(a);
    }
    rep(i, n) cin >> c[i];
    sort(c, c + n, greater<int>());
    node[0].cost = c[0];
    reached[0] = 1;
    dfs(0);
    int ans = 0;
    rrep(i, 1, n) ans += c[i];
    cout << ans << endl;
    rep(i, n) {if (i) cout << " "; cout << node[i].cost;} cout << endl;
}



Measured memory_bytes: 1280
N = int(input())
P = [int(p) for p in input().split()]
T = sorted(P)
if P == T:
  print('YES')
  exit() 
for i in range(N):
  for j in range(i,N):
    P[i], P[j] = P[j], P[i]
    if P == T:
      print('YES')
      exit()
    else:
      P[i], P[j] = P[j], P[i]
print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long K){
	ll res = 0;
	if (K >= 195) {
		if (K==195) cout << 9997134 << "\n";
		if (K==196) cout << 10174780 << "\n";
		if (K==197) cout << 10290813 << "\n";
		if (K==198) cout << 10493367 << "\n";
		if (K==199) cout << 10611772 << "\n";
		if (K==200) cout << 10813692 << "\n";
		return;
	}
	FOR(a, 1, K+1) {
		FOR(b, 1, K+1) {
			FOR(c, 1, K+1) {
				ll n1 = __gcd(a, b);
				ll n2 = __gcd(b, c);
				ll n3 = __gcd(n1, n2);
				res += n3;
			}
		}
	}
	cout << res << "\n";
}

int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());

        String[][] s = new String[h][w];
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < w; j++) {
                s[i][j] = str.substring(j, j + 1);
            }
        }
        int[][] cnt = new int[h][w];
        if (s[0][0].equals("#")) {
            cnt[0][0] = 1;
        }
        for (int j = 1; j < w; j++) {
            cnt[0][j] = cnt[0][j - 1];
            if (!s[0][j].equals(s[0][j - 1])) {
                cnt[0][j]++;
            }
        }
        for (int j = 1; j < h; j++) {
            cnt[j][0] = cnt[j - 1][0];
            if (!s[j][0].equals(s[j - 1][0])) {
                cnt[j][0]++;
            }
        }

        for (int i = 1; i < h; i++) {
            for (int j = 1; j < w; j++) {
                int a = cnt[i][j - 1];
                int b =  cnt[i - 1][j];

                if (!s[i][j].equals(s[i][j - 1])) {
                a++;
                }
                if (!s[i][j].equals(s[i - 1][j])) {
                    b++;
                }
                cnt[i][j] = Math.min(a, b);

            }

        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                // System.out.print(cnt[i][j]);
            }
            // System.out.println();
        }

        System.out.println((cnt[h - 1][w - 1] + 1) / 2);
        sc.close();
    }
}

Measured memory_bytes: 23252
n = int(input())
l = [0]*53
for i in range(n):
    a, b = input().split()
    b = int(b)
    if a == "H":
        b += 13
    elif a == "C":
        b += 26
    elif a == "D":
        b += 39
    l[b] = 1 
for j in range(1,53):
    if l[j] != 1:
         ama = j % 13
         syou = j // 13
         if ama == 0:
             ama = 13
             syou -= 1 
         if syou == 0:
             zi = "S"
         elif syou == 1:
             zi = "H"
         elif syou == 2:
             zi = "C"
         else:
             zi = "D"
         print(zi, ama)

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

using namespace std;

template <class T>
inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>
inline T updmin(T &a, T b) { return a = min(a, b); }

bool isSquare(int k)
{
	for (int i = 0; i * i <= k; i++)
	{
		if (i * i == k)
			return true;
	}
	return false;
}

int main()
{
	int n, d;
	scanf("%d%d", &n, &d);
	vector<vector<int>> a(n, vector<int>(d, 0));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < d; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	int ret = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int test = 0;
			for (int k = 0; k < d; k++)
			{
				test += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
			}
			if (isSquare(test))
				ret++;
		}
	}
	printf("%d\n", ret);

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import numpy as np


def solve(*args: str) -> str:
    n = int(args[0])
    LR = [tuple(map(int, a.split())) for a in args[1:]]
    L, R = zip(*LR)

    ret = 0

    p, q = np.argmax(L), np.argmin(R)
    lp, rq = L[p], R[q]

    ret = max(0, 1+rq-lp) + max(0, max(1+r-l for l, r in LR))

    AB = [[max(0, 1+r-lp), max(0, 1+rq-l)] for l, r in LR]
    AB.sort(key=lambda x: (x[0], -x[1]))
    A, B = map(list, zip(*AB))

    # for i in range(1, n):
    #     ret = max(ret, min(A[i:]) + min(B[:i]))
    b_min = 1+10**9
    for i in range(n-1):
        b_min = min(b_min, B[i])
        ret = max(ret, b_min + A[i+1])

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 65432
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

int P[200000];
int pos[200000];
int dp[200000];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> P[i];
        pos[P[i] - 1] = i;
    }

    for(int i = 0; i < N; i++){
        if(P[i] == 1){
            dp[i] = 1;
        } else {
            int last_num_pos = pos[P[i] - 2];
            if(last_num_pos < i){
                dp[i] = dp[last_num_pos] + 1;
            } else {
                dp[i] = 1;
            }
        }
    }
    int max_sec_num = *max_element(dp, dp + N);
    cout << N - max_sec_num << endl;
    return 0;
}


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

int main() {
  
  int N,L;
  cin >> N >> L;
  
  vector<int> aji(N);
  
  for(int i = 0; i<N; i++){
    aji.at(i) = L + i + 1 - 1;
  }
  
  int hantei = 0;
  
  for( int i = 0; i<N; i++){
    if ( aji.at(i) == 0 ){
      hantei = 0;
      break;
    }else if( aji.at(i) > 0){
      hantei = 1;
    }else if( aji.at(i) < 0){
      hantei = 2;
    }
  }
  
  int pie = 0;
  
  if ( hantei == 0 ){
    for(int i = 0; i<N; i++){
      pie += aji.at(i);
    }
  }else if( hantei == 1){
    for(int i = 1; i<N; i++){
      pie += aji.at(i);
    }
  }else if( hantei == 2){
    for(int i = 0; i<N-1; i++){
      pie += aji.at(i);
    }
  }
  
  cout << pie << endl;
   
}

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

int main(void) {

    string X; cin >> X;
    stack<char> st;
    for (auto x : X) {
        if (st.empty() || x == 'S') {
            st.push(x);
        } else {
            if (st.top() == 'S') {
                st.pop();
            } else {
                st.push(x);
            }
        }
    }

    cout << st.size() << endl;

    return 0;
}

Measured memory_bytes: 1336
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next()); // 店数
        int M = Integer.parseInt(sc.next()); // 買いたい数
        Map<Long, Integer> map = new TreeMap<Long, Integer>();
 
        for (int i = 0; i < N; i++) {
            Long A = sc.nextLong();
            int B = sc.nextInt();
            if(map.containsKey(A)){
                map.put(A,map.get(A)+B);
            }else{
                map.put(A,B);
            }
        }
        Long sum = 0L;
        // int j = 0;
        loop: for(Long a: map.keySet()){
            int tmp = map.get(a);
            if(tmp>= M){
                sum += M*a;
                break loop;
            }else{
                sum += tmp*a;
                M -= tmp;
            }
        }
        System.out.print(sum);
    }
}



Measured memory_bytes: 67280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main()
{
	int ab, bc, ca;
	cin >> ab >> bc >> ca;
	int ans = ab * bc / 2;
	cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,c,sum;
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();
		
		sum = a + b + c;
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 26124
#include <iostream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(void){
    int N;
    cin >> N;
    long long a[N+5];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

    long long count[2] = {0, 0};
    long long sum[2] = {0,0};
    long long sign;
    for(int k=0;k<2;k++){
        /* k=0 a[0] >0, k=1, a[0] <0 */
        sign = pow(-1, k);
        for(int i=0;i<N;i++){
            sum[k] = sum[k] + a[i];
            if(sign * sum[k] <= 0){
                count[k] = count[k] + abs(sum[k]) + 1;
                sum[k] = sign;
            }
            sign = sign * (-1);
        }
    }
    long long ans = min(count[0], count[1]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadInt;
            var ans = int.MaxValue;
            for(int i = 0; i <= N; i++)
            {
                var Tmp = (int)Pow(2, i) + (N - i) * K;
                if (ans > Tmp) ans = Tmp;
            }
            WriteLine(ans);
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13268
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

t = 10 ** 9
r = 0

for i in range(N):
    x = T - H[i] * 6 / 1000
    tt = abs(A - x)
    if t > tt:
        t = tt
        r = i + 1
        
print(r)

Measured memory_bytes: 9264
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		if(a==3 || a==5 || a==7) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 24148
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a, b;
char op;
int main()
{
	cin >> a >> op >> b;
	if (op == '+')
	{
		cout << a + b << endl;
	}
	else
	{
		cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 3660
import collections
N, M = map(int, input().split())
result = []
for i in range(M):
    p, S = input().split()
    result.append((int(p), S))

AC = collections.defaultdict(bool)
WA = collections.defaultdict(int)

const = 0
score = 0
for p, s in result:
    if s == "AC" and not AC[p]:
        score += 1
        const += WA[p]
        AC[p] = True
    if s == "WA" and not AC[p]:
        WA[p] += 1
print(score, const)

Measured memory_bytes: 34604
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int m = sc.nextInt();
		List<Integer>[] adj = new ArrayList[m];
		for(int i=0;i<m;++i){
			 adj[i] = new ArrayList<>();
			 int k = sc.nextInt();
			 for(int j=0;j<k;++j){
			 	int s = sc.nextInt()-1;
			 	adj[i].add(s);
			 }
		}
		int[] p = new int[m];
		for(int i=0;i<m;++i) p[i] = sc.nextInt();
		int ans = 0;
		for(int i = 0; i < (1<<n); ++i){
			boolean light = true;
			
			for (int j=0;j<m && light;++j){
				int on = 0;
				
				for(int bulb : adj[j])
				if(((i>>bulb)&1) == 1) ++on;
				
				on%=2;
				if(on!=p[j]) light = false;
				
			}
			
			if(light) ++ans;
			
		}
		
		System.out.println(ans);
 	}
}


Measured memory_bytes: 23636
import java.util.Scanner

import scala.collection.mutable

object Main extends App {
  val sc = new Scanner(System.in)
  val vec = mutable.ArrayBuffer.empty[(Int, Int, Int)]
  val N = sc.nextInt
  val X, Y, H = Array.fill(1009)(-1)
  var G = (-1, -1, -1)

  (1 to N) foreach { i =>
    X(i) = sc.nextInt
    Y(i) = sc.nextInt
    H(i) = sc.nextInt
    if (H(i) >= 1) {
      G = (X(i), Y(i), H(i))
    }
  }

  for {
    i <- 0 to 100
    j <- 0 to 100
  } {
    var V = G._3 + Math.abs(G._1 - i) + Math.abs(G._2 - j)
    V = Math.max(V, 0)
    var flag = true
    for (k <- 1 to N) {
      var VV = V - Math.abs(X(k) - i) - Math.abs(Y(k) - j)
      VV = Math.max(VV, 0)
      if (H(k) != VV) {
        flag = false
      }
    }
    if (flag) {
      vec.append((i, j, V))
    }
  }

  if (vec.size == 1) {
    println(s"${vec(0)._1} ${vec(0)._2} ${vec(0)._3}")
  }

  //  val xyhs = Seq.fill(n)((sc.nextInt, sc.nextInt, sc.nextInt))
  //  val excludes = xyhs.map { case (x, y, _) => (x, y) }
  //  val h_xys = mutable.Map.empty[(Int, Int), Int]
  //  xyhs.foreach { case (x, y, h) =>
  //    for {
  //      xx <- 0 to 100
  //      yy <- 0 to 100
  //    } {
  //      val hh = Math.abs(x - xx) + Math.abs(y - yy) + h
  //      val already = h_xys.get((xx, yy))
  //      if ((x, y) != (xx, yy) && excludes.contains((xx, yy))) {
  //
  //      } else if (already.isEmpty) {
  //        h_xys.update((xx, yy), hh)
  //      } else if (already.exists(_ != hh)) {
  //        h_xys.update((xx, yy), -1)
  //      }
  //    }
  //  }
  //  val center = h_xys.maxBy { case (_, h) => h }
  //  println(s"${center._1._1} ${center._1._2} ${center._2}")
}


Measured memory_bytes: 32764
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);


// #define int long long

using namespace std;
int main() {


    ios::sync_with_stdio(false);
    cin.tie(0);

    int array_size = 100000;
    int height;
    int sum = 0;
    int n;
    int k;
    int ans = INF;
    vector<int> v;
    cin >> n >> k;

    int price_max = -1;
    for (int count = 0; count < n; count++) {
        cin >> height;
        v.push_back(height);
    }

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

//    for (int i = 0; i < n; i++) {
//        cout << v[i] << " ";
//    }
//    cout << endl;

    for (int i = 0 ; i < n-k+1; i++) {
//        cout << v[i] << " " << v[i+k-1] << endl;
        ans = min(ans, v[i+k-1] - v[i]);
    }

    cout << ans << endl;
}


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

void insertion_sort(vector<int> &a, int i);
void output(vector<int> &a);

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  output(a);
  for (i = 1; i < n; i++) {
    insertion_sort(a, i);
    output(a);
  }
  return 0;
}

void insertion_sort(vector<int> &a, int i) {
  int v = a[i];
  int j = i - 1;
  while (j >= 0 && a[j] > v) {
    a[j + 1] = a[j];
    j--;
  }
  a[j + 1] = v;
}

void output(vector<int> &a) {
  int i;
  for (i = 0; i < a.size(); i++) {
    cout << a[i];
    if (i != a.size() - 1) {
      cout << ' ';
    }
  }
  cout << endl;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,a[120];
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int tot=0;
	for(int i=1;i<=n;i+=2) if(a[i]%2==1) tot++;
	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();

		if(X==Y) {
			System.out.println(2*X);
		}else {
			if(X>Y) {
				System.out.println(2*X-1);
			}else {
				System.out.println(2*Y-1);
			}
		}
	}
}


Measured memory_bytes: 22996
//abc080_c.cpp
//Fri Feb 23 23:14:57 2018

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


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

	int f[n][10];
	for (int i=0;i<n;i++){
		for (int j=0;j<10;j++){
			cin >> f[i][j];
		}
	}

	int p[n][11];
	for (int i=0;i<n;i++){
		for (int j=0;j<11;j++){
			cin >> p[i][j];
		}
	}
	int answer = -(1<<30);
	int b = 1;
	for (int b=1;b<(1<<10);b++){
		int tempp = 0;
		for (int c=0;c<n;c++){
			int tempc = 0;
			for (int j=0;j<10;j++){
				if ((b>>j) & 1 && f[c][j]){
					tempc++;
				}
			}
			tempp = tempp + p[c][tempc];
		}
		if (tempp > answer){
			answer = tempp;
		}
	}
	cout << answer << endl;
}

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

int main(void) {

    int N[100] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;

    cout << N[K-1] << endl;

    return 0;

}



Measured memory_bytes: 256
n = input()
b = [int(x) for x in input().split()]
c = 0
flg = True
while flg:
    for i,x in enumerate(b):
        if x!=0 and x%2 != 0:
            flg=False
            break
        b[i] = int(x/2)
    c += 1
print(c-1)


Measured memory_bytes: 2940
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan =new Scanner(System.in);
		for(int i=0;i<9;i++){
		String a=scan.next();	
		int b =scan.nextInt();
		int c =scan.nextInt();
		int sum=b+c;
		int ans=b*200+c*300;
		System.out.println(a+" "+sum+" "+ans);
		}
	}
}

Measured memory_bytes: 17156
#!/usr/bin/python3
# -*- coding: utf-8 -*-
s = input()
n = len(s)
m = (n-1) // 2
k = (n+3) // 2
flag = 1
for i in range(0, n//2):
    if s[i] != s[n-i-1]:
        flag = 0
        break
for i in range(0, m//2):
    if s[i] != s[m-i-1]:
        flag = 0
        break
for i in range(0, (n-k)//2+1):
    if s[i+k-1] != s[n-i-1]:
        flag = 0
        break
if flag == 1:
    print("Yes")
else:
    print("No")

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

int main(){
  int A,B;
  cin >> A >> B;
  if((A%3 ==0) || (B%3 == 0) || ((A+B)%3 == 0)){
    cout << "Possible" <<endl;
  }else{
    cout << "Impossible" <<endl;
  }

}

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

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{
    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');

        long n;
        n = long.Parse(input[0]);
        long ans = 0;

        for (long i = 1; i * i < n; i++)
        {
            if (n % i == 0 && n / i - 1 > i) ans += n / i - 1;
        }

        Console.WriteLine(ans);

    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 11092
#!/usr/bin/ruby
a=[0]*3
gets
gets.split.each{|e|a[e.to_i%3]+=1}
if a[1]==0 && a[2]==0
	p [1,a[0]].min
else
	pairs=[a[1],a[2]].min
	a[1]-=pairs
	a[2]-=pairs
	p a[0]+pairs*2+[[3,a[1]].min,[3,a[2]].min].max
end

Measured memory_bytes: 33828
import numpy as np
from numba import njit, prange

#'''
N, K = map(int, input().split())
As = list(map(int, input().split()))
'''
N = 200000
K = 100000
As = [0] * N
#'''

@njit("i8[:](i8[:],)", cache = True)
def update(A_array):
    before_csum = np.zeros(N+1, np.int64)
    for i, A in enumerate(A_array[:N]):
        before_csum[max(0, i-A)] += 1
        before_csum[min(N, i+A+1)] -= 1
    return np.cumsum(before_csum)
    
A_array = np.array(As + [0], dtype = np.int64)
for k in range(min(K, 50)):
    A_array = update(A_array)
    
print(*A_array.tolist()[:N])

Measured memory_bytes: 132812
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

const int MAXN = 1000000;
Int fact[MAXN], inv[MAXN];

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

void init_fact() {
    fact[0] = 1;
    for(int i=1; i<MAXN; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    inv[MAXN - 1] = mod_pow(fact[MAXN - 1], MOD-2);
    for(int i=MAXN - 2; i>=0; i--) {
        inv[i] = (inv[i+1] * (i+1)) % MOD;
    }
}

Int comb(int n, int r) {
    if(r < 0 || n < r) return 0;
    return fact[n] * inv[n-r] % MOD * inv[r] % MOD;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

Int A[25][25];

int main(){
    cin.tie(0);

    Int H, W; cin >> H >> W;
    Int h, w; cin >> h >> w;
    cout << H*W - h*W - H*w + h*w << endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        ArrayList<Integer> edges[]=new ArrayList[n];
        long[] pairs=new long[n-1];
        int[] pcol=new int[n];
        for(int i=0;i<n-1;i++){
            int a=fsc.nextInt()-1, b=fsc.nextInt()-1;
            if(edges[a]==null) edges[a]=new ArrayList<Integer>();
            edges[a].add(b);
            pairs[i]=(long)a*n+b;
        }
        fsc.close();
        HashMap<Long, Integer> colors=new HashMap<>();
        int dim=0;
        for(int v=0;v<n;v++){
            if(edges[v]==null) continue;
            int c=0;
            for(int u:edges[v]) colors.put((long)v*n+u, pcol[u]=pcol[v]==++c?++c:c);
            if(c>dim) dim=c;
        }
        PrintWriter pw=new PrintWriter(System.out);
        StringBuilder sb=new StringBuilder(dim+"\n");
        for(int i=0;i<n-1;i++) sb.append(colors.get(pairs[i])+"\n");
        pw.print(sb); pw.flush();
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr<buflen) return true;
        else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }
            catch(IOException e){
                e.printStackTrace();
            }
            if(buflen<=0) return false;
        }
    return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) throw new NumberFormatException();
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }
            else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
            else throw new NumberFormatException();
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
    public void close(){
        try{in.close();}
        catch(IOException e){e.printStackTrace();}
    }
}

Measured memory_bytes: 54696
N,C,K=map(int,input().split())
l=[]

for i in range(N):
  l.append(int(input()))

l.sort()

bus_c=0
t_lim=0
jou_c=0

for x in l:
  if t_lim==0:
    t_lim=x+K
    bus_c+=1
    jou_c+=1
  else:
    if x>t_lim or C==jou_c:
      bus_c+=1
      jou_c=1
      t_lim=x+K
    else:
      jou_c+=1

print(bus_c)

Measured memory_bytes: 7392
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        String S = sc.next();

        int ans = 0;
        int count = 0;
        for(int i = 0; i < S.length(); i++){
            if(S.charAt(i) == 'A' || S.charAt(i) == 'T' || S.charAt(i) == 'G' || S.charAt(i) == 'C'){
                count++;
                ans = Math.max(ans, count);
            }else{
                ans = Math.max(ans, count);
                count = 0;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
n=[int(input()) for i in range(5)]

a=[-(-n[i]//10)*10 for i in range(len(n))]
b=[n[i]%10 for i in range(len(n)) if n[i]%10 != 0]
if b != []:
    print(sum(a) + min(b) -10)
else:
    print(sum(a))


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

int main() {
  int64_t n;
  std::cin >> n;

  int64_t ret = 0;
  char prev = '\0';

  for (int64_t i = 0; i < n; ++i) {
    char c;
    std::cin >> c;
    if (prev != c) {
      ++ret;
      prev = c;
    }
  }

  std::cout << ret << std::endl;

  return 0;
}



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

int main() {
  int N, D;
  cin >> N >> D;
  
  vector<vector<int>> A (N, vector<int>(D));
  
  for (int i = 0; i < N; i++){
    for (int j = 0; j < D; j++){
      cin >> A.at(i).at(j);
    }
  }
  
  int dis = 0;
  double distance = 0;
  int count = 0;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (i != j){
        for (int k = 0; k < D; k++){
          dis += (A.at(i).at(k) - A.at(j).at(k)) * (A.at(i).at(k) - A.at(j).at(k));
          //cout << dis << endl;
        }
        distance = sqrt(dis);
        //cout << distance << endl;
        if (distance == int(distance)){
          count++;
        }
        dis = 0;
        distance = 0;
      }
    }
  }
  cout << count / 2 << endl;
}



Measured memory_bytes: 256