akhauriyash/Code-Regression huggingface dataset:
# abc144_b.py
# https://atcoder.jp/contests/abc144/tasks/abc144_b

# B - 81 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 高橋君は九九を覚えたので、1以上 9 以下の 2つの整数の積を計算することができます。
# 整数 Nが与えられるので、N を 1 以上 9 以下の 2つの整数の積として表すことができるか判定し、
# できるなら Yes を、できないなら No を出力して下さい。

# 制約
#     1≤N≤100
#     Nは整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N

# 出力
# Nを 1 以上 9 以下の 2つの整数の積として表すことができるなら Yes を、できないなら No を出力せよ。

# 入力例 1
# 10

# 出力例 1
# Yes

# 例えば 2×5と表すことができます。

# 入力例 2
# 50

# 出力例 2
# No

# 50を 1 以上 9 以下の 2つの整数の積として表すことはできません。

# 入力例 3
# 81

# 出力例 3
# Yes


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    lst = list()
    for i in range(1, 10):
        for j in range(1, 10):
            lst.append(i*j)

    if N in lst:
        result = 'Yes'
    else:
        result = 'No'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['10']
        lines_export = ['Yes']
    if pattern == 2:
        lines_input = ['50']
        lines_export = ['No']
    if pattern == 3:
        lines_input = ['81']
        lines_export = ['Yes']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

int main() {
    int n, a[100];
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    for(int k= 0; k < n; k++){
        cout << a[k];
        if(k < n-1){
            cout << " ";
        }else{
            cout<< endl;
        }
    }
    
    for(int i=1; i< n; i++) {
        int v=a[i];
        int j = i-1;
        while(j >=0 &&a[j] > v){
            a[j+1]= a[j];
            j--;
        }
        a[j+1]=v;
        
    
        for(int k= 0; k < n; k++){
            cout << a[k];
            if(k < n-1){
                cout << " ";
            }else{
                cout<< endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3088
// https://beta.atcoder.jp/contests/abc075
// status: [solve]

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>
#include <set>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_SIDE = 50;
char field[MAX_SIDE][MAX_SIDE];
int ans[MAX_SIDE][MAX_SIDE];
int H, W;


int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(6 6
#####.
#.#.##
####.#
.#..#.
#.##..
#.#...
)");
    stringstream stream(program_input);
#endif
    stream >> H >> W;
    memset(ans, 0, sizeof(ans));
    // initialization
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            stream >> field[y][x];

            if (field[y][x] == '#') {
                for (int r = max(0, y - 1); r <= min(H - 1, y + 1); ++r) {
                    for (int c = max(0, x - 1); c <= min(W - 1, x + 1); ++c) {
                        ans[r][c]++;
                    }
                }
            }
        }
    }

    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            if (field[y][x] == '#') cout << '#';
            else cout << ans[y][x];
        }
        cout << endl;
    }

#ifdef DEBUG
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            cout << ans[y][x] <<  " ";
        }
        cout << endl;
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int k, q;
  cin >> k >> q;

  vector<int> ds(k);
  F0R(i, k) {
    cin >> ds[i];
  }

  vector<tuple<int,int,int>> qs;
  qs.reserve(q);
  F0R(i, q) {
    int n, x, m;
    cin >> n >> x >> m;
    qs.emplace_back(n, x, m);
  }

  // d を全てmod m にする。その後 0 を m にする。この数列をAとする
  // x を mod m してから、A を順に n-1 個足して、何回 m 以上になるか、をBとする
  // n - B が答え

  for (auto query : qs) {
    int n, x, m;
    tie(n, x, m) = query;

    vector<int> as;
    i64 sum = 0;
    as.reserve(k);
    F0R(i, k) {
      as.push_back(ds[i] % m);
      if (!as[i]) as[i] = m;
      sum += as[i];
    }

    x %= m;

    // x に 数列から n-1 個足す
    n--;
    i64 r = x + (n / k) * sum;
    F0R(i, n% k) {
      r += as[i];
    }

    cout << (n - r / m) << newl;
  }
}
#endif


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;


int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	ll ans = (N / (A + B)) * A;
	N = N % (A + B);
	ans += min(A, N);
	cout << ans << endl;
}

Measured memory_bytes: 3644
<?php
while (true) {
    list($h, $w) = sscanf(trim(fgets(STDIN)), "%d %d");
    if ($h == 0 && $w == 0) { break; }
    for ($i=0; $i<$h; $i++) {
        for ($j=0; $j<$w; $j++) {
            echo "#";
        }
        echo "\n";
    }
    echo "\n";
}



Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<algorithm>
#define fi first
#define se second

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair< int,pair<int,int> > pp;

vi P;
vector<pp> d;

inline void init()
{
  int n;
  vvi a;
  cin >> n;
  P.resize(n);
  for(int i = 0; i < n; ++i)
    P[i] = i;
  a.resize(n);
  for(int i = 0; i < n; ++i){
    a[i].resize(n);
    for(int j = 0; j < n; ++j)
      cin >> a[i][j];
  }
  for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j)
      if(a[i][j] != -1){
	d.push_back(make_pair(a[i][j],make_pair(i,j)));
      }
  sort(d.begin(),d.end());
}

inline int root(int a)
{
  if(P[a] == a) return a;
  else return (P[a] = root(P[a]));
}

inline bool same(int a, int b)
{
  return root(a) != root(b);
}

inline void unite(int a, int b)
{
  P[root(a)] = root(b);
}

inline int answer()
{
  int answer = 0;
  for(size_t i = 0; i < d.size(); ++i){
    if(same(d[i].se.fi,d[i].se.se)){
      unite(d[i].se.fi,d[i].se.se);
	answer += d[i].fi;
    }
  }
  return answer;
}

int main()
{
  init();
  cout << answer() << endl;
  return 0;
}

Measured memory_bytes: 1332
def solve():
    s = input()

    import collections
    deque = collections.deque()

    deque.append(s[0])
    for x in s[1:]:
        if deque[-1] != x:
            deque.append(x)

    return (len(deque)-1)


def main():
    print(solve())


if __name__ == '__main__':
    main()


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

using namespace std;

vector<string> split(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);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}

#define ANTHRO(args...) {__anthro_begin(__LINE__); __anthro(split(#args, ',').begin(), args);}

inline void __anthro_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __anthro_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __anthro_out_var(T* val) { cerr << arrStr(val,2); } //Change the values in case you want to debug something
template<typename T> inline void __anthro_out_var(T val) { cerr << val; }
inline void __anthro(vector<string>::iterator it) { cerr << endl; }

template<typename T, typename... Args>
inline void __anthro(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __anthro_out_var(a);
    cerr << "; ";
    __anthro(++it, args...);
}
//Simple Debugger

#define ll long long
#define MOD 1000000007
#define EPS 1e-9
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
/*
    This is C-Vacation from ATcoderJP
*/

int main(){
    ll n; cin>>n;
    vector<ll> dp(3),tdp(3);
    for(ll i=1;i<=n;i++){
        ll a,b,c; cin>>a>>b>>c;
        if(i==1){
            tdp[0]=a; tdp[1]=b; tdp[2]=c;
        }
        else{
            tdp[0]=a+max(dp[1],dp[2]);
            tdp[1]=b+max(dp[0],dp[2]);
            tdp[2]=c+max(dp[0],dp[1]);
        }
        dp=tdp;
        //ANTHRO(dp);
    }

    cout<<max(dp[0],max(dp[1],dp[2]));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
int main(){
	int N,H;cin>>N>>H;
	vector<pair<int,int>> dam(N*2);
	int a,b;
 	rep(i,0,N){
		cin>>a>>b;
		dam[i]={a,0};
		dam[i+N]={b,1};
	}
	sort(dam.begin(),dam.end());
	reverse(dam.begin(),dam.end());
	int i=0;
	while(dam[i].second==1&&H>0){
		H-=dam[i].first;
		i++;
	}
	if(H<=0){ cout<<i<<endl; return 0; }
	else{
		int k=dam[i].first;
		cout<<i+(H+k-1)/k<<endl;;
	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
int main()
{
  	std::string Input;
    int Len;
	std::cin >> Len;
	std::cin >> Input;
    if(Len%2 ==1)
    {
      std::cout << "No" <<std::endl;
      return 0;
    }
  	auto size = Input.size() /2 ;
  	std::string A(Input.begin(),Input.begin()+size);
  	std::string B(Input.begin()+size,Input.end());
    if(A==B)
    {
 	 	std::cout << "Yes"<<std::endl;
    }
  	else
  	{
	  	std::cout << "No" <<std::endl;
  	}
   return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = "**" + input().strip()

    dp = [0] * (N+2)

    for i in range(N+2):
        if s[i-1:i+1] == "OX" or s[i-1:i+1] == "XO":
            dp[i] = max(dp[i-1], dp[i-2] + 1)
        else:
            dp[i] = dp[i-1]
    # print(dp)
    print(dp[-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 8112
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int N, i, j;
	scanf("%lld", &N);
	vector<pair<int, int>> ps(N);
	for(i = 0; i < N; i++){
		scanf("%lld%lld", &ps[i].first, &ps[i].second);
	}
	auto comp = [&](pair<int, int> a, pair<int, int> b){
		return atan2(a.first, a.second) < atan2(b.first, b.second);
	};
	sort(ps.begin(), ps.end(), comp);
	int ans = 0;
	for(i = 0; i < N; i++){
		int X = 0, Y = 0;
		for(j = 0; j < N; j++){
			X += ps[(i + j) % N].first;
			Y += ps[(i + j) % N].second;
			ans = max(ans, X * X + Y * Y);
		}
	}
	printf("%.20lf\n", sqrt(double(ans)));
	return 0;
}

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

public class Main {
    static ArrayList<Integer> primeList;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        primeList = prime();
        while ((line = br.readLine()) != null) {
            int n = Integer.parseInt(line);
            int count = 0;
            for (int i = 1; i <= n; i++) {
                if (checkPrime(i) && checkPrime(n + 1 - i)) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }

    static boolean checkPrime(int a) {
        if (a <= 1) {
            return false;
        }
        for (int i : primeList) {
            if (a < i * i) {
                return true;
            }
            if (a % i == 0) {
                return false;
            }
        }
        return true;
    }

    static ArrayList<Integer> prime() {
        int SIZE = 10000000;
        ArrayList<Integer> primeList = new ArrayList<Integer>(SIZE);
        int n = 10000;
        primeList.add(2);
        primeList.add(3);
        for (int i = 5; i <= n; i += 2) { //????±?????\???°??????
            boolean wflag = false; //???????????????????????????
            for (int j = 1; primeList.get(j) * primeList.get(j) <= i; j++) {
                // ????±??????°??????????????\????????¨???????´???°??§????????????
                if (0 == i % primeList.get(j)) { //???????????????????´???°??§?????????
                    wflag = true;
                    break;
                }
            }
            if (!wflag) { //???????????§????????????????????£??????
                primeList.add(i); //?´???°??¨????????°????????????
            }
        }
        return primeList;
    }

    static int[] ai() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static int ip() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        return Integer.parseInt(br.readLine());
    }

}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string N){
    long long res = 0;
    for(auto n : N) res += n - '0';
    if(res%9 == 0) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    std::string N;
    std::cin >> N;
    solve(N);
    return 0;
}


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

int main(void)
{
	int n;
	int p;

	p = 0;
	scanf("%d", &n);
	p = n / 2;
	p = n % 2 == 0 ? p : (p + 1);
	printf("%d", p);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	set<int>s;
	cin >> N;
	rep(i, N) {
		int num;
		cin >> num;
		s.insert(num);
	}
	if (s.size() == N)cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 9600
N, T = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(N)]

items.sort()

ans = 0
dp = {0: 0}
for wi, vi in items:
    for w, v in dp.items():
        if w < T:
            v2 = v + vi
            if v2 > ans:
                ans = v2

    for w, v in list(dp.items()):
        w2 = w + wi
        if w2 <= T:
            v2 = v + vi
            if w2 in dp:
                if v2 > dp[w2]:
                    dp[w2] = v2
            else:
                dp[w2] = v2

v2 = max(dp.values())
ans = max(ans, v2)

print(ans)


Measured memory_bytes: 52824
import itertools

N,M,Q = map(int,input().split())
abcd = []
for _ in range(Q):
    abcd.append(list(map(int,input().split())))

ans = 0
for c in itertools.combinations_with_replacement(range(1,M+1),N):
        tmp = 0
        for q in abcd:
            if c[q[1]-1] == c[q[0]-1] + q[2]:
                tmp += q[3]
            ans = max(ans,tmp)

print(ans)

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

int main() {
 int N;
 cin >> N;
 vector<int> v(N);
 vector<int> c(N);
  
 for (int i=0; i < N; i++) cin >> v.at(i);
 for (int i=0; i < N; i++) cin >> c.at(i);
  
  int total = 0;
  
  for (int i=0; i < N; i++){
    if(v.at(i) > c.at(i)) total += v.at(i)-c.at(i);
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
  int n;
  while(~scanf("%d",&n)){
    bool f=false;
    for(int i=0; i<10; i++)
      if(n>>i&1)
	if(f)
	  printf(" %d",1<<i);
	else{
	  f=true;
	  printf("%d",1<<i);
	}
    printf("\n");
  }
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

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

int main(){
    ll a, b, c; cin >> a >> b >> c;
    cout << (a + b - 1) / b * c << endl;
    return 0;
} 

Measured memory_bytes: 3632
import java.math.BigInteger
import java.util.*

data class Color(
  var x: Int = 0,
  var y: Int = 0,
  var z: Int = 0
) {
  fun hat(num: Int) {
    when {
      x == num -> x += 1
      y == num -> y += 1
      z == num -> z += 1
    }
  }

  fun t(num: Int): Int {
    var t = 0
    if (x == num) t += 1
    if (y == num) t += 1
    if (z == num) t += 1
    return t
  }
}

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val hats = Array(n) { sc.nextInt() }
  val color = Color()

  var result = BigInteger.ONE
  for (hat in hats) {
    result = result.multiply(BigInteger(color.t(hat).toString()))
    color.hat(hat)
  }
  println(result.mod(BigInteger("1000000007")))
}

Measured memory_bytes: 118736
import java.util.Scanner;
class Main{
	
    public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int A=sc.nextInt();
String op=sc.next();
int B=sc.nextInt();

System.out.println(op.equals("+")? A+B :A-B);   

 }
  }

 

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

mapa = {}
for i in range(n):
    if a[i] in mapa:
        mapa[a[i]] += 1
    else:
        mapa[a[i]] = 1

mapsa = sorted(mapa.items(), key=lambda x: x[1])
count = 0
if len(mapsa) > k:
    for i in range(len(mapsa) - k):
        count += mapsa[i][1]
print(count)

Measured memory_bytes: 38964
n = gets.to_i
$l = 0

catch(:break_loop) do
    10.times do |uhen|
        $i = uhen
        10.times do |sahen|
            (puts "Yes" ; throw :break_loop) if $i * sahen == n
        end
        $l = $l + 1
    end
end

puts "No" if $l == 10

Measured memory_bytes: 1788
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;

	public static void main(String[] args) {
		int N=sc.nextInt();
		
		int a=0,b=0;
		for(int i=1;i<=N;i++) {
			if(i%2==0) {
				a++;
			}else {
				b++;
			}
		}
		System.out.println((double)b/N);
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int a[200005],b[200005];
int main()
{
	int x,y,z;cin>>x>>y>>z; 
swap(x,y);swap(x,z);
	cout<<x<<' '<<y<<' '<<z;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define int ll
#define Endl endl

signed main(){
    int N,M;
    int A[114514],B[114514];
    int X=0,Y=0;
    cin >> N >> M;
    REP(i,N){cin >> A[i];}
    REP(i,M){cin >> B[i];}
    REP(i,N-1){
        X=(X+(i+1)*(N-i-1)*(A[i+1]-A[i]))%MOD;
    }
    REP(i,M-1){
        Y=(Y+(i+1)*(M-i-1)*(B[i+1]-B[i]))%MOD;
    }
    cout << (X*Y)%MOD << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,M;
    cin>>N>>M;
    vector<int> A, B;
    set<int> a,b,c;
    rep(i,0,N){
        int k;
        cin>>k;
        A.pb(k);
        a.insert(k);
        c.insert(k);
    }
    rep(j,0,M){
        int k;
        cin>>k;
        B.pb(k);
        b.insert(k);
        c.insert(k);
    }
    sor(A);
    sor(B);
    ll ans=1;
    rer(i,M*N+1,1){
        if(ub(A,i)-lb(A,i)>=2||ub(B,i)-lb(B,i)>=2){
            cout <<0<<"\n";
            return 0;
        }
        else if(ub(A,i)-lb(A,i)==0&&ub(B,i)-lb(B,i)==0){
            if(M*N-i>=(A.end()-lb(A,i))*(B.end()-lb(B,i))){
                cout <<0<<"\n";
                return 0;
            }
            ans*=((A.end()-lb(A,i))*(B.end()-lb(B,i))%MOD-(M*N-i)%MOD);
            ans=(ans%MOD+MOD)%MOD;
        }
        else if(ub(A,i)-lb(A,i)==1){
            if(ub(B,i)-lb(B,i)==0) ans*=B.end()-lb(B,i);
            else ans*=1;
            ans%=MOD;
        }
        else if(ub(B,i)-lb(B,i)==1){
            ans*=A.end()-lb(A,i);
            ans%=MOD;
        }
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 384
from collections import Counter
S = input()
L = len(S)
ans = [''] * L
chara = []
chrstat = Counter(S).most_common
for (k, v) in reversed(Counter(S).most_common()):
    for _ in range(v):
        chara.append(k)
for i in range(0, L, 3):
    ans[i] = chara.pop()
for i in range(1, L, 3):
    ans[i] = chara.pop()
for i in range(2, L, 3):
    ans[i] = chara.pop()
ans = ''.join(ans)
print("YES" if all(ans[i] != ans[i + 1] for i in range(L - 1)) and \
      all(ans[i] != ans[i + 2] for i in range(L - 2)) else "NO")


Measured memory_bytes: 5108
#include "bits/stdc++.h"

using namespace std;
static const int INF = (1 << 21);


int main() {
	string S;
	int n,k;
	cin >> n >> k;
	int ans = 1;
	for (int i = 0;i < n;i++) {
		if (ans * 2 > ans + k) ans +=k;
		else ans *= 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
li = [0]*(m+1)
cnt = 0
        
for i in arr:
  for j in range(i, m+1, i):
    li[j] += 1

for i in arr:
  if li[i] == 1:
    cnt += 1

print(cnt)

Measured memory_bytes: 32300
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const char s[4]={'R','G','B','Y'};

int main() {
	int n=read(),m=read(),k=read();
	for (int i=0;i<n;++i) {
		for (int j=0;j<m;++j) {
			int x=(m+i+j)/k&1,y=(m+i-j)/k&1;
			putchar(s[x<<1|y]);
		}
		puts("");
	}
	return 0;
}
// cy

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

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int n;
ll ans[16];
int cur[16];
int x[16],y[16],p[16];
int minx[40000][16],miny[40000][16];

void dfs(int m,int rx,int ry,int kisuu,int kazu){
  if(m==n){
    ll temp=0;
    for(int i=0;i<n;i++){
      temp+=1ll*p[i]*min(minx[rx][i],miny[ry][i]);
    }
    ans[kazu]=min(ans[kazu],temp);
  }
  else{
    cur[m]=1;
    dfs(m+1,rx+kisuu,ry,2*kisuu,kazu+1);
    cur[m]=0;
    dfs(m+1,rx,ry,2*kisuu,kazu);
    cur[m]=-1;
    dfs(m+1,rx,ry+kisuu,2*kisuu,kazu+1);
  }
  return;
}

int main() {
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i]>>p[i];
  }
  for(int i=0;i<n+1;i++){
    ans[i]=1e18;
  }
  for(int i=0;i<(1<<n);i++){
    bool ch[n];
    for(int j=0;j<n;j++){
      ch[j]=false;
    }
    for(int j=0;j<n;j++){
      if((i>>j)&1) ch[j]=true;
    }
    for(int j=0;j<n;j++){
      if(ch[j]){
        minx[i][j]=0;
        miny[i][j]=0;
      }
      else{
        int tempx=min(abs(x[j]),abs(y[j]));
        int tempy=tempx;
        for(int k=0;k<n;k++){
          if(ch[k]){
            tempx=min(tempx,abs(x[j]-x[k]));
            tempy=min(tempy,abs(y[j]-y[k]));
          } 
        }
        minx[i][j]=tempx;
        miny[i][j]=tempy;
      }
    }
  }
  dfs(0,0,0,1,0);
  for(int i=0;i<=n;i++){
    if(ans[i]==1e18) cout<<0<<endl;
    else cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 7728
package main

// Solution for https://atcoder.jp/contests/abc174/tasks/abc174_a

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var s int
	con.Scan(&s)
	if s >= 30 {
		con.Println("Yes")
	} else {
		con.Println("No")
	}
	return nil
}


Measured memory_bytes: 1844
import math

N, M = map(int, input().split())

# N = 100000
# M = 1000000000

def pfac(n):
    values = [1, n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            values.append(i)
            values.append(n // i)
    return values

L = pfac(M)
L = [i for i in L if i * N <= M]

ans = []
for i in L[::-1]:
    if (M - (N * i)) % i == 0:
    # if M % i == 0:
        ans.append(i)
print(max(ans))

# ans2 = 1
# for i in L[::-1]:
#     if (M - (N * i)) % i == 0:
#     # if M % i == 0:
#         ans2 = i
#         break
# print(ans2)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a <= c && b >= c ) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

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

    vector<int> n(3);

    REP(i, 3)
    {
        cin >> n[i];
    }

    sort(n.begin(), n.end());
    cout << n[0] << " " << n[1] << " " << n[2] << endl;

    return 0;
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;


int wlim = 100010;

void push(vector<P>& res, const P& p) {
    if (p.first < wlim && (res.size() == 0 || p.second > res[(int)res.size() - 1].second)) {
        res.push_back(p);
    }
}

vector<P> update(const vector<P>& lis, int v, int w) {
    int sz = lis.size();
    int p1 = 0, p2 = 0;
    vector<P> res;
    while (p1 < sz || p2 < sz) {
        if (p2 == sz) {
            push(res, lis[p1]);
            ++p1;
        }
        else if (p1 == sz) {
            push(res, { lis[p2].first + w, lis[p2].second + v });
            ++p2;
        }
        else {
            if (lis[p1].first < lis[p2].first + w) {
                push(res, lis[p1]);
                ++p1;
            }
            else if (lis[p1].first > lis[p2].first + w) {
                push(res, { lis[p2].first + w, lis[p2].second + v });
                ++p2;
            }
            else {
                push(res, { lis[p1].first, max(lis[p1].second, lis[p2].second + v) });
                ++p1;
                ++p2;
            }
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> v(n), w(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i] >> w[i];
    }
    int q;
    cin >> q;
    vector<vector<P>> que(n, vector<P>());
    for (int i = 0; i < q; ++i) {
        int u, l;
        cin >> u >> l;
        --u;
        que[u].push_back({ l, i });
    }
    int lm = 1 << 12;
    vector<vector<P>> vs(lm);
    vs[0] = { { 0, 0 } };
    vector<int> ans(q);
    for (int i = 0; i < n; ++i) {
        if (i < lm) {
            vs[i] = update(vs[(i - 1) / 2], v[i], w[i]);
            for (auto& p : que[i]) {
                int ma = 0;
                for (auto& j : vs[i]) {
                    if (j.first <= p.first) {
                        ma = max(ma, j.second);
                    }
                }
                ans[p.second] = ma;
            }
        }
        else {
            int a = i;
            vector<P> lis = { { 0, 0 } };
            while (a >= lm) {
                lis = update(lis, v[a], w[a]);
                a = (a - 1) >> 1;
            }

            for (auto& p : que[i]) {
                int l = p.first;
                int k = (int)vs[a].size() - 1;
                int ma = 0;
                for (int j = 0; j < (int)lis.size(); ++j) {
                    while (k >= 0 && lis[j].first + vs[a][k].first > l) {
                        --k;
                    }
                    if (k < 0) break;
                    ma = max(ma, lis[j].second + vs[a][k].second);
                }
                ans[p.second] = ma;
            }
        }
    }
    for (auto& i : ans) {
        cout << i << '\n';
    }
    return 0;
}


Measured memory_bytes: 95916
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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;
}
///////////////////////////////////////////////

/*（๑•﹏•๑｀) */

int main() {
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e-a <= k) printf("Yay!\n");
    else printf(":(\n");
}


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

int main()
{
 string s;
  cin>>s;
  bool flag=false;
  if(s[0]=='A')
  {
    if(islower(s[1]))
    {
      for(int i=2;i<s.length()-1;i++)
      {
        if(islower(s[i]))
           continue;
        else if(s[i]=='C')
          {
            if(!flag)
            {
              flag=true;
            }
            else
            {
              cout<<"WA\n";
              return 0;
            }
          }
      }
      if(flag&&islower(s[s.length()-1]))
       cout<<"AC\n";
      else
        cout<<"WA\n";
    }
    else
    {
      cout<<"WA\n";
      return 0;
    }
  }
  else
    cout<<"WA\n";
  return 0;
}


Measured memory_bytes: 256
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, p=0, h, f=0;
    cin>>n>>m;
    ll a[n];
    for(i=0; i<n; i++){
        cin>>a[i];
        if(a[i]>p)p=a[i];
    }
    if(m>p){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        k=a[0];
        for(i=1; i<n; i++){
            k=__gcd(k, a[i]);
        }
        if(m%k==0)cout<<"POSSIBLE"<<endl;
        else cout<<"IMPOSSIBLE"<<endl;
    }

    return 0;
}



Measured memory_bytes: 4312
//
//  main.cpp
//  B
//
//  Created by 黄道煜 on 2018/9/22.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#define LL unsigned long long
using namespace std;

int n;
LL x, a[200005], ans=1e18;

int main()
{
    scanf("%d%lld", &n, &x);
    for(int i=1; i<=n; i++) scanf("%lld", &a[i]), a[i]+=a[i-1];
    for(int i=1, j; i<=n; i++)
    {
        LL temp=2*(a[n]-a[n-i])+(n+i)*x;
        for(j=1; i*j<=n; j++) temp+=(a[n-i*(j-1)]-a[n-i*j])*(2*j+1);
        temp+=a[n-i*j+i]*(2*j+1);
        ans=min(ans, temp);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int w, a, b;
  cin>>w>>a>>b;
  if(b>=a && b<=w+a){
    cout<<0<<endl;
  }else if(b>a+w){
    cout<<b-(a+w)<<endl;
  }else{
    cout<<a-(b+w)<<endl;
  }
}

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

int main(){
  int a,b,c,ans;
  cin >> a >> b >> c;
  if (a!=b && b!=c && c!=a){
    ans = 3;
  }
  else if( a==b && b==c){
    ans = 1;
  }
  else{
    ans=2;
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 256
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]
import sys
from collections import Counter
d = Counter(d)
for i in t:
    if not i in d:
        print('NO')
        sys.exit()
    d[i] -= 1
print('YES') if min(d.values()) >= 0 else print('NO')

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

namespace RMQ{
  const int MAX_N = 1 << 17;
  int n, dat[2*MAX_N - 1];

  void init(int n_){
    n = 1;
    while(n < n_){
      n *= 2;
    }

    for(int i =0; i < 2*n-1;++i){
      dat[i] = INT_MAX;
    }
  }

  void update(int k, int a){
    k += n-1;
    dat[k] = a;
    while(k>0){
      k = (k-1)/2;
      dat[k] = min(dat[k*2+1],dat[k*2+2]);
    }
  }
  int rec(int a,int b,int k,int l, int r){
    if(r <= a || b <= l){
      return INT_MAX;
    }
    if(a <= l && r <= b){
      return dat[k];
    }
    else{
      int vl,vr;
      vl = rec(a,b,k*2+1,l,(l+r)/2);
      vr = rec(a,b,k*2+2,(l+r)/2,r);
      return min(vl,vr);
    }
  }
  int query(int a,int b){
    return rec(a,b,0,0,n);
  }
}
using namespace RMQ;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,t;
  cin >> N >> t;
  init(N);
  vector<ll> k(N);
  rep(i,N){
    cin >> k[i];
    update(i,k[i]);
  }
  vector<ll> v(N);
  ll m = 0;
  map<ll,ll> ans;
  for(int i = N - 1; i >= 0; --i){
    v[i] = k[i] - query(0,i);
    m = max(m,v[i]);
    ans[v[i]]++;
  }
  cout << ans[m] << endl;
  return 0;
}



Measured memory_bytes: 9088
H, W = map(int, input().split())
data= [str(input()) for i in range(H)]

new_data = []
row = [0] * W
for d in data:
    if d.count('.') == W:
        continue
    new_data.append(d)
    for i in range(W):
        if d[i] == '.':
            row[i] += 1

num = len(new_data)

for d in new_data:
    for i in range(W):
        if row[i] != num:
            print(d[i], end='')
    print()




Measured memory_bytes: 4468
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int N, K, d;
	cin >> N >> K;
	vector<int> s(N, 0);

	for (int i = 0; i < K; ++i) {
		int d;
		cin >> d;
		for (int j = 0; j < d; ++j) {
			int A;
			cin >> A;
			s[A-1]++;
		}
	}
	
	int ans = 0;
	for (auto ss : s) {
		if (ss == 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3588
package main

import (
	"fmt"
)

func main() {
	var A, B, C int
	var check bool = false
	fmt.Scan(&A)
	fmt.Scan(&B)
	fmt.Scan(&C)
	for i := 1; i < 101; i++ {
		if (A*i)%B == C {
			check = true
		}
	}
	if check {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#Python Template

from sys import stdin, stdout

def main():
	n = int(stdin.readline())
	prime = 10**9 + 7
	if n == 1:
		print(0)
	else:
		total = (10**n)%prime
		no0 = (9**n)%prime
		inter = (8**n)%prime
		ans = (total-(no0*2-inter)+prime)%prime
		print(ans)

	

main()

Measured memory_bytes: 10724
k, n = map(int, input().split())
a = list(map(int, input().split()))
ans = k
b = a[0] + (k-a[-1])

prev = a[0]

for i, v in enumerate(a):
    if i == 0:
        ans = min(ans, k-b)
    ans = min(ans, k-(v-prev))
    prev = v
    
print(ans)

Measured memory_bytes: 26100
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

using ll = long long ;

class BBreakNumber {
public:
	void solve(std::istream& cin, std::ostream& cout) {
	    int n ;
	    cin >> n ;
	    int ans = 0 ;
	    for(int i = n ; i>=0 ; --i){
	        if(i && (!(i & (i - 1)))){
	            cout << i  ;
	            return ;
	        }
	    }
	}
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	BBreakNumber solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <queue>
using namespace std;
int ans = 0x7ffffff;  
int movee[5][3];  
bool visited[848][848];  
int r,c,k;  
int sx,sy;  
int a[848][848];  
char s[1000];  
queue<int> q;  
void bfs(int x,int y,int step)  
{  
    q.push(x);q.push(y);q.push(0);  
    int cur_ans,cx,cy,cd,xx,yy,dd;  
    visited[x][y] = true;  
    while (!q.empty())  
    {  
        cx = q.front();
        q.pop();  
        cy = q.front();
        q.pop();  
        cd = q.front();
        q.pop();  
        cur_ans = cx - 1;  
        cur_ans = min(cur_ans,cy - 1);  
        cur_ans = min(cur_ans,r - cx);  
        cur_ans = min(cur_ans,c - cy);  
        ans = min(ans,cur_ans);  
        if(cd == k)
        {
            continue;
        }  
        for(int i = 1;i <= 4; ++i)  
        {  
            xx = cx + movee[i][1];yy = cy + movee[i][2];  
            if(xx < 1 || xx > r || yy < 1 || yy > c)
            {
                continue;  
            }
            if(a[xx][yy] == 1 || visited[xx][yy])
            {
                continue;
            }
            visited[xx][yy] = 1;
            q.push(xx);
            q.push(yy);
            q.push(cd + 1);  
        }  
    }  
}  
  
int main ()  
{  
    movee[1][1] = 1;movee[1][2] = 0;  
    movee[2][1] = 0;movee[2][2] = 1;  
    movee[3][1] = -1;movee[3][2] = 0;  
    movee[4][1] = 0;movee[4][2] = -1;  
    cin>>r>>c>>k; 
    for(int i = 1;i <= r; ++i)  
    {  
        for(int j = 1;j <= c;j++)  
        {  
            char c;
            cin>>c;
            if(c == '#') 
            {
                a[i][j] = 1; 
            } 
            else if(c == '.')
            {
                a[i][j] = 2;  
            }
            else if(c == 'S')  
            {  
                sx = i;
                sy = j;  
                a[i][j] = 2;  
            }  
        }  
    }  
    bfs(sx,sy,0);  
    printf("%d\n",1 + (ans + k - 1) / k);  
    return 0;  
}  

Measured memory_bytes: 3584
def insertSort(n, a):
  for i in range(n):
    v = a[i]
    j = i - 1
    while 0 <= j and v < a[j]:
      a[j + 1] = a[j]
      j -= 1
    a[j + 1] = v
    print(*a)

insertSort(int(input()), [int(i) for i in input().split()])



Measured memory_bytes: 5976
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	vector<long> as(n);
	long all = 0;
	for (long& a : as)
	{
		cin >> a;
		all += a;
	}
	vector<long> cs[2];
	for (int i = 0; i < n; i++)
	{
		cs[0].push_back(as[(i*2+1)%n]);
		cs[1].push_back(as[(i*2+2)%n]);
	}
	long sum[2] = {0}, idx[2] = {n/2, n/2};
	for (int i = 0; i < n/2; i++)
	{
		sum[0] += cs[0][i];
		sum[1] += cs[1][i];
	}
	for (int i = 0; i < n; i++)
	{
		cout << all - 2*sum[i&1] << '\n';
		sum[i&1] += cs[i&1][idx[i&1]];
		sum[i&1] -= cs[i&1][idx[i&1]-n/2];
		idx[i&1]++;
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 3820
N, K = map(int, input().split())
A = list(map(int, input().split()))
Ad = {a:0 for a in set(A)}
if len(set(A)) <= K:
    print(0)
else:
    cnt = 0
    for a in A:
        Ad[a] += 1
    Ad = sorted(Ad.items(), key=lambda x: x[1])
    for i in range(len(set(A))-K):
        cnt += Ad[i][1]
    print(cnt)

Measured memory_bytes: 50864