akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int[] A = new int[N+1];
    int[] B = new int[N];
    for (int i = 1; i <= N; i++) {
      A[i] = sc.nextInt();
      B[i-1] = A[i] - i;
    }
    Arrays.sort(B);
    System.out.println(calc(A, B[N/2]));
  }
  
  private static long calc(int[] A, int b) {
    long ret = 0;
    for (int i = 1; i < A.length; i++) {
      ret += Math.abs(A[i] - (b + i));
    }
    return ret;
  }
}

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

using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if(a%3==0)
	{
		cout<<"Possible"<<endl;
		return 0;
	}
	if(b%3==0)
	{
		cout<<"Possible"<<endl;
		return 0;
	}
	if((a+b)%3==0)
	{
		cout<<"Possible"<<endl;
		return 0;
	}
	cout<<"Impossible"<<endl;
	return 0;
}


Measured memory_bytes: 256
s = input()

year = int(s[:4])
month = int(s[5:7])
day = int(s[8:])

if year == 2019 and month == 4 and day <= 30:
    print("Heisei")
elif year == 2019 and month < 4:
    print("Heisei")
elif year <= 2018:
    print("Heisei")
else:
    print("TBD")

    

Measured memory_bytes: 2940
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    if(s=="abc" || s=="acb" ||s=="bac" ||s=="bca" ||s=="cab" ||s=="cba") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const char* solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& i : a) cin >> i;
    sort(a.begin(), a.end());
    for (int i = 1; i < a.size(); i++) if (a[i] == a[i - 1]) return "NO";
    return "YES";
}
int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 1024
/**So..a**/
#include<bits/stdc++.h>
//#include <chrono>
// Success after trying 5 hour 11 minute :(


using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define PB(x, v) x.push_back(v);
#define M_P(a, b) make_pair(a, b)
#define pll pair<ll, ll>
#define ll long long
#define mll map<ll, ll>
#define vl vector<ll>
#define fa(x, v) for(auto x: v)
#define fr(i, a, b) for(ll i= a;i <=b; i++)
#define TEST  int test; cin >> test; while(test--)
#define FTEST int TesT; cin >> TesT; for(int test = 1; test<=TesT; test++)

#define B_ begin()
#define E_ end()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define NL_ "\n"
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second

#define MOD 1000000000+7
#define  ull unsigned long long



int main()
{

    int n;
    scanf("%d", &n);
    int cnt =0;
    bool ok  = 0;
    int a, b;
    fr(i, 1, n)
    {
        scanf("%d%d", &a, &b);
        if(a==b) cnt++;
        else cnt  = 0;
        if(cnt ==3) ok  =1;
    }
    if(ok) printf("Yes");
    else printf("No");


    return 0;
}


Measured memory_bytes: 3784
def prime_decomposition(n):
    i = 2
    dic = {}
    while i * i <= n:
        while n % i == 0:
            n /= i
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
        i += 1
    if n > 1:
        dic[int(n)] = 1
    return dic

N, P = map(int, input().split())
d = prime_decomposition(P)
ret = 1
for k, v in d.items():
    if v >= N:
        ret *= k ** (v//N)
print(ret)

Measured memory_bytes: 3064
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

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

int main() {
  init();

  ll A;
  cin >> A;
  string B;
  cin >> B;

  string b = "";
  rep(i, B.size()) {
    if (B[i] == '.') continue;
    b += B[i];
  }
  ll B_ = stol(b);

  out((A * B_) / 100);
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String  N = scanner.nextLine();
        char alpha = N.charAt(0);
        if (Character.isUpperCase(alpha)) {
            System.out.println("A");

        } else {

            System.out.println("a");
        }

    }
}


Measured memory_bytes: 35760
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = long.Parse(spl[0]);
        var b = long.Parse(spl[1]);
        var c = long.Parse(spl[2]);
        var k = long.Parse(spl[3]);

        var x = 0L;

        x += Math.Min(a, k);
        k -= a;

        if (k <= 0) return x;

        k -= b;
        if (k <= 0) return x;

        x -= k;

        return x;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

int main(void){
    string s;
    cin>>s;
    vector<int> dp(1<<26,1e9);
    dp[0] = 0;
    int bit = 0;
    rep(i,s.size()){
        bit ^= (1<<(s[i]-'a'));
        rep(j,26) dp[bit] = min(dp[bit], dp[bit^(1<<j)]+1);
    }
    cout<<max(1,dp[bit])<<endl;
}


Measured memory_bytes: 262660
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve [x] = head [(a,b) | a <- [-120..120], b <- [-120..120], a^5-b^5==x]

output :: _ -> IO ()
output (a,b) = putStrLn (show a <> " " <> show b)

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine


Measured memory_bytes: 3744
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double n = sc.nextDouble();
    double ans = 0.5;
    if(n % 2 == 1){
      ans = (n+1)/2/n;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> TP;
typedef pair<string, string> PS;

int main() {
  char c;
  cin >> c;
  switch (c) {
  case 'A':
    cout << 'T';
    break;
  case 'T':
    cout << 'A';
    break;
  case 'C':
    cout << 'G';
    break;
  case 'G':
    cout << 'C';
    break;
  }
  cout << endl;
}

Measured memory_bytes: 256
/**
 * File              : F-tutorial.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 28.01.2020
 * Last Modified Date: 28.01.2020
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<vector<int>> adj;


int const MAXN = 51;
int constexpr log(int x) {
    return sizeof(int) * 8 - __builtin_clz(x);
}
// LCA
int const LOG = log(MAXN);
int parent[MAXN][LOG] {};
int depth[MAXN] {};
void build(int u, int p) {
    depth[u] = depth[p] + 1;
    parent[u][0] = p;
    for (int i = 1; i < LOG; i++)
        if (parent[u][i - 1])
            parent[u][i] = parent[parent[u][i - 1]][i - 1];
    for (auto v: adj[u]) {
        if (v == p) continue;
        build(v, u);
    }
}
int lca(int u, int v) {
    if (depth[u] < depth[v])
        swap(u, v);
    // depth[u] >= depth[v];
    for (int i = LOG - 1; i >= 0; --i)
        if (parent[u][i] && depth[parent[u][i]] >= depth[v])
            u = parent[u][i];
    if (u == v)
        return u;
    for (int i = LOG - 1; i >= 0; --i)
        if (parent[u][i] != parent[v][i])
            u = parent[u][i], v = parent[v][i];
    return parent[u][0];
}
// END LCA
// FAST POWER
ll power(ll base, ll pow) {
    ll res = 1;
    while (pow) {
        if (pow&1)
            res *= base;
        base *= base;
        pow >>= 1;
    }
    return res;
}

// END FAST POWER



int main() {
    int n;
    cin >> n;
    adj.resize(n + 1);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int root = 1;
    build(root, 0);

    int m;
    cin >> m;
    vector<ll> rest;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        int p = lca(u, v);
        ll bit = 0; // WORNG : 1<<p
        for(;u != p;u = parent[u][0]) bit |= (1LL << u);
        for(;v != p;v = parent[v][0]) bit |= (1LL << v);
        rest.push_back(bit);
    }

    ll ans = 0; 
    for (int mask = 0; mask < (1<<m); mask++) {
        ll bit = 0;
        for (int i = 0; i < m; i++)
            if (mask &(1 << i))
                bit |= rest[i];
        ll cnt = 1LL<< (n - 1 - __builtin_popcountll(bit)); // WRONG: n - __builtin_popcountll(bit) because 
/*
8
1 2
2 3
4 3
2 5
6 3
6 7
8 6
5
2 7
3 5 <<-
1 6
2 8
7 8 <<-
restriction (3, 5) + (7, 8) is differ
*/
        if (__builtin_popcount(mask) % 2) {
            ans -= cnt;
        } else {
            ans += cnt;
        }
    }
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>


int main(void)
{
	unsigned w, h, x, y;

	while(scanf("%u%u%u%u", &w, &h, &x, &y)==4)
	{
		double s=0.5*w*h;
		int is_multi=0;

		if(x*2==w && y*2==h) is_multi=1;

		printf("%f %d\n", s, is_multi);
	}

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e5+5;
ll inf=1e15;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        string s1,s2;
        cin>>s1>>s2;
        int n=s1.length();
        int m=s2.length();
        int res=m;
        for(int i=0;i+m-1<n;i++){
            int cnt=0;
            for(int j=0;j<m;j++){
                if(s1[i+j]!=s2[j])
                    cnt++;

            }
            res=min(res,cnt);
        }
        cout<<res;
    }

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define mset(a,x) memset(a,x,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define mp make_pair

int n;
string s,t;

void solve(){
    cin>>s>>t;
    vector<string> v;
    v.pb(s);
    rep(i,n){
        v.pb(s + t.substr(i,n-i));
    }

    int ans = 114514;
    for(auto& a : v) {
        int m = a.size();
        if(a.substr(0,n)==s and a.substr(m-n,n)==t) ans = min(ans, m);
    }
    cout<<ans<<"\n";
}

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

    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define INF 2000000000
#define LINF 9000000000000000000


typedef long long int ll;

int gcd(int m, int n) {
    if ((0 == m) || (0 == n))
        return 0;

    while (m != n) {
        if (m > n) m = m - n;
        else n = n - m;
    }
    return m;
}

int main() {
    int x, y;
    cin >> x >> y;
    if (x < y) {
        cout << x << endl;
    } else if (x == y) {
        cout << -1 << endl;
    } else {
        if (gcd(x, y) == y) {
            cout << -1 << endl;
        } else {
            cout << x << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
//cout << setprecision(123);
//a=atoi(S.c_str());
//S=to_string(a);
int main(){
  int N,a=0;
  cin>>N;
  
  for(int i=1;i<10;i++){
  if(N<i*10&&N%i==0)a++;
  
  }
  
  
  if(a==0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
b_nums = [int(i) for i in input().split()]
count = 0
for j in range(N):
    a_nums = [int(k) for k in input().split()]
    eq = 0
    for m in range(M):
        eq += a_nums[m]*b_nums[m]
    if eq > -C:
        count += 1
print(count)

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

const int MAX_V=101010;

int par[MAX_V];
int rnk[MAX_V];
int num[MAX_V];

void init(){
  for(int i=0;i<MAX_V;i++){
    par[i]=i;
    rnk[i]=0;
    num[i]=1;
  }
}

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 (rnk[x] < rnk[y]){
    par[x] = y;
    num[y]+=num[x];
  }else{
    par[y] = x;
    num[x]+=num[y];
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll ans[101010];

int main(){
  init();
  int N,M; cin>>N>>M;
  vector<pair<int,int>> E(M);
  rep(i,M) cin>>E[i].first>>E[i].second;
  
  ll sum=1LL*N*(N-1)/2;
  for(int i=M-1;i>=0;i--){
    ans[i]=max(sum,0LL);
    int pa=find(E[i].first), pb=find(E[i].second);
    if(pa!=pb){
      sum-=1LL*num[pa]*num[pb];
      unite(pa,pb);
    }
  }
  rep(i,M) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 4096
n,m = map(int,input().split())
ab_l = sorted([list(map(int,input().split())) for _ in range(n)])
cnt = 0
ans = 0
for i in range(n):
    ans += ab_l[i][0] * min(ab_l[i][1],m-cnt)
    cnt += ab_l[i][1]
    if cnt >= m:
        print(ans)
        break

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;


int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  cout << ((a - b) % 2 == 0 ? "Alice" : "Borys") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
#define int ll
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>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    vint a(n); vin(a);
    vector<ll> sum(n + 1, 0);
    rep(i, n) sum[i + 1] = sum[i] + a[i];
    ll ans = LLONG_MAX;
    repi(i, 1, n) {
        chmin(ans, abs(sum[i] - (sum.back() - sum[i])));
    }
    cout << ans << endl;

    return 0;
}


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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
using vi  = vector<int>;
using vvi = vector<vi>;

struct die_t{
  int top, front, right, left, back, bottom;
};

#define rotate_swap(x,a,b,c,d) swap(x.a, x.b); swap(x.b, x.c); swap(x.c, x.d);
// topがrightになるよう回転
void rotate_right(die_t& x){ rotate_swap(x,top,left,bottom,right); }
void rotate_left(die_t& x){ rotate_swap(x,top,right,bottom,left); }
void rotate_front(die_t& x){ rotate_swap(x,top,back,bottom,front); }
void rotate_back(die_t& x){ rotate_swap(x,top,front,bottom,back); }
// 上から見て時計回りに回転
void rotate_cw(die_t& x){ rotate_swap(x,back,left,front,right); }
void rotate_ccw(die_t& x){ rotate_swap(x,back,right,front,left); }

die_t makeDice(int t, int f){
  die_t res;
  res.top = t;
  res.bottom = 7-t;
  res.front = f;
  res.back = 7-f;

  if((t==1 and f==3) or (t==3 and f==6) or (t==6 and f==4) or (t==4 and f==1)){
    res.left = 2;
    res.right = 5;
  }else if((t==3 and f==1) or (t==6 and f==3) or (t==4 and f==6) or (t==1 and f==4)){
    res.left = 5;
    res.right = 2;
  }else if((t==2 and f==1) or (t==1 and f==5) or (t==5 and f==6) or (t==6 and f==2)){
    res.left = 3;
    res.right = 4;
  }else if((t==1 and f==2) or (t==5 and f==1) or (t==6 and f==5) or (t==2 and f==6)){
    res.left = 4;
    res.right = 3;
  }else if((t==2 and f==4) or (t==4 and f==5) or (t==5 and f==3) or (t==3 and f==2)){
    res.left = 1;
    res.right = 6;
  }else if((t==4 and f==2) or (t==5 and f==4) or (t==3 and f==5) or (t==2 and f==3)){
    res.left = 6;
    res.right = 1;
  }

  return res;
}

vi dx = {0,1,0,-1}, dy = {1,0,-1,0};
#define SIZE 10

int main(){
  int n;
  while(cin >> n, n){
    // 高さとtopの目
    vvi h(SIZE,vi(SIZE)), ts(SIZE,vi(SIZE,-1));
    
    rep(_,n){
      int t, f;
      cin >> t >> f;

      die_t d = makeDice(t,f);

      int x = SIZE/2, y = SIZE/2;
      while(1){
	int dir, num = -1;
	vi pip = {d.right, d.front, d.left, d.back};
	rep(k,4){
	  int nx = x + dx[k], ny = y + dy[k];
	  if(h[x][y] > h[nx][ny] and pip[k] > max(3,num)){
	    dir = k;
	    num = pip[k];
	  }
	}
	if(num == -1) break; // 転がらない

	x += dx[dir];
	y += dy[dir];
	if(dir == 0){
	  rotate_right(d);
	}else if(dir == 1){
	  rotate_front(d);
	}else if(dir == 2){
	  rotate_left(d);
	}else if(dir == 3){
	  rotate_back(d);
	}
      }
      h[x][y]++;
      ts[x][y] = d.top-1;
    }

    vi ans(6);
    rep(i,SIZE) rep(j,SIZE){
      if(ts[i][j] != -1)
	ans[ts[i][j]]++;
    }
    cout << ans[0];
    FOR(i,1,6) cout << " " << ans[i];
    cout << endl;
  }
}


Measured memory_bytes: 3172
#include <cstdio>
using namespace std;
int main()
{
    int k,sum=0;
    scanf("%d",&k);
    for(int i=2;i<=k;i++)
    {
        if(!(i&1))
        {
            for(int j=1;j<=k;j++)
            if(j&1)
            sum++;
        }
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 256
#!usr/bin/env python3

import sys


def init_matrix_vector():
    m, n = [int(col_row) for col_row in sys.stdin.readline().split()]
    matrix = [[0 for col in range(n)] for row in range(m)]
    vector = [0 for row in range(n)]

    for row in range(m):
        lst = [int(element) for element in sys.stdin.readline().split()]
        for col in range(n):
            matrix[row][col] += lst[col]

    for row in range(n):
        lst = [int(element) for element in sys.stdin.readline().split()]
        vector[row] += lst[0]

    return matrix, vector


def print_matrix_vector_multiplication_result(matrix, vector):
    for row in range(len(matrix)):
        sum_of_row = 0
        for col in range(len(vector)):
            sum_of_row += matrix[row][col] * vector[col]
        print(sum_of_row)


def main():
    matrix, vector = init_matrix_vector()
    print_matrix_vector_multiplication_result(matrix, vector)


if __name__ == '__main__':
    main()

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

using namespace std;

void solve() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  for (int i = 0; i + 2 < n; ++i ) {
    if (
        s[i] == 'A' &&
        s[i + 1] == 'B' &&
        s[i + 2] == 'C') {
      ++cnt;
    }
  }
  cout << cnt << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128
 
long double PI =3.14159265358979323846;
 
 
ll modo=1e9+7;
const ll inf=1e13;
const ll ms=1e5 +5;
int ar[1005][1005]={0};
int dp[1005][1005]={0};


int main()
{
    faf;
    
    int n;
    int m;
    cin>>n>>m;
    int i;
    int j;
    char a;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>a;
            if(a=='#')ar[i][j]=1;
        }
    }
    dp[1][1]=1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(!ar[i][j]){
            if(i==1&&j==1)continue;
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%modo;}
        }
    }
    cout<<dp[n][m];
    return 0;
}

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

int main(){
    int N;
    bool isfour = false;
    cin >> N;
    
    rep(i, N){
        string s;
        cin >> s;
        if (s == "Y"){
            isfour = true;
        }
    }
    if (isfour){
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		ArrayList<Double> list = new ArrayList<Double>();

		while(null != (str=br.readLine())){
			list.add(Double.parseDouble(str));
		}

		Collections.sort(list);

		System.out.println(list.get(list.size()-1) - list.get(0));
	}
}

Measured memory_bytes: 17028
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll X[int(1e5 + 5)], L[int(1e5 + 5)];
Pll RL[int(1e5 + 5)];

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++){
    scanf("%lld%lld", X + i, L + i);
    RL[i] = {X[i] + L[i], X[i] - L[i]};
  }
  sort(RL, RL + N);

  int ans = 1, now = RL[0].fi;
  for (int i = 1; i < N; i++){
    if (now > RL[i].se) continue;
    now = RL[i].fi;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6784
#include<stdio.h>
#include<string.h>
int main()
{	
    int n,k,s;
	int dp[25][160][15];
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for (int i=1;i<=20;i++)
	{
        for (int j=0;j<=155;j++)
		{
            for (int k=0;k<=10;k++)
			{
                dp[i][j][k]=dp[i-1][j][k];
                if(k>0&&j>=i)
				{
					dp[i][j][k]=dp[i][j][k]+dp[i-1][j-i][k-1];
				}
            }
		}
	}
    while (scanf("%d%d%d",&n,&k,&s)!=EOF&&n!=0&&k!=0&&s!=0)
	{
		printf("%d\n",dp[n][s][k]);
	}
	return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
        int H, W;
        cin >> H >> W;
        vector<vector<char>> a(H+2, vector<char>(W+2, '#'));
        for (int i = 0; i < H; ++i) {
                string s;
                cin >> s;
                for (int j = 0; j < s.length(); ++j) {
                        a[i+1][j+1] = s[j];
                }
        }
        for (int i = 0; i < H+2; ++i) {
                for (int j = 0; j < W+2; ++j) {
                        cout <<  a[i][j];
                }
                cout << endl;
        }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

template <typename T>
using lim = numeric_limits<T>;

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

	unordered_map<int,int> um;
	for (int i = 0; i < 3; i++){
		int a; cin >> a;
		um[a]++;
	}

	if (um[5] == 2 and um[7] == 1) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12

li dp(vector<vector<li>> &mem, int pos, li current, li sum, li &ans, string &s) {
  if (pos == s.size()) {
    ans += sum;
    return 0;
  }
  current = current * 10 + s[pos] - '0';
  dp(mem, pos + 1, 0, sum + current, ans, s);
  if (pos < s.size() - 1)
    dp(mem, pos + 1, current, sum, ans, s);
  return 0;
}

void _main(int tc) {
  string s;
  cin >> s;
  vector<vector<li>> mem(s.size() + 1, vector<li>(2, -1));
  li ans = 0;
  dp(mem, 0, 0, 0, ans, s);
  cout << (ans) << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
 vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x;
 while (getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
 template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}
//

int T;

const int mod = 1e9 + 7;
const int N = 2e5 + 10;
int n;
int a[N];

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (cin >> n)
    {
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            a[i] -= (i + 1);
        }
        sort(a, a + n);
        int v = a[n / 2];
        LL ans = 0;
        for (int i = 0; i < n; i++)
        {
            ans += abs(v - a[i]);
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int n;
  n = S.length();
  if(S.at(n-1)=='s'){
    cout << S << "es" << endl;
  }
  else{
    cout << S << "s" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll A, B;
ll t;
ll ret = 0;

void input() {
  IN(A);
  IN(B);
}

void solve() {
  if (A<10 && B<10) {
    PRINT(A*B);
  } else {
    PRINT(-1);
  }
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; ++i)
#define per(i, a, n)  for(int i=n-1; i>=a; --i)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 1000000007
using namespace std;
typedef long long ll;

int main(){
  const int N = 5;
  vector<int> dish(N);
  vector<int> delay(N);
  int ans = 0;
  rep(i, 0, N)  {
    cin >> dish[i];
    delay[i] = dish[i]%10==0? 0 : 10-dish[i]%10;
  }

  sort(all(delay));
  ans = accumulate(all(dish), 0) + accumulate(delay.begin(), delay.end()-1, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{ ll a,b,c,d;
cin>>a>>b>>c>>d;
ll aa=a*c;
ll bb=b*c;
ll cc=a*d;
ll dd=b*d;
ll m=max(aa,bb);
ll e=max(cc,dd);
cout<<max(m,e);
    
    
    
  return 0;
}



Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(' ');
            var n = int.Parse(nk[0]);
            var k = double.Parse(nk[1]);
            double result = 0.0;
            foreach(var i in Enumerable.Range(1, n))
            {
                double tmp = 1.0 / n;
                int point = i;
                while (point < k)
                {
                    point *= 2;
                    tmp *= 0.5;
                }
                result += tmp;
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13268
'use strict';
function main(input) {
  input = input.split(" ");
  const K = Number(input[0]);
  const X = Number(input[1]);
  let rtn = [];
  
  const a = X - (K-1);
  const b = X + (K-1);
  
  for(let i=a; i<=b; i++){
  	rtn += i +" ";
  }
  console.log(rtn);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector <int> c(n);


    for (int i = 0; i < n; i++) cin >> c[i];

    int dist = 0;
    for (int i = 0; i < n; i++)
    {
        dist += 2*min(c[i], abs(k-c[i]));
    }
    cout << dist << '\n';
    return 0;
}



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

using namespace std;
using namespace __gnu_pbds;

const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define vin(v, N) vi v; rep(i, N) {int x; cin >> x; v.push_back(x);}

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

const int MAX_N = 1e5 + 5;

void solve() {
    string s;
    cin >> s;
    if (s[s.size()-1] == 's') {
        s += "es";
    } else {
        s += "s";
    }
    cout <<s;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a[100010],x=0;
	cin >> n;
	REP(i,n){
		scanf("%d",&a[i]);
		a[i]--;
	}
	REP(i,n){
		if(x==1){
			cout << i << endl;
			return 0;
		}
		x = a[x];
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

int main(){
    int N, M; cin >> N >> M;
    vector<ll> s(N+1), t(M+1);
    for(int i=1; i<=N; ++i) cin >> s[i];
    for(int i=1; i<=M; ++i) cin >> t[i];

    vector<vector<ll>> a(2010, vector<ll>(2020, 0));
    vector<vector<ll>> sum(2020, vector<ll>(2020, 0));

    for(int i=1; i<=N; ++i){
        for(int j=1; j<=M; ++j){
            if(s[i] == t[j]){
                a[i][j] = sum[i-1][j-1]+1;
                a[i][j] %= mod;
            }
            else{
                a[i][j] = 0;
            }
            sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + a[i][j] + mod;
            sum[i][j] %= mod;
        }
    }

    cout << sum[N][M]+1 << endl;
}

Measured memory_bytes: 64128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b))?(b):(a))
#define chmin(a, b) a = (((a)<(b))?(a):(b))

const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}

signed main(){
  int n; cin>>n;
  VI t(n+1,0), x(n+1,0), y(n+1,0); rep(i,n) cin>>t[i+1]>>x[i+1]>>y[i+1];
  reps(i,n){
    int dt = t[i]-t[i-1], dx = abs(x[i]-x[i-1]), dy = abs(y[i]-y[i-1]);
    if(dx>dt||dy>dt) return cout<<"No"<<endl,0;
    if((dx+dy)%2!=dt%2) return cout<<"No"<<endl,0;
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#define rep(i, n) for(int i = 0; i < (n); ++i)

int p[11][11];
int main()
{
	int dx[] = { -1, 0, 0, 1, -1, -1, 1, 1, -2, 0, 0, 2 };
	int dy[] = { 0, -1, 1, 0, -1, 1, -1, 1, 0, -2, 2, 0 };
	int x, y, s;
	rep(i, 10) rep(j, 10) p[i][j] = 0;
	while (scanf("%d,%d,%d", &x, &y, &s) == 3) {
		p[y][x]++;
		rep(i, 4 * s) {
			int r = y + dy[i];
			int c = x + dx[i];
			if (r < 0 || r > 9 || c < 0 || c > 9) continue;
			p[r][c]++;
		}
	}
	int c = 0, best = 0;
	rep(i, 10) rep(j, 10) {
		if (p[i][j] == 0) c++;
		if (best < p[i][j]) best = p[i][j];
	}
	printf("%d\n%d\n", c, best);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;

	int a;
	cin >> a;
	cout << 48 - a << rt;

	please AC;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int n;
  cin>>n;
  n%=7;
  string a;
  if(n==1) a="fri";
  if(n==2) a="sat";
  if(n==3) a="sun";
  if(n==4) a="mon";
  if(n==5) a="tue";
  if(n==6) a="wed";
  if(n==0) a="thu";
  cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll w = 0, ans = 0;
    ll tmp = 0;
    for(int i = s.size() - 1; i >= 0; i--)
    {
        if(s[i] == 'W') w++; 
        if(s[i] == 'B')
        {
            ans += w;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 720
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        String s[] = new String[n];
        int count[] = new int[n];
        for(int i = 0; i < n; i++){
        	s[i] = sc.next();
            count[i] = 0;
        }
        Arrays.sort(s);
        int max = 0;
        for(int i = 0; i < n; i++){
        	for(int j = i + 1; j < n; j++){
            	if(s[i].equals(s[j])){
                	count[i]++;
                }else{
                	break;
                }
            }
            max = Math.max(max, count[i]);
            i += count[i];
        }
        for(int i = 0; i < n; i++){
        	if(count[i] == max){
            	System.out.println(s[i]);
            }
        }
    }
} 

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

typedef pair<int, int> pii;
const int MX = 200020;
int N, M;
vector<pii> seg;

struct BIT {
    vector<int> tree, lazy;
    void init() {
        tree = vector<int>(4*MX, 0);
        lazy = vector<int>(4*MX, 0);
    }
    void prop(int l, int r, int n) {
        if(l != r) {
            tree[2*n] += lazy[n];
            lazy[2*n] += lazy[n];
            tree[2*n + 1] += lazy[n];
            lazy[2*n + 1] += lazy[n];
            lazy[n] = 0;
        }
    }
    void upd(int a, int b, int val, int l, int r, int n) {
        if(b < l || r < a) return;
        if(a <= l && r <= b) {
            tree[n] += val;
            lazy[n] += val;
            return;
        }
        prop(l, r, n);
        int m = (l + r)>>1;
        upd(a, b, val, l, m, 2*n);
        upd(a, b, val, m + 1, r, 2*n + 1);
        tree[n] = max(tree[2*n], tree[2*n + 1]);
    }
    int quer(int a, int b, int l, int r, int n) {
        if(b < l || r < a) return -1e9;
        if(a <= l && r <= b) return tree[n];
        prop(l, r, n);
        int m = (l + r)>>1;
        int L = quer(a, b, l, m, 2*n);
        int R = quer(a, b, m + 1, r, 2*n + 1);
        return max(L, R);
    }
} bit;

int main() {
    scanf("%d %d", &N, &M);
    seg.resize(N);
    for(int i = 0; i < N; i++) {
        int l, r; scanf("%d %d", &l, &r);
        seg[i] = pii(l, r);
    }

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

    bit.init();
    for(int i = 1; i <= M; i++) {
        bit.upd(i, i, -(M + 1 - i), 0, MX - 1, 1);
    }

    int pos = 0;
    int ans = min(N, M);
    for(int i = 0; i <= M; i++) {
        while(pos < seg.size() && seg[pos].first == i) {
            bit.upd(0, seg[pos].second, 1, 0, MX - 1, 1);
            pos++;
        }

        ans = min(ans, N + i - bit.quer(i + 1, M + 1, 0, MX - 1, 1));
    }
    printf("%d", N - ans);
}


Measured memory_bytes: 8064
n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
# 整数の入力
a, b = map(int, input().split())

result = 1
socket = a
if b == 1:
    result = 0
else:
    result = 1

if socket < b:
    for i in range(20):
        socket += a-1
        result += 1
        if socket >= b:
            break
print(result)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()

#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	string s, t; cin>>s>>t;
	t.pop_back();
	if(s == t){
		cout<<"Yes";
	}
	else cout<<"No\n";
}


Measured memory_bytes: 3648