akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

const int MOD = 1000000007;
const int INF = 1000000007;
const int N = 200002;
const int logN = 20;

string s;

int main() {
  cin >> s;
  cout << ((s.size() >= 4 && s.substr(0,4) == "YAKI") ? "Yes\n" : "No\n"); 
  return 0;
}

//1 3 3 4 4 6 100 200


Measured memory_bytes: 384
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    ans=0
    for i in range(1, n+1):
        for j in range(1, i):
            for k in range(1, j):
                if i+j+k == x:
                    ans += 1
    print(ans)


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

int main(){

  int x;
  cin>>x;
  int h = x / 3600;
  int m = (x / 60)%60;
  int s=x%60;
  cout<<h<<":"<<m<<":"<< s<<endl;
  return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll A,B;
    cin>>A>>B;
    cout<<(A*B-A-B+1);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
//ALLAH is one
int main()
{
    ll n,i,j,cnt=1;
   string s;
   char ch;
   s.clear();
   cin>>n>>s;
   for(i=0;i<n-1;i++)
   {
    if(s[i]!=s[i+1])
        cnt++;
   }
cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3748
n = int(input())
alist = list(map(int, input().split()))

last = alist[0]
count = 1
status = 0  # 0-start, 1-asc, 2-desc
for a in alist[1:]:
    if (status == 1 and last > a) or (status == 2 and last < a):
        count += 1
        status = 0
    elif status == 0 and last > a:
        status = 2
    elif status == 0 and last < a:
        status = 1
    last = a
print(count)


Measured memory_bytes: 62704
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int n, m, q;
vector<P> dist(100010);
vector<vector<P>> G(100010);

void dijkstra(int s){
    for(int i=0; i<n; i++) dist[i] = P(1e9, 1e9);

    priority_queue<T, vector<T>, greater<T>> que;
    dist[s] = P(0, q);
    que.push(T(0, s, q));

    while(!que.empty()){
        int ccost, cv, cyear;
        tie(ccost, cv, cyear) = que.top();
        //cout << ccost << " " << cv << " " << cyear << endl;
        que.pop();

        if(ccost == dist[cv].fs){
            if(dist[cv].sc > cyear) continue;
        }

        if(dist[cv].fs < ccost) continue;

        for(auto x : G[cv]){
            int nv, nyear;
            tie(nv, nyear) = x;

            int nnyear = min(nyear, cyear);
            int ncost = ccost + 1;

            //cout << nv << " " << nyear << " " << nnyear << " " << ncost << endl;

            if(ncost == dist[nv].fs){
                if(dist[nv].sc < nnyear){
                    dist[nv] = P(ncost, nnyear);
                    que.push(T(dist[nv].fs, nv, nnyear));
                }
            }
            else if(ncost < dist[nv].fs){
                dist[nv] = P(ncost, nnyear);
                que.push(T(dist[nv].fs, nv, nnyear));
            }
        }
    }
}

int main(){
    cin>>n>>m>>q;
    vector<int> u(m), v(m);
    for(int i=0; i<m; i++){
        cin>>u[i]>>v[i];
        u[i]--, v[i]--;
    }

    vector<int> changeYear(m, q);
    for(int i=0; i<q; i++){
        int r; cin>>r;
        r--;
        changeYear[r] = i;
    }

    for(int i=0; i<m; i++){
        G[u[i]].eb(P(v[i], changeYear[i]));
        G[v[i]].eb(P(u[i], changeYear[i]));
    }

    dijkstra(0);

    /*
    for(int i=0; i<n; i++){
        cout << dist[i].fs << " " << dist[i].sc << endl;
    }
    */

    vector<int> cnt(q+1);
    for(int i=0; i<n; i++){
        cnt[dist[i].sc]++;
    }

    for(int i=0; i<q; i++){
        if(0 < i) cnt[i] += cnt[i-1];
        cout << cnt[i] << endl;
    }
}


Measured memory_bytes: 15512
//

//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    string S, T;
    cin >> S >> T;
    //
    ll mn = 100000000000;
    rep(i, S.size() - T.size() + 1)
    {
        ll cnt = 0;
        rep(j,T.size())
        {
            cnt += S[i+j] == T[j] ? 1 : 0;
        }
        chmin(mn, ll(T.size() - cnt));
    }
    cout << mn;
    //
    return 0;
}

Measured memory_bytes: 3160
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include<bitset>

#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it,o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;


ll solve(vector<ll> &A, vector<ll> &B, ll K, ll border){
    ll mask = (1LL << border);
    ll avalable_bits = K;
    if((K & mask) !=0){
        avalable_bits |= (mask-1LL);
        avalable_bits ^= mask;
    }

    ll ans = 0;
    for(int i = 0; i< A.size(); i++){
        if((A[i]|avalable_bits) == avalable_bits){
            ans += B[i];
        }
    }
    return ans;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), B(N);
    rep(i, N){
        cin >> A[i] >> B[i];
    }
    ll ans = 0;
    rep(i, 40){
        ans = max(ans, solve(A, B, K, i));
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
const ll hell=5*pow(10,6);
ll h,w,k,ax,ay,bx,by,cur=0;
vector<vector<ll>> g(hell);
ll x[hell],y[hell],rem[hell],dir[hell],dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
void func(ll x0,ll y0,ll d,ll r,ll val){
	x[cur]=x0,y[cur]=y0,dir[cur]=d,rem[cur]=r;
	g[val].push_back(cur);
	cur++;
}
void solve(){
	cin>>h>>w>>k>>ax>>ay>>bx>>by;
	ax--,bx--,ay--,by--;
	vector<string> v(h);
	for(ll i=0;i<h;i++)
	cin>>v[i];
	ll i,vis[h][w][4];
	for(i=0;i<h;i++)
	for(ll j=0;j<w;j++)
	for(ll k0=0;k0<4;k0++)
	vis[i][j][k0]=0;
	for(i=0;i<4;i++)
	func(ax,ay,i,k,1);
	i=1;
	while(i<hell){
		for(ll j=0;j<ll(g[i].size());j++){
			ll ind=g[i][j];
			ll x0=x[ind],y0=y[ind],d=dir[ind],r=rem[ind];
			if(x0==bx&&y0==by){
				cout<<i;
				exit(0);
			}
			if(vis[x0][y0][d])
			continue;
			//cout<<i<<" "<<x0<<" "<<y0<<" "<<d<<" "<<r<<endl;
			vis[x0][y0][d]=1;
			for(ll k0=0;k0<4;k0++)
			if(x0+dx[k0]>=0&&x0+dx[k0]<h&&y0+dy[k0]>=0&&y0+dy[k0]<w){
				if(vis[x0+dx[k0]][y0+dy[k0]][k0])
				continue;
				if(v[x0+dx[k0]][y0+dy[k0]]=='@')
				continue;
				if(k0==d&&r){
					func(x0+dx[k0],y0+dy[k0],d,r-1,i);
					continue;
				}
				func(x0+dx[k0],y0+dy[k0],k0,k-1,i+1);
			}
		}
		i++;
	}
	cout<<"-1";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 192776
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<vector>

using namespace std;

int main(){
    //input ひな形
    int N = 0;
    cin >> N;
    int* arr = (int*)malloc(sizeof(int)*N);
    for(int i = 0; i < N; i++){
        cin >> arr[i];
    }
    int k = 1;
    for(int i = 0; i < N; i++){
        if(arr[i] == k){
            k++;
        }
    }
    if(k == 1){
        cout << -1;
    }
    else cout << N - k +1;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
template<typename T>inline void read(T &x)
{
	T s=0,f=1;char k=getchar();
	while(!isdigit(k)&&(k^'-'))k=getchar();
	if(!isdigit(k)){f=-1;k=getchar();}
	while(isdigit(k)){s=s*10+(k^48);k=getchar();}
	x=s*f;
}
/*void init()
{
}
void solve()
{
}*/
const int MAXN=100;
int n,a[MAXN];
bool chk(int x)
{
	int last=a[1],in=0;
	Rep(i,2,n)
	{
		if(a[i]-last>=x)
		{
			last=a[i];
			continue;
		}
		if(a[i]-in<x)return false;
		in=a[i];
	}
	if(24-last-in<x)return false;
	return true;
}
int main()
{
	read(n);
	Rep(i,1,n)read(a[i]);
	sort(a+1,a+n+1);
	if(a[1]==0||n>=24)
	{
		printf("0\n");
		return 0;
	}
	if(n==1)
	{
		printf("%d\n",a[1]);
		return 0;
	}
	int l=1,r=a[1],mid=(l+r)>>1;
	while(l<=r)
	{
		if(chk(mid))l=mid+1;
		else r=mid-1;
		mid=(l+r)>>1;
	}
	printf("%d\n",r);
	//init();
	//solve();
	return 0;
}




Measured memory_bytes: 256
#https://qiita.com/k_karen/items/653ba7025a92f5ac1363
#https://atcoder.jp/contests/abc145/submissions/8802665

MOD = 10 ** 9 + 7
r1, c1, r2, c2 = gets.split.map(&:to_i)
r1 -= 1
c1 -= 1

def fact(a, b)
  (a..b).inject(1) { |result, item| (result * item) % MOD }
end

def comb(n, k)
  (fact(k + 1, n) * inv(fact(1, n - k) % MOD)) % MOD
end

def inv(x)
  res = 1
  beki = x
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == '1'
    beki = (beki * beki) % MOD
  end
  res
end

def g(r, c)
  comb(r + c + 2, r + 1) - 1
end

ans = 0
ans += g(r2, c2)
ans -= g(r1, c2)
ans -= g(r2, c1)
ans += g(r1, c1)
p ans % MOD

Measured memory_bytes: 1788
const lines=readlines()
state=0
input()=lines[global state+=1]
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
floatSub(s::SubString{String})=parse(Float64,s)
intLine()=map(intSub,split(input()))
function main()
    n=int(input())
    l=sort(intLine())
    println(sum(l[1:end-1])>l[end] ? "Yes" : "No")
end
main()

Measured memory_bytes: 124556
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC116_1 solver = new ABC116_1();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC116_1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int AB = in.nextInt();
            int BC = in.nextInt();
            int CA = in.nextInt();

            out.println((AB * BC) / 2);

        }

    }
}



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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int M;
    cin >> M;
    print((24-M) + 24);
}

signed main() {
    solve();
}


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)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long A, long long B, long long K)
{
    for (int i = 1; i <= K; i++)
    {
        if (i % 2 == 1)
        {
            if (A % 2 == 1)
            {
                A--;
            }
            B += A / 2;
            A /= 2;
        }
        else
        {
            if (B % 2 == 1)
            {
                B--;
            }
            A += B / 2;
            B /= 2;
        }
    }
    cout << A << " " << B << endl;
}

int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long K;
    scanf("%lld", &K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
#coding: utf-8

import itertools
from itertools import permutations

def C():
    n = int(raw_input())
    p = list(map(int, raw_input().split()))
    q = list(map(int, raw_input().split()))
    a = 1
    f_a = True
    b = 1
    f_b = True
    for sel in itertools.permutations(range(1,n+1)):
        aa = 0
        bb = 0
        if f_a:
            for i in range(0,n):
                if sel[i] == p[i]:
                    aa = aa + 1
            if aa == n:
                f_a = False
            else:
                a = a + 1
        if f_b:
            for i in range(0,n):
                if sel[i] == q[i]:
                    bb = bb + 1
            if bb == n:
                f_b = False
            else:
                b = b + 1
    print abs(a - b)

if __name__ == '__main__':
    C()

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    vector<int> cnt(n);
    rep (i, n) {
        FOR (j, i + 1, n) {
            int dist = min(j - i, min(abs(x - i) + 1 + abs(y - j), abs(x - j) + 1 + abs(y - i)));
            cnt[dist - 1]++;
        }
    }
    rep (i, n - 1) cout << cnt[i] << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;
typedef vector<ll>		VLL;
typedef vector<VLL>		VVLL;
typedef vector<VVLL>	VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int X, A, B, C;
	cin >> A >> B >> C >> X;

	int ans = 0;
	REP(i, A + 1) {
		REP(j, B + 1) {
			REP(k, C + 1) {
				int en = i * 500 + j * 100 + k * 50;
				if (en == X) {
					ans++;
				}
			}
		}
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi h(n);
    for(int i=0; i<n; i++){
        cin >> h.at(i);
    }
    vi dp(n);
    dp.at(0) = 0;
    dp.at(1) = abs(h.at(1) - h.at(0));
    for(int i=2; i<n; i++){
        int64_t oneBefore = dp.at(i-1) + abs(h.at(i) - h.at(i-1));
        int64_t twoBefore = dp.at(i-2) + abs(h.at(i) - h.at(i-2));
        dp.at(i) = min(oneBefore, twoBefore);
    }
    cout << dp.at(n-1) << endl;
}


Measured memory_bytes: 1792
N, M = map( int, input().split())
P = list( map( int, input().split()))
par = [ i for i in range(N)]
 
def find(x):
    p = par[x]
    if p == x:
        return x
    a = find(p)
    par[x] = a
    return a
 
for i in range(M):
    x, y = map( int, input().split())
    x, y = x-1, y-1
    bx, by = find(x), find(y)
    par[y] = bx
    par[by] = bx
 
ans = 0
for i in range(N):
    if find(i) == find(P[i]-1):
        ans += 1
print(ans)

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

int main(){
  string squares;
  int result = 0;
  
  cin >> squares;
  
  if(squares[0]=='1'){
    result++;
  }
  if(squares[1]=='1'){
    result++;
  }
  if(squares[2]=='1'){
    result++;
  }
  
  cout << result << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
int main() {
    int n,m;
    cin >> n >> m;
    if(n == m) dunk("Yes");
    else dunk("No");
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX=100000;
int N;
int a[NMAX+10][3];
long long dp[NMAX+10][3];

int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < 3; ++j) {
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < 3; ++j) {
      for(int k = 0; k < 3; ++k) {
        if(j == k) continue;
        chmax(dp[i+1][k], dp[i][j] + a[i][k]);
      }
    }
  }
  long long res = 0;
  for(int i = 0; i < 3; ++i) {
    res = max(res, dp[N][i]);
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3712
n, m, k = map(int, input().split())

graph = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

block = [[] for _ in range(n + 1)]

for _ in range(k):
    c, d = map(int, input().split())
    block[c].append(d)
    block[d].append(c)

def dfs(graph, start):
    visited = set([start])
    stack = []
    can_reach = set([start])
    for f in graph[start]:
        stack.append(f)
        can_reach.add(f)
    while stack:
        friend = stack.pop()
        visited.add(friend)
        candidates = graph[friend]
        for c in candidates:
            if c not in visited:
                can_reach.add(c)
                stack.append(c)
    return can_reach

labels = [None] * (n + 1)
for i in range(1, n + 1):
    if labels[i] is None:
        c = dfs(graph, i)
        for j in c:
            labels[j] = [i, len(c)]

ans = []
for i in range(1, n + 1):
    num = labels[i][1] - 1
    for j in graph[i]:
        if labels[i][0] == labels[j][0]:
            num -= 1
    for k in block[i]:
        if labels[i][0] == labels[k][0]:
            num -= 1
    ans.append(num)
print(*ans)


Measured memory_bytes: 107548
// https://atcoder.jp/contests/abc087/tasks/arc090_b
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
class edge{
    public:
    ll to;
    ll d;
    edge(ll _to = -1, ll _d = 0){
        to = _to;
        d = _d;
    }
};

vector<edge>path[101010];

int main(){
    ll N, M;
    cin >> N >> M;
    for(ll i = 0; i < M; i++){
        ll L, R, D;
        cin >> L >> R >> D;
        path[L].push_back(edge(R, D));
        path[R].push_back(edge(L, -D));
    }
    ll ans = 1;
    vector<ll>flg(N + 1, 0), pos(N + 1, 0);
    for(ll i = 1; i <= N; i++){
        if(flg[i])continue;
        flg[i] = 1;
        queue<ll>Q;
        Q.push(i);
        while(!Q.empty()){
            ll idx = Q.front();
            Q.pop();
            for(ll j = 0; j < path[idx].size(); j++){
                ll nxt = path[idx][j].to;
                ll p = pos[idx] + path[idx][j].d;
                if(flg[nxt]){
                    if(pos[nxt] != p)ans = 0;
                }
                else{
                    flg[nxt] = 1;
                    pos[nxt] = p;
                    Q.push(nxt);
                }
            }
        }
    }
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {
    
    int a, b; cin >> a >> b;
    int ans = max(a+b, 2*max(a, b)-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        if(a <= x && a+b >= x) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23252
#include<stdio.h>

long long calcgcd(long long x, long long y) {
	long long tmp;
	while (1) {
		tmp = y;
		y = x%y;
		x = tmp;
		if (y == 0) break;
	}
	return x;
}

int main() {
	long long a, b, gcd, lcm;
	while (scanf("%lld %lld", &a, &b) != EOF) {
		if (a > b) {
			gcd = calcgcd(a, b);
		}
		else {
			gcd = calcgcd(b, a);
		}
		lcm = a*b / gcd;
		printf("%lld %lld\n", gcd, lcm);
	}
	return 0;
}

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

L=[3,5,7]
f = 0
cnt = 0
while f == 0:
  for i in range(3):
    x = L[cnt] * 10 + L[i]
    if x > N:
      f = 1
      break
    else:
      L.append(L[cnt] * 10 + L[i])
  cnt += 1

ans = set(["3","5","7"])
cnt = 0
for i in L:
    s = set(str(i))
    if s == ans:
        cnt += 1
print(cnt)

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

int main(){
    int N,M; cin >> N >> M;
    vector<vector<int>> s(M);
    for(int i = 0; i< M; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int a; cin >> a; a--;
            s[i].push_back(a);
        }
    }
    vector<int> p(M);
    for(int i = 0; i < M; i++) cin >> p[i];
    
    long long res = 0;
    for(int bit = 0; bit < (1<<N); ++bit){
        bool ok = true;
        for(int i = 0; i < M; i++){
            int con = 0;
            for(auto v:s[i]){
                if(bit & (1<<v)) ++con;
            }
            if(con % 2 != p[i]) ok = false;
        }
        if(ok)++res;
    }
    cout << res << endl;
    
}

Measured memory_bytes: 3612
N, K = map(int, input().split())
MOD = 10**9 + 7

if N < K:
    print(0)
else:
    p = q = 1
    for i in range(N-K):
        p = p * (N-1-i) % MOD
        q = q * (i+1) % MOD

    print(p * pow(q, MOD-2, MOD) % MOD)



Measured memory_bytes: 5596
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
#define INF 10000000000000ll
using namespace std;
namespace IO{
	const int BS=(1<<20); char Buffer[BS],*HD,*TL;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	int read(){
		int nm=0,fh=1; char cw=Getchar();
		for(;!isdigit(cw);cw=Getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=Getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
int n,m,A,B,G[M]; LL p[M<<2][2],tg[M<<2],ans=INF;
void pushup(int x){
	p[x][0]=min(p[x<<1][0],p[x<<1|1][0]);
	p[x][1]=min(p[x<<1][1],p[x<<1|1][1]);
}
void pushdown(int x){
	if(!tg[x]) return;
	p[x<<1][0]+=tg[x],p[x<<1|1][0]+=tg[x];
	p[x<<1][1]+=tg[x],p[x<<1|1][1]+=tg[x];
	tg[x<<1]+=tg[x],tg[x<<1|1]+=tg[x],tg[x]=0; 
}
void build(int x,int l,int r){
	if(l==r){
		if(l==A) p[x][0]=-l,p[x][1]=l;
		else p[x][0]=p[x][1]=INF; return;
	}
	int mid=((l+r)>>1); build(x<<1,l,mid);
	build(x<<1|1,mid+1,r),pushup(x);
}
LL qry(int x,int l,int r,int L,int R,int kd){
	if(r<L||R<l) return INF; if(L<=l&&r<=R) return p[x][kd]; pushdown(x);
	int mid=((l+r)>>1); return min(qry(x<<1,l,mid,L,R,kd),qry(x<<1|1,mid+1,r,L,R,kd));
}
void mdf(int x,int l,int r,int pos,LL dt){
	if(l==r){p[x][0]=min(p[x][0],dt-l),p[x][1]=min(p[x][1],dt+l);return;}
	int mid=((l+r)>>1); pushdown(x);
	if(pos<=mid) mdf(x<<1,l,mid,pos,dt);
	else mdf(x<<1|1,mid+1,r,pos,dt); pushup(x);
}
void dfs(int x,int l,int r){
	if(l==r){ans=min(ans,p[x][0]+(LL)l);return;}int mid=((l+r)>>1);
	pushdown(x),dfs(x<<1,l,mid),dfs(x<<1|1,mid+1,r);
}
int main(){
	n=read(),m=read(),A=read(),B=read(),G[0]=B,build(1,1,n);
	for(int i=1;i<=m;i++){
		G[i]=read(); LL t1=G[i]+qry(1,1,n,1,G[i],0);
		LL t2=qry(1,1,n,G[i],n,1)-G[i],dt=abs(G[i]-G[i-1]);
		tg[1]+=dt,p[1][0]+=dt,p[1][1]+=dt,mdf(1,1,n,G[i-1],min(t1,t2));
	} dfs(1,1,n),printf("%lld\n",ans); return 0;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin >> n;
    map<ll, ll> m;
    int x;
    for (int i = 1; i <= 100; i++)
    {
        for (int j = 1; j <= 100; j++)
        {
            for (int k = 1; k <= 100; k++)
            {
                x = i * i + j * j + k * k + i * j + j * k + k * i;
                m[x]++;
            }
        }
    }
    for (int i = 1; i <= n; i++)
        cout << m[i] << endl;
    return 0;
}

Measured memory_bytes: 6064
#include <stdio.h>

int main(void)
{
    int n;
    int buf;
    int a;
    long long int ans=0;

    scanf("%d",&n);
    scanf("%d",&buf);
    for (int i=1; i<n; i++){
        scanf("%d",&a);
        if (a<buf){
            ans+=buf-a;
        } else {
            buf=a;
        }
    }
    printf("%lld\n",ans);
    return 0;
}   

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    stack<char> stk;
    for (int i = 0; i < n; i++) {
        if (s[i] == '1') {
            if (!stk.empty() && stk.top() == '0') {
                stk.pop();
            } else {
                stk.push('1');
            }
        } else {
            if (!stk.empty() && stk.top() == '1') {
                stk.pop();
            } else {
                stk.push('0');
            }
        }
    }
    cout << n - stk.size() << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<26)
#define MAX_N 305
#define MAX_E 1005
int N,E,T;
int W[MAX_N];
int dp[MAX_N];

vector<int> S[MAX_E];
int G[MAX_E];

void init(){
  for(int i=0;i<MAX_E;i++)S[i].clear();
}

int solve(){
  for(int i=0;i<N;i++){
    if(W[i]==1)dp[i]=1;
    else dp[i]=INF;
  }
  vector<int> vec;

  bool update=true;
  while(update){
    update=false;
    for(int i=0;i<E;i++){

      vec.clear();
      for(int j=0;j<(int)S[i].size();j++){
	int x=S[i][j];
	vec.push_back(dp[x]);
      }
      sort(vec.begin(),vec.end());
      reverse(vec.begin(),vec.end());

      int cost=vec[0];
      for(int j=1;j<(int)vec.size();j++){
	cost=max(cost,vec[j]+j);
      }

      if(dp[G[i]]>cost){
	dp[G[i]]=cost;
	update=true;
      }
      
    }//i
  }//while

  if(dp[T]==INF)return -1;
  else return dp[T];
}

int main(){
  while(cin>>N>>E>>T){
    T--;
    init();
    for(int i=0;i<N;i++)cin>>W[i];
    for(int i=0;i<E;i++){
      int c;
      cin>>G[i]>>c;
      G[i]--;
      S[i].resize(c);
      for(int j=0;j<c;j++){
	cin>>S[i][j];
	S[i][j]--;
      }
    }
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    ll n,a,b;
    cin >> n >> a >> b;

    ll ans = (n/(a+b))*a;

    if (n%(a+b) < a) ans += n%(a+b);
    else ans += a;

    cout << ans << endl;

}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	
	if(a % 2 === 0 || b % 2 === 0) {
	    console.log('Even');
	} else {
	    console.log('Odd');
	}
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, a[300008], cnt[3];
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> s;
	zep(i, 0, 3*n){
		if(s[i] == 'R'){a[i] = 0;}
		if(s[i] == 'G'){a[i] = 1;}
		if(s[i] == 'B'){a[i] = 2;}
	}
	
	ll ans = 1;
	memset(cnt, 0, sizeof(cnt));
	zep(i, 0, 3*n){
		if(cnt[(a[i]+1)%3] > 0 && cnt[(a[i]+2)%3] > 0){
			ans *= min(cnt[(a[i]+1)%3], cnt[(a[i]+2)%3]);
			ans %= MOD;
			cnt[(a[i]+1)%3]--;
			cnt[(a[i]+2)%3]--;
		}
		else{
			if(cnt[a[i]] >= cnt[(a[i]+1)%3] && cnt[a[i]] >= cnt[(a[i]+2)%3]){
				cnt[a[i]]++;
			}
			else{
				if(cnt[(a[i]+1)%3] > cnt[a[i]]){
					ans *= cnt[(a[i]+1)%3] - cnt[a[i]];
					ans %= MOD;
				}
				else{
					if(cnt[(a[i]+2)%3] > cnt[a[i]]){
						ans *= cnt[(a[i]+2)%3] - cnt[a[i]];
						ans %= MOD;
					}
				}
				cnt[a[i]]++;
			}
		}
		//printa(cnt, 0, 2)
		//print(ans)
	}
	rrep(i, n, 1){
		ans *= i;
		ans %= MOD;
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 2964
#ABC167B_EasyLinearProgramming.rb
a,b,c,k = gets.split.map(&:to_i)
rem = k
if a >= k
  max = 1 * k
  puts max
  exit
else
  max = 1 * a 
  rem = k - a
  if b >= rem
    max += 0 * rem
    puts max
    exit
  else
    max += 0 * b
    rem -= b
    if c >= rem
    max += -1 * rem
    puts max
    exit
    else
      max += -1 * c
    end
  end
end
puts max


Measured memory_bytes: 14372
N,Q = list(map(int, input().split()))
S = str(input())
lr=[]
for i in range(Q):
    lr.append(list(map(int, input().split())))


count=[0]

k = 0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        k += 1
    count.append(k)

for i,j in lr:
    print(count[j-1]-count[i-1])


Measured memory_bytes: 70872
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main(){

  int H, W, K;
  cin >> H;
  cin >> W;
  cin >> K;

  int s[H][W];
  int ichigo[H];
  int ichigo_[H]; // copy of ichigo[H]
  string temp;
  int num = 1;
  REP(i, 0, H){
    cin >> temp;
    ichigo[i] = 0;
    ichigo_[i] = 0;
    REP(j, 0, W){
      if (temp.substr(j, 1) == "#"){
        s[i][j] = num;
        num++;
        ichigo[i]++;
        ichigo_[i]++;
      }
      else
        s[i][j] = 0;
    }
  }

  // cout << "ichigo_[i]: ";
  // REP(i, 0, H){
  //   cout << ichigo_[i] << " ";
  // }
  // cout << endl;


  // REP(i, 0, H){
  //   REP(j, 0, W){
  //     cout << s[i][j];
  //   }
  //   cout << endl;
  // }

  // algorithm
  int ans[H][W];
  REP(i, 0, H){
    REP(j, 0, W){
      ans[i][j] = -1;
    }
  }

  // cout << "ichigo_[i]: ";
  // REP(i, 0, H){
  //   cout << ichigo_[i] << " ";
  // }
  // cout << endl;

  // cout << "ichigo[i]: ";
  // REP(i, 0, H){
  //   cout << ichigo[i] << " ";
  // }
  // cout << endl;

  // REP(i, 0, H){
  //   REP(j, 0, W){
  //     cout << ans[i][j];
  //   }
  //   cout << endl;
  // }

  num = 0;
  REP(i, 0, H){
    if (ichigo[i] == 0) {
      // cout << "ichigo: " << ichigo[i] << endl;
      continue;
    }
    else{
      // cout << "ichigo: " << ichigo[i] << endl;
      num++;
    }

    int ttt = ichigo[i];
    // cout << "ttt " << ttt << endl;
    REP(j, 0, W){
      if (s[i][j] == 0)
        ans[i][j] = num;
      else{
        ans[i][j] = num;
        ttt--;
        if (ttt == 0){// if no ichigo in this row
          // nanimo sinai
        }
        else { // there are ichigo in this row
          num++;
        }
      }
    }
  }


  //  copy from above or below line
  REP(i, 0, H){
    if (ichigo_[i] == 0) {
      // see above
      int tmp = i;
      while(tmp > 0){
        if (ichigo_[tmp-1] > 0){
          REP(j, 0, W)
            ans[i][j] = ans[tmp-1][j];
          break;
        }
        else
          tmp--;
      }
      // see below
      tmp = i;
      while(tmp < H-1){
        if (ichigo_[tmp+1] > 0){
          REP(j, 0, W)
            ans[i][j] = ans[tmp+1][j];
          break;
        }
        else
          tmp++;
      }
    }
  }

  REP(i, 0, H){
    REP(j, 0, W){
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }

  // REP(i, 0, H)
  //   cout << ichigo_[i] << " ";
  // cout << endl;


  return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end()))
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  string s, t; cin >> s >> t;
  vector<ll> cnts(26, 0), cntt(26, 0);
  for (char si : s) cnts[si-'a']++;
  for (char ti : t) cntt[ti-'a']++;
  vector<ll> sv(26), tv(26);
  for (int i = 0; i < 26; i++) {
    sv[i] = cnts[i];
    tv[i] = cntt[i];
  }
  sort(sv);sort(tv);
  for (int i = 0; i < 26; i++) {
    if (sv[i] != tv[i]) {
      No();
      return;
    }
  }
  Yes();
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main() {
   int a;
   string s;
   cin >> a >> s;

   if (a >= 3200) {
    cout << s << endl;
   } else {
    cout << "red" << endl;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define N 100009
 
using namespace std;
 
int lvl[N],sub[N],n,pa[N];
vector<int> l[N];

void dfs(int ver,int par){
	pa[ver]=par;
	sub[ver]=1;
	for(auto it : l[ver]){
		if(it==par){
			continue ;
		}
		lvl[it]=lvl[ver]+1;
		dfs(it,ver);
		sub[ver]+=sub[it];
	}
	return ;
}

int main(){
	int i,j,t1,t2,t3,t4,lim,curr;
	bool yay=false;
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d %d",&t1,&t2);
		l[t1].push_back(t2);
		l[t2].push_back(t1);
	}
	lvl[1]=0;
	dfs(1,-1);
	lim=ceil(lvl[n]/2.0);
	if(lvl[n]%2==0){
		lim++;
	}
	curr=n;
	for(i=lvl[n]-lim;i>0;i--){
		curr=pa[curr];
	}
	t2=n-sub[curr];
	t3=sub[curr];
	if(t2>t3){
		yay=true;
	}
	if(yay){
		printf("Fennec\n");
	}
	else{
		printf("Snuke\n");
	}
	return 0;		
}

Measured memory_bytes: 13184
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-05-10 21:36:22
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000000

typedef unsigned long ul;

int main()
{
    int n;
    ul k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    map<int, int> enc;
    enc[1]++;
    vector<int> loop(n, -1);
    loop[0] = 1;
    loop[1] = a[0];
    int cur = 1;
    while (enc[loop[cur]] <= 0) {
        enc[loop[cur]]++;
        loop[cur+1] = a[loop[cur]-1];
        cur++;
    }

    int pr;
    for (int i = 0; i < cur; i++) {
        if (loop[i] == loop[cur]) {
            pr = i;
        }
    }
    //pr ~ curでループ構成

    int l = cur - pr;

    int ans;
    if (k > cur) {
        ul res = (k - (ul)pr) % (ul)l;
        ans = loop[pr + (int)res];
    } else {
        ans = loop[k];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 14028
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;
ll N, h[1005], cnt,sum;

int main(void) {
	cin >> N;
	FOR(i, 0, N) {
		cin >> h[i];
		sum += h[i];
	}
	bool flag = false;
	while (sum > 0) {
		FOR(i, 0, N) {
			if (flag==false&&h[i] > 0) {
				flag = true;
				cnt++;
				h[i]--;
				sum--;
			}
			else if (h[i] > 0) {
				h[i]--;
				sum--;
			}
			else flag = false;
		}
		flag = false;
	}
	ct(cnt);
	return 0;
}


Measured memory_bytes: 256
N,x=map(int,input().split())
A=list(map(int,input().split()))
ans=0
for i in range(N):
  L=A[i]-x
  if L>0:
    A[i]=x
    ans+=L
for i in range(1,N):
  M=A[i]+A[i-1]-x
  if M>0:
    A[i]-=M
    ans+=M
print(ans)

Measured memory_bytes: 14132
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	s := getString()
	//b := make([]int, 0)
	w := make([]int, 0)
	for i, v := range s {
		if v == 'W' {
			w = append(w, i)
		} else {
			//		b := append(b, i)
		}
	}
	pos := 0
	ans := 0
	for i := 0; i < len(w); i++ {
		ans += w[i] - pos
		pos++
	}
	out(ans)
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
#define MAXN 200100
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,double> pdd;
inline int mod(int n, int m){int ret = n%m; if(ret < 0) ret += m; return ret;}
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}

int ok[30];

int32_t main(){
	fastio;
	int n;
	cin>>n;
	int best = 1e17;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			best = min(best,i+n/i - 2);
		}
		
		
	}
		cout<<best<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int main(){
  long int n,sum=0;
  cin>>n;
  vector<int>v;
  for(long int i=1;i<=n;i++){
  
    v.push_back(i);
    if(i%3==0||i%5==0)
      v.pop_back();
  }

 
  for(long int i=0;i<v.size();i++){
    sum+=v[i];
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 7396
#include <iostream>
using namespace std;
int main(void){
    int abcd;
    cin>>abcd;
    int a,b,c,d;
    d=abcd%10;
    int abc;
    abc=(abcd-d)/10;
    c=abc%10;
    int ab;
    ab=(abc-c)/10;
    b=ab%10;
    a=(ab-b)/10;
    if (a==b){
        cout<<"Bad"<<endl;
    }
    else if (b==c){
        cout<<"Bad"<<endl;
    }
    else if (c==d){
        cout<<"Bad"<<endl;
    }
    else{
        cout<<"Good"<<endl;
    }
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  a+=b+c+d;
  cout<<a/60<<"\n"<<a%60<<endl;
  return 0;
}

Measured memory_bytes: 0