akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main(){

	int N;
	char W[120][15];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%s", &W[i]);
	}

	bool can = true;

	char past[200][20];
	for (int i = 0; i < 200; i++) {
		for (int j = 0; j < 20; j++) {
			past[i][j] = NULL;
		}
	}
	int ind = 0;

	for (int i = 0; i < strlen(W[0]); i++) {
		past[0][i] = W[0][i];
		
	}
	ind++;

	for (int i = 1; i < N; i++) {
		if (W[i - 1][strlen(W[i - 1])-1] != W[i][0]) {
			can = false;
			break;
		}
		else {
			for (int j = 0; j < strlen(W[i]);j++) {
				past[ind][j] = W[i][j];
			}
			ind++;
		}
	}

	if (can) {
		for (int i = 0; i < ind; i++) {
			for (int j = i + 1; j < ind; j++) {
				if (strcmp(past[i],past[j]) ==0) {
					can = false;
					break;
				}

			}
		}



	}

	if (can) {
		printf("Yes");
	}
	else {
		printf("No");
	}

}








Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

int main(){
    string S;
    cin >> S;
    int n1 = (S[0] - '0') * 10 + (S[1] - '0');
    int n2 = (S[2] - '0') * 10 + (S[3] - '0');
    if(1 <= n1 && n1 <= 12 && 1 <= n2 && n2 <= 12){
        Print("AMBIGUOUS");
    }else if(1 <= n1 && n1 <= 12){
        Print("MMYY");
    }else if(1 <= n2 && n2 <= 12){
        Print("YYMM");
    }else{
        Print("NA");
    }
    return 0;
}

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

int f(int n){
 if(n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}

int main(void){
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  cout << A[2] * 10 + A[1] + A[0];
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		String a_str = scanner.next();
		String b_str = scanner.next();
		String c_str = scanner.next();

		int a = Integer.parseInt(a_str);
		int b = Integer.parseInt(b_str);
		int c = Integer.parseInt(c_str);

		if(a < b  && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

    	scanner.close();
    }
}



Measured memory_bytes: 25960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,k;
  cin>>n>>k;
  int b[n];
  rep(i,0,n) b[i]=0;
  rep(i,0,n){
    int a;
    cin>>a;
    b[a-1]++;
  }
  sort(b,b+n);
  reverse(b,b+n);
  int c=0;
  rep(i,0,k) c+=b[i];
  cout<<n-c<<endl;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**6)


def main():
	n = int(input())
	if n == 0:
		return
	c = [ord(i)-65 for i in input().split(" ")]
	getnum = [0 for i in range(30)]
	mnum = 29
	snum = 29
	flg = True
	for i in range(n):
		getnum[c[i]] += 1
		if getnum[c[i]] >= getnum[mnum] and mnum != c[i]:
			snum = mnum
			mnum = c[i]
		elif getnum[c[i]] >= getnum[snum] and snum != c[i] and mnum != c[i]:
			snum = c[i]
		if getnum[mnum] > getnum[snum] + (n-1) - i:
			print(chr(mnum+65),i+1)
			flg = False
			break
	if flg:
		print("TIE")
	main()
	return

main()


Measured memory_bytes: 7920
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static final double EPS = 1e-10;
	
	public static final double heron(double a, double b, double c){
		double s = (a + b + c) / 2;
		
		return Math.sqrt(s * (s - a) * (s - b) * (s - c));
	}

	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		while(sc.hasNextInt()){
			final int a = sc.nextInt();
			final int l = sc.nextInt();
			final int x = sc.nextInt();
			
			final double a_harf = a / 2.0;
			double area = Math.sin(Math.acos(a_harf / l)) * l * a_harf;
			//System.out.println(area);
			
			final double max_len = l + x;
			double hi = (l + x) / 2.0 - EPS;
			double low = EPS;
			while(hi - low > EPS){
				final double upper = (hi * 2 + low) / 3;
				final double lower = (hi + low * 2) / 3;
				//System.out.println(upper + " " + lower);
				
				final double upper_value = heron(l, upper, max_len - upper);
				final double lower_value = heron(l, lower, max_len - lower);
				
				//System.out.println(upper_value + " " + lower_value);
				
				if(Double.isNaN(lower_value) || upper_value > lower_value){
					low = lower;
				}else{
					hi = upper;
				}
			}
			
			final double value = (low + hi) / 2;
			area += heron(l, value, max_len - value) * 2;
			
			System.out.printf("%.10f\n", area);
		}
	}

}

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

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

using namespace std;

int A[2 * 100000];
int B[2 * 100000];

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

  REP(i, N) {
    cin >> A[i];
    B[A[i]-1]++;
  }

  REP(i, N) cout << B[i] << endl;
}


Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const int MOD = 998244353;
const double PI = 3.141592653589793;
const int INF =  1e9 + 7;
const int nax = 100005;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc = 1;
	// cin >> tc;
	while (tc--) {
		string s, t;
		cin >> s >> t;
		bool pos = true;
		int n = s.length();
		for (int i = 0; i < n; i++) {
			pos &= (s[i] == t[i]);
		}
		cout << (pos ? "Yes" : "No");
	}
	return 0;
}




















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

int main() {
  int n;
  cin >> n;
  multiset<int> st;
  rep(i,n) {
    int d;
    cin >> d;
    st.insert(d);
  }

  int m;
  cin >> m;

  int ok = 1;

  while (m--) {
    int t;
    cin >> t;
    if (st.find(t) == st.end()) ok = 0;
    else {
      st.erase(st.find(t));
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
} 

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N, M; cin >> N >> M;
  vector<pair<ll, ll>> AB(N);
  rep(i, N) {
    int a, b; cin >> a >> b;
    AB[i].first = a;
    AB[i].second = b;
  }

  sort(ALL(AB));

  ll ans = 0, cnt = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < AB[i].second; ++j) {
      ans += AB[i].first;
      cnt++;

      if (cnt == M) {
        cout << ans << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long long int n,j, count = 0;
	cin >> n;
	//string s;
	vector<string>s(n);
	for (long long int i = 0; i < n; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(), s.end());
	/*for (string x : s) {
		cout << x << endl;
	}*/
	for (long long int i = 0; i < n; ) {
		for(j = i + 1; j < n;j++) {

			if (s[i] != s[j]) {
				break;
			 }
		}
		count += (j - i)*(j - i - 1) / (2*1);
		i = j;
	}

	cout << count << endl;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

string S, T;

bool can(int start){
    for(int i=0;i<T.size();++i){
        unless(S[start + i] == '?' ||
               S[start + i] == T[i]){
            return false;
        }
    }

    return true;
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> S >> T;

    int n = S.size(), m = T.size();
    vector<string> v;
    for(int i=0;i+m<=n;++i){
        if(can(i)){
            string s = S;
            for(int j=0;j<m;++j){
                s[i+j] = T[j];
            }
            for(int j=0;j<n;++j){
                if(s[j] == '?'){
                    s[j] = 'a';
                }
            }
            v.emplace_back(s);
        }
    }

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

    if(v.size() == 0){
        std::cout << "UNRESTORABLE" << std::endl;
    }else{
        std::cout << v[0] << std::endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

// // 再帰
// /// Solve the problem: ax + by = gcd(a, b)
// int extgcd(int a, int b, long long &x, long long &y) {
//   if (a == 0) {
//     x = 0;
//     y = 1;
//     return b;
//   }
//   long long x_, y_;
//   int gcd = extgcd(b % a, a, x_, y_);
//   x = y_ - (b / a) * x_;
//   y = x_;
//   return gcd;
// }

// 非再帰
/// Solve the problem: ax + by = gcd(a, b)
int extgcd(int a, int b, long long &x, long long &y) {
  int r1 = b;
  int r2 = a;
  long long x1 = 0, y1 = 1; // a * x1 + b * y1 = r1
  long long x2 = 1, y2 = 0; // a * x2 + b * y2 = r2
  while (r2) {
    int r3 = r1 % r2;             // r1 = q * r2 + r3
    long long x3 = x1 - (r1 / r2) * x2; // x3 = x1 - q * x2
    long long y3 = y1 - (r1 / r2) * y2; // y3 = y1 - q * y2
    r1 = r2;
    r2 = r3;
    x1 = x2, y1 = y2;
    x2 = x3, y2 = y3;
  }
  x = x1, y = y1;
  return r1;
}

int main() {
  int a, b;
  std::cin >> a >> b;
  long long x, y;
  extgcd(a, b, x, y);
  if (a == b)
    std::swap(x, y);
  std::cout << x << " " << y << std::endl;
}



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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll K, N;
vector<vector<ll>> G;

ll dfs(ll v, ll pre = -1)
{
	ll can;
	if (pre == -1)
		can = K-1;
	else
		can = K-2;

	if (K < G[v].size()) return 0;
	else
	{
		ll res{1};
		for (auto &nv : G[v])
		{
			if (nv == pre) continue;
			(res *= can--) %= MOD;
			(res *= dfs(nv, v)) %= MOD;
		}
		return res;
	}
}

int main(int argc, char **argv)
{
	cin >> N >> K;
	G.resize(N);

	REP(i, N-1)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	ll res = K*dfs(0, -1) % MOD;
	std::cout << res << std::endl;
}


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

void solve(int w, int h, int W, int H,
const vector<string>& mmap,
vector<vector<int>>& min_lens,
int len, int& ret) {
    if (min_lens[h][w] <= len) return;
    min_lens[h][w] = len;
    if (w == W-1 && h == H-1 && (ret == 0 || ret > len)) {
        ret = len;
        return;
    }
    const vector<int> dw = {1, 0, -1, 0}, dh = {0, 1, 0, -1};
    for (int i = 0; i < 4; ++i) {
        int nw = w + dw[i], nh = h + dh[i];
        if (0 <= nw && nw < W && 0 <= nh && nh < H &&
            mmap[2*h + dh[i]][2*w + dw[i]] == '0') {
            solve(nw, nh, W, H, mmap, min_lens, len+1, ret);
        }
    }
}

int main() {
    while (true) {
        int h, w; cin >> w >> h;
        if (h == 0 && w == 0) break;
        string dammy;
        getline(cin, dammy);
        vector<string> mmap;
        for (int i = 0; i < 2*h-1; i++) {
            string e; getline(cin, e);
            if (i % 2 == 0) e.push_back(' ');
            mmap.push_back(e);
        }
        vector<vector<int>> min_lens;
        for (int i = 0; i < h; i++) {
            min_lens.emplace_back(w, h*w + 1);
        }
        int ret = 0;
        solve(0, 0, w, h, mmap, min_lens, 1, ret);
        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 3336
import std.stdio, std.string, std.conv;

void main() {
    string s = readln.chomp;
    long mod = 1_000_000_007;
    long[][] dp = new long[][](100001, 13);
    dp[0][0] = 1;
    foreach (i, x; s) {
        if (x == '?') {
            foreach (j; 0 .. 13) {
                foreach (k; 0 .. 10) {
                    dp[i+1][(10*j+k)%13] = (dp[i+1][(j*10+k)%13] + dp[i][j]) % mod;
                }
            }
        } else {
            foreach (j; 0 .. 13) {
                dp[i+1][(10*j+(x-'0'))%13] = (dp[i+1][(10*j+(x-'0'))%13] + dp[i][j]) % mod;
            }
        }
    }
    dp[s.length][5].writeln;
}

Measured memory_bytes: 18328
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::map<int, int> map;

  int N, M, A[111111];

  std::cin >> N >> M;

  long long S = 0, C = 0;

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

    map[(S += A[i]) % M] ++;
  }

  S = 0;

  for (int i = 0; i < N; i ++) {
    C += map[S % M];
    
    S += A[i];

    map[S % M] --;
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int X; cin >> X;

    bool res = (X == 3 or X == 5 or X == 7);

    cout << (res ? "YES":"NO") << endl;

    return 0;
}


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

using namespace std;

using ll = long long;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  auto check = [&](int index) {
    ll low = 0, upp = 0;
    vector<ll> tmp;
    for (int i = 0; i < n; i++) {
      if (i == index) continue;
      if (a[i] <= a[index])
        low++;
      else if (a[i] > a[index] + m) {
        upp++;
        tmp.push_back(a[i]);
      } else {
        tmp.push_back(a[i]);
      }
    }
    if (upp >= p) return false;
    if (low + p - 1 >= v - 1) return true;
    sort(tmp.rbegin(), tmp.rend());
    ll sum = 0;
    for (int i = p - 1; i < (int)tmp.size(); i++) {
      ll val = tmp[i];
      sum += min(a[index] + m - val, m);
    }
    return sum >= (v - low - p) * m;
  };
  if (check(0)) {
    cout << n << endl;
    return 0;
  }
  int lb = n - p, ub = 0;
  while (lb - ub > 1) {
    int mid = (lb + ub) / 2;
    if (check(mid)) {
      lb = mid;
    } else {
      ub = mid;
    }
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] >= a[lb]) ret++;
  }
  cout << ret << endl;
}


Measured memory_bytes: 2884
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	string s;
	cin >> s;
	if (s.size() <= 7) {
		cout << "YES" << endl;
	}
	else {
		int lose = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'x') {
				lose++;
			}
		}
		if (lose >= 8) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
		}
	}
	return 0;
}

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

typedef long long ll;

const ll M = 4000000;

ll n;
ll sum;
bitset<M + 5> v;

int main()
{
    scanf("%lld", &n);
    v[0] = true;
    while(n--)
    {
        ll t;
        scanf("%lld", &t);
        sum += t;
        v |= (v << t);
    }
    for(ll i = (sum + 1) / 2; i <= sum; i++)
    {
        if(v[i])
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
n = int(input())
W = list(map(int, input().split()))

_W = W[:]
_W.sort()
m = _W[0]

C = [None for _ in range(_W[n - 1] + 1)]
V = [False for _ in range(_W[n - 1] + 1)]

for i in range(n):
    C[_W[i]] = W[i]

r = 0

for i in _W:
    if V[i]:
        continue
    nxt = C[i]
    V[i] = True
    if nxt == i or V[nxt]:
        continue
    sum_w = i
    min_w = i
    c = 1
    while V[nxt] is False:
        V[nxt] = True
        sum_w += nxt
        nxt = C[nxt]
        c += 1
    r += min(sum_w + (c - 2) * min_w, sum_w + min_w + (c + 1) * m)

print(r)



Measured memory_bytes: 5800
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  map<int, int> mp;
  for (int i = 0; i < N; i++)
  {
    int a;
    scanf("%d", &a);
    mp[a]++;
  }
  int cnt[3] = {};
  for (auto &e : mp)
  {
    pair<int, int> p = e;
    if (p.second != 0)
    {
      if (p.second % 2 == 0)
        p.second = 2;
      else
        p.second = 1;
    }
    cnt[p.second]++;
  }
  if (cnt[2] % 2 == 1)
    cnt[2]--;
  cout << cnt[0] + cnt[1] + cnt[2] << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(){
    int x;
    int y;
    cin >> x >> y;
    while(1){
        if(x < y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
        cin >> x >> y;
        if(x == 0 && y == 0) break;
    }
}


Measured memory_bytes: 3056
N = input()
N = int(N)

c=[[0 for i in range(10)] for j in range(10)]

c[0][0]
for x in range(1,N+1):
    X=str(x)
    c[int(X[0])][int(X[-1])]+=1

score = 0
for i in range(10):
    for j in range(10):
        score += c[i][j]*c[j][i]
        
print(score)
        
    

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int x , a;

int main()
{
    _FastIO;
    cin >> x >> a;
    if(x >= a)  cout << "1";
    cout << "0" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import collections

def show(c, str):
    if str in c:
        print(str, 'x', c[str])
    else:
        print(str, 'x', 0)

def resolve():

    S = sys.stdin.readlines()
    S = list(map(lambda x: x.strip(), S))
    N = int(S[0])

    del S[0]

    c = collections.Counter(S)

    show(c, 'AC')
    show(c, 'WA')
    show(c, 'TLE')
    show(c, 'RE')
    
resolve()

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

const int maxTime = 1e9+5;

int main() {
  int n, m;
  int k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  vector<ll> atot(n+1, 0), btot(m+1, 0);
  rep(i,n) {
    cin >> a[i];
    atot[i+1] = atot[i] + a[i];
  }
  rep(i,m) {
    cin >> b[i];
    btot[i+1] = btot[i] + b[i];
  }

  int j = m, ans = 0;
  rep(i,n+1) {
    if (atot[i] > k) break;
    while (btot[j] > k - atot[i]) j--;
    chmax(ans, i+j);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8020
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
#include <functional>
using namespace std;
int main() {
	int c[3][3];
	int ans[4];
	for (int i = 0; i < 3;i++) {
		for (int j = 0; j < 3;j++) {
			cin >> c[i][j];
		}
	}
	ans[0] = c[0][0] - c[0][1];
	ans[1] = c[0][0] - c[0][2];
	ans[2] = c[0][0] - c[1][0];
	ans[3] = c[0][0] - c[2][0];
	for (int i = 1; i < 3;i++) {
		if (ans[0] == c[i][0] - c[i][1] && ans[1] == c[i][0] - c[i][2] && ans[2] == c[0][i] - c[1][i] && ans[3] == c[0][i] - c[2][i]) {
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a;
	int b;
	int c;
	int d;
	cin >> a >> b >> c >> d;
	while(a>0 && c>0){
		c-=b;
		if(c<=0){
			cout << "Yes";
			break;
		}
		a-=d;
		if(a<=0){
			cout << "No";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int n;
	std::cin >> n;
	
	int a[n];
	for (int i = 0; i < n; i++) {
	    std::cin >> a[i];
	}
	
	int ans = pow(3,n);
	int even = 0;
    
	for (int i = 0; i < n; i++) {
	    if(a[i] % 2 == 0) even++;
	}
	
	std::cout << ans - pow(2,even) << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	static int[][] memory;
	
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
   
        int count = 0;
        boolean[] color = {false,false,false,false};
        
        for(int i = 0;i<N;i++){
        	
        	String line = sc.next();
        	
        	if('P'==line.charAt(0)&&!color[0]){
        		color[0] = true;
        		count++;
        	}else if('W'==line.charAt(0)&&!color[1]){
        		color[1] = true;
        		count++;
        	}else if('G'==line.charAt(0)&&!color[2]){
        		color[2] = true;
        		count++;
        	}else if('Y'==line.charAt(0)&&!color[3]){
        		color[3] = true;
        		count++;
        	}
        	
        	if(count==4) break;
        	
        }
        if(color[3])
        	System.out.println("Four");
        else
        	System.out.println("Three");
	}
		

    
}

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

int main(){
    long n; cin >> n;
    long cnt = 0;
    vector<long> I(n);
    vector<long> J(n);
    vector<long> K(n);
    for(int i=0;i<3;i++){
        for(int j=0;j<n;j++){
            if(i == 0)cin >> I[j];
            else if(i == 1)cin >> J[j];
            else cin >> K[j];
        }
    }
    sort(I.begin(),I.end());
    sort(K.begin(),K.end());
    for(int i=0;i<n;i++){
        long a = lower_bound(I.begin(),I.end(),J[i]) - I.begin();
        long b = K.end()-upper_bound(K.begin(),K.end(),J[i]);
        cnt += a*b;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 5636
main=do
 [n,m]<-map read.words<$>getLine
 a<-map read.words<$>getLine
 let
  s = sum a
  c = (fromIntegral s) * (1 / fromIntegral(4 * m))
  l = length $ filter (\x-> (fromIntegral x) >= c) a
 putStrLn $ if l >= m then "Yes" else "No"

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

int main(){
    int N;
    cin>>N;
    int L[N];
    rep(i,N)cin>>L[i];
    sort(L,L+N);
    int ans=0;
    rep(i,N)for(int j=i+1; j<N; j++)for(int k=j; k<N; k++){
        if(L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]&&L[k]<L[i]+L[j])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	for (const auto& e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& st) {
	for (const auto& e : st) os << e << " ";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2>& mp) {
	for (const auto& e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T&& h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head&& h, Tail&&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	Int N, T;
	cin >> N >> T;

	//vector<Int> A(N), B(N);
	//for (Int i = 0; i < N; i++) {
	//	cin >> A[i] >> B[i];
	//}

	vector<vector<Int>> ab(N, vector<Int>(2));
	for (Int i = 0; i < N; i++) {
		cin >> ab[i][0] >> ab[i][1];
	}
	sort(ab.begin(), ab.end());

	DMP(ab);

	vector<vector<Int>> dp(N+1, vector<Int>(T));//dp[i+1][j]: i番目までの料理の中で時間j以内となる最大うまさ

	Int ans = 0;
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < T; j++) {

			//i番目の料理を食べる場合
			if (j + ab[i][0] < T) {
				dp[i + 1][j + ab[i][0]] = max(dp[i][j] + ab[i][1], dp[i + 1][j + ab[i][0]]);
			}

			//i番目の料理を食べない場合
			dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
		}
	}


	/*for (Int j = 0; j < T; j++) {
		ans = max(ans, dp[N][j]);
	}*/

	for (Int i = 0; i < N; i++) {
		/*if (i==N) {
			ans = max(ans, dp[i][T - 1]);
			continue;
		}*/
		ans = max(ans, dp[i][T-1] + ab[i][1]);
	}

	cout << ans << "\n";
}


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

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

    int count = 0;
    char current = S[0];
    for (int i = 1; i < S.length(); ++i) {
	if (S[i] != current) {
	    count++;
	    current = S[i];
	}
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    string s; cin >> s;

    int cntp = 0;
    rep(i,s.size()) if(s[i] == 'p') cntp++;

    int p = s.size() / 2;

    cout << p - cntp << endl;
}

Measured memory_bytes: 512
n = int(input())
s = input()
mod = 10 ** 9 + 7
ans = 1
alfa = [chr(i) for i in range(97, 97+26)]
count = [0 for i in range(26)]
for i in range(n):
    x = s[i]
    y = alfa.index(x)
    count[y] += 1

for i in count:
    ans = (ans * (i + 1)) % mod
    
ans -= 1
print(ans)



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

int main(){
	long long n, k;
	cin >> n >> k;
	vector<long long> h(n);

	rep(i, n) cin >> h.at(i);
	sort(h.begin(), h.end());

	long long num = 0;
	rep(i, n-k){
		num += h.at(i);
	}

	cout << num << endl;
}

Measured memory_bytes: 1792
def rally(arr):
	p = max(arr)
	summ = 0
	best = float('inf')
	for i in range(1, p+1):
		summ = 0
		for j in arr:
			summ += (j - i) ** 2
		best = min(best, summ)
	return best
n = int(input())
arr = list(map(int, input().split()))
print(rally(arr))

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
// typedef pair<ll,ll> p;

int p,q,r;
int main(){
  cin >> p >> q >> r;
  int ans = min(p+q, min(q+r, r+p));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn], n;
int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	if(a[0] != 0)
		return cout << -1, 0;
	for(int i = 1; i < n; i++)
		if(a[i] > a[i - 1] + 1)
			return cout << -1, 0;
	for(int i = 1; i < n; i++) {
		if(a[i] == a[i - 1] + 1)
			ans ++;
		else
			ans += a[i];
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long tot, sum;
int n;
int main() {
	cin>>tot>>n;
	for(int i = 1; i <= n; i++) {
		long long now;
		cin>>now;
		sum += now;
	}
	if(sum >= tot)
	   cout<<"Yes"<<endl;
	else
	   cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b;
    cin >> a >> b;
    if(a == b) cout << "Draw" << endl;
    else if(a == 1) cout << "Alice" << endl;
    else if(b == 1) cout << "Bob" << endl;
    else{
        cout << ((a > b) ? "Alice" : "Bob") << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.parseLong;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int d = parseInt(sc.next());
		int x = parseInt(sc.next());
		int[] a = new int[n];
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		d--;
		int sum=n+x;
		for (i = 0; i < n; i++) {
			sum += d/a[i];
		}
		out.println(sum);
	}
}


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

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N, K;
    string S;
    cin >> N >> K >> S;
    int init = 0;
    for (int i = 1; i < N; i++) {
        if (S[i] == S[i - 1])
            init++;
    }
    cout << min(N - 1, init + 2 * K) << '\n';

    return 0;
}

Measured memory_bytes: 512
import Data.List

main = do
    s <- getLine
    putStrLn $ if judge s then "Yes" else "No"

judge :: String -> Bool
judge xs = (xs == reverse xs) && (ini == reverse ini) && (las == reverse las)
    where n   = length xs
          ini = take ((n - 1) `div` 2) xs
          las = drop ((n + 1) `div` 2) xs

Measured memory_bytes: 508
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    LL n;
    vector<LL> a;
    LL tmp_a;
    LL orig=0;
    LL ans;
    cin >> n;
    a.push_back(0);
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }
    a.push_back(0);
    for(int i=0; i<a.size()-1; i++){
        orig+=(int)abs(a[i]-a[i+1]);
    }
    for(int i=1; i<=n; i++){
        ans=orig-(int)abs(a[i-1]-a[i])-(int)abs(a[i]-a[i+1]);
        ans+=(int)abs(a[i-1]-a[i+1]);
        cout << ans << endl;
    }

    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll xa[405][405];
ll dp[405][405];
ll N, C;
ll a[405];
ll b[405];

void f(ll child, ll candy) {
    //cout << child << " " << candy << endl;
    if(dp[child][candy] != 0) {
        //cout << "Again " << child << " " << candy << endl;
        return;
    }
    if(child >= N + 1) return;
    ll ans = 0;
    for(ll now = 0; now <= candy; now++) {
        //cout << "calling " << child + 1 << " " << candy - now << endl;
        f(child + 1, candy - now);
        ans = (ans + xa[child][now] * dp[child + 1][candy - now]) % mod;
    }
    dp[child][candy] = ans;
    //cout << child << " " << candy << " " << ans << endl;
    return;
}

ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1) {
        ans = ans * a % mod;
    }
    return ans;
}

int main() {
    //cout.precision(10);
    cin >> N >> C;
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
    }
    for(int i = 1; i <= N; i++) {
        cin >> b[i];
    }
    for(ll i = 0; i <= C; i++) {
        for(ll child = 0; child <= N; child++) {
            for(ll j = a[child]; j <= b[child]; j++) {
                xa[child][i] = (xa[child][i] + beki(j, i)) % mod;
            }
            //cout << child << " " << i << " " << xa[child][i] << endl;
        }
    }
    dp[N + 1][0]++;
    f(1, C);
    cout << dp[1][C] << endl;
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector> //可変長配列
#include <queue> //キュー
#include <unordered_map> //ハッシュ連想配列
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int a,b,c,x,count=0; cin>>a>>b>>c>>x;
    for(int i = 0; i <= a; i++)
        for(int j = 0; j <= b; j++)
            for(int k = 0; k <= c; k++)
                if(x == 500*i+100*j+50*k)
                    count++;
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<set>
#include<unordered_map>
#include<fstream>
#include<map>
#include<vector>
using namespace std;
//#define F first
//#define S second
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
typedef pair<int, int> P;
int a[214514];
int b[214514];
int vst[214514];
unordered_map<int, int>M;
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	sort(a, a + n);
	rep(i, n) {
		rep(j, 32) {
			if (0<(1ll<<j)-a[i]&&(1ll << j) - a[i] <= a[i]) {
				b[i] = (1ll << j) - a[i];
			}
		
		}
	}
	//rep(i, n)cout << b[i] << endl;
	rep(i, n)M[a[i]]++;
	for (int i = n - 1; i >= 0; i--) {
		if (M[a[i]]&&M[b[i]]) {
			M[a[i]]--;
			M[b[i]]--;
			ans++;
			if (M[b[i]] == -1) {
				M[b[i]] += 2;
				ans--;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 20084
L, R = map(int, input().split())

l_max = min(L + 2018, R-1)
r_min = max(R - 2018, L+1)
ans = float("inf")
for l in range(L, l_max+1):
    for r in range(r_min, R+1):
        if l >= r:
            continue
        ans = min(ans, l*r%2019)
print(ans)


Measured memory_bytes: 2940
n=int(input())
h=list(map(int,input().split()))
dp=[0 for _ in range(n)]
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13928
from collections import deque

def astar(start, S, H, W):
  if S[start[0]][start[1]] == '#':
    return -1
  else:
    INF = 10**9
    D = [[INF]*W for h in range(H)]
    D[start[0]][start[1]] = 0
    next_node = deque([start])
    max_d = 0
    while next_node:
      now_y, now_x = next_node.popleft()
      d = D[now_y][now_x]
      for x, y in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
        if now_y+y<0 or now_y+y>=H or now_x+x<0 or now_x+x>=W:
          continue
        if S[now_y+y][now_x+x] == '.':
          if D[now_y+y][now_x+x] > d + 1:
            D[now_y+y][now_x+x] = D[now_y][now_x] + 1
            max_d = max(max_d, D[now_y+y][now_x+x])
            next_node.append([now_y+y, now_x+x])
    
    return max_d

H, W = map(int, input().split())
nodes = []
for h in range(H):
  for w in range(W):
    nodes.append([h, w])

S = []
for h in range(H):
  S.append(list(input()))

ans = 0
for start in nodes:
  ans = max(ans, astar(start, S, H, W))

print(ans)

Measured memory_bytes: 44396
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class S>void tf(bool b,S t,S f){cout<<(b?t:f)<<endl;}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vl d(n*3),l(n*3,0),r(n*3,0);
	rep(i,n*3)cin>>d[i];
	priority_queue<ll,vl,greater<ll>> ltr;
	ll sum=0;
	rep(i,n*3){
		sum+=d[i];
		ltr.push(d[i]);
		if(ltr.size()>n){
			sum-=ltr.top();
			ltr.pop();
		}
		l[i]=sum;
	}
	ltr=priority_queue<ll,vl,greater<ll>>();
	sum=0;
	rep(j,n*3){
		int i=n*3-1-j;
		sum+=d[i];
		ltr.push(-d[i]);
		if(ltr.size()>n){
			sum+=ltr.top();
			ltr.pop();
		}
		r[i]=sum;
	}
	ll ans=-LINF;
	range(i,n-1,n*2){
		chmax(ans,l[i]-r[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int n;
    string ans("hon");

    cin >> n;

    n = (n % 100) % 10;
    if (n == 3)
    {
        ans = "bon";
    }
    else if (n == 0 || n == 1 || n == 6 || n == 8)
    {
        ans = "pon";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int f(int n) {
    int ret = 0;
    int w = 2;
    n++;
    REP(i, 60) {
        if ((1LL << i) > n) break;
        int cnt = 0;
        int t = n / w;
        int r = n % w;
        cnt += (w / 2) * t;
        cnt += max(0LL, r - w / 2);
        if (cnt % 2) ret |= 1LL << i;
        w *= 2;
    }
    return ret;
}
signed main() {
    int A, B;
    cin >> A >> B;
    cout << (f(B) ^ f(A - 1)) << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
M = int(input())
ans = 0
prev = 0
arr = []
for _ in range(M):
    d, c = map(int, input().split())
    ans += c-1
    total = 0
    a = (c-1) // 9
    b = (c-1) % 9 + 1
    if d == 1:
        ans += a
        total = b
    elif d == 2:
        ans += a * 2
        if b >= 5: ans += 1
        total = [2,4,6,8,1,3,5,7,9][b-1]
    elif d == 3:
        ans += (c-1) // 3
        total = ((c-1) % 3 + 1) * 3
    elif d == 4:
        ans += a * 4
        if b >= 3: ans += 1
        if b >= 5: ans += 1
        if b >= 7: ans += 1
        total = [4,8,3,7,2,6,1,5,9][b-1]
    elif d == 5:
        ans += a * 5
        if b >= 2: ans += 1
        if b >= 4: ans += 1
        if b >= 6: ans += 1
        if b >= 8: ans += 1
        total = [5,1,6,2,7,3,8,4,9][b-1]
    elif d == 6:
        ans += ((c-1) // 3) * 2
        b = (c-1) % 3 + 1
        if b >= 2: ans += 1
        total = [6,3,9][b-1]
    elif d == 7:
        ans += a * 7
        if b >= 2: ans += 1
        if b >= 3: ans += 1
        if b >= 4: ans += 1
        if b >= 6: ans += 1
        if b >= 7: ans += 1
        if b >= 8: ans += 1
        total = [7,5,3,1,8,6,4,2,9][b-1]
    elif d == 8:
        ans += a * 8
        if b >= 2: ans += 1
        if b >= 3: ans += 1
        if b >= 4: ans += 1
        if b >= 5: ans += 1
        if b >= 6: ans += 1
        if b >= 7: ans += 1
        if b >= 8: ans += 1
        total = [8,7,6,5,4,3,2,1,9][b-1]
    elif d == 9:
        ans += (c-1)
        total = 9
    elif d == 0:
        total = 0
    # if prev + total >= 10:
    #     ans += 1
    #     total = (prev + total - 1) % 9 + 1
    # prev = total
    arr.append(total)
p = arr[0]
for m in arr[1:]:
    ans += 1
    if p + m >= 10:
        ans += 1
        p = (p + m - 1) % 9 + 1
    else:
        p = p + m
print(ans)

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

int main()
{
    int n, ans = 0;

    cin >> n;

    int mn = n + 5;

    for(int i = 0; i < n; i++){
        int x;

        cin >> x;

        if(x <= mn) ans++, mn = x;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=200005;

int n,x;
int a[N];

int main(){
	int i,j,k;
	scanf("%d",&n);
	scanf("%d",&x);
	if (n==2){
		if (x==2){
			printf("Yes\n");
			printf("1\n"); printf("2\n"); printf("3\n");
		}
		else printf("No\n");
		return 0;
	}
	if (x==1||x==n+n-1) printf("No\n");
	else{
		printf("Yes\n");
		a[n]=x; a[n-1]=x+1; a[n+1]=x-1; a[n-2]=x-2;
		if (x+2<=n+n-1) a[n+2]=x+2;
		for (i=1,j=1;i<=x-3;i++){
			while (a[j]) j++;
			a[j]=i;
		}
		for (i=x+3;i<=n+n-1;i++){
			while (a[j]) j++;
			a[j]=i;
		}
		for (i=1;i<=n+n-1;i++) printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
 
#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

ll MOD = 1000000007;
 
void solve() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    for (int i = 0 ; i < s.length() ; i++) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}
 
void querySolve() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    solve();
    //querySolve();
}



Measured memory_bytes: 3656