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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];


bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,m;
    cin >> n >> m;
    ll arr[n+5] = {0};
    ll freq[n+5] = {0};
    for(ll i = 1; i<=n; i++)
    {
        cin >> arr[i];
    }
    ll c = 0,a,b;
    ll ans[n+5] = {0};
    for(ll i = 1; i<=m; i++)
    {
        cin >> a;
        cin >> b;
        freq[a] ++;
        freq[b] ++;
        if (arr[a]>arr[b])
        {
            ans[a]++;
        }
        else if(arr[b] > arr[a])
        {
            ans[b]++;
        }
    }
    // for(ll i = 1; i<=n; i++)
    // {
    //     cout << freq[i] << " ";
    // }
    // cout << endl;
    // cout << endl;
    // for(ll i = 1; i<=n; i++)
    // {
    //     cout << ans[i] << " ";
    // }
    // cout << endl;
    for(ll i = 1; i<=n; i++)
    {
        if((freq[i] == ans[i] && ans[i]!=0 && freq[i]!=0) || freq[i]==0)
        {
            ++ c;
        }
    }
    cout << c << endl;
    return 0;
}   

Measured memory_bytes: 5984
def dfs(wants, remains):
    if len(wants) == 0:
        # return (0, [])
        return 0

    #min_cost = (float("inf"), [])
    min_cost = float("inf")
    if len(wants) < len(remains):  # 合成
        for i in range(1, len(remains)):
            # c, h = dfs(wants, [remains[0] + remains[i]] +
            #           remains[1:i] + remains[i+1:])
            #min_cost = min(min_cost, (10+c, ["合成:" + str(remains[0]) +","+str(remains[i])] + h))
            c = dfs(wants, [remains[0] + remains[i]] +
                    remains[1:i] + remains[i+1:])
            min_cost = min(min_cost, 10+c)

    for i in range(len(wants)):  # 延長・短縮
        #c, h = dfs(wants[:i] + wants[i+1:], remains[1:])
        # min_cost = min(min_cost,
        #               (abs(wants[i]-remains[0]) + c, ["増減:"+ str(remains[0])+"to"+ str(wants[i])]  +h))
        c = dfs(wants[:i] + wants[i+1:], remains[1:])
        min_cost = min(min_cost, abs(wants[i]-remains[0]) + c)

    if len(wants) < len(remains):
        #c, h = dfs(wants, remains[1:])
        #min_cost = min(min_cost, (c, ["無視:" + str(remains[0])] + h))
        c = dfs(wants, remains[1:])
        min_cost = min(min_cost, c)

    return min_cost


N, A, B, C = map(int, input().split())
ls = []
for _ in range(N):
    ls.append(int(input()))

wants = [A, B, C]
print(dfs(wants, ls))


Measured memory_bytes: 3064
def bfs(queue=[])
    res = 0
    visited = Array.new(H){Array.new(W, false)}
    while !queue.empty?
        h, w, cnt = queue.shift
        visited[h][w] = true
        [[0,1],[1,0],[0,-1],[-1,0]].each do |dh, dw|
            nh, nw = h+dh, w+dw
            next if nh < 0 || nh >= H || nw < 0 || nw >= W
            next if S[nh][nw] == "#"
            next if visited[nh][nw]
            visited[nh][nw] = true

            ncnt = cnt+1
            queue << [nh, nw, ncnt]
            res = ncnt if ncnt > res
        end
    end
    res
end

H,W = gets.split.map(&:to_i)
S = H.times.map{gets.chomp.chars}

ans = 0
H.times do |i|
    W.times do |j|
        next if S[i][j] == "#"
        t = bfs([[i,j,0]])
        ans = t if t > ans
    end
end
p ans


Measured memory_bytes: 2172
N = int(input())
A = [0] * N

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

cur = 0
ok = False
hist = set()

while True:
    if cur == 1:
        ok = True
        break

    if cur in hist:
        break
    else:
        hist.add(cur)
    
    cur = A[cur]

if ok:
    print(len(hist))
else:
    print(-1)

Measured memory_bytes: 18904
import math
n_test = 1

def solve():
    n = int(input())
    h = list(map(int, input().split()))

    res = [0 for _ in range(n)]
    res[0] = 0
    res[1] = abs(h[1] - h[0])

    for i in range(2, n):
        res[i] = min(res[i - 2] + abs(h[i] - h[i - 2]), 
                     res[i - 1] + abs(h[i] - h[i - 1]))

    return res[n - 1]



for _ in range(n_test):
    print(solve())

Measured memory_bytes: 14480
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;

int main(void)
{
	int S;
	cin >> S;
	int lower = S % 100;
	int upper = S / 100;
	bool yymm = (lower >= 1 && lower <= 12);
	bool mmyy = (upper >= 1 && upper <= 12);

	if (yymm&&mmyy)cout << "AMBIGUOUS" << endl;
	else if (yymm)cout << "YYMM" << endl;
	else if (mmyy)cout << "MMYY" << endl;
	else cout << "NA" << endl;

	return 0;
}

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

using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
i64 mod_pow(i64 a, i64 n, T mod) {
  mod = (i64)mod;
  i64 res = 1, p = a % mod;
  while (n) {
    if (n & 1) res = res * p % mod;
    p = p * p % mod;
    n >>= 1;
  }
  return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
  cout << sizeof...(rest) << endl;
  std::cout << first;
  if (sizeof...(rest)) std::cout << " ";
  print(rest...);
}
template <typename... A>
void print(const A&... rest) {
  print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
  std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
  std::cout << std::endl;
}
int current[1010];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n][n];
  rep(i, n) {
    rep(j, n - 1) {
      int aij;
      cin >> aij;
      a[i][j] = aij - 1;
    }
  }

  int day = 0;
  while (true) {
    bool nopair = true;
    bool used[n]{false};
    rep(i, n) {
      if (current[i] == n - 1) continue;
      // if (!used[i]) {
      // if (a[i].empty()) continue;
      int j = a[i][current[i]];
      if (used[i] || used[j]) continue;
      // if (a[j].empty()) continue;
      if (a[j][current[j]] == i && !used[j]) {
        ++current[i];
        ++current[j];
        used[i] = true;
        used[j] = true;
        nopair = false;
      }
      // }
    }
    if (nopair) {
      cout << -1 << endl;
      return 0;
    }

    ++day;
    bool finish = true;
    rep(i, n) {
      if (current[i] != n - 1) {
        finish = false;
        break;
      }
    }
    if (finish) {
      cout << day << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 4224
t = [0] * 101
while 1:
    p, s = map(int, input().split(','))
    if p == s == 0:
        break
    t[p] = s

rank = list(set(t))
rank.sort(reverse=True)

while 1:
    try:
        n = int(input())
        print(rank.index(t[n])+1)
    except:
        break



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

typedef long long ll;
ll n;

bool check(ll x) {
	ll t = n;
	while(t % x == 0) t /= x;
	t %= x;
	if(t == 1) return 1;
	return 0;
}

int main()
{
	scanf("%lld", &n);
	if(n == 2) puts("1");
	else {
		ll res = 2, t = n - 1; 
		for(ll i = 2; i * i <= t; i++) {
			if(t % i == 0) {
				res++;
				if(i * i != t) res++;
			} 
		}
		
		for(ll i = 2; i * i <= n; i++) {
			if(n % i == 0) {
				res += check(i);
				if(i * i != n) res += check(n / i);
			}
		}
		
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<string> d(k);
    for(int i = 0; i < k; i++){
        cin >> d[i];
        //cout << d[i] << endl;
    }

    while(true){
        bool flag = true;
        string tmp = to_string(n);
        for(int i = 0; i < k; i++){
            string::size_type pos = tmp.find(d[i]);
            if(pos >= 0 && pos <= 10000){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << n << endl;
            return 0;
        }
        n++;
    }

    return 0;
}

/*#include<iostream>
#include<string>
using namespace std;

int main(){
    string str1 = "abcdefgz";
    string str2 = "z";

    cout << str1.find(str2) << endl;
}*/

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int n;
	cin>>n;
	map<string,int> mp;
	ll ans = 0;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		ans += mp[s];
		mp[s]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef vector<int64_t> vi;
typedef vector<vector<int64_t>> vvi;

int main(){
    int k; string s; cin >> k >> s;
    if((int)s.size() <= k){
        cout << s << endl;
        return 0;
    }
    else{
        cout << s.substr(0,k) << "..." << endl;
    }
}

Measured memory_bytes: 3600
import collections
def main():
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]

    ones = collections.defaultdict(int)
    max_i = 0
    for a in A:
        i = 0
        while a:
            ones[i] += a % 2
            max_i = max(max_i, i)
            a = a // 2
            i += 1

    if K > max(A):
        i = 0
        M = K
        while M:
            if i > max_i:
                ones[i] = 0
            M = M // 2
            i += 1

    gain = collections.defaultdict(dict)
    for i in ones:
        gain[i][0] = ones[i]*pow(2, i) # when i-th digit is set to 0
        gain[i][1] = (N-ones[i])*pow(2, i) # when i-th digit is set to 1

    # print(gain)
    b = format(K+1, "b")
    # print(b)
    best = 0
    for i in range(len(b)):
        if b[i] == "1":
            s = b[:i] + "0"
            for j in range(i+1,len(b)):
                k = len(b)-1-j
                # print(gain[k])
                if gain[k][0] >= gain[k][1]:
                    s += "0"
                else:
                    s += "1"
                # print(s)
            f = 0
            v = int(s, 2)
            for a in A:
                f += a^v
            # print(s, v, f)
            best = max(best, f)

    return best


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 15004
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
 
int main() {
  ll a,b,c,d,e;
  ci(a>>b>>c>>d>>e);
  ll a1=a%10
    ,b1=b%10
    ,c1=c%10
    ,d1=d%10
    ,e1=e%10;
  vector<ll> h={a1,b1,c1,d1,e1};
  sort(h,h);
  ll ans=(a/10+b/10+c/10+d/10+e/10)*10;
    for(i,0,5){
    if(ans%10==0)
      ans+=h[i];
    else
      ans+=(h[i]/10+1)*10;
  }
  co(ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }
 
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }
 
template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}
 
struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};
 
ll b[128000];
ll sb[128000];
 
void solve(ll N, vector<ll> A, vector<ll> B, vector<ll> C) {
  sort(ALL(A));
  sort(ALL(B));
  sort(ALL(C));
  REP(i,N) b[i] = lower_bound(ALL(A), B[i]) - begin(A);
  REP(i,N) sb[i+1] = b[i] + sb[i];
  ll res = 0;
  REP(i,N) res += sb[lower_bound(ALL(B), C[i]) - begin(B)];
  cout << res << endl;
}
 
int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> C(N-1+1);
	vector<ll> A(N-1+1);
	vector<ll> B(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &A[i]);
	}
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &B[i]);
	}
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &C[i]);
	}
	solve(N, A, B, C);
	return 0;
}

Measured memory_bytes: 6528
// #define DEBUG_MODE
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("[%s = %s]\n", #x, to_string(x).data())

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	char s[20];
	int a;
	scanf("%d%s", &a, s);
	if (a < 3200) printf("red\n");
	else printf("%s\n", s);
}

Measured memory_bytes: 128
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Map as MP
import Data.Char

type Probs = MP.Map Int Int

step mp k = MP.insertWith (+) k 1 mp

solve :: Probs -> Probs -> String
solve mpd mpt
  | MP.null mpt = "YES"
  | otherwise = 
    case MP.lookup kt mpd of
      Just vd ->
        case compare vt vd of
          LT -> solve mpd mpt'
          EQ -> solve mpd mpt'
          _ -> "NO"
      Nothing -> "NO"
  where
    ((kt,vt),mpt') = MP.deleteFindMin mpt

main = do
  n <- readLn :: IO Int
  ds <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  m <- readLn :: IO Int
  ts <- VU.unfoldrN m (B.readInt . B.dropWhile isSpace) <$> B.getLine
  let mpd = VU.foldl' step MP.empty ds
  let mpt = VU.foldl' step MP.empty ts
  putStrLn $ solve mpd mpt

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

bool sosuu(long long x){
  
  long long i;
  
  for(i = 2; i * i < x; i++){
  
    if (x % i == 0) return true; 
  }
  return false;
}

int main(){
  
  long long X;
  cin >> X;
  
  bool hantei = true;
  
  while(hantei){
    
    hantei = sosuu(X);
    X++;
  }
  
  cout << X - 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#%%
N = int(input())

import time
st = time.time()
flag = False
for h in range(1, 3501):
    if flag:
        break
    for n in range(h, 3501):
        if (4*h*n - n*N - h*N) > 0 and (N*h*n) % (4*h*n - n*N - h*N) == 0:
            print(h, n, (N*h*n) // (4*h*n - n*N - h*N))
            flag = True
            break

#print(h, n, (N*h*n) % (4*h*n - n*N - h*N))
#print(time.time()-st)


#%%

#%%


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long A, long long B, long long C, long long D) {
  bool f1[110] = {};
  bool f2[110] = {};
  FOR(i, A, B) { f1[i] = true; };
  FOR(i, C, D) { f2[i] = true; };
  int ans = 0;
  REP(i, 110) { ans += f1[i] && f2[i]; }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long D;
  long long C;
  long long A;
  long long B;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  solve(A, B, C, D);
  return 0;
}


Measured memory_bytes: 256
S = input() # 文字列を変数に格納

import math

N = len(S)
before = 'R'
List = []
count_R = 1
count_L = 0

for i in range(1,N):
    if before == 'R' and S[i] == 'R':
        count_R += 1

    elif before == 'L' and S[i] == 'L':
        count_L += 1
        
    elif before == 'R' and S[i] == 'L':
        count_L += 1
        before = 'L'
                       
    elif before == 'L' and S[i] == 'R':
        for j in range(count_R-1):
            List.append(0)

        R = math.ceil(count_R / 2) + math.floor(count_L / 2)
        L = math.floor(count_R / 2) + math.ceil(count_L / 2)
        List.append(R)
        List.append(L)
        
        for k in range(count_L-1):
            List.append(0)
            
        count_R = 1
        count_L = 0
        before = 'R'

    if i == (N-1):
        for j in range(count_R-1):
            List.append(0)
        R = math.ceil(count_R / 2) + math.floor(count_L / 2)
        L = math.floor(count_R / 2) + math.ceil(count_L / 2)
        List.append(R)
        List.append(L)       
        for k in range(count_L-1):
            List.append(0)
                
print(*List)   

Measured memory_bytes: 6408
# 入力を格納
C = [list(map(int, input().split())) for _ in range(3)]

# a, bをリストとして準備
a = [0] * 3
b = [0] * 3

# a1=0ならば、b1, b2, b3はC[0]に該当
b[0], b[1], b[2] = C[0][0], C[0][1], C[0][2]

# Cとbの値からa1, a2, a3の値を求める
a[0], a[1], a[2] = 0, C[1][0] - b[0], C[2][0] - b[0]

# Cとai+biを比較し、いずれかのケースで一致いない場合は出力を”No"とする
ans = "Yes"
for i in range(3):
    for j in range(3):
        if C[i][j] == (a[i] + b[j]):
            pass
        else:
            ans = "No"
            break

print(ans)



Measured memory_bytes: 3064
N,A,B = map(int,input().split())
count = 0
for i in range (1,N+1):
	if i == 10000:
		e = 1
		if e>=A and e<=B:
			count += i
	else:
		a=i//1000
		b=(i%1000)//100
		c=(i-a*1000-b*100)//10
		d=i%10
		#print(a,b,c,d)
		e = a+b+c+d
		if e>=A and e<=B:
			count += i
print(count)

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut memo = vec![0; n];
    let mut next = 0;
    let mut ans = 0;
    loop {
        next = a[next] - 1;
        if memo[next] == 1 {
            ans = -1;
            break;
        } else {
            ans += 1;
            if next == 1 { break; }
            memo[next] = 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3808
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 1009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
ll soma(ll a,ll b){
    if(a+b>MOD)return a+b-MOD;
    else return a+b;
}
ll dp[maxn][maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    char mat[n+2][m+2];
    rep(i,0,n){
        rep(j,0,m){
            cin>>mat[i][j];
        }
    }
    memset(dp,0,sizeof dp);
    dp[0][0]=1;
    rep(i,0,n){
        rep(j,0,m){
            if((i==j && i==0) || (mat[i][j]=='#'))continue;
            if(i>0 && mat[i-1][j]=='.')dp[i][j]=soma(dp[i][j],dp[i-1][j]);
            if(j>0 && mat[i][j-1]=='.')dp[i][j]=soma(dp[i][j],dp[i][j-1]);
        }
    }
    cout<<dp[n-1][m-1]<<'\n';
    return 0;   
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n; cin >> n;
  vector<lint> a(n); for(lint i=0;i<n;i++) { cin >> a[i]; }

  lint sum=0;
  vector<lint> b(n);
  b[0] = a[0];
  for(lint i=1;i<n;i++) { b[i] = max(b[i-1],a[i]); }

  for(lint i=0;i<n;i++) { sum += b[i]-a[i]; }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 6356
/*
    Problem 86
    https://atcoder.jp/contests/abc075/tasks/abc075_c
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* class */
class DisjointSet {
public:
    vector<int> d;
    DisjointSet (int size) {d.assign(size, -1);}
    int find(int x) { return (d[x] < 0) ? x : d[x] = find(d[x]); }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
};
/* global variables */
int cnt = 0;
int N, M;
vector<int> usedV, ord, lowLink;
vector<vector<int> > G, usedE;
/* function */
void dfs(int from) {
    usedV[from] = 1;
    ord[from] = lowLink[from] = cnt++;

    for (int to : G[from]) {
        if (!usedV[to]) {
            // nodeが使われていないならdfs
            usedE[from][to] = 1;
            dfs(to);
            // dfsが戻ってきたらlowlinkの更新
            lowLink[from] = min(lowLink[from], lowLink[to]);
        }
        // 辺が使われていなくて
        else if (!usedE[to][from]) {
            // 使われている頂点を訪れようとした場合
            // lowlinkの更新
            lowLink[from] = min(lowLink[from], ord[to]);
        }
    }
    return ;
}
int bridge(vector<pii> edges) {
    int ret = 0;
    int from, to;
    for (pii edge : edges) {
        from = edge.first, to = edge.second;
        if (ord[from] < lowLink[to]) ret++;
        if (ord[to] < lowLink[from]) ret++;
    }
    return ret;
}
void solve1() {
    cin >> N >> M;
    int u, v;
    vector<pii> edges;
    usedV.resize(MAX);
    ord.resize(MAX);
    lowLink.resize(MAX);
    G.resize(MAX, vector<int>(MAX));
    usedE.resize(MAX, vector<int>(MAX));
    for (int i = 0; i < M; i++) {
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
        edges.push_back(pii(u, v));
    }
    dfs(0);
    int ans = bridge(edges);
    cout << ans << '\n';
}
void solve2() {
    cin >> N >> M;
    vector<pii> p(M);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        p[i] = pii(x, y);
    }
    int ans = 0;
    for (pii exclusion : p) {
        DisjointSet ds = DisjointSet(N);
        for (pii edge : p) {
            if (edge == exclusion) continue;
            ds.unite(edge.first, edge.second);
        }
        if (ds.size(0) != N) ans++;
    }
    cout << ans << '\n';
}
/* main */
int main(){
    // solve1();
    solve2();
}

Measured memory_bytes: 3600
def atcoder(s):

    ans = 0
    count = 0
    acgt = ["A", "C", "G", "T"]

    for i in s:
        if i in acgt:
            count += 1
        else:
            count = 0
        ans = max(ans, count)
    return ans

def main():
    s = list(str(input()))
    print(atcoder(s))

if __name__ == '__main__':
    main()

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

int main() {
  
  int n,m;
  
  cin >> n >> m;
  
    vector<int> vec(n);
  
  int sum =0;
  
  for(int i=0; i<n ; i++){
    
    cin >> vec.at(i);
    
    sum += vec.at(i);
  }
  
    sort(vec.begin(), vec.end()); // {1, 2, 2, 5}
  reverse(vec.begin(), vec.end()); // {5, 2, 2, 1}
  if(vec.at(m-1)<(sum+4*m-1)/(4*m))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 50 + 5, maxm = 52 * 52 * 52 + 100;
int A, B, C, N, S, T, tot, cnt, head[maxm], id[maxn][maxn][maxn], q[maxm*5], dis[maxm];
struct Edge { int last, to; }e[maxm*10]; bool used[maxm];

void build(int from, int to)
{
	e[++cnt] = (Edge) {head[from], to};
	head[from] = cnt;
}

void SPFA()
{
	int h = 0, t = 1;
	memset(dis, 11, sizeof(dis));
	dis[S] = 0, used[S] = true, q[1] = S;
	while(h != t)
	{
		int u = q[h=h%maxm+1];
		for(int i = head[u]; i ; i = e[i].last)
		{
			int v = e[i].to;
			if(dis[v] > dis[u]+1)
			{
				dis[v] = dis[u] + 1;
				if(!used[v]) q[t=t%maxm+1] = v, used[v] = true;
			}
		}
		used[u] = false;
	}
}

void Init()
{
	scanf("%d%d%d", &A, &B, &C);
	N = max(A, max(B, C)) + 1;
	for(int i = 0; i <= N; ++i)
		for(int j = 0; j <= N; ++j)
			for(int k = 0; k <= N; ++k)
				id[i][j][k] = ++tot;
	S = id[A][B][C], T = ++tot;
}

void Solve()
{
	for(int i = 0; i <= N; ++i)
		for(int j = 0; j <= N; ++j)
			for(int k = 0; k <= N; ++k)
			{
				if(i+1 <= N)
				{
					if(j+1 <= N) build(id[i][j][k], id[i+1][j+1][k]);
					if(k+1 <= N) build(id[i][j][k], id[i+1][j][k+1]);
				}
				if(j+1<=N && k+1<=N) build(id[i][j][k], id[i][j+1][k+1]);
				if(i+2 <= N) build(id[i][j][k], id[i+2][j][k]);
				if(j+2 <= N) build(id[i][j][k], id[i][j+2][k]);
				if(k+2 <= N) build(id[i][j][k], id[i][j][k+2]);
			}
	for(int i = 0; i <= N; ++i) build(id[i][i][i], T);
	SPFA(), printf("%d\n", dis[T]-1);
}

int main()
{
	Init(), Solve();
}

Measured memory_bytes: 11776
// Problem : E - Handshake
// Contest : AtCoder Beginner Contest 149
// URL : https://atcoder.jp/contests/abc149/tasks/abc149_e
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<int> a;
int n; ll m;
bool check (int mid) {
	int j = n; ll ret = 0;
	for (int i = 1; i <= n; i++) {
		while (j>=1&&a[i]+a[j]>=mid)
			j--;
		ret += n-j;
	}
	return ret >= m;
}
int main () {
	scanf ("%d %lld",&n,&m);
	a.resize(n+1);
	for (int i = 1; i <= n; i++) scanf ("%d",&a[i]);
	sort(a.begin()+1,a.end());
	int low = a[0]<<1, high = a[n]<<1|1, mid, ans=-1;
	while (low <= high) {
		mid = (low+high)>>1;
		if (check(mid)) low = mid+1, ans = mid;
		else high = mid-1;
	}
	assert(ans != -1);
	vector<ll> psa(n+1);
	for (int i = 1; i <= n; i++) psa[i] = psa[i-1] + a[i];
	ll ret = 0; int j = n; ll cnt = 0; int worst = INT_MAX;
	for (int i = 1; i <= n; i++) {
		while (j>=1&&a[i]+a[j]>=ans)
			j--;
		if (j < n) worst = min(worst,a[i]+a[j+1]);
		ret += psa[n]-psa[j]+a[i]*ll(n-j);
		cnt += n-j;
	}
	assert(worst == ans);
	printf ("%lld\n",ret-ans*(cnt-m));
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);



int main(){
    ll h,w;
    cin>>h>>w;
    ll even;
    ll odd;
    ll odd2;
    if(h==1||w==1) cout<<1<<endl;
    else if(h%2==0||w%2==0){
        if(h%2==0){even=h/2; odd=w;}
        else{ even=w/2; odd=h;}
        ll ans=(ll)even*odd;
        cout<<ans<<endl;
    }
    else{
        odd=w;
        odd2=h;
        ll ans=(ll)(odd/2+1)*(odd2/2+1)+(ll)(odd/2)*(odd2/2);
        cout<<ans<<endl;

    }

    
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[1]:


n,a,b = map(int, input().split())


# In[2]:


def nCk(n, k, mod):
    a = 1
    for i in range(n, n-k, -1):
        a *= i
        a %= mod
    b = 1
    for i in range(1, k+1):
        b *= i
        b %= mod
    a *= pow(b, mod-2, mod)
    return a


# In[3]:


mod = 10**9+7
ans = pow(2, n, mod)-1
ans -= nCk(n, a, mod) + nCk(n, b, mod)
print(ans%mod)


# In[ ]:






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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int r;
    cin >> r;
    
    cout << fixed << setprecision(12) << 2 * acos(-1.0) * r << '\n';
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string x,y;
    cin>>x>>y;
    int m=x.length(),n=y.length(),i,j,c=0;
    int dp[m+1][n+1];
    for(i=0;i<=m;i++)
    {
        dp[i][0]=0;
    }
    for(i=0;i<=n;i++)
    dp[0][i]=0;
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(x[i-1]==y[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
        
    }
    i=m,j=n;
    string w="";
    while(dp[i][j]>0)
    {
        if(x[i-1]==y[j-1])
        {
            w.push_back(x[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>=dp[i][j-1])
        i--;
        else if(dp[i-1][j]<dp[i][j-1])
        j--;
        
    }
    m=w.length();
    if(m!=0)
    {
        for(i=m-1;i>=0;i--)
        cout<<w[i];
    }
    else
    cout<<" ";
}

Measured memory_bytes: 35456
import math
import itertools
n=int(input())

a=list(map(str,input().split()))
b=list(map(str,input().split()))

p=str(math.factorial(n))

a_list = [''.join(v) for v in itertools.permutations(a)]
a_int = [int(i) for i in a_list]
a_int.sort()

a_=[int(i) for i in a]
b_=[int(j) for j in b]
x="".join(a)
y="".join(b)

p_=a_int.index(int(x))+1
q_=a_int.index(int(y))+1

sum=abs(p_-q_)
print(sum)


Measured memory_bytes: 7788
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
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

struct BIT {
  int n;
  vector<int> xs;
  BIT (int n) : n(n) {
    xs.resize(n+1);
  }
  void add(int i, int v) {
    for (int x=i+1; x<=n; x+=x&-x) xs[x] += v;
  }
  int sum(int i) {
    int s = 0;
    for (int x=i+1; x>0; x-=x&-x) s += xs[x];
    return s;
  }
  int sum(int a, int b) {
    return sum(b) - sum(a-1);
  }
};


int N, K;
int A[200000];
long long S[200001];
vector<long long> xs;

int pos(long long x) {
  return lower_bound(all(xs), x) - xs.begin();
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> K;
  rep(i, N) {
    cin >> A[i];
    A[i] -= K;
  }
  rep(i, N) {
    S[i+1] = S[i] + A[i];
  }
  rep(i, N+1) xs.pb(S[i]);
  sort(all(xs));
  uniq(xs);
  BIT bit(xs.size());
  long long c = 0;
  for (int y=0; y<=N; y++) {
    int p = pos(S[y]);
    c += bit.sum(p);
    bit.add(p, 1);
  }
  cout << c << "\n";
  return 0;
}


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

using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
#define int long long

signed main(){

	int count=0;

	int n;
	cin>>n;

	int a[n+1]={0};

	for(int i=1;i<=n;i++){
		cin>>a[i];
	}

	for(int i=1;i<n;i++){
		if(a[i]==i){
			swap(a[i],a[i+1]);
			count++;
		}
	}

	if(a[n]==n){
		count++;
	}

	cout<<count<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n-1; i >= 0; --i)
#define s_rep(i, s, e) for (ll i = s; i < e; ++i)
#define sr_rep(i, s, e) for (ll i = e-1; i >= s; --i)

const ll LL_INF = 1LL<<60;

template <class T> inline void chmin(T& a, T b) {if (a > b) {a = b;}}
template <class T> inline void chmax(T& a, T b) {if (a < b) {a = b;}}

using namespace std;

int main() {
    ll N;
    cin >> N;

    vector<ll> a(N);
    vector<ll> b(N);
    rep(i, N) cin >> a[i] >> b[i];

    rep(i, N) {
        rep(j, i) {
            if (b[j] > b[i]) {
                ll tmp_a = a[j], tmp_b = b[j];
                a[j] = a[i];
                b[j] = b[i];
                a[i] = tmp_a;
                b[i] = tmp_b;
            }
        }
    }

    vector<ll> dp(N+1, LL_INF);

    dp[0] = 0;

    ll ret = 0;

    rep(i, N) {
        if (a[i] > b[i]) continue;
        rrep(j, i+1) {
            if (dp[j] == LL_INF || dp[j] + a[i] > b[i]) continue;
            chmin(dp[j+1], dp[j] + a[i]);
            chmax(ret, j+1);
        }
    }
    cout << ret << endl;
}



Measured memory_bytes: 3100
//In the name of Allah
//In the name of the compassionate of the merciful
//Ya Ali!
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename Type>
using ordered_multiset = tree<Type, null_type, less_equal<Type>, rb_tree_tag, tree_order_statistics_node_update> ;

typedef long long ll ;
typedef long double ld ;

const ll maxn = 410 ;
const ll INF = 3e18 ;

#define f first
#define s second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define endll "\n"
#define sortt(v) sort(v.begin() , v.end())
#define reversee(v) reverse(v.begin() , v.end())

// for sqrt on interval and array , always sq = maxn/80 ;
// cout << *ss.find_by_order(index) ; -> return the value that indexed in index position
// cout << ss.order_of_key(value) ; -> lower_bound in ordered_set
//ifstream fin("input.txt");
//ofstream fout("output.txt");
// fflush(stdout);
ll mod = 1e9 + 7 , p1 = 999999929 , p2 = 999999937 ;

ll n , a[maxn] , dp[maxn][maxn] , per[maxn] ;

ll sum(ll l , ll r){
 return per[r]-per[l-1] ;
}

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

cin >> n ;
for(int i = 1 ; i <= n ; i ++)cin >> a[i] ;

per[0] = 0 ;
for(int i = 1 ; i <= n ; i ++)per[i] = per[i-1]+a[i] ;

for(int r = 2 ; r <= n ; r ++){
  for(int l = r-1 ; l > 0 ; l --){
     dp[l][r] = INF;
     for(int k = l ; k < r ; k ++){
       dp[l][r] = min(dp[l][r] , dp[l][k]+dp[k+1][r]+sum(l,r)) ;
     }
  }
}
cout << dp[1][n] ;

 return 0;
}
/*
                  _     _   __
            /_\  (_    (_)  __)
           /   \  _) . (_) (__
*/


Measured memory_bytes: 1536
import collections
n=int(input())
s=[input() for i in range(n)]

l=[i[0] for i in s if i[0]=="M" or i[0]=="A" or i[0]=="R" or i[0]=="C" or i[0]=="H"]
c=collections.Counter(l)
v=list(c.values())
vn=len(v)

if vn<3:print(0)
if vn==3:print(v[0]*v[1]*v[2])
if vn==4:print(v[0]*v[1]*v[2]+v[0]*v[1]*v[3]+v[0]*v[2]*v[3]+v[1]*v[2]*v[3])
if vn==5:print(v[0]*v[1]*v[2]+v[0]*v[1]*v[3]+v[0]*v[1]*v[4]+v[0]*v[2]*v[3]+v[0]*v[2]*v[4]+v[0]*v[3]*v[4]+v[1]*v[2]*v[3]+v[1]*v[2]*v[4]+v[1]*v[3]*v[4]+v[2]*v[3]*v[4])

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

int main()
{
    int M, F, B;
    cin >> M >> F >> B;
    if(M + F < B) {
        cout << "NA" << endl;
    } else {
        cout << max(0, B - M) << endl;
    }
    return (0);
}

Measured memory_bytes: 3056
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int digit(int N){
    int ans = 0;
    while(N){
        ans += N % 10;
        N /= 10;
    }
    return ans;
}

int main()
{
    int N;
    cin >> N;
    if (N % digit(N) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import math

n, k = list(map(int, input().split()))

mod = 10**9 +7

sn = (n*(n+1)*(n+2)/6 +n+1)% mod
sk = ((k-1)*k*(3*n-2*k+4)/6 +k-1)% mod

snk = math.floor((sn - sk)% mod)

print(snk)

Measured memory_bytes: 9188
//keep trying :)
#include <bits/stdc++.h>
#define float long double
#define int long long
#define ll long long
#define PB push_back
#define MP make_pair
#define ss second
#define ff first
#define PI 3.14159265
#define MXX 9*(1e18)
#define fastrack ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
void PT(int a);
void PT1(int a);
const int M = 3*(1e5) + 7, mod = 1e9 + 7;

signed main(){
    fastrack;
    //int tt; cin >> tt; while(tt--)
    {
        int x;
        cin >> x;
        string s;
        cin >> s;
        int y = (s[0] - '0') * pow(10, 2) + (s[2] - '0') * pow(10, 1) + (s[3] - '0') * pow(10, 0);
        //cout << y << "\n";
        cout << (x * y)/100 << "\n";
    }
    return 0;
}

void PT(int a){
    cout << a << "\n";
}

void PT1(int a){
    cout << a << " ";
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;


int main(){

  int h[2], k[2];
  int a, b, c, d;
  cin >> h[0] >> h[1] >> k[0] >> k[1] >> a >> b >> c >> d;

  int ans1 = a * h[0] + b * h[1] + (h[0] / 10) * c + (k[1] / 20) * d;
  int ans2 = a * k[0] + b * k[1] + (k[0] / 10) * c + (k[1] / 20) * d;

  if(ans1 > ans2){
    cout << "hiroshi\n";
  }else if(ans1 < ans2){
    cout << "kenjiro\n";
  }else{
    cout << "even\n";
  }
  return 0;
}




Measured memory_bytes: 3076
#include <climits>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

constexpr char kBlack = '#';
constexpr char kWhite = '.';

int main() {
  int N; std::cin >> N;
  std::string S; std::cin >> S;

  int start = 0, end = N - 1;
  for (; start < N; ++start) {
    if (S[start] == kBlack) break;
  }
  for (; end >= 0; --end) {
    if (S[end] == kWhite) break;
  }

  int b1 = 0, w1 = 0;
  for (int i = start; i <= end; ++i) {
    if (S[i] == kWhite) ++w1;
    else                ++b1;
  }

  int min_cnt = w1;
  int b2 = 0, w2 = 0;
  for (int i = start; i <= end; ++i) {
    if (S[i] == kWhite) {
      --w1; ++w2;
    } else {
      --b1; ++b2;
    }

    int cnt = b2 + w1;
    min_cnt = std::min(min_cnt, cnt);
  }

  std::cout << min_cnt << std::endl;
}


Measured memory_bytes: 640
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)*}
    };
}

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

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,
    }
    let mut max = 0;
    let mut d = 0;
    for i in 1..n + 1 {
        let mut s = i;
        let mut time = 1;
        while s % 2 == 0 && s != 0 {
            time+=1;
            s /= 2;
        }
        if max < time {
            max = time;
            d = i;
        }
    }
    println!("{}", d);
}

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

def ok(arg):
  cnt = 0
  for log in a:
    cnt += -(-log//arg)
    cnt -= 1
  return cnt<=k

st,en = 0,max(a)
mid = 0
while en-st>1:
  mid = (en+st)//2
  if ok(mid):
    en = mid
  else:
    st = mid

print(en)

Measured memory_bytes: 30832
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

mod = 10 ** 9 + 7

N = int(input())
vec = [[] for _ in range(N)]
for _ in range(N-1) :
  A, B = map(int, input().split())
  vec[A-1].append(B-1)
  vec[B-1].append(A-1)

sub_size = [[] for _ in range(N)]

def dfs(cur=0, pre=-1) :
  s = 0
  for nex in vec[cur] :
    if nex == pre :
      continue
    t = dfs(nex, cur)
    s += t
    sub_size[cur].append(t)
  if s != N - 1 :
    sub_size[cur].append(N - 1 - s)

  return s + 1

dfs()

power = [1]
for _ in range(N) :
  power.append(power[-1]*2%mod)

ret = 0
for i in range(N) :
  tmp = power[N-1]-1
  for ss in sub_size[i] :
    tmp -= power[ss]-1
  ret += tmp

ret = ret*pow(power[N], mod - 2, mod)% mod

print(ret)

Measured memory_bytes: 217404
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

string s;
int main(int argc,char* argv[]){
	cin>>s;
	ll sum=0,ans=0;
	for(int i=0;i<s.size();i++){
		sum+=(s[i]=='B');
		ans+=(s[i]=='W')*sum;
	}
	
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    a=(a+11)%13;
    b=(b+11)%13;
    if(a>b)
        cout<<"Alice";
    else if(a<b)
        cout<<"Bob";
    else
        cout<<"Draw";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    string s; cin >> s;
    int ans = 0, cur = 0;
    for(char i:s){
        if(i == 'A'||i=='C'||i=='G'||i=='T'){
            cur++;
            ans = max(ans, cur);
        }
        else cur = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 28;
const long long MOD = 1000000000 + 7;

int main()
{
	string s;
	cin >> s;
	char ans[20];
	int at=0;
	for(int i=0;i<s.size();i++){
		switch(s[i]){
			case '0':
			ans[at]='0';
			at++;
			break;
			case '1':
				ans[at] = '1';
				at++;
				break;
			case 'B':
				if(at!=0){
				ans[at-1] = '\0';
				at--;
				}
				break;
		}
	}
	ans[at]='\0';
	cout << ans << endl;
}


Measured memory_bytes: 256