akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int count(int bits){
	int cnt = 0;
	while(bits){
		bits &= bits-1;
		cnt++;	
	}
	return cnt;
}

int main(){
	int h,w,k;
	cin >> h >> w >> k;
	int s[h][w];
	rep(i,h) rep(j,w){
		char c;
		cin >> c;
		s[i][j] = c-'0';

	}
	int cnt[h+10][w+10] = {};
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cnt[i][j+1] = cnt[i][j];
			if(s[i][j]) cnt[i][j+1]++;
			//cout << cnt[i][j+1];
		}
		//cout << endl;
	}

	int ans = INF;
	// hについてbit全探索
	for(int bit = 0; bit < (1<<(h-1)); bit++){
		int tmp = count(bit),flag = 1,left = 0;
		for(int right = 0; right < w; right++){
			int m = 0;
			int block[count(bit)+1]; memset(block,0,sizeof(block));
			for(int height = 0; height < h; height++){
				block[m] += cnt[height][right+1]-cnt[height][left];
				// ブロック確定
				if(bit&(1<<height) || height == h-1){
					// 次の分岐に入るとアウト
					if(block[m] > k){
						memset(block,0,sizeof(block));
						if(left == right) flag = 0;
						left = right--;
						tmp++;
					}
					m++;
				}
				if(!flag) break;
			}
			if(!flag) break;
		}
		if(flag) ans = min(ans,tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans = (N-2)*B-(N-2)*A+1;
    if(ans<0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
using namespace std;
int main () { 
	int A,B;
	cin >> A >> B;
		if (A == 1 && B == 1){
			cout << "Draw" << endl;
		}else if(B == 1){
			cout << "Bob" << endl;
		}else if (A == 1){
			cout << "Alice" << endl;
		}else if(A > B){
			cout << "Alice" << endl;
		}else if(A < B){
			cout << "Bob" << endl;
		}else if(A == B){
			cout << "Draw" << endl;
		}
			
			
} 			


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>
#include <iterator>

using namespace std;
long A[100000];
long sumO[100000],sumE[100000],sum[100000];
//TODO two way search
int solve(long X, int N){
	int ub = N+1,lb = 1,t;
	t = (ub + lb)/2;
	while(ub - lb >1){
		if(abs(A[N-t]-X) > abs(A[N-(t+1)/2]-X)){
			ub = t;
		}else{
			lb = t;
		}
		t = (ub+lb)/2;
	}
	// for(int i=1;i<N+1;i++){
	// 	if(abs(A[N-i]-X) > abs(A[N-(i+1)/2]-X)) return i-1;
	// }
	return t;
}

void calcSum(int N){
	sumE[0] = A[0];
	sumO[0] = 0;
	sum[0] = A[0];
	for(int i=1;i<N;i++){
		sum[i] = sum[i-1]+A[i];
		sumE[i] = sumE[i-1] + (i%2 == 0 ? A[i] : 0);
		sumO[i] = sumO[i-1] + (i%2 == 1 ? A[i] : 0); 
	}
}

int main(void){
	int N,Q;
	long X[100000];
	cin >> N >> Q;
	for(int i=0;i < N;i++){
		cin >> A[i];
	}
	calcSum(N);

	for(int i=0;i < Q;i++){
		cin >> X[i];
	}
	for(int i=0;i < Q;i++){
		int a = solve(X[i],N);
		long sum1 = sum[N-1] - sum[N -(a+1)/2 -1];
		long sum2;
		if(N!=a){
			if(N%2 == 0)sum2 = sumO[N - a - 1];
			else sum2 = sumE[N - a - 1];
		}else{
			sum2 = 0;
		}
		// for(int j=N -((a+1)/2)*2 -1;j>=0;j-=2){
		// 	sum2 += A[j];
		// }
		cout << sum1 + sum2 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5632
def main():
    N = int(input())
    S,T = input().split()
    new_str = []
    for _,(s,t) in enumerate(zip(S,T)):
        new_str.append(s)
        new_str.append(t)
        
    for i in range(len(new_str)):
        print(new_str[i],end='')
        if i == len(S)+len(T)-1:
            print()

if __name__=='__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    int t;
    for (t = 1; ; t++)
    {
        ans += t;
        if (ans >= n)
            break;
    }
    cout << t;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] arg){
		Scanner in = new Scanner(System.in);
		while(true){
			int x = in.nextInt();	
			int y = in.nextInt();
			if (x == 0 && y == 0)break;
			StringBuilder sb = new StringBuilder();
			for(int i = 0;i < x;i++){
				for(int j=0;j < y;j++){
					sb.append("#");
				}
				sb.append("\n");
			}
			System.out.println(sb);
		}	
	}
}

Measured memory_bytes: 21016
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int n, m, x;
	cin >> n >> m;

	vector<bool> a(n + 1, true);
	rep(i, 0, m) {
		cin >> x;
		a[x] = false;
	}
	
	vector<ll> dp(n + 1);
	dp[0] = 1;
	if (a[1]) dp[1] = 1;

	for (int i = 2; i <= n; i++) {
		if (a[i - 1]) dp[i] += dp[i - 1] % mod;
		if (a[i - 2]) dp[i] += dp[i - 2] % mod;
		dp[i] %= mod;
	}

	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    fio();
    ll a;
    string b;
    cin >> a >> b;
    rep (i, b.size()) {
        if (b[i] == '.') {
            b.erase(b.begin() + i);
            break;
        }
    }
    ll bb = stol(b);
    cout << a * bb / 100 << endl;

}

Measured memory_bytes: 3652
import numpy as np
N, M = list(map(int, input().split()))
Switches = np.zeros((N,M)) # N = Switch, M = light

for i in range(M):
    arr = list(map(int, input().split()))
    for item in arr[1:]:
        Switches[item-1, i] = 1
Ps = np.array(list(map(int, input().split())))


bit_max = 2 ** N
stat = np.zeros(M)
cnt = 1 if (stat == Ps).all() else 0

for i in range(1, bit_max):
    bits = [j for j in range(N) if (i >> j &1)]
    res = stat + Switches[bits].sum(axis=0) % 2
    cnt += 1 if (res == Ps).all() else 0

print(cnt)

Measured memory_bytes: 13660
// CatChecker
import java.util.*;

public class Main {
	static String s;
	static int pos;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		pos = 0;
		s = scanner.next();
		if (cat() && pos == s.length())
			System.out.println("Cat");
		else
			System.out.println("Rabbit");
		scanner.close();
	}

	static boolean cat() {
		char m = s.charAt(pos);
		if (m == 'm') {
			pos++;
			char e = s.charAt(pos);
			if (e == 'e') {
				pos++;
				char w = s.charAt(pos);
				if (w == 'w') {
					pos++;
					return true;
				}
				boolean mew = cat();
				w = s.charAt(pos);
				if (mew && w == 'w') {
					pos++;
					return true;
				}
				return false;
			}
			boolean mewmew = cat();
			e = s.charAt(pos);
			if (mewmew && e == 'e') {
				pos++;
				char w = s.charAt(pos);
				if (w == 'w') {
					pos++;
					return true;
				}
				boolean mew = cat();
				w = s.charAt(pos);
				if (mew && w == 'w') {
					pos++;
					return true;
				}
				return false;
			}
			return false;
		}
		return false;
	}
}

Measured memory_bytes: 17320
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9
struct Puzzle{
  int f[N2];
  int space;
  string path;
  bool operator<(const Puzzle &p)const{
    for(int i=0;i<N2;i++){
      if(f[i]==p.f[i])continue;
      return f[i]>p.f[i];
    }
    return false;
  }
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r',};

bool isTarget(Puzzle p){
  for(int i=0;i<N2;i++)
    if(p.f[i]!=(i+1))return false;
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle>Q;
  map<Puzzle, bool> V;
  Puzzle u,v;
  s.path="";
  Q.push(s);
  V[s]=true;

  while(!Q.empty()){
    u=Q.front();
    Q.pop();
    if(isTarget(u))return u.path;
    int sx=u.space/N;
    int sy=u.space%N;
    for(int r=0;r<4;r++){
      int tx=sx+dx[r];
      int ty=sy+dy[r];
      if(tx<0||ty<0||tx>=N||ty>=N)continue;
      v=u;
      swap(v.f[u.space],v.f[tx*N+ty]);
      v.space=tx*N+ty;
      if(!V[v]){
	V[v]=true;
	v.path+=dir[r];
	Q.push(v);
      }
    }
  }
  return "unsolvable";
}

int main(){
  Puzzle in;

  for(int i=0;i<N2;i++){
    cin>>in.f[i];
    if(in.f[i]==0){
      in.f[i]=N2;
      in.space=i;
    }
  }
  string ans=bfs(in);
  cout<<ans.size()<<endl;
  return 0;
}



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

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-min
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// min-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=min(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return INF; // min
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return min(lv,rv); // min
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmin(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};


// Set,Add,Getmin,Getsum
int main(){
  ll n,q;
  cin >> n >> q;
  segtree T(n);
  for(ll i=0;i<q;i++){
    ll type,a,b,c;
    cin >> type;
    if(type==0){
      cin >> a >> b >> c;
      T.Add(a-1,b,c);
    }
    else {
      cin >> a;
      cout << T.Getsum(a-1,a) << endl;
    }
  }
  return 0;
}


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

int main(){

    ll a, b, c;
    cin >> a >> b >> c;

    ll cnt = 0;
    map<int, int> mem;
    mem[a]++;
    mem[b]++;
    mem[c]++;

    ll a_temp, b_temp, c_temp;
    a_temp = a;
    b_temp = b;
    c_temp = c;

    while ((a%2==0) && (b%2==0) && (c%2==0)){
        a_temp /= 2;
        b_temp /= 2;
        c_temp /= 2;

        a = c_temp + a_temp;
        b = a_temp + b_temp;
        c = b_temp + c_temp;

        mem[a]++;
        mem[b]++;
        mem[c]++;

        if ((mem[a] < 4) && (mem[b] < 4) && (mem[c] < 4)){
            cnt++;
        }
        else{
            cout << -1 << endl;
            return 0;
        }

    }

    cout << cnt << endl;
    return 0;
}

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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  Bint a, b;
  cin >> a >> b;
  cout << a + b << endl;

  return 0;
}



Measured memory_bytes: 3424
def gcd(a, b):
    r = a % b
    return b if r == 0 else gcd(b, r)

def lcm(a, b):
    return a * b // gcd(a, b)


n = int(input())
T = [int(input()) for _ in range(n)]

answer = 1
for t in T:
    answer = lcm(answer, t)

print(answer)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
int n,a,sum,i,max,min;
while(scanf("%d",&n),n){
sum=0;
for(i=0;i<4;i++){
scanf("%d ",&a);
sum+=a;
}
scanf("%d",&a);
sum+=a;
max=sum;
min=sum;
while(n-->1){
sum=0;
for(i=0;i<4;i++){
scanf("%d ",&a);
sum+=a;
}
scanf("%d",&a);
sum+=a;
if(sum>max)
max=sum;
else if(sum<min)
min=sum;
}
printf("%d %d\n",max,min);
}
return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,d;
	cin>>n>>d;

	ll ar[n][d];
	for(i=0;i<n;i++){
		for(j=0;j<d;j++){
			cin>>ar[i][j];
		}
	}

	ll an=0;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			l=0;
			for(k=0;k<d;k++){
				l+=(ar[i][k]-ar[j][k])*((ar[i][k]-ar[j][k]));
			}
			if(ceil(sqrt(l))==floor(sqrt(l))){
					an++;
				}
		}
	}
	cout<<an;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    ll n;
    cin>>n;
    ll ans=0;
    ll c[10][10]={0};
    rep(i,n){
        int p=i+1;
        int ps=p/pow(10,int(log10(p))),pg=p%10;
        c[ps][pg]++;
    }
    rep(i,10)rep(j,10) ans+=c[i][j]*c[j][i];
    cout<<ans<<"\n";
}

Measured memory_bytes: 512
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(input())for _ in range(n)]
    if A[0]!=0:
        print(-1)
        sys.exit()
    dp=[0]*n
    for i,a in enumerate(A[1:],1):
        if a>=A[i-1]+2:
            print(-1) 
            sys.exit()
        elif a==A[i-1]+1:
            dp[i]=1
        else:
            dp[i]=a
    print(sum(dp))

if __name__=='__main__':
    main()

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

int main()
{
	int n,t;
	cin>>n>>t;
	
	pair<int,int>p={0,0};
	bool llego=false;
	int a,b;
	
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(b<=t)
		{
			if(llego != true)
			{			
				p.first=a;
				p.second=b;
				llego=true;
			}
			else 
			{
				if(p.first>a)
				{
					p.first=a;
					p.second=b;
					llego=true;
				}
			}
		}		
	}
	
	if(p.first==0 && p.second==0)
	{
			cout<<"TLE";
	}
	else
	{
		cout<<p.first;
	}
		
	return  0;	
}

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



int main(){
  long long N, Q;
  cin >> N >> Q;
  vector<long long>A(N);
  rep(i,N)cin >> A[i];
  
  
  

  
  rep(j,Q){
    
    long long ans = 0;
    long long x;
    cin >> x;
    long long sum = 0;
    int right = 0;
    
    
    for(int left = 0; left <N; left++){
      while(sum +A[right] <= x && right< N){
        sum += A[right];
        right++;
      }
      //ここを抜けた時，rightは最大
      ans += (right - left);
      
      if(right == left){
        right++;
      }
      else{
        sum -= A[left];
      }
    }
    
    cout << ans << endl;
    
  }
  
}


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

int main(){
    ll x;
    cin >> x;
    ll num = sqrt(sqrt(x));
    for(ll i=1; i<=x; i++){
        if(x%i != 0) continue;
        for(ll a=num; a>-num; a--){
            ll b = a-i;
            if(a*a*a*a*a - b*b*b*b*b == x){
                cout << a <<" "<< b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3680
import sys
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    N, L = map(int, input().rstrip().split())
    s = []
    for _ in range(N):
        s.append(input().rstrip())
    ans = ''
    for st in sorted(s):
        ans += st
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8888
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

long long modpow(long long a,long long n)
{
  long long res=1;
  while(n>0)
  {
    if(n&1)res=res*a%MOD;
    a=a*a%MOD;
    n>>=1;
  }
  return res;
}

int main()
{
long long X,Y,r,n;scanf("%lld %lld",&X,&Y);long long ans=1;
if((X+Y)%3!=0||max(X,Y)>min(X,Y)*2){printf("0\n");return 0;}
r=(2*X-Y)/3;n=X-r;
for(long long i=n;i>n-r;i--)ans=ans*i%MOD;
for(long long i=r;i>0;i--)
{
  ans=ans*modpow(i,MOD-2)%MOD;
}
printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    int K, A, B;
    cin>>K>>A>>B;
    bool ans = false;
    for(int i=A;i<=B;++i){
        if(i%K==0) ans = true;
    }
    if(ans) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;



int main(int argc, char **argv) {
    i64 n;
    cin >> n;

    std::string str;

    cin >> str;

    //i64 ans{0};
    unordered_map<std::string, i64> m;
    m["r"] = 0;
    m["g"] = 0;
    m["b"] = 0;
    m["rg"] = 0;
    m["gb"] = 0;
    m["rb"] = 0;
    m["rgb"] = 0;

    for (char c : str) {
        switch(c) {
        case 'R':
            ++m["r"];
            m["rg"] += m["g"];
            m["rb"] += m["b"];
            m["rgb"] += m["gb"];
            break;
        case 'G':
            ++m["g"];
            m["rg"] += m["r"];
            m["gb"] += m["b"];
            m["rgb"] += m["rb"];
            break;
        case 'B':
            ++m["b"];
            m["rb"] += m["r"];
            m["gb"] += m["g"];
            m["rgb"] += m["rg"];
            break;
        default:
            cout << "oops!" << endl;
            break;
        }
    }

    for (int i=0; i<str.size(); ++i) {
        int j = i+1;
        int k = i+2;
        while (k < str.size()) {
            if (str[i] != str[j] && str[j] != str[k] && str[k] != str[i])
                --m["rgb"];
            ++j;
            k = j + (j-i);
        }
    }

    cout << m["rgb"] <<endl;
    return 0;
}

Measured memory_bytes: 3608
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 262144
#define M 1048576
#define K (N*2)
#define P 0xe6006a2cf4c46aedull

char buf[N+M];
char *ss[N];
int nss[N];
class HashTable {
public:
    uint data[K];
    uint& at(ulli k)
    {
        int pos = k%K;
        while(data[pos] && data[pos]!=(uint)(k>>32)) pos = (pos+1) % K;
        return data[pos];
    }
    bool get(ulli k)
    {
        k *= P;
        return at(k);
    }
    void set(ulli k)
    {
        k *= P;
        at(k) = k>>32;
    }
}lu;
int cnt[128];

int main()
{
    int n;
    scanf("%d", &n);
    char *p = buf;
    for(int i=0;i<n;++i)
    {
        scanf("%s", p), nss[i] = strlen(p);
        ss[i] = p, p += nss[i] + 1;
    }
    for(int i=0;i<n;++i)
        dbg_pri("poi 3: %s\n", ss[i]);
    for(int i=0;i<n;++i)
    {
        ulli x = 0;
        for(int j=nss[i]-1;j>=0;--j)
            x *= P, x ^= ss[i][j];
        lu.set(x);
    }
    int ans = 0;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<nss[i];++j)
            ++cnt[ss[i][j]];
        ulli x = 0;
        for(int j=nss[i]-1;j>=0;--j)
        {
            x *= P;
            for(int k='a';k<='z';++k)if(cnt[k])
                ans += lu.get(x^k);
            x ^= ss[i][j];
            --cnt[ss[i][j]];
        }
    }
    ans -= n;
    printf("%d\n", ans);
    return 0;
}


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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

ll gcd(ll m, ll n) {
    return n != 0 ? gcd(n, m % n) : m;
}

ll lcm(ll m, ll n) {
    // If both m and n are large numbers, the result is overflow without parentheses.
    return m * (n / gcd(m, n));
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    int p = 1;
    int ans = 0;
    REP(i, n) {
        if (a[i] != p) ans++;
        else p++;
    }
    cout << (p == 1 ? -1 : ans) << EOL;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#define MAX_N 10000
using namespace std;
typedef long long ll;
using namespace std;

int N;
vector<ll> a;
int div_count=0;
int main()
{
    cin>>N;
    for(int i=0;i<N;i++)
    {
        int temp=0;
        cin>>temp;
        int count=0;
        while(true)
        {
            if(temp%2==0)
            {
                temp/=2;
                count++;
            }
            else
            {
                div_count+=count;
                break;
            }
        }
   
    }   
    cout<<div_count<<endl;

}

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

char str[1000000];
long long Pow[1000000];
int A[1000000],C[1000000],M[1000000],N[1000000];

int main()
{
	Pow[0]=1;
	for(int i=1;i<=100000;i++)
		Pow[i]=Pow[i-1]*3%1000000007;
	scanf("%s",str+1);
	int len=strlen(str+1);
	for(int i=1;i<=len;i++)
	{
		A[i]=A[i-1]+(str[i]=='A');
		M[i]=M[i-1]+(str[i]=='?');
	}
	for(int i=len;i>=1;i--)
	{
		C[i]=C[i+1]+(str[i]=='C');
		N[i]=N[i+1]+(str[i]=='?');
	}
	long long ans=0;
	for(int i=1;i<=len;i++)
	{
		if(str[i]=='B'||str[i]=='?')
		{
			ans=(ans+A[i]*C[i]*Pow[M[i-1]%1000000007+N[i+1]]+A[i]*N[i+1]%1000000007*Pow[M[i-1]+N[i+1]-1]+\
			C[i]*M[i-1]%1000000007*Pow[M[i-1]+N[i+1]-1]+Pow[M[i-1]+N[i+1]-2]*M[i-1]%1000000007*N[i+1])%1000000007;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
const int MAXH = 25;
const int MAXW = 25;
const int dirx[4] = {0, 0, 1, -1};
const int diry[4] = {-1, 1, 0 ,0};

int h, w;
int dep[MAXH][MAXW];
char mp[MAXH][MAXW];

void dfs(int x, int y){
	// printf(":%d %d\n", x, y);
	if(x <= 0 || y <= 0 || x > h || y > w) return;
	for(int i = 0; i < 4; i++){
		if(mp[x + dirx[i]][y + diry[i]] == '.' && (dep[x + dirx[i]][y + diry[i]] == -1 || dep[x + dirx[i]][y + diry[i]] > dep[x][y] + 1)){
			dep[x + dirx[i]][y + diry[i]] = dep[x][y] + 1;
			dfs(x + dirx[i], y + diry[i]);
		}
	}
}

int main(){
	scanf("%d %d", &h, &w);
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++)
			cin >> mp[i][j];
	int ans = 0;
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++)
			if(mp[i][j] == '.'){
				memset(dep, -1, sizeof(dep));
				dep[i][j] = 1;
				int maxval = -1, maxx = 0, maxy = 0;
				for(int i = 1; i <= h; i++){
					for(int j = 1; j <= w; j++){
						if(dep[i][j] > maxval){
							maxval = dep[i][j];
							maxx = i;
							maxy = j;
						}
					}
				}
				// printf("%d %d\n", maxx, maxy);
				memset(dep, -1, sizeof(dep));
				dep[maxx][maxy] = 1;
				dfs(maxx, maxy);
				maxval = -1;
				for(int i = 1; i <= h; i++)
					for(int j = 1; j <= w; j++){
						maxval = max(maxval, dep[i][j]);
						// printf(":%d %d %d\n", i, j, dep[i][j]);
					}
				ans = max(ans, maxval - 1);
			}
	printf("%d\n", ans);
	return 0;
}

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

string ans(int x, int y){
    int sign1, sign2;
    if (x>0){
        sign1 = 1;
    } else if(x==0){
        sign1=0;
    } else if(x<0){
        sign1=-1;
    }
    if (y>0){
        sign2 = 1;
    } else if(y==0){
        sign2=0;
    } else if(y<0){
        sign2=-1;
    }
    if(sign1==1 & sign2==1){
        return "Positive";
    } else if(sign1==0 || sign2==0){
        return "Zero";
    } else if(sign1==-1 & sign2==1){
        return "Zero";
    } else if (sign1==1 & sign2==-1){
        return "Zero";
    } else if (sign1==-1 & sign2==-1){
        int numb = 0;  
        if (x<y){
            numb = -(x-y) + 1;
        } else if (x==y){
            return "Negative";
        }
        if (numb%2 == 0){
            return "Positive";
        } else if (numb%2 == 1){
            return "Negative";
        }
    }
}

int main(){
    int a,b;
    cin >> a;
    cin >> b;
    cout << ans(a,b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> t(n + 1, 0), x(n + 1, 0), y(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        cin >> t[i] >> x[i] >> y[i];
    }
    bool ok = true;
    for (int i = 1; i <= n; ++i) {
        int o  = abs(x[i] - x[i - 1] + y[i] - y[i - 1]);
        int dt = t[i] - t[i - 1];
        int d  = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        if (dt % 2 != o % 2 || dt < d) {
            ok = false;
            break;
        }
    }
    if (ok)
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
	int i,j,len,ty,mini;
	int count = 0;
	
	
	scanf("%d",&len);
	int A[len];
	
	for(i=0;i<len;i++)
 	scanf("%d",&A[i]);
 		
 
 	  
 	//printf("\n");
	
	for(i=0;i<=len-1;i++){
		mini=i;
		//count++;
	for(j=i;j<=len-1;j++){
	if (A[j]<A[mini]){
		   mini=j;
		   } 
	
   
}
	if(mini != i){ 
	
		   ty = A[mini];
                A[mini] = A[i];
                A[i] = ty;
                count++;
}
}
	for(i=0; i<len; i++){
        printf("%d", A[i]);
        if(i!=len-1) printf(" ");
		  }
     
    printf("\n");
    printf("%d",count);
    printf("\n");
    return 0;
}


Measured memory_bytes: 2048
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  ll N, K; cin >> N >> K;

  ll ans = 0;
  for (ll i = K; i <= N + 1; i++){
    ll now = i * (2 * N - i + 1) / 2 - i * (i - 1) / 2 + 1;
    ans += now; ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
s = input()
op1 = "+"
op2 = "-"

a = [0 for _ in range(8)]
a[0] = int(s[0]) + int(s[1]) + int(s[2]) + int(s[3])
a[1] = int(s[0]) + int(s[1]) + int(s[2]) - int(s[3])
a[2] = int(s[0]) + int(s[1]) - int(s[2]) + int(s[3])
a[3] = int(s[0]) + int(s[1]) - int(s[2]) - int(s[3])
a[4] = int(s[0]) - int(s[1]) + int(s[2]) + int(s[3])
a[5] = int(s[0]) - int(s[1]) + int(s[2]) - int(s[3])
a[6] = int(s[0]) - int(s[1]) - int(s[2]) + int(s[3])
a[7] = int(s[0]) - int(s[1]) - int(s[2]) - int(s[3])

if a[0] == 7:
    print(s[0]+op1+s[1]+op1+s[2]+op1+s[3]+"=7")
    exit()
elif a[1] == 7:
    print(s[0]+op1+s[1]+op1+s[2]+op2+s[3]+"=7")
    exit()
elif a[2] == 7:
    print(s[0]+op1+s[1]+op2+s[2]+op1+s[3]+"=7")
    exit()
elif a[3] == 7:
    print(s[0]+op1+s[1]+op2+s[2]+op2+s[3]+"=7")
    exit()
elif a[4] == 7:
    print(s[0]+op2+s[1]+op1+s[2]+op1+s[3]+"=7")
    exit()
elif a[5] == 7:
    print(s[0]+op2+s[1]+op1+s[2]+op2+s[3]+"=7")
    exit()
elif a[6] == 7:
    print(s[0]+op2+s[1]+op2+s[2]+op1+s[3]+"=7")
    exit()
elif a[7] == 7:
    print(s[0]+op2+s[1]+op2+s[2]+op2+s[3]+"=7")
    exit()


Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  ll ans=0;
  ans=b/x-a/x;
  if(a%x==0){
    ans++;
  }
  cout << ans;
}

Measured memory_bytes: 3572
N,M=gets.split.map(&:to_i)
a={}
b={}
t=0
M.times{
  c,d=gets.split
  next if b[c]
  if d=="AC"
    t+=a[c]||0
    b[c]=true
  else
    a[c]=(a[c]||0)+1
  end
}
puts "#{b.size} #{t}"


Measured memory_bytes: 15228
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
///////////////////////////////////////////
ll h,w;
int main(){speed
    cin>>h>>w;
    if(h%3==0||w%3==0){
        cout<<0;
        return 0;
    }
    ll ans=100000000000000;
    ll S=h*w;
    for(int i=1;i<h;i++){
        ll s1=1,s2=1,s3=1;
        s1=i*w;
        if(w%2==0){
            s2=(h-i)*(int)w/2;
            s3=(h-i)*(int)w/2;
            ll x=max(s1,max(s2,s3))-min(s1,min(s2,s3));
            ans=min(x,ans);
        }
        else{
            s2=(h-i);
            s2*=w/2;
            s3=(h-i);
            s3*=(int)((w)/2+1);
            ll x=max(s1,max(s2,s3))-min(s1,min(s2,s3));
            ans=min(x,ans);
        }
        //cout<<s1<<" "<<s2<<" "<<s3<<endl;
    }
    for(int i=1;i<w;i++){
        //cout<<i<<endl;
        ll s1=1,s2=1,s3=1;
        s1=i*h;
        if(h%2==0){
            s2=(w-i)*(int)h/2;
            s3=(w-i)*(int)h/2;
            ll x=max(s1,max(s2,s3))-min(s1,min(s2,s3));
            ans=min(x,ans);
        }
        else{
            s3*=(w-i);
            s3*=(h/2+1);
            s2*=(w-i);
            s2*=h/2;
            ll x=max(s1,max(s2,s3))-min(s1,min(s2,s3));
            ans=min(x,ans);
        }
        //cout<<s1<<" "<<s2<<" "<<s3<<endl;
    }
    for(int i=1;i<w;i++){
        ll s1=i*h;
        ll s2=1;
        ll s3=1;
        ll W=w-i;
        if(W%2==0){
            s2*=h;
            s2*=(W/2);
            s3*=h;
            s3*=(W/2);
        }
        if(W%2!=0){
            s2*=h;
            s2*=(W/2);
            s3*=h;
            s3*=(W/2+1);
        }
        ll x=max(s1,max(s2,s3))-min(s1,min(s2,s3));
        ans=min(x,ans);
    }
    for(int i=1;i<h;i++){
        ll s1=i*w;
        ll s2=1;
        ll s3=1;
        ll H=h-i;
        if(H%2==0){
            s2*=w;
            s2*=(H/2);
            s3*=w;
            s3*=(H/2);
        }
        if(H%2!=0){
            s2*=w;
            s2*=(H/2);
            s3*=w;
            s3*=(H/2+1);
        }
        ll x=max(s1,max(s2,s3))-min(s1,min(s2,s3));
        ans=min(x,ans);
    }
    cout<<ans;
}


Measured memory_bytes: 256
from sys import stdin

N = int(stdin.readline().rstrip())
H_list = [int(x) for x in stdin.readline().rstrip().split()]

if N == 1:
    print(1)
    exit()

cnt = 1
if H_list[1] >= H_list[0]:
    cnt += 1

for i in range(2, N):
    if H_list[i] >= max(H_list[:i]):
        cnt += 1

print(cnt)


Measured memory_bytes: 38384
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
const ll INF = 1e15;
const ld eps = 1e-6;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	ll H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int,input().split()))
t = 0

if N == 2:
    t += B[0]
else:
    for i in range(N - 2):
        if i == 0:
            if B[i] <= B[i + 1]:
                t += 2 * B[i]
            else:
                t += B[i] + B[i + 1]
        else:
            if B[i] <= B[i + 1]:
                t += B[i]
            else:
                t += B[i + 1]

print(t + B[N - 2])



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

int main(void){
	int N;

	while(cin>>N, N){
		int x[N],y[N];
		x[0] = y[0] = 0;
		int minX=0,maxX=0,minY=0,maxY=0;

		for(int i=1;i<N;i++){
			int n,d;
			cin>>n>>d;

			x[i] = x[n];
			y[i] = y[n];
			if(d == 0) x[i]--;
			if(d == 1) y[i]++;
			if(d == 2) x[i]++;
			if(d == 3) y[i]--;

			minX = min(minX,x[i]);
			minY = min(minY,y[i]);
			maxX = max(maxX,x[i]);
			maxY = max(maxY,y[i]);
		}

		cout<<maxX-minX+1<<" "<<maxY-minY+1<<endl;
	}

	return 0;
}

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

typedef pair<int,int> P;

int n;
int t[10][10];
long long v;
map<long long,bool> m;
vector<P> can;
int dy[] = {-1,0,1,0} , dx[] = {0,1,0,-1};

bool rec(int id);

bool dfs(int id,int y,int x,int sum){
  if(sum == 0)return rec(id+1);
  if(sum>0)return false;

  for(int i=0;i<4;i++){
    int ty = y+dy[i], tx = x+dx[i];
    if(ty<0 || tx<0 || n<=ty || n<= tx)continue;
    if( (v>>(ty*n+tx)) & 1LL || t[ty][tx]<0)continue;
    v |= 1LL << (ty*n+tx);
    if(dfs(id,ty,tx,sum+t[ty][tx]))return true;
    v &= ~(1LL << (ty*n+tx));
  }
  return false;
}

bool rec(int id){
  if(id == can.size())return true;
  if(m[v])return false;
  m[v] = true;
  int y = can[id].first, x = can[id].second;
  return dfs(id,y,x,t[y][x]);
}

int main(){
  while(cin >> n,n){
    int sum = 0; can.clear(); m.clear();
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++){
	cin >> t[i][j];
	sum += t[i][j];
	if(t[i][j]<0){
	  can.push_back(P(i,j));
	  v |= 1LL<<(i*n+j);
	}
      }
    v = 0LL;

    cout << ( (!sum && rec(0))?"YES\n":"NO\n" );
  }
}

Measured memory_bytes: 2480
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

ll gcd (ll a, ll b) {     //Eulers algorithm
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

ll arr[21][21];
ll dp[(1<<21)+1];
ll m = 1000000007;
ll f(ll s,ll n){
  ll j = __builtin_popcount(s);
  if(s == (1<<n)-1){return 1;}
  if(j==n){return 0;}
  if(dp[s]!=-1){return dp[s];}
//   cout<<j<<"\n";
  ll ans = 0;
  rep(i,0,n-1){
      if( (s & 1<<i)==0 && arr[i][j]==1){
          ans = (ans + f((s | 1<<i),n)%m)%m;
      }
  }
  dp[s] = ans;
  return ans;
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n; cin>>n;
    memset(dp,-1,sizeof(dp));
    rep(i,0,n-1){
        rep(j,0,n-1){
            cin>>arr[i][j];
        }
    }
    cout<<f(0,n);
}


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

int main(){
  int n;
  cin >> n;
  char s[n+1];
  for(int i = 1; i <= n; i++){
    cin >> s[i];
  }
  int b[n+1] = {0}, w[n+1] = {0};
  for(int i = 1; i <= n; i++){
    if(s[i] == '.') {
      w[i] = w[i-1] + 1;
      b[i] = b[i-1];
    }
    if(s[i] == '#'){
       b[i] = b[i-1] + 1;
       w[i] = w[i-1];
    }
  }
  int ans = w[n];
  for(int i = 1; i <= n; i++){
    ans = min(ans, b[i] + w[n] - w[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void calc(vector<vector<int> > hap)
{
  vector<vector<int> > dp(hap.size(),vector<int>(3,0));
  dp = hap;
  /*
  for (auto i:3)
    dp[0][i] = hap[0][i];
  */
  int n = hap.size()-1, ans=0;

  for (auto i=1;i<hap.size();i++)
  {
    for (auto j=0;j<3;j++)
    {
      int m=0;
      for(auto k=0;k<3;k++)
      {
          if(k!=j)
          m = max(m,dp[i-1][k]);
      }

        dp[i][j] += m;
    }
  }
  
  /*
  // To test output

  cout << endl;
  for (auto i=0;i<hap.size();i++)
  {
    for (auto j=0;j<3;j++)
    {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */
  for (auto i=0;i<3;i++)
    ans = max(dp[n][i],ans);

  cout << ans;

}

int main()
{
int n;
  cin >> n;
  
  vector<vector<int> > hap(n,vector<int>(3,0));
  for (auto i=0;i<n;i++)
    for (auto j=0;j<3;j++)
    cin >> hap[i][j];
  
  calc(hap);
}



                          

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll h(n);
  rep(i,n) cin>>h[i];
  vll dp(n);
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for(int i=2;i<n;i++){
    dp[i]=min(abs(h[i-2]-h[i])+dp[i-2],abs(h[i-1]-h[i])+dp[i-1]);
  }
  COUT(dp[n-1]);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<string>
#define pii pair<int, int>
#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back
#define S second
#define F first
using namespace std;



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

	
	int n;
	cin >> n;
	if (n >= 30) cout << "Yes\n";
	else cout << "No\n";

}

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

const int N=2e5+5;
int a[N];
ll pre[N],suf[N];
ll dp[N][3];

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++){
        pre[i]=a[i]+(i>=2?pre[i-2]:0);
    }
    for(int i=n;i;i--){
        suf[i]=a[i]+(i+2<=n?suf[i+2]:0);
    }
    ll ans=-1e18;
    if(n%2==0){
        ans=max(pre[n-1],pre[n]);
        for(int i=1;i+3<=n;i++) if(i&1) ans=max(ans,pre[i]+suf[i+3]);
    }
    else{
        ans=max(pre[n-1],pre[n-2]);
        ans=max(ans,max(suf[2],suf[3]));
        for(int i=1;i+4<=n;i++)if(i&1){
            ans=max(ans,pre[i]+suf[i+4]);
        }
        dp[0][0]=0,dp[0][1]=dp[0][2]=0xcfcfcfcfcfcfcfcf;
        for(int i=1;i<=n;i++){
            for(int j=0;j<3;j++) dp[i][j]=dp[max(0,i-2)][j]+a[i];
            if(i-3>=1) dp[i][1]=max(dp[i][1],dp[max(0,i-3)][0]+a[i]);
            if(i-3>=1) dp[i][2]=max(dp[i][2],dp[max(0,i-3)][1]+a[i]);
        }
//        cout<<"dp: "<<dp[n][2]<<endl;
        ans=max(ans,dp[n][2]);
    }
    cout<<ans;
}


Measured memory_bytes: 12248