akhauriyash/Code-Regression huggingface dataset:
N,W = map(int, input().split())
dp = [[0]*(W+1) for y in range(N+1)]

for i in range(1,N+1):
    v, w = map(int, input().split())
    dp[i][0:w] = dp[i-1][0:w]
    for j in range(w, W+1):
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v)

print(dp[N][W])

Measured memory_bytes: 25488
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    int sum = 0;
    while(n > 0){
        sum++;
        n /= 2;
    }
    int ans = 1;
    while(sum > 1){
        sum--;
        ans *= 2;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int N; cin >> N;
    vector<int> a(N);
    bool flag = 1;

    int count = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    
    while (flag)
    {
        flag = 0;
        for (int i = 0; i < N-1; i++)
        {
            if (a[i] > a[i+1])
            {
                int tmp = a[i+1];
                a[i+1] = a[i];
                a[i] = tmp;
                count++;
                flag = 1;
            }
        }
    }
    

    cout << a[0];
    for (int i = 1; i < N; i++)
    {
        cout << " " << a[i];
    }
    cout << endl;
    cout << count << endl;

}


Measured memory_bytes: 3096
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

bool chk(int n){
    stringstream ss;
    ss << n;
    auto s = ss.str();
    auto t = s;
    reverse(all(t));
    return s == t;
}

int main(){
    int n;
    while(cin >> n && n){
        int ans = -1;
        for(int i=0;i<10000;i++){
            int y = -i+n;
            if(y >= 0 && chk(y)){
                ans = y;
                break;
            }
            int x = i+n;
            if(chk(x)){
                ans = x;
                break;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1224
#include <stdio.h>
 
int main() {
    int a, b, c, date = 0;
    int week;
    int ans;
    scanf("%d %d %d",&a, &b, &c);
 
    week = a * 7 + b;
 
    date += c / week;
    ans = date * 7;
      
    c -= week * date;
 
    if (c < a * 7) {
        if (c%a == 0) {
            ans += c / a;
        }
        else {
            ans += c / a + 1;
        }
    }
    else {
        ans += 7;
    }
 
    printf("%d\n", ans);
}



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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

void show(vector<int> &s){
    REP(i,s.size()){
        cout << s[i] << " ";
    }
    cout << endl;
}

vector<int> z_algorithmn(string &s){
    vector<int> a(s.size(),0);
    a[0] = s.size();
    int i = 1,j = 0;
    while(i < s.size()){
        while(i+j < s.size() && s[j] == s[i+j])j++;
        a[i] = j;
        // show(a);
        if(j == 0){i++;continue;}
        int k = 1;
        while(i+k < s.size() && k+a[k] < j)a[i+k] = a[k], k++;  //前方で同じ最長共通文字列の情報を利用
        // show(a);
        i += k; j -= k;
    }
    return a;
}

int solve(string &s){
    int ans = 0;
    REP(i,s.size()){
        string ss = s.substr(i);
        vector<int> index = z_algorithmn(ss);
        // REP(i,index.size()){
        //     cout << index[i] << endl;
        // }
        // j:重ならない距離、index[j]:jからの最長共通文字列の長さ
        // j ＜ index[j] の場合、重なっているため、重なっている長さ分を除去した長さjが採用される
        // ex) ababa,j=2(j_0=0)の時、 index[2]=3であり、"aba"と"aba"で'a'が重なっているため、"ab"が採用される 
        // 
        REP(j,index.size()){
            int k = min(j,index[j]);
            ans = max(k,ans);
        }
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = solve(s);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int k, n, a[N];
int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>k>>n;
	for (int i=1; i<=n; i++){
		cin>>a[i];
	}
	int mx = a[1] + k - a[n];
	for (int i=2; i<=n; i++){
		mx = max(mx, a[i] - a[i-1]);
	}
	cout<<k-mx;
}

Measured memory_bytes: 1024
import Data.List
import Data.Function

solve :: String -> Char -> Int
solve []  _ = 0
solve s c
  | all (==c) s = 0
  | otherwise   = 1 + solve (go s) c
  where
    go []  = []
    go [_] = []
    go (s1:s2:ss) = (if s1 == c || s2 == c
                        then c else s1) : go (s2:ss)

main :: IO ()
main = do
    s <- getLine :: IO String
    print . minimum $ map (solve s) s

Measured memory_bytes: 1020
n = int(input())
a = list(map(int, input().split()))

approvedNum = 0

for num in a:
    if num % 2 == 0:
        if num % 3 == 0 or num % 5 ==0:
            approvedNum += 1
    if num % 2 == 1:
        approvedNum += 1

print('APPROVED') if approvedNum == len(a) else print('DENIED')

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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007

const int mx = 1e6 + 1;

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	int n; cin >> n;
	int a[n];
	unordered_map<int, int> freq;
	for(int i=0; i<n; i++){
	    cin >> a[i];
	    freq[a[i]]++;
	}
	sort(a, a+n);
	bool check[mx];
	int m = a[n-1];
	memset(check, false, sizeof(check));

	for(int i=0; i<n; i++){
	    for(int j=a[i]*2; j<=m;){
		check[j] = true;
		j += a[i];
	    }
	    if(freq[a[i]] > 1)
		check[a[i]] = true;
	}
	int ans = 0;
	for(int i=0; i<n; i++){
	    if(!check[a[i]])
		ans++;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 13172
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    rep(i, (n/2)+1) {
        int a, b;
        a = i;
        b = n-a;
        rep(j, (m/2)+1) {
            int c, d;
            c = j;
            d = m-c;
            int sum = a*c+b*d;
            if (sum == k || sum == (n*m - k)) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

string s, t;

void solve() {
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			cout << "No";
			return;
		}
	}
	cout << "Yes";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a[3];
    int cnt_5, cnt_7;

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

    cnt_5 = cnt_7 = 0;
    for (int i = 0; i < 3; ++i) {
        if (a[i] == 5) {
            cnt_5++;
        } else if (a[i] == 7) {
            cnt_7++;
        }
    }

    if (cnt_5 == 2 && cnt_7 == 1) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int solve(int answer) {
	int a, ab, abc, abcd;
	int cnt = 0;
	for (a = 0; a < 10; a++) {
		if (answer < a)
			break;
		for (ab = a; ab < a + 10; ab++) {
			if (answer < ab)
				break;
			for (abc = ab; abc < ab + 10; abc++) {
				if (answer < abc)
					break;
				for (abcd = abc; abcd < abc + 10; abcd++) {
					if (answer == abcd) {
						cnt++;
						break;
					}
					if (answer < abcd)
						break;
				}
			}
		}
	}
	return cnt;
}
int main() {
	int n;
	while (scanf(" %d", &n) != EOF) {
		printf("%d\n", solve(n));
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a <= k) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}



Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

/*
問題の見かけに反して重実装

アリとラベルを別に考える。
アリ同士がぶつかる際に、すり抜けてラベルだけ交換するとしても同じ
アリ0がA回ぶつかったらラベルは
	アリ0が右回りなら：(0+A)%n
	アリ0が左回りなら：(0-A)%n
ラベルの順序は変わらないので、アリ0が何回ぶつかるかをカウントすれば全てのアリのラベルと位置が分かる
ただし、アリ0と同じ位置のが2個あったら、ソートする際にアリ0がどの位置に置かれるかが不明なため、個別に考える
	右回りの場合は：２つのうち中心から見て左側
	左回りの場合は：２つのうち中心から見て右側

速度を半分にして時間を倍にすると端数が出なくて計算しやすい
*/

bool is_same_pos=false;
ll n,l,t,x[100010],w[100010],hit=0,zero_id,zero_pos,ans[100010];
mp afterPos_and_beforeID[100010];

int main(void){
	cin>>n>>l>>t;
	rep(i,n)cin>>x[i]>>w[i];
	//アリ0がぶつかる回数をカウント
	rep(i,n){
		if(w[0]==1 && w[i]==2){//回転方向によってカウント方法が変わるので
			if(2*t-(x[i]-x[0])>0){//ちょうどは衝突に含めない
				hit++;
				if((2*t-(x[i]-x[0]))%l==0){//ちょうどは衝突に含めない
					hit+=(2*t-(x[i]-x[0]))/l - 1;
				}else{
					hit+=(2*t-(x[i]-x[0]))/l;
				}
			}
		}
		if(w[0]==2 && w[i]==1){
			if(2*t-(l-(x[i]-x[0]))>0){
				hit++;
				if((2*t-(l-(x[i]-x[0])))%l==0){//ちょうどは衝突に含めない
					hit+=(2*t-(l-(x[i]-x[0])))/l - 1;
				}else{
					hit+=(2*t-(l-(x[i]-x[0])))/l;
				}
			}
		}
	}
	//t秒後のアリの位置
	rep(i,n){
		if(w[i]==1){
			x[i]=(x[i]+t)%l;
		}else{
			x[i]=((x[i]-t)%l+l)%l;
		}
		if(i==0){
			zero_pos=x[i];
		}else if(x[0]==x[i]){//同じ位置のやつがいるか確認
			is_same_pos=true;
		}
	}
	sort(x,x+n);
	//アリ0がどこに行ったか調べる
	rep(i,n){
		if(x[i]==zero_pos){
			if(is_same_pos){
				if(w[0]==1){
					//右に同じ位置のがあるか確認
					if(x[(i+1)%n]==x[i]){
						zero_id=i;
					}else{
						zero_id=(i-1+n)%n;
					}
				}else{
					//左に同じ位置のがあるか確認
					if(x[(i-1+n)%n]==x[i]){
						zero_id=i;
					}else{
						zero_id=(i+1)%n;
					}
				}
			}else{
				zero_id=i;
				break;
			}
		}
	}
	//ラベルの付替え作業
	rep(i,n){
		int after_id;
		if(w[0]==1){//進む方向によってアリ0のラベルの値が変わるので
			after_id = ((i-zero_id+hit)%n+n)%n;
		}else{
			after_id = ((i-zero_id-hit)%n+n)%n;
		}
		ans[after_id] = x[i];
	}
	rep(i,n)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 3584
from collections import *
n=int(input())
a=list(map(int,input().split()))
a.sort()
a=deque(a)
ans=[]
aa=a.pop()
tmp=a.popleft()
while a:
    t=a.popleft()
    if t<=0:
        ans.append((aa,t))
        aa-=t
    else:
        ans.append((tmp,t))
        tmp-=t
ans.append((aa,tmp))
print(aa-tmp)
for i in ans:
    print(i[0],i[1])

Measured memory_bytes: 93356
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll N;
  ll AC = 0;
  ll WA = 0;
  ll TLE = 0;
  ll RE = 0;
  string S;
  cin >> N;
  rep(i, N)
  {
    cin >> S;
    if (S == "AC")
    {
      AC++;
    }
    else if (S == "WA")
    {
      WA++;
    }
    else if (S == "TLE")
    {
      TLE++;
    }
    else if (S == "RE")
    {
      RE++;
    }
  }

  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;

  return 0;
}


Measured memory_bytes: 3720
#include <iostream>

using namespace std;

int main(void) {
    int X, A, B, C, D;
    cin >> X;
    A = X/1000;
    B = X%1000/100;
    C = X%100/10;
    D = X%10;
    for (int i=-1;i<2;i++) for (int j=-1;j<2;j++) for (int k=-1;k<2;k++) if (i) if (j) if (k) {
        int ret = A + i*B + j*C + k*D;
        if (ret == 7) {
            cout << A;
            if (i>0) cout << "+"; else cout << "-";
            cout << B;
            if (j>0) cout << "+"; else cout << "-";
            cout << C;
            if (k>0) cout << "+"; else cout << "-";
            cout << D << "=7" << endl;
            return 0;
        }
    }

    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int now=n,d=0;
	while (now>0)
	{
		d+=now%10;
		now/=10;
	}
	if (n%d==0)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
count_0 = 0
count_1 = 0
for i in range(n):
    if i % 2== 0:
        if int(s[i]) != 1:
            count_1 += 1
        else:
            count_0 += 1
    else:
        if int(s[i]) == 1:
            count_1 += 1
        else:
            count_0 += 1
print(min(count_0,count_1))

Measured memory_bytes: 3188
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

/*

3 3
1 2 1
2 3 2
3 4 3
//=> 2

3 1
1 2 1
3 4 1
5 6 1
//=> 1

3 1
1 2 1
2 3 1
3 4 1
//=> 2

*/

fn main() {
    let (N, C) = read!(usize, usize);
    let mut T = read![usize, usize, usize; N];

    T.sort_by_key(|&(s, t, c)| (c, s, t));

    let mut i = 0;
    while i + 1 < N {
        let mut j = i + 1;

        while j < N {
            let (s1, t1, c1) = T[i];
            let (s2, t2, c2) = T[j];
            if c1 != c2 || t1 != s2 {
                break;
            }

            T[i] = (s1, t2, c1);
            T[j] = (0, 0, std::usize::MAX);
            j += 1;
        }

        i = j;
    }
    T.retain(|&(_, _, c)| c != std::usize::MAX);
    let N = ();

    let mut events = vec![];
    for &(s, t, c) in &T {
        events.push((s, 0, c));
        events.push((t, 1, c));
    }
    events.sort();

    debug!(T, events);

    let mut alloc = 0;
    let mut free = 0;
    for (_, ev, _) in events {
        if ev == 0 {
            // 録画開始
            if free >= 1 {
                free -= 1;
            } else {
                alloc += 1;
            }
        } else {
            // 録画終了
            free += 1;
        }
    }

    println!("{}", alloc)
}


Measured memory_bytes: 17704
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    int[] LUT = new int[1000];
    for (int i = 1; i < 1000; ++i) {
      LUT[i] = i * (i + 1) * (i + 2) / 6;
    }
    int[] dp = new int[1000000 + 1];
    Arrays.fill(dp, 1 << 28);
    dp[0] = 0;
    for (int i = 1; i < 1000; ++i) {
      for (int j = 0; j <= 1000000; ++j) {
        int next = j + LUT[i];
        if (next > 1000000) {
          break;
        }
        dp[next] = Math.min(dp[next], dp[j] + 1);
      }
    }
    int[] ep = new int[1000000 + 1];
    Arrays.fill(ep, 1 << 28);
    ep[0] = 0;
    for (int i = 1; i < 1000; ++i) {
      if (LUT[i] % 2 == 0) {
        continue;
      }
      for (int j = 0; j <= 1000000; ++j) {
        int next = j + LUT[i];
        if (next > 1000000) {
          break;
        }
        ep[next] = Math.min(ep[next], ep[j] + 1);
      }
    }
    for (; ; ) {
      int n = ni();
      if (n == 0) {
        break;
      }

      System.out.println(dp[n] + " " + ep[n]);
    }
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 35180
#include <stdio.h>
#include <climits>
#include <algorithm>

const int N_MAX = 100000;
const int A_MAX = 1000000000;

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

  // dp[i] は、長さi+1になる部分増加列のうち最右項が最小のもの
  // 存在しなければINF
  int dp[N_MAX];
  int INF = INT_MAX;
  std::fill(dp,dp+N_MAX,INF);
  // O(n)
  for(int i=0;i<n;i++){
    // O(log(n))
    *std::lower_bound(dp,dp+n,a[i]) = a[i];
  }

  printf("%d\n",std::lower_bound(dp,dp+n,INF)-dp);

}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vii vector<ii>
#define vs vector<string>
#define si set<ll>
#define endl "\n"
#define pb push_back
#define x first
#define y second
//g++ -std=c++11 -Wall -Wextra -pedantic-errors main.cpp -o main
const int ms = 1e3 + 5, base = 31, mod = 1e9 + 7;
using namespace std;

double P[ms];

void sieve(){
	double sum = 0;
	for (int i = 1; i < ms; i++){
		sum += i;
		P[i] = sum/i;
	}
}

int main(){
	ios::sync_with_stdio(false), cin.tie(0);
	
	
	sieve();
	int n, k; cin >> n >> k;
	
	vi arr;
	
	for (int i = 0; i < n; i++){
		int a;cin>>a;
		arr.pb(a);
	}
	
	double ans = 0;
	
	double temp = 0;
	for (int j = 0; j < k; j++){
		temp += P[arr[j]];
	}
	ans = temp;
	for (int i = k; i < n; i++){
		temp -= P[arr[i-k]];
		temp += P[arr[i]];
		
		ans = max(ans, temp);
	}
	
	cout << setprecision(10) << fixed << ans << endl;
	
	return 0;
}

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

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  long long ans = 1000000000000000;
  for(int i = 0; i <= 100000; i++){
    long long tmp = 0;
    tmp += 2 * c * i + a * max(0, x-i) + b * max(0, y - i);
    ans = min(tmp,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
using namespace std;
int main(){
    ll th,ts;
    cin>>th>>ts;
    ll oh,os;
    cin>>oh>>os;
    ll turnt=(oh+ts-1)/ts;
    ll turno = (th+os-1)/os;
    if(turnt<=turno){
        cout<<"Yes\n";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 3636
t = readline.to_i
t.times{
  n = readline.to_i
  h = readline.split.map(&:to_i)
  diff = []
  h[0..-2].zip(h[1..-1]){|a, b| diff << a-b}
  min_val, max_val = diff.minmax
  if min_val > 0
    min_val = 0
  end
  if max_val < 0
    max_val = 0
  end

  puts "#{-min_val} #{max_val}"    
}

Measured memory_bytes: 8760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b>> c;
    if (a + b >= c) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int n; cin >> n;
    bool ok = false;
    int x = 0;
    while(n--)
    {
        int a, b;
        cin >> a >> b;
        if(a == b) x++;
        else x = 0;

        if(x == 3) ok = true;
    }

    cout << (ok ? "Yes" : "No") << endl;
    
    return 0;
}

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

const int N = 2e5 + 10;
typedef long long LL;

int n, a[N];
LL ans, sum, cur;

int main(){
    scanf("%d", &n);
    sum = 0;
    ans = (LL)1e18;
    for(int i=1; i<=n; i++){
        scanf("%d", a+i);
        sum += a[i];
    }
    cur = 0;
    for(int i=1; i<n; i++){
        cur += a[i];
        ans = min(ans, abs(sum - cur - cur));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    out(a * b / 2);
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


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

int main() {
    ll X, K, D; cin >> X >> K >> D;
    if (X < 0) X = -X;
    if (K < X / D) {
        X -= K * D;
        cout << X << endl;
        return 0;
    }
    ll T = X / D;
    K -= T;
    X -= T * D;
    if (K < X / D) {
        X -= K * D;
        cout << X << endl;
        return 0;
    }

    if (X == 0 && K % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll X2 = abs(X - D);
    if (K % 2 == 1) {
        cout << X2 << endl;
    } else {
        cout << X << endl;
    }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	
	printf("%d\n", std::min({a + b, b + c, c + a}));
	return 0;
}


Measured memory_bytes: 764
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    int x4 = 0, x2 = 0, x1 = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];

        if(a[i]%4 == 0)x4++;
        else if(a[i]%4 == 2)x2++;
        else x1++;
    }

    if(x2 != 0){
        if(x4>=x1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    else{
        if(x4>=x1-1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}


Measured memory_bytes: 640
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
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;}
// clang-format on

void solve(long long X, long long Y, long long Z) {
  ANS(Z << " " << X << " " << Y);
}

// clang-format off
int main() {
  long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
  long long Z;
  scanf("%lld",&Z);
  solve(X, Y, Z);
  return 0;
}


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

typedef long long ll;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

int main(){
    string S,T;

    cin >> S >> T;
    int N = S.size();
    vector<char> a;

    REP(i,N){
        char x = S[i];
        char y = T[i];
        if(x == y){
            a.push_back(x);
        }
        else{
            REP(j, a.size()){
                if(a[j] == x || a[j] == y){
                    cout << "No" << endl;
                    return 0;
                }
            }
            for(int j = i; j<N; j++){
                if(S[j] == x){
                    S[j] = y;
                }
                else if(S[j] == y){
                    S[j] = x;
                }
            }
        a.push_back(y);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1032
def mod_(b, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * b % mod
        b = b * b % mod
        n >>= 1
    return int(res)

def main():

    N = int(input())
    A = list(map(int, input().split()))

    n = ((N+1) >> 1)
    li = [0]*n



    for a in A:
        li[a >> 1] += 1

    if N & 1:
        if li[0] != 1:
            print(0)
        elif li.count(2) != n-1:
            print(0)
        else:
            c = n-1
            print(2 ** c % (10**9+7))
    else:
        if li.count(2) != n:
            print(0)
        else:
            c = n
            print(2 ** c % (10**9+7))

main()

Measured memory_bytes: 14008
# N=頂点数、X,Y=座標
N, X, Y = map(int, input().split())

# 最短距離データ
min_dist_list = [0 for i in range(N+1)]

for i in range(1,N+1):
    for j in range(i+1, N+1):
            t_dist = min(abs(j-i), 1+abs(X-i)+abs(Y-j), 1+abs(Y-i)+abs(X-j)) 
            min_dist_list[t_dist] += 1         

for i in range(1, N):
    print(min_dist_list[i])

Measured memory_bytes: 3444
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

constexpr ll mod = 1e9 + 7;

ll modpow(ll a, ll b) {
	if (a > mod) a %= mod;
	if (b == 0LL) return 1LL;
	ll tmp = modpow(a, b / 2);
	if (b & 1LL)
		return tmp * tmp % mod * a % mod;
	return tmp * tmp % mod;
}

// S(i, j) = 1^j + 2^j + 3^j + ... + i^j (^ : 累乗)
ll S(int i, int j){
    static bool first_called = true;
    static vector<vector<ll>> res(401, vector<ll>(401, 0LL));
    if (first_called){
        for (int j = 0; j <= 400; ++j){
            res[0][j] = 0;
            for (int i = 1; i <= 400; ++i)
                res[i][j] = (res[i - 1][j] + modpow(i, j)) % mod;
        }
    }
    first_called = false;
    return res[i][j];
}

int main(void){
    int N, C; cin >> N >> C;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];
    for (int i = 0; i < N; ++i)
        cin >> B[i];
    
    vector<vector<ll>> dp(N + 1, vector<ll>(C + 1, 0LL));
    dp[0][0] = 1LL;

    for (int i = 0; i < N; ++i){
        for (int k = 0; k <= C; ++k){
            for (int c = 0; c <= C - k; ++c){
                ll tmp = (S(B[i], c) - S(A[i] - 1, c) + mod) % mod;
                dp[i + 1][k + c] += tmp * dp[i][k] % mod;
                dp[i + 1][k + c] %= mod;
            }
        }
    }

    /* for (int i = 0; i <= N; ++i){
        for (int c = 0; c <= C; ++c)
            cout << dp[i][c] << " ";
        cout << endl;
    } */

    cout << dp[N][C] << endl;

    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007

bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int binaryExponentiation(int x, int n) //function to calculate x raise to power n
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x;
		x = x * x;
		n = n / 2;
	}
	return result;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-______________________________________________________________________________


	string s;
	cin >> s;
	if (s[1] == 'B')
	{
		s[1] = 'R';
	}
	else
	{
		s[1] = 'B';
	}
	cout << s << en;

	return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N>>S;
  int A=N;
  for(int i=0;i<N;i++){
    if(S[i]==S[i+1]){
      A--;
    }
  }
  cout<<A<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++) cout<<"x";
  cout<<endl;
}


Measured memory_bytes: 256
from heapq import heappop,heappush
V,E,r = map(int,input().split())
G = [[] for _ in range(V)]
for _ in range(E):
    s,t,d = map(int,input().split())
    G[s].append((t,d))
PQ = []
INF = float("inf")
dist = [INF]*V
white = 0; gray = 1 ;black = 2
color = [white]*V
heappush(PQ,(0,r))
dist[r] = 0

while PQ:
    md,s = heappop(PQ)
    color[s] = black
    if dist[s] < md: continue
    for t,d in G[s]:
        if color[t] == black: continue
        if dist[t] > dist[s] + d:
            dist[t] = dist[s] + d
            color[t] = gray
            heappush(PQ,(dist[t],t))
    
print("\n".join(map(lambda x:"INF" if x == INF else str(x),dist)))


Measured memory_bytes: 95452
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	C := make([]int, int(1e4)+1)
	n := nextInt(sc)
	for i := 0; i < n; i++ {
		v := nextInt(sc)
		C[v]++
	}
	wtr := bufio.NewWriter(os.Stdout)
	cnt := 0
	for i := 0; i < len(C); i++ {
		if C[i] == 0 {
			continue
		}
		if cnt > 0 {
			fmt.Fprint(wtr, " ")
		}
		for j := 0; j < C[i]; j++ {
			if j > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, i)
			cnt++
		}
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}
func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}



Measured memory_bytes: 6324
### A

N = int(input())
a_all = list(map(int, input().split()))
t = list(set(a_all))

if len(t)==3:
    if (t[0]^t[1]==t[2]):
        a=0
        b=0
        c=0
        for i in a_all:
            if i==t[0]:
                a+=1
            elif i==t[1]:
                b+=1
            else:
                c+=1
        if a==b and b==c:
            print("Yes")
        else:
            print("No")
    
    else:
        print("No")
    
    
elif len(t)==2:
    a=0
    b=0
    for i in a_all:
        if i==t[0]:
            a+=1
        else:
            b+=1
    if(a == b*2 or  b == a*2):
        print("Yes")
    else:
        print("No")
elif len(t)==1:
    if t[0]^t[0]==t[0]:
        print("Yes")
    else:
        print("No")

else:
    print("No")

Measured memory_bytes: 14212
#include<bits/stdc++.h>
using namespace std;
#define int             unsigned long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define no_of_test(x)   int x; cin>>x; while(x--)
const int mod = 1e9 + 7;
void very_fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}


int32_t main()
{
	very_fast();
//	no_of_test(x)
	{
		int n, k, count = 0;
		cin >> n >> k;
		for (int i = 0; i < n; i++)
		{
			int x, y;
			cin >> x >> y;
			int w = ((x - 0) * (x - 0) + (y - 0) * (y - 0));
			int l = k * k;
			if (w <= l)
				count++;
		}
		cout << count << endl;

	}
	return 0;
}





Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
#define N 200010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
int n;


int calc(vector<int> A){
  int sum = 0;
  for(int i=0;i<n;i++) {
    if(i == n-1 && A[i] == i) return sum+1;
    if(A[i] == i) sum++,swap(A[i],A[i+1]);
  }
  
  return sum;
}

int rcalc(vector<int> A){
  int sum = 0;
  for(int i=n-1;i>=0;i--) {
    if(i == 0 && A[i] == i) return sum+1;
    if(A[i] == i) sum++,swap(A[i],A[i-1]);
  }
  return sum;
}


signed main(){
  vector<int> A;
  cin>>n;
  A.resize(n);
  for(int i=0;i<n;i++) cin>>A[i],A[i]--;
  cout<<min(calc(A),rcalc(A))<<endl;
  
  return 0;
}


Measured memory_bytes: 2560
import math
a,b,h,m = map(int,input().split())
m_rad = (m * math.pi) / 30
h_rad = ((60*h+m)*math.pi)/360
rad = abs(h_rad -m_rad)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(rad))
print(ans)

Measured memory_bytes: 9432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0114
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                long[] items = RLongAr();
                if (items.Sum() == 0) break;

                long a1 = items[0]; long m1 = items[1];
                long a2 = items[2]; long m2 = items[3];
                long a3 = items[4]; long m3 = items[5];

                long x1 = 1, x2 = 1, x3 = 1;
                int cnt1 = 0, cnt2 = 0, cnt3 = 0;

                do { x1 = (a1 * x1) % m1; cnt1++; } while (x1 != 1);
                do { x2 = (a2 * x2) % m2; cnt2++; } while (x2 != 1);
                do { x3 = (a3 * x3) % m3; cnt3++; } while (x3 != 1);

                Console.WriteLine(Lcm(Lcm(cnt1,cnt2),cnt3));
            }

        }

        /// <summary>
        ///最小公倍数
        /// </summary>
        public static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }

        /// <summary>
        ///最大公約数
        /// </summary>
        public static long Gcd(long a, long b)
        {
            if (a < b) return Gcd(b, a);  // 引数を入替えて自分を呼び出す
            if (b == 0) return a; //一方が0の場合は、もう片方の数自身がGCD

            long d = 0;
            do
            {
                d = a % b;
                a = b;
                b = d;
            } while (d != 0);
            return a;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

int main() {
    int n, m, a;
    cin >> n >> m;
    priority_queue<int> q;
    for (int i=0;i<n;i++) {
        cin >> a;
        q.push(a);
    }
    for (int i=0;i<m;i++) {
        int k = q.top();
        q.pop();
        k /= 2;
        q.push(k);
    }
    ll ans = 0;
    while(!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

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

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	int max1 = 0, max2 = 0;
	rep(i, n){
		cin >> a[i];
		if(a[i] > max1){
			max1 = a[i];
		}else if(a[i] > max2){
			max2 = a[i];
		}
	}
	rep(i, n){
		if(a[i] != max1) cout << max1 << endl;
		else cout << max2 << endl;
	}
	
	
	return 0;
}

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

int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s / 100;
  s2 = (s - (s1 * 100)) / 10;
  s3 = s - (s1 * 100) - (s2 * 10);
  cout << s1 + s2 + s3 << endl;
}

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

    ll ans = 0;
    ll ct = ((K - 1) * K) / 2;
    ct %= MOD;
    rep(i, N) {
        ll cnt = 0;
        repd(j, i + 1, N) {
            if (A[i] > A[j]) cnt++;
        }
        ans += cnt * K;
        ans %= MOD;
        cnt = 0;
        rep(j, N) {
            if (A[i] > A[j]) cnt++;
        }
        ans += cnt * ct;
        ans %= MOD;
    }

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

Measured memory_bytes: 3640