akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, std::vector<long long> A){
  vl m1(N+1,-LINF),m2(N+1,-LINF);
  rep(i,N) m1[i+1] = max(m1[i],A[i]);
  RREP(i,N-1,0) m2[i] = max(m2[i+1],A[i]);
  dump(m1);
  dump(m2);

  rep(i,N){
    cout << max(m1[i],m2[i+1]) << endl;
  }
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 6272
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  LL N;
  cin >> N;

  vector<pii> v;

  FOR(i,1,N+1){
    FOR(j,i+1,N+1){
      if(i+j!=(N/2)*2+1){
        v.push_back(make_pair(i, j));
      }
    }
  }

  cout << v.size() << endl;
  REP(i,v.size()){
    cout << v[i].first << " " << v[i].second << endl;
  }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;cin >> a >> b >> c;
    cout << a*b/2 << endl;
}

Measured memory_bytes: 3652
#!/usr/bin/env python
from typing import List


def input_int() -> int:
    return int(input())


def input_list_int() -> List[int]:
    return list(map(lambda x: int(x), input().split()))


def f(n: int) -> int:
    ans = 0
    for a in range(1, n):
        ans += (n - 1) // a
    return ans


if __name__ == '__main__':
    n = input_int()
    print(f(n))

Measured memory_bytes: 10184
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <string>
#include <unordered_set>
#include <vector>

struct Tree {
  int value;
  size_t depth;
  size_t tree_size = 0;
  Tree *parent = nullptr;
  std::vector<Tree *> friends{};
  size_t blocked = 0;
  Tree(int a) {
    this->value = a;
    this->tree_size = 1;
    this->depth = 1;
  }
  Tree *GetRoot() {
    Tree *t;
    for (t = this; t->parent != nullptr; t = t->parent) {
    }
    return t;
  }
  void Merge(Tree *t) {
    if (this == t)
      return;

    Tree *p;
    Tree *c;
    if (this->depth > t->depth) {
      p = this;
      c = t;
    } else {
      p = t;
      c = this;
    }
    c->parent = p;
    p->tree_size += c->tree_size;
    p->depth = std::max(p->depth, c->depth + 1);
  }
};

int main() {
  int n, m, k;
  std::cin >> n >> m >> k;

  std::vector<Tree *> forest{};
  forest.reserve(n);
  for (int i = 0; i < n; i++) {
    auto t = new Tree(i + 1);
    forest.push_back(t);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    std::cin >> a >> b;
    Tree *ta = forest[a - 1];
    Tree *tb = forest[b - 1];
    ta->friends.push_back(tb);
    tb->friends.push_back(ta);

    Tree *ra = ta->GetRoot();
    Tree *rb = tb->GetRoot();
    if (ra != rb)
      ra->Merge(rb);
  }
  std::vector<Tree *> roots{};
  for (int i = 0; i < forest.size(); i++) {
    roots.push_back(forest[i]->GetRoot());
  }
  for (int i = 0; i < k; i++) {
    int c, d;
    std::cin >> c >> d;
    Tree *tc = forest[c - 1];
    Tree *td = forest[d - 1];
    if (roots[tc->value - 1] == roots[td->value - 1]) {
      tc->blocked += 1;
      td->blocked += 1;
    }
  }
  for (int i = 0; i < forest.size(); i++) {
    Tree *t = forest[i];
    Tree *root = roots[i];
    if (i > 0)
      std::cout << " ";
    std::cout << root->tree_size - t->friends.size() - t->blocked - 1;
  }
std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 14324
#include <stdio.h>
int main(){
   int N,K,P,i;
   scanf("%d",&N);
   for(i=1;i<=N;i++){
       scanf("%d%d",&K,&P);
       if(K%P==0){printf("%d\n",P);}
       else{printf("%d\n",K%P);}
           }
       return 0;
   }

Measured memory_bytes: 596
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var K = sc.nextInt();
        var Q = sc.nextInt();
        var A = sc.ArrayInt(Q);

        var p = new int[N];
        for (int i = 0; i < Q; i++) {
            p[A[i] - 1]++;
        }
        for (int i = 0; i < N; i++) {
            if (p[i] + K - Q > 0) {
                WriteLine("Yes");
            } else {
                WriteLine("No");
            }
        }
    }
    
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 15960
#include <stdio.h>

int main()
{
  int N,i,j,k,v;
  int A[100];

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

Measured memory_bytes: 604
/**
 *   author: sahushivam
 *   created: 18 August 2019 (Sunday)  17:20:00
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
        int n;
        cin>>n;
        vector<int> arr(n);
        for(int i=0;i<n;i++)
            cin>>arr[i];
        double ans=0;
        for(int i=0;i<n;i++)
        {
            double a=1.0/arr[i];
            ans+=a;
        }
        ans=1.0/ans;
        cout<<setprecision(6)<<ans;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long
#define ld long double

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	cout << (n / 1000 + (n%1000?1:0)) *1000-n;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000007
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};  // 4 Direction
// int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1};  // 8 Direction
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};  // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};  // Hexagonal Direction

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//unordered_map <ll, ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;

ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, flag=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL

    cin>>m>>d>>a>>b;
    if(d==30)
    {
        if(m==4 || m==6 || m==9|| m==11)
        {
            cnt=1;
        }
    }
    else if(d==31)
    {
        if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12)
        {
            cnt=1;
        }
    }
    else if(d==28 && m==2)
    {
        cnt=1;
    }
    if(cnt)
    {
        cout<<1<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  int a[3];
  int temp;
  int i,j,k;
  scanf("%d",&n);
  for(k=0;k<n;k++){
    for(i=0;i<3;i++){
      scanf("%d",&a[i]);
    }
    for(i=0;i<2;i++){
      for(j=0;j<2-i;j++){
	if(a[j]<a[j+1]){
	  temp=a[j];
	  a[j]=a[j+1];
	  a[j+1]=temp;
	}
      }
    }
    if(a[0]*a[0]==a[1]*a[1]+a[2]*a[2]){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!


void solve(){
    
    ll n,m,d;
    cin>>n>>m>>d;
    vll A(n),B(m);
    for(ll i=0;i<n;i++){cin>>A[i];}
    for(ll i=0;i<m;i++){cin>>B[i];}
    
    ll cost=*min_element(all(A)) + *min_element(all(B));
    for(ll i=0;i<d;i++){
        ll x,y;
        ll c;
        cin>>x>>y>>c;
        x--;y--;
        cost=min(cost,A[x]+B[y]-c);
    }
    cout<<cost<<endl;
    
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 4780
import fractions
import bisect
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N, M = map(int, input().split())
S = input()
T = input()
L = lcm(N,M)
S_arr = [0]*N
T_arr = [0]*M
for i in range(1,N):
    S_arr[i] = i*(L//N)
for i in range(1,M):
    T_arr[i] = i*(L//M)
if M <= N:
    for i in range(M):
        index = bisect.bisect_left(S_arr,T_arr[i])
        if S_arr[index] == T_arr[i] and S[index] != T[i]:
            print(-1)
            exit()
else:
    for i in range(N):
        index = bisect.bisect_left(T_arr,S_arr[i])
        if T_arr[index] == S_arr[i] and T[index] != S[i]:
            print(-1)
            exit()

print(L)

Measured memory_bytes: 69848
let ans, n, k, ws, h = Scanf.(scanf " %d %d %d %d %d" @@ fun n k r s p -> ref 0, n, k, Array.init n (fun _ -> scanf " %c" @@ function 'r' -> 'p' | 's' -> 'r' | _ -> 's'), function 'r' -> r | 's' -> s | _ -> p)
let g t u = List.(filter (fun x -> x <> t && x <> u) ['r'; 's'; 'p'] |> hd)
let _ = Array.iteri (fun i w -> if i - k >= 0 && ws.(i - k) = w then ws.(i) <- g w @@ if i + k < n then ws.(i + k) else w else ans := !ans + h w) ws; Printf.printf "%d\n" !ans

Measured memory_bytes: 5376
import sys
input =  sys.stdin.readline

n, k = map(int, input().split())
s = input()+'-1'

cnt = 0
cnt_list = []
for i in range(n):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        cnt_list.append(cnt+1)
        cnt = 0

# print(cnt_list)


l = 0
r = 2*k
ma = 0
su = 0
if s[0] == '0':
    r = 2*k
else:
    r = 2*k+1
su = sum(cnt_list[l:r])
while l < r:
    if ma < su:
        ma = su
    if l == 0 and r == 2*k:
        l += 1
        su -= cnt_list[l-1]
    else:
        l += 2
        su -= sum(cnt_list[l-2:l])
    r += 2
    su += sum(cnt_list[r-2:r])
    if r >= len(cnt_list):
        r = len(cnt_list)
    
print(ma)


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int n,m,X,Y;
  cin>>n>>m>>X>>Y;
  int x[n],y[m];
  rep(i,n)
    cin>>x[i];
  rep(i,m)
    cin>>y[i];
  bool flag=false;
  for(int i=X+1;i<=Y;i++){
    bool flag1=false,flag2=false;
    rep(j,n){
      if(x[j]>=i)
	break;
      if(j==n-1){
	flag1=true;
	//cout<<"Z=="<<i<<endl;
	//	cout<<"n-1=="<<n-1<<endl;
	//cout<<"j=="<<j<<endl;
      }}
    rep(k,m){
      if(y[k]<i)
	break;
      if(k==m-1){
	flag2=true;
	//cout<<k<<endl;
      }}
    if(flag1&&flag2)
      flag=true;
  }
  
  if(flag)
    cout<<"No War"<<endl;
  else
    cout<<"War"<<endl;
  
  


  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
words=[input().rstrip() for i in range(n)]
u=len(list(set(words)))
if u!=n:
    print("No")
    sys.exit()
for i in range(n-1):
    if words[i][-1]!=words[i+1][0]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3572
import io.StdIn._
import scala.collection.mutable

object Main extends App {
  val line1 = readLine.split(" ").map(_.toInt)
  val line2 = readLine.split(" ").map(_.toInt)
  val line3 = readLine.split(" ").map(_.toInt)

  val N = readInt
  val numbers = mutable.Set.empty[Int]
  for (i <- 0 until N) {
    numbers.add(readInt)
  }

  val patterns = mutable.Set.empty[(Int, Int, Int)]
  patterns.add((line1(0), line1(1), line1(2)))
  patterns.add((line2(0), line2(1), line2(2)))
  patterns.add((line3(0), line3(1), line3(2)))

  patterns.add((line1(0), line2(0), line3(0)))
  patterns.add((line1(1), line2(1), line3(1)))
  patterns.add((line1(2), line2(2), line3(2)))

  patterns.add((line1(0), line2(1), line3(2)))
  patterns.add((line1(2), line2(1), line3(0)))

  val ans = patterns.exists { case (a, b, c) =>
    numbers.contains(a) && numbers.contains(b) && numbers.contains(c)
  }

  println(if (ans) "Yes" else "No")
}


Measured memory_bytes: 27324
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int a=s[0]-'0';
    int b=s[1]-'0';
    int c=s[2]-'0';
    int d=s[3]-'0';
    if(a+b+c+d==7)
        cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
    else if(a+b+c-d==7)
        cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
    else if(a+b-c+d==7)
        cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
    else if(a+b-c-d==7)
        cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
    else if(a-b+c+d==7)
        cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
    else if(a-b+c-d==7)
        cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
    else if(a-b-c+d==7)
        cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
    else if(a-b-c-d==7)
        cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 12, 2020 15:02:31 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


import bisect
from sys import stdin
input = stdin.readline


def least(n, k):
  return bisect.bisect_left(list(map(lambda x: n*2**x, range(20))), k)


def main():
  N, K = list(map(int, input().split()))

  P = 0
  for i in range(1, N+1):
    if 0 < i < K:
      P += (1/N) * (0.5)**least(i, K)
    if K <= i:
      P += (1/N)

  print(P)


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


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    ll in[4],n,ans=0;
    REP(i,4) cin >> in[i];
    cin >> n;
    n*=4;
    PINT vp[4];
    REP(i,4) vp[i]={pow(2,3-i)*in[i],i};
    sort(vp,vp+4);
    REP(i,4){
        int q = n/pow(2,vp[i].s2);
        ans += q*in[vp[i].s2];
        n-=q*pow(2,vp[i].s2);
        if(n==0) break;
    }

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


Measured memory_bytes: 640
// ABC 172 B Minor Change

#include <bits/stdc++.h>
using namespace std;

int solve(string s, string t) {
  int count = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] != t[i]) count++;
  }
  return count;
}

int main() {
  string s;
  cin >> s;
  string t;
  cin >> t;
  cout << solve(s, t) << endl;
  return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define IOS                 ios::sync_with_stdio(false); cin.tie(nullptr)
#define deb(x)              cout << #x << " = " << x << endl
#define deb2(x, y)          cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)         for(i = a; i < n; i++)
#define f1(i, a, n)         for(i = a; i <= n; i++)
#define tc(t)               int t; cin >> t; while(t--)
#define ini(x, y)           memset(x, y, sizeof(x))
#define all(x)              x.begin(),x.end()
#define sz(x)               x.size()
#define ll                  long long int
#define vi                  vector<int>
#define si                  set<int>
#define pb                  emplace_back
#define ppb                 pop_back
#define mp                  make_pair
#define M                   1000000007
#define endl                '\n'
#define bits(x)             __builtin_popcountll(x)
#define zrbits(x)           __builtin_ctzll(x)

using namespace std;

void solve() {
        int n, m, i, ans = INT_MAX;
        string s, t;
        cin >> s >> t;
        n = sz(s);
        m = sz(t);
        if(m < n) {
                swap(s, t);
                swap(n, m);
        }

        for(int i = 0; i < m-n+1; i++) {
                int cnt = 0;
                for(int j = 0; j < n; j++) {
                        if(s[j] != t[i+j]) cnt++;
                }
                ans = min(ans, cnt);
        }
        cout << ans << endl;
}

int main () {
        IOS;
        // tc(t)
        solve();
        return 0;
}

Measured memory_bytes: 3648
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {in_n: usize, in_a: [i64; in_n], in_q: usize, in_bc: [[i64; 2]; in_q]};
    let mut counts = vec![0; 100001];
    let mut total = 0;

    for a in &in_a {
        counts[*a as usize] += 1;
        total += *a;
    }

    for bc in &in_bc {
        total -= bc[0] * counts[bc[0] as usize];
        total += bc[1] * counts[bc[0] as usize];
        counts[bc[1] as usize] += counts[bc[0] as usize];
        counts[bc[0] as usize] = 0;
        println!("{}", total);
    }
}


Measured memory_bytes: 10788
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int d;
	cin >> d;
	switch (d) {
	case 22:
		PRI("Christmas Eve Eve Eve");
		break;
	case 23:
		PRI("Christmas Eve Eve");
		break;
	case 24:
		PRI("Christmas Eve");
		break;
	case 25:
		PRI("Christmas");
		break;
	};
	return 0;
}

Measured memory_bytes: 3548
//Moh_K_Imar .......
//28/08/2020  ... 11,25.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    string a;
    cin>>a;
    if(a[0]==a[1]||a[2]==a[3]||a[1]==a[2])cout<<"Bad"<<endl;
    else cout<<"Good"<<endl;

    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int dp[100][50][2];

int solve(int w, int h){
  vector<vector<char>> vec(h,vector<char>(w));
  rep(i,h) rep(j,w) scanf(" %c", &vec[i][j]);

  fill(dp[0][0], dp[100][0], INF);
  // dp[h][w][r?l]

  queue<int> sx,sy,sz;

  rep(i,h) rep(j,w){
    if(vec[i][j]=='S'){
      sx.push(i); sy.push(j); sz.push(0);
      dp[i][j][0] = 0;
      sx.push(i); sy.push(j); sz.push(1);
      dp[i][j][1] = 0;
    }
    if(vec[i][j]=='T') vec[i][j]='0';
  }

  while(!sx.empty()){
    int x = sx.front(); sx.pop();
    int y = sy.front(); sy.pop();
    int z = sz.front(); sz.pop();
    const int dx[]={-2,-1,-1,0,0,0,1,1,2};
    const int dy[][9]={{1,1,2,1,2,3,1,2,1}, {-1,-1,-2,-1,-2,-3,-1,-2,-1}};
    rep(i,9){
      int nx = x+dx[i];
      int ny = y+dy[z][i];
      int nz = !z;
      if(nx<0 || nx>=h || ny<0 || ny>=w || vec[nx][ny]=='X') continue;
      int nd = dp[x][y][z] + vec[nx][ny] - '0';
      if(dp[nx][ny][nz]>nd){
        dp[nx][ny][nz] = nd;
        sx.push(nx); sy.push(ny); sz.push(nz);
      }
    }
  }

  int ret=INF;
  rep(i,h) rep(j,w) if(vec[i][j]=='0') rep(k,2) ret = min(ret, dp[i][j][k]);
  if(ret==INF) return -1;
  else return ret;
}

int main(){
  int w,h;
  while(cin>>w>>h, w|h){
    cout<<solve(w,h)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//UnionFind
//全て添字で扱うこと
struct union_find {
  vll parent;
  vll sizes;

  //初期化
  void init(ll n) {
    for (ll i = 0; i < n; i++) parent.push_back(i);
    for (ll i = 0; i < n; i++) sizes.push_back(1);
    return;
  }

  //頂点nの根
  ll root(ll n) {
    if (parent[n] == n) return n;
    return parent[n] = root(parent[n]);
  }

  //頂点nと間接的に繋がっている頂点の数(自身含む)
  ll size(ll n) {
    return sizes[root(n)];
  }

  //頂点a, bが間接的に繋がっているか判定
  bool is_united(ll a, ll b) {
    return (root(a) == root(b));
  }

  //頂点aを含むグラフに頂点bを含むグラフを結合
  void unite(ll a, ll b) {
    if (is_united(a, b)) return;
    sizes[root(a)] += size(b);
    parent[root(b)] = root(a);
    return;
  }
};

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

  union_find uf;
  uf.init(n);

  vll a(m), b(m), c(k), d(k);
  vector<vll> nx(n, vll(0));
  for (ll i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    uf.unite(a[i] - 1, b[i] - 1);
    nx[a[i] - 1].push_back(b[i] - 1);
    nx[b[i] - 1].push_back(a[i] - 1);
  }
  vll block(n, 0);
  for (ll i = 0; i < k; i++) {
    cin >> c[i] >> d[i];
    if (uf.is_united(c[i] - 1, d[i] - 1)) {
      block[c[i] - 1]++;
      block[d[i] - 1]++;
    }
  }

  for (ll i = 0; i < n - 1; i++) {
    cout << uf.size(i) - nx[i].size() - 1 - block[i] << " ";
  }
  cout << uf.size(n - 1) - nx[n - 1].size() - 1 - block[n - 1] << endl;
}

Measured memory_bytes: 12916
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Data{
public:
    int y, x, d;
    Data(int y0, int x0, int d0){
        y = y0;
        x = x0;
        d = d0;
    }
};

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

int main()
{
    for(;;){
        int h, w, n;
        cin >> h >> w >> n;
        if(h == 0)
            return 0;

        string command;
        cin >> command;

        vector<string> grid(h+2, string(w+2, '#'));
        int sy, sx, gy, gx;
        for(int i=1; i<=h; ++i){
            for(int j=1; j<=w; ++j){
                cin >> grid[i][j];
                if(grid[i][j] == 'S'){
                    sy = i;
                    sx = j;
                    grid[i][j] = '.';
                }
                if(grid[i][j] == 'G'){
                    gy = i;
                    gx = j;
                    grid[i][j] = '.';
                }
            }
        }

        vector<vector<int> > minChange(n+1, vector<int>(4));
        int d = (count(command.begin(), command.end(), 'R') + count(command.begin(), command.end(), 'L') * 3) % 4;
        vector<int> tmp(4, INT_MAX);
        for(int i=n; i>=0; --i){
            tmp[d] = i;
            minChange[i] = tmp;
            if(i > 0){
                if(command[i-1] == 'R')
                    d += 3;
                else
                    ++ d;
                d %= 4;
            }
        }

        multimap<int, Data> mm;
        mm.insert(make_pair(0, Data(sy, sx, 0)));
        vector<vector<vector<int> > > minTurn(h+2, vector<vector<int> >(w+2, vector<int>(4, INT_MAX)));
        minTurn[sy][sx][0] = 0;
        bool ok = false;
        while(!mm.empty()){
            int turn0 = mm.begin()->first;
            int y0 = mm.begin()->second.y;
            int x0 = mm.begin()->second.x;
            int d0 = mm.begin()->second.d;
            mm.erase(mm.begin());
            if(turn0 > minTurn[y0][x0][d0])
                continue;

            if(y0 == gy && x0 == gx){
                ok = true;
                break;
            }

            for(int i=0; i<4; ++i){
                int turn = minChange[turn0][i];
                if(turn < minTurn[y0][x0][i]){
                    minTurn[y0][x0][i] = turn;
                    mm.insert(make_pair(turn, Data(y0, x0, i)));
                }
            }
            int y = y0 + dy[d0];
            int x = x0 + dx[d0];
            if(grid[y][x] != '#' && turn0 < minTurn[y][x][d0]){
                minTurn[y][x][d0] = turn0;
                mm.insert(make_pair(turn0, Data(y, x, d0)));
            }
        }

        if(ok)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std; 
int a[105],n,ans,num;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<n;i++)
    	if(a[i]>a[i+1]) ans+=a[i]-a[i+1];
    ans+=a[n];
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int i, j, k;
	int	n, m, h, w, g, a, b, c, d;
	int f = 0;
	char s[2100000];


	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);

	scanf("%s", s);


	for (i = 0;i < n-1;i++) {
		if (s[i] == '#') {
			if (s[i + 1] == '#') {
				if (i > a-1) {
					if (i < c) {
						f = 1;
					}
				}
				if (i > b-1) {
					if (i < d) {
						f = 1;
					}
				}
			}
		}
	}

	if (d < c&&f==0) {
		f = 1;
		for (i = b-2;i < n-2;i++) {
			if (i > d-2) {
				break;
			}
			if (s[i] == '.') {
				if (s[i + 1] == '.') {
					if (s[i + 2] == '.') {
						f = 0;
						break;
					}
				}

			}
		}
	}




	if (f == 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}


	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1000000007;

int n, m;
vi a, b, c, d;

int main(){
  cin >> n >> m;
  int in1, in2;
  rep(i, n){
    cin >> in1 >> in2;
    a.push_back(in1); b.push_back(in2);
  }
  rep(i, m){
    cin >> in1 >> in2;
    c.push_back(in1); d.push_back(in2);
  }
  int pnt = 0;
  int dis;
  int ans;
  rep(i, n){
    dis = INF;
    rep(j, m){
      if(dis > abs(a[i] - c[j]) + abs(b[i] - d[j])){
        dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
        ans = j;
      }
    }
    cout << ans + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " = " << x << endl;
typedef long long ll;
int main()
{
    fastIO
    string s,t;

    cin>>s>>t;

    int ans=0;

    for (int i=0; i<s.size(); ++i)
    {
        ans+=(s[i]!=t[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 3724
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)


Measured memory_bytes: 18736
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,m; cin>>n>>m;
	vector<ll> arr(m);
	for(auto &it:arr)cin>>it;
	ll s=0;
	for(auto i=0;i<m;++i)s+=arr[i];
	if(s>n)cout<<"-1\n";
	else
		cout<<n-s<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 3672
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll win[100001];

int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k,q;
    cin >> n >> k >> q;
    rep(i,0,q){
        ll x;
        cin >> x;
        win[x]++;
    }
    //cout << k << " " << q << "\n";
    for(ll i=1; i<=n; i++){
        //cout << win[i] << "\n";
        if(k+win[i]>q) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 1408
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
offset = 0
for i in range(n):
    offset = a[i] * 2 - offset
offset //= 2
for i in range(n):
    print(offset, end = " ")
    offset = a[i] * 2 - offset

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

int main() {
  int s,s1,s2,s3;
  cin >> s;
  s1 = s % 10;
  s2 = s / 10 % 10;
  s3 = s / 10 /10 % 10;
  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lli long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<lli>   vll;
typedef vector<int>   vi;
typedef set<lli>      sll;
typedef set<int>      si;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

int i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
//
lli power(lli x,lli n,unsigned lli m=ULLONG_MAX)
{ 
  lli res=1;  	x%=m; 
     while(n>0)
       { 
         if(n&1==1) res=(res*x)%m;
          n/=2;
          x=(x*x)%m;
       }
   return res;
}

void solve()
{
	double n,k; cin>>n>>k;
	double ans=0.0;

	rep(i,1,n)
	{
		double temp=0.0;
		if(i>=k) 
		{
			temp=1/n;
			ans+=temp;
			continue;
		}

		double val=log2((k/i));
		if(val!=int(val))
           {
           	val=int(val);
           	++val;
           }

          temp=1/n;
          temp/=power(2,val);
          ans+=temp;
	}
	cout<<fixed<<setprecision(12)<<ans;
	cout<<"\n";
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int n;
  if(b<10) n=10*a+b;
  else if (b<100) n=100*a+b;
  else n=1000*a+b;
  bool flag = 0;
  int i=1;
  while (flag==0 && i*i<=n){
    if(i*i==n){
      flag =1;
      break;
    }
    else i++;
  }
  cout << (flag?"Yes":"No") << endl;
}

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

public class Hello
{
    public static void Main()
    {
        // Your code here!
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int A = a[0];
        int B = a[1];
        int K = a[2];
        int numT = A;
        int numA = B;
        
        for(int i = 1; i <= K; i++)
        {
            if(i % 2 == 1)
            {
                //高橋君の処理
                if(numT % 2 == 1) //numTが奇数のとき
                {
                    numT--;
                    
                }
                //半分あげる
                int exchange = numT / 2;
                numT -= exchange;
                numA += exchange;
                
            }
            else
            {
                //青木君の処理
                 if(numA % 2 == 1) //numAが奇数のとき
                {
                    numA--;
                }
                
                //半分あげる
                int exchange = numA / 2;
                numA -= exchange;
                numT += exchange;
            }
            
        }
        Console.WriteLine(numT + " " + numA);
        
    }
}


Measured memory_bytes: 13396
// D - Built?

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;
// const double INF = DBL_MAX;

// use in Kruskal
class DisjointSet {
	public:
	vector<int> rank;
	vector<int> parent;

	DisjointSet() {}

	// 0, 1, ... size-1 をそれぞれ唯一の要素とする
	// size個の互いに素な集合を作成
	DisjointSet(int size) {
		rank.resize(size, 0);
		parent.resize(size, 0);
		for (int i=0; i<size; i++) {
			makeSet(i);
		}
	}

	// 要素がXただ一つである新しい集合を作る
	void makeSet(int x) {
		parent[x] = x;
		rank[x] = 0;
	}

	// xとyが同じ集合に属しているかを判定する
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	// 指定された2つの要素x, yを合併する
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	// 低い方の木を高い方の木に合併
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			parent[y] = x;
		} else {
			parent[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	// 要素xが属する集合の代表の要素を求める
	int findSet(int x) {
		if (x != parent[x]) {
			parent[x] = findSet(parent[x]);
		}
		return parent[x];
	}
};

class Edge {
	public:
	int node1, node2;
	ll cost;

	Edge(int node1 = 0, int node2 = 0, ll cost = 0):
		node1(node1), node2(node2), cost(cost) {}

	bool operator < (const Edge &e) const {
		return cost < e.cost;
	}
};

ll Kruskal(int N, vector<Edge> edges) {
	ll totalCost = 0;
	sort(edges.begin(), edges.end());

	DisjointSet dset = DisjointSet(N);

	int node1, node2;
	for (int i=0; i< edges.size(); i++) {
		Edge e = edges[i];
		if (!dset.same(e.node1, e.node2)) {
			//MST.push_back(e);
			totalCost += e.cost;
			dset.unite(e.node1, e.node2);
		}
	}

	return totalCost;
}

pair<int, int> town[100000];
pair<int, int> x_idx[100000];
pair<int, int> y_idx[100000];

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

	int x, y;
	for (int i=0; i<N; i++) {
		cin >> x >> y;
		town[i] = make_pair(x, y);
		x_idx[i] = make_pair(x, i);
		y_idx[i] = make_pair(y, i);
	}

	sort(x_idx, x_idx + N);
	sort(y_idx, y_idx + N);

	vector<Edge> edges;

	// x方向で隣接する街に辺を設定
	for (int i=0; i<N-1; i++) {
		int idx_1 = x_idx[i].second;
		int idx_2 = x_idx[i+1].second;
		int x1 = town[idx_1].first;
		int y1 = town[idx_1].second;
		int x2 = town[idx_2].first;
		int y2 = town[idx_2].second;
		ll d = min(abs(x1 - x2), abs(y1 - y2));
		edges.push_back(Edge(idx_1, idx_2, d));
	}

	// y方向で隣接する街に辺を設定
	for (int i=0; i<N-1; i++) {
		int idx_1 = y_idx[i].second;
		int idx_2 = y_idx[i+1].second;
		int x1 = town[idx_1].first;
		int y1 = town[idx_1].second;
		int x2 = town[idx_2].first;
		int y2 = town[idx_2].second;
		ll d = min(abs(x1 - x2), abs(y1 - y2));
		edges.push_back(Edge(idx_1, idx_2, d));
	}

	ll ans = Kruskal(N, edges);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb                     push_back
#define ll                     long long int
#define fi                     first
#define se                     second
#define ii                     pair<long long int, long long int>
#define vi                     vector <long long int>
#define vii                    vector <pair <long long int, long long int > >
#define all(cont)              cont.begin(), cont.end()
#define EPS                    1e-9
#define MOD                    1000000007
#define range
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
 int comp(const void* a, const void* b)  
{ return *(int*)a > *(int*)b ; }  
  

int main(){
 
    IOS;
    clock_t clk = clock();
   // freopen("input.txt",  "r", stdin);
   // freopen("output.txt", "w", stdout);
 	int n; cin >> n;
 	int arr[n];
 	forn(i,n)
 	{
 		cin>>arr[i];
 	}
 	
 	if(n<3){cout<<0;return 0;}
 	qsort(arr, n, sizeof( arr[0] ), comp);  
  
   
    int count = 0;  
  
     
    for (int i = 0; i < n - 2; ++i)  
    {  
                int k = i + 2;  
  
        
        for (int j = i + 1; j < n; ++j)  
        {  
           
            while (k < n && arr[i] + arr[j] > arr[k])  
            ++k;  
  
           
            if(k > j)  
            count += k - j - 1;  
        }  
    }  
  cout<<count;  

 
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5;
const double INF = 1e9;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	vector<vector<double>> dp(N + 1, vector<double>(MAX, INF));
	for (int i = 1; i < MAX; i++) {
		dp[0][i] = 0;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 1; j < MAX; j++) {
			for (int k = j; k < MAX; k += j) {
				dp[i + 1][k] = min(dp[i + 1][k], max(dp[i][j], (double)abs(k - a[i]) / a[i]));
			}
		}
	}
	double res = INF;
	for (int i = 1; i < MAX; i++) {
		res = min(res, dp[N][i]);
	}
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}

Measured memory_bytes: 37084
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,sum=0;
    cin>>n>>m;
    if(m>=n) cout<<0;
    else 
    {
        long long int a[n];
        for (int i=0;i<n;i++) cin>>a[i];
        if(n!=1) sort(a,a+n);
        long long int i=n-1;
        while(m>0 && i>=0)
        {
            a[i]=0;
            i--;
            m--;
        }
        for (long long int i=0;i<n;i++) sum += a[i];
        cout<<sum;
    }
}

Measured memory_bytes: 1792