akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
	int w,h,i;
	char a[101][101];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++)
	{
		scanf("%s",a[i]);
	}
	for(i=0;i<h;i++)
	{
		printf("%s\n",a[i]);
		printf("%s\n",a[i]);
	}
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    double L; cin >> L;

    cout << setprecision(20);
    cout << L * L * L / 27.0;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  ll x; cin>>x;
  ll op = 100;
  int ans = 0;
  while(op < x){
    op += op/100;
    ans++;
  }
  cout<<ans<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


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

int N, M, a, b, res = 0;
int A[200010];
int B[200010];


struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};



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

    UnionFind uf(N+1);
    for(int i = 0; i < M; i++){
        cin >> A[i] >> B[i];
        uf.merge(A[i], B[i]);  //内輪を作る
    }

    for(int i = 1; i <= N; i++) res = max(res, uf.size(i));
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5552
import math
a,b,h,m = map(int,input().split())

ans = 0

m_r = m/5
# print(m_r)
h_r = h + m/60
# print(h_r)
# print((h_r - m_r)/12*360)
reg = (h_r - m_r)/12*360
ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.radians(reg)))

print(ans)

Measured memory_bytes: 9500
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
ST = [readline().split() for _ in range(N)]
X = read().rstrip()

S,T = zip(*ST)

i = S.index(X)

answer = sum(map(int,T[i+1:]))
print(answer)

Measured memory_bytes: 3060
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################n
s =input()
if s=="ABC":
    print("ARC")
else:
    print("ABC")
















Measured memory_bytes: 9120
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using static System.Console;
using static System.Math;
class Simple {
    private int x, y;
    void Solve() {
        //input
        x = io.Int;
        y = io.Int;
        //cal
        //var A
        var B = new int[] {4, 6, 9, 11};
        var C = new int[] {2};
        Func <int, int> grouping = (n) => C.Contains(n) ? 2 : B.Contains(n) ? 1 : 0;
        var ans = grouping(x) == grouping(y);
        //ret
        WriteLine(ans ? "Yes" : "No");
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        if(st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    ll x;
    cin >> x;
    vector<ll> v;
    v.pb(100);
    ll prev = 100LL;
    ll i = 0;
    while(true) {
        ll curr = prev + (prev)/(100);
        i++;
        if(curr >= x) {
            cout << i;
            return;
        }
        prev = curr;
    }
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    //debug_map();
    return 0;
}



Measured memory_bytes: 3624
#![allow(unused_imports)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}
impl<T: Iterator> IteratorExt for T {}

fn main() {
    let a = read!(usize);
    println!("{}", a + a*a + a*a*a);

}

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

using namespace std;

using ll = long long;

template <class T>
using grid = vector<vector<T>>;

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

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

void fill_erat(vector<bool> &erat, ll x) {
  int size = erat.size();
  for(int i = x; i < size; i += x) {
    erat[i] = true;
  }
}

int main() {
  // int MAX = 2 * pow(10, 5) + 1;
  int MAX = pow(10, 6) + 1;
  vector<bool> erat(MAX, false);
  ll input(n);
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  vector<ll> dup(MAX, 0);

  ll ans = 0;
  for (auto v: a) {
    if (!erat[v]) {
      ans += 1;
      fill_erat(erat, v);
      dup[v] += 1;
    } else {
      if (dup[v] == 1) {
        ans -= 1;
        dup[v] += 1;
      }
    }
  }
  print(ans);
}

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

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

using namespace std;

typedef long long ll;

int main()
{
    int N = 3;
    vector<int> p(N);
    REP(i, N)
    {
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    int ans = 0;
    if ((p[1] - p[0]) % 2 ==0)
    {
        // p[0] == p[1] にする
        // p[0] += 2　を((p[1] - p[0]) / 2) 回行う
        ans += (p[1] - p[0]) / 2;
        // p[0] == p[1] == p[3] にする
        // p[0] += 1, p[1] += 1 を(p[2] - p[1]) 回行う
        ans += p[2] - p[1];
    }
    else
    {
        // p[0] + 1 == p[1] にする
        // p[0] += 2　を((p[1] - p[0]) / 2) 回行う
        ans += (p[1] - p[0]) / 2;
        if (p[2] == p[1])
        {
            // p[2] += 2する
            ans += 1;
            // p[0] += 1, p[2] += 1する
            ans += 1;
        }
        else
        {
            // p[0] + 2 == p[1] + 1 = p[2] にする
            // p[0] += 1, p[1] += 1 を(p[2] - p[1] - 1)回行う
            ans += p[2] - p[1] - 1;
            // p[1] += 2する
            ans += 1;
            // p[0] += 1, p[2] += 1する
            ans += 1;
            // p[0] += 2する
            ans += 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def dfs(G, v, p, dist):
    """G: graph, v: vertex, p: parent"""
    # Loop for each child
    for c, d in G[v]:
        # Avoid multiple access to parent
        if c == p:
            continue
        dist[c] = dist[v] + d
        dfs(G, c, v, dist)


def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append((b, c))
        G[b].append((a, c))

    Q, K = map(int, input().split())
    x = [0] * Q
    y = [0] * Q
    for i in range(Q):
        x[i], y[i] = map(int, input().split())

    dist = [0] * N
    dfs(G, K-1, -1, dist)
    for i in range(Q):
        ans = dist[x[i]-1] + dist[y[i]-1]
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 139580
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

void solve() {
	int N, D; cin >> N >> D;
	int ans = 0;
	REP(i, N) {
		int x, y; cin >> x >> y;
		if (x*x + y * y <= D * D)ans++;
	}
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,minN = INF,sum = 0,sumtmp = 0;
	cin >> n;
	vector<ll>a(n),sumL,sumR;
	rep(i, n)cin >> a[i];
	sum = accumulate(all(a),0LL);
	for (ll i = 0; i < n; i++) {
		sumtmp += a[i];
		minN = min(minN,abs(sum-2*sumtmp));
	}
	cout << minN << endl;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        int[] A = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        
        int[] gcdL = new int[N];
        int[] gcdR = new int[N];
        
        gcdL[0] = A[0];
        for(int i = 1; i < N-1; i++){
            gcdL[i] = GCD(gcdL[i-1], A[i]);
        }
        
        gcdR[N-1] = A[N-1];
        for(int i = N-2; i >= 1; i--){
            gcdR[i] = GCD(gcdR[i+1], A[i]);
        }
        
        int maxGCD = 1;
        for(int i = 0; i < N; i++){
            
            if ( i == 0 ){
                maxGCD = Math.max(maxGCD, gcdR[i+1]);
                continue;
            } 
            if ( i == N - 1){
                maxGCD = Math.max(maxGCD, gcdL[N-2]);
                continue;
            }
            
            maxGCD = Math.max(maxGCD, GCD(gcdL[i-1], gcdR[i+1]) );
        }
        
        System.out.println(maxGCD);
        
    }
    
    public static int GCD(int x, int y){
        if( y == 0 ) return x;
        return GCD( y, x % y );
    }
}


Measured memory_bytes: 47372
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,k,i=0,j,c=0,p=0,max=0,h[200010],q=0;
    string s[200100],a[200010];
    cin >> n;
    for(i=0;i<n;i++)
    {
        q=0;
        cin >> s[i];
    }
    sort(s,s+n);
    for(i=0;i<n;i++)
        {
            if(s[i]==s[i-1] && i!=0)
            {
                continue;
            }
        a[c]=s[i];
        c++;
        }
    sort(a,a+c);
    for(i=0;i<n;i++)
    {
        
        if(s[i]==s[i+1])
            {
                p++;
                if(max<p)
                {
                    max=p;
                }
            }
        else if(s[i]!=s[i+1])
        {
            h[q]=p;
            q++;
            p=0;
            
        }
    }
    for(i=0;i<c;i++)
    {
        if(h[i]==max)
        { 
            cout << a[i] << endl;
        }
    }
    
    return 0;

}


Measured memory_bytes: 17696
n, k = map(int, input().split())
a = list(map(int, input().split()))

l = [1]
ind = 0
val = 0
for i in range(n):
    val = a[ind]
    l.append(val)
    ind = val - 1

if n >=k:
    answer1 = l[k]

cnt = 1
repeat =[]
repeat.append(l.pop())
z = 0

for j in range(n - 1, -1, -1):
    z = l.pop()
    if z == repeat[0]:
        break
    else:
        cnt += 1
        repeat.append(z)

repeat = repeat[::-1]

jouyo = (k - n - 1) % cnt

if n >= k:
    print(answer1)
else:
    print(repeat[jouyo])


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i=0; i<n; i++){
        int spl[3] = {0, i, n};
        valarray<int> a[2];
        for(int j=0; j<2; j++){
            a[j] = valarray<int>(0, 26);
            for(int k=spl[j]; k<spl[j+1]; k++){
                a[j][s[k]-'a'] = 1;
            }
        }
        a[0] *= a[1];
        ans = max(ans, a[0].sum());
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define X first
#define Y second
#define fw(i, start, end) for (ll i = start; i < end; ++i)
#define fe(i, start, end) for (ll i = start; i <= end; ++i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define endl "\n"
#define mem(a, i) memset(a, i, sizeof(a))
int main()
{
    FASTIO
long    double n, m;
    cin >> n >> m;
    cout << (ll)((n * m)+0.0009) << endl;

    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
using namespace std;
int main() {
    long long n, a, b; cin >> n >> a >> b;
    int cur; cin >> cur;
    long long ans = 0;
    while (--n) {
        int x; cin >> x;
        ans += min(a * (x - cur), b);
        cur = x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;

int main(){
  int W,n,count=1,a,i,j,sum=100000;
 
  scanf("%d",&W);
  while(  W != 0 ){
    cin >> n;
    int dp[n+1][W+1],value[n],weight[n];
    /*dp = 価値の最大値 */
    for( i = 0 ; i < n ; i++){
      scanf("%d,%d",&value[i],&weight[i]);
      
    }
    for( i = 0 ; i < n+1 ; i++){
      for( j = 0 ; j <= W ; j++){
	dp[i][j] = 0;
      }
    }

    for( i = 0 ; i < n ; i++){
      for( j = 0 ; j <= W ; j++){
	
	dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
	if((j+weight[i]) <= W){
	  dp[i+1][j+weight[i]] = max(dp[i+1][j+weight[i]],dp[i][j] + value[i]);  
	}
      }
    }

    for ( i =0 ; i <= n ; i++){
      for ( j = 0 ; j <= W ; j++){
	if(dp[n][W] == dp[i][j]){
	  sum = min(sum, j);
	}
      }
    }

    cout << "Case " << count << ":" <<endl;
    cout << dp[n][W] <<endl;
    cout << sum <<endl;
    scanf("%d",&W);
    count++;
    sum =1000000 ;
  }
  
  


  return 0;
}

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

class fenwick_tree {
  private:
    std::vector<int> _data;
    int& _size;
    static int lsb(int x) { return x & -x; }
  public:
    fenwick_tree(int size):
      _data(size + 1), _size(_data.front())
    { _size = size; }
    void add(int index, int value) {
      for (; index <= _size; index += lsb(index))
        _data[index] += value;
    }
    int sum(int index) {
      int result = 0;
      for (; index > 0; index -= lsb(index))
        result += _data[index];
      return result;
    }
};

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m;
  std::cin >> n >> m;
  std::vector<std::vector<std::pair<int, int>>> ranges(m + 1);
  for (int i = 0; i < n; i++) {
    int l, r;
    std::cin >> l >> r;
    ranges[r - l + 1].emplace_back(l, r);
  }
  fenwick_tree range_count(m + 1);
  int always = n;
  for (int i = 1; i <= m; i++) {
    for (auto const& range : ranges[i - 1]) {
      range_count.add(range.first, 1);
      range_count.add(range.second + 1, -1);
    }
    always -= ranges[i - 1].size();
    int result = always;
    for (int j = i; j <= m; j += i)
      result += range_count.sum(j);
    std::cout << result << std::endl;
  }
}


Measured memory_bytes: 8064
N = int(input())
H = [int(i) for i in input().split()]

ans = True
_max = 0
for i in range(N):
	_max=max(H[i], _max)
	if _max-H[i]>1:
		ans = False
		break
	if i==N-1:
		break

if ans:
	print("Yes")
else:
	print("No")		

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

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b){a=b; return 1;} return 0;}

const int INF = 2147483647;

int main() {

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

  int h[N], dp[N];

  for(int i=0;i<N;i++){
    cin >> h[i];
    dp[i] = INF;
  }

  dp[0] = 0;


  for(int i = 1; i < N; i++) {
    for(int m = 1; m <= K; m++) {
      if(i-m < 0) break; 
      chmin(dp[i], dp[i-m] + abs(h[i]-h[i-m]));
    }
  }


  cout << dp[N-1] << endl;
    
  return 0;
}


Measured memory_bytes: 1024
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    a = IS()
    if a.islower():
        print('a')
    else:
        print('A')

if __name__ == '__main__':
    main()

Measured memory_bytes: 8980
// solv_C.cpp : 
//

#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
	ll N, K;
	ll x,ans;

	cin >> N >> K;

	x = N % K;

	ans	= min<ll>(K-x, x);

	cout << ans << endl;

}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b) cout << "Yes" << endl;
	else if (b <= c && c <= a) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		if (n == 0) {
			pr.println('0');
		} else if (n > 0) {
			char[] ans = new char[40];
			Arrays.fill(ans, '0');
			
			for (int i = 0; i < 40; i++) {
				if ((n & 0x1L << i) != 0) {
					set(ans, i);
				}
			}

			boolean flag = false;
			for (int i = ans.length - 1; i >= 0; i--) {
				if (flag) {
					pr.print(ans[i]);
				} else if (ans[i] == '1') {
					flag = true;
					pr.print(ans[i]);
				}
			}
			pr.println();
			
			check(n, ans);
		} else {
			long tmp = -1;
			int cnt = 0;
			while (tmp > n) {
				tmp *= 2;
				cnt++;
			}
			
			long tmp2 = n - tmp;
			char[] ans = new char[40];
			Arrays.fill(ans, '0');
			
			for (int i = 0; i < 40; i++) {
				if ((tmp2 & 0x1L << i) != 0) {
					set(ans, i);
				}
			}

			if (cnt % 2 == 1 && ans[cnt] == '0') {
				ans[cnt] = '1';
			} else if (cnt % 2 == 1 && ans[cnt] == '1') {
				ans[cnt + 1] = '0';
				ans[cnt] = '0';
			} else if (cnt % 2 == 0 && ans[cnt] == '0') {
				ans[cnt] = '1';
				ans[cnt + 1] = '1';
			} else {
				ans[cnt] = '0';
			}

			boolean flag = false;
			for (int i = ans.length - 1; i >= 0; i--) {
				if (flag) {
					pr.print(ans[i]);
				} else if (ans[i] == '1') {
					flag = true;
					pr.print(ans[i]);
				}
			}
			pr.println();
			check(n, ans);
		}
	}

	private static void set(char[] ans, int i) {
		if (i % 2 == 0 && ans[i] != '1') {
			ans[i] = '1';
		} else if (i % 2 == 0 && ans[i] == '1') {
			ans[i] = '0';
			set(ans, i + 1);
		} else if (i % 2 == 1 && ans[i] != '1') {
			ans[i] = '1';
			set(ans, i + 1);
		} else {
			ans[i] = '0';
		}
	}

	private static void check(int n, char[] ans) {
		long tmp = 1;
		long tmp2 = 0;
		for (int i = 0, size = ans.length; i < size; i++, tmp *= -2) {
			if (ans[i] == '1') {
				tmp2 += tmp;
			}
		}

		if (n != tmp2) {
			pr.printf("err %d %d\n", n, tmp2);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    string S;
    cin >> S;
    string A = "abcdefghijklmnopqrstuvwxyz";
    REP(i,S.length()){
        REP(j,26){
            if(A.empty()){
                break;
            }else if(S[i]==A[j]){
                A.erase(A.begin()+j);
            }
        }
    }
    if(A.empty()){
        cout << "None";
    }else{
        cout << A[0];
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string input;
    int i,j;
    int stringlength = 0;
    cin >> input;



    for(i = 0; i < input.length(); i++) {
 
        if(input[i] == 'A'){
            for(j = i; j < input.length(); j++) {
                if(input[j] == 'Z') {
                    stringlength = j - i + 1;
                } 
            }
            break;
        }

     //   if(maxlength < length) {
      //      maxlength = length;
     //   }
        
    }

    cout << stringlength << endl;
       
    return 0;
}

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

#define MAX_INPUT_SIZE  1024
#define INPUT_FROM_FILE

int* createArray(int size, char* input);
void insertionSort(int size, int* array);
void trace(int size, int* array);

int
main(int argc, char* argv[])
{
    char input[MAX_INPUT_SIZE];

    int size = atoi(fgets(input, sizeof(input), stdin));
    //printf("array size : %d\n", size);

    while ((fgets(input, sizeof(input), stdin)) != NULL) {
        int* array = createArray(size, input);
        insertionSort(size, array);

        if (array != NULL) {
            delete [] array;
        }
    }

    return 0;
}

int*
createArray(int size, char* input)
{
    int* array = new int[size];

    if (array != NULL) {
        for (int i = 0; i < size; i++) {
            array[i] = i == 0 ?
                atoi(strtok(input, " ")) : atoi(strtok(NULL," "));
        }
    }

    return array;
}

void
insertionSort(int size, int *array)
{
    for (int i = 0; i < size; i++) {
        int key = array[i];
        int j = i - 1;
        while (j >= 0 && array[j] > key) {
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = key;
        trace(size, array);
    }
}

void
trace(int size, int* array)
{
    for (int i = 0; i < size; i++) {
        if (i != 0) printf(" ");
        printf("%d", array[i]);
    }
    printf("\n");
}

Measured memory_bytes: 996
import collections
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
xy.sort()
count={}
ans=0
for i in range(n):
    for j in range(i+1,n):
   #     print(i,j)
        x=xy[i][0]-xy[j][0]
        y=xy[i][1]-xy[j][1]
        if (x,y) in count:
            count[x,y]+=1
        else:
            count[x,y]=1
#print(count)
for v in count.values():
    ans=max(ans,v)
print(n-ans)

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

int main(){
    int n;
    cin >> n;
    
    int x, y, b, p;
    while(n-- > 0){
        cin >> x >> y >> b >> p;
        cout << min(x*b + y*p, (int)(0.8*(max(5,b)*x + max(2,p)*y))) << endl;
    }
    return 0;
}



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


void solve(long long N, long long M){
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
h,w,k = map(int,input().split())
cake = []
ans = [[0]*w for _ in range(h)]
color = 1
for i in range(h):
    cake.append(list(input()))
for i in range(h):
    cur = 0
    for j in range(w):
        if cake[i][j] == "#":
            cur = color
            color += 1
            if j > 0 and ans[i][j-1] == "0":
                for k in range(j):
                    ans[i][k] = str(cur)
        ans[i][j] = str(cur)
flag = True
for i in range(h):
    for j in range(w):
        if ans[i][j] != "0":
            flag = False
        elif flag:
            k = i
            while ans[k][j] == "0":
                k += 1
            ans[i][j] = ans[k][j]
        else:
            k = i
            while ans[k][j] == "0":
                k -= 1
            ans[i][j] = ans[k][j]
for i in range(h):
    print(" ".join(ans[i]))            

Measured memory_bytes: 10100
/*
 list ではなく　vectorを使用する方が楽
 for文の中に要素数の違うvectorを二つ入れる時はifを入れて調整する
*/


#include<bits/stdc++.h>

using namespace std;

signed main(){

    
    int N,answer = 0;
    cin>>N;
    
    vector<int> A,B,C;
    
    for(int i = 0; i < N ;i++ ){
        int num;
        cin >> num;
        A.push_back(num);
    }
    for(int i = 0; i < N ;i++ ){
        int num;
        cin >> num;
        B.push_back(num);
        answer += num;
    }
    for(int i = 0; i < N-1 ;i++ ){
        int num;
        cin >> num;
        C.push_back(num);
    }
    
    for(int i = 0; i< N ; i++){
        
        if( A[i+1] - A[i] == 1) {
            int t = C[A[i]-1] ;
            answer += t ;
        }
    }
    
    cout << answer;

    return 0;
}


Measured memory_bytes: 256
def area(p)
  x, y = p[0]
  s = 0.0
  oldV = [p[1][0]-x, p[1][1]-y]
  p[2..-1].each do |x1, y1|
    va = [x1-x, y1-y]
    s += triangleArea(va, oldV)
    oldV = va
  end
  s
end

def triangleArea(a, b)
  ((a[0] * b[1] - a[1] * b[0])/2.0).abs
end

if __FILE__ == $0
  points = []
  loop do
    input = gets
    break if input.nil?
    points << input.split(',').map(&:to_f)
  end
  p area(points)
end

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;
const int MOD = 1e9 + 7;
int n, m;
string a[51], b[51];

bool ok(int x, int y){
    for(int i = x; i < x + m; i++){
        for(int j = y; j < y + m; j++){
            if(a[i][j] != b[i - x][j - y]) return false;
        }
    }
    return true;
}

void solve(){
    cin >> n >> m;
    fo(0, n - 1) cin >> a[i];
    fo(0, m - 1) cin >> b[i];
    for(int i = 0; i <= n - m; i++){
        for(int j = 0; j <= n - m; j++){
            if(ok(i, j)){
                cout << "Yes";
                return;
            }
        }
    }
    cout << "No";
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    char c;
    cin >> c;
    cout << (char) (c + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

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

const int N = 2e5 + 10;

char s[N]; 
int f[N], n; 

int main(int argc, char const *argv[]) {
    scanf("%s", s + 1); 
    n = strlen(s + 1); 

    f[1] = 1; 
    for(int i = 2; i <= n; ++i) {
        if(s[i] != s[i - 1]) {
            f[i] = f[i - 1] + 1; 
        } else {
            f[i] = i >= 3 ? f[i - 3] + 2 : 1;
        }
    }

    printf("%d\n", f[n]);
}

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

#define ll long long

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
int main() {

	ll N, P[200005], Q[200005];
	cin >> N;
	for (int i = 1; i <= N; i++) {

		cin >> P[i];
		Q[P[i]] = i;

	}
	int cnt=0, m=0;
	for (int i = 2; i <= N; i++) {

		if (Q[i - 1] < Q[i]) {

			cnt++;
			m = MAX(m, cnt);

		}
		else {//421536//1324

			cnt = 0;

		}

	}
	cout << N - m - 1 << endl;

	return 0;
}

Measured memory_bytes: 3328
def main():
    N = int(input())
    dict = {}

    for _ in range(N):
        word = input()
        if word in dict:
            dict[word] += 1
        else:
            dict[word] = 0

    m = max(dict.values())
    dict = sorted(dict.items(), key=lambda x: x[0])

    for d in dict:
        if d[1] == m:
            print(d[0])
    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 102452
#include<iostream>
#include<string>

using namespace std;

int main(void){
	int game;
	cin >> game;
	for(int i = 0; i < game; i++){
		int out = 0;
		int base = 0;
		int point = 0;
		string n;
		while(out < 3){
			cin >> n;
			if(n == "HIT"){
				base++;
				if(base == 4){
					point++;
					base--;
				}
			}else if(n == "OUT"){
				out++;
			}else if(n == "HOMERUN"){
				point += base + 1;
				base = 0;
			}
		}
		cout << point << endl;
	}
	
	return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;

  vll as(n);
  rep(i, n) {
    ll a;
    cin >> a;
    a--;
    as[i] = a;
  }

  vll visd(n, -1);
  vll jun;
  jun.push_back(0);
  visd[0] = 0;
  ll cur = 0;
  ll lpst = 0;
  rep(i, n) {
    cur = as[cur];
    if (visd[cur] == -1) {
      jun.push_back(cur);
      visd[cur] = i + 1;
    } else {
      lpst = cur;
      break;
    }
  }
  if(k <= visd[lpst]) {
    cout << jun.at(k) + 1 << endl;
    return 0;
  }
  ll lplen = jun.size() - visd[lpst];
  ll nk = k - visd[lpst];
  nk %= lplen;

  ll ans = jun[nk + visd[lpst]];

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


Measured memory_bytes: 8460
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N,K = map(int,input().split())
MOD = 10 ** 9 + 7

edge = [[] for _ in range(N)]
for _ in range(N-1):
  a,b = map(lambda x: int(x) - 1,input().split())
  edge[a].append(b)
  edge[b].append(a)
deg = [len(E) for E in edge]
  
U = 10 ** 5 + 100
fact = [1] * (U+1)
fact_inv = [1] * (U+1)
for n in range(1,U+1):
  fact[n] = fact[n-1] * n % MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)
for n in range(U-1,0,-1):
  fact_inv[n] = fact_inv[n+1] * (n+1) % MOD

def perm(n,k):
  if k > n or k < 0:
    return 0
  return fact[n] * fact_inv[n-k] % MOD

def F(x,parent = None):
  if parent is None:
    c = perm(K, deg[x] + 1)
  else:
    c = perm(K-2, deg[x] - 1)
  for y in edge[x]:
    if y == parent:
      continue
    c *= F(y,x)
    c %= MOD
  return c

answer = F(0)
print(answer)

Measured memory_bytes: 110188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int n;
    cin >> n;

    string s;

    cin >> s;

    char before{0};
    int ans{0};
    for (char c : s) {
        if (before != c) {
            ans += 1;
        }
        before = c;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
while True:
    c,op,d=map(str,input().split())
    a=int(c)
    b=int(d)
    if op =="?":
        break
    elif op=="+":
        ans=a+b
    elif op=="-":
        ans=a-b
    elif op=="*":
        ans=a*b
    elif op=="/":
        ans=int(a/b)
    print(ans)


Measured memory_bytes: 5596
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int cntA = 0, cntB = 0, cntC = 0;
    for(int i = 0; i < (int)s.length(); i++)
    {
        if('a' == s[i])
        {
            cntA++;
        }

        if('b' == s[i])
        {
            cntB++;
        }

        if('c' == s[i])
        {
            cntC++;
        }
    }

    if(1 == cntA && 1 == cntB && 1 == cntC)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    int n;
    cin >> n;
    vector<pair<int,int>> p(n);
    vector<int> ans(n),ans2(n);
    for(int i =0 ; i < n; i++){
        cin >> p[i].first >> p[i].second;
        ans[i] = p[i].first + p[i].second;
        ans2[i] = p[i].first - p[i].second;
    }
    sort(all(ans2));
    sort(all(ans));
    cout << max(ans2[n - 1] - ans2[0], ans[n - 1] - ans[0]) << '\n' ;
}

int32_t main()
{
    FLASH
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 9504
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void reverse(int[] arr) {
        for (int i = 0; i < arr.length / 2; i++) {
            int temp = arr[i];
            arr[i] = arr[arr.length - i - 1];
            arr[arr.length - i - 1] = temp;
        }
    }

    private static void solve() {
        int n = in.nextInt();
        int[] a = in.nextIntArray(n);
        Arrays.sort(a);
        reverse(a);

        long ans = 0;
        Queue<Integer> next = new ArrayDeque<>();
        for (int i = 0; i < a.length; i++) {
            if (next.isEmpty()) {
                next.add(a[i]);
                continue;
            }
            int side = next.poll();
            ans += side;
            next.add(Math.min(side, a[i]));
            next.add(Math.min(side, a[i]));
        }

        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 57556
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000007LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 205
int t, n;
ll a[MN];
string s;
vll basis;

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

    cin >> t;
    F0R(_, t){
        basis.clear();
        cin >> n;
        F0R(i, n){
            cin >> a[i];
        }
        cin >> s;
        bool ok = true;
        RFOR(i, n-1, 0){
            if(s[i] == '0'){
                ll A = a[i];
                for(ll b : basis){
                    A = min(A, A^b);
                }
                if(A){
                    int ind = 0;
                    while(ind < basis.size() && basis[ind] > A) ++ind;
                    basis.insert(basis.begin()+ind, A);
                }
            } else{
                ll A = a[i];
                for(ll b : basis){
                    A = min(A, A^b);
                }
                if(A){
                    ok = false;
                    break;
                }
            }
        }
        if(ok){
            cout << "0\n";
        } else{
            cout << "1\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3608
N = int(input())
lst = [int(input()) for _ in range(N)]
max_ = max(lst)
divisors = []
d = 0

for i in range(1, int(max_**0.5) + 1):
    if max_ % i == 0:
        divisors.append(i)
        divisors.append(max_ // i)
divisors.sort()

for i in sorted(lst):
    for divisor in divisors:
        if i <= divisor:
            d += divisor - i
            break

print(d)


Measured memory_bytes: 10664
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "["; for (int i=0; i<(int)v.size(); i++) cout << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p>>=1;){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

ll N,a[110];

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

    int i; ll res=1,b=1;
    for (i=1; i<=N; i++){
        cin >> a[i];
        res*=3;

        if (a[i]%2==0) b*=2;
    }

    cout << res-b << "\n";

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

typedef long long ll;

using namespace std;

priority_queue<ll> pq;
ll lunlun[100000 + 5];
int lunlun_sz;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	for (int i = 1; i <= 9; ++i)
	{
		pq.push(-i);
	}

	while (!pq.empty() && lunlun_sz < 100000)
	{
		ll cur = -pq.top();
		pq.pop();

		lunlun[lunlun_sz++] = cur;

		pq.push(-(cur * 10 + cur % 10));
		if (cur % 10 - 1 >= 0) pq.push(-(cur * 10 + cur % 10 - 1));
		if (cur % 10 + 1 <= 9) pq.push(-(cur * 10 + cur % 10 + 1));
	}

	int K;

	scanf("%d", &K);
	printf("%lld\n", lunlun[K - 1]);

	return 0;
}

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

int main(){
	int N,K;
	string S;
	cin >> N >> S >> K;
	char x = S.at(K-1);
	for(int i = 0; i < N; i++){
		if(S.at(i) != x)
			S.at(i) = '*';
	}
	cout << S << endl;
}

Measured memory_bytes: 256