akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        int ma = 0;
        int mi = 1000;
        cin >> n;

        if(n == 0){
            break;
        }

        int a[n];

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

        sort(a,a+n);

        for(int i = 2;i < n-1;i++){
            a[1] += a[i];
        }

        cout << a[1]/(n-2) << endl;
    }   
 
}

Measured memory_bytes: 1176
function solve(lines: string): void {
  const n = parseInt(lines[0].trim(), 10);
  const xs = lines[1].trim().split(' ').map( (x) => parseInt(x, 10) );
  let ans = 1;
  for (let i = 0; i < n; i++) {
    ans *= 3;
  }
  let pat = 1;
  for (let x of xs) {
    if (x % 2 === 0) {
      pat *= 2;
    }
  }
  ans -= pat;
  console.log(ans);
}
let buf = '';
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
  const s = process.stdin.read();
  if (s !== null) { buf += s.toString(); }
});
process.stdin.on('end', () => {
  solve(buf.trim().split("\n"));
});

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

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define MOD 1000000007

using namespace std;

int main(){
	int A, B;
	int ans = -MOD;
	scanf("%d%d", &A, &B);
	ans = max(ans, A + B);
	ans = max(ans, A - B);
	ans = max(ans, A*B);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	float weight;
	char str[12][30]={"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};
	int r;
	while(~scanf("%f",&weight)){
		if(weight<=48.00) r=0;
		else if(weight <= 51.00) r=1;
		else if(weight <= 54.00) r=2;
		else if(weight <= 57.00) r=3;
		else if(weight <= 60.00) r=4;
		else if(weight <= 64.00) r=5;
		else if(weight <= 69.00) r=6;
		else if(weight <= 75.00) r=7;
		else if(weight <= 81.00) r=8;
		else if(weight <= 91.00) r=9;
		else r=10;
		printf("%s\n",str[r]);
	}
	return 0;
	
}

Measured memory_bytes: 604
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int printkigou(int, char);

int main(void) {
#ifdef DEBUG
	printf("");
#endif

	int A, B;
	int ans;

	scanf("%d %d", &A, &B);
	ans = A + B;
	if (ans >= 10) {
		printf("error\n");
	}
	else {
		printf("%d\n", ans);
	}

	return 0;
}



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

int n,i,arr[3];
string s;

int main(){
	cin>>s;
	n=s.length();
	for(i = 1;i<=n;i++){
		if(s.substr(i - 1,1) == "A"){
			arr[1]++;
		}
		else{
			arr[2]++;
		}
	}
	if(arr[1] == 0 || arr[2] == 0){
		cout<<"No"<<endl;
		
	}
	else{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
///                    BISMILLAHIR RAHMANIR RAHIM

int main()
{
   int n;
   cin>>n;
   string s;
   cin>>s;
   int l=s.length();
   for(int i=0;i<l;i++){
    int r=s[i]+n;
    if(r>90)
        r=r-26;
    printf("%c",(r));
   }
   cout<<endl;

}



/// A L H A M D U L I L L A H


Measured memory_bytes: 3472
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define int long long

signed main(){
	bool ans = false;
	int a, b, k;
	cin >> k >> a >> b;
	for(int i = a; i <= b; i++)if(i%k == 0)ans = true;
	if(ans)cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3604
fun main(args: Array<String>) {
    abc129d()
}

fun abc129d() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val wall = Array(h) { BooleanArray(w) }
    repeat(h) { i ->
        wall[i] = readLine()!!.map { it == '#' }.toBooleanArray()
    }

    // down,up,right,left
    val cSumD = Array(h) { IntArray(w) }
    val cSumU = Array(h) { IntArray(w) }
    val cSumR = Array(h) { IntArray(w) }
    val cSumL = Array(h) { IntArray(w) }

    for (x in 0 until w) {
        for (y in 0 until h) {
            cSumD[y][x] = if (wall[y][x]) 0 else if (y == 0) 1 else cSumD[y - 1][x] + 1
            cSumR[y][x] = if (wall[y][x]) 0 else if (x == 0) 1 else cSumR[y][x - 1] + 1
        }
    }
    for (x in w - 1 downTo 0) {
        for (y in h - 1 downTo 0) {
            cSumU[y][x] = if (wall[y][x]) 0 else if (y == h - 1) 1 else cSumU[y + 1][x] + 1
            cSumL[y][x] = if (wall[y][x]) 0 else if (x == w - 1) 1 else cSumL[y][x + 1] + 1
        }
    }

    var answer = 0

    for (y in 0 until h) {
        for (x in 0 until w) {
            val curr = cSumD[y][x] + cSumU[y][x] + cSumR[y][x] + cSumL[y][x] - 3
            if (curr > answer) answer = curr
        }
    }

    println(answer)
}


Measured memory_bytes: 135432
<?php
//error_reporting(0);
//$S = trim(fgets(STDIN));
list($N,$K,$Q) =  explode(" ",trim(fgets(STDIN)));
//$B = explode(" ",trim(fgets(STDIN)));

$p  = array_fill(0,$N,$K-$Q);

for($i=0;$i<$Q;$i++) {
  $A = trim(fgets(STDIN));
  $p[$A-1]++;
}

foreach($p as $v) {
  printf("%s\n",$v>0?'Yes':'No');
}



Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

template <class T> vector<T> divisor(T N) {
    vector<T> ans;
    if (N == 1) {
        ans.emplace_back(1);
        return ans;
    }
    if (N <= 0) {
        return ans;
    }
    for (long long i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ans.emplace_back(i);
            if (i != 1 && i * i != N) {
                ans.emplace_back(N / i);
            }
        }
    }
    ans.emplace_back(N);
    return ans;
}

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

    ll N;
    scan(N);

    auto div = divisor(N);
    ll ans   = INF64;
    rep(i, div.size()) {
        ll x = div[i] - 1;
        ll y = N / div[i] - 1;
        chmin(ans, x + y);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#define PI 3.14159267
using namespace std;
int main() {
    int x,h,max,num=1;
    cin>>x;
    cin>>h;
    max=h;
    for(int i=1;i<x;++i)
    {
        cin>>h;
        if(h>=max)
        {
            ++num;
            max=h;
        }
    }
    cout<<num<<endl;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    cin>>n;
    vector<double> v;
    rep(i,n){
        double nv;
        cin>>nv;
        v.pb(nv);
    }
    //sort(v.begin(),v.end());
    rep(i,n-1){
        
        sort(v.begin(),v.end());
        //cout<<v[0]<<" "<<v[1]<<endl;
        double x=(v[0]+v[1])/2.0;
        v.erase(v.begin());v.erase(v.begin());
        v.pb(x);
        
    }
    cout<<*v.begin()<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N):
    for j in range(N):
        flg = True
        for k in range(M):
            for l in range(M):
                try:
                    if A[i+k][j+l] != B[k][l]:
                        flg = False
                except IndexError:
                    flg = False
        if flg:
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3064
p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
a=[0 for i in range(len(p))]

n= int(input())
for i in range(n):
  m=i+1
  for j in range(len(p)):
    while m%p[j]==0:
      a[j]+=1
      m=m/p[j]

x=0;y=0;z=0;w=0;u=0
for i in range(len(a)):
  if a[i]>=74:
    x+=1
  if a[i]>=24:
    y+=1
  if a[i]>=14:
    z+=1
  if a[i]>=4:
    w+=1
  if a[i]>=2:
    u+=1
print(int(x+y*(u-1)+z*(w-1)+w*(w-1)/2*(u-2)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define mp make_pair

#define F first
#define S second

using ll = long long;
using namespace std;

void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

const int mod = 1000000007;
const int INF = 1e+9;

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

    sort(h.begin(), h.end());
    int ans = 1000000000;
    int i = 0;
    while (true) {
        if (i + k == n+1) break;
        ans = min(ans, h[k+i-1]-h[i]);
		cerr << h[k+i-1] << endl;
        cerr << "-------" << endl;
        i++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template <typename T> 
struct WeightedUnionFind{
  int n;
  T d;
  vector<int> r,p;
  vector<T> ws;
  WeightedUnionFind(){}
  WeightedUnionFind(int sz,T d_):
    n(sz),d(d_),r(n,1),p(n),ws(n,d){iota(p.begin(),p.end(),0);}
  int find(int x){
    if(x==p[x]){
      return x;
    }else{
      int t=find(p[x]);
      ws[x]+=ws[p[x]];
      return p[x]=t;
    }
  }
  T weight(int x){
    find(x);
    return ws[x];
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y,T w){
    w+=weight(x);
    w-=weight(y);
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y),w=-w;
    r[x]+=r[y];
    p[y]=x;
    ws[y]=w;
  }
  T diff(int x,int y){
    return weight(y)-weight(x);
  }
};
//END CUT HERE
signed AOJ_1330(){
  int n,m;
  while(cin>>n>>m,n||m){
    WeightedUnionFind<Int> u(n,0);
    for(int i=0;i<m;i++){
      int a,b;
      char c;
      cin>>c>>a>>b;
      a--;b--;
      if(c=='!'){
	Int w;
	cin>>w;
	u.unite(a,b,w);
      }else{
	if(!u.same(a,b)) cout<<"UNKNOWN"<<endl;
	else cout<<u.diff(a,b)<<endl;
      }
    }
  }
  return 0;
}
/*
  verified on 2017/10/29
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1330
*/

signed DSL_1_B(){
  Int n,q;
  cin>>n>>q;
  WeightedUnionFind<Int> wuf(n,0);
  
  for(Int i=0;i<q;i++){
    Int t,x,y,z;
    cin>>t>>x>>y;
    //cout<<t<<":"<<x<<" "<<y<<endl;
    if(t){
      if(wuf.same(x,y)) cout<<wuf.diff(x,y)<<endl;
      else cout<<"?"<<endl;
    }else{
      cin>>z;
      wuf.unite(x,y,z);
    }
  }
}
/*
  verified on 2018/04/16
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_B&lang=jp
*/

signed main(){
  //AOJ_1330();
  DSL_1_B();
}



Measured memory_bytes: 4424
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 - y2 + y1 << " " << y2 + x2 - x1 << " " << x1 - y2 + y1 << " " << y1 + x2 - x1 << endl;

    return 0;
}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

void solve(int n, vector<int> &a){
    lint sum = 0;
    lint x = 0;
    FOR(i, 1, n+2){
        sum += abs(a[i] - x);
        x = a[i];
    }
    FOR(i, 1, n+1){
        if((a[i-1] <= a[i] && a[i] <= a[i+1]) || (a[i+1] <= a[i] && a[i] <= a[i-1])){
            cout << sum << endl;
        }
        else if((a[i-1] <= a[i+1] && a[i+1] <= a[i]) || (a[i] <= a[i+1] && a[i+1] <= a[i-1])){
            cout << sum - 2 * abs(a[i+1] - a[i]) << endl;
        }
        else {
            cout << sum - 2 * abs(a[i-1] - a[i]) << endl;
        }
    }
    return;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n+2, 0);
    REP(i, n){
        cin >> a[i+1];
    }
    solve(n, a);
    return 0;
}

Measured memory_bytes: 1664
N = int(input())
A = list(map(int, input().split()))

minCost = None
cost = 0

for i in range(-100, 101):
    for a in A:
        cost += (a - i) ** 2
    if minCost is None:
        minCost = cost
    else:
        minCost = min(minCost, cost)
    cost = 0

print(minCost)

Measured memory_bytes: 3060
//
// Created by Myabu on 2020/01/27.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int N;
    cin>>N;
    vector<string> s(N);
    map<string, int> a;
    for (int i = 0; i < N; ++i) {
        string temp;
        cin>>temp;
        a[temp] = a[temp]+1;
    }

    int M;
    cin>>M;
    for (int i = 0; i < M; ++i) {
        string temp;
        cin>>temp;
        a[temp] = a[temp]-1;
    }

    string ans_w ="";
    int max_val = 0;
    for(auto i: a){
        if(max_val < i.second){
            max_val = i.second;
            ans_w = i.first;
        }
    }

    cout<<max_val<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <map>
using ll = long long;
using namespace std;

void monmo(){
    
}

int main() {
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;i++){
        for(int j=0;j<=x;j++){
            if((2*i+4*j)==y && i+j==x){
                cout<<"Yes";
                exit(0);
            }
        }
    }
    cout<<"No";
}


Measured memory_bytes: 3592
#E
n=int(input())
C=sorted(list(map(int,input().split())))
mod=10**9+7

pow2=[1]
for i in range(n+5): #2の累乗(mod 10**9+7)のテーブル作成
    pow2.append(pow2[i]*2%mod)

sum=0
for i in range(n):
    l=i #その桁より左側の桁数(関係ないやつ)
    r=n-i #その桁より右側の個数(その桁自身も含む、1の個数を数えるやつ)
    if r==1:
        ans=pow2[l]
        ans=ans*C[i]%mod
        sum=(sum+ans)%mod
    else:
        ans=pow2[r-1]
        ans=(ans+pow2[r-2]*(r-1)%mod)%mod
        ans=ans*pow2[l]%mod
        ans=ans*C[i]%mod
        sum=(sum+ans)%mod
print((sum*pow2[n]%mod))

Measured memory_bytes: 25772
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;
int g[11][11];
int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,m;
  cin>>n>>m;
  vector<int> p(n);
  iota(all(p),0);

  rep(i,m){
    int x,y;
    cin>>x>>y; --x; --y;
    g[x][y]=g[y][x]=1;
  }
  int re=0;
  do{
    int f=1;
    if(p[0]) break;
    reps(i,1,n) if(g[p[i-1]][p[i]]==0) f=0;
    if(f) ++re;
  }while(next_permutation(all(p)));
  cout<<re<<endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

R = [0] * (N+1)
L = [0] * (N+1)
l = 0
ap = A[-1]#float("inf")
P = [0] * 20
stack = [0]

for i in range(N):
    a = A[-1-i]
    #cnt = 0
    while ap < a:
        #cnt += 2
        l += (i-stack[-1])<<1
        if stack[-1] != 0: del stack[-1]
        ap <<= 2
    a4 = a<<2
    while ap >= a4:
        ap >>= 2
        stack.append(i)
    R[-(i+2)] = l
    ap = a
ap = -A[0]
l = 0
stack = [0]
for i in range(N):
    l += 1
    a = -A[i]
    #cnt = 0

    while ap > a:
        #cnt += 2
        l += (i-stack[-1])<<1
        if stack[-1] != 0: del stack[-1]
        ap <<= 2
    a4 = a << 2
    while ap <= a4:
        ap >>= 2
        stack.append(i)
    #l += i * cnt
    L[i+1] = l
    ap = a
#print(L, R)
ans = float("inf")
for l, r in zip(L, R):
    ans = min(ans, l+r)
print(ans)


Measured memory_bytes: 96080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265
int main()
{
    int ar[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    cout << ar[n] << endl;
    return 0;
}


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

def mizuyari(niwa):
	if niwa == []:
		return 0
	if 0 not in niwa:
		return mizuyari(list(map(lambda x: x - 1, niwa))) + 1
	if niwa[0] == 0:
		return mizuyari(niwa[1:])
	elif niwa[-1] == 0:
		return mizuyari(niwa[:-1])
	for i in range(1, len(niwa) - 1):
		if niwa[i] == 0:
			return mizuyari(niwa[:i]) + mizuyari(niwa[i+1:])

print(mizuyari(h))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) {
    cin>>a[i];
  }
  ll ans=a[n-1];
  rep(i,n-1) ans^=a[i];
  rep(i,n){
    ll j=ans^a[i];
    cout<<j<<" ";
  }
}

Measured memory_bytes: 4760
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

struct FenwickTree {
    vector<int> bit;  // binary indexed tree
    int n;

    FenwickTree(int n) {
        this->n = n;
        bit.assign(n, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()) {
        for (size_t i = 0; i < a.size(); i++)
            add(i, a[i]);
    }

    int sum(int r) {
        int ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    int sum(int l, int r) {
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

vector<pair<int, int>> right_segs[1000000]; // left, id

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, q; cin >> n >> q;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  FenwickTree t(1000000);
  vector<int> last(1000000, -1);
  vector<int> ans(1000000);

  rep (i, q) {
    int l, r; cin >> l >> r;
    l--, r--;
    right_segs[r].push_back({l, i});
  }

  for (int i = 0; i < n; i++) {
    if (last[a[i]] != -1) {
      t.add(last[a[i]], -1);
    }
    t.add(i, 1);
    last[a[i]] = i;

    for (auto p : right_segs[i]) {
      ans[p.second] = t.sum(p.first, i);
    }

  }

  for (int i = 0; i < q; i++) {
    cout << ans[i] << endl;
  }
  

  return 0;
}

Measured memory_bytes: 50788
import java.util.Scanner;
                import java.util.ArrayList;
                import java.util.Collections;
            	import java.util.Arrays;
                 
                public class Main { //クラス名はMain
                    public static void main(String[] args) {
                        //コード
                      Scanner sc = new Scanner(System.in);
                      int mojilen = Integer.parseInt(sc.nextLine());
                      String answer = "";
                      //変換前文字列
                      String c1 = sc.nextLine();
            		  String[] strArray1 = c1.split(" ");
             
                      //配列変換
                      String[] x = new String[mojilen];
                		for (int i = 0; i < mojilen; i++) {
                    	x[i] = strArray1[0].substring(i, i+1);
                		}
                      String[] y = new String[mojilen];
                		for (int j = 0; j < mojilen; j++) {
                    	y[j] = strArray1[1].substring(j, j+1);
                		}
                      //判定
                      loop: for(int k=0;k<mojilen;k++) {
                        	answer = answer + x[k] + y[k];
                      }
               System.out.println(answer);
                }
                }

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int n;
  cin >> n;
  vector<int> odd(100001);
  vector<int> even(100001);
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    if (i % 2 == 0) {
      odd[v]++;
    } else {
      even[v]++;
    }
  }
  int oddMax = 0, evenMax = 0;
  int oddMax2 = 0, evenMax2 = 0;
  int oddMaxNum = 0, evenMaxNum = 0;
  for (int i = 0; i < 100001; i++) {
    if (odd[i] >= oddMax) {
      oddMax2 = oddMax;
      oddMax = odd[i];
      oddMaxNum = i;
    } else if(odd[i] > oddMax2){
      oddMax2 = odd[i];
    }
    if (even[i] >= evenMax) {
      evenMax2 = evenMax;
      evenMax = even[i];
      evenMaxNum = i;
    } else if(even[i] > evenMax2){
      evenMax2 = even[i];
    }
  }
  if (oddMaxNum == evenMaxNum) {
    if (oddMax - oddMax2 > evenMax - evenMax2) {
      evenMax = evenMax2;
    } else {
      oddMax = oddMax2;
    }
  }
  cout << n - oddMax - evenMax << endl;
}


Measured memory_bytes: 3956
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795


ll solve(int n, vi&a)
{
	ll s=0;
	for(auto&m:a) s+=m;
	vll limit(n+1, s);

	ll b=1;
	for(int i=0;i<=n;i++)
	{
		if(b<a[i]) return -1;
		limit[i]=b;
		if(b>=s) break;
		b-=a[i];
		b*=2;
	}

	ll ret=0;
	ll c=0;
	for(int i=n;i>=0;i--)
	{
		c=min(limit[i], c+a[i]);
		ret+=c;
	}

	return ret;
}

int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vi a(n+1);

		for(int i=0;i<=n;i++) scanf("%d", &a[i]);

		printf("%lld\n", solve(n, a));
	}
	return 0;
}


Measured memory_bytes: 3820
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define pai 3.1415926535


int main(void) {
	char S[1001];
	scanf("%s", S);
	int count_N = 0, count_W = 0, count_S = 0, count_E = 0;
	for (int i = 0; i < strlen(S); i++) {
		if (S[i] == 'N'&&count_N == 0) {
			count_N++;
		}
		else if (S[i] == 'W'&&count_W == 0) {
			count_W++;
		}
		else if (S[i] == 'S'&&count_S == 0) {
			count_S++;
		}
		else if (S[i] == 'E'&&count_E == 0) {
			count_E++;
		}
	}

	if ((count_N == count_S) && (count_W == count_E)) {
		printf("Yes");
	}
	else {
		printf("No");
	}




	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
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 (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int gcd(const vector<int> &v) {
	int ret = v[0];
	for (int i = 1; i < v.size(); i++)
		ret = gcd(ret, v[i]);
	return ret;
}
int lcm(const vector<int> &v) {
	int ret = v[0];
	for (int i = 1; i < v.size(); i++)
		ret = lcm(ret, v[i]);
	return ret;
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int T; cin >> T;
	vector<bool> ans;
	rep(t, 0, T) {
		int A, B, C, D; cin >> A >> B >> C >> D;
		bool yes = true;
		if (B > D)yes = false;
		if (A < B)yes = false;
		int g = gcd(B, D);
		dump(g);
		int d = A % g;
		dump(d);
		if (d <= C) d += ((C - d) / g + 1) * g;
		dump(d);
		if (d < B)yes = false;

		ans.push_back(yes);
		dump(yes);
	}
	rep(t, 0, T)
		cout << (ans[t] ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc159/submissions/11108540

def main():
    def calc(group):
        ret = max(group)
        ctr = [0] * H
        for c in range(W):
            need_cut = False
            for r, g in enumerate(group):
                ctr[g] += s[r][c]
                if ctr[g] > K:
                    need_cut = True
                    break

            if need_cut:
                ctr = [0] * H
                ret += 1
                for r, g in enumerate(group):
                    ctr[g] += s[r][c]
                    if ctr[g] > K:
                        return H * W
                continue
        return ret

    def gen():
        from itertools import accumulate, product

        for prod in product(range(2), repeat=H - 1):
            group = [0]
            group.extend(accumulate(prod))
            yield calc(group)

    H, W, K = map(int, input().split())
    s = []
    for _ in range(H):
        *row, = map(int, input())
        s.append(row)

    ret = min(gen())
    print(ret)


if __name__ == '__main__':
    main()


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

int main(){
    int c[3][3], a[3], b[3];
    bool judge = true;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }
    a[0] = 0;
    b[0] = c[0][0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    b[1] = c[0][1];
    b[2] = c[0][2];

    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(c[i][j] != a[i]+b[j]){
                judge = false;
            }
        }
    }
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); //参加者
		int K = sc.nextInt(); //ポイント
		int Q = sc.nextInt(); //クイズの回数
		int A[] =  new int[Q]; //正解者
		for(int i=0;i<Q;i++) {
			A[i] = sc.nextInt();
		}
		
		int points[] = new int[N];
		//初期化
		for (int point :points ) {
			point=0;
		}
		
		//自分以外に、K回正解されるとアウト。
		//したがって正解数Q回ならば、自分の正解数をAとすると、Q-A<Kならいい。つまり、A＞Q-Kなら良い。
		//開始０ポイントで、正解した人は１ポイントとし、
		//終了までにQ-Kポイント獲得すると突破に読み換える。
		for(int i=0;i<Q;i++) {
			points[A[i]-1]++;
		}
		
		for (int point :points ) {
			if(point>Q-K) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
		
		

	}
}


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

X = []

for i in range(N):
    x,l = list(map(int,input().split()))
    X.append([x-l,x+l])

X.sort(key = lambda x: x[1])

count = 0
prev = -10**27
for i in range(N):
    if prev<=X[i][0]:
        prev = X[i][1]
        count+=1

print(count)



Measured memory_bytes: 63508
def get_total_strike_times(health: int, damage: int) -> int:
    """
    Given a monster's health and damage in integer,
    calculate the number of attack required to deplete the monster's health.
    :param health: int
    :param damage: int
    :return: int
    """
    return int((health + damage - 1) / damage)


if __name__ == '__main__':
    print(get_total_strike_times(*map(int, input().split())))


Measured memory_bytes: 2940
class Dice
  def initialize
    @up = 1
    @down = 6
    @front = 2
    @back = 5
    @right = 3
    @left = 4
  end

  def north
    @up, @down, @front, @back = @front, @back, @down, @up
    @up
  end

  def south
    @up, @down, @front, @back = @back, @front, @up, @down
    @up
  end

  def east
    @up, @down, @right, @left = @left, @right, @up, @down
    @up
  end

  def west
    @up, @down, @right, @left = @right, @left, @down, @up
    @up
  end

  def right
    @front, @back, @right, @left = @right, @left, @back, @front
    @up
  end

  def left
    @front, @back, @right, @left = @left, @right, @front, @back
    @up
  end
end

while true do
  n = gets.to_i
  break if n == 0

  dice = Dice.new
  sum = 1
  n.times do 
    command = gets.chomp
    case command
    when 'North' then
      sum += dice.north
    when 'South' then
      sum += dice.south
    when 'East' then
      sum += dice.east
    when 'West' then
      sum += dice.west
    when 'Right' then
      sum += dice.right
    when 'Left' then
      sum += dice.left
    end
  end
  puts sum
end

Measured memory_bytes: 6112
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
string s;
int a[26];
int cnt;
int mn=5;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(a[s[i]-'A']==0){
			cnt++;
		}
		a[s[i]-'A']++;
	}
	for(int i=0;i<26;i++){
		if(a[i]==0){
			continue;
		}
		mn=min(mn,a[i]);
	}
	if(cnt==2&&mn==2){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
    return 0;
}


Measured memory_bytes: 256
import sys
# 数値(1~26)→(A~Z)
num2alpha = lambda c: chr(c+64)

h,w = map(int,input().split())
A = list(input().split() for i in range(h))

for i in range(w):
    for j in range(h):
        if A[j][i] == 'snuke':
          print(num2alpha(i+1)+str(j+1))
          sys.exit()

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int h = tmp[0], w = tmp[1];
	string[] g = new string[h+2];
	g[0] = g[h+1] = new string('.', w+2);
	for (int i = 1; i <= h; i++)
	{
	    g[i] = "." + ReadLine() + ".";
	}

	for (int i = 1; i <= h; i++)
	{
	    string s = "";
	    for (int j = 1; j <= w; j++)
	    {
		char c = g[i][j];
		if (c == '#'){ s += c; }
		else
		{
		    int n = 0;
		    for (int x = -1; x <= 1; x++)
			for (int y = -1; y <= 1; y++)
			    if (g[i+x][j+y] == '#'){ n++; }
		    s += $"{n}";
		}
	    }
	    WriteLine(s);
	}
	
    }
}


Measured memory_bytes: 13396
cn,ca[6];wn,wg[108][108];ln,lg[8][8];G(){char s[9];int r;scanf("%s",s);r=*s-67?*s-72?*s-68?cn+1+atoi(s+1):cn+1:cn:atoi(s+1)-1;return r;}D(s){int co[108],d[108]={0},c,n,i,t;memset(co,1,sizeof(co));c=s;co[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=co[c]+wg[c][i];if(t<co[i])co[i]=t;}if(n<0||co[i]<co[n])n=i;}}c=n;}for(i=0;i<ln;i++)lg[s][i]=co[i];}S(){int dp[1<<8][8],h=cn,d=cn+1,b,i,j,nb,t,a=1e8;memset(dp,1,sizeof(dp));dp[1<<h][h]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(nb=b|1<<j,nb-b)if(t=dp[b][i]+lg[i][j],t<dp[nb][j])dp[nb][j]=t;for(b=1<<h|1<<d;b<1<<ln;b++){t=dp[b][d];for(i=0;i<cn;i++)if(b&1<<i)t-=ca[i];if(t<a)a=t;}return a;}main(){int k,d,i,a,b,c;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d)*cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",ca+i);memset(wg,1,sizeof(wg));for(;d--;){a=G(),b=G();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)D(i);printf("%d\n",S());}}

Measured memory_bytes: 476
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

const int MAX_SIZE = 100010; // 10000010でもよさそう？
bool isprime[MAX_SIZE];
vector<int> prime_num;

void init() {
  fill(isprime, isprime+MAX_SIZE, true);
  isprime[0] = isprime[1] = false;
  for (auto i=2; i<MAX_SIZE; i++) {
    if (isprime[i]) {
      prime_num.push_back(i);
      for (auto j=2; i*j<MAX_SIZE; j++) {
        isprime[i*j] = false;
      }
    }
  }
}

bool prime(long long x) { // 2 \leq x \leq MAX_SIZE^2
  if (x < MAX_SIZE) {
    return isprime[x];
  }
  for (auto e : prime_num) {
    if (x%e == 0) return false;
  }
  return true;
}

int keta(ll A) {
  int ans = 1;
  while (A >= 10) {
    A /= 10;
    ++ans;
  }
  return ans;
}

int F(ll A, ll B) {
  return max(keta(A), keta(B));
}

int main() {
  init();
  ll N;
  cin >> N;
  int ans = keta(N);
  for (ll i = 1; i < 100010; ++i) {
    if (N % i == 0) {
      ans = min(ans, F(i, N/i));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 10000000000
#define PI 3.141592653589793

int main() {
	long long x, ans = 0, deposit = 100;
	cin >> x;

	while (deposit < x) {
		deposit += deposit / 100;
		ans++;
	}

	cout << ans;
	return 0;
}

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

int main() {
 int a,b,c,d,e;
 cin>>a>>b>>c>>d>>e;
 if(a==0){
   cout<<1<<endl;
   return 0;
 }
 if(b==0){
   cout<<2<<endl;
   return 0;
 }
 if(c==0){
   cout<<3<<endl;
   return 0;
 }
 if(d==0){
   cout<<4<<endl;
   return 0;
 }
 if(e==0){
   cout<<5<<endl;
   return 0;
 }
}

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


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();


        var c = sc.intarr;
        int n = c[0];
        int ans = 0;


        Dictionary<string, int> a= new Dictionary<string, int>();

        for(int i = 0; i < n ; ++i)
        {
            
            string s = sc.str;
            if (a.ContainsKey(s))
            {
                a[s]++;

            }
            else a[s] = 1;
        }
         c = sc.intarr;
        int m = c[0];
        for (int i = 0; i < m; ++i)
        {
            string s = sc.str;
            if (a.ContainsKey(s))
            {
                a[s]--;

            }
        }

        foreach(var x in a)
        {
            ans = Math.Max(ans, x.Value);
        }

        wr.wri(ans);
    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => strarr.Select(char.Parse).ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13280
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    ll n, d, a;
    cin >> n >> d >> a;
    vector<vector<int>> v(n, vector<int>(2));
    for (int i = 0; i < n; i++) cin >> v[i][0] >> v[i][1];
    sort(v.begin(), v.end());

    vector<vector<ll>> query;
    int nextQuery = 0;
    ll nowDamage = 0;
    ll ret = 0;
    for (int i = 0; i < n; i++) {
        while (query.size() > nextQuery && query[nextQuery][0] < v[i][0]) {
            nowDamage -= query[nextQuery][1], nextQuery++;
        }

        if (nowDamage < v[i][1]) {
            ll count = (v[i][1] - nowDamage + a - 1) / a;
            query.push_back({v[i][0] + d * 2, a * count});
            nowDamage += a * count, ret += count;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 23088
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
int ckck(int n)
{
    if(n==2||n==3)
        return 1;
    else if(n%2==0||n%3==0)
        return 0;
    else
    {
        for(int j=2;j*j<=n;j++)
        {
            if(n%j==0)
                return 0;
        }
        return 1;
    }
}
int main()
{
    ll n;
    cin>>n;
    ll i;

    ll A[n];
    ll res=0;
    for(i=0;i<n;i++)
    {
        cin>>A[i];
        res=res^A[i];
    }
    for(i=0;i<n;i++)
    {
        ll p=res^A[i];
        cout<<p<<" ";
    }


}




Measured memory_bytes: 5128
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, K;
    cin >> N >> K;

    int H;
    int ans = 0;
    REPinit(i, 0, N) {
        cin >> H;
        if (H >= K) ans++;
    }

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


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

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  ll n;
  cin >> n;
  cout << 180 * (n - 2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>
void print(T x)
{
	std::cout << x << " ";
}
template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}
int main() {
	string num;
	cin >> num;

	for (int bit = 0; bit < (1 << 3); bit++) {
		vector<string>op;
		int ans = num[0] - '0';
		rep(i, 3) {
			if (bit & (1 << i)) {
				ans += num[i + 1] - '0';
				op.pb("+");
			}
			else {
				op.pb("-");
				ans -= num[i + 1] - '0';
			}
		}
		//print(ans);
		if (ans == 7) {
			cout << num[0] << op[0] << num[1] << op[1] << num[2] << op[2] << num[3] << "=7" << '\n';
			break;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>

long long Merge(int A[],int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int i,j,k;
  int L[n1+1],R[n2+1];
  long long res = 0;
  for (i = 0;i<n1;i++)L[i]=A[left+i];
  for (i = 0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=1000000001;
  R[n2]=1000000001;

  i=j=0;
  for(k = left;k<right;k++)
    {
      if(L[i]<=R[j]){
        A[k]=L[i];
        i++;
        }
      else{
        A[k]=R[j];
        j++;
          res+=(long long)n1-(long long)i;
      }
    }
  return res;
}



long long Merge_Sort(int A[],int left,int right)
{
  int mid;
  long long res = 0;
  if(left + 1 < right){
    mid = (left + right)/2;

    res+=Merge_Sort(A,left,mid);
    res+=Merge_Sort(A,mid,right);
    res+=Merge(A,left,mid,right);
  }
  return res;
}
int  main(void)
{
  int i,n,S[200000];
  long long x;
  scanf("%d",&n);
  for (i = 0;i<n;i++)scanf("%d",&S[i]);
  x = Merge_Sort(S,0,n);
  printf("%ld\n",x);
  return 0;
}

Measured memory_bytes: 2156