akhauriyash/Code-Regression huggingface dataset:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,K = mint()
ans = 0

def div2(x):
    k = 0
    while x<K:
        k += 1
        x *= 2
    return k

for i in range(1,N+1):
    ans += (1/N)*(1/2)**div2(i)
print(ans)

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

ll SUM(ll n)
{
    return n * (n + 1) / 2;
}

int main()
{
    ll n;
    cin >> n;
    ll ans = SUM(n) - SUM(n / 3) * 3 - SUM(n / 5) * 5 + SUM(n / 15) * 15;
    cout << ans << endl;
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	int K;
	cin >> S >> K;

	int oi = 0;
	while (S[oi] == '1')oi++;

	if (K <= oi)
	{
		cout << '1' << endl;
	}
	else
	{
		cout << S[oi] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
ulong MIDDLE = 100_000;
alias Pair = Tuple!(long, "flag", long, "num");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto n = lread();
    auto d = aryread();
    auto m = lread();
    auto t = aryread();
    d.sort(), t.sort();
    long iter, flag = 1;
    foreach (e; t)
    {
        while (iter < n && d[iter] != e)
            iter++;

        if (iter++ >= n)
        {
            flag = 0;
            break;
        }
    }
    if (flag)
        writeln("YES");
    else
        writeln("NO");
}


Measured memory_bytes: 19220
#include <bits/stdc++.h>
#include <atcoder/all>
#define F first
#define S second
using namespace std;
using namespace atcoder;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
typedef pair<int, int> P;
const ll Mod = 1000000007;
int main() {
  int N,M;
  cin >> N >> M;
  dsu d(N);
  bool seen[N];
  for (int i = 0; i < N; i++) {
    seen[i] = false;
  }
  for (int i = 0; i < M; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    d.merge(a,b);
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    seen[d.leader(i)] = true;
  }
  for (int i = 0; i < N; i++) {
    if (seen[i]) {
      cnt++;
    }
  }
  int ans = cnt - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3820
N = int(input())
X = list(map(int, input().split()))
X_min = min(X)
X_max = max(X)
min_sum = float('inf')
for i in range(X_min, X_max+1):
    sum = 0
    for j in X:
        sum += (j-i)**2
    min_sum = min(min_sum, sum)
print(min_sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c;
    cin>>a>>b;
    if((a+b)%2==0)
    {
        c=(a+b)/2;
        cout<<c<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";

string SetAns() {
//	const ll max = 1000000000000001;
	ll N;
	cin >> N;
	string nowAns = "";
	do {
		N--;
		nowAns = (char)('a' + N % 26) + nowAns;
		N = N / 26; //整数除算
	} while (N > 0);
	return nowAns;
}

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


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<ll> a(n+1);
    a[0] = 2; a[1] = 1;
    for (int i = 2; i <= n; ++i) {
        a[i] = a[i-1] + a[i-2];
    }
    cout << a[n] << endl;
    
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
string Yes[2] = {"Yes", "No"};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;

/*------------------------------------------------------------------*/


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

    ll n; cin >> n;
    vector<mint> a(n);
    rep(i, n) cin >> a[i];
    vector<mint> a_sum(n + 1);
    a_sum[n] = 0;
    for(int i = n - 1; i >= 0; i--) a_sum[i] = a_sum[i + 1] + a[i];
    //rep(i, n + 1) cout << a_sum[i] << endl;

    mint ans = 0;
    rep(i, n - 1) ans += a[i] * a_sum[i + 1];
    cout << ans << endl;
}

Measured memory_bytes: 4772
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    int w, c = 1;
    while(cin >>w && w){
        int n;
        cin >>n;
        vector< vector<int> > dp(n + 1, vector<int>(w + 1));
        REP(i, dp.size()){
            REP(j, dp[i].size()){
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 0;
        //input begin
        vector<P> j(n + 1);
        string str;
        getline(cin, str);
        FOR(i, 1, n + 1){
            getline(cin, str);
            stringstream ss(str);
            int a, b;
            char c;
            ss >>a >>c >>b;
            j[i].first = a;
            j[i].second = b;
        }
        //input end

        FOR(i, 1, dp.size()){
            int value = j[i].first, weight = j[i].second;
            REP(j, dp[i].size()){
                if(j >= weight){
                    dp[i][j] = max(dp[i][j], dp[i - 1][j - weight] + value);
                }
                dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            }
        }

        int ans_v = -1, ans_w = 0;
        REP(i, dp[0].size()){
            if(dp[n][i] > ans_v){
                ans_v = dp[n][i];
                ans_w = i;
            }
        }
        cout <<"Case " <<c <<":" <<endl <<ans_v <<endl <<ans_w <<endl;
        c++;
    }
    return 0;
}

Measured memory_bytes: 5196
#include<stdio.h>

int main(void){

int i, j, k, n, v;
int A[100];

scanf("%d",&n);

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

for(k=0;k<n-1;k++){
    printf("%d ",A[k]);
}
printf("%d\n",A[n-1]);

for(i=1;i<n;i++){
    v = A[i];
    for(j=i-1;j>=0;j--){
        if(A[j]>v) A[j+1] = A[j];
        else break;
    }
    A[j+1] = v;
    for(k=0;k<n-1;k++){ 
        printf("%d ",A[k]);
    }
    printf("%d\n",A[n-1]);
}
return 0;
}
    
    



Measured memory_bytes: 2044
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

N = onem()

for h in range(1,3501):
    for n in range(1,3501):
        if (4*h*n - N*n - N*h) > 0 and (N*h*n)/(4*h*n - N*n - N*h) == (N*h*n)//(4*h*n - N*n - N*h):
            print(h,n,(N*h*n)//(4*h*n - N*n - N*h))
            exit()










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

int main(){
  vector<int> data(3);
  cin>>data.at(0);
  cin>>data.at(1);
  cin>>data.at(2);
  
  int k;
  cin>>k;
  
  sort(data.begin(),data.end());
  
  int answer=data.at(0)+data.at(1);
  
  for (int i=0;i<k;i++){
    data.at(2)*=2;
  }
  
  answer+=data.at(2);
  
  cout<<answer<<endl;
  
  
}

  













Measured memory_bytes: 256
use proconio::marker::Usize1;
use std::collections::VecDeque;
use petgraph::graph::{Graph};

fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        mat: [(Usize1, Usize1);m],
    }

    // create graph
    let mut g = Graph::<(),(),petgraph::Undirected>::new_undirected();
    let nodes: Vec<_> = (0..n).map(|_| g.add_node(())).collect();
    g.extend_with_edges(mat.iter().map(|&x| (nodes[x.0], nodes[x.1])));

    // globals
    let mut mark = vec![0;n];
    let mut visited = vec![false;n];
    let mut q = VecDeque::new();

    // bfs
    q.push_back(nodes[0]);
    visited[nodes[0].index()] = true;
    while q.len() != 0 {
        let curr = q.remove(0).unwrap();
        g.neighbors(curr)
        .for_each(|ni| {
            if !visited[ni.index()] {
                visited[ni.index()] = true;
                mark[ni.index()] = curr.index();
                q.push_back(ni);
            }
        })
    }

    println!("Yes");
    mark.iter().skip(1).for_each(|&x| println!("{}", x+1));
}


Measured memory_bytes: 12692
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	char s[10];
	for (int i = 0; i < 10; i++) {
		cin >> s[i];
	}
	s[3] = '8';
	for (int i = 0; i < 10; i++) {
		cout << s[i];
	}
	cout << endl;
}

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

int main(){
  long long n,s,i;
  cin >> n;
  s=0;
  for(i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0){
      s=s+i;
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int R=1,C=1,H[2000010]={0};
int N[2000010]={-1000};
int hyouka(int a,int b){//printf("%d %d\n",a,b);
  if(b==0)return 0;
  if(C<b)return 1;
  if(C<a)return 0;
  return N[H[a]]>N[H[b]]?1:0;
}
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;//prih();//printf("%d\n",i);
}
int hout(){
  int rt=H[1],i=0,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[i/2]=k;
  return rt;
}
int main(){
  int a;
  char s[100];
  while(scanf("%s",s),s[2]-'d'){//prih();
    if(s[2]=='s'){
      scanf("%d",&a);
      hin(a);
    }
    else printf("%d\n",N[hout()]);
  }//prih();
  return 0;
}

Measured memory_bytes: 12980
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int ans = 0;
  rep(i, s.size()-1) {
    if(s[i] != s[i+1]) ans++;
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000001;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
ll ac[100010],cc[100010],hc[100010];
ll b[100010];
int main(){
    string s;cin>>s;
    int n=s.length();
    b[0]=1;
    for(int i=0;i<=n;i++){
        b[i+1]=b[i]*3;
        b[i+1]%=MOD;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='A'){
            ac[i]++;
        }else if(s[i]=='C'){
            cc[i]++;
        }else if(s[i]=='?'){
            hc[i]++;
        }
        ac[i+1]+=ac[i];
        cc[i+1]+=cc[i];
        hc[i+1]+=hc[i];
    }
    ll ans=0;
    for(int i=1;i<n-1;i++){
        if(s[i]=='B'||s[i]=='?'){
            ll acc=ac[i-1];
            ll ccc=cc[n-1]-cc[i];
            ll hc1=hc[i-1];
            ll hc2=hc[n-1]-hc[i];
            ll s2=(ccc*b[hc2]%MOD+hc2*b[hc2-1]%MOD)%MOD;
            ans+=acc*s2%MOD*b[hc1]%MOD;
            ans%=MOD;
            ans+=hc1*s2%MOD*b[hc1-1]%MOD;
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  ll K, A, B;
  cin >> K >> A >> B;
  if (A + 1 >= B || A >= K) {
    cout << K + 1 << endl;
    return 0;
  }
  ll dis = B - A;
  K -= (A - 1);
  cout << A + (dis * (K / 2)) + (K % 2) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <map>
#include <numeric>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    ll n, c = 0;
    string s, t = "RGB";
    map<char, ll> m;
    for (auto i = t.begin(); i != t.end(); ++i) m[*i];
    cin >> n >> s;
    for (ll i = 0; i < n; ++i) {
        for (ll j = i + 2; j < n; j += 2) {
            ll k = (i + j) / 2;
            if (s.at(i) != s.at(j) && s.at(i) != s.at(k) && s.at(j) != s.at(k)) ++c;
        }
        ++m[s.at(i)];
    }
    cout << accumulate(m.begin(), m.end(), 1LL, [](ll i, pair<char, ll> j) {
        return i *= j.second;
    }) - c << endl;
    return 0;
}


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

int main(){
    int n,ans;
    vector<int> v1,v2;
    cin >> n;
    v1.push_back(1);v2.push_back(1);
    for(int i=0;i<6;i++) v1.push_back(v1.back()*6);
    for(int i=0;i<5;i++) v2.push_back(v2.back()*9);
    sort(v1.begin(),v1.end(),greater<int>());
    sort(v2.begin(),v2.end(),greater<int>());
    ans=n;
    for(int i=0;i<n+1;i++){
        int v1_n=i,v2_n=n-i,cnt=0;
        for(auto iter=v1.begin();iter!=v1.end();iter++) cnt+=v1_n/(*iter),v1_n%=(*iter);
        for(auto iter=v2.begin();iter!=v2.end();iter++) cnt+=v2_n/(*iter),v2_n%=(*iter);
        if(cnt<ans) ans=cnt;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    import numpy as np
    n = int(input())
    a = list(map(int, input().split()))
    b = np.array([0] + a + [0])
    c = np.abs(np.diff(b))
    s = np.sum(c)
    t = np.array([-(c[i - 1] + c[i]) + abs(b[i + 1] - b[i - 1]) for i in range(1, n + 1)])
    u = s + t
    v = list(map(str, u))
    ans = '\n'.join(v)
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    int N, M;
    cin >> N;
    map<string, int> s, t;
    for (int i = 0; i < N; i++) {
        string a; cin >> a;
        s[a] ++;
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        string b; cin >> b;
        t[b] ++;
    }

    int ans = 0;
    for (auto v : s) {
        int val = s[v.first]-t[v.first];
        ans = max(ans, val);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<u32> = read_as_vec();
    let (n, k) = (line[0], line[1]);

    if k == 1{
        println!("0");
    }else{
        println!("{}", n-k);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i],v[i]=-v[i];
	map<ll,ll> mp;
	ll ans=0;
	rep(i,n){
		auto itr=mp.upper_bound(v[i]);
		if(itr==mp.end()){
			ans++;
			mp[v[i]]++;
		}
		else{
			(*itr).sc--;
			if((*itr).sc==0){
				mp.erase((*itr).fs);
			}
			mp[v[i]]++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 7168
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner (System.in);
		
	int N = sc.nextInt();
	int R = sc.nextInt();
	
	if(N>10) {
		System.out.println(R);
	}else {
		System.out.println(R+(100*(10-N)));
	}
	
	}
}

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

int main() {
    int n;
    cin >> n;
    int A[n] = {0};

    rep(i, n - 1) {
        int a;
        cin >> a;
        A[a - 1]++;
    }

    rep(i, n) cout << A[i] << endl;

    return 0;
}


Measured memory_bytes: 4400
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

# 公式：comb(n, r) = n!/((n-r)!r!)

# 公式より、 n > m ならば comb(n, r) > comb(m, r)
# また、 n, m > r なので、 a の中から r が取りうる値は n の時の方が多い。
# 以上より、 comb(ai, aj) を大きくするには ai は大きいほど良い。

ai, i = a.each_with_index.max

# 公式より、 comb(n, r) を大きくするには、 r が floor(n / 2) に近いほど良い。

class Array
  def dup_delete_at(pos)
    dup = self.dup
    dup.delete_at(pos)
    dup
  end
end
ideal = ai / 2
aj = a.dup_delete_at(i).min_by { |ak| (ak - ideal).abs }

puts "#{ai} #{aj}"


Measured memory_bytes: 12804
a,b,k = map(int,input().split())
from fractions import gcd
ans = gcd(a,b)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
print(make_divisors(ans)[::-1][k-1])



Measured memory_bytes: 63980
#include <iostream>
using namespace std;
long cur=1e9;
inline bool check(long x){
    cout<<"? "<<x<<endl;
    char res;
    cin>>res;
    return res=='Y';
}
int main(){
    if(check(cur))while(cur>1 && check(cur-1))cur/=10;
    else{
        while(!check(cur/=10));
        long lb=cur,ub=cur*10;
        while(ub-lb>1){
            long mid=(lb+ub)/2;
            if(check(mid*10))ub=mid;
            else lb=mid;
        }
        cur=ub;
    }
    cout<<"! "<<cur<<endl;
    return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(void){
	int a[100]={0},sum=0,num,i;
	while(scanf("%d",&num) != EOF){
		a[num-1] ++;
		if(sum < a[num-1])
			sum = a[num-1];
	}
	for(i=0;i<100;i++){
		if(sum == a[i])
			printf("%d\n",i+1);
	}
	return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    int ans = 0;
    for(int i=0; i<n; i++){
        int sum = 0;
        int cur = h[i];
        while(i + 1 < n && cur >= h[i+1]){
            cur = h[i+1];
            i++;
            sum++;
        }

        chmax(ans, sum);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main() {
    int N, K, count = 0;
    string S;
    cin >> N >> K >> S;
    for(int i = 0; i < N - 1; i++) if(S[i] == S[i+1]) count++;
    cout << min(count + 2 * K, N - 1) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

//C++17
template<typename Type>
Type GCD(Type a,Type b){ return b ? GCD(b,a%b) : a ;}
template<typename Type>
Type LCM(Type a,Type b){ return a*b / GCD(a,b) ;}

template<typename Type>//文字列の置換/Boost:replace_all()
Type replace_str(Type str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n,w;
    cin >> n >> w;
    vector<ll> weight(110);
    vector<ll> value(110);
    rep(i,n)cin >> weight[i] >> value[i];
    vector<vector<ll>> dp(n+1,vector<ll>(w+1));
    for(int i=0;i<n;i++){
        for(int sum_w=0;sum_w<=w;sum_w++){
            if(sum_w - weight[i]>=0){
                dp[i+1][sum_w] = max(dp[i+1][sum_w],dp[i][sum_w - weight[i]] + value[i]);
            }
            dp[i+1][sum_w] = max(dp[i+1][sum_w],dp[i][sum_w]);
            
        }
    }
   cout << dp[n][w] << endl;
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  string k;
  for(char a='a';a<='z';a++){
    int MIN=9999;
    for(int i=0;i<n;i++){
      int cnt=0;
      for(int j=0;j<s[i].size();j++){
       if(s[i][j]==a){cnt++;}
      }
      MIN=min(MIN,cnt);
    }
    for(int i=0;i<MIN;i++){
      k+=a;
    }
  }
  cout<<k<<endl;

  return 0;
}

Measured memory_bytes: 3608
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let mut l: Vec<i32> = readnc();
    l.sort();

    let mut sum = 0;
    for i in 0..n {
        sum += l[i*2];
    }
    println!("{}", sum);
}

Measured memory_bytes: 4352
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;

#define int long long
namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int vv[20][20];
int table[20][20];
void mainmain(){
	int w,h;
	while(cin>>w>>h,w||h){
		rep(i,20){
			rep(j,20){
				vv[i][j]=0;
			}
		}
		rep(i,20){
			rep(j,20){
				table[i][j]=0;
			}
		}
		reep(i,1,w+1){
			vv[0][i]=1;
		}
		rep(i,h){
			rep(j,w){
				cin>>table[i+1][j+1];
			}
		}
		rep(i,h){
			reep(j,1,w+1){
				if(table[i][j]==2){
					vv[i+2][j]+=vv[i][j];
					continue;
				}
				if(table[i][j]==1) continue;
				vv[i+1][j]+=vv[i][j];
				if(i&&j-1>0&&table[i+1][j-1]==0){
					vv[i+1][j-1]+=vv[i][j];
				}
				if(i&&j+1<=w&&table[i+1][j+1]==0){
					vv[i+1][j+1]+=vv[i][j];
				}
			}
		}
		int ans=0;
		reep(i,h,h+2){
			reep(j,1,w+1){
				if(table[i][j]!=1) ans+=vv[i][j];
			}
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1160
import java.util.Scanner;


public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		int a= scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		
		int temp;
		
		if(a>b){
			temp=a;
			a=b;
			b=temp;
		}
		
		if(b>c){
			temp=b;
			b=c;
			c=temp;
		}
		
		if(a>b){
			temp=a;
			a=b;
			b=temp;
		}
		
		System.out.println(Integer.toString(a)+" "+Integer.toString(b)+" "+Integer.toString(c));
		scanner.close();
	}
}

Measured memory_bytes: 17156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
int mod=1e9+7;
int gcd (int a, int b) {
   while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll fast(ll a,ll n){
	a%=mod;
	ll res=1;
	while(n>0){
		if(n&1)res=res*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return res;
}
int digit_sum(int a){
	int sum=0;
	while(a){
		sum+=a%10;
		a/=10;
	}
	return sum;
}
	// vector<int> v;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n;
	// vector<vector<int> >a(n,vector<int>(3,0));
	int W;
	cin>>W;
	int wt[n],v[n];
	// int dp[tw+1][n+1];
	// memset(dp,-1,sizeof dp);
	// f(i,n+1)dp[0][i]=0;
	// f(i,tw+1)dp[i][0]=0;
	//
	f(i,n)cin>>wt[i]>>v[i];
	// f(j,n)cin>>v[j];

		 int i, w;
    ll K[n + 1][W + 1];

    // Build table K[][] in bottom up manner
    for (i = 0; i <= n; i++) {
        for (w = 0; w <= W; w++) {
            if (i == 0 || w == 0)
                K[i][w] = 0;
            else if (wt[i - 1] <= w)
                K[i][w] = max(
                    v[i - 1] + K[i - 1][w - wt[i - 1]],
                    K[i - 1][w]);
            else
                K[i][w] = K[i - 1][w];
        }
    }


	cout<< K[n][W]<<endl;
	return 0;
}



Measured memory_bytes: 82464
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int a_idx, z_idx;
    for (int i=0; i<n; i++) {
        if (s[i] == 'A') {
            a_idx = i;
            break;
        }
    }
    for (int i=n; i>0; i--) {
        if (s[i-1] == 'Z') {
            z_idx = i;
            break;
        }
    }
    cout << z_idx - a_idx << endl;
    return 0;
}

Measured memory_bytes: 640
def intMap(): return map(int,input().split())
def intList(): return list(map(int, input().split())) #横並びの場合
n = int(input())
a = intList()

#MAX_NUM = 1000000 * 1000000 * 1000000
MAX_NUM = 10**18

for i in range(n):
    if a[i] == 0:
        print(0)
        exit()

ans = 1
for i in range(n):
    ans *= a[i]
    if ans > MAX_NUM:
        print(-1)
        exit()

print(ans)



Measured memory_bytes: 21768
#include <bits/stdc++.h>
//#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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(){
  cout << fixed << setprecision(15);

  int x, y, z; cin >> x >> y >> z;

  ll ans = 0;
  //string ans = "No";

  x -= y + z + z;
  ans = 1;
  ans += x / (y + z);
  
  cout << ans << endl;

  return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N;
	cin >> N;
	vector <ll> A(N+1, 0);
	for (int ii = 0; ii < N+1; ++ii){
		cin >> A[ii];
	}
	vector <ll> B(N, 0);
	for (int ii = 0; ii < N; ++ii){
		cin >> B[ii];
	}

	ll sum = 0;
	for (int ii = 0; ii < N; ++ii){
		if (A[ii] >= B[ii]){
			sum += B[ii];
		} else {
			ll rem = B[ii] - A[ii];
			sum += A[ii];

			if (A[ii+1] >= rem){
				A[ii+1] -= rem;
				sum += rem;
			} else {
				sum += A[ii+1];
				A[ii+1] = 0;
			}
		}
		// printf("sum[%i] %i\n", ii, sum);
	}

	cout << sum << endl;


	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int cnt = 0;
    bool flag = true;
    vector<int> array(N);
    for(int i = 0; i < N;i++){
        cin >> array[i];
    }
    
    while(flag){
        for(int i = 0; i < N;i++){
            if(array[i] % 2 == 0){
              array[i] /= 2;  
            }else{
                flag = false;
                break;
            }
        }
        if(flag) cnt++;
    }
    cout << cnt << endl;
}


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

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

string s;

char solve() {
  char res = 'd';
  rep(i,3) if (s[i*3] == s[i*3+1] && s[i*3+1] == s[i*3+2]) {
    if (s[i*3] == 'o') {
      res = 'o';
    } else if (s[i*3] == 'x') {
      res = 'x';
    }
  }
  
  rep(i,3) if (s[i] == s[i+3] && s[i+3] == s[i+6]) {
    if (s[i] == 'o') {
      res = 'o';
    } else if (s[i] == 'x') {
      res = 'x';
    }
  }
  
  if (s[0] == s[4] && s[4] == s[8]) {
    if (s[0] == 'o') {
      res = 'o';
    } else if (s[0] == 'x') {
      res = 'x';
    }
  }
  
  if (s[2] == s[4] && s[4] == s[6]) {
    if (s[2] == 'o') {
      res = 'o';
    } else if (s[2] == 'x') {
      res = 'x';
    }
  }
  return res;
}

int main (int argc, char const* argv[]) {
  while (cin>>s) {
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
    long long t,n,a,b,i;
    cin>>a>>b;
    if(a<b){
        for(i=0;i<b;i++)
            cout<<a;
        cout<<endl;
    }
    else{
        for(i=0;i<a;i++)
            cout<<b;
        cout<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<list>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define first fi
#define second se
const int MAX=100005;
const int inf=1e9;
vi G[MAX];
int N;
bool visited[MAX];
int prenum[MAX],parent[MAX],lowest[MAX],timer;

void dfs(int current,int prev)
{
  prenum[current]=lowest[current]=timer;
  timer++;

  visited[current]=true;
  int next;
  for(int i=0;i<G[current].size();i++)
  {
    next=G[current][i];
    if(!visited[next])
    {
      parent[next]=current;
      dfs(next,current);
      lowest[current]=min(lowest[current],lowest[next]);
    }
    else if(next!=prev)
    {
      lowest[current]=min(lowest[current],prenum[next]);
    }
  }
}

void art_points()
{
  timer=1;
  dfs(0,-1);
  set<int> ap;
  int np=0;
  for(int i=1;i<N;i++)
  {
    int p=parent[i];
    if(p==0) np++;
    else if(prenum[p]<=lowest[i]) ap.insert(p);
  }
  if(np>1) ap.insert(0);
  for(set<int>::iterator it =ap.begin();it!=ap.end();it++)
  {
    cout << *it << endl;
  }
}

int main(void)
{
  int m;
  cin >> N >> m;
  memset(visited,false,sizeof(visited));
  for(int i=0;i<m;i++)
  {
    int s,t;
    cin >> s>> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  art_points();
}




Measured memory_bytes: 6988
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    ni = n
    d = dict()
    t = 0
    ans = 0
    while True:
        if ni%2 == 0:
            ni //= 2
            t += 1
        else:
            break
    if t > 0:
        d[2] = t
    pi = 3
    t = 0
    while ni > 1 and pi < 10**6+1:
        if ni%pi == 0:
            t += 1
            ni //= pi
        else:
            if t == 0:
                pi += 2
                continue
            else:
                d[pi] = t
                t = 0
                pi += 2
    if t > 0:
        d[pi] = t
    if ni > 1:
        d[ni] = 1
    for i in d.values():
        t = 0
        ni = i
        while True:
            if ni >= t+1:
                ni -= t+1
                t += 1
            else:
                break
        ans += t
    print(ans)



    return



if __name__ == '__main__':
    main()


Measured memory_bytes: 68864
parseInt(x) = parse(Int, x)
n = parseInt(readline())

x = parseInt.(split(readline()))
#K=split(readline())
#x=map(x->parse(Int,x),K)
ans = n * 101^2

for i in 1:100
    sum = 0
    for j in 1:n
        sum += (x[j] - i)^2
    end
    if sum < ans
        ans = sum
    end
end
print(ans)

Measured memory_bytes: 172492
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

int main() {
	
	fast;
	
	ll a, b;
	cin>>a>>b;
	cout<<a*b;
	
	return 0;
}


Measured memory_bytes: 3640
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
def main():
      global X
      global x
      print(answer(pre(X,x)))
def pre(a,b):
      b = [i-a for i in b]
      return b
def answer(k):
      Min = min([abs(i) for i in k])
      flag = False
      for i in range(1,Min+1):
            if flag == True:
                  break
            flag = True
            if Min%i==0:
                  ans = Min//i
                  for j in k:
                        if j%ans!=0:
                              flag = False
            else:
                  flag = False
      return ans
main()

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
template <class T, typename U> void assign(T& container, int N, initializer_list<U> list) {
	for (auto e: list) {
		container[N] = e;
		N++;
	}
}

//------------------8<------------------------------------8<--------------------

signed main() {
	int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  //pair<int, int> temp(1, 0);
  int prev=1, temp;
  vector<int> clusters({0});
  vector<int> res;
  for (auto i=0; i<N; i++) {
    temp = S[i] - '0';
    if (temp == prev) {
      clusters.back()++;
    } else {
      prev = temp;
      clusters.push_back(1);
    }
  }
  
  //for (auto e: clusters) cout << e << " ";
  
  int cs = (int)(clusters.size());
  for (auto i=0; i <= max((int)0, cs-K); i++) {
    temp=0;
    for (auto j=2*i; j <= min(2*i+2*K, cs-1); j++)
      temp += clusters[j];
    res.push_back(temp);
  }
  cout << *max_element(all(res)) << endl;

  return 0;
}


Measured memory_bytes: 2676
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);

  int ans = 0;
  int i;
  for(i=0;i<n;i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    ans += r - l + 1;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n;
const string AC = "AC";
const string WA = "WA";
const string TLE = "TLE";
const string RE = "RE";
int ac_cnt, wa_cnt, tle_cnt, re_cnt;

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        if (s == AC)
            ac_cnt++;
        else if (s == WA)
            wa_cnt++;
        else if (s == TLE)
            tle_cnt++;
        else if (s == RE)
            re_cnt++;
    }

    cout << AC << " x " << ac_cnt << '\n';

    cout << WA << " x " << wa_cnt << '\n';

    cout << TLE << " x " << tle_cnt << '\n';

    cout << RE << " x " << re_cnt << '\n';
    return 0;
}


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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)

int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    string s;
    cin >> s;
    for (char ch : s) {
        if (ch == '?') cout << 'D';
        else cout << ch;
    }
    return 0;
}

Measured memory_bytes: 3788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int h,w,k; cin >> h >> w >> k;
	vector<string> c(h);
	rep(i,h) cin >> c[i];
	int ans = 0;
	rep(i, (1 << h)){
		rep(j, (1 << w)){
			int count = 0;
			rep(x,h){
				rep(y,w){
					if(c[x][y] == '#'){
						if(((i >> x) & 1) && ((j >> y) & 1)){
							count++;
						}
					}
				}
			}
			if(count == k) ans++;
		}
	}
	cout << ans << endl;}

Measured memory_bytes: 3644