akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int H, W, h, w;

    cin >> H >> W;
    cin >> h >> w;

    cout << H*W - h*W - w*H + h*w << endl;


    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve()
{
	unsigned long long x, sum = 0;
	cin >> x;
	for (int i = 1; i <= x; i++)
		for (int j = 1; j <= x; j++)
			for (int k = 1; k <= x; k++)
				sum += __gcd(__gcd(i, j), k);
	cout << sum;
}
int main(void)
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	solve();

	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	string s[26][26];
	bool flag = false;
	rep(i, h) {
		rep(j, w) {
			cin >> s[i][j];
			if (s[i][j] == "snuke") {
				h = i;
				w = j;
				flag = true;
				break;
			}
		}
		if (flag) {
			break;
		}
	}
	cout << char(w + 'A') << h + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int kyo[1005] = {0};
	for (int i = 1; i <= n; i++) {
		cin >> kyo[i];
		
	}
	int wed[1005] = { 0 };
	for (int i = 1; i <= m; i++) {
		cin >> wed[i];
		
	}
	
	int dk1[1005] = { 0 }, dk2[1005] = { 0 };
	
	
	
	/*cout << dk2[2] << endl;*/
	dk1[1] = 0;
	dk1[2] = kyo[1] * wed[1];
	/*cout << dk1[1] <<" "<< dk1[2] << endl;*/
	for (int i = 2; i <= m; i++) {
		for (int j = 1; j <= i; j++) {
			/*cout <<"dk1[j] "<< dk1[j] << " "<<"dk2[j] "<<dk2[j] << endl;*/
			if(dk1[j]!=0){
				if (dk2[j] > dk1[j]) {
					dk2[j] = dk1[j];

				}
			}
			else {
				dk2[j] = dk1[j];
			}
			/*cout << "dk1[j]+kyo[i]*wed[i] "<<dk1[j] + kyo[i] * wed[i] << " dk2[j+1] " << dk2[j + 1] << endl;*/
			if (dk2[j + 1] != 0) {
				if (dk2[j + 1] > dk1[j] + kyo[j] * wed[i]) {
					dk2[j + 1] = dk1[j] + kyo[j] * wed[i];
					/*cout << "i " << i << " j " << j << " dk2[j+1] " << dk2[j + 1] << endl;*/
				}
			}
			else {
				dk2[j + 1] = dk1[j] + kyo[j] * wed[i];
			}

		}
		for (int k = 1; k <= i + 1; k++) {
			dk1[k] = dk2[k];
			
			dk2[k] = 0;
		}
		
	}
	cout << dk1[n + 1]<<endl;
    return 0;
}

Measured memory_bytes: 3084
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  int p[n];
  FOR(i,0,n) cin >> p[i];
  int dp[n+1][4];
  FOR(i,0,n+1)FOR(j,0,4)dp[i][j]=1e9;
  int ans = 1e9;
  FOR(i,0,n-1){
    if(i==0){
      FOR(j,0,4){
        dp[i][j] = min(dp[i][j], j * 2 + max(0, p[0] - j));
      }
    }
    else {
      FOR(j,0,4){
        FOR(k,0,4){
          if(k + j >= p[i]){
            dp[i][k] = min(dp[i][k], dp[i-1][j] + k * 2);
            if(i == n - 2) {
              dp[i+1][k] = min(dp[i+1][k], dp[i][k] + max(0, p[i+1] - k));
              ans = min(ans ,dp[i+1][k]);
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}


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

int main()
{
	ll N;
	cin >> N;
	ll res = LLONG_MAX;
	for (ll i = 1; i * i <= N; i++) if (N % i == 0) {
		res = min(res, (i - 1) + (N / i - 1));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	char str[4];
	int sum = 0;
	cin >> str[0] >> str[1] >> str[2] >> str[3];
	for(int i = 0; i < 4; ++i) {
		if (str[i] == '+') {
			++sum;
		} else {
			--sum;
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 256
use std::cmp;
use std::collections::VecDeque;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut xy: Vec<(u64, u64)> = (0..n)
        .map(|_| {
            let x: u64 = sc.read();
            let y: u64 = sc.read();
            (cmp::min(x, y), cmp::max(x, y))
        })
        .collect();

    let global_min = xy.iter().map(|&(x, _)| x).min().unwrap();
    let global_max = xy.iter().map(|&(_, y)| y).max().unwrap();

    let max_x = xy.iter().map(|&(x, _)| x).max().unwrap();
    let min_y = xy.iter().map(|&(_, y)| y).min().unwrap();
    let ans1 = (max_x - global_min) * (global_max - min_y);

    xy.sort();

    let mut ans2 = (xy[n - 1].0 - xy[0].0) * (global_max - global_min);
    let mut cur_y_min = global_max;
    let mut cur_y_max = global_min;
    for i in 0..n {
        let added_y = xy[i].1;
        cur_y_min = cmp::min(cur_y_min, added_y);
        cur_y_max = cmp::max(cur_y_max, added_y);

        let mut min = cur_y_min;
        if i + 1 < n {
            min = cmp::min(min, xy[i + 1].0);
        }

        let mut max = cur_y_max;
        if i < n - 1 {
            max = cmp::max(max, xy[n - 1].0);
        }

        ans2 = cmp::min(ans2, (global_max - global_min) * (max - min));
    }

    println!("{}", cmp::min(ans1, ans2));
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10620
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
namespace bst = boost;

int main() {
  int N,K,Q;

  cin >>N>>K>>Q;
  
  vector<int> A(N,K);
  int norm = 0;
  
  REP(i,Q) {
    int a;
    cin >> a;
    
    A[a - 1]++;
    norm++;
  }
  
  for (auto i : A)
  {
    cout << (i > norm ? "Yes" : "No") << endl;
  }

  return 0;
}


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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int A, B;
    string S;
    cin >> A >> B >> S;
    bool x = true;
    for (int i = 0; i < A; i++)
        if (!isdigit(S[i]))
            x = false;
    if(S[A]!='-')
        x = false;
    for (int i = A + 1; i < S.size(); i++)
        if (!isdigit(S[i]))
            x = false;
    cout << (x ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll k,t;
  cin >> k >> t;
  ll a=0;
  ll b;
  for(int i=0;i<t;i++){
    cin >> b;
    a=max(a,b);
  }
  b=k-a;
  ll z=0;
  cout << max(z,a-b-1) << endl;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1005,INF=1000;

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

int main(){
    
    ll N,X;cin>>N>>X;
    if(gcd(N,X)==1) cout<<(N-1)*3<<endl;
    else cout<<(N/gcd(N,X)-1)*3*gcd(N,X)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define SORT(n) sort((n).begin(),(n).end(),greater<int>())
#define SORTP sort((n).begin(),(n).end(),greater<pair<int,int>>());
#define pb push_back
#define eb emplace_back
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> vc( N * 2 );
	for( auto&& x : vc ){
		cin >> x;
	}
	sort( vc.begin(), vc.end() );
	int res{};
	REP( i, N * 2 ){
		res += min( vc[i], vc[i+1] );
		i++;
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	
	int A, B; 
	cin >> A >> B;

	int ans = 0;
	int num = 1;
	while(num < B){
		num += A-1;
		ans++;
	}

	cout << ans << endl;	


	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = (1ll<<31) - 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

struct Data
{
	int num;
	Data() :num(INF) {};
	Data(int n) :num(n) {};
};

struct SegmentTree
{
	int n; vector<Data> data;
	SegmentTree(int N)
	{
		n = 1;
		while (n < N) n *= 2;
		data.resize(2 * n);
	}
private:
	Data sub(int left, int right, int node, int nleft, int nright)
	{
		if (nright <= left || right <= nleft) return Data();
		if (left <= nleft && nright <= right) return data[node];
		Data vl = sub(left, right, node * 2 + 1, nleft, (nleft + nright) / 2);
		Data vr = sub(left, right, node * 2 + 2, (nleft + nright) / 2, nright);
		return min(vl.num, vr.num);
	}

public:
	void update(int pos, Data value)
	{
		pos += n - 1;
		data[pos] = value;
		while (pos > 0)
		{
			pos = (pos - 1) / 2;
			data[pos] = min(data[pos * 2 + 1].num, data[pos * 2 + 2].num);
		}
	}
	Data min_query(int left, int right)
	{
		return sub(left, right, 0, 0, n);
	}
};


int main()
{
	int n, q; cin >> n >> q;
	SegmentTree seg(n);
	REP(i, q)
	{
		int a, b, c;
		cin >> a >> b >> c;
		if (a == 0) seg.update(b, c);
		else cout << seg.min_query(b, c+1).num << endl;
	}
	return 0;
}

Measured memory_bytes: 3884
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())

ST = list(map(int, read().split()))
S = ST[0::2]
T = ST[1::2]
 
edge_out = [[] for i in range(N)] #edge_out[i]はiから出ている道
edge_in = [[] for i in range(N + 1)] # edge_in[i]はiに行く道
 
for i in range(M):
    s, t = S[i], T[i]
    edge_out[s].append(t)
    edge_in[t].append(s)
    

edge_sum = [len(edge_out[i]) for i in range(N)] # edge_sum[i] = iから出ている道の本数

dp = [0.0]*(N + 1) # dp[i]はiからNへの距離の期待値
dp[N - 1] = 1.0
# 道を塞がない場合
for i in range(N - 2, 0, - 1):
    dp[i] = 1 + sum(dp[j] for j in edge_out[i])/edge_sum[i]
    
p_to_i = [0]*(N + 1) # p_to_i[i]は1から各iへ到達する確率
p_to_i[1] = 1
for i in range(2, N + 1):
    p_to_i[i] = sum(p_to_i[j]/edge_sum[j] for j in edge_in[i])


t = 0

for i in range(1, N - 1):
    if edge_sum[i] == 1:
        continue
        # iから出ている道の先にある部屋のうち、その部屋からNまでの距離の期待値が最も大きいものへ通ずる道を塞ぐ
    t = max(t, p_to_i[i]*(dp[i] - 1- ((dp[i] - 1)*edge_sum[i] - max(dp[j] for j in edge_out[i]))/(edge_sum[i] - 1)))
    
print(dp[1] - t)

Measured memory_bytes: 30608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
int main()
{
    ARB
    ll h,w;
    cin>>h>>w;
    if(h==1||w==1)
    {
        cout<<1;
        return 0;
    }
    ll ans=(h*w);
    if(ans%2==0)
        cout<<ans/2;
    else
        cout<<ans/2+1;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <stdio.h>
using namespace std;
int main(void)
{
	for (int i = 1; i <= 9; i++)
		for (int j = 1; j <= 9; j++)
			printf("%dx%d=%d\n", i, j, i * j);

	return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int n;
	cin>>n;
  	vector<long long>store(n+1,0);
  	long long mod=1000000007;
	for(int i=3;i<n+1;++i){
		store[i]+=1;
    	for(int j=i+3;j<n+1;++j){
          	store[j]=(store[j]+store[i])%mod;
        }
    }
  	cout<<store[n]<<endl;
  	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
struct Node
{
	int key;
	Node* parent;
	Node* left;
	Node* right;
};
Node* root;
void insert(int val)
{
	Node* x = new Node();
	x->key = val;
	x->left = nullptr;
	x->right = nullptr;
	Node *q = nullptr;
	Node *p = root;
	while (p != nullptr)
	{
		q = p;
		if (x->key < p->key)
			p = p->left;
		else
			p = p->right;
	}
	x->parent = q;
	if (q == nullptr)
		root = x;
	else if (x->key < q->key)
		q->left = x;
	else
		q->right = x;
}
Node* find(Node* root,int x)
{
	while (root != nullptr&&root->key != x)
	{
		if (x < root->key)
			root = root->left;
		else
			root = root->right;
	}
	return root;
}
void inorder(Node* root)
{
	if (root == nullptr)
		return;
	inorder(root->left);
	printf(" %d", root->key);
	inorder(root->right);
}
void preorder(Node* root)
{
	if (root == nullptr)
		return;
	printf(" %d", root->key);
	preorder(root->left);
	preorder(root->right);
}
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		int t;
		cin >> s;
		if (s[0] == 'i')
		{
			cin >> t;
			insert(t);
		}
		else if (s[0] == 'p')
		{
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		else if (s[0] == 'f')
		{
			cin >> t;
			cout << (find(root,t) ? "yes" : "no") << endl;
		}
	}
}


Measured memory_bytes: 22024
#!/usr/bin/env python3

h,w = map(int,input().split())
a = []
dlrow = []
dlcol = []

efrow = list(range(h))
efcol = list(range(w))

# input
for i in range(h):
    a.append(input())

# row
for i in range(h):
    flg = True
    for j in range(w):
        if a[i][j] == '#':
            flg = False
    # delete this row
    if flg == True:
        dlrow.append(i)
        efrow.remove(i)

#print("dlrow =",dlrow)
#print("efrow =",efrow)

# column
for j in range(w):
    flg = True
    for i in range(h):
        if a[i][j] == '#':
            flg = False
    # delete this column
    if flg == True:
        dlcol.append(j)
        efcol.remove(j)

#print("dlcol =",dlcol)
#print("efcol =",efcol)

# print
for i in efrow:
    s = []
    s2 = []
    for j in efcol:
      s.append(a[i][j])
      s2 = "".join(s)
    print(s2) 


Measured memory_bytes: 3064
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <bitset>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <numeric>
#include <set>
#include <cassert>
#include <cmath>
#include <cinttypes>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}
template<class T> T read_val() { throw 1; }
template<> int read_val() { int tmp; scanf("%" PRId32, &tmp); return tmp; }
template<> long long read_val() { long long tmp; scanf("%" PRId64, &tmp); return tmp; }
auto read_int = read_val<int>; auto read_long = read_val<long long>;
template<class T> void scanf_vec(vector<T>& vec) { for (int i = 0; i < vec.size(); i++) vec[i] = read_val<T>(); }

#define MOD 1000000007
#define inf 2000000000
#define FWT_SIZE 2000000
#define pii pair<int,int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define sort_all(x) sort(all(x))
#define make_unique(x) (x).erase(unique(all(x)), (x).end())



int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	int n, k;
	cin >> n >> k;
	vector<int> p(n);

	cin >> p;
	stack<int> min_p;
	int nearest = n, ans = 0, been_none=0;

	stack<pii> max_a, max_b;

	for (int j = p.size() - 1; j >= 0; j--)
	{
		while (min_p.size() > 0 && p[min_p.top()] >= p[j])
			min_p.pop();

		bool changes = false;
		if (min_p.size() > 0 && p[j] > p[min_p.top()])
		{
			changes = min_p.top() < j + k;
			nearest = min(nearest, min_p.top());
		}
		int curr_max = 0;
		if (max_a.size() > 0) curr_max = max(curr_max, max_a.top().second);
		if (max_b.size() > 0) curr_max = max(curr_max, max_b.top().second);
		if (j + k < n && p[j + k] < curr_max)
			changes = true;

		min_p.push(j);

		if (j + k - 1 < n && nearest < j + k && (j+k==n || changes))
		{
			ans++;
		}

		if (j + k - 1 < n && nearest >= (j + k))
			been_none = 1;

		if (k > 1)
		{
			if (max_a.size() > 0) max_a.push({ p[j], max(p[j],max_a.top().second) });
			else max_a.push({ p[j], p[j] });
			if (max_b.size() == 0)
			{
				int max_v = 0;
				while (max_a.size() > 0)
				{
					max_v = max(max_v, max_a.top().first);
					max_b.push({ max_a.top().first, max_v });
					max_a.pop();
				}
			}
			while (max_a.size() + max_b.size() > (k - 1))
				max_b.pop();
		}
	}

	cout << ans+been_none;

	return 0;
}

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


struct UnionFind {
  vector<int> par;
    
  UnionFind(int n) : par(n, -1) { }
  void init(int n) { par.assign(n, -1); }
    
  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
    
  bool issame(int x, int y) {
    return root(x)==root(y);
  }
    
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x==y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x]+=par[y];
    par[y]=x;
    return true;
  }
    
  int size(int x) {
    return -par[root(x)];
  }
};

int main() {
  ll n,m; cin>>n>>m;
  vector<int> A(m),B(m);
  rep(i, m) {
    cin>>A[i]>>B[i];
    A[i]--; B[i]--;
  }

  ll sum=n*(n-1)/2;
  UnionFind uf(n);
  vector<ll> res;
  rep(i, m) {
    res.push_back(sum);
    int a=A[m-1-i];
    int b=B[m-1-i];
    if (uf.issame(a, b)) continue;
    ll x=uf.size(a);
    ll y=uf.size(b);
    sum-=x*y;
    uf.merge(a, b);
  }
  reverse(res.begin(), res.end());
  rep(i, m) cout<<res[i]<<endl;
}


Measured memory_bytes: 3444
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int left = (25 * N - 1) / 27 + 1;
    int right = (25 * N + 24) / 27;
    if (right < left) System.out.println(":(");
    else System.out.println(left);
  }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=20,INF=1e9;

int N,cost;
int t[MAX_N][MAX_N];
int dp[1<<MAX_N];
vector<int> visited;

void solve(){
    for (int mask=0;mask<(1<<N);++mask) dp[mask]=INF;
    dp[0]=0;
    for (int mask=0;mask<(1<<N);++mask){
        visited.clear();
        for (int i=0;i<N;++i) if (mask&1<<i){
            visited.emplace_back(i);
        }
        for (int i=0;i<N;++i) if (!(mask&1<<i)){
            cost=t[i][0];
            for (int j:visited) cost=min(cost,t[i][j+1]);
            dp[mask|1<<i]=min(dp[mask|1<<i],dp[mask]+cost);
        }
    }
    cout << dp[(1<<N)-1] << '\n';
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N,N){
        for (int i=0;i<N;++i)
            for (int j=0;j<N+1;++j)
                cin >> t[i][j];
        solve();
    }
}


Measured memory_bytes: 3388
#include<iostream>
#include<cstring>
using namespace std;
int n;
bool a[105];
int main(){
	memset(a,0,sizeof(a));
	cin>>n;
	for (int i=1;i<10;i++)
		for (int j=1;j<10;j++)	a[i*j]=1;
	if (a[n]) cout<<"Yes";else cout<<"No";
	return 0;
}

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

prev_d1=0
prev_d2=0

seq=0
flag = False
for _ in range(N):
    d1, d2 = map(int, input().split())

    if d1==d2:
        seq+=1
    else:
        seq=0

    if seq==3:
        flag=True
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  cin>>n;
  vin x(n),l(n);
  rep(i,0,n)cin>>x[i]>>l[i];
  vector<P> a(n);
  rep(i,0,n){
   a[i]=mp(x[i]+l[i],x[i]-l[i]); //後ろ　前
  }
  sort(all(a));
  int ans=0;
  int ude=-inf;
  rep(i,0,n){
    int w=a[i].first;
    int v=a[i].second;
    if(ude<=v){
      ude=w;
      ans++;
     // cout<<v<<endl;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4820
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;
int mod = 1000000007;

int N, M, R;

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

  vector<int> r(R);
  rep(i, R) {
    cin >> r.at(i);
  }

  int dist[201][201];
  rep(i, 201) {
    rep(j, 201) {
      if (i==j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = INT_MAX;
      }
    }
  }

  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    dist[a][b] = c;
    dist[b][a] = c;
  }

  for(int k=1; k<=N; k++) {
    for(int i=1; i<=N; i++) {
      for (int j=1; j<=N; j++) {
        if (dist[i][k] != INT_MAX && dist[k][j] != INT_MAX) {
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }
  }

  sort(r.begin(), r.end());
  int ans = INT_MAX;
  do {
    int now = 0;
    rep(i, R-1) {
      now += dist[r.at(i)][r.at(i+1)];
    }
    ans = min(now, ans);
  } while (next_permutation(r.begin(), r.end()));

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int MAX_V = 50;
const int MAX_S = MAX_V * 50 + 50;

struct Edge {
    int to, a, b;
    Edge(int to, int a, int b): to(to), a(a), b(b) {}
};

struct Data {
    int v, s; //頂点、所持金
    ll x; // 時間
    Data(int v, int s, ll x):v(v), s(s), x(x) {}
    bool operator<(const Data & a) const {
        return x > a.x;
    }
};

vector<Edge> g[MAX_V];

// 頂点数, 所持金
ll dp[MAX_V][MAX_S+5];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, s;
    cin >> n >> m >> s;
    rep(i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }

    rep(i, n) rep(j, MAX_S + 5) dp[i][j] = LINF;
    s = min(s, MAX_S);

    priority_queue<Data> q;
    auto push = [&](int v, int s, ll x) {
        if (s < 0) return;
        if (dp[v][s] <= x) return;
        dp[v][s] = x;
        q.emplace(v, s, x);
    };

    vector<int> c(n), d(n);
    rep(i, n) cin >> c[i] >> d[i];

    push(0, s, 0);
    
    while(!q.empty()) {
        Data hoge = q.top(); q.pop();
        int v = hoge.v, s = hoge.s;
        ll x = hoge.x;
        if (dp[v][s] != x) continue;
        {
            // 両替
            int ns = min(s+c[v], MAX_S);
            push(v, ns, x+d[v]);
        }
        for (Edge e : g[v]) {
            push(e.to, s-e.a, x+e.b);
        }
    }
    for (int i = 1; i < n; ++i) {
        ll ans = LINF;
        rep(j, MAX_S+5) {
            ans = min(ans, dp[i][j]);
        }
        cout << ans << endl;
    }

    return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n; cin >> n;
    map<int, int> count;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        count[a]++;
    }

    int ans = 0;
    for (auto &e: count) {
        int val = e.first, num = e.second;
        ans += (val <= num ? num - val : num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
from bisect import bisect_left, bisect_right
n = int(input()) # 入力が1つ
s = input()
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字
r = []
g = []
b = []
for i in range(n):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    else:
        b.append(i)
ans = 0

def bs(nums, target):
    l = 0
    r = len(nums) - 1
    while l <= r:
        mid = (l + r) // 2
        if nums[mid] == target:
            return True
        elif nums[mid] < target:
            l = mid + 1
        else:
            r = mid - 1
    return False

def solution(t1, t2, t3):
    ans = 0
    if len(t1) < 1 or len(t2) < 1 or len(t3) < 1:
        return ans
    for i in range(len(t2)):
        num = t2[i]
        left = bisect_left(t1, num)
        right = bisect_right(t3, num)
        ans += left * (len(t3) - right)

    for i in t1:
        for j in t3:
            if i < j:
                if (i + j) % 2 == 0 and bs(t2, (i + j) // 2):
                    ans -= 1
    return ans

ans = 0
ans += solution(r, g, b)
ans += solution(r, b, g)
ans += solution(g, r, b)
ans += solution(g, b, r)
ans += solution(b, r, g)
ans += solution(b, g, r)
print(ans)

Measured memory_bytes: 69292
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n,kk;
	cin >> n >> kk;
	vector<int> x(n),y(n);
	rep(i,n)cin >> x[i] >> y[i];
	vector<int> sortx(n),sorty(n);

	rep(i,n)
	{
		sortx[i]=x[i];
		sorty[i]=y[i];
	}
	sort(ALL(sortx));
	sort(ALL(sorty));

	ll ans =1LL *  (sortx[n-1]-sortx[0])*(sorty[n-1]-sorty[0]);

	for(int i= 0;i<n;i++)
		for(int j= i+1;j<n;j++)
			for(int k = 0;k< n;k++)
				for(int l=k+1;l<n;l++)
				{
					int c = 0;
					rep(m,n)
					{
						if(sortx[i]<=x[m]&&x[m]<=sortx[j]&&sorty[k]<=y[m]&&y[m]<=sorty[l])
						c++;
					}

					if(c>=kk)
					{
						//cout<<c<<endl;
						ans = min (ans , 1LL*(sortx[j]-sortx[i])*(sorty[l]-sorty[k]) );
					}
				}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    cin >> h;
    sort(all(h));
    ll ans = 0;
    if(k >= h.size()){
        cout << ans << endl;
        return 0;
    }
    for(int i = 0;i<h.size()-k;i++){
        ans += h[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3964
n=int(input())
a=[0]*n
b=[0]*n
ans=0
cnt=0
for i in range(n):
    a[i],b[i]=map(int,input().split())
#print(a)
a=a[::-1]
b=b[::-1]
#print(a)
for i in range(n):
    a[i]+=cnt
    if a[i]%b[i]==0:
        continue
    else:
        #print(b[i]-a[i]%b[i])
        cnt+=b[i]-a[i]%b[i]
        a[i]+=b[i]-a[i]%b[i]
print(cnt)


Measured memory_bytes: 47192
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  string s;
  cin>>s>>k;
  vector<string>ss;
  ss.push_back("");
  rep(i,s.size())
  {
    rep(j,min((int)s.size()-i+1,6))
    {
      ss.push_back(s.substr(i,j));
    }
  }
  sort(all(ss));
  ss.erase(unique(all(ss)),ss.end());
  //cout<<(ss[3]==ss[4])<<endl;
  //rep(i,5)cout<<ss[i]<<endl;
  cout<<ss[k]<<endl;

  return 0;

}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
using graph = vector<vector<int>>;

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	if(n >= 30) cout << "Yes" << endl;
	else cout << "No" << endl; 
} 

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

public class Main {
    int K, X;
    String solve(){
        if(K * 500 >= X) return "Yes";
        return "No";
    }

    public void _main() throws Exception {
        //System.setIn(new FileInputStream("/home/zxt/workspace/contest/inputs/a.in"));
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] ss = in.readLine().split("[ \t]+");
        K = Integer.parseInt(ss[0]);
        X = Integer.parseInt(ss[1]);

        System.out.println(solve());
    }

    public static void main(String[] args) throws Exception {
        Main s = new Main();
        s._main();
    }
}

Measured memory_bytes: 23380
import java.util.Scanner;


public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        
        int a = (price+1000-1)/1000;
        int r = a*1000 - price;
        System.out.println(r);
        
//        if(price < 1000) {
//            System.out.println(price);
//        } else {
//            int surplus = price % 1000;
//            int change  = 1000 - surplus;
//            System.out.println(change);
//        }
    }
}

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

int main(){
    int n;cin>>n;
    while(n--){
        int a,b,c;cin>>a>>b>>c;
        int mi=min(min(a,b),c);
        int ans=mi;
        a-=mi;b-=mi;c-=mi;
        mi=min(a/2,b);
        ans+=mi;
        a-=mi*2;b-=mi;
        ans+=a/3;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 300000
using namespace std;
int n,seq[MAXN+5],lsh[MAXN+5],lcnt;
int a[MAXN+5],b[MAXN+5],la,lb;
int main()
{
//	freopen("sort.in","r",stdin);
//	freopen("sort.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&seq[i]);
		lsh[++lcnt]=seq[i];
	}
	sort(lsh+1,lsh+1+lcnt);
	lcnt=unique(lsh+1,lsh+1+lcnt)-lsh-1;
	for(int i=1;i<=n;i++)
		seq[i]=lower_bound(lsh+1,lsh+1+lcnt,seq[i])-lsh;
	int ans=0;
	for(int i=1;i<=n;i+=2)
		if(seq[i]%2==0)
			ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <stack>
#include <utility>
#include <algorithm>

using namespace std;

const int kNil = -1;

enum class Color {
  kWhite,
  kGrey,
  kBlack,
};

template <class T>
struct Edge {
  using w_type = T;
  Edge(int u, int v, w_type w): u(u), v(v), w(w) { }
  int u, v;
  w_type w;
  bool operator<(const Edge<T> & rhs) const {
    if (w != rhs.w) { return w < rhs.w; }
    if (u != rhs.u) { return u < rhs.u; }
    return v < rhs.v;
  }
};

template <class Edge>
void DFSVisitTopological(const typename vector<Edge>::size_type node_now,
       typename vector<Edge>::size_type & time,
       const vector<vector<Edge>> & adjacency_list,
       vector<int> & d,
       vector<int> & f,
       vector<Color> & color,
       vector<int> & parent,
       stack<int> & stk) {
  color[node_now] = Color::kGrey;
  d[node_now] = time++;
  for (const auto & e: adjacency_list[node_now]) {
    if (color[e.v] == Color::kWhite) {
      parent[e.v] = node_now;
      DFSVisitTopological(e.v, time, adjacency_list, d, f, color, parent, stk);
    }
  }
  color[node_now] = Color::kBlack;
  f[node_now] = time++;
  stk.push(node_now);
}

template <class Edge>
decltype(auto) DFSTopological(const vector<Edge> & edges,
                 typename vector<Edge>::size_type node_num) {
  using size_type = typename vector<Edge>::size_type;

  vector<vector<Edge>> adjacency_list(node_num, vector<Edge>());
  for (const auto & e: edges) {
    adjacency_list[e.u].push_back(e);
  }

  vector<int> d(node_num);
  vector<int> f(node_num);
  vector<Color> color(node_num, Color::kWhite);
  vector<int> parent(node_num);
  stack<int> stk;
  size_type time = 0;

  for (unsigned i = 0; i < node_num; ++i) {
    if (color[i] == Color::kWhite) {
      DFSVisitTopological(i, time, adjacency_list, d, f, color, parent, stk);
    }
  }

  return stk;
}

int main(int argc, char const *argv[]) {
  using w_type = unsigned;

  vector<Edge<w_type>> edges;
  unsigned V, E;
  cin >> V >> E;
  for (unsigned i = 0; i < E; ++i) {
    unsigned u, v;
    w_type w;
    cin >> u >> v;
    edges.emplace_back(u, v, 1);
  }

  auto result = DFSTopological(edges, V);
  while (!result.empty()) {
    auto e = result.top();
    result.pop();
    cout << e << endl;
  }

  return 0;
}

Measured memory_bytes: 4448
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "map"

using namespace std;
const long long int MOD = 1000000007;

long long int N,M;
long long int box;
int num[100000];
char letter[100001];


int main() {
	cin >> N >> M;
	if (N * 2 > M) {
		cout << M / 2 << endl;
		return 0;
	}
	box = (M - 2 * N) / 4;
	N += box;
	M -= box * 2;
	
	cout << min(N, M / 2) << endl;
	return 0;
}


Measured memory_bytes: 256
n, k = gets.chomp.split.map(&:to_i)
dices = gets.chomp.split.map { |n| (1 + n.to_f) / 2.0 }

ans = 0
current = 0
target = []

n.times do |i|
  if i < k
    current += dices[i]
    target << dices[i]
    next
  end

  previous = target.shift
  target.push dices[i]
  current = current - previous + dices[i]

  ans = current if current > ans
end

ans = current if ans.zero?

puts ans


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

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long x1 = parseLong(sc.next());
		long y1 = parseLong(sc.next());
		long x2 = parseLong(sc.next());
		long y2 = parseLong(sc.next());
		sc.close();
		long dx = x2-x1;
		long dy = y2-y1;
		long x3 = x2-dy;
		long y3 = y2+dx;
		long x4 = x3-dx;
		long y4 = y3-dy;
		out.printf("%d %d %d %d%n", x3, y3, x4, y4);
	}
}


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

using namespace std;
using ll = long long;

int main() {
    string s; cin >> s;
    map <char, int> mp;
    for (auto c : s) {
        mp[c]++;
    }

    for (auto pp : mp) {
        if (pp.second & 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const int MAX_N = 110;
const int MAX_W = 100010;

int N, W;
ll w[MAX_N];
ll v[MAX_N];

ll dp[MAX_N][MAX_W];

void _main()
{
    cin >> N >> W;
    rep(i, 0, N) cin >> w[i] >> v[i];

    memset(dp, -1, sizeof(dp));

    dp[0][0] = 0;

    rep(i, 0, N)
    {
        rep(weight, 0, W + 1)
        {
            chmax(dp[i + 1][weight], dp[i][weight]);

            if (weight - w[i] < 0) continue;
            if (dp[i][weight - w[i]] < 0) continue;

            chmax(dp[i + 1][weight], dp[i][weight - w[i]] + v[i]);
        }
    }

    cout << *max_element(dp[N], dp[N] + MAX_W) << endl;
}


Measured memory_bytes: 86272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
void func(vector<int>& l, int depth, int idx){
  ;
}
int main() {
  int n;cin>>n;
  vector<string> s(n);
  vector<int> t(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
    cin>>t[i];
  }
  string x;cin>>x;
  int ans=0;
  bool found=false;
  for(int i=0;i<n;i++){
    if(found){
      ans+=t[i];
    }
    if(s[i]==x){
      found=true;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3632
from collections import defaultdict

N, C, K = map(int, input().split())

ps = defaultdict(int)
for i in range(N):
    T = int(input())
    ps[T] += 1

count = 0
current_ps = 0
time_limit = 10**9+K+1

for t in sorted(ps.keys()):
    if t > time_limit and current_ps > 0:
        count += 1
        current_ps = 0

    if current_ps == 0:
        time_limit = t + K

    current_ps += ps[t]
    while current_ps >= C:
        count += 1
        current_ps -= C
        time_limit = t + K

if current_ps > 0:
    count += 1

print(count)

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

int main(){
    int n, m;
    cin>>n>>m;
    set<int> st,st1;
    for(int i = 1; i <= m; i ++) {
        int x, y;
        cin >> x >> y;
        if(x == 1) st.insert(y);
        if(y == 1) st.insert(x);
        if(x == n) st1.insert(y);
        if(y == n) st1.insert(x);
    }
    set<int>::iterator it;
    for(it = st.begin(); it != st.end(); it ++) {
        if(st1.count((*it))){
            return 0*printf("POSSIBLE\n");
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}


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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> using iodef_rng_t = typename enable_if<decltype(declval<C>().begin(), true_type{})::value && !is_same<C, string>::value>::type;
template<class C, class = iodef_rng_t<C>> istream& operator>>(istream& in, C& c) { for (auto& v : c) { in >> v; } return in; }
template<class C, class = iodef_rng_t<C>> ostream& operator<<(ostream& out, const C& c) { int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    int64_t a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a + b) {
        cout << min(k, a) << '\n';
    } else if (k <= a + b + c) {
        cout << a - (k - a - b) << '\n';
    }
}


Measured memory_bytes: 3652
k = input()
d = int(input())
mod = 10**9+7
if d == 1:
    print(int(k)%mod)
    exit()
dp = [[[0]*2 for i in range(d)] for j in range(len(k))]
## dp[][][0] k 以下確定 [1] 未定

s = int(k[0])
dp[0][s%d][1] = 1
for i in range(s):
    dp[0][i%d][0] = 1

for i in range(1,len(k)):
    s = int(k[i])
    for j in range(10):
        for m in range(d):
            if s == j:
                dp[i][(m+j)%d][1] += dp[i-1][m][1]
                dp[i][(m+j)%d][1] %= mod
            elif s > j:
                dp[i][(m+j)%d][0] += dp[i-1][m][1]
                dp[i][(m+j)%d][0] %= mod
            dp[i][(m+j)%d][0] += dp[i-1][m][0]
            dp[i][(m+j)%d][0] %= mod
ans = sum(dp[-1][0])

print((ans-1)%mod)

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

bool check(string &s, string &t) {
    map<char, char> s2t, t2s;
    for (int i = 0; i < (int)s.size(); i++) {
        char si = s[i], ti = t[i];
        if (s2t.count(si)) if (s2t[si] != ti) return false;
        if (t2s.count(ti)) if (t2s[ti] != si) return false;
        s2t[si] = ti, t2s[ti] = si;
    }
    return true;
}

int main() {
    string s, t; cin >> s >> t;
    cout << (check(s, t) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 776