akhauriyash/Code-Regression huggingface dataset:
object Main {
  def main(args: Array[String]): Unit = {
    def convert(line: String): String = {
      line match {
        case str if str.matches(".*(the|that|this).*") => str
        case str =>
          convert(str.map {
            case ch if 'b' to 'z' contains ch => (ch - 1).toChar
            case ch if ch == 'a' => 'z'
            case ch => ch
          })
      }
    }

    val sc = new java.util.Scanner(System.in)
    while (sc.hasNextLine) {
      println(convert(sc.nextLine()))
    }
  }
}

Measured memory_bytes: 47592
local n = io.read("*n")
local sum = io.read("*n")
local prv = sum
local mmi = math.min
for i = 2, n - 1 do
  local nxt = io.read("*n")
  sum = sum + mmi(prv, nxt)
  prv = nxt
end
sum = sum + prv
print(sum)


Measured memory_bytes: 760
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b; cin >> n >> a >> b;
	if (n > b) {
		cout << '0' << endl;
	}
	else if (n + a < b) {
		cout << "NA" << endl;
	}
	else {
		cout << b - n << endl;
	}
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>
 
#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)
 
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;
 
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
void printhoge(set<int> v) {
    ALL(it, v) {
        cout << *it << " ";
    }
    cout << endl;
 
}
int main() {
    int a,b;cin>>a>>b;
    if (a + b  == 15)
        cout << "+";
    else if(a * b == 15)
        cout << "*";
    else
        cout << "x";
    cout <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W, N;
  cin >> H >> W >> N;
  if(H >= W){
    if(N%H == 0) cout << N/H << endl;
    else cout << N/H + 1 << endl;
  }
  else {
    if(N%W == 0) cout << N/W << endl;
    else cout << N/W + 1 << endl;
  }
}
    

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

int N;
vector<long long> A, B;

long long solve() {
    if (A == B) return 0;
    long long sum = 0, mi = 1LL<<60;
    for (int i = 0; i < N; ++i) {
        sum += A[i];
        if (A[i] > B[i]) mi = min(mi, B[i]);
    }
    return sum - mi;
}

int main() {
    cin >> N;
    A.resize(N), B.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];
    cout << solve() << endl;
}


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

int main()
{
    int d, g;
    cin >> d >> g;
    g /= 100;

    vector<int> p(d), c(d);
    for (int i = 0; i < d; i++) cin >> p[i] >> c[i], c[i] /= 100;

    int ans = 1 << 29;
    for (int i = 0; i < 1 << d; i++) {
        vector<bool> f(d);
        int score = 0, cnt = 0;
        for (int j = 0; j < d; j++) {
            if ((i >> j) & 1) {
                f[j] = true;
                score += (j + 1) * p[j] + c[j];
                cnt += p[j];
            }
        }
        // cerr << score << " " << cnt << endl;
        if (score < g) {
            for (int j = d - 1; j >= 0; j--) {
                if (f[j]) continue;
                bool ff = false;
                for (int k = 0; k < p[j] - 1; k++) {
                    score += j + 1;
                    cnt++;
                    if (score >= g) {
                        ff = true;
                        break;
                    }
                }
                if (ff) break;
            }
            // cerr << " " << score << " " << cnt << endl;
        }
        if (score >= g) ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e12

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans;
    if(a>b) ans = a + (a-1);
    else if (a==b) ans = a+b;
    else ans = b + (b-1);
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  vector<pair<int,int>> ab(n),cd(n);
  for(int i=0; i<n; ++i) cin>>ab[i].first>>ab[i].second;
  for(int i=0; i<n; ++i) cin>>cd[i].first>>cd[i].second;
  sort(ab.begin(),ab.end());
  sort(cd.begin(),cd.end());
  int res=0,d=999999;
  pair<int,int> a(-1,-1);
  unordered_map<int,bool> m;
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      int d1=cd[i].first-ab[j].first;
      int d2=cd[i].second-ab[j].second;
      if(d1>0&&d2>0) if(d2<d) if(m[j]==false) a=make_pair(i,j),d=d2;
    }
    if(a.first>=0&&a.second>=0) ++res,m[a.second]=true;
    d=999999; a=make_pair(-1,-1);
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 3620
N = int(input())
a = [int(_) for _ in input().split()]

d = {}

for i in range(N):
    if a[i] not in d:
        d[a[i]]=1
    else:
        d[a[i]]+=1
num_odd = 0
num_even= 0

for m in d:
    if d[m] % 2 == 0:num_even+=1
    else:num_odd+=1
print((num_odd+num_even if num_even%2==0 else num_odd +num_even-1))

Measured memory_bytes: 18272
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int d=0;
    while(b<=a)
    {
        b*=2;
        d++;
    }
    while(c<=b)
    {
        c*=2;
        d++;
    }
    if(d<=k)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 3652
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N, M = ILI()
    edges = IAI(M)
    return (N, M, edges)


def solve(N, M, edges):
    ans = [0] * N
    for edge in edges:
        a, b = map(lambda x: x - 1, edge)
        ans[a] += 1
        ans[b] += 1
    
    return ans


def main():
    params = read()
    ans = solve(*params)
    for i in ans:
        print(i)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
#define mod ((long long)(1e9 + 7))

int main(void) {
  string S;
  cin >> S;
  int N = S.length();
  vector<vector<long long>> dp(N + 1, vector<long long>(13, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    if (S[i - 1] != '?') {
      for (int j = 0; j < 13; j++) {
        int n = (j * 10 + S[i - 1] - '0') % 13;
        dp[i][n] += dp[i - 1][j];
        dp[i][n] %= mod;
      }
    } else {
      for (int j = 0; j < 10; j++) {
        for (int k = 0; k < 13; k++) {
          int n = (k * 10 + j) % 13;
          dp[i][n] += dp[i - 1][k];
          dp[i][n] %= mod;
        }
      }
    }
  }
  cout << dp[N][5] << endl;
  return 0;
}

Measured memory_bytes: 13696
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define Pll pair<ll,ll>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
int n,q;
hei(ll) seg, lazy;

void aaa(int k) {
	if (lazy[k] == 0)return ;
	if (k < n - 1) {
		lazy[k * 2 + 1] += lazy[k];
		lazy[k * 2 + 2] += lazy[k];
	}
	seg[k] += lazy[k];
	lazy[k] = 0;
}

void update(int a, int b, ll x,int k,int l,int r) {
	aaa(k);
	if (a<=l && b>=r) {
		lazy[k] += x;
		aaa(k);
	}
	else if(a<r&&l<b){
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		seg[k] = seg[k * 2 + 1]+seg[k * 2 + 2];
	}
}

ll query(int a,int b,int k,int l,int r){
	aaa(k);
	if (l >= b || r <= a)return 0;
	if (a <=l  && b >= r) {
		return seg[k];
	}
	ll v1 = query(a, b, k*2+1, l, (l + r) / 2);
	ll v2 = query(a, b, k*2+2, (l + r) / 2, r);
	return v1 + v2;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = a * x + b * y;
	if (x > y) {
		ans = min({ ans,a * (x - y) + c * 2 * y,c * 2 * x });
	}
	else ans = min({ans, b * (y - x) + c * 2 * x, c * 2 * y});
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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

ll a, b, n;

int main() {

	cin >> a >> b >> n;

	if (b <= n) {
		cout << max((a * n / b) - (n / b) * a, a * (b - 1) / b) << endl;
	}
	else {
		cout << (a * n / b) - (n / b) * a << endl;
	}

	return 0;
}


Measured memory_bytes: 3588
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
s = input()
t = input()
#x,y = [int(i) for i in readline().split()]
MOD = 10**9+7
if s[0] == t[0]:
    ans = 3
    i = 1
    yoko = 0
else:
    ans = 6
    i = 2
    yoko = 1


while i < n:
    if yoko:
        if s[i] == t[i]:
            i += 1
            yoko = 0
        else:
            ans *= 3
            i += 2
            yoko = 1
    else:
        if s[i] == t[i]:
            ans *= 2
            i += 1
            yoko = 0
        else:
            ans *= 2
            i += 2
            yoko = 1
    ans %= MOD
print(ans)


    

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

int main(){
  int a;
  cin >> a;
  ll ans = 0;
  rep(i,a){
    rep(j,a){
      rep(k,a){
        ans += gcd(gcd(i,j),k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int n;
	cin >> n;
	vector<map<int, int>> g(n);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		for (int j = 0; j < a; j++) {
			int x, y;
			cin >> x >> y;
			g[i][--x] = y;
		}
	}
	ll lim = pow(2, n);
	int max = 0;
	for (int i = 0; i < lim; i++)
	{
		bool f = false;
		for (int j = 0; j < n; j++) {
			if (!(i & (1 << j)))
				continue ;
			for (auto it = g[j].begin(); it != g[j].end(); it++)
			{
				if (it->second == 1 && !(i & (1 << it->first)))
					f = true;
				if (it->second == 0 && i & (1 << it->first))
					f = true;
			}
		}
		int honest = __builtin_popcount(i);
		if (!f && honest > max)
			max = honest;
	}
	cout << max << endl;
}



Measured memory_bytes: 4040
<?php
$input = STDIN;

while (true) {
    $n = intval(trim(fgets($input)));
    if ($n == 0) {
        break;
    }

    $s = array_map("floatval", explode(' ', trim(fgets($input))));
    $avg = array_sum($s) / $n;

    $var = 0;
    foreach ($s as $s_i) {
        $var += ($s_i - $avg) ** 2;
    }
    $var /= $n;

    $sdev = sqrt($var);

    print $sdev . "\n";
}


Measured memory_bytes: 9640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  ll x,y;
  cin >> x >> y;
  int ans = 0;
  if(x*y==0){
    if(x<y) ans = y-x;
    if(y<x) ans = x-y+1;
  }
  if(x*y>0){
    if(x<y) ans = y-x;
    if(y<x) ans = x-y+2;
  }
  if(x*y<0){
    ans = abs(x+y)+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
# ABC 043: B – バイナリハックイージー / Unhappy Hacking (ABC Edit)
s = input()
editor = ''

for key in s:
    if key == '0':
        editor += '0'
    elif key == '1':
        editor += '1'
    elif key == 'B':
        if editor != '':
            editor = editor[:-1]

print(editor)

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

const int INF = INT_MAX/2;

int main(){
    int N; cin >> N;
    vector<vector<int>> dp(N+1, {-INF, -INF, -INF});
    for(int &i : dp[0]) i = 0;
    for(int i=1; i<N+1; i++){
        int a[3]; cin >> a[0] >> a[1] >> a[2];
        dp[i][0] = max(dp[i-1][1]+a[1], dp[i-1][2]+a[2]);
        dp[i][1] = max(dp[i-1][0]+a[0], dp[i-1][2]+a[2]);
        dp[i][2] = max(dp[i-1][0]+a[0], dp[i-1][1]+a[1]);
    }
    cout << *(max_element(dp[N].begin(), dp[N].end())) << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  ll n, a, b;
  cin >> n >> a >> b;
  if (a == 0) {
    fin(0);
    return 0;
  }
  ll ans = 0;
  ans += (n / (a + b)) * a;
  ll rem = n % (a + b);
  if (rem > a) {
    ans += a;
  } else {
    ans += rem;
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 256
n, m = list(map(int, input().split()))

moves = [list(map(int, input().split())) for i in range(m)]

possibilities = [False] * n
possibilities[0] = True
nums = [1] * n

for i in range(m):
    x = moves[i][0] - 1
    y = moves[i][1] - 1

    if possibilities[x]:
        possibilities[y] = True

    nums[x] -= 1
    nums[y] += 1
    if nums[x] == 0:
        possibilities[x] = False

ans = 0
for j in range(n):
    if possibilities[j] and (nums[j] > 0):
        ans += 1
print(ans)



Measured memory_bytes: 28964
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }
        sc.close();

        if (Swap0or1(N, p, 1, 0)) {
            System.out.println("NO");
        }
        else {
            System.out.println("YES");
        }
    }
    public static boolean Swap0or1(int N, int[] p, int index, int times) {
        if (index > N) {
            return false;
        }
        if (p[index-1] != index) {
            if (p[p[index-1]-1] != index || times == 1) {
                return true;
            }
            p[p[index-1]-1] = p[index-1];
            p[index-1] = index;
            return Swap0or1(N, p, index + 1, times + 1);
        }
        return Swap0or1(N, p, index + 1, times);
    } 
}


Measured memory_bytes: 21716
N = int(input())
ans = [0]*10000
for x in range(1,99):
  for y in range(1,99):
    for z in range(1,99):
      a = x**2+y**2+z**2+x*y+y*z+z*x
      if a<=10000:
        ans[a-1]+=1
for i in range(N):
  print(ans[i])
  

Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n,k;
 cin>>n>>k;
 vector<ll> p(n);
 for(ll i=0;i<n;i++)cin>>p[i];
 sort(p.begin(),p.end());
 ll sum = 0;
 for(ll i=0;i<k;i++)sum+=p[i];
 cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3600
usrInput = []
flag = False
for n in range(6):
    usrInput.append(int(input()))

for l in range(5):
    for m in range(5):
        if abs(int(usrInput[l]) - int(usrInput[m])) > usrInput[5]:
            flag = True

if flag:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll k; cin >> k;
  int n = 50;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) a[i] = n - 1 - i + k / n;
  for (int i = 0; i < k % n; i++) a[i]++;

  cout << n << endl << a.front();
  for (int i = 1; i < n; i++) cout << " " << a[i];
  cout << endl;
}

Measured memory_bytes: 256
function Main(input){
    const arr = input.split('\n');
    const NK = arr[0].split(' ').map(Number);
    const Ai = arr[1].split(' ').map(Number);
    // N学期の出力
    for(let n = NK[1]+1; n<=NK[0]; n++){
        console.log(Ai[n-1] > Ai[n-(NK[1]+1)] ? 'Yes': 'No');
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  long N, X, A, sum, pre = 0, ans = 0;
  cin >> N >> X;
  while (cin >> A) {
    sum = pre + A;
    if (sum > X) ans += sum - X, A -= sum - X;
    pre = A;
  }
  cout << ans << "\n"; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  char a,b;
  cin >> a >> b;
  if (a>b) cout << ">" << endl;
  if (a<b) cout << "<" << endl;
  if (a==b) cout << "=" << endl;
}


Measured memory_bytes: 256
def sura_backsura():
    import collections

    N = int(input())
    a = [int(i) for i in input().split()]

    fp = collections.Counter(a[0::2]).most_common()
    sp = collections.Counter(a[1::2]).most_common()

    fp.append((0, 0))
    sp.append((0, 0))

    if fp[0] != sp[0]:
        count = N - fp[0][1] - sp[0][1]
    else:
        count = min(N - fp[0][1] - sp[1][1], N - fp[1][1] - sp[0][1])

    print(count)
    
if __name__ == "__main__":
    sura_backsura()

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

using namespace std;

int main(void){
  int n, y;
  scanf("%d %d", &n, &y);
  for(int i = 0, ii = 0; ii <= y;++i, ii += 1000){
    for(int j = 0, jj = 0; jj + ii <= y;++j, jj += 5000){
      int k = n - i - j;
      int kk = k * 10000;
        if(ii + jj + kk == y && i + j + k == n){
          printf("%d %d %d\n", k, j, i);
          return 0;
        }
    }
  }
  puts("-1 -1 -1");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int a[100005];
set<int>s;
int main()
{
	int i,j,k;
	int n;
	sd(n);
	for(i=1;i<=n;i++){
		sd(a[i]);
		s.insert(a[i]);
	}
	if(s.size()>2)
		printf("No\n");
	else if(s.size()==1)
	{
		int x=*s.begin();
		if(n>=2*x)
			printf("Yes\n");
		else if(n==x+1)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else
	{
		int x=*(s.begin());
		s.erase(s.begin());
		int y=*(s.begin());
		if(y!=x+1)
			printf("No\n");
		else
		{
			int temp=0;
			for(i=1;i<=n;i++)
			{
				if(a[i]==x)
					temp++;
			}
			if(y>=temp+1 && y<=temp+(n-temp)/2)
				printf("Yes\n");
			else
				printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 5376
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
lenB = M**2
flg=False
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j] == B[0][0]:
            cnt=0
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] == B[k][l]:
                        cnt += 1
            if cnt==M**2:
                flg=True
ans='Yes' if flg else 'No'
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

typedef struct tnode tnode;

typedef struct{
	tnode *root;
}Tree;

struct tnode {
	int key;
	tnode *left, *right;
	tnode *p;
};

void insert(Tree *T, int n) {
	tnode *z;
	z = malloc(sizeof(tnode));
	z->key = n;
	z->left = z->right = NULL;
	tnode *y = NULL;
	tnode *x = T->root;
	while (x != NULL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
		z->p = y;
	}

	if (y == NULL) {
		T->root = z;
	}
	else if (z->key < y->key) {
		y->left = z;
	}
	else {
		y->right = z;
	}
}

int find_rec(tnode *node, int key) {
	if(node->key == key) return 1;
	if(node->key == key) return 1;
	if(node->key > key) {
		if(node->left != NULL && find_rec(node->left, key)) return 1;
	}
	else {
		if(node->right != NULL && find_rec(node->right, key)) return 1;
	}
	return 0;
}

int find(Tree *tree, int key) {
	return find_rec(tree->root, key);
}

void print_preorder_rec(tnode *node){
	printf(" %d", node->key);
	if(node->left != NULL) print_preorder_rec(node->left);
	if(node->right != NULL) print_preorder_rec(node->right);
}

void print_preorder(Tree *tree) {
	print_preorder_rec(tree->root);
	printf("\n");
}

void print_inorder_rec(tnode *node){
	if(node->left != NULL) print_inorder_rec(node->left);
	printf(" %d", node->key);
	if(node->right != NULL) print_inorder_rec(node->right);
}

void print_inorder(Tree *tree) {
	print_inorder_rec(tree->root);
	printf("\n");
}

void print_postorder_rec(tnode *node){
	if(node->left != NULL) print_postorder_rec(node->left);
	if(node->right != NULL) print_postorder_rec(node->right);
	printf(" %d", node->key);
}

void print_postorder(Tree *tree) {
	print_postorder_rec(tree->root);
	printf("\n");
}

int main(void) {
	Tree T;
	T.root = NULL;
	int i, n, z;
	char command[7];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", command);
		if (strcmp(command, "insert") == 0) {
			scanf("%d", &z);
			insert(&T, z);
		}
		if (strcmp(command, "print") == 0) {
			print_inorder(&T);
			print_preorder(&T);
		}
		if (strcmp(command, "find") == 0) {
			scanf("%d", &z);
			if (find(&T, z)) printf("yes\n");
			else printf("no\n");
		}
	}
	return 0;
}

Measured memory_bytes: 19364
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    solve <$> replicateM n (getl $ wrds toInt) >>= mapM_ putStrLn
    main
    
solve :: [[Int]] -> [String]
solve = map mult
  where
    mult [x1,y1,z1,w1,x2,y2,z2,w2] = unwords . map show $ [(x1*x2-y1*y2-z1*z2-w1*w2),
                                                           (x1*y2+y1*x2+z1*w2-w1*z2),
                                                           (x1*z2-y1*w2+z1*x2+w1*y2),
                                                           (x1*w2+y1*z2-z1*y2+w1*x2)]

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

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

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        if(i==0) a[i]--;
        else {
            if(a[i]!=a[i-1]) a[i]--;
            if(a[i]<a[i-1]) {
                printf("No\n"); return 0;
            }
        }
    }
    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 640
<?php

$N = trim(fgets(STDIN));

$N_1 = substr($N, -1);

if ($N_1 == 3) {
  echo 'bon';
} elseif ($N_1 == 0 || $N_1 == 1 || $N_1 == 6 || $N_1 == 8) {
  echo 'pon';
} else {
  echo 'hon'; 
}

Measured memory_bytes: 16028
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String o = scan.next();
		String e = scan.next();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < o.length(); i++) {
			list.add(o.charAt(i) + "");
			if(i < e.length()) {
				list.add(e.charAt(i) + "");
			}
		}
		for(String a:list) {
			System.out.print(a);
		}
		System.out.println();
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin>>s;
    int n=SZ(s);
    int ans=n;
    REP(i,n-1) {
        if(s[i]!=s[i+1]) {
            chmin(ans,max(i+1,n-i-1));
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int now = 1;
  int ans = 0;
  int N; cin >> N;

  for(int i = 0; i < N; i++){
    int tmp; cin >> tmp;
    if(tmp != now){
      ans++;
    } else { 
      now++;
    }
  }

  if(ans == N){
    ans = -1;
  }
  cout << ans << endl;
}


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

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  ll ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int N;
  cin >> N;
  vector<ll> A(N);
  ll S = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    S += A.at(i);
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    S -= A.at(i);
    ans += (((S % MOD) * A.at(i)) % MOD);
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4832
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		sc.close();
		System.out.println((H-h)*(W-w));
	}

}

Measured memory_bytes: 35756
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N,x;
      cin>>N>>x;
      int count=0;
      vector<int>a(N);
      for(int i=0;i<N;i++){
        cin>>a.at(i);}
      sort(a.begin(),a.end());
      for(int i=0;i<N;i++){
      if(i==N-1&&x>a.at(i)){break;}
      else if(x>=a.at(i)){x-=a.at(i);count++;} 
      } 
      cout<<count<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<cstring>
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#define ll long long
using namespace std;

int main()
{
	string s;
	cin>>s;
	int n;
	scanf("%d",&n);
	int  tot=0,sp=0;
	int fl=0;
	while(n--)
	{
		int f;
		scanf("%d",&f);
		if(f==1) 
		{
			tot++;
			sp++;
		}
		else 
		{
			int t;
			scanf("%d",&t);
			char c;
			scanf(" %c",&c);
			if(fl==0)
			{
				if(tot%2==0)
				{
					if(t==2) s.push_back(c);
					else 
					{
						string cc;
						cc.push_back(c);
						s.insert(0,cc);
					}
				}
				else 
				{
					if(t==1) s.push_back(c);
					else 
					{
						string cc;
						cc.push_back(c);
						s.insert(0,cc);
					}
					fl=1;
				}
			}
			else
			{
				if(tot%2==0)
				{
					if(t==1) s.push_back(c);
					else 
					{
						string cc;
						cc.push_back(c);
						s.insert(0,cc);
						
					}
				}
				else 
				{
					if(t==2) s.push_back(c);
					else 
					{
						string cc;
						cc.push_back(c);
						s.insert(0,cc);
					}
					fl=0;
				}
			}
			tot=0;
		}
	}
	if(sp&1) reverse(s.begin(),s.end());
	cout<<s<<endl;
    return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
using namespace std;

using ll = long long;
using ii = pair<ll, ll>;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    string s;
    cin >> s;

    int left = 0, right = 0;

    string ans = s;

    rep(i, n) {
        if (s[i] == '(') {
            left++;
        } else {
            right++;
        }

        if (right > left) {
            ans = "(" + ans;
            left++;
        }
    }

    int count = max(0, left - right);
    rep(i, count) { ans += ")"; }
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define MAX  1e18
#define ss 1e15
#define pb push_back
int a[100005],dp[100005];
int n,m;

lli recur(int x){
    if(x > n)return 0;
    if(x == n)return 1;
    if(dp[x]!=-1)return dp[x];
    
    if(a[x] == 1)return 0;
    return dp[x] = (recur(x+1)%mod + recur(x+2)%mod)%mod;
}

int main() {
    for(int i=0;i<=100000;i++){
        a[i] = 0;
        dp[i] = -1;
    }
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        a[x] = 1;
    }
    lli ans = recur(0);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 4096
from collections import defaultdict


def readln():
    return list(map(int, input().split()))


N = readln()[0]
S = input()
mod = 10**9+7

dic = defaultdict(lambda: 0)
for s in S:
    dic[s] += 1
ans = 1
for count in dic.values():
    # print(count)
    ans *= (count + 1)

# print(ans)
print((ans-1) % mod)


Measured memory_bytes: 3444
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(a,b,c);
    cout << a+b+c - max(a,max(b,c)) << nn;
    return 0;
}

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


int main()
{
	int max,k,val,v,f,i;
	cin>>k>>val;
	max=k*4;
	if(val>max || val<2)
		cout<<"No";
	else
	{
		f=0;
		for(i=0;i<k;i++)
		{
			v=2*(k-i)+4*(i);
			if(val%v==0)
			{
				f=1;
				break;
			}
		}
		if(f==1)
			cout<<"Yes";
		else
			cout<<"No";
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 200010;
int nowarn;

char str[MAXN];
int n, a[MAXN], cnt[26] = {0};

void input() {
	nowarn = scanf( "%s", str );
	n = (int)strlen(str);
	for( int i = 0; i < n; ++i )
		++cnt[a[i] = str[i] - 'a'];
}

void solve() {
	ll ans = 0;
	for( int i = 0; i < n; ++i ) {
		ans += n - i - cnt[a[i]];
		--cnt[a[i]];
	}
	printf( "%lld\n", ans+1 );
}

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


Measured memory_bytes: 1280
/*
*/

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

int main() {
    ll n;
    std::cin >> n;
    vector<bool> same(n);
    for (int i = 0; i < n; i++) {
        ll tmp;
        std::cin >> tmp;
        tmp--;
        if(i == tmp){
            same[i] = true;
        }else{
            same[i] = false;
        }
    }
    
    ll result = 0;
    
    for (int i = 0; i < n; i++) {
        if( same[i] ){
            same[i] = false;
            if(i<n-1){
                same[i+1] = false;
            }
            result++;
        }
    }
    std::cout << result << std::endl;
}



Measured memory_bytes: 256
import sys
n = int(input())
h = list(map(int,input().split())) #input from array of integer like "1 2 3"

for i in range(n-1):
  x = h[i+1]-h[i]
  if x > 0:
    h[i+1] = h[i+1]-1
  elif x < 0:
    print("No")
    sys.exit()
print("Yes")


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ull> vul;
typedef complex<double> P;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) REP(i,v.size())cout<<#v<<"["<<i<<"]: "<<v[i]<<endl
#define ALL(a) (a).begin(),(a).end()

// suffix-array????????????????????????????????????????????????

string s;
int len;

const ull B = 100000007;
vul sh(1000001);
vul bs(1000001);
// arihon P.333

void makeHash(){
  bs[0] = 1;
  REPR(i,len+1)bs[i]=bs[i-1]*B;
  sh[0] = 0;
  REPR(i,len+1)sh[i]=sh[i-1]*B+s[i-1];
}

ull getHash(int left,int right){
  if(left == 0)return sh[right];
  return sh[right]-sh[left]*bs[right-left];
}

bool equal(int from, int tlen, int to){
  // ??????????????°???????????\??????
  ull ah = getHash(from,from+tlen);
  ull bh = getHash(to,  to+tlen  );
  return ah==bh;
}

bool check(int lena, int lenb){
  // if(lena<=0 || lenb<=0)return false;

  // A in center
  if( !equal(0,lena,lena+lenb) )return false;
  if( !equal(0,lena,2*(lena+lenb)))return false;

  // B
  if( !equal(lena,lenb,2*lena+lenb)) return false;
  return true;
}

int main(){
  cin>>s;
  len = s.size();
  makeHash();

  int minlenab = len;
  string WA = "mitomerarenaiWA";
  int result = len;
  // ABABA -> 3*A+2*B
  REPR(lena,len/3+1){
    if((len-(lena*3))%2!=0)continue;
    int lenb = (len-(lena*3))/2;
    if(lena<=0 || lenb<=0)continue;
    if(lena+lenb>minlenab)continue;

    if(check(lena,lenb)){
      minlenab = lena+lenb;
      result = lena+lenb;
    }
    // bool ok = true;
    // REP(_,2)REP(i,lena){
    //   if(s[i]!=s[(lena+lenb)*(_+1)+i])ok=false;
    //   if(!ok)break;
    // }
    // REP(i,lenb){
    //   if(s[lena+i]!=s[lena*2+lenb+i])ok=false;
    //   if(!ok)break;
    // }
    // if(ok){
    //   minlenab = lena+lenb;
    //   result = lena+lenb;
    // }
  }
  if(result==len)cout<<WA<<endl;
  else cout<<"Love "<<s.substr(0,result)<<"!"<<endl;
  return 0;
}

Measured memory_bytes: 18204
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll V[51];
int to[102], ne[102], he[51];
void dfs(int p, ll v, int mae) {
	V[p] = v >> 1;
	for (int q = he[p]; q; q = ne[q]) {
		int To = to[q];
		if (mae != To) {
			v ^= 1ll << (q >> 1);
			dfs(To, v, p);
			v ^= 1ll << (q >> 1);
		}
	}
}

//包除原理でもできるらしいのでがんばる
int N, M;
int kazoeru[51];
ll seiyaku[20];
void keisan(int i, bool k, ll are) {
	if (i == M) {
		kazoeru[__builtin_popcountll(are)] += 1 - k * 2;
	}
	else {
		keisan(i + 1, k, are);
		keisan(i + 1, !k, are | seiyaku[i]);
	}
}

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


	scanf("%d", &N);
	int kari = 2;
	rep(i, N - 1) {
		int a, b;
		scanf("%d %d", &a, &b);
		to[kari] = b;
		ne[kari] = he[a];
		he[a] = kari++;
		to[kari] = a;
		ne[kari] = he[b];
		he[b] = kari++;
	}

	dfs(1, 0, 0);

	scanf("%d", &M);
	rep(i, M) {
		int u, v;
		scanf("%d %d", &u, &v);
		seiyaku[i] = V[u] ^ V[v];
	}

	keisan(0, 1, 0);

	ll kotae = 0;
	rep1(i, N) {
		ll tmp = (1ll << N - 1) - (1ll << (N - i - 1));
		kotae += tmp * kazoeru[i];
	}
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 128