akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int inival=0;
int N_;

struct RMQ{
    vector<int> data;
    int nodes;

    RMQ(int N){
        nodes=1;
        while(nodes<N) nodes*=2;
        data.resize(nodes*2);
        N_=(data.size()+1)/2;
        for(int i=0;i<data.size();++i) data[i]=inival;
    }

    void update(int k,int a){  //要素kをa
        k+=nodes-1;
        data[k]=a;
        while(k>0){
            k=(k-1)/2;
            data[k]=data[k*2+1]+data[k*2+2];
        }
    }

    int query(int a,int b,int k,int l, int r){ //mainから呼び出すときは(a,b,0,0,n)
        if(r<=a||b<=l)return 0;

        if(a<=l&&r<=b) return data[k];
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        //return min(vl,vr);
        return vl+vr;
    }

};
int main() {
    int N,Q; string S; cin>>N>>S>>Q;

    RMQ rmq[26]={N,N,N,N,N,N,N,N,N,N,
                 N,N,N,N,N,N,N,N,N,N,
                 N,N,N,N,N,N};
    //cout<<rmq[1].query(0,N,0,0,N)<<endl;
    //rmq[1].update(2,1);
    //cout<<rmq[1].query(0,N,0,0,N)<<endl;

    for (int i = 0; i < N; ++i) {
        rmq[S[i]-'a'].update(i,1);
    }
    //cout<<rmq[1].query(0,1,0,0,N_)<<endl;
    int t,k,l,r;
    char c;

    for (int i = 0; i < Q; ++i) {
        cin>>t;
        if(t==1){ //更新

            cin>>k>>c;
            //continue;
            --k;
            rmq[S[k]-'a'].update(k,0);
            S[k]=c;
            rmq[c-'a'].update(k,1);
        }else{
            cin>>l>>r; --l;
            int cnt=0;
            //cout<<"----"<<endl;
            for (int j = 0; j < 26; ++j) {

                if(rmq[j].query(l,r,0,0,N_)>0) {
                    ++cnt;
                    //cout<<j<<endl;
                }

            }
            //cout<<"++++"<<endl;
            cout<<cnt<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 109572
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let (k, x) = read!(i32, i32);
    let ans = ((x - k + 1)..(x + k))
        .map(|x| x.to_string())
        .collect::<Vec<_>>();
    println!("{}", ans.join(" "));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int N; cin >> N;
  int a[N][3];
  rep(i,N) cin >> a[i][0] >> a[i][1] >> a[i][2];

  vector<vector<int>> dp(N+1,vector<int>(3,0));
  rep(i,N){ // 配るdp
    rep(j,3){
      chmax(dp[i+1][(j+1)%3], dp[i][j] + a[i][(j+1)%3]);
      chmax(dp[i+1][(j+2)%3], dp[i][j] + a[i][(j+2)%3]);
    }
  }
  ll ans = *max_element(all(dp[N]));
  cout << ans << endl;

 

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 9824
package main
import (
  "fmt"
  "container/list"
)
const INF = 1<<30
func main() {
  var n int
  var s string
  fmt.Scan(&n)
  g := make([][]int,n)
  d := make([][]int,n)
  for i:=0;i<n;i++ {
    d[i] = make([]int,n)
    fmt.Scan(&s)
    for j,r := range s {
      if j != i { d[i][j] = INF }
      if r == '1' {
        g[i] = append(g[i],j)
        g[j] = append(g[j],i)
        d[i][j] = 1
      }
    }
  }
  c := make([]int,n)
  q := list.New()
  c[0] = 1
  q.PushBack(0)
  for q.Len() > 0 {
    i,_ := q.Remove(q.Back()).(int)
    for _,j := range g[i] {
      if c[j] == c[i] { fmt.Println(-1);return }
      if c[j] == 0 {
        c[j] = -c[i]
        q.PushBack(j)
      }
    }
  }
  for k:=0;k<n;k++ {
    for i:=0;i<n;i++ {
      for j:=0;j<n;j++ {
        if d[i][j] > d[i][k]+d[k][j] { d[i][j] = d[i][k]+d[k][j] }
      }
    }
  }
  m := 0
  for i:=0;i<n;i++ {
    for j:=0;j<n;j++ {
      if m < d[i][j] { m = d[i][j] }
    }
  }
  fmt.Println(m+1)
}

Measured memory_bytes: 2688
n = gets.to_i
dR = []
dB = []
n.times{dR << gets.split.map(&:to_i)}
n.times{dB << gets.split.map(&:to_i)}

dR = dR.sort_by{|a| a[1]}.reverse
dB = dB.sort_by{|a| a[0]}

ans = 0

dB.each do|b|
  n.times do |i|
    if dR[i][0] < b[0] && dR[i][1] < b[1]
      ans += 1
      dR[i][0] = 1000000
      dR[i][1] = 1000000
      break 
    end
  end
end

puts ans


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 998244353;
int N, S;
int A[3100];
ll dp[3100][3100];

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

  std::cin >> N >> S;

  for(int i=0;i<N;++i){
      std::cin >> A[i];
  }

  dp[0][0] = 1;

  for(int i=0;i<N;++i){
      for(int j=0;j<=S;++j){
          dp[i+1][j] = (dp[i+1][j] + 2ll * dp[i][j]) % MOD;
          if(j + A[i] <= S){
              dp[i+1][j+A[i]] = (dp[i+1][j+A[i]] + dp[i][j]) % MOD;
          }
      }
  }

  ll res = dp[N][S];
  std::cout << res << std::endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int n;
    string s;
    cin >> n >> s;

    int cnt = 0;
    rep(i, n){
        if(s[i] == 'E') cnt++;
    }

    int cnt_W = 0, ans = INF;
    for (int i = 0; i < n; ++i) {
        if(s[i-1] == 'W') cnt_W++;
        if(s[i] == 'E') cnt--;
        ans = min(ans, cnt + cnt_W);
    }


    cout << ans << endl;

    return 0;
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N, M, Q; cin >> N >> M >> Q;
    int L[M], R[M];
    rep(i,M){
        int Li, Ri;
        cin >> Li >> Ri;
        L[i] = Li; R[i] = Ri;
    }
    int p[Q], q[Q];
    rep(i,Q){
        cin >> p[i] >> q[i];
    }
    int sum[N+1][N+1];
    rep(i,N+1) rep(j,N+1) sum[i][j] = 0;
    rep(i,M) sum[L[i]][R[i]]++;
    rep(i,N+1){
        rep(j,N+1){
            sum[i][j] += sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
        }
    }
    rep(i,Q){
        int l = p[i], r = q[i];
        int ans = sum[r][r] - sum[r][l-1] - sum[l-1][r] + sum[l-1][l-1];
        cout << ans << endl;
    }
}

Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    char c;
    cin >> c;
    if(c=='Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.text.DecimalFormat;

public class Main{
    public static void main(String[] args) throws Exception{
        new Main().run();
    }
    void run() throws Exception{
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        boolean multiple = false;
        for(int tc = 1, tt = (multiple)?ni(in):1; tc<=tt; tc++)solve(in,out,tc);
        out.flush();
        out.close();
    }
    void solve(FastReader in, PrintWriter out, int TC) throws Exception{
        int n = ni(in);
        for(int i = 0; i*4<=n; i++){
            if((n-4*i)%7==0){
                pn(out, "Yes");
                return;
            }   
        }
        pn(out,"No");
    }
    void p(PrintWriter out, Object o){out.print(o);}
    void pn(PrintWriter out,Object o){out.println(o);}
    int ni(FastReader in){return Integer.parseInt(in.next());}
    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
} 


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int mod = 1e9 + 7;
const int MAXN = 222222;

int h, w, a, b;
lint fact[MAXN], invf[MAXN];

lint ipow(int x, int p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

lint path(int sx, int sy, int ex, int ey){
	int d = ex - sx;
	int e = ey - sy;
	return fact[d+e] * (invf[d] * invf[e] % mod) % mod;
}

int main(){
	fact[0] = invf[0] = 1;
	for(int i=1; i<MAXN; i++){
		fact[i] = fact[i-1] * i % mod;
		invf[i] = ipow(fact[i], mod - 2);
	}
	cin >> h >> w >> a >> b;
	lint ret = 0;
	for(int i=1; i<=w-b; i++){
		ret += path(1, 1, a, i) * path(a+1, i, h, w) % mod;
	}
	cout << ret % mod << endl;
}


Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main(void){
       int a,b;
       cin>>a>>b;
       if(a<b){
           cout<<b-a<<endl;
       }
       else if(a>b){
           cout<<a-b<<endl;
       }
       else cout<<"0"<<endl;
       
       return 0;
    
}


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



int main(){
    int n, l;
    cin >> n >> l;
    int eat = l;
    for(int i=2; i<=n; i++){
        if(abs(eat) > abs(l+i - 1)) eat = l+i - 1;
    }
    int ans = 0;
    for(int i = 1; i <=n; i++){
        ans += l+i - 1;
    }
    cout << ans - eat << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <cmath>

#define rep(i, n) for(int i=0; i<(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;

using namespace std;



lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;

bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> n >> m;

    lint ans = 0;

    if(n*2 < m)
    {
        //sが足りない
        ans = n;
        m-=n*2;
        n=0;

        //sを作る
        ans += m / 4;
        m -= (m / 4) * 4;
    }
    else
    {
        //cが足りない
        ans = m/2;
        n -= (m/2);
        m -= (m/2)*2;
        
        
    }
    


    while(1)
    {
        if(n>0)
        {
            n--;
        }
        else
        {
            m-=2;
        }

        m-=2;

        if(m>=0)
        {
            ans++;
        }
        else
        {
            break;
        }


    }

    cout << ans << endl;


//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

long long dfs(int idx, vector<bool> visited, const vector<vector<int>> &p){
    bool f = true;
    long long ans = 0;
    // cout << idx;
    for(int i = 0; i < visited.size(); i++){
        if(!visited[i]){
            f = false;
            break;
        }
    }
    if(f) return 1;
    for(int i = 0; i < p[idx].size(); i++){
        if(!visited[p[idx][i]]){
            visited[p[idx][i]] = true;
            ans += dfs(p[idx][i], visited, p);
            visited[p[idx][i]] = false;
        }
    }
    return ans;
}

int main(void){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> p(N);
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        p[--a].push_back(--b);
        p[b].push_back(a);
    }
    vector<bool> visited(N, false);
    visited[0] = true;
    cout << dfs(0, visited, p) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  998244353;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  int n, m, p;
  cin >> n >> m >> p;
  using Node = tuple<int, int, ll>;
  vector<Node> edges;
  REP(_, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;b--;
    edges.emplace_back(a, b, -c+p);
  }
  vector<ll> d(n, inf);
  d[0] = 0;
  REP(i, n - 1) {
    REP(j, m) {
      if(d[get<0>(edges[j])] == inf) continue;
      d[get<1>(edges[j])] = min(d[get<1>(edges[j])], d[get<0>(edges[j])] + get<2>(edges[j]));
    }
  }
  vector<bool> update(n, false);
  REP(i, 2 * n) {
    REP(j, m) {
      if(d[get<0>(edges[j])] == inf) continue;
      if(d[get<1>(edges[j])] > d[get<0>(edges[j])] + get<2>(edges[j])) {
        update[get<1>(edges[j])] = true;
        d[get<1>(edges[j])] = d[get<0>(edges[j])] + get<2>(edges[j]);
      }
    }
  }
  REP(i, n - 1) {
    REP(j, m) {
      if(d[get<0>(edges[j])] == inf) continue;
      if(update[get<0>(edges[j])]) {
        update[get<1>(edges[j])] = true;
      }
    }
  }
  if(update[n-1]) {
    cout << -1 << endl;
    return 0;
  }
  cout << max(-d[n-1], 0ll) << endl;
  return 0; 
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reps(i, m, n) for(ll i = m; i < n; i++)
#define reprs(i, m, n) for(ll i = n; i >= m; i--)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef long long ll;
typedef pair<ll, ll> pl;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

ll fu(ll b,ll nn){
  if(nn<b) return nn;
  return fu(b,floor(nn/b))+nn%b;
}

int main(){

  ll n,s;
  cin >> n >>s;

  ll x=floor(sqrt(n));


  reps(i,2,x+2){
    if(fu(i,n)==s) {
      std::cout << i << '\n';
      return 0;
    }
  }

  reprs(j,1,min(x,s)){
    if((n-s+j)%j==0&&(n-s+j)/j>x&&(n-s+j)/j<=n) {
      if(fu((n-s+j)/j,n)==s) {
        std::cout << (n-s+j)/j << '\n';
        return 0;}
    }
  }

  if(n==s) {
  std::cout << n+1 << '\n';
  return 0;}

  std::cout << -1 << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, k;
	cin >> n >> k;
	map<int, int> mop;
	for (int i = 0, x; i < n; i++)
		cin >> x, mop[x]++;
	vector<int> v;
	for (auto i : mop)
		v.pb(i.S);
	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 0; i + k < (int)v.size(); i++)
		ans += v[i];
	cout << ans;
	return 0;
}


Measured memory_bytes: 10744
N = gets.to_i
a = gets.split.map &:to_i

as = []

a.each_with_index{ |x, i|
	as << [x, i + 1] 
}

as.sort!{ |a,b| a[0] <=> b[0] }

puts as.map{ |x| x[1] }.join(" ")


Measured memory_bytes: 19440
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int a,b,x;
    cin >> a >> b >> x;
        if(b < x - a || x < a) cout << "NO";
        else cout << "YES";
        cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

int N;
int A[110];

int main() {
    cin >> N;
    REP(i,N)cin >>A[i];
    ll ans = 1e18;
    FOR(i,-100,101){
        ll sum = 0;
        REP(j,N){
           sum += (i - A[j])*(i - A[j]);
        }
        if(ans>sum)ans = sum;
    }
    PRI(ans)
    return 0;
}

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

int main() {
	int a, b; string s;
	cin >> a >> b >> s;
	for(int i  =0; i < s.size(); ++i){
		if(b-1!= i) cout << s[i];
		else cout << char(tolower(s[i]));
	}
	return 0;
}

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

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

  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  for(int i = 1; i < n; ++i) {
    string x = s.substr(0, i);
    string y = s.substr(i, s.length()-i);

    int cnt = 0;
    for(char c = 'a'; c <= 'z'; ++c) {
      bool isFoundX = false, isFoundY = false;
      rep(j, x.length()) {
        if(x[j]==c) isFoundX = true;
      }
      rep(j, y.length()) {
        if(y[j]==c) isFoundY = true;
      }
      if(isFoundX && isFoundY) ++cnt;
    }
    ans = max(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	ll n = s.size();
	ll dp[n+1][4] = {0};
	dp[0][0] = 1;
	FOR(i,0,n){
		FOR(j,0,4)dp[i+1][j] = dp[i][j];
		if(s[i]=='A'){
			dp[i+1][1] += dp[i][0];
		}
		if(s[i]=='B'){
			dp[i+1][2] += dp[i][1];
		}
		if(s[i]=='C'){
			dp[i+1][3] += dp[i][2];
		}
		if(s[i]=='?'){
			FOR(j,0,4)dp[i+1][j] += dp[i][j];
			FOR(j,0,4)dp[i+1][j] += dp[i][j];
			dp[i+1][1] += dp[i][0];
			dp[i+1][2] += dp[i][1];
			dp[i+1][3] += dp[i][2];
		}
		dp[i+1][0] %= MOD;
		dp[i+1][1] %= MOD;
		dp[i+1][2] %= MOD;
		dp[i+1][3] %= MOD;
	}
	cout << dp[n][3] << endl;
}


Measured memory_bytes: 3664
from collections import defaultdict
N=int(input())
ans=[]
d=defaultdict(int)
for _ in range(N):
    d[input()]+=1
maxv=max(d.values())
for i in d.keys():
    if d[i]==maxv:
        ans.append(i)
ans.sort()
[print(i) for i in ans]


Measured memory_bytes: 32860
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long cnt;
    char prev = '@';
    foreach (i; 0 .. S.length)
        if (prev != S[i])
        {
            prev = S[i];
            cnt++;
        }
    writeln(cnt - 1);
}


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

int main() {

	int n, m; cin >> n >> m;	
	vector<pair<int, int>> pa;
	vector<vector<int>> c(n);
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--;
		pa.push_back({ a,b });
		c[a].push_back(b);
	}
	for (int i = 0; i < c.size(); i++) {
		sort(c[i].begin(), c[i].end());		
	}
	for (int i = 0; i < m; i++) {
		int x = pa[i].second;
		int index = find(c[pa[i].first].begin(), c[pa[i].first].end(), x) - c[pa[i].first].begin();
		cout << setw(6) << setfill('0') << pa[i].first + 1 << setw(6) << setfill('0') << index + 1 << endl;
	}	
	return 0;
}

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

int main() {
    int h,w,n;
    cin >> h >> w >> n;
    int m = max(h,w);
    int ans = (n+m-1)/m;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using ll = long long;

ll solve(std::vector<ll> &dp, int n){
    if(n < 0) return 0;
    if(dp[n] != -1) return dp[n];
    dp[n] = solve(dp, n - 1) + solve(dp, n - 2);
    return dp[n];
}

int main(){
    int N;
    std::cin >> N;
    std::vector<ll> dp(N + 1, -1);
    dp[0] = 2; dp[1] = 1;
    std::cout << solve(dp, N) << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	void main()	{
		try(Scanner sc = new Scanner(System.in)){
			
				int x = sc.nextInt();
				System.out.println(x*x*x);
				
			
		}
    	
	}
	

    public static void main(String[] args) {

        new Main().main();

    }

}


Measured memory_bytes: 26380
from itertools import product


def patterns(w):
    res = []
    for pt in product([0, 1], repeat=w):
        valid = True
        for i in range(w - 1):
            if pt[i] == pt[i + 1] == 1:
                valid = False
                break
        if valid:
            res.append(pt)
    return res


def submit():
    h, w, k = [int(e) for e in input().split()]
    dp = [[0 for _ in range(w)] for _ in range(h + 1)]
    dp[0][0] = 1
    modp = 10 ** 9 + 7

    pts = patterns(w - 1)

    for i in range(1, h + 1):
        for j in range(w):
            for pt in pts:
                if j > 0 and pt[j - 1] == 1: # j -> j - 1に遷移する
                    dp[i][j - 1] += dp[i - 1][j]
                    dp[i][j - 1] %= modp
                elif j < w - 1 and pt[j] == 1:  # j -> j + 1に遷移する
                    dp[i][j + 1] += dp[i - 1][j]
                    dp[i][j + 1] %= modp
                else:
                    dp[i][j] += dp[i - 1][j]
                    dp[i][j] %= modp


    print(dp[h][k - 1])


submit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  REP(i, N) cin >> H[i];
  int ans = 0;
  int tmp = 0;
  REP(i, N - 1) {
    if (H[i] >= H[i + 1]) {
      tmp++;
    } else {
      tmp = 0;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int num = 1;
  for(int i=0; i<n; i++){
    if(num * 2 < num + k) num *= 2;
    else num += k;
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAX_N = 100000;
const int MAX_W = 10000;
typedef long long llong;

int n, k;
llong w[MAX_N];

int check(llong P) {
  int i = 0;
  for ( int j = 0; j < k; j++ ) {
    llong s = 0;
    while( s + w[i] <= P) {
      s += w[i];
      i++;
      if ( i == n ) return n;
    }
  }
  return i;
}

int solve() {
  llong left = 0;
  llong right = n * MAX_W;
  llong mid;
  while ( right - left > 1 ) {
    mid = (left + right) / 2;
    int v = check(mid);
    if ( v >= n ) right = mid;
    else left = mid;
  }

  return right;
}

int main() {
  cin >> n >> k;
  for ( int i = 0; i < n; i++ ) cin >> w[i];
  llong ans = solve();
  cout << ans << endl;

  return 0;
}


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

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u){
    for(int v = nt[u]; v < n; v++){
        nt[u] = v + 1;
        if(M[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r){
    for(int i = 0; i < n; i++) nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while(!S.empty()){
        int u = S.top();
        int v = next(u);
        if(v != -1){
            if(color[v] == WHITE){
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }else{
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs(){
    for(int i = 0; i < n; i++){
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    for(int u = 0; u < n; u++)
        if(color[u] == WHITE) dfs_visit(u);

    for(int i = 0; i < n; i++)
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
}

int main(){
    int u, k, v;

    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++) M[i][j] = 0;

    for(int i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        for(int j = 0; j < k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    dfs();
}



Measured memory_bytes: 3136
n,d= map(int,input().split())
d=d**2
Number=[]
Alphabet=[]
for i in range(n):
    a,b=input().split()
    Number.append(int(a))
    Alphabet.append(int(b))
s=0
for i in range(n):
    if Number[i]**2+Alphabet[i]**2<=d:
        s+=1
print(s)

Measured memory_bytes: 24836
S = input()
T = input()
S_LEN = len(S)
T_LEN = len(T)
ans_li = []
if S_LEN - T_LEN < 0:
    print("UNRESTORABLE")
else:
    for i in range(S_LEN - T_LEN + 1):
        is_ok = True
        for j in range(T_LEN):
            if S[i + j] != "?" and S[i + j] != T[j]:
                is_ok = False
                break
        if is_ok:
            tmp = S[:i] + T + S[i + T_LEN:]
            ans_li.append(tmp.replace("?", "a"))
    print(sorted(ans_li)[0]) if ans_li != [] else print("UNRESTORABLE")


Measured memory_bytes: 61880
#include<bits/stdc++.h>
using namespace std;
#define ff      first
#define ss      second
#define ll      int
#define ull     unsigned long long
#define mod     1000000007
#define vi      vector<ll>
#define ppi     pair<ll,pair<ll,ll>>
#define pb      push_back
#define mp      make_pair
#define str     string
#define pi      2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)    cout<<a;
#define sp(x,y) fixed<<setprecision(y)<<x
#define w(x)    ll x; cin>>x; while(x--)
#define e       cout<<'\n';
#define all(v)  v.begin(), v.end()
#define test    cout<<"BECOME_EXPERT_FAST"<<endl;
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
int32_t main() {
	kehsihba();
	int a,b;scanf("%d%d",&a,&b);
	double ret=0;
	for(int i=1;i<=a;i++){
	double tmp=1.0/a;
	int now=i;
	while(now<b){
	now*=2;
	tmp/=2;
	}
	ret+=tmp;
	}
	printf("%.12f\n",ret);
}







Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    string o, e, ans;
    cin >> o >> e;
    for (int i = 0; i < o.length(); ++i) {
        if(o[i] != '\0'){
            ans += o[i];
        }
        if(e[i] != '\0'){
            ans += e[i];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
 
int p[800];
int d[800];
int map[800][800];
int count[800];
 
void dp(int now,int old,int n,int now_dis,int* dis_max,int* point){
    int cost = 0;
    int i;
    for(i=0;i<n;i++){
        if(map[i][now] != 0 && i != old){
            if(count[i] == 1){
                if(now_dis > *dis_max){
                    *dis_max = now_dis;
                    *point = now;
                }
            }else{
                dp(i,now,n,now_dis+map[i][now],dis_max,point);
            }
        }
    }
}
 
int bridge(int n){
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            map[i][j] = 0;
        }
        count[i] = 0;
}
    for(i=1;i<n;i++){
        scanf("%d",&p[i]);
        p[i]--;
    }
    for(i=1;i<n;i++){
        scanf("%d",&d[i]);
        map[i][p[i]] = map[p[i]][i] = d[i];
        count[i]++;
        count[p[i]]++;
    }
 
    int cost = 0;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            if(count[i] == 1 || count[j] == 1) cost += map[i][j];
            else cost += (3 * map[i][j]);
        }
    }
 
    int point = -1;
    int maxint = -1;
    for(i=0;i<n;i++){
        if(count[i] > 1){
            dp(i,-1,n,0,&maxint,&point);
            break;
        }
    }
    maxint = -1;
    dp(point,-1,n,0,&maxint,&point);
    cost -= maxint;
    return cost;
}
 int main(){
    int n;
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        printf("%d\n",bridge(n));
    }
    return 0;
}

Measured memory_bytes: 3168
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  string A;;
  cin >> A;
  int i,I;
  for(i=0;i<A.size();i++)
    for(I=0;I<A.size();I++)
      if(A[i]==A[I+i+1]){
  cout << "no" << endl;

  return 0;
  }
  cout << "yes" << endl;
  return 0;
}



Measured memory_bytes: 256
S = input()

alpha = ["a", "b", "c", "d", "e", "f", "g",
        "h", "i", "j", "k", "l", "m", "n",
        "o", "p", "q", "r", "s", "t", "u",
        "v", "w", "x", "y", "z"]
S = list(set(S))
S.sort()
#print(len(S))
for i in range(len(S)):
    if S[i] != alpha[i]:
        print(alpha[i])
        break
    elif i == 25:
        print("None")
    elif i == len(S) - 1:
        print(alpha[i+1])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k;
  	cin>>k;
  	string st;
  	cin>>st;
  	int len = (int)st.size();
  	for (int i=0;i<min(len,k);i++) cout<<st[i];
  	if (len > k) cout<<"...";
  	cout<<endl;
  	return 0;
}


Measured memory_bytes: 3568
#include <iostream>

using namespace std;

int main(){
    int num=0;
    char S[4];
    cin >> S;
    for(int i=0;i<4;i++){
        if (S[i]-'+'==0){
            num++;
        }
        else if(S[i]-'-'==0){
            num--;
        }
    }
    cout << num <<endl;
}


Measured memory_bytes: 256
fun c98(args: Array<String>) {
    class SegTree(n: Int) {
        var size: Int = 0
        var tree: Array<Int> = emptyArray()

        init {
            var curr = 1
            while (curr < n) {
                curr *= 2
            }
            size = curr
            tree = Array(2 * size - 1) { 0 }
        }

        fun update(index: Int, value: Int) {
            var curr = index + (size - 1)
            tree[curr] += value
            while (curr != (curr - 1) / 2) {
                curr = (curr - 1) / 2
                tree[curr] += value
            }
        }

        fun sumOfW(fromInclusive: Int, toInclusive: Int): Int {
            fun sum(myIndex: Int, myFromInclusive: Int, myToInclusive: Int): Int {
                if (myFromInclusive > toInclusive || myToInclusive < fromInclusive) {
                    return 0
                }
                if (myFromInclusive >= fromInclusive && myToInclusive <= toInclusive) {
                    return tree[myIndex]
                }
                val left = sum(myIndex * 2 + 1, myFromInclusive, ((myFromInclusive + myToInclusive + 1) / 2) - 1)
                val right = sum(myIndex * 2 + 2, ((myFromInclusive + myToInclusive + 1) / 2), myToInclusive)
                return left + right
            }
            return sum(0, 0, size - 1)
        }

        fun sumOfE(fromInclusive: Int, toInclusive: Int): Int {
            return toInclusive + 1 - fromInclusive - sumOfW(fromInclusive, toInclusive)
        }
    }

    val num = args[0].toInt()
    val people = args[1]

    val segTree = SegTree(num)
    people.toCharArray().forEachIndexed { index, c ->
        if (c == 'W') {
            segTree.update(index, 1)
        }
    }

    var ans = Int.MAX_VALUE
    (0..num - 1).map {
        val left = if (it == 0) 0 else segTree.sumOfW(0, it - 1)
        val right = if (it == num - 1) 0 else segTree.sumOfE(it + 1, num - 1)
        if (ans > left + right) {
            ans = left + right
        }
    }

    println(ans)
}

fun main(args: Array<String>) {
    c98(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 73464
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    rep(i,3){
        if(s[i]==s[i+1]){
            cout << "Bad";
            return 0;
        }

    }
    cout << "Good";

    return 0;
}

Measured memory_bytes: 256
// ITP1_4

import java.util.Scanner;
import java.io.*;

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

		double a = 0.0;
		double b = 0.0;
		int d = 0;
		int r = 0;
		double f = 0.0;

		a = sc.nextInt ();
		b = sc.nextInt ();
		
		d = ( int )a / ( int )b;
		r = ( int )a % ( int )b;
		f = a / b;

		System.out.println ( d + " " + r + " " + String.format ( "%7f", f ) );
	}
}

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

int main()
{
  int N, ans=0, max=0;
  cin >> N;
  for(int i=0; i<N; ++i)
  {
    int c;
    cin >> c;
    ans += c;
    if(c > max) max = c;
  }
  cout << ans - max/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    char b;cin>>b;
    switch(b){
        case 'A':
            cout<<'T'<<endl;
            break;
        case 'T':
            cout<<'A'<<endl;
            break;
        case 'C':
            cout<<'G'<<endl;
            break;
        case 'G':
            cout<<'C'<<endl;
            break;
    }
}

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

#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define F first
#define S second

vector<pair<pair<int,int>,pair<int,int> > > v;

main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		v.PB(MP(MP(a,b),MP(0,0)));
	}
	for(int i=0;i<n;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		v.PB(MP(MP(a,b),MP(1,0)));
	}
	sort(v.begin(),v.end());
	int ans=0;
	for(int i=0;i<v.size();i++)
	{
		if(v[i].S.F)
		{
			int mi=2e9,whe=-1;
			for(int j=i-1;j>=0;j--)
			{
				if(!v[j].S.F&&!v[j].S.S&&v[j].F.S<v[i].F.S)
				{
					int nw=v[i].F.S-v[j].F.S;
					if(nw<mi)
					{
						mi=nw;
						whe=j;
					}
				}
			}
			if(whe!=-1)
			{
				ans++;
				v[whe].S.S=1;
			}
		}
	}
	printf("%d\n",ans);
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, k; cin >> n >> k;

    ll ans = 0;

    while (n > 0) {
        n /= k;
        ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
is_even s = iter x y
  where iter [] [] = True
        iter (x1:xs) (y1:ys)
          | x1 == y1 = iter xs ys
          | otherwise = False
        x = take len s
        y = drop len s
        len = div (length s) 2

solve s = iter $ reverse s
  where iter [] = 0
        iter (x1:x2:xs)
          | is_even(xs) = length xs
          | otherwise = iter xs

main = do
  s <- getLine
  print $ solve s


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

int main()
{
    int A,B,res;
    char c;

    cin >> A >> c >> B;

    if(c=='+'){
        res = A + B;
    }
    else if(c=='-'){
        res = A - B;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

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

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

//	for priority queue
//	priority_queue<ipair, vector<ipair>, greater<ipair>>
using ipair = pair<int, pair<int, int>>;
bool operator>(const ipair a, const ipair b) { return a.first > b.first; };
bool operator<(const ipair a, const ipair b) { return a.first < b.first; };

int main()
{
	int x, y;
	cin >> x >> y;
	
	bool ok = false;
	for (int i = 0; i <= x; i++)
	{
		int k = i * 2 + (x - i) * 4;
		if (k == y)
		{
			ok = true;
			break;
		}
	}

	if (ok)
		printf("Yes");
	else
		printf("No");
	return 0;
}


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


int main() {
    int N;
    cin >> N;
    int ds[N];
    for (int i = 0; i < N; i++) {
        cin >> ds[i];
    }
    sort(ds, ds + N);
    int a = ds[N/2 - 1];
    int b = ds[N/2];
    cout << (b - a) << "\n";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;

int n,a[N],b[N],ans;

int main(){
	cin>>n;
	for(int i=1;i<n;++i)cin>>b[i];
	b[n]=b[0]=1e9;
	for(int i=0;i<n;++i)ans+=min(b[i],b[i+1]);
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(10000)
N, M = map(int, input().split())
table = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    table[a-1].append(b-1)

visit = [False] * N
visit2 = [False] * N
g = []


def dfs(v):
    g.append(v)
    if visit[v]:
        return True
    visit[v] = True
    visit2[v] = True
    for u in table[v]:
        if dfs(u):
            return True
    g.pop()
    visit[v] = False
    return False


for i in range(N):
    g = []
    if not visit2[i]:
        if dfs(i):
            break
else:
    print(-1)
    exit()
print(0)
# ans = [v+1 for v in g[g.index(g[-1]):-1]]
# print(len(ans))
# print(*ans, sep="\n")


Measured memory_bytes: 3956
// https://atcoder.jp/contests/abc165/tasks/abc165_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, M, Q;
  cin >> N >> M >> Q;

  struct Const {
    ll a, b, c, d;
  };

  V<Const> cs(Q);

  rep(i, Q) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b;
    cs[i] = {a, b, c, d};
  }

  ll res = 0;

  repf(a1, 1, M + 1) repf(a2, a1, M + 1) repf(a3, a2, M + 1) repf(a4, a3, M + 1)
      repf(a5, a4, M + 1) repf(a6, a5, M + 1) repf(a7, a6, M + 1)
          repf(a8, a7, M + 1) repf(a9, a8, M + 1) repf(a10, a9, M + 1) {
    VL arr = {a1, a2, a3, a4, a5, a6, a7, a8, a9, a10};

    ll s = 0;
    for (auto c : cs)
      if (arr[c.b] - arr[c.a] == c.c) s += c.d;

    chmax(res, s);
  }

  cout << res << "\n";
}


Measured memory_bytes: 3660
N, M, X = map(int, input().split())
book_list = []
cost = [0] * (2 ** N)

cost_parform = []
for i in range(N):
    book_list.append(list(map(int, input().split())))
for i in range(2 ** N):
    bag = []
    rikaido = [0] * M
    for j in range(N):  # このループが一番のポイント
        if (i >> j & 1):
            bag.append(j)
    for k in bag:
        # print(bag)
        # print(bag[k])
        cost[i] = cost[i] + book_list[k][0]
        for m in range(M):
            rikaido[m] = rikaido[m] + book_list[k][m+1]

    count = 0
    for m in range(M):
        if rikaido[m] >= X:
            count += 1
    if count == M:
        cost_parform.append(cost[i])

if len(cost_parform) == 0:
    x = -1
    print(x)
else:
    print(min(cost_parform))

#print(cost_parform)

Measured memory_bytes: 9220