akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

int main(){
	string s;
	cin>>s;
	long long int kai=0;
	long long int n=s.size();
	
	map<char,int> mp;
	for(int i=0;i<26;i++){
		mp['a'+i]=0;
	}
	
	for(int i=0;i<n;i++){
		mp[s[i]]++;
	}
	
	for(int i=0;i<26;i++){
		if(mp['a'+i]>1){
			long long int kait=0;
			for(int j=1;j<mp['a'+i]+1;j++)kait+=(j-1);
			kai+=kait;
		}
	}
	
	//cout<<kai<<endl;
	cout<<s.size()*(s.size()-1)/2+1-kai<<endl;
	
	return 0;
}

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


int main() {
  string S;
  long long K;
  cin>>S>>K;
  
  for(int i=0;i<min((long long)S.size(),K);i++){
    if(S.at(i)=='1') continue;
    else{
      cout<<S.at(i)<<endl;
      return 0;
    }
  }
  cout<<'1'<<endl;
  
  
}

Measured memory_bytes: 3608
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

ll solve(ll A, ll B, ll C, ll d) {
  if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
    return d;
  } else if (A == B && B == C) {
    return -1;
  } else {
    const ll A2 = A / 2, B2 = B / 2, C2 = C / 2;
    return solve(B2 + C2, C2 + A2, A2 + B2, d + 1);
  }
}

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  cout << solve(A, B, C, 0) << endl;
  return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    map<string, int> m;
    int mx = 0;
    REP(i, n) {
        string s;
        cin >> s;
        m[s]++;
        chmax(mx, m[s]);
    }
    set<string> st;
    for (auto x : m) {
        if (x.second == mx) st.emplace(x.first);
    }
    for (auto x : st) cout << x << endl;
}


Measured memory_bytes: 33280
def show (nums):
    for i in range(len(nums)):
        if i!=len(nums)-1:
            print(nums[i],end=' ')
        else :
            print(nums[i])

n=int(input())
nums=list(map(int,input().split()))
show(nums)
for i in range(1,n):
    v=nums[i]
    j=i-1
    while (j>=0 and nums[j]>v):
        nums[j+1]=nums[j]
        j-=1
    nums[j+1]=v
    show(nums)

    

Measured memory_bytes: 8136
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 998244353
#define F first
#define S second
#ifdef LOCAL
    #include "trace.h"
#else
    #define trace(args...)
#endif
 
ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
	ll n, x, m;
	cin>>n>>x>>m;
	vector<ll> a;
	vector<ll> occur(m, -1);
	a.push_back(x);
	occur[x] = 0;
	
	while(occur[(a.back()*a.back())%m]==-1){
		occur[(a.back()*a.back())%m] = sz(a);
		a.push_back((a.back()*a.back())%m);
	}

	ll repeat = (a.back()*a.back())%m;

	vector<ll> pref_sum(sz(a)+1, 0);
	for(int i = 1; i<=sz(a); i++)
		pref_sum[i] = pref_sum[i-1] + a[i-1];
	if(n<=sz(a))
		cout<<pref_sum[n]<<endl;
	else{
		ll rem = n - sz(a);
		ll ans = pref_sum[sz(a)];
		ll dist = sz(a) - occur[repeat];
		ll sum  = pref_sum[sz(a)] - pref_sum[occur[repeat]];
		ans += (rem/dist)*sum;
		ans += pref_sum[occur[repeat]+rem%dist]-pref_sum[occur[repeat]];
		cout<<ans<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	ll t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 5056
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
const int INF = 1e9;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, a[MAXN * 2];
int fb[MAXN][MAXN], fw[MAXN][MAXN], dp[MAXN][MAXN];
char type[MAXN * 2];
int main() {
	read(n);
	int tans = 0;
	for (int i = 1; i <= 2 * n; i++) {
		char opt = getchar();
		while (opt != 'B' && opt != 'W') opt = getchar();
		type[i] = opt; read(a[i]);
		for (int j = 1; j <= i - 1; j++)
			tans += type[i] == type[j] && a[i] < a[j];
	}
	static bool eb[MAXN], ew[MAXN];
	for (int i = 2 * n; i >= 1; i--) {
		if (type[i] == 'B') {
			for (int j = 1; j <= n; j++)
				fb[a[i]][j] = fb[a[i]][j - 1] + ew[j];
		} else {
			for (int j = 1; j <= n; j++)
				fw[a[i]][j] = fw[a[i]][j - 1] + eb[j];
		}
		if (type[i] == 'B') eb[a[i]] = true;
		else ew[a[i]] = true;
	}
	for (int i = 0; i <= n; i++)
	for (int j = 0; j <= n; j++) {
		if (i == 0 && j == 0) dp[i][j] = 0;
		else dp[i][j] = INF;
		if (i != 0) chkmin(dp[i][j], dp[i - 1][j] + fb[i][j]);
		if (j != 0) chkmin(dp[i][j], dp[i][j - 1] + fw[j][i]);
	}
	writeln(dp[n][n] + tans);
	return 0;
}

Measured memory_bytes: 47360
def main():
    n = input()
    A = []
    for i in xrange(n):
        A.append(map(int,raw_input().split()))

    inf = float('inf')
    d = [inf]*n
    p = [-1]*n
    c = [-1]*n
    d[0] = 0

    while(True):
        mincost = inf
        for i in xrange(n):
            if(c[i] != 1) & (d[i] < mincost):
                mincost = d[i]
                u = i
        if mincost == inf:
            break

        c[u] = 1
        
        for v in xrange(n):
            if (c[v] != 1) & (A[u][v] != -1):
                if A[u][v] < d[v]:
                    d[v] = A[u][v]
                    p[v] = u
                    c[v] = 0

    cost = 0
    for i in xrange(n):
        if(p[i] != -1):
            cost += A[i][p[i]]

    print cost
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 6564
def main():
    N,T = [int(i) for i in input().split()]
    t = [int(i) for i in input().split()]
    ans = 0

    for i in range(N-1):
        x = t[i+1] - t[i]
        ans += min(T,x)

    print(ans+T)

if __name__ == '__main__':
    main()


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

int main(){
    vector<int> N(2);
    while (1){
        cin >> N[0] >> N[1];
        if(N[0] == 0 && N[1] == 0){
            break;
        }
        else{
            sort(N.begin(), N.end());
            cout << N[0] << ' ' << N[1] << endl; 
        }
    }
    return 0;
}


Measured memory_bytes: 3024
#include <stdio.h>

long long i=1;

int kaizyou(int kazu){
	if(kazu==1){
		return 0;
	}else{
		i*=--kazu;
		kaizyou(kazu);
	}
}

int main(){
	scanf("%d",&i);
	kaizyou(i);
	printf("%lld\n",i);
	return 0;
}

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

int main(){
    int s,i(0);
    vector<int> a;

    cin >> s;
    a.push_back(s);

    while(true){
        if((a[i]%2)==0){
            a.push_back(a[i]/2);
            i++;
        }else{
            a.push_back(3*a[i]+1);
            i++;
        }
        rep(j,a.size()-1){
            if(a[i]==a[j]){
                cout << i+1 << endl;
                return 0;
            }
        }
        if(a[i]==a[i-1]){
            i++;
            break;
        }
    }


}

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

int main(){
    int a, b, k; cin >> a >> b >> k;
    vector<int> v;

    for(int i = 1; i <= max(a,b); i++){
        if(a % i == 0 && b % i == 0){
            v.push_back(i);
        }
    }

    sort(v.begin(),v.end());
    //for(auto e:v) cout << e << " ";
    put(v[v.size()-k]);
}

Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline
  n=int(input())
  xy=[list(map(int,input().split())) for _ in [0]*n]
  ans=0
  for i in range(n):
    xi,yi=xy[i][0],xy[i][1]
    for j in range(i+1,n):
      xj,yj=xy[j][0],xy[j][1]
      ans+=pow(pow(xi-xj,2)+pow(yi-yj,2),0.5)
  print(ans*2/n)
  # (各ペア間距離の総和)*2*(n-1)!/n!=(各ペア間距離の総和)*2/n
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define readvec(vec)    \
  for (auto& e : vec) { \
    cin >> e;           \
  }
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> g(n + 1);
  vecint ans(q, 0);
  int l = 0;
  int r = 0;
  REP(i, m) {
    cin >> l >> r;
    g[l].push_back(r);
  }
  REP(i, n + 1) { sort(all(g[i])); }
  int a = 0;
  int b = 0;
  REP(i, q) {
    cin >> a >> b;
    for (int j = a; j <= b; j++) {
      if (g[j].size() == 0) continue;
      if (g[j][0] > b) continue;
      if (g[j].back() <= b) {
        ans[i] += g[j].size();
        continue;
      }
      auto itr = upper_bound(all(g[j]), b);
      ans[i] += distance(g[j].begin(), itr);
    }
  }
  // cout << endl;

  for (auto& e : ans) cout << e << endl;
}

Measured memory_bytes: 2560
using System;

namespace ABC169A
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = Console.ReadLine().Trim().Split(' ');
            int a = int.Parse(t[0]);
            int b = int.Parse(t[1]);
            Console.WriteLine(a*b);
        }
    }
}

Measured memory_bytes: 27536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0015
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();

            for (int i = 0 ; i < n ; i++)
            {
                string a = ReadSt();
                string b = ReadSt();

                a = string.Join("", a.PadLeft(100, '0').Reverse());
                b = string.Join("", b.PadLeft(100, '0').Reverse());

                string[] resAr = new string[100];
                bool carrying = false;
                for (int j = 0 ; j < resAr.Length ; j++)
                {
                    string tmp = (int.Parse(a[j].ToString()) + int.Parse(b[j].ToString()) + (carrying ? 1 : 0)).ToString();
                    resAr[j] = tmp.Substring(tmp.Length - 1, 1);
                    carrying = (int.Parse(tmp) > 9) ? true : false;
                }

                string res = string.Join("", resAr.Reverse().SkipWhile(x => x == "0").ToArray());
                Console.WriteLine(res.Length > 80 ? "overflow" : res.Count() == 0 ? "0" : res);

            }

        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 18292
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    int l,r;
    bool f=0;
    for(int i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1])
        {
            f=1;
            l=i+1;
            r=i+2;
            break;
        }
        if(i<n-2)
        {
            if(s[i]==s[i+2])
            {
                f=1;
            l=i+1;
            r=i+3;
            break; 
            }
        }
    }
    if(!f)
        cout<<"-1 -1\n";
    else
        cout<<l<<" "<<r<<endl; 

    
    return 0;   
}


 
 


Measured memory_bytes: 512
#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字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1000000007;

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

    if(abs(N-M)>1){

        cout << 0 << endl;

    } else if(N == M){

        ll ans = 1;
        for(int i=1; i<=N; i++){
            ans *= i;
            ans %= mod;
            ans *= i;
            ans %= mod;
        }
        ans = 2*ans%mod;
        cout << ans << endl;

    } else {

        ll ans = 1;
        for(int i=1; i<=N; i++){
            ans *= i;
            ans %= mod;
        }
        for(int i=1; i<=M; i++){
            ans *= i;
            ans %= mod;
        }
        cout << ans << endl;

    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int t,n,s,f,i,sum;
    while(1){
        scanf("%d",&t);
        if(t==0){
            break;
        }
        scanf("%d",&n);
        sum=0;
        for(i=0;i<n;i++){
            scanf("%d %d",&s,&f);
            sum=sum+(f-s);
        }
        if(sum>=t){
            puts("OK");
        }else{
            printf("%d\n", t - sum);
        }
    }
    return 0;
}


Measured memory_bytes: 2056
import copy
n = int(input())
A = list(map(int, input().split()))
q = int(input())

for i in range(q):
    B = copy.copy(A)
    queryi = list(map(int, input().split()))
    b = queryi[0]
    m = queryi[1]
    e = queryi[2]

    for k in range(e-b):
        pos = b+((k+e-m) % (e-b))
        B[pos] = A[b+k]
    
    A = copy.copy(B)
    
B = list(map(str, B))
print(" ".join(B))


Measured memory_bytes: 6352
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> inputList = new ArrayList<>();
        int a = 0;
        int b = 0;
        while(true) {
            a = sc.nextInt();
            b = sc.nextInt();
            if(a == 0 && b == 0){
                break;
            }
            if(a < b){
                inputList.add(a);
                inputList.add(b);
            }else{
                inputList.add(b);
                inputList.add(a);
            }
            
        }
        
        int count = 0;
        for(int input: inputList){
            if(++count % 2 == 0){
            	count = 0;
            	System.out.println(input);
            }else{
            	System.out.print(input + " ");
            }
        }
        
    }
}


Measured memory_bytes: 36380
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int[] a = LineInt();
        int[] ans = new int[N + 1];
        Array.Reverse(a);
        for (int i = 0; i < N; i++)
        {
            int num = N - i;
            int x = 2;
            int sum = 0;
            while (num * x <= N)
            {
                sum += ans[num * x];
                x++;
            }
            if (a[i] != sum % 2) ans[num]++;
        }
        int count = ans.Count(v => v == 1);
        Console.WriteLine(count);
        for (int i = 0; i <= N; i++)
            if (ans[i] == 1) Console.WriteLine(i);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


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

int main()
{
  int n;
  cin>>n;
  std::vector<int> h(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>h[i];
  }
  reverse(h.begin(), h.end());
  for (int i = 1; i < n; ++i)
  {
    if(h[i-1]<h[i]){
      h[i]--;
    }
  }
  bool flag=true;
  for (int i = 1; i < n; ++i)
  {
    if(h[i-1]<h[i]){
      flag=false;
    }
  }
  cout<<(flag? "Yes":"No");
}

Measured memory_bytes: 640
// inputに入力データ全体が入る
function Main(input) {
    var s = input;
    var counter;
    var res = true;
    for(var i = 0;i<4;i++){
        if(counter == s.charAt(i)){
            res = false;
            break;
        }
        counter = s.charAt(i);
    }
    if(!res){
        console.log("Bad")
    }else{
        console.log("Good")
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int h1, h2, k1, k2, a, b, c, d, h, k;
	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
	h = h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d;
	k = k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d;
	if (h > k)
		cout << "hiroshi" << endl;
	else if (h < k)
		cout << "kenjiro" << endl;
	else
		cout << "even" << endl;

	return 0;
}

Measured memory_bytes: 3088
from __future__ import print_function
import numpy as np
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

cnt=0
S=list(input())
# eprint(S)

L=list()
L.append(S.pop())
while len(S)!=0:
    if S[-1]==L[-1]: # SのfrontとLのfrontが0と0とか一致しちゃった時だから，消せない．次のSのfrontを見よう 
        L.append(S.pop())
        # eprint("S: " + str(S))
        # eprint("L: " + str(L))
    else: # SのfrontとLのfrontが0と1となっている場合．消す．
        S.pop()
        L.pop()
        if L==[] and S!=[]:
            L.append(S.pop())
        cnt=cnt+2
        # eprint("S: " + str(S))
        # eprint("L: " + str(L))

print(cnt)

#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#


Measured memory_bytes: 13796
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <list>
#include <map>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

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

const int MOD = 1000000007;
const ll INF = 1e18;

int main() {
    int n; cin >> n;
    vi a, b;
    int t;
    forn(i, n + 1) {
        cin >> t; a.pb(t);
    }
    forn(i, n) {
        cin >> t; b.pb(t);
    }

    ll ans = 0;

    forn(i, n) {
        if (b[i] < a[i]) ans += b[i];
        else {
            ans += a[i] + min(b[i] - a[i], a[i + 1]);
            a[i + 1] = max(0, a[i + 1] - (b[i] - a[i]));
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1400
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>
#include <set>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

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

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

bool vector_finder(std::vector<int> vec, int number) { // vector 内にnumberがあるかどうか
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance( vec.begin(), itr );
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int main() {
	int x;
	cin >> x;
	if (x == 0) {
		cout << 1;
	} else {
		cout << 0;
	}
	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    cins(all(a));
    vector<ll> cnt;
    RSORT(a);
    cnt.push_back(a[0]);
    rep(i,1,n){
        cnt.push_back(a[i]);
        cnt.push_back(a[i]);
    }
    RSORT(cnt);
    ll ans = 0;
    rep(i,n-1) ans += cnt[i];
    PRINT(ans);
}


Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,Q;
  long long K;
  cin>>N>>K>>Q;
  vector<int>A(Q);
  vector<int>score(N,K-Q);
  for(int i=0;i<Q;i++){
    cin>>A.at(i);
    score.at(A.at(i)-1)=score.at(A.at(i)-1)+1;
  }
  for(int i=0;i<N;i++){
    if(score.at(i)>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}
  

Measured memory_bytes: 1408
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int N,M,R,r[10],d[203][203];


int main (){
      cin>>N>>M>>R;
      rep0(i,R) cin>>r[i];
      rep1(i,N){
            rep1(j,N){
                  d[i][j]=inf;
            }
      }
      rep1(i,N){
            d[i][i]=0;
      }
      rep0(i,M){
            int A,B;
            cin>>A>>B;
            cin>>d[A][B];
            d[B][A]=d[A][B];
      }
      rep1(k,N){
            rep1(i,N){
                  rep1(j,N){
                        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
                  }
            }
      }
      sort(r,r+R);
      ll ans=inf;
      do{
            ll now=0;
            rep0(i,R-1)now+=d[r[i]][r[i+1]];
            ans=min(ans,now);
      }while(next_permutation(r,r+R));
      cout<<ans<<endl;

      
      return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int d= 1e9;

int main() {
  ll s; cin >> s;
  ll x, y;
  x = (d-s%d)%d;
  y = (s+x)/d;
  cout << "0 0 1000000000 1 " << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        System.out.println((n - 2) / (k - 1) + 1);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 52348
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 2];
int sumE,head[MAXN],N;
int dis[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs(int u,int fa) {
    dis[u] = dis[fa] + 1;
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa) {
            dfs(v,u);
        }
    }
}
void Solve() {
    read(N);
    if(N == 1) {
        puts("First");return;
    }
    int a,b;
    for(int i = 1 ; i < N ; ++i) {
        read(a);read(b);
        add(a,b);add(b,a);
    }
    dfs(1,0);
    int u = 1;
    for(int i = 1 ; i <= N ; ++i) {
        if(dis[i] > dis[u]) u = i;
    }
    dfs(u,0);
    u = 1;
    for(int i = 1 ; i <= N ; ++i) {
        if(dis[i] > dis[u]) u = i;
    }
    if(dis[u] % 3 == 2) {puts("Second");}
    else puts("First");
}
int main() {
    Solve();
}

Measured memory_bytes: 11136
#include "bits/stdc++.h"
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
#define MAX_V (110)

signed main(){
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size())ans += s[i] == '1';
	cout << ans << endl;
}

Measured memory_bytes: 256
import math
def prime2(x):
  cnt = 0
  while x % 2 == 0:
    x //= 2
    cnt += 1
  return cnt
def prime5(x):
  cnt = 0
  while x % 5 == 0:
    x //= 5
    cnt += 1
  return cnt


N = int(input())
A = [input() for _ in range(N)]

D = [[0] * 3 for _ in range(N)]

M2 = 0
M5 = 0
Md = 0

cnt = 0
for x in A:
  t = x.find(".")
  d = 9
  if t != -1:
    for i in range(t):
      x = x.rstrip("0")
    d -= (len(x) - t - 1)
    x = x.replace(".", "")
  p2 = prime2(int(x))
  p5 = prime5(int(x))
  n = min(p2, p5)
  p2 -= n
  p5 -= n
  d += n
  D[cnt] = [p2, p5, d]
  cnt += 1
  M2 = max(M2, p2)
  M5 = max(M5, p5)
  Md = max(Md, d)

Md += 1
M = min(M2, M5) + 1
L = [[[0] * M for _ in range(2)] for _ in range(Md)]

ans = 0
for i in range(N):
  p2, p5, d = D[i]
  if p2 == 0:
    n = 1
    t = p5
  else:
    n = 0
    t = p2
  for j in range(Md):
    for k in range(M):
      if d + j + min(t, k) >= 18:
        ans += L[j][1 - n][k]
      if d + j >= 18:
        ans += L[j][n][k]
  L[d][n][min(t, M - 1)] += 1

print(ans)


Measured memory_bytes: 134072
S = input()
Y = "Yes"
N = "No"
if S[0] == S[1] == S[2] == S[3]:
  print(N)
elif S[0] == S[1] and S[2] == S[3]:
  print(Y)
elif S[0] == S[2] and S[1] == S[3]:
  print(Y)
elif S[0] ==S[3] and S[1] == S[2]:
  print(Y)
else:
  print(N)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/



int n, a[55], b[55], c[55];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i]; a[i]--;
	}
	rep(i, n)cin >> b[i];
	rep(i, n - 1)cin >> c[i];
	int ans = 0;
	rep(i, n) {
		ans += b[a[i]];
		if (a[i] + 1 == a[i + 1] && i < n - 1)ans += c[a[i]];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

bool hantei(string s){
  int l = s.size();
  bool flag = true;
  rep(i,l){
    if(s.at(i)!=s.at(l-1-i))flag = false;
  }
  return flag;
}

int main(){
  string s;
  cin >> s;
  int l = s.size();
  string a = "";
  string b = "";
  rep(i,l/2)a += s.at(i);
  for(int i = l/2+1;i < l;i++)b += s.at(i);
  if(hantei(s)&&hantei(a)&&hantei(b)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

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


int main() {
	int i, j, k;
	int N, M, K;

	cin >> N;
	int A[100];
	int B[100];
	rep(i, 0, N) {
		cin >> A[i];
		A[i]--;
		B[i] = i - A[i];
	}
	stack<int> Ans;
	rep(i, 0, N) {

		int a=-1;
		rep(j, 0, N) {
			if (A[j] == -1) continue;
			if (B[j] == 0)
				a = j;
		}
		if (a == -1) {
			cout << "-1";
			return 0;
		}
		Ans.push(A[a]);
		A[a] = -1;
		rep(j, a + 1, N) {
			B[j] --;
		}

	}
	rep(i,0,N){
		int a = Ans.top();
		Ans.pop();
		cout << a+1 << endl;
	}
	return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  ll anser = k * pow(k - 1, n - 1);
  cout << anser << endl;
  return 0;
}






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




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n;
    cin>>n;
    ll ans = 0;
    if(n%2){
        cout << 0 << endl;
        return 0;
    }
    ll f=0;
    while(n){
        f+=n/5/2;
        n/=5;   
    }
    cout << f << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<cmath>

#define MIN(a,b) (a)>(b)?(b):(a)

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	float a = float(B - 1)/float(A - 1);
	cout << (int)ceilf(a);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

int main() {
	array<int, 4> v;
	string s;
	string ans;
	cin >> s;
	rep(i, 4) v[i] = s[i] - '0';
	rep(i, 3) {
		ans += s[i];
		ans += ' ';
	}
	ans += s[3];

	int b = v[0];
	rep(c, 1 << 3) {
		int sum = v[0];
		for (int i = 1, j = 1; j < 4; i *= 2, j++) {
			if (i & c) {
				sum += v[j];
				ans[j * 2 - 1] = '+';
			} else {
				sum -= v[j];
				ans[j * 2 - 1] = '-';
			}
		}
		if (sum == 7)
			break;
	}

	cout << ans << "=7" NL;

	return 0;

}



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

#define INF 1234567890
#define ll long long

struct Node {
	int x, y, i;
	bool operator<(Node &n)
	{
		return x < n.x;
	}
};

int N;
int X[200201], Y[200201];
int p[200201], sz[200201];

int Find(int n)
{
	if (n == p[n]) return n;
	return p[n] = Find(p[n]);
}

void Union(int a, int b)
{
	a = Find(a); b = Find(b);
	if (a == b) return;
	p[a] = b;
	sz[b] += sz[a];
}

// int fen[200201];

// int Sum(int idx)
// {
// 	int ret = 0;
// 	while(idx)
// 	{
// 		ret += fen[idx];
// 		idx &= idx-1;
// 	}
// 	return ret;
// }

// void Add(int idx, int val)
// {
// 	while(idx <= 200000)
// 	{
// 		fen[idx] += val;
// 		idx += idx & -idx;
// 	}
// }

int main()
{
	for(int i=0; i<200201; i++)
		p[i] = i, sz[i] = 1;
	scanf("%d", &N);
	vector<Node> v;
	for(int i=1; i<=N; i++)
	{
		scanf("%d %d", &X[i], &Y[i]);
		v.push_back({X[i], Y[i], i});
	}
	sort(v.begin(), v.end());

	vector<pair<int, int> > st;
	for(int i=0; i<v.size(); i++)
	{
		int x = v[i].x, y = v[i].y, idx = v[i].i;
		int mn = y;
		while(!st.empty() && st.back().first < y)
			mn = min(mn, st.back().first), Union(st.back().second, idx), st.pop_back();
		st.push_back({mn, idx});
	}
	st.clear();

	reverse(v.begin(), v.end());
	for(int i=0; i<v.size(); i++)
	{
		int x = v[i].x, y = v[i].y, idx = v[i].i;
		int mx = y;
		while(!st.empty() && st.back().first > y)
			mx = max(mx, st.back().first), Union(st.back().second, idx), st.pop_back();
		st.push_back({mx, idx});
	}

	for(int i=1; i<=N; i++)
		printf("%d\n", sz[Find(i)]);
	return 0;
}

Measured memory_bytes: 9212
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 0; i < n; i++) {
            int a = sc.nextInt();
            while(a%2 == 0) {
                ans++;
                a /= 2;
            }
        }
        System.out.println(ans);
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/16  Problem: ABC 075 C / Link: http://abc075.contest.atcoder.jp/tasks/abc075_c  ----- */
struct UnionFind {
	vector<int> data;
	UnionFind(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};
struct Lowlink {
	UnionFind uf;
	vector<int> low, ord, used, parent;
	int root, k;
	Lowlink(int V, int Root) :uf(V), low(V), ord(V), used(V), parent(V), root(Root), k(0) {}

	void lowlink(int v, int p, int &k, vector<vector<int>>& G) {
		used[v] = true; //visited
		low[v] = ord[v] = k; k++;
		for (int i = 0; i < (int)G[v].size(); i++) {
			int u = G[v][i];
			if (used[u] == 0) {
				parent[u] = v;
				lowlink(u, v, k, G);
				low[v] = min(low[v], low[u]);
				if (ord[v] >= low[u])uf.unionSet(v, u);
			}
			else if (u != p) {
				low[v] = min(low[v], ord[u]);
			}
		}
	}
};
struct Artivcal_points : Lowlink {
	vector<pair<int, int> > edges;
	Artivcal_points(int V, int Root) :Lowlink(V, Root) {}

	void get_bridge(vector<int>& points, vector<pair<int, int> >& bridges, vector<vector<int> >& G) {
		Lowlink::lowlink(root, -1, k, G);
		{
			for (int v = 0; v < (int)G.size(); v++) {
				for (int i = 0; i < (int)G[v].size(); i++) {
					int u = G[v][i];
					if (ord[v] < low[u]) {
						if (u > v)
							bridges.push_back(pair<int, int>(v, u));
						else bridges.push_back(pair<int, int>(u, v));
					}
				}
			}
			sort(bridges.begin(), bridges.end());
			bridges.erase(unique(bridges.begin(), bridges.end()), bridges.end());
		}
	}
};


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

	LL N, M; cin >> N >> M;
	VI p;
	vector<PII> br;
	VVI G(N);
	FOR(i, 0, M) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	Artivcal_points a(N, 0);
	a.get_bridge(p, br, G);

	LL ans = SZ(br);


	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
L = input()
mod = 10**9 + 7

x = len(L)
L = int(L, 2)
sure = 1
possible = 2
for i in range(2, x+1):
    if (L >> (x-i)) & 1:
        sure = (sure * 3 + possible) % mod
        possible = possible * 2 % mod

    else:
        sure = sure * 3 % mod
        
ans = (sure + possible) % mod
print(ans)

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

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

    int h, w;
    cin >> h >> w;
    int cnt = 0;
    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] == '#')
                cnt++;
        }
    }
    if (cnt == h + w - 1)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
}

Measured memory_bytes: 256