akhauriyash/Code-Regression huggingface dataset:
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second


ll N, K, A, B, C;
ll arr[100005];
vector<ll> V;
string S;

int main() {
	scanf("%lld %lld", &A, &B);
	for(int i = 0; i <= 1000; i++) {
		double X = 0.08;
		double Y = 0.1;
		if(i == 25) {

			// cout << X * i << " " << Y * i << " ";
		}
		if(((int)(i * X) == A) && (int)(i * Y) == B) {
			printf("%d\n", i);
			exit(0);
		}
	}
	printf("-1\n");
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main() {
  long long int a, b;
  cin >> a >> b;
  if(a*b<=0) {
      cout << "Zero" << endl;
  }
  else if(a>0) {
      cout << "Positive" << endl;
  }
  else if((b-a+1)%2==0) {
      cout << "Positive" << endl;
  }
  else if((b-a+1)%2!=0) {
      cout << "Negative" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string n,m;
    cin>>n;
    m=n;
    reverse(n.begin(),n.end());
    int c=n.size();
    for(int i=0;i<c;i++){
        if(n[i]=='b')n[i]='d';
        else if(n[i]=='d')n[i]='b';
        else if(n[i]=='p')n[i]='q';
        else if(n[i]=='q')n[i]='p';
    }
    if(n==m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 512
h, w = map(int, input().strip().split())
s = []

for _ in range(h):
    temp = input()
    s.append(temp)


def func(height, weight, board):
    for i in range(height):
        for j in range(weight):
            flg = False
            if board[i][j] == '#':
                if i > 0:
                    if board[i-1][j] == '#':
                        flg = True
                if j > 0:
                    if board[i][j-1] == '#' and not flg:
                        flg = True
                if j < weight - 1:
                    if board[i][j+1] == '#' and not flg:
                        flg = True
                if i < height - 1:
                    if board[i+1][j] == '#' and not flg:
                        flg = True
                if not flg:
                    print('No')
                    return
    else:
        print('Yes')


func(height=h, weight=w, board=s)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
long long gcd(long long a, long long b) {
  if (a > b) swap(a, b);
  if (a == 0) return b;
  return gcd(b%a, a);
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  long long g = 1;
  rep(i, N) {
    long long a;
    cin >> a;
    g = (g / gcd(g, a)) * a;
  }
  cout << g << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        Main ak = new Main();
        ak.solve(sc);

    }
    void solve(Scanner in){
        int n = in.nextInt();
        int m = in.nextInt();
        int[][] arr = new int[m][2];
        for(int i=0;i<m;i++){
            arr[i] = new int[]{in.nextInt(),in.nextInt()};
        }
        int[] par = new int[n+1];
        Arrays.fill(par,-1);
        for(int i=0;i<m;i++){
            union(par,arr[i][0],arr[i][1]);
        }
        int cnt = 0;
        for(int i=1;i<=n;i++){
            if(par[i]<0) cnt++;
        }
        System.out.println(cnt-1);
    }
    int find(int[] par, int i){
        if(par[i]<0) return i;
        return par[i] = find(par,par[i]);
    }
    void union(int[] par, int i, int j){
        int pi = find(par,i);
        int pj = find(par,j);
        if(pi==pj) return;
        
        if(par[pi]<par[pj]){
            par[pi]+=par[pj];
            par[pj] = pi;
        }else{
            par[pj]+=par[pi];
            par[pi] = pj;
        }
    }

}



Measured memory_bytes: 63584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  string A, B; cin >> A >> B;
  if(A == B) { cout << "EQUAL" << endl; return 0;}
  
  if(A.size() > B.size()){ cout << "GREATER" << endl; return 0;}
  else if (A.size() < B.size()){ cout << "LESS" << endl; return 0;}
  
  rep(i,A.size()){
    if(A[i]<B[i]){ cout << "LESS" << endl; return 0;}
    else if(A[i]>B[i]){ cout << "GREATER" << endl; return 0;}
  }
  return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
 
int Levenstein(std::string a,std::string b){
  int dp[a.size()+1][b.size()+1];
 
  for(int i=0;i<=a.size();i++){
  	dp[i][0]=i;
  }
  for(int i=0;i<=b.size();i++){
  	dp[0][i]=i;
  }
 
  for(int i=1;i<=a.size();i++){
    for(int j=1;j<=b.size();j++){
      int cost=(a[i-1]==b[j-1])?0:1;
      dp[i][j]=std::min(dp[i-1][j]+1,std::min(dp[i][j-1]+1,dp[i-1][j-1]+cost));
    }
  }
  return dp[a.size()][b.size()];
}
 
int main(void){
 
  std::string a,b;
  std::cin >> a >> b;
  std::cout << Levenstein(a,b) << std::endl;
 
  return 0;
}



Measured memory_bytes: 7124
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const ll inf=1000000000007;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,0,n) cin >> h[i];
  ll val=h[0];
  int ans=1;
  rep(i,1,n){
    if(h[i]>=val){
      ans++;
      val=h[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,s=0,i;
    cin>>n>>m;
    int a[n+2];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    int k=m;
    for(i=0;i<n;i++)
    {
        if(a[i]*4*m>=s)
            k--;
    }
    if(k<=0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b, h;
    cin >> a >> b >> h;
    OP((a + b) * h / 2);
    return 0;
}

Measured memory_bytes: 256
#速い解答みてるとこんなロジックで通ってるんだがいいのか？
#つまりbbcc → bcbc でもOKということなんだが。それがokなら全部OKでは。

sS = input().rstrip()
sT = input().rstrip()

aS = [0] * 26
aT = [0] * 26
sABC = "abcdefghijklmnopqrstuvwxyz"
for i in range(26):
    aS[i]=sS.count(sABC[i])
    aT[i]=sT.count(sABC[i])
aS.sort()
aT.sort()
if aS == aT:
    print ("Yes")
else:
    print ("No")


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int t=1;
    while(t--)
    {
        ll n,k,x,y;
        cin>>n>>k>>x>>y;
        ll cnt=min(k,n);
        ll r=max(0LL,n-cnt);
        cout<<(cnt*x+r*y)<<endl;
    }
}


Measured memory_bytes: 3588
package main

import "fmt"

type Edge struct {
	v int
	u int
	n int
}

func main() {
	var l int
	fmt.Scan(&l)
	var m int
	for (l >> uint(m+1)) > 0 {
		m++
	}
	var edges []Edge
	for i := 0; i < m; i++ {
		edges = append(edges, Edge{i + 1, i + 2, 0})
		edges = append(edges, Edge{i + 1, i + 2, 1 << uint(i)})
	}
	b := 1 << uint(m)
	for i := m - 1; i >= 0; i-- {
		d := 1 << uint(i)
		if l-b >= d {
			edges = append(edges, Edge{i + 1, m + 1, b})
			b += d
		}
	}
	fmt.Println(m+1, len(edges))
	for _, e := range edges {
		fmt.Println(e.v, e.u, e.n)
	}
}


Measured memory_bytes: 512
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb(n) push_back(n)
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
void solve(){
	ll n,x;
	cin>>n;
	x=n%10;
	if(x == 3){
		cout<<"bon";
	}
	else if(x==0 or x==1 or x==8 or x==6)
		cout<<"pon";
	else
		cout<<"hon";
	return;
}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main()
{
    long int a, sqr[100050];

    scanf("%ld", &a);

    long int m=a;

    long int max=0, v1=0, v2, cnt1=0;

    for(long int i=0; i<a; i++)
    {

        scanf("%ld", & sqr[i]);

        v2=sqr[i];

        if(v1>=v2)
        {
           cnt1++;
        }

        if(cnt1>max)
        {
            max=cnt1;
        }

        if(v1<v2)
        {
            cnt1=0;
        }

        v1=v2;
    }

    printf("%ld\n", max);


    return 0;
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,A[1000010],tot,sum,ans[1000010];
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&A[i]),tot+=A[i];
	for(int i=1;i<n;i+=2)sum+=A[i]*2;
	ans[n]=tot-sum;
	ans[1]=A[n]*2-ans[n];
	for(int i=2;i<=n-1;i++)ans[i]=A[i-1]*2-ans[i-1];
	for(int i=1;i<=n;i++)printf("%lld ",ans[i]);
	return 0;
}

Measured memory_bytes: 6144
#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>

using namespace std;

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

#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--)

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

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

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;
    else return gcd(b, a%b);
}

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

int INF = 1e9+7;

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

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int n) : par(n , -1), rank(n, 1) { }
    void init(int n) { par.assign(n, -1), rank.assign(n, 1); }

    int find(int x) {
        if (par[x] == -1) return x;
        else return par[x] = find(par[x]);
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }

    bool merge(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        rank[x] += rank[y];
        par[y] = x;
        return true;
    }

    vector<int> roots(){
        vector<int> d;
        rep(i,par.size()){
            if(par[i]<0) d.emplace_back(i);
        }
        return d;
    }

    int size(int x){
        return rank[find(x)];
    }

    int count_group(){
        return roots().size();
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> p(n);
    vector<int> q(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
        q[p[i]]=i;
    }
    UnionFind uf(n);
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--; y--;
        uf.merge(x,y);
    }
    int ans = 0;
    rep(i,n){
        if(uf.is_same(i,q[i])) ans++;
        else continue;
    }
    cout << ans << endl;
}

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

#define mx 200005
#define ll long long 

void IO()
{
     #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
}

int ar[mx];
vector<int>g[mx];
int par[mx],tot[mx];
int vis[mx];
int m,n,k,ii;

void dfs(int u)
{
    k++;
    vis[u]=1;
    for(int v:g[u])
    {
        if(vis[v])continue;
        dfs(v);
    }
}


void solve()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int re=1;
    for(int i=1;i<=n;i++)
    {
        if(vis[i] || g[i].empty())continue;
        k=0;
        dfs(i);
        re=max(re,k);
    }
    printf("%d\n",re );
}

int main()
{
    IO();

    int t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 21796
#include <iostream>
using namespace std;
int main()
{
	string s;
	string x = "Sunny";
	string y = "Cloudy";
	string z = "Rainy";
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == x[i] && s[i + 1] == x[i + 1] && s[i + 2] == x[i + 2] && s[i+3] == x[i+3] && s[i + 4] == x[i + 4] && s[i + 5] == x[i + 5]){
			cout <<y<<endl;
			break;
		}
		else if (s[i] == y[i] && s[i + 1] == y[i + 1] && s[i + 2] == y[i + 2] && s[i+3] == y[i+3] && s[i + 4] == y[i + 4] && s[i + 5] == y[i + 5]){
			cout <<z<<endl;
			break;
		}
		else if (s[i] == z[i] && s[i + 1] == z[i + 1] && s[i + 2] == z[i + 2] && s[i+3] == z[i+3] && s[i + 4] == z[i + 4] && s[i + 5] == z[i + 5]){
			cout <<x<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 200005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string s;
    cin>>s;
    if(sz(s)<6){
        cout<<"No";
    }else{
        if(s[2]==s[3]&&s[4]==s[5]){
            cout<<"Yes";
        }else{
            cout<<"No";
        }
    }


    return 0;
}

Measured memory_bytes: 256
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
A = get_ints

set = Set.new

A.each { |a| set.add(a) }

puts set.length == A.length ? 'YES' : 'NO'


Measured memory_bytes: 37720
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, H, M = map(int, read().split())

H += M / 60

t1 = 2 * np.pi * H / 12
t2 = 2 * np.pi * H

z1 = A * np.exp(t1 * 1j)
z2 = B * np.exp(t2 * 1j)

print(abs(z1 - z2))


Measured memory_bytes: 27144
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define INF 0x3f
const int maxn = 2e5+ 5;

int n;
int a[maxn];
map<int,int>mp;
int main()
{
    ios::sync_with_stdio(false),cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            a[i]-=i;
        }
    sort(a+1,a+n+1);
    ll sum=0;
    if(n%2==1)
    {
        int num=a[(n+1)/2];
        for(int i=1;i<=n;i++)
           sum+=abs(a[i]-num);
    }
    else
    {
        int num=(a[n/2]+a[n/2+1])/2;
               for(int i=1;i<=n;i++)
           sum+=abs(a[i]-num);
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1024
from collections import Counter
s=input()
n=len(s)
M=[0]
mod=2019
for i in range(n):
	m=(M[-1]+int(s[n-1-i])%mod*pow(10,i,mod))%mod
	M.append(m)
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

Measured memory_bytes: 77792
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#pragma region DEBUG
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#pragma endregion DEBUG
#define MOD 1000000007
#define MAX 500005
#define endl "\n"
lli arr[MAX];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
    lli t;
    t = 1;
    while(t--){
        lli n,D;
        cin>>n>>D;
        lli ctr = 0;
        for(lli i = 0; i<n; i++){
            lli x,y;
            cin>>x>>y;
            if(x*x + y*y <= D*D)
                ctr++;
        }
        cout<<ctr<<endl;
    }
}

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

int main() {
	long long N, A, K, XOR = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A >> K;
		while (A % K != 0) {
			long long NOW = A / K + 1;
			A -= NOW * ((A - (NOW - 1) * (K - 1)) / NOW);
		}
		XOR ^= (A / K);
	}
	cout << (XOR == 0 ? "Aoki" : "Takahashi") << endl;
}

Measured memory_bytes: 256
import itertools

a1, a2, a3 = map(int, input().strip().split(' '))

min_score = float('inf')
for a, b, c in itertools.permutations((a1, a2, a3)):
    total = 0
    total += abs(b-a)
    total += abs(c-b)
    if total < min_score:
        min_score = total

print(min_score)


Measured memory_bytes: 3060
def getlist():
    return list(map(int, input().split()))

M, D = getlist()

ans = 0
for i in range(1, M + 1):
    for j in range(1, D + 1):
        d1 = j % 10
        d10 = int(j // 10)
        if d1 >= 2 and d10 >= 2 and d1 * d10 == i:
            ans += 1

print(ans)

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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
string num;

bool read() {
    if (!(cin >> num))
        return false;

    return true;
}

void solve() {
    n = num.size();
    auto pw = 1ll;
    auto ans = 0ll;
    auto sqr = [](long long x) -> long long { return x * x % MOD; };

    function<long long(long long, int)> bp = [&sqr, &bp](long long a, int n) {
        return n == 0 ? 1 : sqr(bp(a, n / 2)) * (n % 2 ? a : 1) % MOD;
    };

    for (int i = 0; i < n; pw = pw * (1 + (num[i++] == '1')) % MOD)
        ans = (ans + (num[i] - '0') * pw * bp(3, n - i - 1)) % MOD;

    cout << (ans + pw) % MOD << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
    int N, M;
    scanf("%d %d", &N, &M);
    int A = 0;
    for (int i = 0; i < M; i++) {
        int a = 0;
        scanf("%d", &a);
        A += a;
    }

    if (N < A) {
        printf("-1\n");
        return 0;
    }
    
    printf("%d\n", N - A);


    return 0;
}

Measured memory_bytes: 2148
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int count = 0;
    String str = sc.next();
    char[] ch = new char[n];
    for(int i = 0; i < n; i++) {
      ch[i] = str.charAt(i);
    }
    char temp = ch[0];
    for(int i = 0; i < n; i++) {
      if(temp != ch[i]) {
        count++;
        temp = ch[i];
      }
    }
    int ans = n;
    if(count / 2 >= k) ans -= (count - 2 * k + 1);
    else ans --;
    System.out.println(ans);
  }
}


Measured memory_bytes: 28284
#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int SIZE = 1 << 18; char STR[SIZE], *BEG = STR, *END = STR;
inline char get() { if(BEG == END) END = (BEG = STR) + fread(STR, 1, SIZE, stdin); return (BEG == END? EOF: *(BEG++)); }
inline int read() {
	int x = 0, op = 1; char ch = 0;
	while(not isdigit(ch = get())) if(ch == '-') op = -op;
	do x = (x << 3) + (x << 1) + (ch - '0'); while(isdigit(ch = get()));
	return op * x;
}
const int inf = 10000000000000LL;
int w = 0, h = 0, n = 0; pair<int, int> pos[300500];
int xds[300500 << 2], laz[300500 << 2];
inline void flsh(int t, int l, int r) {
	if(laz[t]) {
		if(l < r) laz[t << 1] += laz[t], laz[t << 1 | 1] += laz[t];
		xds[t] += laz[t], laz[t] = 0;
	}
}
void add(int u, int v, int s, int t, int l, int r) {
	flsh(t, l, r);
	if(u > v) return;
	if(u <= l and r <= v) {
		laz[t] += s;
		flsh(t, l, r);
	} else {
		flsh(t << 1, l, (l + r) >> 1), flsh(t << 1 | 1, ((l + r) >> 1) + 1, r);
		if(u <= (l + r) >> 1) add(u, v, s, t << 1, l, (l + r) >> 1);
		if(v > (l + r) >> 1) add(u, v, s, t << 1 | 1, ((l + r) >> 1) + 1, r);
		xds[t] = max(xds[t << 1], xds[t << 1 | 1]);
	}
}
int sol(int u, int v, int t, int l, int r) {
	flsh(t, l, r);
	if(u > v) return -inf;
	if(u <= l and r <= v) return xds[t];
	else {
		int p = -inf;
		if(u <= (l + r) >> 1) p = max(p, sol(u, v, t << 1, l, (l + r) >> 1));
		if(v > (l + r) >> 1) p = max(p, sol(u, v, t << 1 | 1, ((l + r) >> 1) + 1, r));
		return p;
	}
}
int solve() {
	sort(pos + 1, pos + n + 1);
	stack<pair<int, int> > up, down;
	memset(laz, 0, sizeof laz), memset(xds, 0, sizeof xds);
	int rez = 0;
	for(int i = 1; i <= n; i++) {
		int las = i - 1;
		if(pos[i].second > h / 2) {
			while(not up.empty() and up.top().second >= pos[i].second) {
				if(up.top().second != pos[i].second) add(up.top().first, las, pos[i].second - up.top().second, 1, 1, n);
				las = up.top().first - 1, up.pop();
			}
			if(las < i - 1) up.push(make_pair(las + 1, pos[i].second));
		} else {
			while(not down.empty() and down.top().second <= pos[i].second) {
				if(down.top().second != pos[i].second) add(down.top().first, las, down.top().second - pos[i].second, 1, 1, n);
				las = down.top().first - 1, down.pop();
			}
			if(las < i - 1) down.push(make_pair(las + 1, pos[i].second));
		}
		up.push(make_pair(i, h)), down.push(make_pair(i, 0));
		add(i, i, h - pos[i].first, 1, 1, n); // 总高度-左边界 
		rez = max(rez, pos[i + 1].first + sol(1, n, 1, 1, n)); // 最大值+右边界 
	}
	return rez << 1;
}
signed main() {

	w = read(), h = read(), n = read();
	for(int i = 1; i <= n; i++) pos[i].first = read(), pos[i].second = read();
	n++, pos[n] = make_pair(w, h), n++, pos[n] = make_pair(0, 0);
	int ans = 0;
	ans = max(ans, solve());
	swap(w, h); for(int i = 1; i <= n; i++) swap(pos[i].first, pos[i].second);
	ans = max(ans, solve());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 26496
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <bitset>

using ll = long long;

using namespace std;
using bs = bitset<30>;

int main() {
    int n, _k;
    cin >> n >> _k;
    bs k(_k), filled = (1 << 30) - 1;
    vector<bs> vars;
    vars.push_back(k);
    for ( ; (filled & k) != 0; filled <<= 1) {
        vars.push_back((filled & k).to_ulong() - 1);
        //cerr << vars.back() << '\n';
    }
    bs a;
    long _a, b, sum[31] = {0};
    for (int i=0; i<n; i++) {
        cin >> _a >> b;
        a = _a;
        int j=0;
        for (auto &v:vars) {
            if ((v | a) == v) sum[j] += b;
            j++;
        }
    }
    long _max = 0;
    for (auto &s:sum) _max = max(_max, s);
    cout << _max << '\n';
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[5],ans,cost[5];
void recur(int t,int used[])
{
    int f=0,rem=0;
    for(int i=0; i<5; i++)
    {
        if(!used[i])
        {
            f=1;
            rem=0;
            if(t%10){
               rem=10-(t%10);
            }

            used[i]=1;
            recur(t+arr[i]+rem,used);
            used[i]=0;

        }
    }
    if(!f)
        ans=min(ans,t);

}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

    for(int i=0; i<5; i++)
        cin>>arr[i];
    int used[20]= {0};
    ans=INT_MAX;
    recur(0,used);
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 3568
while(1):
    a, op, b = input().split()
    if op == "?":
        break
    a, b = int(a), int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n;
  int max=0;
  int a[1005][1005]={};
  int x1[100005],y1[100005],x2[100005],y2[100005];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];

    a[x2[i]][y2[i]]++;
    a[x1[i]][y1[i]]++;
    a[x1[i]][y2[i]]--;
    a[x2[i]][y1[i]]--;
  
  }

  for(int j=0;j<1000;j++){
    for(int k=1;k<1000;k++){
    
      a[j][k]+=a[j][k-1];
      
    }
  }
  for(int j=1;j<1000;j++){
    for(int k=0;k<1000;k++){
    
      a[j][k]+=a[j-1][k];
    }
  }

  for(int j=0;j<1000;j++){
    for(int k=0;k<1000;k++){
      if(max<a[j][k]){
	max=a[j][k];
      }
    }
  }
  
  cout<<max<<"\n";
  
 return 0;
}






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

int main(){
  int N;
  cin>>N;
  set<char> st;
  for(int i=0;i<N;i++){
    char c;
    cin>>c;
    st.insert(c);
  }
  if(st.size()==4){
    cout<<"Four"<<endl;
  }else{
    cout<<"Three"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = map(int,input().split())
a = list(map(bin,a))
a = [int(i,2) for i in a]
ans = a[0]
for i in range(n-1):
    ans = ans ^ a[i+1]

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

Measured memory_bytes: 18852
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMax(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	MAX := int(math.Pow10(5))
	N := scanInt()

	A := make([]int, MAX+2)
	for i := 0; i < N; i++ {
		a := scanInt()
		A[a]++
	}

	ans := 0
	for i := 1; i <= MAX; i++ {
		ans = intMax(ans, A[i-1]+A[i]+A[i+1])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf (int)50000000000000000 //5･10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
int n;
map<int,int>a;
signed main() {
  cin>>n;
  rep(i,n) {
    int d;
    cin>>d;
    a[d]++;
  }
  int m;
  cin>>m;
  rep(i,m) {
    int t;
    cin>>t;
    if(a[t]==0) {
      cout<<"NO"<<endl;
      return 0;
    }
    else {
      a[t]--;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 12800
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
  IOS

  int n;
  map<int,int> m;
  cin>>n;
  int sum = 0;
  for(int i = 1;i<=n;i++){
      int x;
      cin>>x;
      m[x]++;
      sum+=x;
  }
  int q;
  cin>>q;
  while(q--){
      int b,c;
      cin>>b>>c;
      sum+=(c-b)*(m[b]);
      cout<<sum<<endl;
      m[c]+=m[b];
      m.erase(b);
  }
  
  
  
}

Measured memory_bytes: 7528
#include <bits/stdc++.h>
const int maxN = 200003;
typedef long long LL;
LL A[maxN], B[maxN];
int Acnt, Bcnt;
LL K;

int main()
{
    std::cin >> Acnt >> Bcnt >> K;
    for (int i=0; i<Acnt; ++i)
        std::cin >> A[i];
    for (int i=0; i<Bcnt; ++i)
        std::cin >> B[i];
    int ret = 0;
    int posA = 0, posB = 0;
    while (posA < Acnt)
    {
        if (A[posA] <= K)
        {
            ++ret;
            K -= A[posA++];
        }
        else
            break;
    }
    while (posB < Bcnt)
    {
        if (B[posB] <= K)
        {
            ++ret;
            K -= B[posB++];
        }
        else
            break;
    }
    int max_ret = ret;
    while (posA >= 0)
    {
        K += A[--posA];
        --ret;
        while (posB < Bcnt)
        {
            if (B[posB] <= K)
            {
                ++ret;
                K -= B[posB++];
            }
            else
                break;
        }
        if (ret > max_ret)
            max_ret = ret;
    }
    std::cout << max_ret;
}

Measured memory_bytes: 6756
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ii pair<int,int>
#define ll long long
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define orta ((bas+son)>>1)
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define inf 100000000
#define N 505
#define MOD 998244353
using namespace std;

int main() {

	int n;

	scanf("%d",&n);

	vector<int> a(n),tut(n+1);

	for(int i=0;i<n;i++) {

		scanf("%d",&a[i]);
		
		tut[a[i]]=i;

	}

	int r=0;
	int mx=0;
	int rmost=0;

	for(int l=1;l<=n;l++) {

		if(l>r) {

			r=l;
			rmost=tut[r];

		}

		while(r+1<=n && tut[r+1]>rmost) {

			r++;
			rmost=tut[r];

		}

		umax(mx,r-l+1);

	}

	printf("%d",n-mx);


}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main(){
  ll n;
  cin>>n;
  bitset<40> b(0);
  if(!n){
     cout<<0;
     return 0; 
  }
  ll x,cnt,sum,f=0;
  while(n){
     if(n>0){
        sum=x=1;
        cnt=0;
        while(n>sum){
           cnt+=2;
           sum+=x*=4; 
        }
     }else{
        sum=x=-2;
        cnt=1;
        while(n<sum){
           cnt+=2;
           sum+=x*=4; 
        }
     }
     n-=x;
     b.set(cnt);
  }
  string s=b.to_string();
  rep(i,s.size())
     if(f || (f=(s[i]=='1')))
       cout<<s[i]; 
  return 0;
}

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

public class Main {

	int a[];
	Integer b[];
	
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H = sc.nextInt();
		a = new int[N];
		b = new Integer[N];
		for(int i=0; i<N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(b, Collections.reverseOrder()); //降順
		
		int aMax = 0;
		for(int i=0; i<N; i++) if(aMax < a[i]) aMax = a[i];
		
		int dam = 0, count = 0;
		for(int i=0; i<N; i++) {
			if(b[i] > aMax) { //投げるより振る方が得の場合ある
				dam += b[i];
				count++;
			}
			if(dam >= H) { //投げて終わり
				System.out.println(count);
				return;
			}
		}
		
		//投げて終わらない
		int j = 0;
		while(dam < H) {
			dam += aMax;
			j++;
		}
		
		System.out.println(count+j);
	}
}

Measured memory_bytes: 86300
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        for (int i = X; i <= 110000; i++) {
            if (is_prime(i)) {
                System.out.println(i);
                return;
            }
        }
    }
    private boolean is_prime(int x) {
        if (x < 2) {
            return false;
        }
        for (int i = 2; i * i <= x; i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 21716
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [i32; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }
 
// https://practice.contest.atcoder.jp/tasks/practice_1
fn main() {
    input! { a: i32, b: i32 }
    println!("{}", if b%a==0 { a+b } else { b-a } );
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	int res = 0;
	FOR(i,1, n/2+1) {
		if (i != n - i) {
			res++;
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace myApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<int> d = new List<int>();

            for(int i = 0 ; i < n; i++)
                d.Add(int.Parse(Console.ReadLine()));

            List<int> dan = d.Distinct().ToList();

            Console.WriteLine(dan.Count());
        }
    }
}


Measured memory_bytes: 13268
function main(arg) {
	arg = arg.trim().split(/\n/);
  	var n = arg[0], s = arg[1], abc = /(ABC)/g,
  		out = s.match(abc);
 	if (out === null) {
    	console.log('0');
    } else {
	 	console.log(out.length);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 22204
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    println!("{}", (n + k - 3) / (k - 1));
}

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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
   int n;
   cin>>n;
   vector<int> a(n);
   rep(i,n){
      cin>>a[i];
   }
   int count=0;

   rep(i,n){
      bool f=true;
      
      
         for(int j=0;j<i;j++){
            if(a[i]<a[j]) f=false;
         }
      
      if(f) count++;
       
   }
   cout<<count;
   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> x(n), y(n);
    for(ll i=0;i<n;++i){
        cin>>x[i]>>y[i];
    }

    
    ld ans = 0;
    for(ll i=0;i<n;++i){
        for(ll j=i;j<n;++j){
            if(i == j){
                continue;
            }
            ans += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
        }
    }
    ans = ans * 2 / n;
    cout<<setprecision(15)<<ans<<endl;

    return 0;
}

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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=1e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

char c;

int main()
{
    c=getchar();
    if(c>='A'&&c<='Z')puts("A");
    else puts("a");
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>

int map[50][50];
int w, h;
int ans;
int xx, yy;
const int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

void Walk(int X, int Y) {
	map[Y][X] = 0;
	for(int i = 0; i < (sizeof(dx) / sizeof(dx[0])); i++) {
		xx = X + dx[i];
		yy = Y + dy[i];
		if(0 <= xx && xx < w && 0 <= yy && yy < h && map[yy][xx] == 1) {
			Walk(xx, yy);
		}
	}
}

int main(void) {
	while(1) {
		ans = 0;
		scanf("%d %d", &w, &h);
		if(!w && !h) break;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				scanf("%d", &map[i][j]);
			}
		}
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(map[i][j] == 1) {
					ans++;
					Walk(j, i);
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1104
import itertools
n = int(input())
a_L = list(map(int,input().split()))

def get_ruisekiwa(a_L):
    # 累積和
    return [0] + list(itertools.accumulate(a_L))

ans = float("inf")
r = get_ruisekiwa(a_L)

#print(r)
for i in range(1,len(a_L)):
    x = r[i]
    g = r[-1] - r[i]
    ans = min(abs(x-g),ans)

print(ans)

Measured memory_bytes: 88528
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=ja
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q;
    cin >> N;
    vector<int> A(N);
    for (auto &x : A) {
        cin >> x;
    }
    cin >> Q;
    int ans = 0;
    while (Q--) {
        int t;
        cin >> t;
        // 二分探索
        int ng = -1, ok = N - 1;
        while (ok - ng > 1) {
            int mid = (ng + ok) / 2;
            (A[mid] >= t ? ok : ng) = mid;
        }
        ans += (A[ok] == t);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  vector<int> f(n+1,0);
  
    for(int X=1;X*X<=n ;X++){//Xを１からnまで回す
            for(int Y=1;Y*Y<=n;Y++){//Yを１からnまで回す
                    for(int Z=1;Z*Z<=n;Z++){//Zを１からnまで回す
                        int A = X*X+Y*Y+Z*Z+X*Y+Y*Z+Z*X;
                        if(A>n) break;
                        f[A]++;
                    }
            }
    }
    
    for(int i=1; i<=n; i++){
        cout << f[i] << endl;
    }
}


Measured memory_bytes: 3600
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

struct people {
    int a, b, c;

    people() {
        a = b = c = 0;
    }
} arr[MAXN];

ll v1[MAXN], v2[MAXN];

int X, Y, Z;

ll ans;

int n;

bool cmp(people f, people s) {
    return f.a - f.b < s.a - s.b;
}

void solve() {
    scanf("%d %d %d", &X, &Y, &Z);
    n = X + Y + Z;

    for (int i = 1; i <= n; ++i) {
        scanf("%d %d %d", &arr[i].a, &arr[i].b, &arr[i].c);
    }

    sort(arr + 1, arr + n + 1, cmp);

    for (int i = 1; i <= n; ++i) {
        arr[i].a -= arr[i].c;
        arr[i].b -= arr[i].c;
    }

    multiset<int> S;

    for (int i = 1; i <= n; ++i) {
        v1[i] = v1[i - 1] + arr[i].b;
        S.insert(arr[i].b);

        if (S.size() > Y) {
            v1[i] -= *S.begin();
            S.erase(S.begin());
        }
    }

    S.clear();

    for (int i = n; i > 0; --i) {
        v2[i] = v2[i + 1] + arr[i].a;
        S.insert(arr[i].a);

        if (S.size() > X) {
            v2[i] -= *S.begin();
            S.erase(S.begin());
        }
    }

    ans = -(ll)1e18;

    for (int i = Y; i <= n - X; ++i) {
        ans = max(ans, v1[i] + v2[i + 1]);
    }

    for (int i = 1; i <= n; ++i) {
        ans += arr[i].c;
    }

    printf("%lld\n", ans);
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 7424