akhauriyash/Code-Regression huggingface dataset:
from collections import deque
import sys
input = sys.stdin.readline

def main():
    N,X,Y = map(int,input().split())
    edge = [[] for _ in range(N)]
    for i in range(N):
        if i == 0:
            edge[i].append(i+1)
        elif i == N-1:
            edge[i].append(i-1)
        else:
            edge[i].append(i-1)
            edge[i].append(i+1)
    edge[X-1].append(Y-1)
    edge[Y-1].append(X-1)
    
    ans = [0]*(N-1)
    
    for i in range(N):
        visited = [0]*N
        dist = [0]*N
        q = deque([i])#i番目のノードを根とする探索
        visited[i] = 1
        while q:
            now = q.popleft()
            for connection in edge[now]:
                if visited[connection]:
                    dist[connection] = min(dist[connection],dist[now]+1)
                else:
                    visited[connection] = 1
                    dist[connection] = dist[now] + 1
                    q.append(connection)
        for d in dist:
            if d == 0:
                continue
            ans[d-1] += 1
    ans = list(map(lambda x: x//2,ans))
    print(*ans,sep="\n")
if __name__ == '__main__':
    main()

Measured memory_bytes: 48860
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,A,B;
int fir[100005],nxt[200005],to[200005],cnt;
int deg[100005],s4,s6,vis[100005];

int read(){
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

void dfs(int x){
	vis[x]=1;
	for(int i=fir[x];i;i=nxt[i]){
		if(vis[to[i]]==2){
			if(A) B=to[i];else A=to[i];
		}
		else if(!vis[to[i]]) dfs(to[i]);
	}
}

int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		x=read(),y=read();
		deg[x]++,deg[y]++;
		to[++cnt]=y,nxt[cnt]=fir[x],fir[x]=cnt;
		to[++cnt]=x,nxt[cnt]=fir[y],fir[y]=cnt;
	}
	for(int i=1;i<=n;i++){
		if(deg[i]&1){puts("No");return 0;}
		s4+=(deg[i]==4),s6+=(deg[i]>=6);
	}
	if(s6){puts("Yes");return 0;}
	if(!s6&&!s4){puts("No");return 0;}
	if(s4>2){puts("Yes");return 0;}
	if(s4==1){puts("No");return 0;}
	for(int i=1;i<=n;i++) if(deg[i]==4) vis[i]=2;
	for(int i=1;i<=n;i++){
		A=0,B=0;
		if(!vis[i]) dfs(i);
		if(A==B&&A){puts("Yes");return 0;}
	}
	puts("No");

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	double r;
	cin >> r;
	cout << fixed << setprecision(10) << 2.0 * r * 3.1415926535 << endl;
	return 0;
}


Measured memory_bytes: 3788
N, M = map(int, input().split())
# print(N)

# DPテーブルを初期化
dp = [10**9] * 2**(N+1)  # dp[010100011010]: 状態010100011010に到達するための最小コスト
dp[0] = 0

# ループを回す
for i in range(M):
    a, b = map(int, input().split())
    c = [int(i) for i in input().split()]

    bit = 0
    for cb in c:
        bit += 2**(cb-1)

    for fromb in range(2**N):
        dp[fromb | bit] = min(dp[fromb | bit], dp[fromb]+a)

if dp[2**N-1] == 10**9:
    print(-1)
else:
    print(dp[2**N-1])


Measured memory_bytes: 47832
class dice:
    def __init__(s, i):
        s.d1,s.d2,s.d3,s.d4,s.d5,s.d6 = map(int, i)
        s.dic = {s.d1:{s.d2:s.d3,s.d3:s.d5,s.d4:s.d2,s.d5:s.d4}
                ,s.d2:{s.d1:s.d4,s.d3:s.d1,s.d4:s.d6,s.d6:s.d3}
                ,s.d3:{s.d1:s.d2,s.d2:s.d6,s.d5:s.d1,s.d6:s.d5}
                ,s.d4:{s.d1:s.d5,s.d2:s.d1,s.d5:s.d6,s.d6:s.d2}
                ,s.d5:{s.d1:s.d3,s.d3:s.d6,s.d4:s.d1,s.d6:s.d4}
                ,s.d6:{s.d2:s.d4,s.d3:s.d2,s.d4:s.d5,s.d5:s.d3}}
 
    def get(s, i):
        up, bef = map(int, i)
        return s.dic[up][bef]

dice1 = dice(input().split())
q = int(input())
for i in range(q):
    print(dice1.get(input().split()))
    


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll n;
cin>>n;
cout<<lcm(2,n)<<endl;
}









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

def uniq(h):
	res = []
	pre = -1
	for x in h:
		if pre != x:
			res.append(x)
		pre = x
	return res

ans = 0
while(True):
	h = uniq(h)
	if len(h)== 1:
		ans += h[0]
		break
	m = max(h)
	ans+=h.count(m)
	h = [x if x != m else m-1 for x in h]
print(ans)




Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
    int r;
    //rを定義
    int g;
    //gを定義
    int b;
    //bを定義
    cin >> r >> g >>b;
    if((r * 100 + g * 10 + b) % 4 == 0){
        cout << "YES" << endl;
        //rgbが4の倍数の場合YESと出力
    } else {
        cout << "NO" << endl;
        //それ以外はNOと出力
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    static Node NIL;
    static Node root;
    static StringBuilder sb;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        NIL = new Node(-1);
        root = NIL;
        sb = new StringBuilder();
        int m = Integer.parseInt(sc.next());
        
        for(int i = 0; i < m; i++){
            String s = sc.next();
            if(s.equals("insert")){
                intsert(Integer.parseInt(sc.next()));
            }else if(s.equals("print")){
                inPerse(root);
                sb.append(System.lineSeparator());
                prePerse(root);
                sb.append(System.lineSeparator());
            }
        }
        System.out.print(sb);
    }
    
    static void intsert(int key){
        
        Node y = NIL;
        Node x = root;
        Node z = new Node(key);
        
        while(x != NIL){
            y = x;
            if(z.key < x.key){
                x = x.left;
            }else{
                x = x.right;
            }
        }
        z.parent = y;
        
        if(y == NIL){
            root = z;
        }else if(z.key < y.key){
            y.left = z;
        }else{
            y.right = z;
        }
    }
    
    static void prePerse(Node u){
        
        if(u == NIL) return;
        sb.append(" ").append(u.key);
        prePerse(u.left);
        prePerse(u.right);
    }
    
    static void inPerse(Node u){
        
        if(u == NIL) return;
        inPerse(u.left);
        sb.append(" ").append(u.key);
        inPerse(u.right);
    }
    
    static class Node {
        int key;
        Node parent, left, right;

        public Node(int key) {
            this.key = key;
            parent = NIL;
            left = NIL;
            right = NIL;
        }
    }
}


Measured memory_bytes: 188920
sx, sy, tx, ty = map(int, input().split())
tx -= sx
ty -= sy

ans = 'U' * ty + 'R' * tx + 'D' * ty + 'L' * tx
ans += 'L' + 'U' * (ty+1) + 'R' * (tx+1) + 'DR' + 'D' * (ty+1) + 'L' * (tx+1) + 'U'

print(ans)

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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> c;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        c[a[i]]++;
    }
    vector<int> k, v;
    for (auto x : c)
    {
        k.PB(x.fst);
        v.PB(x.snd);
    }
    bool ok;
    if (SZ(c) > 3)
    {
        ok = false;
    }
    if (SZ(c) == 3)
    {
        ok = ((v[0] == v[1]) && (v[1] == v[2]) && (k[0] == (k[1] ^ k[2])));
    }
    if (SZ(c) == 2)
    {
        ok = (k[0] == 0 && v[0] * 2 == v[1]);
    }
    if (SZ(c) == 1)
    {
        ok = (k[0] == 0);
    }
    if (ok)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

// #define multitest 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

bool solve(int n)
{
	if (n < 10)
		return 1;
	if (n < 100)
		return 0;
	if (n < 1000)
		return 1;
	if (n < 10000)
		return 0;
	if (n < 100000)
		return 1;
	if (n < 1000000)
		return 0;
	return 0;
}

void solve()
{
	int n, cnt = 0;
	cin >> n;
	while (n--)
	{
		cnt += solve(n + 1);
	}
	cout << cnt;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef TIME
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
/* Coding Space*/
int main(){
  int n,t; cin >> n >> t;
  vi v(n);
  rep(i,n) cin >> v[i];
  vi vmin(n);
  int ans = 0;
  int max_v = 0;
  vmin[0] = v[0];
  for(int i = 1; i < n; i++){
    vmin[i] = min(vmin[i-1],v[i]);
    if(v[i] - vmin[i-1] > max_v){
      max_v = v[i] - vmin[i-1];
      ans = 1;
    }else if(v[i] - vmin[i-1] == max_v)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
        String sentence;
        int[] abc = new int[26];
 
        while ((sentence = input.readLine()) != null) {
            for (int i = 0; i < sentence.length(); i++) {
                char c = sentence.charAt(i);
                     c = Character.toLowerCase(c);
                char cc = 'a';
                for (int j = 0; j < abc.length; j++) {
                    if (cc == c)
                        abc[j]++;
                    cc++;
                }
            }
        }
 
        char cc = 'a';
        for (int i = 0; i < abc.length; i++) {
            System.out.println(cc + " : " + abc[i]);
            cc++;
        }
    }
 
}

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

const ll p = 1e9+7;
const int MAXN = 1e5+5;

ll n, a, b, s[MAXN];
ll dp[MAXN][2], r[MAXN][2];

int main() {
    cin >> n >> a >> b;
    for (int i = 0; i < n; ++i)
        cin >> s[i];
    for (int i = n-1; i >= 0; --i) {
        r[i][0] = r[i][1] = i;
        if (i != n-1 && s[i+1]-s[i]>=a)
            r[i][0] = r[i+1][0];
        if (i != n-1 && s[i+1]-s[i]>=b)
            r[i][1] = r[i+1][1];
    }

    for (int i = n-1; i >= 0; --i) {
        if (i == n-1) {
            dp[i][0] = dp[i][1] = 1;
            continue;
        }

        int lo = i, hi = n-1;
        while (lo != hi) {
            int mid = (lo+hi+1)/2;
            if (s[mid] < a+s[i])
                lo = mid;
            else
                hi = mid-1;
        }

        if (lo == i)
            dp[i][0] = (dp[i+1][0] + dp[i+1][1])%p;
        else if (r[i+1][1] < lo)
            dp[i][0] = 0;
        else
            dp[i][0] = dp[lo][1];

        lo = i, hi = n-1;
        while (lo != hi) {
            int mid = (lo+hi+1)/2;
            if (s[mid] < b+s[i])
                lo = mid;
            else
                hi = mid-1;
        }

        if (lo == i)
            dp[i][1] = (dp[i+1][0] + dp[i+1][1])%p;
        else if (r[i+1][0] < lo)
            dp[i][1] = 0;
        else
            dp[i][1] = dp[lo][0];
    }

    cout << (dp[0][0] + dp[0][1])%p << endl;
}

Measured memory_bytes: 4224
N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[10**9]*(N)
dp[0]=0
for i in range(1,N):
    for j in range(max(0,i-K),i):
        dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i])
print(dp[-1])
#print(dp)



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

using namespace std;

struct UnionFindTree{
  vector<int> parent;
  
  UnionFindTree(int n) : parent(n){
    for(int i = 0; i < n; i++) parent[i] = i;
  }
  
  int find(int x){
    if(parent[x] == x) return x;
    else return parent[x] = find(parent[x]);
  }
  
  void unite(int x, int y){
    parent[find(x)] = find(y);
  }
};

int main(){
  int N;
  cin >> N;
  
  vector<pair<int, int>> Ai(N);
  vector<pair<int, int>> BA(N);
  
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    Ai[i] = make_pair(a, i);
  }
  
  for(int i = 0; i < N; i++){
    int b;
    cin >> b;
    BA[i] = make_pair(b, Ai[i].first);
  }
  
  sort(Ai.begin(), Ai.end());
  sort(BA.begin(), BA.end());
  
  bool able = true;
  for(int i = 0; i < N; i++){
    Ai[i] = make_pair(BA[i].second, i);
  }
  
  sort(Ai.begin(), Ai.end());
  
  for(int i = 0; i < N; i++){
    if(Ai[i].first > BA[i].first){
      able = false;
      break;
    }
  }
  
  UnionFindTree permutation(N);
  for(int i = 0; i < N; i++){
    permutation.unite(Ai[i].second, i);
  }
  
  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(permutation.find(i) == i) cnt++;
  }
  
  if(able && cnt == 1){
    able = false;
    for(int i = 0; i < N - 1; i++){
      if(BA[i].first >= Ai[i + 1].first){
        able = true;
        break;
      }
    }
  }
  
  cout << (able ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a[5];
  for(int i = 0;i<5;i++){
  cin >> a[i];
  }
  int ans;
  for(int i =0;i<5;i++){
  if(a[i]==0){
    ans = i+1;
    break;
  }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (n > k * 2) {

	}
	return fac[n] / (fac[k] * fac[n - k]);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
vector<vector<ll>>tree;
char c[505][505];
ll dist[505][505];
bool flag[505][505];
ll h, w;
ll sx, sy, gx, gy;
vector<ll>L;
queue<pair<ll, ll>>que;

void bfs() {
	while (!que.empty()) {
		pair<ll, ll> target = que.front();
		ll y = target.first;
		ll x = target.second;
		que.pop();
		rep(i, 4) {
			ll ny = y + dy[i];
			ll nx = x + dx[i];
			if (c[ny][nx] != '#') {
				if (0 <= ny && ny < h && 0 <= nx && nx < w&&flag[ny][nx]==false) {
					que.push(make_pair(ny, nx));
					dist[ny][nx] = dist[y][x] + 1;
					flag[ny][nx] = true;
				}
			}
		}
	}
}

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	cin >> h >> w;
	ll white = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
			if (c[i][j] == '.')white++;
		}
	}
	que.push(make_pair(0, 0));
	bfs();
	ll total = white - dist[h - 1][w - 1] - 1;
	if (dist[h - 1][w - 1] == 0) {
		cout << -1 << endl;
		return 0;
	}
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 3816
s=str(input())
if len(s)%2==0:
  char1='01'*(int(len(s)/2))
  char2='10'*(int(len(s)/2))
else:
  char1='01'*(int(len(s)/2))+'0'
  char2='10'*(int(len(s)/2))+'1'
count1=0
count2=0
for i in range(len(s)):
  if char1[i]!=s[i]:
    count1+=1
  if char2[i]!=s[i]:
    count2+=1
print(min(count1,count2))

Measured memory_bytes: 3316
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
import operator

N,H,W = map(int,readline().split())
RCA = [tuple(int(x) for x in line.split()) for line in readlines()]

RCA.sort(key = operator.itemgetter(2), reverse=True)

root = list(range(H+W))
size = [0] * (H+W)
no_cycle = [True] * (H+W)

def find_root(x):
    y = root[x]
    if x == y:
        return y
    z = find_root(y)
    root[x] = z
    return z

def merge(x,y):
    x,y = find_root(x),find_root(y)
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    no_cycle[x] = no_cycle[x] and no_cycle[y]

answer = 0
for R,C,A in RCA:
    x,y = R-1,H+C-1
    rx,ry = find_root(x),find_root(y)
    if rx == ry:
        if not no_cycle[rx]:
            continue
        no_cycle[rx] = False
    else:
        if (not no_cycle[rx]) and (not no_cycle[ry]):
            continue
        merge(rx,ry)
    answer += A

print(answer)



Measured memory_bytes: 100776
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class C {
	int n;
	vi a, b, c;
public:
	C()
	{
		cin >> n;
		a.resize(n);
		b.resize(n);
		c.resize(n);

		REP(i, n)
			cin >> a[i];
		REP(i, n)
			cin >> b[i];
		REP(i, n)
			cin >> c[i];

		sort(ALL(a));
		sort(ALL(b));
		sort(ALL(c));

	}
	void solve()
	{

		ll ans{ 0 };
		int last{ -1 };
		ll lastval{ -1 };

		REP(i, n)
		{
			if (b[i] == last)
				ans += lastval;

			else
			{
				ll tmp{ 1 };

				tmp *= (lower_bound(ALL(a), b[i]) - a.begin());
				tmp *= (c.end() - upper_bound(ALL(c), b[i]));
				ans += tmp;

				last = b[i];
				lastval = tmp;
			}
		}

		cout << ans << endl;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int N;
ll x, A[100005];
ll ans;

int main(void) {
    
    scanf("%d %lld", &N, &x);
    rep(i, 0, N) scanf("%lld", &A[i]);
    
    rep(i, 1, N) {
      ll t = A[i-1]+A[i];
      if (t > x) {
        ll t2 = t - x;
        A[i-1] -= max(0LL, t2 - A[i]);
        A[i] -= min(t2, A[i]);
        ans += t2;
      }
    }
    
    
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
  
  int N, K; cin >> N >> K; int sum = 0;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  sort(vec.begin(), vec.end());
  
  for (int i = 0; i < K; i++) sum += vec[i];
  
  cout << sum << endl;
  
}

Measured memory_bytes: 3556
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

    int ans=0;
    int n,m;
    cin>>n>>m;

    ans=((n+m)*(n+m-1))/2-n*m;
    
    cout<<ans<<endl;
   
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a,b; cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> v1(a);
  vector<int> v2(b);
  vector<pair<pair<int, int>, int>> v3(m);
  rep(i, a) cin >> v1[i];
  rep(i, b) cin >> v2[i];
  rep(i, m) cin >> v3[i].first.first >> v3[i].first.second >> v3[i].second;
  int ans = INT_MAX;
  rep(i, m) {
    int tmp = v1[v3[i].first.first - 1] + v2[v3[i].first.second - 1] - v3[i].second;
    ans = min(tmp, ans);
  }
  vector<int>::iterator iter1 = min_element(all(v1));
  vector<int>::iterator iter2 = min_element(all(v2));
  ans = min(ans, *iter1 + *iter2);
  fin(ans);
  return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    ll ans = 0ll;
    for(ll i = k+1; i<=n; i++){
        ll t = n/i;
        ans += t*(i-k);
        if(k==0){
            ans--;
        }
        ll x = t*i;
        if((x+k)>n) continue;
        ans += n-x-k+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Double> arr = new ArrayList<>();
        for(int i = 0; i < n; i++) arr.add((double) sc.nextInt());
        sc.close();

        Collections.sort(arr);
        double ans = arr.get(0);

        for(int i = 1; i < arr.size(); i++){
            ans = (arr.get(i) + ans) / 2.0;
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 23508
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2019-11-24
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    string str[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string n;
    cin >> n;
    int x;

    for (int i = 0; i < 7; i++) {
        if (n == str[i]) {
            x = i + 1;
            break;
        }
    }

    int a = (7 - x)+1;

    if (a == 0) a = 7;

    cout << a << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INFTY 1000000000
int S[500000];

int merge(int A[500000],int left,int mid,int right){
    int n1,n2,i,j,k;
    n1=mid-left;
    n2=right-mid;
    int L[n1+1],R[n2+1];
    for(i=0;i<n1;i++)
        L[i]=A[left+i];
    for(i=0;i<n2;i++)
        R[i]=A[mid+i];
    L[n1]=INFTY;
    R[n2]=INFTY;
    i=0;
    j=0;
    for(k=left;k<right;k++){
        if(L[i]<=R[j]){
            A[k]=L[i];
            i+=1;
        }else{
            A[k]=R[j];
            j+=1;
        }
    }
    return i+j;
}

int mergeSort(int A[500000],int left,int right){
    int mid,sum=0;
    if(left+1<right){
        mid=(left+right)/2;
        sum+=mergeSort(A,left,mid);
        sum+=mergeSort(A,mid,right);
        sum+=merge(A,left,mid,right);
    }
    return sum;
}

int main(){
    int i,n,sum;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    sum=mergeSort(S,0,n);
    for(i=0;i<n-1;i++)
        printf("%d ",S[i]);
    printf("%d\n%d\n",S[n-1],sum);
    
    return 0;
}

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

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define piii    pair<int, pair<int, int>>

int print(bool ok) {
        if (ok) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}

int main() {
        int i, j;
        int n;
        cin >> n;
        int a = 0, b = 0, c = 0;
        for (i = 0; i < n; i ++) {
                int p;
                cin >> p;
                if (p % 4 == 0) a ++;
                else if (p % 2 == 0) b ++;
                else c ++;
        }
        if (a == 0) {
                if (b == n) return print(1);
                else return print(0);
        }
        if (a * 2 + 1 >= n) return print(1);
        int diff = n - (b * 2 + 1);
        if (diff + 1 == a) return print(1);
        print(0);
        return 0;
}



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

int main() {
  long num;
  long i;
  int flag  = 0;
  char buf[16];
  int num_of_prime=0;
  fgets(buf, 16, stdin);
  while (1) {
    flag  = 0;
    memset(buf, 0, 16);
    fgets(buf, 16, stdin);
    num = strtol(buf, NULL, 10);
    if (num == 0) {
      break;
    }


    for (i=2; i<=sqrt(num); i++) {
      if (num % i == 0) {
        flag  = 1;
        break;
      }
    }
    if (!flag) {
      num_of_prime++;
    }
  }
  printf("%d\n", num_of_prime);
  return 0;
}

Measured memory_bytes: 960
#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<intt,intt>
#define mp make_pair
typedef long long intt;
using namespace std;
intt mod=1e9+7;
intt bigmod(intt b,intt p ,intt m)
{
    if(p==0)
        return 1;
    if(p%2 == 0)
    {
        intt temp = bigmod(b,p/2,m);
        return (temp*temp)%m;
    }
    return (bigmod(b,p-1,m)*(b%m))%m;
}

int main()
{
    intt n;
    cin>>n;
    intt all=bigmod(2,n,mod);
    //cout<<all;
    intt a,b;
    cin>>a>>b;
    intt fir=0;
    intt c=1;
    intt i;
    for(i=n;i>n-a;i--)
        c*=i,c%=mod;
        intt mk=1;
    for(i=1;i<=a;i++)
      mk*=i,mk%=mod;
      mk=bigmod(mk,mod-2,mod);
      c*=mk;
      c%=mod;
      all-=c;
      all%=mod;
      all+=mod;
      all%=mod;
       c=1;
    for(i=n;i>n-b;i--)
        c*=i,c%=mod;
         mk=1;
    for(i=1;i<=b;i++)
      mk*=i,mk%=mod;
      mk=bigmod(mk,mod-2,mod);
      c*=mk;
      c%=mod;
      all-=c;
      all%=mod;
      all+=mod;
      all%=mod;
      all-=1;
      all+=mod;
      all%=mod;
      cout<<all<<endl;
      return 0;
}


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

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

    string S;
    cin >> S;

    int zero = count(S.cbegin(), S.cend(), '0');
    int one  = count(S.cbegin(), S.cend(), '1');

    cout << 2 * min(zero, one) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;
    long long mod = n % k;
    long long min_value = mod;
    long long current = mod;
    while (true) {
        current = abs(current - k);
        if (current < min_value) min_value = current;
        if (current == mod) break;
    }
    cout << min_value << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int idt[] = new int[26];
        
        while(sc.hasNext()){
            String str = sc.next();
            for(int i=0;i<str.length();i++){
                if(Character.isUpperCase(str.charAt(i))) idt[str.charAt(i)-65]++;
                if(Character.isLowerCase(str.charAt(i))) idt[str.charAt(i)-97]++;
            }
        }
        char c = 'a';
        for(int i=0;i<26;i++){
            System.out.println(c+" : "+idt[i]);
            c++;
        }
    }
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> v(4);
  vector<char> op(4);
  for (int i = 0; i < 4; i++)
  {
    int buf = n % 10;
    n /= 10;
    v.at(i) = buf;
  }
  reverse(v.begin(), v.end());

  for (int i = 0; i < 8; i++)
  {
    int sum = v.at(0);
    for (int j = 0; j < 3; j++)
    {
      if (i & (1 << j))
      {
        op[j] = '+';
        sum += v[j + 1];
      }
      else
      {
        op[j] = '-';
        sum -= v[j + 1];
      }
    }
    if (sum == 7)
    {
      break;
    }
  }
  for (int i = 0; i < 3; i++)
  {
    cout << v.at(i) << op.at(i);
  }
  cout << v.at(3) << "=7" << endl;
}


Measured memory_bytes: 3632
from collections import deque
n, q = map(int, input().split())

deq = deque()
for i in range(n):
    name, time = input().split(); time = int(time)
    deq.append((time, name))
    # deque([(150, 'p1'), (80, 'p2'), (200, 'p3'), (350, 'p4'), (20, 'p5')])
ans = []
cur = 0
while deq:
    time, name = deq.popleft()
    if time <= q:
        cur += time
        ans.append("%s %d" % (name, cur))
    else:
        cur += q
        deq.append((time-q, name))
print(*ans, sep="\n")


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int r, d, x; cin >> r >> d >> x;
    int next;
    rep(i, 10){
        next = r*x - d;
        cout << next << endl;
        x = next;
    }
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3548
def main():
    x, y = map(int, input().split())
    if 4*x - y < 0 or y - 2*x < 0:
        print("No")
    else:
        c = (4*x - y) / 2
        t = (y - 2*x) / 2
        
        if c==int(c) and t==int(t):
            print("Yes")
        else:
            print("No")
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 10^^9 + 7;

void chmin(T)(ref T a, in T b) { if (a > b) a = b; }

void madd(T)(ref T a, in T x) { a += x; a %= MOD; }

int calc(string s) {
    auto dp = new int[][](s.length + 1, 13);
    // dp[i][j]
    // i : i 桁目までみた
    // j : 13 で割った余

    dp[0][0] = 1;
    for (int i = 0; i < s.length; i++) { // i 桁目
        for (int j = 0; j < 13; j++) { // 余り
            foreach (k; s[i] == '?' ? iota(0, 10) : iota(s[i]-'0', s[i]-'0'+1)) {
                // dp[i + 1][(10 * j + k) % 13] += dp[i][j];
                // dp[i + 1][(10 * j + k) % 13] %= MOD;

                madd(dp[i + 1][(10 * j + k) % 13], dp[i][j]);
            }
        }
    }
    return dp[s.length][5];
}

void main() {
    string s = read!string;
    writeln(calc(s));
}


Measured memory_bytes: 11032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            long n = Long.parseLong(br.readLine());
            for (long i = n; i > 0; i--) {
                long tmp = (long)Math.sqrt(i);
                if (tmp * tmp == i) {
                    System.out.println(i);
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}


ll fun_len(ll N){
  ll ans = 0 ;
  
  while( N != 0){
    N/= 10;
    ans ++;
  }
  return ans;
}

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

  ll len = fun_len(N);

  vector<ll> possi;
  
  
  for(ll i = 1; i <= len - 2; i++){
    for(ll j = 1 ; j <= len - i - 1; j++){
      for(ll k = 1; k <= len - i - j; k++){
	
	vector<ll> ve;
	
	rep(l,i) ve.pb(3);
	rep(l,j) ve.pb(5);
	rep(l,k) ve.pb(7);
	
	do{
	  ll p = 0 ;
	  rep(l, ve.size()){
	    p*=10;
	    p += ve[l];
	  }
	  possi.pb(p);
	}while(next_permutation(all(ve)));
      }
    }
  }

  ll ans = 0 ;
  rep(i, possi.size()){
    if(possi[i] <= N) ans ++;
  }

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


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

using namespace std;
typedef long long ll;

int main(){
	ll n,m; cin >> n >> m;

	if(m < n){
		ll temp = n;
		n = m;
		m = temp;
	}

	ll ans;
	if(n == 1 && m == 1){
		cout << "1" << endl;
	}else if(n == 1 && m != 1){
		cout << m - 2 << endl;
	}else{
		ans = (n-2) * (m-2);
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
	ll n, m;
	cin >> n >> m;
	vector<ll> p(m), y(m);
	vector<ll> id[n+1];
	for (ll i = 0; i < m; i++){
		cin >> p[i] >> y[i];
		id[p[i]].push_back(y[i]);
	}

	for (ll i = 0; i < n; i++){
		sort(id[i+1].begin(), id[i+1].end());
	}

	for (ll i = 0; i < m; i++){
		printf("%012lld\n", p[i] * 1000000 + int(lower_bound(id[p[i]].begin(), id[p[i]].end(), y[i]) - id[p[i]].begin()) + 1);
	}
	return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>

int main(){
  long a,b,k;
  scanf("%ld",&a);
  scanf("%ld",&b);
  scanf("%ld",&k);
  a-=k;
  if(a<0){
    b+=a;
    a=0;
  }
  if(b<0){
    b=0;
  }
  printf("%ld %ld",a,b);
  return(0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 100010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

void ff1(ll x, ll d, ll k)
{
    ll ans, tmp;
    ans=x%d;
    tmp=(x-ans)/d;
    k-=tmp;
    if (k%2) ans=abs(ans-d);
    cout << ans << endl;
}

int main()
{
    RUN_FAST; cin.tie(nullptr);
    ll x, k, d, tmp, ans, len;
    cin >> x >> k >> d;
    x=abs(x);
    len=log10(k)+log10(d)+1;

    if (len>15) ff1(x, d, k);
    else {
        tmp=k*d;
        ans=x-tmp;
        if (ans>=0) cout << ans << endl;
        else ff1(x, d, k);
    }
    return 0;
}


Measured memory_bytes: 3896
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline
n = int(rl())
a = []
b = []
for _ in range(n):
    aa, bb = map(int, rl().split())
    a.append(aa)
    b.append(bb)

def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]
a = heapsort(a)
b = heapsort(b)
if n&1:
    ans = b[n//2] - a[n//2] + 1
else:
    c = a[n//2] + a[n//2 - 1]
    d = b[n//2] + b[n//2 - 1]
    ans = (d/2 - c/2) / 0.5 + 1
print(int(ans))

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

int main(void) {

	int N, L, ans = 0;
	cin >> N >> L;

	if (L >= 0) {
		for (int i = 1; i < N; i++) {
			ans += L + i;
		}
	}
	else {
		if (N > abs(L)) {
			for (int i = 0; i < N; i++) {
				ans += L + i;
			}
		}
		else {
			for (int i = 0; i < N - 1; i++) {
				ans += L + i;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x = ni()
w = 100
y = 0
while w < x:
    w = w * 101 // 100
    y += 1
print(y)



Measured memory_bytes: 62880
#include <bits/stdc++.h>
#define fr(i, n) for (ll i = 0; i < n; ++i)
#define frab(i, a, b) for (ll i = a; i < b; ++i)
#define mp make_pair
#define pb push_back
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e9 + 7;
const int M = 105;
const ld PI = acos(-1);
const int POW = 42;
const ll MOD = 1000 * 1000 * 1000 + 7;

const int N = 510;

int ar[N][N];

int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    ll H, W, h, w;
    cin >> H >> W >> h >> w;

    ll a = H / h;
    ll b = W / w;
    if (H % h == 0 && W % w == 0) {
        cout << "No";
        return 0;
    }

    if (H % h) {
        ll l = H % h;
        fr(i, H)
            fr(j, W)
                if (i % h < l)
                    ar[i][j] = 2 * a * (h - l);
                else
                    ar[i][j] = -2 * a * l - 1;
    }
    else {
        ll l = W % w;
        fr(i, H)
            fr(j, W)
                if (j % w < l)
                    ar[i][j] = 2 * b * (w - l);
                else
                    ar[i][j] = -2 * b * l - 1;
    }
    cout << "Yes" << endl;
    fr(i, H) {
        fr(j, W)
            cout << ar[i][j] << " ";
            cout << endl;
    }

}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

int main() {
  int n;
  cin >> n;
  double a[n],b=0.0;
  rep (i,n) {
    cin >> a[i];
    b +=1.0/a[i];
  }
cout << fixed << setprecision(14)<<1.0 / b << endl;
}

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


int main(){
  const static long INF = pow(10,9)+7;
  int N;
  long ans = 1;
  cin >> N;
  for(long i=1;i<=N;i++){
    ans = ans * i % INF;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256