akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

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; }
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N, M;
vector<PI> V;
int a,b;
int main(void){
    cin >> N >> M;
    rep(i,N){
        scanf("%d%d",&a,&b);
        V.push_back(PI(M-a,b));
    }
    sort(V.begin(), V.end());
    /*
    for(int i=0;i<V.size();i++)
        cout << V[i].first << " " << V[i].second << endl;
    return 0;
    */
    PQI S;
    ll dp[100000];
    dp[N] = 0;
    dp[N-1] = 0;
    int s=N-1;
    for(int i = N-1;i >=0;i--){
        while(V[s].first >= i and s >= 0){
            S.push(V[s].second);
            s--;
        }
        if(!S.empty()){
            // cout << i << " " << S.top() << endl;
            dp[i] = dp[i+1] + S.top();
            S.pop();
        }else dp[i] = dp[i+1];
    }
    cout << dp[0] << endl;

    return 0;
}



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

int x[501][501];

int main(){
  int a,b,i,n,j,k,m,h,l,q;
  cin >> n >> m >> q;
  //vector<pair<int,int> > pairs(n);
  for(i=0;i<m;i++){
    cin >> j >> k;
    x[j][k]++;
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      x[i][j]+=x[i-1][j];
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      x[i][j]+=x[i][j-1];
    }
  }
  //long long ret = 0;
  for(i=0;i<q;i++){
    cin >> j >> k;
    cout << x[k][k]+x[j-1][j-1]-x[j-1][k]-x[k][j-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1920
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;


///// failed!!
#if 1
class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
#endif

/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


int main()
{
	ll N, M;
	
	cin >> N >> M;

	ll a[M], b[M];

	rep(i, M)
	{
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}

	UnionFind tree(N);

	ll ans[M];
	memset(ans, 0, sizeof(ans));
	ll nn = 0;

	rrep(i, M)
	{
		
		ans[i] = nn;
		
		if (!tree.same(a[i], b[i]))
		{
			nn += tree.size__(a[i]) * tree.size__(b[i]); 
			//cout << nn << ", a=" << a[i] << ", b=" << b[i]<<", tree.size__(a[i])=" << tree.size__(a[i]) <<"; tree.size__(b[i])=" << tree.size__(b[i])<< endl;
		}
		tree.unite(a[i], b[i]);

	}
	ll total = N * (N-1) / 2;

	rep(i, M)
	{
		cout << total - ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int k;
  string s;
  cin >> k >> s;
  if(s.size()<=k)cout << s << "\n";
  else {
    REP(i, k) { cout << s.at(i); }
    cout << "..." << "\n";
  }
  return 0;
}


Measured memory_bytes: 3632
import sys

l = []
for i in sys.stdin:
    l.append(i.split())

for i in range(0,len(l)):
    if l[i][0] == '0' or l[i][1] == '0':
        continue
    for j in range(0,int(l[i][0])):
        for k in range(0,int(l[i][1])):
            if (j % 2 == 0 and k % 2 == 0) or (j % 2 != 0 and k % 2 != 0):
                print("#",end='')
            else:
                print(".",end='')
        print()
    print()


Measured memory_bytes: 7012
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	int R, G, B, N;
	cin >> R >> G >> B >> N;

	ll ans = 0;

	for (int r = 0; r*R <= N; r++) {
		for (int g = 0;r*R + g*G <= N; g++) {

			int nokori = N - (r*R + g * G);

			if (nokori % B == 0) {
				ans++;
			}


		}
	}


	cout << ans;



}




Measured memory_bytes: 256
from itertools import *
g=lambda a,x,b:a+b if x=='+'else a-b if x=='-'else a*b
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   if g(g(g(a,x,b),y,c),z,d)==10:return f"((({a} {x} {b}) {y} {c}) {z} {d})"
   if g(g(a,x,b),y,g(c,z,d))==10:return f"(({a} {x} {b}) {y} ({c} {z} {d}))"
 return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


Measured memory_bytes: 5656
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define INF 0x3f3f3f3f
#define INFll 0x3f3f3f3f3f3f3f3f
#define y0 _lxybz_
#define y1 _ljmnzyzhhhoscartxdy_
typedef long double ld;
typedef long long ll;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define lo(x) ((x)&(-(x)))
#define trav(a, x) for (auto &a : x)
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
const ld Pi = 4*atan((ld)1);
template<class T> void chmin(T &a,const T&b) { a = min(a, b); }
template<class T> void chmax(T &a,const T&b) { a = max(a, b); }
namespace IO{
template<class T> inline void read(T&ret)
{
	ret=0; int f=1; char c=getchar();
	while(c<48||c>57){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	ret*=f;
}
template<class T> inline void prin(const T&ret)
{
	if(!ret){putchar(48);return;} static T o; o=ret;
	if(o<0){putchar('-');o=-o;}
	static int op[25],tt; tt=0;
	while(o){
		op[++tt]=o%10;
		o/=10;
	}
	for(int i=tt;i;--i)putchar(op[i]+48);
}
template<class T> inline void pri_(const T&ret)
{
	prin(ret);putchar(' ');
}
template<class T> inline void priE(const T&ret)
{
	prin(ret);putchar('\n');
}
}
using namespace IO;

#define N 
#define MO 
int n,ma;
string s;
map<string, int>mp;
inline void _Sol_()
{
	read(n);
	F(i,1,n){
		cin>>s;
		++mp[s];
		chmax(ma,mp[s]);
	}
	for(auto it=mp.begin();it!=mp.end();++it){
		if(it->second==ma)cout<<it->first<<endl;
	}
}

int main()
{
	int T=1; //read(T);
	while(T--)_Sol_();
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main(){
  int n;
  cin >> n;
  int zero=0;
  map<pair<ll,ll>,P> mp; // x/y とその個数．
  rep(i,n){
    ll x ,y;
    cin >>x>>y;
    if(x==0 && y==0){
      zero++;
      continue;
    }
    ll g=gcd(x,y);
    x /=g;
    y /=g;
    if(y<0) x=-x, y=-y;
    if(y==0 && x <0) x=-x,y=-y;
    bool rot90 = (x<=0);
    if(rot90){
      ll tmp=x;
      x=y; y=-tmp;
    }
    if(rot90) mp[{x,y}].first++;
    else mp[{x,y}].second++;
  }
  mint ans=1;
  
  for(auto p : mp){
    int s = p.second.first;
    int t = p.second.second;
    //cout <<s<<t<<endl;
    
    mint now=1;
    now +=mint(2).pow(s)-1;
    now +=mint(2).pow(t)-1;
    ans *=now;
  }
  ans-=1;
  ans+=zero;
  cout<<ans<<endl;
  return 0;
  
  
}

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

const int N = 1e5 + 10, INF = 0x3f3f3f3f ;

int f[N][15];
int p[N][15];
int temp[N];

int main(){
    ios_base::sync_with_stdio(0);
    int n;cin>>n;
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < 10;j++) {
            cin>>f[i][j];
        }
    }
    for(int i = 0;i < n;i++) {
        for(int j = 0;j <= 10;j++) {
            cin>>p[i][j];
        }
    }
    ll res = -INF;
    for(int i = 1;i < (1<<10);i++) {
        memset(temp,0,sizeof temp);
        for(int j = 0;j < n;j++) {
            for(int k = 0;k < 10;k++) {
                if(f[j][k] && ((1<<k)&i)) {
                    temp[j]++;
                }
            }
        }
        ll t = 0;
        for(int j = 0;j < n;j++) {
            t += p[j][temp[j]];
        }
        res = max(res,t);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <atcoder/all>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3000000;
const int K = 100000;
const int mod = 1e9 + 7;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m;
    cin >> n >> m;
    scc_graph g(n);
    for (int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        g.add_edge(u, v);
    }
    vector<vector<int>> scc = g.scc();
    cout << scc.size() << endl;
    for (auto x: scc){
        cout << x.size() << " ";
        for (auto y: x) cout << y << " ";
        cout << endl;
    }
}


Measured memory_bytes: 40604
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const int N = 3005;

double dp[N][N];
double p[N];
int n;

int main(){

    cin>>n;
    for(int i=0;i<n;i++)
        cin>>p[i];
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(j==0){
                dp[i][j] = dp[i-1][j]*(1-p[i-1]);
            }
            else{
                dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1]);
            }
        }
    }

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

    double ans = 0;
    for(int i=(n+1)/2;i<=n;i++)
        ans+=dp[n][i];

    cout<<fixed<<setprecision(10)<<ans<<endl;

    return 0;
}


Measured memory_bytes: 74216
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n, t, e, x[128];
  scanf("%d%d%d", &n, &t, &e);
  rep(i, n) scanf("%d", x+i);
  rep(i, n){
    for(int j = 1; x[i] * j <= t+e; j++){
      if(x[i] * j >= t-e){
	printf("%d\n", i+1);
	return 0;
      }
    }
  }

  puts("-1");
  return 0;
}

Measured memory_bytes: 1188
def is_operator(op):
    if '+' == op:
        return True
    if '-' == op:
        return True
    if '*' == op:
        return True

    return False

def operate(op, stack):
    if not is_operator(op):
        stack.append(op)
        return stack

    n2 = int(stack.pop())
    n1 = int(stack.pop())

    if '+' == op:
        n = n1+n2
    if '-' == op:
        n = n1-n2
    if '*' == op:
        n = n1*n2

    stack.append(str(n))

    return stack

def main():
    ops = input().split()

    stack = []
    for op in ops:
        stack = operate(op, stack)

    print(stack.pop())

if __name__ == '__main__':
    main()



Measured memory_bytes: 5596
#include <iostream>
#include <bitset>

using namespace std;
constexpr int MAX = 600000;
bitset<MAX> Mask;
int LSB = 0;
int MSB = MAX - 1;
bool place(const int d)
{
    if (d > MAX) {
        return not Mask.all();
    } else {
        const int bit = MAX - d;
        if (MSB < bit) {
            return false;
        } else {
            int pos = bit;
            while (Mask[pos]) {
                Mask[pos] = 0;
                pos++;
            }
            Mask[pos] = 1;
            if (pos == MSB) {
                while (pos >= 0 and Mask[pos]) {
                    pos--;
                }
                MSB = pos;
            }
            return true;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    bool first = true;
    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        if (first) {
            cout << "Yes" << endl;
            for (int i = d + 1; i < MAX; i++) {
                place(i);
            }
            first = false;
        } else {
            cout << (place(d) ? "Yes" : "No") << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,K;
    cin >> N >> K;
    vector<int>h(N);
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }
    int ans = INF;
    sort(h.begin(),h.end());
    for(int i = 0; i < N-K+1; i++) {
        ans = min(ans,h[i+K-1]-h[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3992
import collections as col
s = list(input())
t = list(input())
s_1 = col.Counter(s)
t_1 = col.Counter(t)
s_2 = sorted(s_1.values())
t_2 = sorted(t_1.values())
if s_2 == t_2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6960
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int n;
	while(cin>>n,n){
		int data[20][20];
		rep(i,20)rep(j,20)data[i][j]=0;
		for(int i =0;i < n;i++){
			for(int j =0;j < n;j++){
				cin>>data[i][j];
			}
		}
		int sum = 0;
		for(int i =0;i<n;i++){
			for(int j =0;j < n;j++){
				data[i][n]+=data[i][j];
				sum +=data[i][j];
			}
		}
		for(int j =0;j < n;j++){
			for(int i =0;i <n;i++){
				data[n][j]+=data[i][j];
			}
		}
		data[n][n]=sum;
		for(int i =0;i <=n;i++){
			for(int j =0;j <=n;j++){
				printf("%5d",data[i][j]);
			}
			cout <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstring>

int main(){
	char num[1001];
	int sum;
	int num_size;
	while(true){
		sum = 0;

		std::cin >> num;
		if(strcmp(num, "0")==0) break;

		num_size = strlen(num);
		for(int i=0; i<num_size; i++){
			sum += num[i] - '0';
		}
		std::cout << sum << std::endl;
	}
}

Measured memory_bytes: 3076
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>
#include <atcoder/all>


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

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


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



















int main(){
    ll t;
    cin >> t;
    REP(i, t){
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  vector<ll> data;
  cin >> n;
  vector<ll> sum_data(n + 1);
  REP(i, n) {
    ll x;
    cin >> x;
    data.push_back(x);
  }
  sort(ALL(data));
  REP(i, n) {
    if (i == 0) {
      sum_data[0] = data[0];
    } else {
      sum_data[i] = sum_data[i - 1] + data[i];
    }
  }

  int t = 0;
  for (int i = n - 1; i > 0; i--) {
    if (data[i] > 2 * sum_data[i - 1]) {
      t = i;
      break;
    }
  }

  cout << n - t << endl;
}

Measured memory_bytes: 2168
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

ll N;
ll sum = 0;

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3512
n,k=gets.split.map(&:to_i)
hs = readlines.map(&:to_i)

hs.sort!

ret = 1_000_000_000
0.upto(n-k) do |i|
  t = hs[i+k-1] - hs[i]
  if t < ret
    ret = t
  end
end

p ret

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

int main(){
  int N,K,p,count=0;
  cin >> N >> K;
  
  p=K;
  count++;
  while(N>=p){
    p*=K;
    count++;
  }
  
  cout << count << endl;
  return 0;
}


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

int H,W;
vector<vector<char>>field;
vector<int>dxy={-1,0,0,1,0,-1};
void paint(int _i, int _j) {
	bool flg=true;
	for(int i=0, n=dxy.size()-1; i<n;++i){
		int t_x_1=_j+dxy[i],t_y_1=_i+dxy[i+1];
		if((t_x_1<0||t_x_1>=W)||(t_y_1<0||t_y_1>=H))continue;

		for(int j=i+1, m=dxy.size()-1; j<m; ++j) {
			int t_x_2=_j+dxy[j],t_y_2=_i+dxy[j+1];
			if((t_x_2<0||t_x_2>=W)||(t_y_2<0||t_y_2>=H))continue;

			if(field[t_y_1][t_x_1]=='#'&&(field[t_y_2][t_x_2]=='#'||field[t_y_2][t_x_2]=='b')||
				field[t_y_2][t_x_2]=='#'&&(field[t_y_1][t_x_1]=='#'||field[t_y_1][t_x_1]=='b')){
				field[t_y_1][t_x_1]='b';
				field[t_y_2][t_x_2]='b';
				flg=false;
				break;
			}
		}
		if(flg==false)break;
	}
}
void print() {
	for(auto s:field) {
		for(auto c:s)cout<<c;
		cout<<endl;
	}
}
int main() {
	cin>>H>>W;
	field=vector<vector<char>>(H, vector<char>(W));

	for(int i=0; i<H; ++i)
		for(int j=0; j<W; ++j)
			cin>>field[i][j];

	for(int i=0; i<H; ++i)
	for(int j=0; j<W; ++j) {
		if(field[i][j]=='#')
			paint(i, j);
	}
	
	bool flg=true;
	for(int i=0; i<H; ++i)
	for(int j=0; j<W; ++j)
		if(field[i][j]=='#')
			flg=false;

	if(flg)cout<<"Yes";
	else cout<<"No";
	cout<<endl;

	return 0;
}


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

int main() {
    int k;
    cin >> k;
    vector<int> a(k);
    rep(i, k) cin >> a[i];
    reverse(a.begin(), a.end());

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

Measured memory_bytes: 640
n, m = gets.split.map(&:to_i)
cond = m.times.map {
  k, *ss = gets.split.map(&:to_i)
  ss.inject(0) {|acc, s| acc | (1 << (s - 1))}
}
ps = gets.split.map(&:to_i)

puts (2 ** n).times.map {|switches|
  cond.zip(ps).map {|c, p| (switches & c).to_s(2).count("1") % 2 == p}.all?
}.count(true)

Measured memory_bytes: 3836
#import pysnooper
import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
#input=stdin.readline


t=stdin.read()
abc=string.ascii_lowercase
ABC=string.ascii_uppercase
for i in range(26):
    n=t.count(abc[i])+t.count(ABC[i])
    print(abc[i],":",n)


Measured memory_bytes: 6724
#include<stdio.h>

#define NUMBER 100


void print_array(int array[],int num)
{
	int i;
	
	for(i = 0; i < num - 1; i++){
		
		printf("%d ", array[i]);
	}
	printf("%d\n", array[i]);
	
}
	
void insertSort(int array[],int num)
{
	int i, v, j;
	for(i = 1; i <= num - 1; i++){
		print_array(array, num);
		v = array[i];
		j = i - 1;
		while(j >= 0 && array[j] > v){
			array[j + 1] = array[j];
			j--;
			
		}
		array[j + 1] = v;
	
    }
}

int main(void)
{
	int i, num;
	int array[NUMBER];

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


Measured memory_bytes: 2756
n, *a = map(int, open(0).read().split())
if sum(a) % n == 0:
    avg = sum(a)//n
    ans = 0
    for e in a:
        ans += (e - avg)**2
    print(ans)
else:
    avg = sum(a)//n + 1
    avg2 = sum(a)//n - 1
    avg3 = sum(a)//n
    ans2 = 0
    ans = 0
    ans3 = 0
    for e in a:
        ans += (e - avg) ** 2
        ans2 += (e-avg2) ** 2
        ans3 += (e-avg3) ** 2
    print(min(ans, ans2, ans3))

Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
  int main()
  {
    int n;
    cin>>n;
    int r;
    int f=0;
    while(n)
    {
      
      r=n%10;
      if(r==7) { f=1; return cout<<"Yes\n",0;}
      n/=10;
    }
    if(!f) cout<<"No\n";
  }

Measured memory_bytes: 3628
#include <stdio.h>
int main(){
	int N,A,B;
	scanf("%d %d %d",&N,&A,&B);
	int Ptrain=A*N;
	if(Ptrain<=B){
		printf("%d",Ptrain);
    }else{
		printf("%d",B);
    }
	return 0;
}

Measured memory_bytes: 128
n = int(input())
h = list(map(int,input().split()))

dp = [0] * (n)
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),
                dp[i-2] + abs(h[i]-h[i-2]))

print(dp[n-1])


Measured memory_bytes: 13980
s = list(input())

k = int(input())

n = len(s)

if(len(set(s)) == 1):
    print(n*k//2)
else:
    t = 0
    c = 1
    for i in range(n-1):
        if(s[i] == s[i+1]):
            c += 1
        else:
            t += c // 2
            c = 1
    t += c // 2
    if(s[0] != s[-1]):
        print(t*k)
    else:
        a = 0
        b = 0
        for i in range(n):
            if(s[i] == s[0]):a+=1
            else:break
        for i in range(n)[::-1]:
            if(s[i] == s[-1]):b+=1
            else:break
        print(t*k - (a//2 + b//2 - (a+b)//2) * (k-1))

Measured memory_bytes: 3064
package main

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

func main() {
	nextReader = newScanner()
	_, m := nextInt(), nextInt()

	ma := make(map[int]bool, 0)
	mw := make(map[int]int, 0)
	wa := 0
	for i := 0; i < m; i++ {
		p := nextInt()
		s := nextString()

		if s == "AC" && !ma[p] {
			ma[p] = true
			wa += mw[p]
		}
		if s == "WA" && !ma[p] {
			mw[p]++
		}
	}
	fmt.Printf("%d %d\n", len(ma), wa)
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 6912
#include<iostream>

#define int long long

using namespace std;

int abs(int a,int b){
  if(a>b){
    return a-b;
  }
  return b-a;
}

int calcMinCost(int dp[],int n){
    int arr[n+1];
    arr[0] = 0;
    arr[1] = abs(dp[1],dp[0]);
    for(int i=2;i<n;i++)
      arr[i] = min(arr[i-1]+abs(dp[i],dp[i-1]),arr[i-2]+abs(dp[i],dp[i-2]));
    return arr[n-1];
}

int32_t main(int argc, char const *argv[]) {
  /* code */
  int n;
  cin >> n;
  int dp[n];
  for(int i = 0;i < n;i++){
    cin >> dp[i];
  }
  cout<<calcMinCost(dp,n)<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define pb push_back
#define pr pair<int,int>
using namespace std;
using ll = long long;
// using mod = 1000000000 + 7;
void self_max(int &a,int b){
	a = max(a,b);
}

void self_min(int &a,int b){
	a = min(a,b);
}
int main(){
	int n; cin >> n;
	vector<int> A(n);
	// vector<int> B(n);
	ll total = 0;
	rep(i,n){
		cin >> A[i];
		total = total xor A[i];
	}


	rep(i,n){
		int k = total xor A[i];
		cout << k << " " << endl;
	}




	return 0;
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int r, x_2000, D;
    cin >> r >> D >> x_2000;
  
  	int outPut = x_2000;
  	
  	for(int i = 0; i < 10; i++){
    	outPut = r * outPut - D;
        cout << outPut << endl;
    }
}

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

using namespace std;
typedef long long ll;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){
	vector<ll> div;
	for(int i=1;i*i<=x;i++){
		if(i*i!=x && x%i==0){
			div.pb(i);
			div.pb(x/i);
		}
		else if(x%i==0) div.pb(i);
	}
	return div;
}
vector<ll> vectorprime(ll x){
	vector<bool> is_prime(x+1);
	vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){
		if(is_prime[i]){
			prime.pb(i);
		}
		for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
	}
	return prime;
}

//a,b x
int main(){
	string s; cin>>s;
	ll cnt=0;
	rep(i,4){
		if(s[i]=='2') cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 256
count = int(input());
data = [];
for i in range(count):
    data.append(int(input()));

def max_profit(data):
    profit = -10 ** 18;
    prev = 10 ** 18;
    for n in data:
        profit = max(profit, n - prev);
        prev = min(prev, n);
    return profit;

print(max_profit(data));


Measured memory_bytes: 13592
N = int(input())
A = list(map(int,input().split()))
B = [0]
tmp = 0
for a in A:
    tmp += a
    B.append(tmp)

l = 1
r = 3
cut = []
for i in range(2,N-1):
    Lm = float("inf")
    Rm = float("inf")
    c = [0,i,0]
    for j in range(l,i):
        tmp = abs(B[i]-2*B[j])
        if tmp > Lm:
            c[0] = j-1
            l = j-1
            break
        Lm = tmp
    else:
        c[0] = i-1
        l = i-1
    for k in range(r,N):
        tmp = abs((B[N]-B[k])-(B[k]-B[i]))
        if tmp > Rm:
            c[2] = k-1
            r = k-1
            break
        Rm = tmp
    else:
        c[2] = N-1
        r = N
    cut.append(c)
#print(cut)
ans = float("inf")
for p,q,r in cut:
    P = B[p]
    Q = B[q]-B[p]
    R = B[r]-B[q]
    S = B[N]-B[r]
    ans = min(ans,max(P,Q,R,S)-min(P,Q,R,S))
print(ans)


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &i : a) {
        cin >> i;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 == 0 || a[i] % 5 == 0) {
                continue;
            } else {
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    vi64 v(3);
    bool ev = false;
    forn(i, 3) cin >> v[i], ev |= v[i] % 2 == 0;
    sort(all(v));
    cout << (ev ? 0LL : v[0] * v[1]) << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int []A = new int[N];
	for(int i=0;i<N;i++){
		A[i] = sc.nextInt();
	}
	for(int i=0;i<N-1;i++) {
		for(int j=0;j<N-1-i;j++) {
			if(A[j]<A[j+1]) {
			int temp= A[j];
			A[j]=A[j+1];
			A[j+1]=temp;	
		}
	}
	}
    int max = A[0];
    int sum =0;
    for(int i=1;i<N;i++) {
    	sum+=A[i];
    }
    if(max>=sum){
    	System.out.println("No");
    }
    else if(max<sum){
    	System.out.println("Yes");
    }
    
}
	}


Measured memory_bytes: 22740
import numpy as np
N,K = map(int,input().split())
S = input()
stands = []
temp = ''
first_handstand = False
for i,s in enumerate(S):
    if i == 0:
        temp += s
        continue
    if temp[-1] == s:
        temp += s
    else:
        stands.append(len(temp))
        temp = s
stands.append(len(temp)) # 最後の連続列
if S[0] == '0':
    stands.insert(0,0)
if S[-1] == '0':
    stands.append(0)
cumsum_stands = np.cumsum(np.array(stands))
cumsum_stands = np.insert(cumsum_stands,0,0)

ans = 0

for l in range(0,len(cumsum_stands),2):
    r = min(l + 2*K+1,len(cumsum_stands)-1)
    ans = max(ans, cumsum_stands[r] - cumsum_stands[l])
print(ans)

Measured memory_bytes: 15640
#include <bits/stdc++.h>
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
ll  a[51],b[1001];
int main(){
	sonic;
	ll n;
	cin>>n;
	double cnt=double(n-(n/2))/n;	
	cout<<fixed<<setprecision(10)<<cnt;
}

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

int main(void){

    long long N,H,W;
    cin >> N >> H >> W;
    
    long long A,B;
    int ans = 0;
    for(int i = 0; i < N ; i++){
        cin >> A >> B;
        if(A >= H && B >= W)ans++;
    }
    cout << ans << endl;
        
}

Measured memory_bytes: 256
#include<iostream>
 
int main(){
  int people[4][3][10];
  int n;
  int b, f, r, v;
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 10; k++){
    people[i][j][k] = 0;
      }
    }
  }
 
  std::cin >> n;
 
  for(int i = 0; i < n; i++){
    std::cin >> b >> f >> r >> v;
    people[b -1 ][f -1][r - 1] += v;
  }
 
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 10; k++){
    std::cout << ' ' << people[i][j][k];
      }
      std::cout << std::endl;
    }
    if(i != 3) std::cout << "####################" << std::endl;
  }
 
 
  return 0;
}


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

typedef long long ll;

using namespace std;

void solve(int A, int B, int H, int M) {
    
    double hour = (30*H)+(double)M/2;
    double min = 6*M;
    
    double angle = abs(hour-min);
    angle*=(double)M_PI/180;
    
    cout << setprecision(20) << sqrt(A*A+B*B-(2*A*B)*cos(angle)) << "\n";
}

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int A,B,H,M;
    cin>>A>>B>>H>>M;
    
    solve(A,B,H,M);
    
    //4.56425719433005567605

}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; string s; cin >> n >> s;
	int ans = 0;
	int l = 0, r = n - 1;
	while (l < r) {
		while (l < r and s[l] == 'R') ++l;
		while (r > l and s[r] == 'W') --r;
		if (l < r) swap(s[l], s[r]), ++ans;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

void dfs(int v, vvi &G, vector<bool> &seen){
  if(seen[v]) return;
  seen[v] = true;
  for(auto nv : G[v]) {
    dfs(nv, G, seen);
  }
}

int main(){
  int n,m,p; cin >> n >> m >> p;
  vvi G(n),rG(n);
  vector<tuple<int, int, int>> edges;
  rep(i,m) {
    int a,b,c; cin >> a >> b >> c;
    a--; b--;
    c -= p;
    c = -c;
    edges.emplace_back(a,b,c);
    G[a].pb(b);
    rG[b].pb(a);
  }

  vector<bool> seen1(n,false);
  vector<bool> seen2(n,false);

  dfs(0, G, seen1);
  dfs(n-1, rG, seen2);

  vector<bool> ok(n);
  rep(i,n) ok[i] = seen1[i]&seen2[i];

  vi d(n,1e9);
  d[0] = 0;
  int step = 0;
  for(bool upd = true; upd; step++) {
    upd = false;
    rep(i,m) {
      int a,b,c;
      tie(a,b,c) = edges[i];
      if(!ok[a] || !ok[b]) continue;
      if(chmin(d[b], d[a] + c)) upd = true;
    }
    //step++;
    if(step > n){
      cout << -1 << endl;
      return 0;
    }
  }
    
  int ans = -d[n-1];
  ans = max(ans,0);
  cout << ans << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

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

  int a, b, c;
  ll k;
  cin >> a >> b >> c;
  cin >> k;

  int ans;
  if(k % 2 == 0) ans = a - b;
  else ans = b - a;

  cout << ans << endl;

  return 0;
}


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

int main() {

  int N, tmp;

  cin >> N;

  int first = N % 10;
  tmp = N / 10;

  int second = tmp % 10;
  tmp = tmp / 10;

  int third = tmp % 10;
  tmp = tmp / 10;


  int fourth = tmp;

  if ( (first == second && second == third) || (second == third && third == fourth) ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
/*  ex4_2
    Rikuta  */

#include <stdio.h>
#include <math.h>

#define PI 3.141592653589

int main(void){

    int hour_hand_length,min_hand_length,num_hour,num_min;

    //入力受け取り
    scanf("%d %d %d %d",&hour_hand_length,&min_hand_length,&num_hour,&num_min);

    //何時何分を分になおす
    int sum_mins=60*num_hour+num_min;

    //時針と分針の0:00からの弧度
    double hour_hand_radian=(double)sum_mins/360*PI;
    double min_hand_radian=(double)num_min/30*PI;

    //時針と分針の間の弧度
    double dif_radian=hour_hand_radian-min_hand_radian;

    //余弦定理をつかった答えの計算
    double ans=sqrt(pow((double)hour_hand_length,2)+pow((double)min_hand_length,2)-2*hour_hand_length*min_hand_length*cos(dif_radian));

    //答えの出力
    printf("%.9lf\n",ans);

    return 0;
}

Measured memory_bytes: 2584
#include<iostream>

using namespace std;

int main(){
  int x,y;
  while (x!=0||y!=0){
    cin >> x >> y;
    if(x==0&&y==0){}
    else if(x<y){
      cout << x << " " << y << endl;
    }else if(y<=x){
      cout << y << " " << x << endl;
    }
  }return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	 
	for(int i=1;i<=k;i++)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
n, m = gets.chomp.split(' ').map(&:to_i)
item = []
n.times do
  item << gets.chomp.split(' ').map(&:to_i)
end
item.sort!{ |a, b| a[0] <=> b[0] }
money = 0
item.each do |val|
  price, num = val
  if num <= m
    money += num * price
    m -= num
  else
    money += price * m
    break
  end
end
p money

Measured memory_bytes: 11512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)


typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


/*************************************************************************/
//多次元配列の確保及び初期化用マクロ
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}
/*************************************************************************/



const ll INF = 1e9 + 7;

#define ARRAY_MAX 100005



void warshall_floyd(int v, vector<vector<ll> >& d) {
	/*頂点の個数、コスト:d[u][v]はe=(u,v)のコスト(存在しない場合はINF,ただしd[i][j]=0とする)*/

	for (int k = 0; k < v; k++) {
		for (int i = 0; i < v; i++) {
			for (int j = 0; j < v; j++) {
				if (d[i][k] == INF || d[k][j] == INF)
				{
					continue;
				}
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				//kを通る経路と通らない経路の最小値をとる
			}
		}
	}
}




int main() {

	ll n, m;
	cin >> n >> m;

	auto mp = make_v<ll>(n + 10, n + 10);
	auto dp = make_v<ll>(n + 10, n + 10);
	fill_v(mp, INF);
	fill_v(dp, INF);

	for (int i = 0; i < n; i++)
	{
		mp[i][i] = dp[i][i] = 0;
	}
	   
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		mp[a][b] = mp[b][a] = c;
		dp[a][b] = dp[b][a] = c;
	}

	int pass_siz = 0;

	warshall_floyd(n, dp);

	for (int i = 0; i < n; i++)
	{
		for (int j = i+1; j < n; j++)
		{
			if (mp[i][j] == INF)
			{
				continue;
			}
			if (dp[i][j] != mp[i][j])
			{
				pass_siz++;
			}
		}
	}

	cout << pass_siz << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;

int main() {
	int a, b;
	cin >> a >> b;
	int ans = 0, now = 1;
	if (b == 1) {
		cout << 0 << endl;
		return 0;
	}
	rep(i, INF) {
		ans++;
		now += a - 1;
		if (now >= b) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>

#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()

typedef long long ll;

using namespace std;
class UnionFind
//UnionFind(n）だと0-indexedにしないとだめ
{
public:
  UnionFind(int n)
  {
    parent=vector<int>(n,-1);//親なら-size
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    return parent[a]=root(parent[a]);
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int A=root(a);
    int B=root(b);
    if(A==B)return false;
    if(size(A)>size(B))swap(A,B);
    parent[B]+=parent[A];
    parent[A]=B;
    return true;
  }
private:
  vector<int> parent;

};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n,m;
  cin>>n>>m;
  vector<pair<int,int> > edge(m);
  rep(i,m)
  {
    int a,b;
    cin>>a>>b;
    edge[i]=make_pair(a,b);
  }
  UnionFind uni(n+1) ;
  vector<ll> ans(m);
  ans[m-1]=(ll)n*(n-1)/2;
  for(int i=m-2;i>=0;i--)
  {
    ans[i]=ans[i+1];
    ll da=(ll)uni.size(edge[i+1].first)*uni.size(edge[i+1].second);
    if(uni.connect(edge[i+1].first,edge[i+1].second))
    ans[i]-=da;

  }
  rep(i,m)cout<<ans[i]<<'\n';
  return 0;

}


Measured memory_bytes: 3328