akhauriyash/Code-Regression huggingface dataset:
// C
 #ifndef _GLIBCXX_NO_ASSERT
 #include <cassert>
 #endif
 #include <cctype>
 #include <cerrno>
 #include <cfloat>
 #include <ciso646>
 #include <climits>
 #include <clocale>
 #include <cmath>
 #include <csetjmp>
 #include <csignal>
 #include <cstdarg>
 #include <cstddef>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <ctime> 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #include <ccomplex>
 #include <cfenv>
 #include <cinttypes>
 #include <cstdbool>
 #include <cstdint>
 #include <ctgmath>
 #include <cwchar>
 #include <cwctype>
 #endif
 
 // C++
 #include <algorithm>
 #include <bitset>
 #include <complex>
 #include <deque>
 #include <exception>
 #include <fstream>
 #include <functional>
 #include <iomanip>
 #include <ios>
 #include <iosfwd>
 #include <iostream>
 #include <istream>
 #include <iterator>
 #include <limits>
 #include <list>
 #include <locale>
 #include <map>
 #include <memory>
 #include <new>
 #include <numeric>
 #include <ostream>
 #include <queue>
 #include <set>
 #include <sstream>
 #include <stack>
 #include <stdexcept>
 #include <streambuf>
 #include <string>
 #include <typeinfo>
 #include <utility>
 #include <valarray>
 #include <vector> 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #include <array>
 #include <atomic>
 #include <chrono>
 #include <condition_variable>
 #include <forward_list>
 #include <future>
 #include <initializer_list>
 #include <mutex>
 #include <random>
 #include <ratio>
 #include <regex>
 #include <system_error>
 #include <thread>
 #include <tuple>
 #include <typeindex>
 #include <type_traits>
 #include <unordered_map>
 #include <unordered_set>
 #endif
using namespace std;
int dp[110][10010];
int main(){
    int N,W; cin >> N >> W;
    vector<int> v(N),w(N);
    for(int i=0;i<N;++i) cin >> v[i] >> w[i];
    for(int i=0;i<=N;++i){
        for(int j=0;j<=W;++j){
            dp[i][j] = -1;
        }
    }
    for(int i=0;i<W;++i) dp[0][i] = 0;
    for(int i=0;i<N;++i){
        for(int j=0;j<=W;++j){
            dp[i+1][j] = dp[i][j];
            if(j-w[i]>=0){
                dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]] + v[i]);
                dp[i+1][j] = max(dp[i+1][j],dp[i+1][j-w[i]] + v[i]);
            }
            /*for(int k=1;k<=j;++k){
                if(j-w[i]*k < 0) break;
                dp[i+1][j] = max(dp[i+1][j],dp[i][j-w[i]*k] + v[i]*k);
            }*/
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7040
#include <stdio.h>

int main(){ 
	int n, i,tmp;
	int num[100] = { 0 };
	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%d", &num[i]);
	}

	for (i = 0;i<(n/2); i++){
		tmp = num[i];
		num[i] = num[n - i-1];
		num[n - i-1] = tmp;
	}
	for (i = 0; i < n; i++){
		if (i == (n - 1)){
			printf("%d\n", num[i]);
		}
		else{
			printf("%d ", num[i]);
		}
	}

	return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < 7; i++) {
    int d = N - 4 * i;
    if (d < 0) continue;
    if (d % 7 == 0) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";

  return 0;
}


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

int main() {
  string s;
  int K;
  cin >> s >> K;
  for(int i=0;i<s.length();i++){
    if(K>=('a'-s[i]+26)%26){
      K-=('a'-s[i]+26)%26;
      s[i]='a';
    }
  }
  K=K%26;
  s[s.length()-1]=s[s.length()-1]+K;
  cout << s;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
ll a[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n ;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);

    ll ans=0;
    vector<ll> l;
    int c=0;
    for(int i=n-1;i>=1;i--){
        if(l.size()==2)break;
        if(a[i-1]==a[i]&&c-i!=1){
            l.push_back(a[i]);
            c=i;
        }
    }
    if(l.size()==2)
    cout << ll(l[0]*l[1]) << "\n";
    else{
         cout << 0 << "\n";
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define All(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n);
  Cins(int, 2 * n, l);

  sort(All(l));

  int ans = 0;
  for (int i = 0; i < n; ++i) ans += min(l[2 * i], l[2 * i + 1]);
  cout << ans << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int n = 7;
int a[n];

int read() {
  for (int i = 0; i < n; i++) {
    if (scanf("%d", &a[i]) < 1) {
      return false;
    }
  }
  return true;
}

void solve() {
  long long res = 0;
  for (int i = 0; i < 2; i++) {
    if (a[0] < i || a[3] < i || a[4] < i) {
      continue;
    }
    long long cur = ((a[0] - i) - ((a[0] - i) & 1));
    cur += a[1];
    cur += ((a[3] - i) - ((a[3] - i) & 1));
    cur += ((a[4] - i) - ((a[4] - i) & 1));
    cur += 3 * i;
    res = max(res, cur);
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int GCD(int A, int B) {
	if (B == 0) return A;
	return GCD(B, A % B);
}

int main() {
	int K, ANS = 0;
	cin >> K;
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {
				ANS += GCD(GCD(i, j), k);
			}
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 3676
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int r,g,b,ans;
	cin>>r>>g>>b;
	ans=r*100+g*10+b;
	if(ans%4==0) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
vals = []
mappy = {}
ans = 0
for i in range(n):
    if(i+1-a[i] > 0):
        if(i+1-a[i] in mappy):
            mappy[i+1-a[i]]+=1
        else:
            mappy[i+1-a[i]] =1
for i in range(n):
    if(i+1+a[i]in mappy):
        ans+=mappy[i+1+a[i]]
print(ans)



Measured memory_bytes: 97672
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String p = sc.next();
		String c;
		int flag = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(i + p.length() <= s.length()){
				c = s.substring(i, p.length() + i);
			} else {
				c = s.substring(i, s.length()) + s.substring(0, p.length() - (s.length() - i));
			}
			
			if(c.equals(p)) {
				flag = 1;
				break;
			}
		}
		
		if(flag == 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

#define mp make_pair
#define pb push_back

#define int long long
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int mpow(int x, int y, int mod) {
    if(y==0)
        return 1;
    int temp = mpow(x,y/2, mod);
    temp*=temp;
    temp%=mod;
    if(y&1)
        return (temp*x)%mod;
    return temp; 
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin>>s;
    int n = s.length();
    if(s.length()<4)
    {
        cout<<0;
        return 0;
    }
    int premod[n];
    int ans = 0;
    vector<int> freq(2019);
    freq[0]=1;
    premod[0]=s[0]-'0';
    for(int i=1;i<n;i++) {
        premod[i]=(premod[i-1]*10+s[i]-'0')%2019;
        premod[i]%=2019;
    }

    for(int i=0;i<n;i++) {
        premod[i]=premod[i]*mpow(10, n+1-i, 2019);
        premod[i]%=2019;
        // cout<<premod[i]<<"\n";
        freq[premod[i]]++;
    }

    for(int i=0;i<2019;i++) {
        ans+=(freq[i]*(freq[i]-1)/2);
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 5360
import numpy as np
def main():
    mod=10**9+7
    n,k=map(int,input().split())
    A=np.matrix([list(map(int,input().split()))for _ in range(n)],dtype='O')
    D=A.copy()
    for i in range(k.bit_length()-1,0,-1):
        D=(D*D)%mod
        if k&1<<(i-1)>0:
            D=(D*A)%mod
    print(int(((D*np.ones(n,dtype='O')[:,np.newaxis])%mod).sum()%mod))
main()

Measured memory_bytes: 14564
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 10000005

ll f[MAX_N] = {};
int main() {
    ll n;
    cin >> n;


    srep(i,1,n+1){
        int ii = i;
        while(ii <= n){
            f[ii]++;
            ii += i;
        }
    }

    ll ans = 0;
    srep(i,1,n+1){
        ll ii = i;
        ans += f[i] * ii;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 81624
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

using namespace std;
ll vs[300000+10];
const int MOD = 1000000007;

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%lld", &vs[i]);
  }
  ll res = 0;
  REP(b, 60) {
    ll cnt1 = 0;
    REP(i, n) {
      if(vs[i] & (1LL << ll(b))) {
        ++cnt1;
      }
    }
    ll cnt0 = n - cnt1;
    ll tmp = cnt1 * cnt0 % MOD * ((1LL << ll(b)) % MOD) % MOD;
    res = (res + tmp) % MOD;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    int mx = 0;
    for(int i=0; i<s.size() - t.size() + 1;i++) {
        int cnt = 0;
        for(int j=0;j < t.size();j++) {
            if (s[i + j] == t[j]) cnt++;
        }
        mx = max(mx, cnt);
    }
    cout << t.size() - mx << endl;
    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int h,w;
  cin>>h>>w;
  vector<string>s(h);
  rep(i,h) cin>>s[i];
  vector<bool>l(h,false),r(w,false);
  rep(i,h)rep(j,w){
    if(s[i][j]=='#'){
      l[i]=true;
      r[j]=true;
    }
  }
  rep(i,h){
    if(l[i]){
      rep(j,w){
        if(r[j])
          cout<<s[i][j];
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 3592
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 20, F = 1e3 + 10;
const ll inf = 1e15 + 42;

struct state {
	int l, r, a, b;
	bool operator<(const state &o) const {
		return tie(l, r, a, b) < tie(o.l, o.r, o.a, o.b);
	}
};

// ll dp[N][N][F][F];
map<state, pll> dp;
ll A[N];

pll solve(int l, int r, int a, int b);

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> A[i];
	}
	auto ans = solve(2, n - 1, 1, 1);
	cout << A[1] + A[n] + ans.first + ans.second << '\n';
}

pll solve(int l, int r, int a, int b) {
	if (l > r) {
		return {0, 0};
	} else if (l == r) {
		return {A[l], A[l]};
	} else if (dp.find({l, r, a, b}) != dp.end()) {
		return dp[{l, r, a, b}];
	} else {
		pll ans = {inf, inf};
		for (int i = l; i <= r; ++i) {
			pll cand = {0, 0};
			pll ans_lt = solve(l, i - 1, a, a + b);
			pll ans_rt = solve(i + 1, r, a + b, b);
			cand.first = A[i] + ans_lt.first + ans_lt.second + ans_rt.first;
			cand.second = A[i] + ans_rt.first + ans_rt.second + ans_lt.second;
			if (a * cand.first + b * cand.second < a * ans.first + b * ans.second) {
				ans = cand;
			}
		}
		dp[{l, r, a, b}] = ans;
		return ans;
	}
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int mod = 998244353;
const int N = 200010;

ll f[N], If[N];

ll bigmod(ll a, ll n, ll M) {
  ll res = 1LL;
  while (n) {
    if (n & 1) res = (res * a) % M;
    a = (a * a) % M;
    n >>= 1;
  }
  return res % M;
}

ll nCr(ll n, ll r) {
  return (((f[n] * If[r]) % mod) * If[n - r]) % mod;
}

int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  f[0] = 1;
  f[1] = 1;
  for (int i = 2; i <= n; ++i) f[i] = (f[i - 1] * i) % mod;
  If[0] = 1;
  If[1] = 1;
  for (int i = 2; i <= n; ++i) If[i] = bigmod(f[i], mod - 2, mod);
  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ll val = ((nCr(n - 1, i) * m % mod) * bigmod(m - 1, (n - 1) - i, mod)) % mod;
    ans = (ans + val) % mod;
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 6952
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if ((a < b) && (b < c)){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return (0);
}

Measured memory_bytes: 580
r,c=map(int,input().split())
l=[]
for i in range(r):
    l.append(list(map(int,input().split())))
csum=[0 for j in range(c)]
gsum=0
for i in range(r):
    rsum=0
    for j in range(c):
        print(l[i][j],end=' ')
        rsum+=l[i][j]
        csum[j]+=l[i][j]
    print(rsum)
    gsum+=rsum
for elem in csum:
    print(elem,end=' ')
print(gsum)
    


Measured memory_bytes: 6220
#include<stdio.h>
int main(int argc){
int W,H,x,y,r,M,m,R,L;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
M=y+r;
m=y-r;
R=x+r;
L=x-r;
if (M<=H&&m>=0&&R<=W&&L>=0)
puts("Yes");
else puts("No");
return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1005,M=20005;
struct block
{
	int w,s,v;
	bool operator<(const block k)const
	{
		return w+s<k.w+k.s;
	}
}a[N];
int n,dp[M],ans;
main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i].w>>a[i].s>>a[i].v;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=a[i].s;j>=0;j--)
			dp[j+a[i].w]=max(dp[j+a[i].w],dp[j]+a[i].v);
	for(int i=0;i<=20000;i++)
		ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string a;cin>>a;
  ll n=a.size();
  ll ans=1+n*(n-1)/2;
  map<char,ll>M;
  rep(i,n)M[a[i]]++;
  for(auto p:M){
    ans-=p.second*(p.second-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main() {
	ll h;
	cin >> h;

	ll ans = 1;
	ll n = 1;
	for (ll i = 1; i < 1000000000010; i = i * 2) {
		if (h > ans) {
			ans = ans * 2 + 1;
		}
		else if (h <= ans) {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,b,c,sum=0;
    cin>>n;
    ll a[n];
    mll m;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
        sum+=a[i];
    }
    ll q;
    cin>>q;
    while(q--)
    {
        cin>>b>>c;
        sum-=(m[b]*b);
        sum+=(m[b]*c);
        cout<<sum<< "\n";
        m[c]+=m[b];
        m.erase(b);
    }
    return 0;
}


Measured memory_bytes: 8352
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[input() for i in range(n)]
    ll=[]
    ans='Yes'
    if len(set(l))!=n:
        ans='No'
    else:
        for j in range(n-1):
            if l[j][-1]==l[j+1][0]:
                ll.append(l[j])
            else:
                ans='No'
                break
    print(ans)
resolve()

Measured memory_bytes: 3064
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
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);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<ll> A(N+1), B(N);
    for(int i=0; i<N+1; i++) cin >> A[i];
    for(int i=0; i<N  ; i++) cin >> B[i];

    ll ans = 0;
    for(int i=0; i<N; i++) {
        // i 番目のを倒す
        {
            ll add = min(A[i], B[i]);
            ans += add;
            B[i] -= add;
            A[i] -= add;
        }
        
        // i+1 番目のをたおす
        {
            ll add = min(A[i+1], B[i]);
            ans += add;
            B[i  ] -= add;
            A[i+1] -= add;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef priority_queue<int> P_QI;
typedef priority_queue<string> P_QS;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector< int > :: iterator $$;

#define SET(arr) memset(arr, -1, sizeof(arr))
#define CLR(arr) memset(arr, 0, sizeof(arr))

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

#define $ vector< int > :: iterator
#define m_p make_pair
#define p_b push_back
#define rep(i, n) for(int i=0; i<(n); i++)
#define forn(i, n) for (int i = 1; i <=(int)(n); ++i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define forba(i, b, a) for (int i = (int)(b); i >= (int)(a); --i)

#define forv(i,v) rep(i,SZ(v))
#define forit(i,s) for(auto i=(s).begin();i!=(s).end();++i)

#define Boost ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define _ <<" "<<
#define CS(i) cout<<"Case "<<(int)(i)<<": "

const int MOD = 1e9+7;
const int inf = 1e9+9;
const long long INF = 1e18+3;
const ld eps = 1e-9;
const ld PI=acos(-1.0);
const ld E=2.71828182845904523536;

int main() {
Boost;
//READ("in.txt");
//WRITE("out.txt");
    int r,g,b,n,rem,ans=0;
    cin>>r>>g>>b>>n;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            rem=n-i*r-j*g;
            if(rem>=0 && rem%b==0) ans++;
        }
    }
    cout<<ans<<endl;

return 0;
}





Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
typedef int key;

int main(){
	int r,c,n;
	scanf("%d%d%d",&r,&c,&n);
	map<key,vector<pair<key,long long>>>m;
	string s1,s2;
	for(;n;n--){
		int s1,s2,d;
		scanf("%d%d%d",&s1,&s2,&d);
		m[s1].emplace_back(s2+r,d);
		m[s2+r].emplace_back(s1,-d);
	}
	for(;!m.empty();){
		long long a=-1LL<<61,b=1LL<<61;
		auto s=m.begin()->first;
		vector<pair<key,long long> >st={{s,0}};
		map<key,long long>memo={{s,0}};
		for(;!st.empty();){
			auto p=*st.rbegin();st.pop_back();
			auto cur=p.first;long long d=p.second;
			memo[cur]=d;
			if(cur<=r)a=max(a,d);
			else b=min(b,d);
			for(auto &e:m[cur]){
				if(memo.find(e.first)==memo.end()){
					st.emplace_back(e.first,d+e.second);
				}else if(memo[e.first]!=d+e.second){
					puts("No");
					return 0;
				}
			}
		}
		if(a>b){
			puts("No");
			return 0;
		}
		for(auto &e:memo)m.erase(m.find(e.first));
	}
	puts("Yes");
}

Measured memory_bytes: 22144
#include <stdio.h>
#include <stdlib.h>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


SINT32 main() {
    SINT32 n,q;
    scanf("%d%d",&n,&q);
    
    SINT8 s[200001] = {'F'};
    scanf("%s",s);

    SINT32 data[200001] = {0};
    SINT32 ans[200001] = {0};


    for (SINT32 i = 1; i < n+1; i++) {
        if (s[i] == 'C') {
            if (s[i-1] == 'A') {
                data[i] = 1;
            } else {
                data[i] = 0;
            }
        } else {
            data[i] = 0;
        }
    }

    ans[0] = 0;
    for (SINT32 i = 1; i < n+1; i++) {
        ans[i] = data[i] + ans[i-1];
    }


    SINT32 a,b;
    for (SINT32 i = 0; i < q; i++) {
        scanf("%d%d",&a,&b);

        printf("%d\n",ans[b-1]-ans[a-1]);
    }

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int dp[1111][1111];

void Main() {
  int n,m;
  cin >> n >> m;
  int d[n],c[m];
  rep(i,n) R d[i];
  rep(i,m) R c[i];
  rep(i,n+1)rep(j,m+1)dp[i][j]=MAX;
  dp[0][0]=0;
  rep(i,n)rep(j,m) {
    dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
    dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+d[i]*c[j]);
  }
  int ans=MAX;
  rep(i,m+1) ans=min(ans,dp[n][i]);
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 6612
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;
const int kMod = 998244353;

int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; ++i) {
    cin >> D[i];
  }

  if (D[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  
  int Dmax = *max_element(D.begin(), D.end());
  vector<int> C(Dmax + 1, 0);
  for (int i = 0; i < N; ++i) {
    C[D[i]] += 1;
  }

  if (C[0] != 1) {
    cout << 0 << endl;
  } else {
    ll ans = 1;
    for (int i = 1; i <= Dmax; ++i) {
      for (int j = 0; j < C[i]; ++j) {
	ans *= C[i - 1];
	ans %= kMod;
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1024
#define yuki(x, y) for(int i = x; i < (y); ++i)
#define yukj(x, y) for(int j = x; j < (y); ++j)
#define yukii(x, y) for(int i = x; i <= (y); ++i)
#define yukji(x, y) for(int j = x; j <= (y); ++j)
#define yuk(x, y, z) for(int x = y; x < (z); ++x)
#define yui(x, y, z) for(int x = y; x >= (z); --x)
#define sclr(x) memset(x, 0, sizeof(x))
#define sclr1(x) memset(x, -1, sizeof(x))
#define scl(x, y) memset(x, y, sizeof(x))
#define ft first
#define sc second
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long lol;
int i, o, t, j, l;
lol rm1(int x)
{
    return ~(~x|1);
}
int main(int argc, char **argv)
{
	scanf("%d%d%d%d%d", &i, &o, &t, &j, &l);
	printf("%lld\n", max(rm1(i)+o+rm1(j)+rm1(l), i && j && l ? 3+rm1(i-1)+o+rm1(j-1)+rm1(l-1) : 0ll));
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main()
{
	char card[201];
	char str[201];
	char stra[201];
	int m,h,length;
	int i,k,j=0;

	while(1){
		scanf("%s",card);
		length=strlen(card);
		if(strcmp(card,"-")==0) break;
		scanf("%d",&m);
		for(k=0;k<m;k++){
		    strcpy(str,card);
		    scanf("%d",&h);
		    for(i=0;i<(length-h);i++){
		        card[i]=str[i+h];
	    	}
		   // printf("%s\n",card);
		    for(i=0;i<h;i++){
		        card[length-h+i]=str[i];
		        //printf("%d\n",length-h+i);
		    }
		}
		for(i=0;i<length;i++){
	        stra[j++]=card[i];
    	}
		stra[j++]='\n';
	    
	}
	stra[j]='\0';
	printf("%s",stra);
	
	return 0;
}


Measured memory_bytes: 2044
using System;

namespace ABC069_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var s2 = s.Substring(1, s.Length - 2);
            int count = s2.Length;
            Console.WriteLine("{0}{1}{2}", s[0], count, s[s.Length - 1]);
        }
    }
}


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

namespace ABC086C
{
    class Program
    {
        static bool canTravelling()
        {
            var n = int.Parse(Console.ReadLine());
            int currentT = 0, currentX = 0, currentY = 0;
            foreach (var _ in Enumerable.Range(0, n))
            {
                var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
                var t = nums[0];
                var x = nums[1];
                var y = nums[2];

                var deltaT = t - currentT;
                var deltaX = Math.Abs(x - currentX);
                var deltaY = Math.Abs(y - currentY);
                var deltaSum = deltaX + deltaY;

                if (deltaT < deltaSum)
                {
                    return false;
                }

                if (((deltaT - deltaSum) % 2) == 1)
                {
                    return false;
                }

                currentT = t;
                currentX = x;
                currentY = y;

            }

            return true;
        }

        static void Main(string[] args)
        {
            Console.WriteLine(canTravelling() ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 15440
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <random>

#define fol(i,n) for(int i=0;i<n;i++)

using namespace std;

long long gcd(long long a, long long b) {
    return b != 0 ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}
int main(){
    int n;
    long long c,ans=1;
    cin >>n;
    fol(i,n){
        cin >>c;
        ans = lcm(c,ans);
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string S;
void input(){
    fast_io();
    cin >> S;
}

int solve(){
    ll ans = 0;
    char now = S[0];
    for (int i = 0; i < S.length(); i++)
    {
        if(S[i]==now) continue;
        ans++;
        now = S[i];
    }
    cout << ans << endl;
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int main(){
    int totalNumber;
    int japanese;
    int overseas;
    scanf("%d %d %d",&totalNumber,&japanese,&overseas);
    char string[totalNumber];
    scanf("%s",string);
    int canPass = japanese+overseas;
    int i;
    for (i=0;i<totalNumber;i++) {

        if (string[i] == 'a') {
            if (canPass > 0) {
                printf("Yes");
                canPass--;
            } else {
                printf("No");
            }
        }
        if(string[i] == 'b') {
            if (canPass > 0) {
                if (overseas > 0) {
                    printf("Yes");
                    overseas--;
                    canPass--;
                } else {
                    printf("No");
                }
            } else {
                printf("No");
            }
        }
        if(string[i] == 'c') {
            printf("No");
        }
        if(i == totalNumber-1) {
        } else {
            printf("\n");
        }
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 640
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

cum = [0] * (n+1)
for i, ai in enumerate(a):
    cum[i+1] += cum[i] + ai

cnt = Counter(cum)
ans = 0
for num in cnt.values():
    ans += num * (num-1) // 2

print(ans)

Measured memory_bytes: 40960
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 24 16:26:21 JST 2020
 **/

signed main() {
    Int n, Q;
    std::cin >> n >> Q;
    std::vector<std::list<Int>> ls(n);
    REP(q, Q) {
        Int c;
        std::cin >> c;
        if (c == 0) {
            Int t, x;
            std::cin >> t >> x;
            ls[t].push_back(x);
        } else if (c == 1) {
            Int t;
            std::cin >> t;
            Int cnt = 0;
            // // TLE
            // for (Int x : ls[t]) std::cout << x << (++cnt == ls[t].size() ? "" : " ");

            // AC
            Int sz = ls[t].size();
            for (Int x : ls[t]) std::cout << x << (++cnt == sz ? "" : " ");

            std::cout << "\n";
        } else if (c == 2) {
            Int s, t;
            std::cin >> s >> t;
            ls[t].splice(ls[t].end(), ls[s]);
            ls[s].clear();
        }
    }
}



Measured memory_bytes: 18768
N,M = map(int,input().split())
edge = [0]*M
for i in range(M):
    a,b,c=map(int,input().split())
    a -= 1
    b -= 1
    c *= -1
    edge[i] = (a,b,c)

inf = float('inf')
V = N
E = M
d = [inf]*V
d[0] = 0
for i in range(V):
    for j in range(E):
        From,To,cost = edge[j]
        if d[From] != inf and d[To]>d[From]+cost:
            d[To]=d[From]+cost
ans = d[N-1]
for i in range(V):
    for j in range(E):
        From,To,cost = edge[j]
        if d[From] != inf and d[To]>d[From]+cost:
            d[To]=d[From]+cost

if d[N-1]!=ans:
    print('inf')
else:
    print(-ans)

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int MAXN=101010;
int n,a[MAXN],b[MAXN],c[MAXN],dp[MAXN][3];

int main(){
    #ifdef Javier
        freopen(".in", "r", stdin);
    #endif // Javier

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

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

    for(int i=1;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
        dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
        dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
    }

    int sol=max(dp[n][0],max(dp[n][1],dp[n][2]));
    cout<<sol;
    return 0;
}



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

int main() {
  int n, s = 0;
  cin >> n;
  vector<pair<int,int>> v(n);
  rep(i, n){
    int a, b;
    cin >> a;
    --a;
    b = max(i, a);
    a = min(i, a);
    v[i] = make_pair(a, b);
  }
  sort(v.begin(), v.end());
  rep(i, n-1){
    if(v[i] ==v[i+1]) ++s;
  }
  cout << s << endl;
  return 0;
}

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

int main() {
	long long n,k;
	cin >> n >> k;
	long long am = n % k,ans=am;
	if(am > abs(am - k))
	{
		ans = abs(am - k);
	}
	cout << ans << endl;
	return 0;
}


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

bool a[101];
int main() {
  int x, n, p;
  cin >> x >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p;
    a[p] = true;
  }
  int b = 111, c;
  for (int i = 0; i <= 101; ++i) {
    if (!a[i] && abs(i - x) < b) {
      b = abs(i - x);
      c = i;
    }
  }
  cout << c;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

const ll MOD = 1e9 + 7;

ll pow_fast(ll n, ll k) {
  if (k == 0) {
    return 1LL;
  }
  if (k == 1) {
    return n;
  }

  if (k % 2 == 0) {
    ll tmp = pow_fast(n, k / 2);
    return tmp * tmp % MOD;
  } else {
    ll tmp = pow_fast(n, (k - 1) / 2);
    tmp *= tmp;
    tmp %= MOD;
    return tmp * n % MOD;
  }
}

template<typename T>
class stack
{
private:
vector<T> _vec;
public:
  stack () {
  };

  void push(T n) {
    _vec.push_back(n);
    return;
  }

  void pop() {
    if (this->empty()) {
      return;
    }
    _vec.erase(_vec.end() - 1);
    _vec.shrink_to_fit();
    return;
  }

  size_t size() {
   return _vec.size(); 
  }

  T top() {
    return _vec[this->size() - 1];
  }
  bool empty() {
    return _vec.empty();
  }
};


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

  stack<char> ans;

  for (ll i = 0; i < s.size(); i++)
  {
    if (s[i] == '0') ans.push('0');
    if (s[i] == '1') ans.push('1');
    if (s[i] == 'B') ans.pop();
  }
  
  vector<char> str;
  while (!ans.empty())
  {
    str.push_back(ans.top());
    ans.pop();
  }

  for (vector<char>::reverse_iterator it = str.rbegin(); it != str.rend(); ++it)
  {
    cout << *it;
  }
    cout << endl;
}

Measured memory_bytes: 3628
/*
Author : shah_entrance
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if((a+b)>=c)
        cout<<b+c<<endl;
    else
        cout<<a+2*b+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cmath>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long int ll;

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

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    
    ll c = 0, d = 0;
    REP(i, n){
        if(s[i] == 'a'){
            if(c < a + b){
                cout << "Yes" << '\n';
                c++;
            }
            else{
                cout << "No" << '\n';
            }
        }
        else if(s[i] == 'b'){
            if(c < a + b && d < b){
                cout << "Yes" << '\n';
                c++;
                d++;
            }
            else{
                cout << "No" << '\n';
            }
        }
        else{
            cout << "No" << '\n';
        }
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

vector<int> edge[2010];

int dfs(int v, int p, int dep, int dia) {
  int ret = dep > dia ? 1 : 0;
  for (int c : edge[v]) if (c != p) ret += dfs(c, v, dep+1, dia);
  return ret;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, K; cin >> N >> K;
  REP(i, N-1) {
    int a, b; cin >> a >> b; a--, b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  int ret = N;
  if (K % 2 == 0) {
    REP(i, N) ret = min(ret, dfs(i, -1, 0, K/2));
  } else {
    REP(i, N) {
      for (int c : edge[i]) ret = min(ret, dfs(i, c, 0, K/2) + dfs(c, i, 0, K/2));
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 512
n,k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9+7
inside = 0
outside = 0

for i in range(n-1):
	for j in range(i,n):
		if a[i] > a[j]:
			inside += 1

for i in range(n):
	for j in range(n):
		if a[i] < a[j]:
			outside += 1

inside %= mod
outside %= mod

ans = 0

ans += (inside*k)%mod
ans += ((1+k-1)*(k-1)*pow(2,mod-2,mod)*outside)%mod

print(ans % mod)

Measured memory_bytes: 3188
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<pair<int, int>>a(n);

	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;

		a[i]=make_pair(x, y);
	}

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

	for (auto p : a) {
		cout << p.first << " " << p.second << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 2e5 + 10;
int a[N], f[N];
int n;
LL k;

bool check(LL mid) {
	LL sum = 0;
	for (int i = 0; i < n; i++) {
		sum += max(0ll, a[i] - mid / f[i]);
	}
	return sum <= k;
}

int main() {
	scanf("%d%lld", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	for (int i = 0; i < n; i++) scanf("%d", f + i);
	sort(a, a + n, greater<int>());
	sort(f, f + n);
	LL l = 0, r = 1e12;
	while (l < r) {
		LL mid = (l + r) / 2;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%lld\n", r);
	return 0;
}


Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int N = sc.nextInt();
		int[] D = new int[N];
		for(int i=0; i<N; i++) {
			D[i] = sc.nextInt();
		}
		int M = sc.nextInt();
		int[] T = new int[M];
		for(int i=0; i<M; i++) {
			T[i] = sc.nextInt();
		}
		Arrays.sort(D);
		Arrays.sort(T);
		int i = 0;
		int j = 0;
		while(i < D.length && j < T.length) {
			if(D[i] == T[j]) {
				i++;
				j++;
			} else if(D[i] > T[j]) {
				System.out.println("NO");
				return;
			} else {
				i++;
			}
		}
		if(j == T.length) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
	
	static 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;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); 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() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 49400
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,j;
	char s[200000];
	scanf("%s", s);
	for(i=0; i<strlen(s); i++)
	{
		if(s[i]=='A')
		{
			for(j=strlen(s)-1; j>=i+1; j--)
			{
				if(s[j]=='Z')
				{
					printf("%d\n", j-i+1);
					break;
				}
			}
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 384
import scala.io.StdIn

object Main extends App {

  val Array(a, b, c, d, e, f) = StdIn.readLine().split(' ').map(_.toInt)

  def judge(water: Int, sato: Int, maxw: Int, maxs: Int): Boolean = {
    water + sato <= f && e * water  >= sato * 100 && sato * maxw > maxs * water
  }

  val waters = (0 to f).flatMap { ai => (0 to f).map(bi => 100 * ai * a + 100 * bi * b).filter(e => e < f)}

  val sugars = (0 to f).flatMap { ci => (0 to f).map(di => ci * c + di * d).filter(e => e < f)}

  var result = (1, -1)
  waters.foreach { w =>
    sugars.foreach { s =>
      //if (judge(w, s) && w != 0 && max < ((s + w) / w)) {
      if (judge(w, s, result._1, result._2) ) {
        result = (w, s)
        //println(s"$w , $s")
      }
    }
  }
  println(result._1 + result._2 + " " + result._2)
}

Measured memory_bytes: 114576