akhauriyash/Code-Regression huggingface dataset:
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
bool sortbysecdesc(const pair<string,ll> &a,const pair<string,ll> &b)
{
       return a.second>b.second;
}
int main() {
	int n;cin>>n;
	int arr[n];
	loop(n,i,0)cin>>arr[i];
	if(arr[0]>arr[1])arr[0]--;
	loop(n,i,1){
		if(arr[i]>arr[i-1])arr[i]--;
		if(arr[i]<arr[i-1])return cout<<"No"<<endl,0;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
using namespace std;

int main(){
     string S;
     cin >>S;
     if(S[0]==S[1]&&S[1]==S[2]&&S[2]==S[0]){
          cout <<"No"<<endl;
     }else{
          cout << "Yes"<<endl;
     }
}


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

int main() {
  string S;
  cin >> S;
	bool isGood = true;
	for(int i = 1; i < S.size(); i++) {
		if(S[i] == S[i - 1]) isGood = false;
	}
	if(isGood) cout << "Good" << endl;
	else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int d[10][10];
int main()
{
	int num;
	scanf("%d", &num);
	string s;
	cin >> s;
	int now = 0, mini = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == ')')now--;
		else now++;
		mini = min(mini, now);
	}
	for (int i = 0; i < -mini; i++)printf("(");
	for (int i = 0; i < s.size(); i++)printf("%c", s[i]);
	for (int i = 0; i < now - mini; i++)printf(")");
	printf("\n");
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    input = input.split(" ");
    var a = parseInt(input[0]);
    var b = parseInt(input[1]);

    if((a*500)>=b){
        //出力
	console.log("Yes");

    }else{
        console.log("No");
    }
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21956
n = int(input())
w = [int(s) for s in input().split()]

acc = [sum(w[:x]) for x in range(1, n + 1)]
center = acc[n - 1] / 2
index = 0

for i in range(n):
    if acc[i] >= center:
        if abs(center - acc[i]) < abs(center - acc[i - 1]):
            index = i
        else:
            index = i - 1
        break
print(abs((acc[n - 1] - acc[index]) - acc[index]))

Measured memory_bytes: 9164
t=d=m = 0
gets
$<.each {|s|
  a = s.split.map &:to_i
  a[t] -= d
  s,t = [0,1,2].sort_by{|i| a[i]+m}.pop 2
  m += a[t]
  d = a[t]-a[s]
}  
p m

Measured memory_bytes: 1788
A = [int(input())]

for n in range(2,10**6):
  if A[-1]%2==0:
    if A[-1]//2 in A:
      print(n)
      exit()
    else:
      A.append(A[-1]//2)
  else:
    if 1+3*A[-1] in A:
      print(n)
      exit()
    else:
      A.append(1+3*A[-1])

Measured memory_bytes: 9192
N = int(input())
s = ""
words = "abcdefghijklmnopqrstuvwxyz"
while N > 0:
    if N%26 == 0:
        amari = 26
    else:
        amari = N%26
    if N > 26:
        N = (N-amari)/26
    else:
        N = N-26
    s = words[int(amari-1)]+s
print(s)

Measured memory_bytes: 9164
from itertools import product


def get_ms_ls(i):
    temp = list(str(i))
    return int(temp[0]), int(temp[-1])


def main():
    N = int(input())

    dp = [[0] * 10 for _ in range(10)]
    for i in range(1, N + 1):
        msb, lsb = get_ms_ls(i)
        dp[msb][lsb] += 1

    ans = 0
    for (i, j) in product(range(10), repeat=2):
        x, y = dp[i][j], dp[j][i]
        ans += x * y

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40684
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

typedef pair<int,int> P;


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

	string s;
	cin >> s;

	int start=0;
	int len=s.size();
	//cout << len << "\n";

	while(start <= len-1){ 
		if(s.substr(start,5) == "dream"){
			if(s.substr(start,7) == "dreamer"){
				if(start+7 < len && s[start+7] == 'a'){	//dreamerase
					start+=5;
	//				cout << start << " dream\n";
				}else{	//dreamer
					start+=7;
	//				cout << start << " dreamer\n";
				}
			}else{	//dream
				start+=5;
	//			cout << start << " dream\n";
			}
		}
		else if(s.substr(start,5) == "erase"){
			if(start+5 < len && s[start+5] == 'r'){	//eraser
				start+=6;
	//			cout << start << " eraser\n";
			}else{					//erase
				start+=5;
	//			cout << start << " erase\n";
			}
		}
		else{
			cout << "NO\n";
			return 0;
		}
	}

	cout << "YES\n";

	return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long uLL;
typedef long double ldb;
typedef pair<int,int> pii;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    int i = 1;
    for(i = 1; i*i<=n; ++i);
    --i;
    cout<<i*i<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
int A[9][9];


int main(void) {
  int n,m;
  cin >> n >> m;
  rep(i,9)rep(j,9){
    A[i][j] = 0;
  }
  rep(i,m) {
    int a,b;
    cin >> a >> b;
    A[a-1][b-1] = 1;
    A[b-1][a-1] = 1;
  }
  vector<int> ord(n);
  rep(i,n) ord[i] = i;
  int cnt = 0;
  do{
    if(ord[0] !=  0) break;
    bool ok = true;
    rep(i,n-1){
      if(A[ord[i]][ord[i+1]] == 0) ok = false;
    }
    if(ok) cnt++;
  }while(next_permutation(ord.begin(),ord.end()));
  cout << cnt << endl;
  
  
    
  
}


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


int d[300000];
int n;

bool able(){
    int p = 0;
    for(int i = 0; i < n; i++) {
        p = max(p, i + d[i]);
        if(p == i) return false;
    }
    return true;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++) {cin >> d[i]; d[i] /= 10; }
    
    bool a = able();
    reverse(d, d+n);
    bool b = able();
    
    cout << (a && b ? "yes" : "no") << endl;
    
    return 0;
}


Measured memory_bytes: 4280
#include <iostream>
#include <string>
using namespace std;
int main(void) {
	string s;
	cin >> s;
	bool ok = false;
	for (int i = 0; i < s.size(); ++i) {
		for (int j = i; j <= s.size(); ++j) {
			string a = s.substr(0, i) + s.substr(j);
			if (a == "keyence") ok = true;
		}
	}
	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        bool ip = false;
        bool jp = false;
        bool kp = false;
        rep(x,n){
          if(i == 2 && j == 2 && k == 4){
            //cout << ip << jp << kp << endl;
            //cout << "e" << endl;
          }
          if((s.at(x) - '0') == i && !ip){
            ip = true;
            continue;
          }
          if(((s.at(x) - '0') == j) && ip && !jp){
            //if(i == 2 && j == 2 && k == 4) cout << -1009209 << endl;
            jp = true;
            continue;
          }
          if(((s.at(x) - '0') == k) && ip && jp && !kp){
            kp = true;
            cnt++;
            //if(i == 2 && j == 2 && k == 4) cout << "d" << endl;
            break;
          }
          /*if(i == 2 && j == 2 && k == 4){
            cout << ip << jp << kp << endl;
            cout << "d" << endl;
          }*/
        }
      }
    }
  }
  cout << cnt << endl;
}


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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n; cin >> n;
    cout << (n + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s[0]==s[1]&&s[0]==s[2]){
    cout<<"Yes"<<endl;
  }
  else if(s[1]==s[2]&&s[1]==s[3]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int n;
  static char[] s;

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

    n = sc.nextInt();
    s = sc.next().toCharArray();

    int right = 0;
    StringBuilder b = new StringBuilder();
    StringBuilder c = new StringBuilder();
    for(int i = 0; i < n; i++){
      if(s[i] == '('){
        ++right;
      }
      else{
        --right;
      }
      if(right < 0){
        b.append("(");
        ++right;
      }
    }
    for(int i = 0; i < right; i++){
      c.append(")");
    }

    System.out.print(b);
    System.out.print(s);
    System.out.println(c);
  }
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

const int INF = 1000000009;

int main() {
  int n; cin >> n;
  string s; cin >> s;

  vector<set<int>> a(26, set<int>({INF})); // INF は番兵のようなもの
  for (int i = 0; i < n; i++) { a[s[i]-'a'].insert(i); }

  int q; cin >> q;
  while (q--) {
    int type; cin >> type;
    if (type == 1) {
      int idx; char nc; cin >> idx >> nc; idx--;
      // a[s[idx]-'a'].erase(idx);
      // a[c-'a'].insert(idx);
      auto pc = s[idx];
      s[idx] = nc;
      a[pc - 'a'].erase(idx);
      a[nc - 'a'].insert(idx);
    }
    if (type == 2) {
      int l, r; cin >> l >> r; l--;
      int ret = 0;
      for (int i = 0; i < 26; i++) {
        int lid = *a[i].lower_bound(l);
        int rid = *a[i].lower_bound(r);
        if (rid > lid) ret++;
        // if (lid < r) { ret++; }
      }
      cout << ret << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 24196
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	A := make(map[int]int)
	ans, n := 0, nextInt()
	for i := 0; i < n; i++ {
		a := nextInt()
		ans += a
		A[a] += 1
	}
	q := nextInt()
	for i := 0; i < q; i++ {
		b := nextInt()
		c := nextInt()
		ans -= A[b] * b
		ans += A[b] * c
		A[c] += A[b]
		A[b] = 0
		fmt.Println(ans)
	}
}


Measured memory_bytes: 8716
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct city{
  ll x, y, id;
};
struct edge{
  ll u, v, c;
};
llvec p;
vector<edge> e;

ll total;


P root(ll a){
  ll atmp=a;
  ll cnt=0;
  while(atmp!=p[atmp]){
    atmp=p[atmp];
    cnt++;
  }
  p[a]=atmp;
  return {cnt, atmp};
}

bool con(ll u, ll v){
  P ur=root(u);
  P vr=root(v);
  if(ur.second==vr.second){
    return false;
  }else{
    if(ur.first>vr.first)swap(ur, vr);
    p[ur.second]=vr.second;
    return true;
  }
}

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  vector<city> loc;
  cin >> N;
  p=llvec(N);
  rep(i, N){
    city c;
    cin >> c.x >> c.y;
    c.id = i;
    p[i]=i;
    loc.push_back(c);
  }
  
  sort(ALL(loc), [](city a, city b){return a.x<b.x;});
  rep(i, N-1){
    edge t;
    t.u = loc[i].id;
    t.v = loc[i+1].id;
    t.c = loc[i+1].x - loc[i].x;
    e.push_back(t);
  }
  sort(ALL(loc), [](city a, city b){return a.y<b.y;});
  rep(i, N-1){
    edge t;
    t.u = loc[i].id;
    t.v = loc[i+1].id;
    t.c = loc[i+1].y - loc[i].y;
    e.push_back(t);
  }

  total = N;
  sort(ALL(e), [](edge a, edge b){return a.c<b.c;});
  ll i=0;
  ll ans = 0;
  while(total>1){
    if(con(e[i].u, e[i].v)){
      total--;
      ans += e[i].c;
    }
    i++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 11760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long ll;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;

int main()
{
    int N; cin >> N;
    string S; cin >> S;
    int x = 0;
    int ans = 0;

    rep(i, N){
        if (S[i] == 'I'){
            ++x;
            ans = max(ans, x);
        } else {
            --x;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N,M = map(int,input().split())
AC_dict = defaultdict(int)
ans_AC = 0
ans_WA = 0

for _ in range(M):
    p,s = input().split()
    p = int(p)
    if s == "AC":
        if AC_dict[p] == -1:
            continue
        else:
            ans_AC += 1
            ans_WA += AC_dict[p]
            AC_dict[p] = -1
    else:
        if AC_dict[p] == -1:
            continue
        else:
            AC_dict[p] += 1

print(ans_AC,ans_WA)

Measured memory_bytes: 15460
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    char alpha = scan.next().charAt(0);
    int code = (int)(alpha);
    if (65<=code && code<=90){
      System.out.println("A");
    }else{
      System.out.println("a");
    }
  }
}


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

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

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

	int ans = k;
	for (int i = 1; i < n; i++)
	{
		ans *= k - 1;
	}

	cout << ans << endl;
}

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

const int nax = 1e5;
vector<int> node[nax];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    node[a].push_back(b);
    node[b].push_back(a);
  }

  vector<int> par(n), done(n);
  queue<int> q;
  q.push(0);
  done[0] = 1;
  while (q.size()) {
    int p = q.front();
    q.pop();
    for (int i : node[p]) {
      if (!done[i]++) {
	par[i] = p;
	q.push(i);
      }
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++) {
    cout << par[i]+1 << '\n';
  }
}


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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 2e5 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main ()
{
	hey();
	ll n;
	cin >> n;
	int kol = 0;
	ll now = 100;
	while (now < n)
	{
		kol++;
		now = now + now * 0.01;
	}
	cout << kol;
}




Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll      long long
#define pii     pair<int, int>
#define f       first
#define s       second
#define read	freopen("input.txt", "r", stdin)
#define write	freopen("output.txt", "w", stdout)
#define mx      5e12

using namespace std;
ll dp[110][100009];
int main()
{
	// read;
	// write;

    int n, W, x, y;
    cin>>n>>W;

    vector< pii >v;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        v.push_back(pii(x,y));
    }
    sort(v.begin(), v.end());
    for(int i=0;i<=n;i++){
        for(int j=0;j<100009;j++){
            dp[i][j] = mx;
        }
    }

    dp[0][0] = 0;
    dp[0][v[0].s] = v[0].f;
    for(int i=1;i<n;i++){
        for(int j=0;j<100009;j++){
            if(j-v[i].s >= 0)
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i].s]+v[i].f);
            else
                dp[i][j] = dp[i-1][j];
        }
    }

    ll ans = 0;
    for(int i=0;i<100009;i++){
        if(dp[n-1][i] <= W)
            ans = i;
    }
    cout<<ans;
}
    



Measured memory_bytes: 80128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << (n % k == 0 ? 0 : 1) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

int main() {
    ll N;
    cin >> N;
    ll ans = 0, cnt = 0;
    if(N % 2 == 0) {
        N /= 2;
        while(N > 0) {
            N /= 5;
            ans += N;
        }
    }
    cout << ans << endl;
}


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

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX

using namespace std;

#define F first
#define S second 

#ifdef __debug_leywar
#include <debug/debugger.h>
#else
#define db(...) ;
#endif

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int n ;
    long long k ; 
    cin >> n >> k ;

    vector<int> ar( n + 1 ) ; 

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

    int ans = 0 ; 

    for( int i = ( 1 << 30 ) ; i >= 1 ; i /= 2 )
    {
        int target = ans + i ; 
        long long sc = 0 ;

        for( int j = 1 ; j <= n ; j++ )
        {
            if( ar[j] <= target ) 
                continue ; 
            else 
                sc += (( ar[j] + target - 1 ) / target ) - 1 ;
        }   

        if( sc > k ) 
            ans = target ;         
    }

    cout << ans + 1 ; 

    return 0;
}

Measured memory_bytes: 4784
N,M = map(int,input().split())

XY = [list(map(int,input().split())) for _ in range(M)]

ball_count = [1]*N

red_ball_cand = [0]*N
red_ball_cand[0] = 1

for i in range(M):
    x,y = XY[i]
    x,y = x-1,y-1
    if 0 < red_ball_cand[x]:
        red_ball_cand[y] = 1
        
    ball_count[x] -= 1
    ball_count[y] += 1
    
    if ball_count[x] == 0:
        red_ball_cand[x] = 0
print(sum(red_ball_cand))

Measured memory_bytes: 91496
n = int(input())
a_ls = list(map(int, input().split()))
small = sum(a_ls)//n
big = small + 1
ans = float('inf')
for goal in [big, small]:
    Sum = 0
    for a in a_ls:
        Sum += (goal - a) ** 2
    ans = min(ans, Sum)
print(ans)

Measured memory_bytes: 3060
#include <iostream>

int main()
{
    int n, m, q;
    int lr[501][501] = {0};
    int pi[100000];
    int qi[100000];
    int c[501][501] = {0};

    std::cin >> n >> m >> q;
    for (int i = 0; i < m; i++) {
        int l, r;
        std::cin >> l >> r;
        lr[l][r]++;
    }

    for (int i = 0; i < q; i++) {
        std::cin >> pi[i] >> qi[i];
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            c[i][j] = c[i][j-1] + lr[i][j];
        }
    }

    for (int i = 0; i < q; i++) {
        int count = 0;
        for (int j = pi[i]; j <= qi[i]; j++) {
            count += c[j][qi[i]] - c[j][pi[i] - 1];
        }

        std::cout << count << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3712
s = str(input())
t = str(input())
slist = []*len(s)
scnt = 0
tlist = []*len(t)
tcnt = 0
ans='Yes'
i=0
while i < len(s):
    inds = s.index(s[i])
    indt = t.index(t[i])
    if inds < i:
        slist.append(slist[inds])
    else:
        slist.append(scnt)
        scnt+=1
    if indt < i:
        tlist.append(tlist[indt])
    else:
        tlist.append(tcnt)
        tcnt+=1
    if slist[i]!=tlist[i]:
        ans='No'
        break
    i+=1
print(ans)

Measured memory_bytes: 6656
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
lint n;
int main(){
	std::string ans;
	std::cin>>n;
	while(n){
		n--;
		ans+='a'+n%26;
		n/=26;
	}
	std::reverse(all(ans));
	std::cout<<ans<<std::endl;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;

#define ll long long

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}

int main() {

	string S, T;
	cin >> S >> T;

	if (S.size() < T.size()) {

		cout << "UNRESTORABLE" << endl;
		return 0;

	}

	bool flag;
	for (int i = S.size() - T.size(); i >= 0; i--) {
		flag = true;

		for (int j = 0; j < T.size(); j++) {

			if (S[i + j] != T[j] && S[i + j] != '?')flag = false;

		}
		
		if (!flag)continue;

		for (int j = 0; j < S.size(); j++) {

			if (i <= j&&j < i + T.size())cout << T[j - i];
			else if (S[j] == '?')cout << 'a';
			else cout << S[j];

		}
		cout << endl;
		break;

	}

	if (!flag)cout << "UNRESTORABLE" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
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 INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string a,b,c;
	
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2]<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    string s;
    cin >> s;
    // 文字列の入力
  	int i;
  	i = 0;
  	while (s[i++])
	    cout << 'x';
  	cout << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	var ans int
	fmt.Scan(&a, &b)
	if a*b == 2 {
		ans = 3
	} else if a*b == 3 {
		ans = 2
	} else {
		ans = 1
	}
	fmt.Println(ans)
}


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

int main(){
 int n, k;
 cin >> n;
 string s;
 cin >> s >> k;
 char x=s[k-1];
 for(int i=0;i<n;i++){
  if(s[i]==x){
   }else{
   s[i]='*';
  }
  }
 cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,m;cin>>n>>m;
    vector<ll>c(m);
    vector<ll>a(m);
    rep(i,m){
        ll aa,b;cin>>aa>>b;
        a[i]=aa;
        ll cnt=0;
        rep(j,b){
            ll cc;
            cin>>cc;
            cnt+=(1<<cc);
        }
        c[i]=cnt;
    }
    vector<ll>dp(1<<13,inf);
    dp[0]=0;
    rep(i,(1<<13)){
        rep(j,m){
            if((i|c[j])!=i){
                dp[i|c[j]]=min(dp[i|c[j]],dp[i]+a[j]);
            }
        }
    }
    if(dp[(1<<(n+1))-2]==inf)dp[(1<<(n+1))-2]=-1;
    cout<<dp[(1<<(n+1))-2]<<endl;
}

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

int main(void) {
  int N;
  cin >> N;
  set<char> s;
  for (int i = 0; i < N; i++) {
    char c;
    cin >> c;
    s.insert(c);
  }
  cout << (s.size() == 3 ? "Three" : "Four") << endl;
  return 0;
}

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

// #define ANS  //for answer
#define CMP  //for compe

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x,(x)
#define ncv(x) #x,":",(x)
#define ncvc(x) #x,":",(x),","
using ll = long long;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>void pPRINT(std::ostream& ost,const T t,const U... u) {ost<<t<<" ";pPRINT(ost, u...);}
template <class... T>void PRINT(const T... t) {pPRINT(std::cout, t...);}
template <class... T>void PRINTl(const T... t){pPRINT(std::cout,t...);std::cout<<"\n";}
template <class T>void PRINTa(const T* const t,const ll size){REP(i,size)PRINT(t[i]);PRINTl();}
template <class T>void PRINTal(const T* const t,const ll size){REP(i,size)PRINTl(i,":",t[i]);}
#ifdef CMP
using namespace std;
#else
#endif
#ifndef DBG
#define DEBUG(...)
void init(){}
#else
#define DEBUG(...) PRINT("##DEBUG##","file :",__FILE__,", line :",__LINE__,"[");PRINT(__VA_ARGS__);PRINTl("]");
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

int main(int argc, char *argv[]) {

  init();
  DEBUG();
  solve();

  return 0;
}

void solve(){

  DEBUG("SOLVE START");

  ll n,m;cin>>n>>m;
  ll x[m];REP(i,m)cin>>x[i];
  sort(x,x+m);
  ll d[m-1];REP(i,m-1)d[i]=x[i+1]-x[i];
  sort(d,d+m-1);
  ll ans = 0;
  REP(i,m-n)ans+=d[i];
  PRINTl(ans);



}

Measured memory_bytes: 1792
N=int(input())
a = list(map(int, input().split()))

dp=[[0 for i in range(N+1)] for j in range(N+1)]
for i in range(1,N+1):
    dp[i][i]=a[i-1]
for j in range(1,N+1):
    for i in reversed(range(1,N+1)):
        if i>j:
            continue
        if i==j:
            dp[i][j]=a[i-1]
        if i<j:
            dp[i][j]=max(a[i-1]-dp[i+1][j],a[j-1]-dp[i][j-1])
print(dp[1][N])

Measured memory_bytes: 153556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define sc second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
	int l, r, d;
	scanf("%d %d %d", &l, &r, &d);
	
	int ans = (r - l) / d;
	
	if(r % d == 0 or l % d == 0) ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 3864
(function(stdin) {
  // Define Function

  // Declare Variable
  const inputs  = stdin.toString().trim().split('\n');

  // Main Procedure
  const result = (function(a) {

    return Math.pow(a, 3);

  }(parseInt(inputs[0], 10)));

  // Display
  console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15780
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<-1<<endl;return 0;}
//template

//main
signed main(){
  string s;cin>>s;
  int N=s.size();
  for(int i=1;i<N-1;i++)if(s[i]!=s[N-i-2])fin;
  if(s[N-1]=='1')fin;if(s[0]=='0')fin;
  queue<int> to_next;
  for(int i=1;i<=N;i++){
    if(s[i-1]=='1'){
      while(to_next.size()){
        int p=to_next.front();to_next.pop();
        cout<<p<<" "<<i<<endl;
      }
    }
    to_next.push(i);
  }
  cout<<N-1<<" "<<N<<endl;
}


Measured memory_bytes: 2304
import java.util.*;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        List<Integer> all_x = new ArrayList<>();
        all_x.add(x);
        for (int i = 0; i < n; i++) {
            all_x.add(sc.nextInt());
        }
        Collections.sort(all_x);

        List<Integer> all_y = new ArrayList<>();
        all_y.add(y);
        for (int i = 0; i < m; i++) {
            all_y.add(sc.nextInt());
        }
        Collections.sort(all_y);

        if (all_x.get(n) < all_y.get(0)) {
            System.out.println("No War");
        } else {
            System.out.println("War");
        }
    }

}




Measured memory_bytes: 23636
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;
#define MAX_N 100
int d[MAX_N];

void init(){
	rep(i,MAX_N){
		d[i] = -1;
	}
}


int main()
{
	init();
	int n;
	cin>>n;
	vector<int> *node = new vector<int>[n];
	rep(i,n){
		int num,k;
		cin>>num>>k;
		rep(j,k){
			int num;
			cin>>num;
			num--;
			node[i].push_back(num);
		}
	}
	
	d[0] = 0;
	queue<int> que;
	que.push(0);
	while(que.empty() != true){
		int currentNode = que.front();
		que.pop();
		for(auto iter = node[currentNode].begin(); iter != node[currentNode].end(); iter++){
			if( d[*iter] == -1 || d[currentNode] + 1 < d[*iter]){
				d[*iter] = d[currentNode] + 1;
				que.push(*iter);
			}
		}
	}
	rep(i,n)cout<<i+1<<" "<<d[i]<<endl;
	return 0;
}




Measured memory_bytes: 3168
n = int(input())
A = []
for _ in range(n):
    A.append(input())

for i, e in enumerate(A):
    if i == 0: continue
    if A.count(e) != 1 or A[i - 1][-1] != A[i][0]:
        print('No')
        break
    if i == n - 1:
        print('Yes')


Measured memory_bytes: 2940
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int[4];
    for (int i = 0; i < 4; i++){
      a[i] = sc.nextInt();
    }
    System.out.println(Math.max(a[0]*a[1], a[2]*a[3]));
  }
}

Measured memory_bytes: 35640
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
sm=sum(a)
ans=1
pas=a[0]
for i in range(1,n):
    if a[i-1]>(sm-pas)*2:
        break
    ans += 1
    pas += a[i]
print(ans)


Measured memory_bytes: 14308
h,w=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]
a=[list(map(int,input().split())) for _ in range(h)]


def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
inf=1<<32
d = [[inf for i in range(10)] for _ in range(10)]
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(10):
    for j in range(10):
        d[i][j]=c[i][j]
for i in range(10):
    d[i][i] = 0 #自身のところに行くコストは０
x=warshall_floyd(d)
ans=0
for i in range(h):
    for j in range(w):
        if a[i][j]==-1:
            continue
        ans+=x[a[i][j]][1]
print(ans)


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

namespace arc075_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInt();
            var a = new List<int>();

            for(int i = 0; i < N; i++) 
                a.Add(GetInt());

            if (a.Sum() % 10 != 0)
                Console.WriteLine(a.Sum());
            else 
            {
                var b = a.Where(x => x % 10 != 0).OrderBy(x => x);
                if (b.Any())
                    Console.WriteLine(a.Sum() - b.First());
                else
                    Console.WriteLine(0);
            }
        }

        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();

    }
}


Measured memory_bytes: 13396
//ABC084 - C
#include <iostream>
using namespace std;

long long  N;

int main() {
    cin >> N;
    long C[N-1],S[N-1],F[N-1];
    for(int i=0;i<N-1;i++) cin >> C[i] >> S[i] >> F[i];
    for(int i=0;i<N-1;i++){
        long answer = 0;
        for(int j=i;j<N-1;j++){
            long a = S[j] / F[j];
            long sub =  - S[j] + answer;
            if(sub<=0) answer = S[j];
            else{
                long b = sub/F[j];
                if(sub%F[j]==0) answer = S[j] + b*F[j];
                else answer = S[j] + (b+1)*F[j];
            }
            //cout << j <<" " << answer <<"\n";
            answer = answer + C[j];
            //cout << j << " " << answer <<"\n";
        }
        cout << answer <<"\n";
    }
    cout << 0 <<"\n";

    return 0;
}

Measured memory_bytes: 256
from collections import deque
n, m = map(int ,input().split())
graph = [[] for _ in range(n)]
for i in range(m):
  a,b = map(int, input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
v = [0]*n
ans = 0
for i in range(n):
  if v[i] == 0:
    ans += 1
    q = deque()
    q.append(i)
    v[i] = 1
    while q:
      node = q.popleft()
      for j in graph[node]:
        if v[j] == 0:
          q.append(j)
          v[j] = 1
print(ans-1)

Measured memory_bytes: 26652
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int x,a,b;

	cin >> x>>a>>b;
  
    if(abs(x-a)>abs(x-b)){
      cout<<'B'<<endl;
    }else{
      cout << 'A'<<endl;
    }

	

	return 0;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN,"%s",$s);
$kisu = array('R','U','D');
$gusu = array('L','U','D');
$flag = true;

for($i=0;$i<(int)(strlen($s));$i++){
   if($i%2==0){

     if(!in_array($s[$i],$kisu)){
       //echo $s[$i];
       
       $flag = false;
       break;
     }
   }else{
     if(!in_array($s[$i],$gusu)){
       $flag = false;
       break;
     }
   }
}



if(!$flag){
  echo "No";
}else{
  echo "Yes";
}

Measured memory_bytes: 16256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int nw = 1;
  vector<int> b;
  for(int i = 1; n > i; i++){
    if(a[i-1] != a[i]){
      b.push_back(nw);
      nw = 1;
    }else{
      nw++;
    }
  }
  b.push_back(nw);
  int ans = 0;
  for(int i = 0; b.size() > i; i++){
    ans += b[i]%2;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 1276
n = int(input())
infolist = []
for i in range(n):
    infolist.append([int(x) for x in input().split()])
center = []
for x in infolist:
    if x[2] != 0:
        x1, y1, h1 = x
        break
for i in range(101):
    for j in range(101):
        H = h1 + abs(x1-i) + abs(y1-j)
        if all(h == max((H - abs(x-i) - abs(y-j)) ,0) for x, y, h in infolist):
            print(i, j, H)

Measured memory_bytes: 3064
from collections import defaultdict

N, M = map(int, input().split())

connections = defaultdict(list)
for i in range(M):
    a, b = map(int, input().split())

    connections[a].append(b)
    connections[b].append(a)

for v in connections[1]:
    if N in connections[v]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Measured memory_bytes: 135244
s = input()
num = int(input())
for i in range(num):
    L = input().split()
    if L[0] == 'print':
        print(s[int(L[1]):int(L[2])+1])
    elif L[0] == 'reverse':
        ts = s[int(L[1]):int(L[2])+1]
        s = s[:int(L[1])] + ts[:: -1] + s[int(L[2])+1:]
    elif L[0] == 'replace':
        s = s[:int(L[1])] + L[3] + s[int(L[2])+1:]


Measured memory_bytes: 5612
use proconio::*;
use std::cmp::*;

fn main() {
    input! {
    a:i32,
    b:i32,
    c:i32,
    d:u32,
    }
    let e: i32 = max(a,max(b,c));
    println!("{}",a+b+c-e+e*2_i32.pow(d))
}

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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           100005
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(int i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(int i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<ll,ll> pp;
typedef vector<int> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = 1e9+7;
const int minf = (-1)*(1e9+7);

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b){ return __gcd(a,b);}
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}


void solve(int test){

    ll n;
    ldb d;
    cin >> n >> d;
    ll ans = 0;

    fr(i,0,n,1){
        ldb x,y;
        cin >> x >> y;
        ll temp = pow(x,2) + pow(y,2);
        if(sqrt(temp) <= d)ans++;
    }

    cout << ans;

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sc(a) scanf("%l64d", &a)
#define pr(a) printf("%l64d", a)

using namespace std;

main(){
    int n;
    scanf("%d", &n);
    map<int, int> m;
    int ans = 0;
    int a;
    for (int i = 0; i < n; i++){
        scanf("%d", &a);
        if (m[a] == 0){
            m[a]++;
            ans++;
        } else {
            m[a]--;
            ans--;
        }
    }
    printf("%d", ans);
}


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

int main() { 
    int h, w, num = 0, ans = 0;
    cin >> h >> w;
    char a[h][w];
    queue<pair<pair<int, int>, int>> q;

    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> a[i][j];
            if(a[i][j] == '#') {
                q.push(make_pair(make_pair(i, j), 0));
            }
        }
    }

    while(q.size()) {
        pair<pair<int, int>, int> ij = q.front();
        q.pop();
        int i = ij.first.first, j = ij.first.second;
        int layer = ij.second;

        if(i > 0) {
            if(a[i-1][j] != '#') {
                a[i-1][j] = '#';
                q.push(make_pair(make_pair(i-1, j), layer+1));
            }
        }
        if(i < h-1) {
            if(a[i+1][j] != '#') {
                a[i+1][j] = '#';
                q.push(make_pair(make_pair(i+1, j), layer+1));
            }
        }
        if(j > 0) {
            if(a[i][j-1] != '#') {
                a[i][j-1] = '#';
                q.push(make_pair(make_pair(i, j-1), layer+1));
            }
        }
        if(j < w-1) {
            if(a[i][j+1] != '#') {
                a[i][j+1] = '#';
                q.push(make_pair(make_pair(i, j+1), layer+1));
            }
        }
        ans = layer;
    }
    cout << ans << '\n';
}


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

int main(){
	int n,m;
	cin >> n>>m;
	int a[m]={};
	rep(i,n){
		int k;
		cin>>k;
		rep(j,k){
			int b;
			cin>>b;
			a[b-1]++;
		}
	}
	ll ans=0;
	rep(i,m)if(a[i]==n)ans++;
	cout << ans << endl;
	
}


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

int cnt;
int L[500000/2+2], R[500000/2+2];

void merge( int A[], int left, int mid, int right ){
  int n1 = mid-left;
  int n2 = right-mid;

  for( int i=0; i<n1; i++ ){
    L[i] = A[left+i];
  }
  for( int i=0; i<n2; i++ ){
    R[i] = A[mid+i];
  }
  L[n1] = 1000000000;
  R[n2] = 1000000000;

  int a=0, b=0;
  for( int j=left; j<right; j++ ){
    cnt++;
    if( L[a] <= R[b] ){
      A[j] = L[a++];
    }else{
      A[j] = R[b++];
    }
  }
}

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

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

  int S[500000];
  for( int i=0; i<n; i++ ){
    cin >> S[i];
  }

  mergeSort( S, 0, n );

  for( int i=0; i<n; i++ ){
     if( i!=n-1 ){
       cout << S[i] << " ";
     }else{
       cout << S[i] << endl;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 6916
package main

import (
	"fmt"
	"sort"
)

func MinMax(n []int, sum int) (int, int, int) {
	sort.Ints(n)
	
	return n[0], n[len(n) - 1], sum
}

func main(){
	var dataInt []int
	var leng, inp, sum int
	
	fmt.Scan(&leng)
	
		for i := 0; i < leng; i++ {		
			fmt.Scan(&inp)
			sum += inp
			dataInt = append(dataInt, inp)
		}

	fmt.Println(MinMax(dataInt, sum))
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 305, P = 998244353;

int n, a[N], S, f[N * N];

int main() {
	read(n);
	int ans = 1;
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
		ans = 3ll * ans % P;
		S += a[i];
	}
	f[0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = S; j >= a[i]; --j) {
			f[j] = (2ll * f[j] + f[j - a[i]]) % P;
		}
		for (int j = a[i] - 1; ~j; --j) {
			f[j] = 2ll * f[j] % P;
		}
	}
	for (int i = (S + 1) / 2; i <= S; ++i) {
		ans = (ans + 3ll * (P - f[i])) % P;
	}
	if (!(S & 1)) {
		for (int i = 0; i <= S; ++i) {
			f[i] = 0;
		}
		f[0] = 1;
		for (int i = 1; i <= n; ++i) {
			for (int j = S; j >= a[i]; --j) {
				f[j] = (f[j] + f[j - a[i]]) % P;
			}
		}
		ans = (ans + 3ll * f[S / 2]) % P;
	}
	print(ans);
}


Measured memory_bytes: 3980