akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

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

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













class unionfind {
private:
    vector<int> par;
    vector<int> rank;
    vector<int> counter;
public:
    unionfind(int n) : rank(n), counter(n, 1){
        for(int i = 0; i < n; i++){
            par.push_back(i);
        }
    }
    
    int find(int x){
        if (par[x] == x) {
            return x;
        }
        else {
            return par[x] = find(par[x]);
        }
    }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        
        if (rank[x] < rank[y]) {
            counter[y] += counter[x];
            counter[x] = counter[y];
            par[x] = y;
        }
        else {
            counter[y] += counter[x];
            counter[x] = counter[y];
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }
    
    ll count(int x){
        return counter[find(x)];
    }
};


int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    unionfind uni(n);
    vector<set<ll>> v(n);
    REP(i, m){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        uni.unite(a, b);
        v[a].insert(b);
        v[b].insert(a);
    }
    vector<ll> ans(n);
    REP(i, n){
        ans[i] = uni.count(i) - 1 - v[i].size();
    }
    REP(i, k){
        ll c, d;
        cin >> c >> d;
        c--; d--;
        if(uni.same(c, d)){
            ans[c]--;
            ans[d]--;
        }
    }
    REP(i, n){
        cout << ans[i] << " \n"[i == n - 1];
    }
}

Measured memory_bytes: 16888
/*
#include<iostream>
using namespace std;

int A[2000005], B[2000005], C[10005];

void CountingSort(int n) {
    int k = 10000;
    for (int i = 0; i <= k; i++) C[i] = 0;

    for (int j = 0; j < n; j++) C[A[j]]++;

    for (int i = 1; i <= k; i++) C[i] += C[i - 1];

    for (int j = n - 1; j >= 0; j--) {
        B[C[A[j]] - 1] = A[j];
        C[A[j]]--;
    } 
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    CountingSort(n);
    for (int i = 0; i < n; i++) cout << B[i] << (i != n - 1 ? " " : "\n");
}
*/

#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
    unsigned short *A, *B;

    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);

    A = (unsigned short *)malloc(sizeof(unsigned short) * (n + 1));
    B = (unsigned short *)malloc(sizeof(unsigned short) * (n + 1));

    for (i = 0; i <= VMAX; i++) C[i] = 0;

    for (i = 0; i < n; i++) {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }

    for (i = 1; i <= VMAX; i++) C[i] = C[i] + C[i - 1];

    for (j = 1; j <= n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--; 
    }

    for (i = 1; i <= n; i++) {
        if (i > 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 10440
#include<bits/stdc++.h>
using namespace  std;
int main ()
{
	string s,a;
	cin>>s>>a;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=a[i])
		{
			cout<<"No";
			return 0;
		}
	} 
	cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 3608
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){
    return ((n + d -1) / d);
}
/*
inline double Sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
*/
// }}}

bool f(int n,int m,int v){
    if(n >= v){
        n -= v;
        m -= v * 2;
    }else{
        m -= (v - n) * 2;
        m -= v * 2;
    }
    return (m >= 0);
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;

    int low = 0,high = 1e12;
    while(high - low > 1){
        int mid = (high + low) / 2;
        if(f(n,m,mid)) low = mid;
        else high = mid;
    }

    cout << low << '\n';

    return 0;
}


Measured memory_bytes: 256
MOD = 1000000007
lim = 200000
inv_t = [-1 for i in range(lim+1)]
factrial = [-1 for i in range(lim+1)]
factrial_inv = [-1 for i in range(lim+1)]


def set_inv(max=lim):
    inv_t[0] = 0
    for i in range(1, max):
        inv_t[i] == mod_inv(i)


def mod_inv(x, mod=MOD):
    y, u, v, _x = mod, 1, 0, x
    while y:
        t = _x//y
        _x -= t*y
        _x, y = y, _x
        u -= t*v
        u, v = v, u
    u %= mod
    if u < 0:
        u += mod
    return u


def mod_pow(a, n, mod=MOD):
    res = 1
    while n:
        if n & 1:
            res = res*a % mod
        a = a*a % mod
        n >>= 1
    return res


def set_factrial(max=lim, mod=MOD):
    c = 1
    factrial[0] = factrial_inv[0] = 1
    for i in range(1, max):
        c *= i
        c %= mod
        factrial[i] = c
        factrial_inv[i] = mod_inv(c, mod)


def comb(a, b, mod=MOD):
    if factrial[0] == -1:
        set_factrial()
    return (factrial[a]*factrial_inv[b]*factrial_inv[a-b]) % mod


N = n = int(input())
s = [input() for i in range(2)]

ret = []
i = 0
while i < N:
    if s[0][i] == s[1][i]:
        ret.append(1)
        i += 1
    else:
        ret.append(2)
        i += 2
ans = 3*ret[0]
for i in range(1, len(ret)):
    if ret[i-1] == 1 and ret[i] == 1:
        ans *= 2
    elif ret[i-1] == 1 and ret[i] == 2:
        ans *= 2
    elif ret[i-1] == 2 and ret[i] == 1:
        ans *= 1
    elif ret[i-1] == 2 and ret[i] == 2:
        ans *= 3
    ans %= MOD

print(ans)
# print(ret)


Measured memory_bytes: 8008
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	int count;
	int n;
	
	while (scanf("%d", &n) != EOF){
		count = 0;
		for (a = 0; a <= 9; a++){
			for (b = 0; b <= 9; b++){
				for (c = 0; c <= 9; c++){
					for (d = 0; d <= 9; d++){
						if (a + b + c + d == n){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 596
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N = i_inpl()
    S1, S2 = input(), input()

    l = []
    i = 0
    while True:
        if S1[i] == S2[i]:
            l.append("X")
        else:
            l.append("Y")
            i += 1
        i += 1
        if i >= N:
            break

    if l[0] == "X":
        ans = 3
    else:
        ans = 6

    for i in range(1, len(l)):
        if l[i-1] == "X" and l[i] == "Y":
            ans *= 2
        elif l[i-1] == "X" and l[i] == "X":
            ans *= 2
        elif l[i-1] == "Y" and l[i] == "Y":
            ans *= 3
        elif l[i-1] == "X" and l[i] == "Y":
            ans *= 1
        ans %= MOD

    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N,rs=0,max=0;
    cin >> N;
    vector<ll> H(N);

    for(ll i = 0;i < N;i++)
        cin >> H.at(i);

    for(ll i = 0;i < N -1;i++){
        if(H.at(i) >= H.at(i+1)){
            rs++;
        }else{
            if(rs > max)
                max = rs;
            rs = 0;
        }
        if(i == N -2){
            if(rs > max)
                max = rs;
        }
    }

    cout << max << endl;    

}

Measured memory_bytes: 4032
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <vector>
#include <array>
#include <cmath>
#include <queue>

#define r(i, v, n) for(int i = v; i < n; i++)
#define re(i, v, n) for(int i = v; i <= n; i++)
#define rr(e, v) for(auto&& (e) : (v))

using namespace std;
using ll = long long;
using ul = unsigned long;

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

    int a = 1;
    r(i, 0, n) {
        if(a < k) {
            a *= 2;
        } else {
            a += k;
        }
    }
    cout << a;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

#define size_t int

using namespace std;
typedef unsigned long ul;
typedef unsigned long long ull;

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

  int n,k;
  std::cin >> n >> k;
  int d[k];
  for (int i = 0; i < k; i++) {
    cin >> d[i];
  }

  for(; ; n++){
    string nstr = to_string(n);
    for (size_t i = 0; i < k; i++) {
      if(nstr.find(to_string(d[i])) != string::npos){
        break;
      }
      if(i == k-1){
        std::cout << n << '\n';
        return 0;
      }
    }
  }

  return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N,K;
signed main() {
    cin>>N>>K;
    if(N%K==0)cout<<0<<endl;
    else cout<<1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc002_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M;
  cin >> N >> M;

  vector<int> c(N, 1);
  vector<bool> possible(N, false);
  possible[0] = true;
  rep(i, M) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;

    if (possible[x]) {
      possible[y] = true;
    }
    c[y]++;
    c[x]--;
    if (!c[x]) possible[x] = false;
 }

  ll ans = 0;
  rep(i, N) {
    if (possible[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3680
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Monoid
import Data.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS

main = do
  [n,q] <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
  edges <- VU.replicateM (n-1) $ do
    [a,b] <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    return (a-1,b-1)
  operations <- VU.replicateM q $ do
    [p,x] <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    return (p-1,x)
  let graph :: V.Vector [Int]
      graph = V.create $ do
        vec <- VM.replicate n []
        VU.forM_ edges $ \(a,b) -> do
          VM.modify vec (b:) a
          VM.modify vec (a:) b
        return vec
      values :: VU.Vector Int
      values = VU.create $ do
        vec <- VUM.replicate n 0
        VU.forM_ operations $ \(p,x) -> 
          VUM.modify vec (+ x) p
        return vec
      result :: VU.Vector Int
      result = VU.create $ do
        vec <- VUM.new n
        let dfs !parent !q !acc = do
              let !acc' = acc + values VU.! q
              VUM.write vec q acc'
              forM_ (graph V.! q) $ \i ->
                when (i /= parent) $
                  dfs q i acc'
        dfs (-1) 0 0
        return vec
  mapM_ print $ VU.toList result

Measured memory_bytes: 45052
n = gets.to_i
a = gets.split.map(&:to_i)
o = []
0.step(n - 1, 2) do |i|
  o.push(a[i])
end
e = []
1.step(n - 1, 2) do |i|
  e.push(a[i])
end
if n % 2 == 0
  puts (e.reverse + o).join(" ")
else
  puts (o.reverse + e).join(" ")
end


Measured memory_bytes: 27708
#!/usr/bin/env python3
import sys
from collections import defaultdict, deque

inf = float('inf')


class Dinic(object):
    def __init__(self):
        self.V = set()
        self.adj = defaultdict(list)
        self.c = defaultdict(lambda: 0)
        self.f = defaultdict(lambda: 0)
        self.iter = defaultdict(lambda: 0)
    
    def add_edge(self, u, v, cap):
        self.V.add(u)
        self.V.add(v)
        self.adj[u].append(v)
        self.adj[v].append(u)
        self.c[(u, v)] = cap
    
    def bfs(self, s):
        self.level = {v: inf for v in self.V}
        self.level[s] = 0
        Q = deque([s])
        while len(Q) > 0:
            u = Q.popleft()
            for v in self.adj[u]:
                if self.c[(u, v)] <= 0:
                    continue
                if self.level[v] <= self.level[u]:
                    continue
                self.level[v] = self.level[u] + 1
                Q.append(v)
    
    def dfs(self, u, t, mincap):
        if u == t:
            return mincap

        for i in range(self.iter[u], len(self.adj[u])):
            self.iter[u] = i
            v = self.adj[u][i]
            if self.c[(u, v)] <= 0:
                continue
            if self.level[v] <= self.level[u]:
                continue
            d = self.dfs(v, t, min(mincap, self.c[(u, v)]))
            if d > 0:
                self.c[(u, v)] -= d
                self.c[(v, u)] += d
                return d
        return 0

    def max_flow(self, s, t):
        flow = 0
        
        while True:
            self.bfs(s)

            if self.level[t] == inf:
                return flow
        
            self.iter = defaultdict(lambda: 0)
            d = self.dfs(s, t, inf)
            while d > 0:
                flow += d
                d = self.dfs(s, t, inf)


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    G = Dinic()
    for xr, yr in zip(a, b):
        G.add_edge(0, (xr, yr), 1)
        for xb, yb in zip(c, d):
            if xr < xb and yr < yb:
                G.add_edge((xr, yr), (xb, yb), 1)
    for xb, yb in zip(c, d):
        G.add_edge((xb, yb), 1, 1)
    print(G.max_flow(0, 1))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]" 
    b = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    c = [int()] * (N)  # type: "List[int]" 
    d = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 51548
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

signed main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1*60+m1;
    int t2 = h2*60+m2;
    cout << (t2-t1) - k << endl;
}

Measured memory_bytes: 3624
#define minupd(v,x)((x)<v?v=(x):0)
D[101][101],b1,b2,c,i,j,k,t,ans;
main(n,m,s,g1,g2){
	for(;scanf("%d%d%d%d%d",&n,&m,&s,&g1,&g2)*n;){
		memset(D,1,sizeof(D));
		for(;m--;){
			scanf("%d%d%d",&b1,&b2,&c);
			D[b1][b2]=c;
			D[b1][b1]=0;
		}
		for(k=n;k;k--)
			for(i=n;i;i--)
				for(j=n;j;j--)
					minupd(D[i][j],D[i][k]+D[k][j]);
		ans=1e9;
		for(i=n;i;i--)
			minupd(ans,D[s][i]+D[i][g1]+D[i][g2]);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 452
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iH = int.Parse(sS[0]);
            int iW = int.Parse(sS[1]);
            sS = System.Console.ReadLine().Trim().Split(' ');
            int ih = int.Parse(sS[0]);
            int iw = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iR = iH * iW - (ih * iW + iw * iH - ih * iw);

            // 出力
            System.Console.WriteLine("{0}", iR.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
  long long  a,b,c;
  cin >> a>> b>> c;
  if(b+c>0){
    cout << (a/(b+c))*b+min(b,a%(b+c))<<endl;
  }else{
  cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

function solve(n){
    return Math.floor(n / 2) + n % 2;
}

function Main(input){
    n = parseInt(input);
    ans = solve(n);
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 20424
#include <iostream>
using namespace std;
int main(){
int n;
cin >> n;
int a[n];
int cnt=0;
for(int i=0;i<n;i++){
cin >> a[i];
while(a[i]%2!=1){
a[i]=a[i]/2;
cnt++;}
}
cout << cnt << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}

int main() {
    ll a;
    cin >> a;
    ll ans = a+pow(a,2)+pow(a,3);
    cout<<ans<<endl;
}
    



Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ACC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mod 1000000007
#define MAXN 10000001
//string alpha="abcdefghijklmnopqrstuvwxyz";
//int dx[]={1,-1,0,0};
//int dy[]={0,0,1,-1};
//int dx8[]={1,-1,0,0,1,1,-1,-1};
//int dy8[]={0,0,1,-1,1,-1,1,-1};
/*int spf[MAXN];
void sieve()
{
	int i,j;
	for(i=0;i<MAXN;i++)
	spf[i]=i;
	for(i=4;i<MAXN;i+=2)
	spf[i]=2;
	for(i=3;i*i<MAXN;i++)
	{
		if(spf[i]==i)
		{
			for(j=i*i;j<MAXN;j+=i)
			{
				if(spf[j]==j)spf[j]=i;
			}
		}
	}
}*/
/*bool isvowel(char c)
{
    switch(c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':return true;
        default : return false;
    }
}*/
/*bool isValid(int x,int y,int n,int m)
{
    if(x<0||x>n-1||y<0||y>m-1)return false;
    return true;
}*/
/*
bool comp(pair<int,int> x,pair<int,int> y)
{
    if(y.second==x.second)
        return y.first<x.first;
    return y.second<x.second;
}*/
int32_t main()
{
    ACC
    int T;
    T=1;
    //cin>>T;
    while(T--)
    {
        int s,j,i;
        cin>>s;
        int dp[s+100];
        dp[0]=1;
        dp[1]=0;
        dp[2]=0;
        dp[3]=1;
        for(i=4;i<=s;i++)
        {
            dp[i]=0;
            int x=0;
            for(j=3;j<=i;j++)
            {
                if(i-j<0)continue;
                x=(x%mod+dp[i-j]%mod)%mod;
            }
            dp[i]=x%mod;
        }
        cout<<dp[s]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c) {
        cout << b + c << endl;
    }
    else {
        cout << b + (a+b+1) << endl;
    }
    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  rep(i,3) {
    if(s[i] == t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3592
n = int(input())
a = [num for num in map(int, input().split())]

# print(n, a)

target = 1
keep = 0
for i in range(n):
  if a[i] == target:
    target += 1
    keep += 1
if keep == 0:
  print(-1)
elif keep == n:
  print(0)
else:
  print(n - keep)

Measured memory_bytes: 77872
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [a,b] <- readInts 
  print $ numOfPlndrm a b

numOfPlndrm
  :: Int -> Int -> Int
numOfPlndrm a b = length [x | x <- [a .. b], isP x]

isP :: Int -> Bool
isP n = c == reverse c
  where
    c = show n

Measured memory_bytes: 892
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int d,n;
	scanf("%d %d",&d,&n);
	if(n==100)n+=1;
	int ans=n*pow(100,d);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
   int n;cin>>n;
   long a[100006];
   for(int i = 0;i<100006;i++) a[i] = 0;
   for(int i = 0;i<n;i++){
    int aa;cin>>aa;
    a[aa]+=1;
   }
   long mg = 0;
   for(int i = 0;i<100006;i++){
     mg+= a[i]*i;
   }
   //cout<<mg;
   int q;cin>>q;
   for(int i = 0;i<q;i++){
     int b,c;cin>>b>>c;
     if(a[b] > 0){
       mg+=(c-b)*a[b];
       //cout<<(c-b)*a[b]<<endl;
       a[c]+=a[b];
       a[b]-=a[b];
     }
     cout<<mg<<endl;
   }
    return 0;
}

Measured memory_bytes: 3924
#include <iostream>
#include <cmath>
#include <limits>
using namespace std;

int main() {
    long double a,b,c;
    cin>>a>>b>>c;
    
//    if(sqrt(a)+sqrt(b)<sqrt(c)){
    if(c-a-b-2*sqrt(a*b)>0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  vll H(N);
  rep(i, N) {
    cin >> H[i];
  }

  repr(i, N - 1) {
    if (i == 0) {
      continue;
    }
    if (H[i - 1] < H[i]) {
      continue;
    } else if (H[i - 1] == H[i]) {
      continue;
    } else if (H[i - 1] - 1 == H[i]) {
      H[i - 1]--;
      continue;
    } else {
      COUT("No");
      return 0;
    }
  }

  COUT("Yes");
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,s,t;
vi a;

bool f(int i){
	return ((s&1<<i)>0^(t&1<<i)>0);
}

int main(){
	cin>>n>>s>>t;
	int cnt=0;
	for(int i=0;i<n;i++) if(f(i)) cnt++;
	if(cnt%2==0){
		cout<<"NO"<<endl;
		return 0;
	}
	int I=0;
	a.push_back(s);
	for(int i=n-1;i>=0;i--){
		int J;
		for(int j=0;j<n;j++) if(!(I&1<<j)&&f(j)){
			J=j;
			I+=1<<J;
			break;
		}
		for(int j=1;j<1<<i;j++){
			for(int k=0;k<i;k++) if(j&1<<k){
				int tmp=0;
				for(int l=0;l<n;l++) if(!(I&1<<l)){
					if(tmp==k){
						s^=1<<l;
						a.push_back(s);
						break;
					}
					tmp++;
				}
				break;
			}
		}
		s^=1<<J;
		a.push_back(s);
	}
	int N=1<<n;
	cout<<"YES"<<endl;
	for(int i=0;i<N;i++) cout<<a[i]<<" \n"[i==N-1];
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, a[101];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	
	int cnt = 0, m = 0;
	for(int i = 0; i < n; i++){
		m = max(m, a[i]);
		if(m <= a[i]) cnt++;
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
import collections

N = int(input())
tree = [[] for _ in range(N)] #i行目には、i番目のマスと隣り合っているマスの番号が加えられる
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

color = [0] * N #色が塗られていなければ0、黒は1、白は-1
color[0] = 1
color[N-1] = -1
que = collections.deque() #色が塗られたマスの番号を、隣り合うマスが全て塗られるまでここに入れる
que.append(0)
que.append(N-1)
while que: #塗るべきマスがなくなるまで繰り返す
    i = que.popleft() #「左から」が重要 #n回でたどり着けるマスはn回目に全て塗って良い
    for x in tree[i]:
        if color[x] == 0:
            color[x] = color[i]
            que.append(x) #塗ったマスは調べるリストに入れる

if sum(color) > 0: #合計が正、つまり黒が多い場合は先手の勝ち
    print("Fennec")
else: #合計が0でも先手の塗るマスがないため後手の勝ち
    print("Snuke")


Measured memory_bytes: 26744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1000000007;

int counts[30][200002];

int main(){
    string A;
    cin >> A;

    memset(counts, 0, sizeof(counts));
    int N = A.size();
    for(int i=0;i<26;i++){
        char c = 'a' + i;
        int v = 0;
        for(int j=N-1;j>=0;j--){
            counts[i][j] = v;
            if(A[j] == c){
                v++;
            }
        }
    }

    ll ans = 0;
    for(int i=0;i<N;i++){
        ans += N - 1 - i - counts[int(A[i] - 'a')][i];
    }
    cout << 1 + ans << endl;

    return 0;
}

Measured memory_bytes: 24068
# coding: utf-8
(n,m,k) = map(int, input().rstrip().split(" "))

for i in range(n + 1):
    for j in range(m + 1):
        cnt = i*m
        cnt += j*n
        cnt -= i*j*2
        if cnt == k:
            print("Yes")
            exit(0)

print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
    int a;
	long long int b,c,d,e;
	cin>>a>>b>>c;
	for(int i=0;i<a-1;i++)
    {
        cin>>d>>e;
        long long int k;
        k=max(b/d,c/e);
        while((d*k)<(b)||(e*k)<(c))
        {
            ++k;
        }
        b=k*d;
        c=k*e;
    }
    cout<< b+c <<endl;
	return 0;
}

Measured memory_bytes: 256
def resolve():
    a, b, c = map(int, input().split())

    ans= 0
    even = []
    odd = []
    for i in [a, b, c]:
        if i % 2== 0:
            even.append(i)
        else:
            odd.append(i)
    if len(even) == 1:
        ans += 1 #奇数に+1
        odd[0] += 1
        odd[1] += 1
        m = max(max(even), odd[0]+1)
        even.extend(odd)
        for i in even:
            ans += (m-i)//2
    elif len(even) == 2:
        ans += 1 #偶数に+１
        even[0] += 1
        even[1] += 1
        m = max(max(even),odd[0])
        even.extend(odd)
        for i in even:
            ans += (m-i)//2
    elif len(even) == 3 or len(odd) == 3:
        m = max(max(even, odd))
        for i in max(even, odd):
            ans += (m-i)//2
    print(ans)
resolve()

Measured memory_bytes: 9196
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
	    void solve(IO io, PrintWriter out)
	    {
           int i, j=0;
           	int n = io.nextInt();
          	int a = io.nextInt();
          	int num=0;
          	if(n>a)
              num= n%a!=0?(n/a)+1:n/a;
          	else
              num=1;
          	out.print(num);
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
}

Measured memory_bytes: 22868
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  bool ans=false;

  rep(i,n){
    string s;
    cin>>s;
    if(s[0]=='Y')ans=true;
  }
  if(ans)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <memory.h>

int main(void) {
	int i, j, k, n, p, size;
	char buff1[202];
	char buff2[202];
	char *ptr1, *ptr2;
	char *ptr;
	
	ptr1 = buff1;
	ptr2 = buff2;
	while(1) {
		fgets(ptr1, sizeof(buff1), stdin);
		if(ptr1[0] == '-')
			break;
		
		/* 改行消す */	
		ptr1[strlen(ptr1)-1] = '\0';
			
		scanf("%d\n", &n);
		for(i=0;i<n;i++) {
			scanf("%d\n", &p);
			memset(ptr2, 0x00, sizeof(buff1));
			for(j=0,size=strlen(ptr1);j<size;j++) {
				if(j+p<size) {
					ptr2[j] = ptr1[j+p];
					k=0;
				} else {
					ptr2[j] = ptr1[k];
					k++;
				}
			}
			ptr = ptr1;
			ptr1 = ptr2;
			ptr2 = ptr;
		}
		printf("%s\n", ptr1);
	}
	
	return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <map>
#include <vector>
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)
            {
                puts("Yes");
                return 0;
            }
        }
    }

    puts("No");
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100001
#define NIL -1
int n;
struct Node{
  int p,l,r;
};
struct Node T[N];

int CalcDepth(int id){
  if(T[id].p==NIL) return 0;
  return CalcDepth(T[id].p)+1;
}

int CalcHeight(int id){
  int i,c,q=0;
  for(i=0;i<n;i++){
    if(T[i].p==id){
      c=1+CalcHeight(i);
      if(q<c) q=c;
    }
  }
    return q;
}

int main(){
  int i,j,id,k,c,pr;
  int sib[N], deg[N], left, right;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    deg[i]=0;
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r=NIL;
    sib[i]=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    if(left!=NIL && right!=NIL){/*There are right and left*/
      deg[id]=2;
      T[id].l=left;
      T[id].r=right;
      T[left].p=id;
      T[right].p=id;
      sib[left]=right;
      sib[right]=left;
    }else if(left!=NIL && right==NIL){/*There is only left*/
      deg[id]=1; 
      T[id].l=left;
      T[left].p=id;
    }else if(left==NIL && right!=NIL){/*There is only right*/
      deg[id]=1; 
      T[id].r=right;
      T[right].p=id;
    }else{/*There is neither*/
      deg[id]=0;
    }
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,T[i].p,sib[i],deg[i],CalcDepth(i),CalcHeight(i));
    if(T[i].p==NIL) printf("root\n"); 
    else if(T[i].l==NIL&&T[i].r==NIL) printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

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

int n, h[N];
ll mx[N << 2], a[N];

void Modify(int l, int r, int x, ll val, int pos) {
    if (l == r) {
        mx[pos] = val;
        return ;
    }
    int mid = (l + r) >> 1;
    if (x <= mid) Modify(l, mid, x, val, pos << 1);
    else Modify(mid + 1, r, x, val, pos << 1 | 1);
    mx[pos] = max(mx[pos << 1], mx[pos << 1 | 1]);
}

inline ll Query(int l, int r, int L, int R, int pos) {
    if (L <= l && r <= R) return mx[pos];
    int mid = (l + r) >> 1;
    ll res = 0;
    if (L <= mid) res = Query(l, mid, L, R, pos << 1);
    if (mid < R) res = max(res, Query(mid + 1, r, L, R, pos << 1 | 1));
    return res;
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n;
    for (int i = 1; i <= n; ++i)
        scanf("%d", h + i);
    for (int i = 1; i <= n; ++i)
        scanf("%lld", a + i);
    for (int i = 1; i <= n; ++i) {
        ll tmp = Query(1, n, 1, h[i], 1);
        Modify(1, n, h[i], tmp + a[i], 1);
    }
    cout << mx[1] << endl;
    return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
int main()
{
 
 
int n;
 cin>>n;
 
char h[10000000];
 cin>>h;
 for(int i=0;i<strlen(h);i++)
 { if(int(h[i])+n>90)
      cout<<char(int(h[i])+n-26);
   else
     cout<<char(int(h[i])+n);
 
 
 
 }


return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF            1e9
#define REP(i,n)       for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n)  for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPR(i,n)      for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(lint i=(n);i>0;--i)
#define REPRI(i,ini,n) for(lint i=(ini)-1,i##_len=(n);i>=i##_len;--i)
#define REPC(i,obj)    for(auto i:obj)
#define R_UP(a,b)      (((a)+(b)-1)/(b))
#define ALL(obj)       (obj).begin(),(obj).end()
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
signed main()
{
	string s = in<string>(), t = in<string>();
	REP(i, s.size())
	{
		rotate(s.begin(), s.begin() + 1, s.end());
		if (s == t)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        while(n-->0){
            String s1 = sc.next(), s2 = sc.next();
            int num = getNumber(s1) + getNumber(s2);
            System.out.println(toMCXI(num));
        }
    }

    String toMCXI(int num){
        String[] ss = {"m","c","x","i"};
        int n = 1000;
        String res = "";
        for(int i=0; i<4; i++){
            if(num/n>=1){
                if(num/n>=2) res += num/n + "";
                res += ss[i];
            }
            num %= n;
            n /= 10;
        }
        return res;
    }

    int getNumber(String s){
        int num = 0;
        char[] c = s.toCharArray();
        for(int i=0; i<c.length; i++){
            if(Character.isDigit(c[i])){
                if(c[i+1]=='m') num += (c[i]-'0') * 1000;
                if(c[i+1]=='c') num += (c[i]-'0') * 100;
                if(c[i+1]=='x') num += (c[i]-'0') * 10;
                if(c[i+1]=='i') num += (c[i]-'0') * 1;
                i++;
            }else{
                if(c[i]=='m') num += 1000;
                if(c[i]=='c') num += 100;
                if(c[i]=='x') num += 10;
                if(c[i]=='i') num += 1;
            }
        }   
        return num;
    }

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

Measured memory_bytes: 25376
#include<cstdio>
using ull = unsigned long long;
 
int main(){
	ull N, M;
	scanf("%llu %llu", &N, &M);
	if(N == 1 && M == 1){
		printf("1\n");
		return 0;
	}
	if(N == 1){
		printf("%d\n", M-2);
		return 0;
	}
	if(M == 1){
		printf("%d\n", N-2);
		return 0;
	}
	printf("%lld\n", (N - 2)*(M - 2));
	return 0;
}

Measured memory_bytes: 1652
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    vector<int> a(3);
    for(int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a[2] - a[1] + a[1] - a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;

ll N;
ll X[100], Y[100], H[100];


ll max(ll a, ll b) {
    if (a >= b) return a;
    return b;
}

bool query(ll x, ll y, ll h) {
    for (ll i = 0; i < N; i++) {
        if (H[i] != max(0, h - abs(X[i]-x) - abs(Y[i]-y))) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> N;
    for (ll i = 0; i < N; i++) {
        cin >> X[i] >> Y[i] >> H[i];
    }
    
    for (ll x = 0; x <= 100; x++) {
        for (ll y = 0; y <= 100; y++) {
            for (ll n = 0; n < N; n++) {
            ll th = H[n] + abs(X[n] - x) + abs(Y[n]-y);
            if (query(x,y,th)) {
                cout << x << " " << y << " " << th << endl;
                return 0;
            }
            }           
        }
    }

}


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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    long A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K % 2){
        cout << B - A << endl;
    }else{
        cout << A - B << endl;
    }
}




Measured memory_bytes: 256
dbflag=""

def debug(*args):
	if ""!=dbflag: print(*args)

if ""!=dbflag: _INDATA=open(dbflag)

def readline():
	if ""!=dbflag:return _INDATA.readline()
	else: return input()


result = -1

c = readline().rstrip()

BOIN = {'a','i','u','e','o'}


if c in BOIN:
	result = "vowel"
else:
	result = "consonant"

print(result)


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

signed main()
{
    ll x,k,d; cin >> x >> k >> d;
    if (x < 0) x *= (-1L); // スタート地点を正にしておく
    ll dv = x / d; // 最初に 0 に近づくほうに移動する回数
    if (dv > k) dv = k;
    x -= dv * d;
    ll remain = k - dv; // 残りの移動回数
    if (remain % 2) // 残りの移動回数が奇数なら
        x -= d;     // もう１回、マイナス側に移動
    if (x < 0) x *= (-1); // abs() って有ったっけ？（忘れた）

    cout << x << endl;
    return 0;
}


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

int main() {
    long long ans = 0;
    int N, K; scanf("%d%d",&N,&K);
    if(K == 0) return !printf("%lld", 1LL*N*N);
    for(int b=K+1; b<=N; b++) {
        ans += ((N - (b-1)) / b + 1) * (b-K);
        if((N - (b-1)) % b != 0) ans += max(N%b - K + 1, 0);
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 256