akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int mod7=1e9+7;
const int mod9=1e9+9;
const int inf=1<<30;
const ll INF=1LL<<60;
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):abs(a);}
template<typename T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
template<typename A,size_t N,typename T> void Fill(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}

int main(){
    string s;cin>>s;
    rep(i,s.size())
        for(int j=i+1;j<s.size();j++)
        {
            if("keyence"==s.substr(0,i+1)+s.substr(j)){cout<<"YES"<<endl;return 0;}
        }
    cout<<"NO"<<endl;
}

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

int N, A[110];

void trace(int A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void insertion_sort(int A[], int N) {
    for (int i = 1; i < N; i++) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

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

    trace(A, N);
    insertion_sort(A, N);
}



Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
string a[100];
string b[100];
int c,d,ans;
int main(){
cin>>c;
for(int i=0;i<c;i++)
cin>>a[i];
cin>>d;
for(int j=0;j<d;j++)
cin>>b[j];
for(int i=0;i<c;i++){
int an=0;
for(int j=0;j<c;j++)
if(a[i]==a[j])
an++;
for(int j=0;j<d;j++)
if(b[j]==a[i])
an--;
ans=max(ans,an);}
cout<<ans;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <iostream>

using namespace std;
const int nax = 1e5+103;
int n, k;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	for(int j=2; j<=k; j++){
		if(i+j<n) ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
	}
	return dp[i]=ans;
}
int main(){
	cin>>n>>k;
	for(int i=0; i<n; i++) {cin>>a[i]; dp[i]=-1;}

	cout<<f(0)<<endl;
	return 0;
}

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n;
  cin >> n;
  vector< tuple< ul, ul > > p(n);
  vector< tuple< ul, ul > > xi(n), yi(n);
  for (ul i=0; i<n; ++i) {
    ul x, y;
    cin >> x >> y;
    p[i] = make_tuple(x, y);
    xi[i] = make_tuple(x, i);
    yi[i] = make_tuple(y, i);
  }
  sort(xi.begin(), xi.end());
  sort(yi.begin(), yi.end());
  vector< tuple< ul, ul, ul > > d((n-1)*2);
  for (ul i=0; i<n-1; ++i) {
    d[i*2  ] = make_tuple(get<0>(xi[i+1])-get<0>(xi[i]), get<1>(xi[i]), get<1>(xi[i+1]));
    d[i*2+1] = make_tuple(get<0>(yi[i+1])-get<0>(yi[i]), get<1>(yi[i]), get<1>(yi[i+1]));
  }
  sort(d.begin(), d.end());
  vector< ll > group(n, -1);
  ul ans = 0;
  for (auto di : d) {
    ul p1 = get<1>(di), p2 = get<2>(di);
    while (group[p1] != -1) p1 = group[p1];
    while (group[p2] != -1) p2 = group[p2];
    if (p1 == p2) continue;
    ul pb = min(p1, p2), pt = max(p1, p2);
    ans += get<0>(di);
    if (group[pb] == -1 && group[pt] == -1) {
      group[pt] = pb;
    } else if (group[pb] == -1) {
      while (group[pt] != -1) pt = group[pt];
      cerr << pb << " - " << pt << endl;
      if (pb < pt) group[pt] = pb;
      else group[pb] = pt;
    } else if (group[pt] == -1) {
      while (group[pb] != -1) pb = group[pb];
      group[pt] = pb;
    } else {
      while (group[pb] != -1) pb = group[pb];
      while (group[pt] != -1) pt = group[pt];
      if (pb < pt) group[pt] = pb;
      else group[pb] = pt;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    string w[n], ans = "Yes";
    map<string, bool> mp;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        if (mp[w[i]]) ans = "No";
        mp[w[i]] = true;
        if (i > 0) {
            if (w[i].front() != w[i-1].back()) ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
(function() {
function Main(input) {
  a = lines = input.split(" ")[0] * 1
  p = lines = input.split(" ")[1] * 1
  console.log(Math.floor((a * 3 + p) / 2))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}())


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

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

int main(){
    int n; cin >> n;
    vector<ll> data(n); rep(i,n) cin >> data[i];
    map<ll,ll> data2;
    rep(i,n) data2[data[i]]++;
    ll ans = 0; rep(i,n) ans += data[i];
    
    int q; cin >> q;
    rep(i,q){
        int b, c; cin >> b >> c;
        int d = data2[b];
        ans += (c-b)*d;
        cout << ans << endl;
        data2[b] = 0;
        data2[c] += d; 
    }
}



Measured memory_bytes: 10068
#include <iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i) 

int main() {
	
	int n,k;
	cin >> n>>k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int z = 0;
	rep(i, n) if (a[i] >= k)z++;
	cout << z << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > b){
            System.out.println("a > b");
        }else if(a < b){
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 25840
#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	int count[6] = {0};
	for(int i = 0; i < n; ++i)
	{
		double height;
		cin >> height;
		if(height <165.0)
		{
			count[0]++;
		}
		else if(height < 170.0)
		{
			count[1]++;
		}
		else if(height < 175.0)
		{
			count[2]++;
		}
		else if(height < 180.0)
		{
			count[3]++;
		}
		else if(height < 185.0)
		{
			count[4]++;
		}
		else
		{
			count[5]++;
		}
	}
	for(int i = 0; i < 6; ++i)
	{
		cout << i + 1 << ":";
		for(int j = 0; j < count[i]; ++j)
		{
			cout << "*";
		}
		cout << endl;
	}
}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

ll binpow(ll a, ll b)
{
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
        return res * a;
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int l,r,d;
    cin>>l>>r>>d;
    cout<<r/d-(l-1)/d;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

bool comp(pair<ll, ll> &a, pair<ll, ll> &b) {
  if (a.second != b.second)
    return a.second < b.second;
  else
    return a.first < b.first;
}

bool comp2(pair<ll, ll> &a, pair<ll, ll> &b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second > b.second;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  pair<ll, ll> arr[n + 5];
  for (ll i = 1; i <= n; i++)
    cin >> arr[i].first >> arr[i].second;

  sort(arr + 1, arr + n + 1, comp);

  pair<ll, ll> val = arr[1];

  sort(arr + 1, arr + n + 1, comp2);

  ll indx = -1;
  vector<pair<ll, ll>> curr;
  for (ll i = 1; i <= n; i++) {
    if (arr[i] == val) {
      indx = i;
      curr.push_back(arr[i]);
      for (ll i = 1; i <= n; i++) {
        if (i == indx)
          continue;
        curr.push_back(arr[i]);
      }
      for (ll i = 1; i <= n; i++)
        arr[i] = curr[i - 1];
      break;
    }
  }
  ll suff[n + 5];
  ll lMax = -inf, rMin = inf;
  for (ll i = n; i >= 1; i--) {

    lMax = max(lMax, arr[i].first);

    rMin = min(rMin, arr[i].second);

    suff[i] = max(0ll, rMin - lMax + 1);
  }
  lMax = val.first, rMin = val.second;

  ll res = 0;

  for (ll i = 1; i < n; i++) {

    lMax = max(lMax, arr[i].first);

    rMin = min(rMin, arr[i].second);

    res = max(res, max(0ll, rMin - lMax + 1) + suff[i + 1]);
  }

  for (ll i = 1; i <= n; i++) {
    res = max(res, arr[i].second - arr[i].first + 1);
  }

  multiset<ll> left1, right1;

  for (ll i = 1; i <= n; i++) {
    left1.insert(arr[i].first);

    right1.insert(arr[i].second);
  }
  for (ll i = 1; i <= n; i++) {
    left1.erase(left1.find(arr[i].first));
    right1.erase(right1.find(arr[i].second));

    res = max(res, arr[i].second - arr[i].first + 1 +
                       max(0ll, (*right1.begin()) - (*(--left1.end())) + 1));
    left1.insert(arr[i].first);

    right1.insert(arr[i].second);
  }

  cout << res << en;

  return 0;
}

Measured memory_bytes: 13552
class UnionFind():
 def __init__(self, n):
  self.n = n
  self.parents = [-1] * n

 def find(self, x):
  if self.parents[x] < 0:
   return x
  else:
   self.parents[x] = self.find(self.parents[x])
   return self.parents[x]

 def union(self, x, y):
  x = self.find(x)
  y = self.find(y)

  if x == y:
   return

  if self.parents[x] > self.parents[y]:
   x, y = y, x

  self.parents[x] += self.parents[y]
  self.parents[y] = x

 def size(self, x):
  return -self.parents[self.find(x)]
 def same(self, x, y):
  return self.find(x) == self.find(y)

N,M,K = map(int,input().split())
uf = UnionFind(N)
lst=[0]*(N)
for i in range(M):
 A,B=map(int,input().split())
 uf.union(A-1,B-1)
 lst[A-1]-=1
 lst[B-1]-=1
for i in range(K):
 A,B=map(int,input().split())
 if uf.same(A-1,B-1):
  lst[A-1]-=1
  lst[B-1]-=1
lst=[lst[i]+uf.size(i)-1 for i in range(N)]
L=[str(a) for a in lst]
L=' '.join(L)
print(L)

Measured memory_bytes: 17820
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int k;
    cin >> k;
    vector<LL> a(k);

    for (int i = 0; i < k; i++) {
        cin >> a[i];
    }

    if (a[k - 1] != 2) {
        cout << -1 << endl;
        return 0;
    }

    LL l = 2, r = 3;
    for (int i = k - 2; i >= 0; i--) {
        LL x = a[i] * ((l + a[i] - 1) / a[i]);
        if (x >= l && x <= r) {
            l = x;
            r = a[i] * ((r + a[i]) / a[i]) - 1;
        } else {
            cout << -1 << endl;
            return 0;
        }
        // cout << l << " " << r << " " << x << endl;
    }

    cout << l << " " << r << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
    int i,j,H,W;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0,W==0){
            break;
        }else{
            for(i=0;i<H;i++){
                printf("#");
                for(j=0;j<W-2;j++){
                    if(i==0 || i==H-1){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
                printf("#\n");
            }
            printf("\n");
        }
    }
        return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)

using namespace std;
typedef long long ll;
int sum[100005];

int main(){
    int  N,M;
    int sum[100005];
    string S;
    cin>>N>>M;
    cin>>S;
    sum[0]=0;
    for(int i = 0;i < N-1;i++){
        sum[i+1]=sum[i];
        if(S[i]=='A'&&S[i+1]=='C'){
            sum[i+1]++;
        }
    }
    for(int i = 0;i < M;i++){
        int l,r;
        cin>>l>>r;
        cout<<sum[r-1]-sum[l-1]<<endl;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

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

const ll mod = 1e9 + 7;


int main(){
    ll N;
    cin >> N;
    map<ll,ll> cnt;
    repf(i,1,N+1){
        ll now = i;
        ll d = 2;
        while (i>1 && d*d<=i){
            while (now%d==0){
                cnt[d]++;
                now /= d;
            }
            d++;
        }
        if (now>1)
            cnt[now]++;
    }
    ll ans = 1;
    for (auto itr = cnt.begin(); itr != cnt.end();itr++){
        pll p = *itr;
        //cout << p.first << " " << p.second << endl;
        ans = (ans * (1 + p.second)) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int h,w;
        cin >> h >> w;
        if(h==0&&w==0)return 0;
        for(int i=1;i<=h;i++){
            if(i%2==1){
                for(int r=1;r<=w/2;r++){
                    cout << "#" << flush;
                    cout << "." << flush;
                }
                    if(w%2==1)cout << "#" << flush;
                cout << endl;
            }
            else{
                for(int r=1;r<=w/2;r++){
                    cout << "." << flush;
                    cout << "#" << flush;
                    }
                    if(w%2==1)cout << "." << flush;
                cout << endl;
            }

            
        }
        cout << endl;
    }
}




Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<set>

int const MAXN = 1e5;

int N, M, K;

int data[MAXN]; // zero-positive: parent, negative(root): count
int rank[MAXN]; // height
std::set<int> block[MAXN]; // block or friend

void init() {
  std::fill(data, data+N, -1);
  std::fill(rank, rank+N, 0);
}

int find(int x) {
  if(data[x] < 0) return x;
  return data[x] = find(data[x]);
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if(x == y) return;
  if(rank[x] > rank[y]) std::swap(x, y);
  // rank_x <= rank_y: unite x under y
  data[y] += data[x];
  data[x] = y;
  if(rank[x] == rank[y]) ++rank[y];
}

int main() {
  std::cin >> N >> M >> K;
  init();
  for(int i = 0; i < M; ++i) {
    int A, B; std::cin >> A >> B;
    unite(A-1, B-1);
    block[A-1].insert(B-1);
    block[B-1].insert(A-1);
  }
  for(int i = 0; i < K; ++i) {
    int C, D; std::cin >> C >> D;
    block[C-1].insert(D-1);
    block[D-1].insert(C-1);
  }
  for(int i = 0; i < N; ++i) {
    int count = -data[find(i)] - 1;
    for(auto j: block[i]) if(find(i) == find(j)) --count;
    std::cout << count;
    if(i < N-1) std::cout << " ";
  }
  std::cout << std::endl;
  return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int n,k;
	cin >> n >> k;
	int ans=0;
	rep(i,k,n+1)
	{
		int minn = ((i-1)*i)/2;
		int maxx = (n*(n+1))/2  - ((n-i)*(n-i+1))/2;
		ans = (ans+maxx-minn+1)%M; 
	}
	cout << ans << endl;
}


Measured memory_bytes: 3644
def is_pa(s):
    s = s.casefold()
    rev = reversed(s)
    return list(s)==list(rev)
S = input()
N = len(S)
if is_pa(S) and is_pa(S[0:int((N-1)/2)]) and is_pa(S[int((N+3)/2)-1:]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 20
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root,NIL;

Node find(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key)u=u->left;
    else u = u->right;
}
  return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else {if(z->key < y->key)y->left=z;
        else y->right=z;}
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
 
void preorder(Node u){
 if(u==NIL)return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[MAX];
  Node t;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if(com[0]=='f'){
     scanf("%d", &x);
     t = find(root, x);
      if(t != NIL )printf("yes\n");
      else printf("no\n");
    }else if(com[0]=='i'){
      scanf("%d", &x);
      insert(x);
    }else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20456
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[3];
    int p = 0;
    for (int i = 0; i < 3; ++i)
    {
        cin >> a[i];
        p += a[i] % 2;
    }
    sort(a, a + 3);
    if (p == 0 || p == 3)
        cout << (a[2] - a[0] + a[2] - a[1]) / 2;
    else
    {
        if (a[0] % 2 == a[1] % 2)
            a[0]++, a[1]++;
        else if (a[1] % 2 == a[2] % 2)
            a[1]++, a[2]++;
        else
            a[0]++, a[2]++;
        sort(a, a + 3);
        cout << (a[2] - a[0] + a[2] - a[1]) / 2 + 1;
    }
}


Measured memory_bytes: 256
L = [set(map(int,input().split())) for i in range(3)]
L += [set([1,0]),set([2,0]),set([3,0]),set([4,0])]
import copy
def dfs(left_towns, current_town):
    if len(left_towns) == 0:
        return 1
    
    ret = 0
    for t in left_towns:
        if set([t,current_town]) in L:
            new_left_towns = copy.deepcopy(left_towns)
            new_left_towns.remove(t)
            ret += dfs(new_left_towns, t)
    
    if ret>0:
        return 1
    else:
        return 0

ans = 'YES' if dfs([1,2,3,4],0)>0 else 'NO'
print(ans)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N,M,K;
	cin >> N >> M >> K;
	for(int i =0; i <= N; i++) for(int j =0; j <= M; j++)
		if((N-i)*j+(M-j)*i == K) {
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int x,y,z,c=0;
 scanf("%d%d%d",&x,&y,&z);
 x-=z;
 while(x>=y+z){
  x-=y+z;
  c++;
 }
 printf("%d",c);
 return 0;
}

Measured memory_bytes: 128
use proconio::input;

fn main() {
    input! {
        h: usize,
        _: usize,
        k: usize,
        ss: [String; h],
    }
    let grid = ss
        .into_iter()
        .map(|s| s.chars().map(|c| if c == '#' { 1 } else { 0 }).collect())
        .collect();
    println!("{}", check_v(&grid, k, 0));
}

fn check_v(grid: &Vec<Vec<usize>>, k: usize, v: usize) -> usize {
    let sum: usize = grid.iter().map(|v| -> usize { v.iter().sum() }).sum();
    if sum < k {
        return 0;
    }
    let mut total = 0;
    total += check_h(grid, k, 0);
    for i in v..grid[0].len() {
        let ng: Vec<Vec<usize>> = grid
            .to_owned()
            .into_iter()
            .map(|r| -> Vec<usize> {
                r.iter()
                    .enumerate()
                    .filter(|&(n, _)| n != i)
                    .map(|(_, &e)| e)
                    .collect()
            })
            .collect();
        total += check_v(&ng, k, i);
    }
    return total;
}

fn check_h(grid: &Vec<Vec<usize>>, k: usize, h: usize) -> usize {
    let sum: usize = grid.iter().map(|v| -> usize { v.iter().sum() }).sum();
    if sum < k {
        return 0;
    }
    let mut total = if sum == k { 1 } else { 0 };
    for i in h..grid.len() {
        let ng = grid
            .to_owned()
            .into_iter()
            .enumerate()
            .filter(|&(n, _)| n != i)
            .map(|(_, e)| e)
            .collect();
        total += check_h(&ng, k, i);
    }
    return total;
}


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

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

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

  bool AC[n+1]={false};
  int WA[n+1]={0};

  int cAC=0, cWA=0;
  rep(i,m){
    int p;
    string S;
    cin >> p >> S;
    if(S=="WA")WA[p]++;
    if(AC[p]==false && S=="AC"){
      AC[p] = true;
      cWA += WA[p];
      cAC++;
    }
    
  }
  printf("%d %d\n",cAC, cWA);
  return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	final Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int[] a=new int[n];
	for(int i=0;i<n;i++) a[i]=sc.nextInt();
	for(int i=n-1;i>=0;i--){
	    if(i==0 )System.out.print(a[i]);
	    else System.out.print(a[i]+" ");
	}
	System.out.println("");
    }
}

Measured memory_bytes: 19004
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 3005
#define INF 1000000000
#define MOD 998244353
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,a[MAXN],fact[2*MAXN],invf[2*MAXN];
char str[MAXN+1];
int dp[MAXN][MAXN],cnt1[MAXN],cnt2[MAXN];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
int comb(int n,int k)
{
    if(n<k) return 0;
    return 1LL*fact[n]*invf[k]%MOD*invf[n-k]%MOD;
}
int main()
{
    fact[0]=invf[0]=1;
    for(int i=1;i<=5000;i++) fact[i]=1LL*fact[i-1]*i%MOD;
    invf[5000]=pow_mod(fact[5000],MOD-2);
    for(int i=4999;i>=1;i--) invf[i]=1LL*invf[i+1]*(i+1)%MOD;
    scanf("%s",str+1);
    n=strlen(str+1);
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        cnt1[i]=cnt1[i-1];cnt2[i]=cnt2[i-1];
        if(str[i]=='0') cnt1[i]+=2;
        else if(str[i]=='2') cnt2[i]+=2;
        else
        {
            cnt1[i]++;cnt2[i]++;
        }   
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(!dp[i][j]) continue;
            if(j<cnt1[i+1]) add(dp[i+1][j+1],dp[i][j]);
            if(i-j<cnt2[i+1]) add(dp[i+1][j],dp[i][j]);
        }
    }
    int ans=0;
    for(int i=0;i<=n;i++) add(ans,1LL*dp[n][i]*comb(n,cnt1[n]-i)%MOD);
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 35584
#include <stdio.h>
int main(void)
{
int D;
scanf ("%d", &D);
if (D==25){
printf("Christmas");
}
else if (D==24){
printf("Christmas Eve");
}
else if (D==23){
printf("Christmas Eve Eve");
}
else if (D==22){
printf("Christmas Eve Eve Eve");
}
return 0;
}

Measured memory_bytes: 128
//
//  C.cpp
//  RC103
//
//  Created by 김성환 on 12/10/2018.
//  Copyright © 2018 김성환. All rights reserved.
//

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

int n,t,ans[2],chg[2],data[500001];
pair<int,int> ar[500001];

bool cmp(const pair<int,int>& l, const pair<int,int>& r) {return l.second>r.second;}

int main() {
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>t;
        ar[t].second++;
        ar[t].first=t;
        data[i]=t;
    }
    sort(ar,ar+500000,cmp);
    chg[0]=ar[0].first;
    chg[1]=ar[1].first;
    if(chg[1]==0) chg[1]=chg[0]+1;
    
    for(int i=0;i<n;i++) {
        if(data[i]!=chg[i%2]) ans[0]++;
    }
    for(int i=0;i<n;i++) {
        if(data[i]!=chg[(i+1)%2]) ans[1]++;
    }
    cout<<min(ans[0],ans[1]);

    return 0;
}


Measured memory_bytes: 4608
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
S = readline()
T = readline()
S = list(S.rstrip())
T = list(T.rstrip())
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

g = gcd(N, M)
l = N * M // g
x = l // N
y = l // M

if S[::y] != T[::x]:
    print(-1)
    exit()
print(l)


Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    ll m,n;
    if(a%d==0) m=a/d;
    else m=a/d+1; //打死a的次数 
    
     n=(c+b-1)/b;  // m==n
    if(m>=n) 
    {
    	cout<<"Yes";
	}
    else
      cout<<"No";

return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

using Graph = vector<vector<int>>;

// 二部グラフ判定
vector<int> color;
bool dfs(const Graph &G, int v, int cur = 0) {
    color[v] = cur;
    for (auto next_v : G[v]) {
        // 隣接頂点がすでに色確定していた場合
        if (color[next_v] != -1) {
            if (color[next_v] == cur) return false; // 同じ色が隣接したらダメ
            continue;
        }

        // 隣接頂点の色を変えて、再帰的に探索 (一回でも false が返ってきたら false)
        if (!dfs(G, next_v , 1 - cur)) return false;
    }
    return true;
}

int main(){
    int n,m;
    cin >> n >> m;
    Graph G(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    color.assign(n, -1);
    bool is_bipartite = dfs(G,0);
    if(is_bipartite){
        int b=0;int w=0;
        rep(i,n){
            if(color[i]==0)b++;
            else w++;
        }
        cout << (ll)b*w - m << endl;
    }else{
        cout << (ll)n*(n-1)/2 - m << endl;
    }
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  int M,N;
  cin >> N >> M;
  vector<int> foods(M, 0);
  for (int i=0;i<N;i++){
    int K;
    cin >> K;
    for (int j=0;j<K;j++) {
      int A;
      cin >> A;
      A--;
      foods[A]++;
    }
  }
  int count = 0;
  for (int i=0;i<M;i++) {
    if (foods[i] == N) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int x;
    cin>>x;
    int xx=x/500;
    int ans=xx*1000;
    x%=500;
    x/=5;
    ans+=x*5;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
ab = [inpl() for i in range(n)]
hq = []
res = 0
ind = 0
ab.sort()
for i in range(1,m+1):
    while True:
        if ind >= n: break
        a,b = ab[ind]
        if a <= i:
            heappush(hq,[-b,a])
            ind += 1
        else: break
    if hq == []: continue
    tmp = heappop(hq)
    res -= tmp[0]
    # print(tmp,res)
print(res)

Measured memory_bytes: 101336
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[300005];
int32_t main(){
	int n;cin>>n;
	for(int i=1;i<=3*n;i++){
		cin>>ar[i];
	}
	sort(ar+1,ar+3*n+1);
	set<int> se;
	int ans = 0;
	for(int i=3*n-1;se.size()<n;i-=2){
		//cout<<i<<" "<<ar[i]<<"\n";
		ans +=ar[i];se.insert(i);
	}
	cout<<ans;
}


Measured memory_bytes: 7296
#include <stdio.h>
#include <math.h>
 
int main(void){
  int n, m, fn=0;
  scanf("%d",&n);
  m=n;
  while(m!=0){
    fn+=m%10;
    m/=10;
  }
  if(n%fn==0) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

int main(){
	int H, W; cin >> H >> W;
	vector<vector<int>> a(H, vector<int>(W));
	for(int i=0; i<H; ++i)
		for(int k=0; k<W; ++k)
			cin >> a[i][k];
	queue<pair<int, int>> path;
	stack<pair<int, int>> prev;

	int y = 0;
	while(y < H){
		for(int x=0; x<W; ++x) path.push(make_pair(x, y));
		++y;
		if(y >= H) break;
		for(int x=W-1; x>=0; --x) path.push(make_pair(x, y));
		++y;
	}

	prev.push(path.front());
	path.pop();

	int act = 0;
	vector<string> ans;
	while(!path.empty()){
		auto now = path.front(), pre = prev.top();
		path.pop();

		if(a[pre.second][pre.first] & 1){
			++act;
			ans.push_back(to_string(pre.second + 1) + " " + to_string(pre.first + 1) + " " + to_string(now.second + 1) + " " + to_string(now.first + 1));
			++a[now.second][now.first];
		}

		prev.push(now);
	}

	cout << act << endl;
	for(auto answer : ans) cout << answer << endl;
}


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

int main()
{
  ll n; cin>>n;
  ll t; cin>>t; //基準
  ll a; cin>>a; //平均気温

  double min=pow(10,6);
  ll ans;

  rep(i,n) {
    ll tmp; cin>>tmp;
    // cout << abs(a - (t - tmp * 0.006)) << endl;
    // if (min > abs(a - (t - tmp * 0.006))) ans = i+1;
    if (min > abs(a - (t - tmp * 0.006))) {
      // cout << "min: " << min << "abs" << abs(a - (t - tmp * 0.006)) << endl;
      // cout << "debug: "<< i <<endl;
      // cout << "debug: "<< abs(a - (t - tmp * 0.006)) << endl;
      min = abs(a - (t - tmp * 0.006));
      ans = i+1;
    }
  }

  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

using namespace std;

int main()
{
  int x, a;
  cin >> x >> a;

  if (x < a)
	cout << 0 << endl;
  else
	cout << 10 << endl;



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF INT_MAX
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll
#define P pair<int,int>

signed main(){
  string s;
  cin>>s;
  if(s[0]!='A'){
    cout<<"WA"<<en; RE;
  }
  bool there=false;
  for(int i=2; i<s.size()-1; i++){
    if(s[i]=='C'){
      if(!there){
        there=true;
      }else{
        cout<<"WA"<<en;
        RE;
      }
    }
  }
  
  if(!there){cout<<"WA"<<en; RE;}
  for(int i=0; i<s.size(); i++){
    if(s[i]=='A'||s[i]=='C') continue;
    if(!islower(s[i])){
      cout<<"WA"<<en;
      RE;
    }
  }
  cout<<"AC"<<en;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

from functools import reduce

import math


from collections import defaultdict
from math import sqrt

def is_prime(n):
    for i in range(2, int(sqrt(n))):
        if n % i == 0:
            return False
    return True

def prime_factors(n):
    primes = defaultdict(int)
    i = 2
    mx = sqrt(n)
    while n != 1:
        if n % i == 0:
            n = n // i
            primes[i] += 1
        elif i >= mx:
            if len(primes) == 0:
                primes[i] += 1
            elif is_prime(n):
                primes[i] += 1
            break
        else:
            i += 1
    return primes

def solve_n(x):
    return (-1 + sqrt(1 + 4 * 2* x)) / 2

def solve(N: int):
    fs = prime_factors(N)
    count = 0
    for key, value in fs.items():
        val = solve_n(value)
        count += math.floor(val)

    print(count)
    return



# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9496
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;



int main()
{
  string a, b, c;
  cin  >> a;
  cin >> b;
  cin >> c;


  string ans;
  char st = a[0];
  a.erase( a.begin() );
  while (true) {
    if (st == 'a') {
      if (a.size() == 0) {
        ans = "A";
        break;
      }
      st = a[0];
      a.erase( a.begin() );
    }
    if (st == 'b') {
      if (b.size() == 0) {
        ans = "B";
        break;
      }
      st = b[0];
      b.erase( b.begin() );
    }
    if (st == 'c') {
      if (c.size() == 0) {
        ans = "C";
        break;
      }
      st = c[0];
      c.erase( c.begin() );
    }


  }




  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
ll fun(ll a){
    return (a*(a-1))/2;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    int b[300000]={0};
    ll ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans-=fun(b[a[i]]);
        b[a[i]]++;
        ans+=fun(b[a[i]]);
    }
    for(int i=0;i<n;i++){
        cout<<ans+fun(b[a[i]]-1)-fun(b[a[i]])<<'\n';
    }
}

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

using namespace std;

typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair

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

int h, w, k;
pii start, target;
vector<string> a;
vector<vector<pii>> f[4];

bool inside(int x, int y) {
    return 0 <= x && x < h && 0 <= y && y < w;
}

int main() {
    scanf("%d%d%d", &h, &w, &k);
    scanf("%d%d%d%d", &start.fi, &start.se, &target.fi, &target.se);
    start.fi--; start.se--;
    target.fi--; target.se--;
    a.resize(h);
    for (int i = 0; i < 4; i++)
        f[i].resize(h);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < 4; j++)
            f[j][i].resize(w);
    }
    for (int i = 0; i < h; i++) {
        cin >> a[i];
        for (int j = 0; j < w; j++)
            for (int dir = 0; dir < 4; dir++)
                f[dir][i][j].fi = (int)(1e9);
    }
    int t0 = 0, t1 = 1;
    queue<pair<pii, int>> Q[2];
    for (int dir = 0; dir < 4; dir++) {
        f[dir][start.fi][start.se] = mp(1, 0);
        Q[t0].push(mp(start, dir));
    }
    while (Q[t0].size() || Q[t1].size()) {
        if (Q[t0].empty()) t0 ^= 1, t1 ^= 1;
        pair<pii, int> p = Q[t0].front();
        Q[t0].pop();
        pii coor = p.fi;
        int dir = p.se;
        pii curf = f[dir][coor.fi][coor.se];
//        cout << coor.fi + 1 << " " << coor.se + 1 << " " << dir << " " << curf.fi << " " << curf.se << endl;
        if (coor == target) {
            cout << curf.fi;
            return 0;
        }
        for (int ndir = 0; ndir < 4; ndir++) {
            pii newcoor = mp(coor.fi + dx[ndir], coor.se + dy[ndir]);
            if (!inside(newcoor.fi, newcoor.se)) continue;
            if (a[newcoor.fi][newcoor.se] == '@') continue;
            pii newf = curf;
            if (ndir == dir) {
                if (newf.se == k) {
                    newf.fi++;
                    newf.se = 1;
                } else
                    newf.se++;
            } else  {
                newf.fi++;
                newf.se = 1;
            }
            if (f[ndir][newcoor.fi][newcoor.se] <= newf) continue;
            f[ndir][newcoor.fi][newcoor.se] = newf;
            if (newf.se != 1) Q[t0].push(mp(newcoor, ndir));
            else Q[t1].push(mp(newcoor, ndir));
        }
//        cout << endl;
    }
    cout << -1;
}


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

int main(int argc, const char * argv[]) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) {
        cout << "Left" << endl;
    }else if (a + b < c + d){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Long[] tmp = new Long[n];
        
        for(int i=0; i<n; i++){
            tmp[i] = sc.nextLong();
        }
        Arrays.sort(tmp);
        
        Long ans = 0L;
        for(int j=0; j<n-k; j++){
            ans += tmp[j];
        }
        
        System.out.println(ans);
    }
}

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


int solve()
{
	int n;
	cin>>n;
	
	int arr[n];
	for(int i=0;i<n;i++)
	cin>>arr[i];
	
	if(n==1)
	return 0;
	
	if(n==2)
	return abs(arr[0]-arr[1]);
	
	int dp[n];
	dp[0]=0;
	dp[1]=abs(arr[0]-arr[1]);
	
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-2]+abs(arr[i-2]-arr[i]),dp[i-1]+abs(arr[i-1]-arr[i]));
	}
	return dp[n-1];
}
int main()
{
	cout<<solve();	
}


Measured memory_bytes: 4384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define ALL(a) begin(a), end(a)
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x, y;
    cin >> x >> y;
    int ans = 0;   
    while (x <= y)
        ++ans, x *= 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] arr = new Integer[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        sc.close();

        Arrays.sort(arr, Comparator.reverseOrder());

        int sumA = 0;
        int sumB = 0;

        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                sumA += arr[i];
            } else {
                sumB += arr[i];
            }
        }

        System.out.println(sumA - sumB);
    }
}

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

int main(){
	string s,t;
	cin >> s >> t;
	int len = s.length();
	if(t.substr(0,len)==s && t.length()==len+1)
		cout << "Yes" << endl;

	else 
	 	cout << "No" << endl; 
}

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

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

    vector<int> L(n+1);
    vector<int> v(n);
    for(int i=1; i<=n; i++){
        cin >> L[i];
        v[i-1] = L[i];
    }
    sort(v.begin(),v.end());

    int count = 0;
    for(int i=n-2; i>=0; i--){// middle
        for(int j=i-1; j>=0; j--){// shortest
            auto too_long = lower_bound(v.begin(), v.end(), v[i] + v[j]);
            count += ((n - 1) - i) - distance(too_long, v.end());
        }
    }
    cout << count << endl;
    return 0;
}

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

int isAC[100010];
int penalty[100010];
int ans1 = 0;
int ans2 = 0;

int main(){
	int n, m;	cin >> n >> m;
	string s;
	for (int i = 0; i < m; ++i){
		int p;
		cin >> p;
		char dum = getchar();
		cin >> s;
		if(isAC[p] == 0 && s[0] == 'W')	penalty[p]++; 
		else			isAC[p] = 1;
	}
	for (int i = 0; i <= n; ++i){
		if(isAC[i]){
			ans1++;
			ans2 += penalty[i];
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
 
 
public class Main {

	static long MOD = 1_000_000_007;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//int N = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());
		//char[] c = sc.next().toCharArray();
		int INF = Integer.MAX_VALUE;
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		char[][] map = new char[H][W];
		for(int i=0; i<H; i++){
			map[i] = sc.next().toCharArray();
		}
		
		int[][] dpup = new int[H][W];
		int[][] dpdown = new int[H][W];
		int[][] dpleft = new int[H][W];
		int[][] dpright = new int[H][W];
		int[][] dpans = new int[H][W];
		
		
		for(int h=0; h<H; h++){
			for(int w=0; w<W; w++){
				if(h==0 || map[h][w] == '#'){
					dpup[h][w] = 0;
					continue;
				}
				if(map[h-1][w] == '#'){
					dpup[h][w] = 0;
				}else{
					dpup[h][w] = dpup[h-1][w]+1;
				}
			}
		}
		
		for(int h=H-1; h>=0; h--){
			for(int w=0; w<W; w++){
				if(h==H-1 || map[h][w] == '#'){
					dpdown[h][w] = 0;
					continue;
				}
				if(map[h+1][w] == '#'){
					dpdown[h][w] = 0;
				}else{
					dpdown[h][w] = dpdown[h+1][w]+1;
				}
			}
		}
		
		for(int h=0; h<H; h++){
			for(int w=0; w<W; w++){
				if(w==0 || map[h][w] == '#'){
					dpleft[h][w] = 0;
					continue;
				}
				if(map[h][w-1] == '#'){
					dpleft[h][w] = 0;
				}else{
					dpleft[h][w] = dpleft[h][w-1]+1;
				}
			}
		}
		
		for(int h=0; h<H; h++){
			for(int w=W-1; w>=0; w--){
				if(w==W-1 || map[h][w] == '#'){
					dpright[h][w] = 0;
					continue;
				}
				if(map[h][w+1] == '#'){
					dpright[h][w] = 0;
				}else{
					dpright[h][w] = dpright[h][w+1]+1;
				}
			}
		}
		

		//ans
		
		for(int h=0; h<H; h++){
			for(int w=0; w<W; w++){
				dpans[h][w] = dpup[h][w]+dpdown[h][w]+dpleft[h][w]+dpright[h][w];
				if(map[h][w]=='.')dpans[h][w] += 1;
				ans = Math.max(ans, dpans[h][w]);
			}
		}
		

		
		
		System.out.println(ans);
		
	}
	
	
}



Measured memory_bytes: 145480