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

int main (){
    
    int a = 1 ;
    int b = 1 ;
    int s = 0 ;

    while( s != 999 ){
        cin >> a;
        cin >> b;
        if (a == 0 && b == 0) break;
        
        if (b < a) {
            s = a;
            a = b;
            b = s;
            };
        
        cout << a << " " << b << endl ;
    }
    
    return 0;
}


Measured memory_bytes: 3036
from collections import deque

n,x,y = map(int,input().split())

adj = [[] for i in range(n)]

adj[x-1].append(y-1)
adj[y-1].append(x-1)

for i in range(n-1):
    adj[i].append(i+1) 
    adj[i+1].append(i)
        
ans = [0 for _ in range(n)]

def bfs(start):
    inf = 1001001001
    q = deque()
    q.append(start)
    dist = [inf]*n
    dist[start] = 0
    
    while q:
        v = q.popleft()

        for i in adj[v]:
            if dist[i] == inf:
                dist[i] = dist[v] + 1
                q.append(i)

    for i in range(n):
        ans[dist[i]] += 1

for i in range(n):
    bfs(i)

for i in range(1,n):
    print(ans[i]//2)

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

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

    char s;
    int x, xmax;
    x=0;
    xmax=x;
    scanf("%c",&s);
    for(int i=0; i<N; i++){
        scanf("%c", &s);
        if(s=='I'){
            x=x+1;
        }else if(s=='D'){
            x=x-1;
        }
        //cout << "i x xmax" << " " << i << " " << x << " " << xmax << endl;
        if(xmax<x){
            //cout << "i x xmax" << " " << i << " " << x << " " << xmax << endl;
            xmax=x;
        }
    }

    cout << xmax << endl;

    return 0;
}

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

using namespace std;

#define N 1200

int n,m,ans,f[N][N],g[N][N];
char s[N][N];

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i)
		scanf("%s",s[i]+1);
	memset(g,0x3f,sizeof g);
	memset(f,0x3f,sizeof f);
	for (int i=1;i<=n;++i){
		for (int j=1;j<=m;++j){
			if (s[i][j]=='#') f[i][j]=0;
			f[i][j]=min(f[i][j],min(f[i-1][j],f[i][j-1])+1);
			g[i][j]=min(g[i][j],f[i][j]);
		}
	}
	memset(f,0x3f,sizeof f);
	for (int i=1;i<=n;++i){
		for (int j=m;j;--j){
			if (s[i][j]=='#') f[i][j]=0;
			f[i][j]=min(f[i][j],min(f[i-1][j],f[i][j+1])+1);
			g[i][j]=min(g[i][j],f[i][j]);
		}
	}
	memset(f,0x3f,sizeof f);
	for (int i=n;i;--i){
		for (int j=1;j<=m;++j){
			if (s[i][j]=='#') f[i][j]=0;
			f[i][j]=min(f[i][j],min(f[i+1][j],f[i][j-1])+1);
			g[i][j]=min(g[i][j],f[i][j]);
		}
	}
	memset(f,0x3f,sizeof f);
	for (int i=n;i;--i){
		for (int j=m;j;--j){
			if (s[i][j]=='#') f[i][j]=0;
			f[i][j]=min(f[i][j],min(f[i+1][j],f[i][j+1])+1);
			g[i][j]=min(g[i][j],f[i][j]);
		}
	}
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j) ans=max(ans,g[i][j]);
	printf("%d\n",ans);
	
	return 0;
}
			


Measured memory_bytes: 12672
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-11;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

string L;
ll dp[100010][2];
void solve(){
  cin >> L;
  ll N = L.size();
  dp[0][0] = 1;
  rep(i, N)rep(j, 2){
    rep(a, 2)rep(b, 2){
      ll nj = j;
      if(a && b) continue;
      if(L[i] == '0' && !j && (a+b)) continue;
      if(L[i] == '1' && !a && !b) nj = 1;
      dp[i+1][nj] += dp[i][j];
      dp[i+1][nj] %= MOD;
    }
  }
  ll ans = (dp[N][0] + dp[N][1]) % MOD;
  cout << ans << endl;
}

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


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

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    unordered_map<string, ll> anagramCount; 
    for(int i = 0; i < N; i++){
        string S;
        cin >> S;
        sort(S.begin(), S.end());
        anagramCount[S]++;
    }
    ll answer = 0;
    for(pair<string, ll> p: anagramCount)
    {
        ll value = p.second;
        if(value > 1)
        {
            answer += value * (value - 1) / 2;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 10660
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
//#include <bits/stdc++.h>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

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

	int N; while (cin >> N && N != 0)
	{
		vector<vector<int>> dat(N + 2, vector<int>(0));
		rep(i, N)
		{
			int M = 0; cin >> M;
			rep(j, M)
			{
				int tmp; cin >> tmp;
				dat[i].push_back(tmp);
			}
		}
		int K; cin >> K;
		vector<int> tar(K, 0);
		rep(i, K) { cin >> tar[i]; }
		vector<int> ans(N, 0);
		int cri = 0;
		rep(i, N) rep(j, (int)tar.size())
		{
			int tmp = count(all(dat[i]), tar[j]);
			if (tmp >= 1) { ans[i]++; }
			if (ans[i] == (int)tar.size()) { cri++; }
		}
		if (cri == 1){printf("%d\n", max_element(all(ans)) - ans.begin() + 1); }
		else { printf("-1\n"); }
	}

	return 0;
}

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

typedef long long llint;

int n;
int a[210000], b[210000];
int bb[210000];

//二分探索
//・条件を満たす *最小* の値のindexをかえす。
//・求める値は区間 (left, right] に絶対に含まれる。
bool judge(long long x, int border) {
    if (x == -1) {
        return false;
    }
    if (x == n) {
        return true;
    }
    return border <= bb[x];
}

long long nibutan(long long left, long long right, int border) {
    while (right - left > 1) {
        long long mid = (left + right) / 2;
        if (judge(mid, border)) {
            right = mid;
        } else {
            left = mid;
        }
    }
    return right;
}

int solve() {
    int ans = 0;
    int t = 1;
    for (int i = 0; i <= 29; i++) {
        for (int j = 0; j < n; j++) {
            bb[j] = b[j] % (t * 2);
        }
        sort(bb, bb + n);

        llint cnt = 0;
        for (int j = 0; j < n; j++) {
            int atmp = a[j] % (t * 2);
            llint l, r;
            l = nibutan(-1, n, t - atmp);
            r = nibutan(-1, n, t * 2 - atmp);
            cnt += r - l;
            l = nibutan(-1, n, t * 3 - atmp);
            r = nibutan(-1, n, t * 4 - atmp);
            cnt += r - l;
        }

        if (cnt % 2 == 1) {
            ans += t;
        }

        t *= 2;
    }
    return ans;
}

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

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 2560
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    S = N[l]
    table = [[0 for i in range(10)] for j in range(10)]
    for i in range(len(S)):
        table[0][i] = int(S[i])
    for i in range(1,10):
        for j in range(0,10-i):
            table[i][j] = (table[i-1][j] + table[i-1][j+1]) % 10
    print(table[9][0])




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

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename G >
struct LowLink {
  const G &g;
  vector< int > used, ord, low;
  vector< int > articulation;
  vector< pair< int, int > > bridge;

  LowLink(const G &g) : g(g), used(g.size()), ord(g.size()), low(g.size()) {}

  int build(int idx = 0, int k = 0, int par = -1) {
    used[idx] = true;
    ord[idx] = k++;
    low[idx] = ord[idx];
    bool is_articulation = false;
    int cnt = 0, ordmax = k;
    for(auto &to : g[idx]) {
      if(!used[to]) {
        ++cnt;
        ordmax = build(to, ordmax, idx);
        low[idx] = min(low[idx], low[to]);
        is_articulation |= ~par && low[to] >= ord[idx];
        if(ord[idx] < low[to]) bridge.emplace_back(minmax(idx, to));
      } else if(to != par) {
        low[idx] = min(low[idx], ord[to]);
      }
    }
    is_articulation |= par == -1 && cnt > 1;
    if(is_articulation) articulation.push_back(idx);
    return ordmax;
  }
};


int main() {
  int V, E;
  scanf("%d %d", &V, &E);
  UnWeightedGraph g(V);
  for(int i = 0; i < E; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  LowLink< UnWeightedGraph > lowlink(g);
  lowlink.build();
  sort(lowlink.bridge.begin(), lowlink.bridge.end());
  for(auto &p : lowlink.bridge) printf("%d %d\n", p.first, p.second);
}



Measured memory_bytes: 4612
// AtCoder Begginer Contest 136 C - Build Stairs
// https://atcoder.jp/contests/abc136/tasks/abc136_c

#include<iostream>
#include<vector>
using namespace std;
using uint = unsigned int;

int main() {
	uint N;
	cin >> N;
	
	vector<uint> H(N);
	for(uint i=0; i<N; i++) {
		cin >> H[i];
	}
	
	for(int i=N-1; 0<i; i--) {
		if(H[i-1] > H[i] + 1) {
			cout << "No" << endl;
			return 0;
		} else if (H[i-1] == H[i] + 1) {
			H[i-1]--; 
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int h[N], n, memo[N];
int solve(int idx)
{
    if(idx == n - 1)
        return 0;
    if(memo[idx] != -1)
        return memo[idx];
    int awal, tany = 1e9 + 5;
    awal = abs(h[idx] - h[idx + 1]) + solve(idx + 1);
    if(idx + 2 <= n - 1)
        tany = abs(h[idx] - h[idx + 2]) + solve(idx + 2);
    return memo[idx] = min(awal, tany);
}
int main()
{
    memset(memo, -1, sizeof(memo));
    cin >> n;
    for(int i = 0 ; i < n ; i++)
        cin >> h[i];
    cout << solve(0);
    return 0;
}

Measured memory_bytes: 5760
def main():
    n, m, *a = map(int, open(0).read().split())
    t = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
    a.sort(reverse=True)
    b = {}
    for i in a:
        x = t[i]
        if b.get(x) is not None:
            a.remove(i)
        else:
            b[x] = 0

    b = [t[i] for i in a]
    dp = [-float('Inf')] * (n + 10)
    dp[0] = 0
    for i in range(2, n + 1):
        dp[i] = max(dp[i - j] + 1 for j in b)

    nums = []
    for i in range(dp[n], 0, -1):
        for x in a:
            if dp[n - t[x]] == i - 1:
                nums.append(x)
                n -= t[x]
                break

    ans = ''.join(map(str, nums))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3696
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
  int64_t s;
  cin >> s;
  int64_t a,b,c,d,e,f,t;
    
  int64_t s1;
  if ((int64_t)sqrt(s)*(int64_t)sqrt(s)==s)
    s1 = sqrt(s);
  else
    s1 = (int64_t)sqrt(s) + 1;

  a = s1;
  d = s1;
  t = s1 * s1 - s;
  f = 0;
  
  if (t >= s1){
    e = 1;
    t -= s1;
    c = 2;
    b = t;
  }
  else{
    e = 0;
    f = 0;
    c = 1;
    b = t;
  }
  cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f;
  return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>

using namespace std;

void solve()
{
	int H, W;
	while (cin >> H >> W, H || W)
	{
		for (int i = 0; i < H; ++i)
		{
			for (int j = 0; j < W; ++j)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };

int main() {
	ll n, a, x[55], dp[55][2510], ans = 0;
	cin >> n >> a;
	for (int i = 0;i < n;i++) {
		cin >> x[i];
	}
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0;i < n;i++) {
		for (int k = n;k >= 1;k--) {
			for (int j = 2510;j >= 0;j--) {
				if (j - x[i] >= 0)dp[k][j] += dp[k-1][j - x[i]];
			}
		}
	}
	for (int i = 1;i <= n;i++) {
		ans += dp[i][a*i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1280
#include<iostream>

int main(){
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;
    int start = std::max(A, C);
    int end = std::min(B, D);
    if(start <= end) std::cout << end - start << std::endl;
    else std::cout << 0 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)
typedef long long ll;
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	long long r,g;
	cin>>r>>g;
	cout<<g*2-r; 
	
	
    return 0;
}


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

//#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e9 + 7;
const int N = 2e6 + 7;
const int M = 26;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve1()
{
    int n;
    cin >> n;
    vector < int > a(n);
    vector < vector < int > > b( 2 , vector < int > (1e5 + 1 , 0) );
    for( int i = 0; i < n; i++ ){
        cin >> a[i];
        b[i % 2][a[i]] += 1;
    }
    int ans = 0;
    vector < pair < int , int > > v;
    v.push_back({ 0 , 0 });
    v.push_back({ 0 , 0 });
    for( int i = 0; i < 2; i++ ){
        for( int j = 1; j <= 1e5; j++ ){
            if( b[i][j] > 0 ){
                v.push_back({ b[i][j] , j });
            }
        }
    }
    sort( v.begin() , v.end() );
    int l = (int)v.size();
    if( v[l - 2].se == v[l - 1].se ){
        cout << n - (v[l - 1].fi + v[l - 3].fi);
    }else cout << n - (v[l - 1].fi + v[l - 2].fi);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 5812
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <numeric>
#include <string>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <deque>
#include <stdlib.h>
#include<cmath>
#define N 1003
using namespace std;

int main()
{
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
    return 0;
}


Measured memory_bytes: 256
#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 DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    int n; cin >> n;
    vector<vi> a(2, vi(n));
    rep(i, 2) rep(j, n) cin >> a[i][j];

    int res = 0;
    rep(k, n){
        int cur = 0;
        int y = 0;
        rep(x, n){
            if(x == k) cur += a[y][x], y = 1;
            cur += a[y][x];
        }
        chmax(res, cur);
    }

    cout << res << endl;

    return 0;
}


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

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

    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8) {
        cout << "Yay!";
    } else {
        cout << ":(";
    }
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
count=0
for i in range(n-1,-1,-1):
    for j in range(i+1):
        if(a[j]>a[i]):
            t=a[j]
            a[j]=a[i]
            a[i]=t
            count+=1
if(count>1):
    print("NO")
else:
    print("YES")


Measured memory_bytes: 9072
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

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

//********************************template END****************************************//

struct UnionFind
{
	//number of parents(par[i] = i => root)
	vector <int> par;
	//rank of tree
	vector <int> rank;

	UnionFind(int n) : par(n), rank(n, 1) {
		//initialize
		rep(n, i) par[i] = i;
	}

	//find root (keiroasshuku at the same time)
	int root(int x){
		if (par[x] == x) return x;
		else return par[x] = root(par[x]);
	}

	//unite
	void unite(int x, int y){
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rank[x] > rank[y]) swap(x, y);
		par[x] = y;
		rank[y] += rank[x];
	}

	//same tree?
	bool same(int x, int y){
		return root(x) == root(y);
	}
};


void solve(void)
{
	int N, K, L;
	cin >> N >> K >> L;

	UnionFind uf1(N), uf2(N);

	while(K--)
	{
		int u, v;
		cin >> u >> v;
		uf1.unite(u-1, v-1);
	}

	while(L--)
	{
		int u, v;
		cin >> u >> v;
		uf2.unite(u-1, v-1);
	}

	map<intP, int> mp;

	rep(N, i)
	{
		mp[intP(uf1.root(i), uf2.root(i))]++;
	}

	rep(N, i)
	{
		cout << mp[intP(uf1.root(i), uf2.root(i))] << (i == N-1 ? '\n' : ' ');
	}


}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-b)<=d&&abs(b-c)<=d||abs(a-c)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(){
	int W, H, x, y, r;
	bool flag = true;
	cin >> W >> H >> x >> y >> r;
	flag = flag&&(x-r>=0);
	flag = flag&&(y-r>=0);
	flag = flag&&(x+r<=W);
	flag = flag&&(y+r<=H);
	if(flag){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
}


Measured memory_bytes: 3104
import sys
I = lambda:int(sys.stdin.readline())
LI = lambda:[int(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]

def check(a,b,h,c):
    cnt = 0
    for enc in h:
        if enc - b*c > 0:
            cnt += ((enc - b*c)+(a-b)-1)//(a-b)
            if cnt > c:
                return False
    return True


N,A,B = LI()
H = IR(N)

OK = (max(H)+B-1)//B
NG = 0

while(OK-NG>1):
    mid = (OK+NG)//2
    if check(A,B,H,mid):
        OK = mid
    else:
        NG = mid

print(OK)




Measured memory_bytes: 44252
def judge_triangle(edges):
    edges.sort(reverse = True)
    if edges[0]**2 == edges[1]**2 + edges[2]**2:
        return 'YES'
    else:
        return 'NO'

lines = int(input())

for i in range(lines):
    edges = list(map(int, raw_input().split()))
    print judge_triangle(edges)


Measured memory_bytes: 4652
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	string s;
	cin >> s;
	int x, y;
	cin >> x >> y;

	bool d = true;
	int f = -1;
	vector<int> r;
	vector<int> u;
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'F') {
			count++;
		} else {
			if (f == -1) {
				f = count;
				count = 0;
				d = false;
				continue;
			}
			if (d) {
				r.push_back(count);
				d = false;
			} else {
				u.push_back(count);
				d = true;
			}
			count = 0;
		}
	}
	if (f == -1) {
		f = count;
	} else if (count != 0) {
		if (d) {
			r.push_back(count);
		} else {
			u.push_back(count);
		}
	}
	//cout << "r" << endl;
	//for (auto e : r)
	//	printf("%d\t", e);
	//cout << "u" << endl;
	//for (auto e : u)
	//	printf("%d\t", e);

	bool rok = false;
	if (r.empty()) {
		if (x == f)
			rok = true;
	} else {
		//bool dp1[r.size()][s.size()*2+1];
		bool dp[2][s.size()*2+1];
		bool *olddp = dp[0];
		bool *curdp = dp[1];
		for (int i = 0; i < r.size(); i++) {
			for (int j = 0; j < s.size()*2+1; j++) {
				int cx = j-s.size();
				if (i == 0) {
					if (cx == f + r[0] || cx == f - r[0])
						curdp[j] = true;
					else
						curdp[j] = false;
					continue;
				}

				curdp[j] = false;
				if ((j - r[i]) >= 0)
					if (olddp[j-r[i]])
						curdp[j] = true;
				if ((j + r[i]) < (s.size()*2+1))
					if (olddp[j+r[i]])
						curdp[j] = true;
			}
			swap(olddp, curdp);
		}
		if (x+s.size() >= 0 && x + s.size() < s.size()*2+1)
			if (olddp[x+s.size()])
				rok = true;
	}

	bool uok = false;
	if (u.empty()) {
		if (y == 0)
			uok = true;
	} else {
		bool dp[2][s.size()*2+1];
		bool *olddp = dp[1];
		bool *curdp = dp[0];
		for (int i = 0; i < u.size(); i++) {
			for (int j = 0; j < s.size()*2+1; j++) {
				int cy = j-s.size();
				if (i == 0) {
					if (cy == u[0] || cy == -u[0])
						curdp[j] = true;
					else
						curdp[j] = false;
					continue;
				}

				curdp[j] = false;
				if ((j-u[i]) >= 0)
					if (olddp[j-u[i]])
						curdp[j] = true;
				if ((j+u[i]) < (s.size()*2+1))
					if (olddp[j+u[i]])
						curdp[j] = true;
			}
			swap(olddp, curdp);
		}
		if (y+s.size() >= 0 && y+s.size() < s.size()*2+1)
			if (olddp[y+s.size()])
				uok = true;
	}

	if (rok && uok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    unordered_map<ll, ll> mp;
    rep(i, n){
        cin >> a[i];

        for(ll j=-1;j<2;j++){
            ll a_ = a[i]+j;
            if (mp.find(a_) == mp.end()){
                mp[a_] = 1;
            }else{
                mp[a_] += 1;
            }
        }
    }

    ll ans = 0;
    for(auto o : mp){
        ans = max(o.second, ans);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 7668
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
    int i,k,a,b;
    cin>>k>>a>>b;
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK";
            break;
        }
    }
    if(i==b+1)
    cout<<"NG";
    return 0;

}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 1e9+7;

int main() {
	int N;
	cin >> N;
	int s[N];
	int sum = 0;
	bool all_zero = true;
	for (int i = 0; i < N; i++) {
		cin >> s[i];
		if (s[i] % 10 != 0) all_zero = false;
		sum += s[i];
	}

	if (all_zero) {
		cout << 0 << endl;
		return 0;
	}

	if (sum % 10 == 0) {
		sort(s, s+N);

		for (int i = 0; i < N; i++) {
			if (s[i] % 10 == 0) continue;
			sum -= s[i];
			break;
		}
	}

	cout << sum << endl;

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n, c, k, i; cin >> n >> c >> k;
    vll t(n); rep(i,n) cin >> t[i];
    sort(t.begin(), t.end());

    int bus_counting = 1, j = 0;
    rep(i, n){
        if(i-j+1 > c || t[i] > t[j]  + k){
           bus_counting++;
           j = i;
        }
    }
    cout << bus_counting << '\n';
}

Measured memory_bytes: 1024
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e5;

int main()
{
  FastIO();
  int tc, ca = 0;
  int n, m;
  cin >> n >> m;
  vector <string> v(n);
  for (int i = 0;i < n;i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  for (int i = 0;i < n;i++){
    cout << v[i];
  }cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n, m, k ;
  cin >> n >> m >> k ;
  
  int hoge, moge ;
  
  REP(i,n+1){
    REP(j,m+1){
      if(k==m*i+(n-2*i)*j){
        cout << "Yes" <<endl ;
        return 0 ;
      }
    }
  }
  
  cout << "No" <<endl ;


  return 0 ;
}




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

int main () {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  
  else {
    cout << "consonant" << endl;
  }
}

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

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

int main(){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans;
    if(K % 2 == 0){
        ans = A - B;
    }else{
        ans = B - A;
    }

    if(ans > pow(10, 18)){
        cout << "Unfair" << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
#include <cctype>
#define _GLIBCXX_DEBUG
#define ll long long

using namespace std;


int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll p=1; p < n+1; ++p) {
        ll tmp = 0;
        for (ll q=1; q < (n / p)+1; ++q) {
            tmp += q;
        }
        ans += p * tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

n = int(input())
p = list(map(float,input().split()))
dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1.0
for i in range(n):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j] *(1.0-p[i])
ans = 0
for j in range((n+1)//2,n+1):
    ans += dp[n][j]
print(ans)


Measured memory_bytes: 254088
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	double l;
	cin >> l;
	cout << fixed << setprecision(12);
	cout << (l * l * l) / (3 * 3 * 3 * 1.0);
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 256
// :pray: :arrayman:
// :pray: :summit:
// :pray: :pusheen:
// :pray: :prodakcin:
// :pray: :spacewalker:
// :pray: :duk:
// :pray: :gustav:
// :pray: :tmw:
// :pray: :eed:
// :pray: :chicubed:
// :pray: :arceus:
// :pray: :gamegame:
// :pray: :sinx:
// :pray: :eyg:
// :pray: :evan:
// :pray: :cj:
// :pray: :steph:
// :pray: :fatant:
// :pray: :mathbot:
// :pray: :dolphin:
// :pray: :stef:
// :pray: :geothermal:
// :pray: :mikey:
// :pray: :horse:
// :pray: :snek:
// :pray: :wayne:
// :pray: :wu:
// :pray: :vmaddur:
// :pray: :dorijanko:
// :pray: :gaming:
// :pray: :kassuno:
// :pray: :hyacinth:
// :pray: :chilli:
// :pray: :dhruv:
// :pray: :philip:
// :pray: :paiman:
// :pray: :camel:
// :pray: :tree:
// :pray: :tux:
// :pray: :jony:
// :pray: :kage:
// :pray: :ghost:
// :pray: :aha:
// :pray: :coolguy:
// :pray: :imax:
// :pray: :howlet:
// :pray: :darren:
// :pray: :arie: 
// :pray: :blastman: 
// :pray: :zephyr: 
// :pray: :bigc:

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>

#define ll long long
#define eps 1e-8
#define MOD 1000000007

#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f

// change if necessary
#define MAXN 100000

using namespace std;

int n;
int k;
int h[MAXN + 1];
int dp[MAXN + 1];

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

    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    for (int i = 1; i < n; i++) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);

        for (int d = 2; d <= k; d++) {
            if (i - d >= 0) {
                dp[i] = min(dp[i], dp[i - d] + abs(h[i] - h[i - d]));
            }
        }
    }

    cout << dp[n - 1] << '\n';

    return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int x;
    cin >> x;

    vector<int> v;
    v.push_back(1);
    for (int i = 2; i <= x; i++)
    {
        int tmp = i;
        int idx = 2;
        while (tmp < x)
        {
            tmp = pow(i, idx++);
            v.push_back(tmp);
        }
    }

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

    int mx = -1;
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] <= x)
            mx = max(mx, v[i]);
    }
    cout << mx << endl;
}


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

int gcd(int m, int n){
  if(n>m)return gcd(n, m);
  if(n==0)return m;
  return gcd(n, m%n);
}

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0; i<n; i++)cin >> a[i];
  vector<int>f(n), b(n);
  f[0]=a[0];
  b[n-1]=a[n-1];
  for(int i=1; i<n; i++)f[i]=gcd(f[i-1], a[i]);
  for(int i=n-2; i>=0; i--)b[i]=gcd(b[i+1], a[i]);
  int ret=max(f[n-2], b[1]);
  for(int i=1; i<n-1; i++)ret=max(ret, gcd(f[i-1], b[i+1]));
  cout << ret;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int N=100000+5;
#define int long long
#define Is(c) ('0'<=c && c<='9')
inline int read(){
	int x=0;bool f=0;char c=getchar();
	while(!Is(c)) f=c=='-',c=getchar();
	while(Is(c)) x=x*10+c-48,c=getchar();
	return f ? -x : x;
}
int n,x,y,z,ans;
int pre[N],suf[N];
struct node{
	int a,b,c;
}t[N];
bool cmp(node x,node y){ return x.a-x.b>y.a-y.b; }
priority_queue<int> q;
signed main(){
	x=read(),y=read(),z=read(),n=x+y+z;
	for(int i=1;i<=n;i++) t[i].a=read(),t[i].b=read(),t[i].c=read();
	sort(t+1,t+1+n,cmp);
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+t[i].a;
	for(int i=n;i>=1;i--) suf[i]=suf[i+1]+t[i].b;
	int cnt=0;
	for(int i=1;i<=x;i++) q.push(t[i].c-t[i].a);
	for(int i=x+1;i<=n;i++){
		q.push(t[i].c-t[i].a);
		cnt+=q.top();
		q.pop();
		pre[i]+=cnt;
	}
	cnt=0;
	while(!q.empty()) q.pop();
	for(int i=n;i>=n-y+1;i--) q.push(t[i].c-t[i].b);
	for(int i=n-y;i>=1;i--){
		q.push(t[i].c-t[i].b);
		cnt+=q.top();
		q.pop();
		suf[i]+=cnt;
	}
	for(int i=x;i<=n-y;i++) ans=max(ans,pre[i]+suf[i+1]);
	printf("%lld",ans);
	return 0;
}

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

typedef long long ll;
typedef long double ld;

#define n1		      "\n"
#define B                     begin()
#define E                     end()
#define F                     first
#define S                     second
#define pb                    push_back
#define pf                    push_front
#define popb                  pop_back()
#define popf                  pop_front()

const int BIG=1e5+55;
const int BIGG=1e9+7;
const ll BIGGE=1e12+55;
const double SML=(1e-7);

using namespace std;

    int a[5];
    bool go = 0;

void dp(int i, int sum, string s) {
    if (go || i > 3)
        return;
    if (sum == 7 && i == 3) {
        go = 1;
        cout <<s <<'=' <<7;
        return;
    }
    string ans = s , an = s;
    ans += '-';
    ans += (a[i+1] + '0');
    if (i != -1)
        an  += '+';
    an  += (a[i+1] + '0');
    if (i != -1)
        dp(i+1 , sum-a[i+1] ,ans);
    dp(i+1 , sum+a[i+1] ,an);
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    cout.tie(NULL);
    for (int i=0; i<4; i++) {
        char c;
        cin >>c;
        a[i] = c - '0';
    }
    dp(-1,0,"");



    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int cmpChar(char *pchar){
  
  if(strlen(pchar) == 0) return 0;
  
  int rc = 0;
  if(memcmp(pchar, "dreamer", 7) == 0){
    rc = cmpChar(pchar + 7);
    if(rc == 0) return rc;
  }  
  if(memcmp(pchar, "dream", 5) == 0){
    rc = cmpChar(pchar + 5);
    if(rc == 0) return rc;
  }
  if(memcmp(pchar, "eraser", 6) == 0){
    rc = cmpChar(pchar + 6);
    if(rc == 0) return rc;
  }
  if(memcmp(pchar, "erase", 5) == 0){
    rc = cmpChar(pchar + 5);
    if(rc == 0) return rc;
  }
  
  return -1;
}

int main(void){
  char buf[131072] = { 0 };
  
  fgets(buf, sizeof(buf), stdin);
  // 改行チェック
  char *tok = strtok(buf, "\n"); 
  
  int rc = cmpChar(tok);
  if(rc == 0) printf("YES\n");
  else printf("NO\n");
  
  return 0;
}

Measured memory_bytes: 1888
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}
	b := make([]int, n)
	for i := range b {
		b[i] = scanInt()
	}

	c := make([]int, n)
	for i := range c {
		c[i] = a[i] - b[i]
	}
	sort.Ints(c)

	ans := 0
	sum := 0
	for _, v := range c {
		if v >= 0 {
			break
		}
		ans++
		sum += v
	}
	for i := n - 1; i >= 0; i-- {
		if c[i] <= 0 || sum >= 0 {
			break
		}
		ans++
		sum += c[i]
	}

	if sum < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 5632
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();
        }
        int cnt = 0;
        boolean is_odd = false;
        while (!is_odd) {
            for (int i=0;i<n;i++) {
                if ((a[i] & 1) == 0) {
                    a[i] >>= 1;
                } else {
                    is_odd = true;
                    break;
                }
            }
            if (!is_odd)
                cnt++;
        }
        System.out.println(cnt);
    }
}


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

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

typedef long long int ll;

//const ll INF=(ll)1e18;
const int INF=(1<<21);

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

  vector<pair<int, int>> e[n];
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int,int>>> pq;

  int d[n];
  bool visited[n];

  REP(i,n)d[i]=INF;
  REP(i,n)visited[i]=false;

  REP(i,n){
    int u,k;
    cin >> u >> k;

    REP(j,k){
      int v,c;
      cin >> v >> c;;
      e[i].push_back(make_pair(v,c));
    }
  }

  d[0]=0;
  visited[0]=true;

  pq.push(make_pair(0,0));
  while(!pq.empty()){
    int c=pq.top().first;
    int u=pq.top().second;
    pq.pop();

    visited[u] = true;
    if(d[u] < c)continue;

    REP(i,e[u].size()){
      int v = e[u][i].first;
      if(visited[v])continue;

      if(d[u] + e[u][i].second < d[v]){
        d[v] = d[u] + e[u][i].second;
        pq.push(make_pair(d[v], v));
      }
    }

  }

  REP(i,n){
    cout << i << " " << d[i] << endl;
  }


}




Measured memory_bytes: 7796
N,Q = (int(x) for x in input().split())

S = input()

a = [0]*len(S)
nac = 0
for i in range(1, len(S)):
    if S[i-1] == "A" and S[i] =="C":
        nac += 1
    a[i] = nac

for _ in range(Q):
    l,r = (int(x) for x in input().split())
    if l == 0:
        lac = 0
    else:
        lac = a[l-1]
    print(a[r-1]-a[l-1])



Measured memory_bytes: 6084
import itertools

n = int(input())

count = 0
for i in range(3, 11):
    for itr in itertools.product('357', repeat=i):
        if '3' not in itr or '5' not in itr or '7' not in itr:
            continue
        value = 0
        for j in range(i):
            value += int(itr[j])*10**j
        if value <= n:
            count += 1
print(count)

Measured memory_bytes: 43228
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
bool can_go;
bool used[51][51][51][51];
string s0[51],s1[51];
int h,w;
int c_x(int x){
  if(x<0)x=0;
  if(x>=h)x=h-1;
  return x;
}
int c_y(int y){
  if(y<0)y=0;
  if(y>=w)y=w-1;
  return y;
}
struct pt{
  int x,y,rx,ry;
  pt(int a,int b,int c,int d){
    x=a;
    y=b;
    rx=c;
    ry=d;
  }
};
void search(int lX,int lY,int rX,int rY){
  queue<pt> que;
  int x,y,rx,ry;
  que.push(pt(lX,lY,rX,rY));
  while(!que.empty()){
    pt tmp=que.front();
    que.pop();
    x=tmp.x;
    y=tmp.y;
    rx=tmp.rx;
    ry=tmp.ry;
    if(used[x][y][rx][ry]) continue;
    if(s0[x][y]=='%'&&s1[rx][ry]=='%'){
      can_go=true;
      break;
    }
    if(s0[x][y]=='%'||s1[rx][ry]=='%'){
      continue;
    }
    int X,Y,RX,RY;
    used[x][y][rx][ry]=true;
    if(x>0&&s0[x-1][y]=='#')X=x;
    else X=c_x(x-1);
    if(rx>0&&s1[rx-1][ry]=='#')RX=rx;
    else RX=c_x(rx-1);
    que.push(pt(X,y,RX,ry));

    if(x<h-1&&s0[x+1][y]=='#')X=x;
    else X=c_x(x+1);
    if(rx<h-1&&s1[rx+1][ry]=='#')RX=rx;
    else RX=c_x(rx+1);
    que.push(pt(X,y,RX,ry));

    if(y>0&&s0[x][y-1]=='#')Y=y;
    else Y=c_y(y-1);
    if(ry<w-1&&s1[rx][ry+1]=='#')RY=ry;
    else RY=c_y(ry+1);
    que.push(pt(x,Y,rx,RY));

    if(y<w-1&&s0[x][y+1]=='#')Y=y;
    else Y=c_y(y+1);
    if(ry>0&&s1[rx][ry-1]=='#')RY=ry;
    else RY=c_y(ry-1);
    que.push(pt(x,Y,rx,RY));
  }
}
int main(){
  int rx,ry,lx,ly;
  cin >> w >> h;
  while(w!=0){
    can_go=false;
    for(int i=0;i<h;i++){
      cin >> s0[i];
      cin >> s1[i];
      for(int j=0;j<w;j++){
        if(s0[i][j]=='L'){
          lx=i;
          ly=j;
        }
        if(s1[i][j]=='R'){
          rx=i;
          ry=j;
        }
        for(int k=0;k<h;k++){
          for(int l=0;l<w;l++){
            used[i][j][k][l]=false;
          }
        }
      }
    }
    search(lx,ly,rx,ry);
    if(can_go) cout <<"Yes\n";
    else cout <<"No\n";
    cin >> w >> h;
  }
}



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

void trace(int A[], int N) {
  int i;
  for (i = 0; i < N; i++) {
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N) {
  int j, i, v;
  for (i = 1; i < N; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &A[i]);

  trace(A, N);
  insertionSort(A, N);

  return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <unordered_set>

using namespace std;

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

    unordered_set<int> set;
    int exceed = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a >= 3200) {
            exceed++;
        } else {
            set.insert(a / 400);
        }
    }

    if (set.size() == 0) {
        cout << 1 << " " << exceed << endl;
    } else {
        cout << set.size() << " " << (set.size() + exceed) << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string S, T;

int main() {
  INCANT;
  cin >> S >> T;
  int ans=INF;
  for (int i=0; i<=S.size()-T.size();i++) {
    int tmp=0;
    rep(j, T.size()) {
      if (T[j]!=S[i+j]) tmp++;
    }
    ans = min(ans, tmp);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	char s1[100],s2[100],s3[100];
	
	scanf("%s %s %s",s1,s2,s3);
	
	//char ans[]={s1[0],s2[0],s3[0]};
	
	printf("%c%c%c\n",s1[0]-32,s2[0]-32,s3[0]-32);
	
	return 0;
}

Measured memory_bytes: 128