akhauriyash/Code-Regression huggingface dataset:
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( $ t : ty ;; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ;; ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let (n, k) = get!(usize, usize);

    if n % k == 0 {
        println!("0");
    } else {
        println!("1");
    }
}


Measured memory_bytes: 8572
@dx = [-1, 0, 1, 0]
@dy = [0, 1, 0, -1]
@field = []

def is_inside(x, y)
  return x >= 0 && y >= 0 && x < @field[0].length && y < @field.length
end

def count(x, y)
  ret = 1
  @field[y][x] = '#'
  (0 ... @dx.length).each do |i|
    if is_inside(x+@dx[i], y+@dy[i]) and @field[y+@dy[i]][x+@dx[i]] == '.' then
      ret += count(x+@dx[i], y+@dy[i])
    end
  end
  return ret
end

until (n, m = gets.split.map(&:to_i)) == [0, 0]
  @field = []
  m.times {@field << gets.chomp}
  x = 0
  y = 0
  (0 ... m).each do |i|
    x = @field[i].index('@')
    if x != nil then
      y = i
      break
    end
  end
  puts count(x, y)
end

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(a) (a).begin(),(a).end()

int main() {
    vector<int> a(10);
    REP(i, 10) cin >> a[i];
    sort(ALL(a), greater<int>());
    REP(i, 3) cout << a[i]<< endl;
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int N; cin >> N;
  int odd = 0;
  rep(i, N) {
    int A; scanf("%d", &A);
    if(A%2) ++odd;
  }
  printf("%s\n", odd%2?"NO":"YES");
}


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

int main(){
  int n;
  int un=1;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1]){
      un++;
    }
  }
  cout<<un<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
  char S[4];
  scanf("%s", &S);
  int i, N[4], A, B, flag = 0;
  for (i=0; i<4; i++){
    N[i] = S[i] - '0';
  }

  A = N[0]*10 + N[1];
  B = N[2]*10 + N[3];

  if (A>12 || A == 0){//year
    if (B>12 || B == 0){//year
      printf("NA");
    }else{
      printf("YYMM");
    }
  }else{
    if (B>12 || B == 0){//year
      printf("MMYY");
    }else{
      printf("AMBIGUOUS");
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
import heapq
n, m = map(int, input().split())
a = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(a)
for _ in range(m):
    min = ((heapq.heappop(a) * (-1)) // 2) * (-1)
    heapq.heappush(a, min)
print(sum(a)*(-1))

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

int kindmax=-1,i,j,k;

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

    int vec[n][n];

    for(i=0;i<n;i++){//1スタートにするとallゼロの場合を逃すので不可
        for(j=0;j<n;j++){
            vec[i][j]=-1;//証言無し
        }
    }

    for(i=0;i<n;i++){//証人の番号
        int a;cin>>a;//証言の個数
        for(j=0;j<a;j++){
            int x,y;
            cin>>x>>y;x--;
            vec[i][x]=y;
        }
    }

    
    
    for(i=0;i<(1<<n);i++){//iはn人の人が正直か不親切かを割り当てる
        int num=0;//正直者の人数    
        bool AC=true;//全体で矛盾がないか

        for(j=0;j<n;j++){//j人目の証言について
            if((i>>j)&1){//honestの時のみ調べる
                for(k=0;k<n;k++){
                    if(vec[j][k]==-1){continue;}//-1は証言無し
                    if(vec[j][k]!=((i>>k)&1)){AC=false;}//証言が間違い->矛盾
                }
                num++;
            }
        }
        if(AC){if(kindmax<num){kindmax=num;}}
    }

    cout<<kindmax<<endl;
    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

LL gcd(LL x, LL y) {
    return y ? gcd(y, x%y) : x;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int k;cin >> k;
    LL ans = 0;
    inc(i, 1, k+1){
        inc(j, 1, k+1){
            inc(l, 1, k+1){
                ans += gcd(gcd(i, j), l);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Wall solver = new Wall();
        solver.solve(1, in, out);
        out.close();
    }

    static class Wall {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int h = in.nextInt();
            int w = in.nextInt();

            int[][] c = new int[10][10];
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    c[i][j] = Integer.parseInt(in.next());
                }
            }
            warshallFloyd(c);

            long result = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    int v = Integer.parseInt(in.next());
                    if (v == -1 || v == 1) {
                        continue;
                    }
                    result += c[v][1];
                }
            }
            out.println(result);

        }

        static void warshallFloyd(int[][] g) {
            int n = g.length;
            for (int k = 0; k < n; k++) {
                for (int i = 0; i < n; i++) {
                    if (g[i][k] == Integer.MAX_VALUE) {
                        continue;
                    }
                    for (int j = 0; j < n; j++) {
                        if (g[k][j] == Integer.MAX_VALUE) {
                            continue;
                        }
                        g[i][j] = Math.min(g[i][j], g[i][k] + g[k][j]);
                    }
                }
            }
        }

    }
}



Measured memory_bytes: 54780
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using std::setprecision;
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main(){
  double x,y,s;
  double d1,d2;
  double b,c;
  int max = 0;

  while(cin >> x >> y >> s){
    if(x == 0 && y == 0){
      break;
    }
    max = 0;

    for(int i = 1;i < s ; i++){
      for(int j= 1; j < s; j++){
        b = double(i) +double(i) *(x/100.0);
        c = double(j) + double(j)*(x/100.0);
        if(s == int(b) + int(c)){
          b = double(i)  + double(i) *  (y/100.0);
          c = double(j) + double(j) * y/100.0;
          if(max == 0 || max < int(b) + int(c)){
            max = int(b) + int(c);
          }
        }
      }
    }

    cout << max << endl;

  }
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long int n,a,b,low=0,mid,high=2e9,count=0,i;
        cin>>n>>a>>b;
        vector<long long int> v(n);
        for(int i=0;i<n;i++)
            cin>>v[i];
        while(low<=high)
        {
            count=0;
            mid=(low+high)/2;
            for(int x=0;x<v.size();x++)
            {
                i=v[x];
                if(i>mid*b)
                    count+=ceil((1.0*(i-mid*b))/(a-b));
            }
            if(count<=mid)
                high=mid-1;
            else
                low=mid+1;
        }
        cout<<high+1;
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i,j;
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    VI p(a);
    VI q(b);
    VI r(c);
    for(i=0;i<a;i++) cin>>p[i];
    for(i=0;i<b;i++) cin>>q[i];
    for(i=0;i<c;i++) cin>>r[i];
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    sort(r.begin(),r.end());
    ll ps[a+1];
    ll qs[b+1];
    ll rs[c+1];
    ps[0]=0;
    for(i=1;i<=a;i++) ps[i]=ps[i-1]+p[i-1];
    qs[0]=0;
    for(i=1;i<=b;i++) qs[i]=qs[i-1]+q[i-1];
    rs[0]=0;
    for(i=1;i<=c;i++) rs[i]=rs[i-1]+r[i-1];
    ll ans=-1;
    for(i=0;i<=x;i++){
        if(x-i>r.size()) continue;
        ll cnt=ps[a]-ps[a-i];
        ll le=-2,ri=inf;
        while(ri-le>1){
            int m=(ri+le)/2;
            ll u1=q.end()-lower_bound(q.begin(),q.end(),m);
            ll u2=r.end()-lower_bound(r.begin(),r.end(),m);
            u2 -= (x-i);
            if(u2<0) u2=0;
            if(u1+u2>=y) le=m;
            else ri=m;
        }
        if(le<0) continue;
            ll u1=q.end()-lower_bound(q.begin(),q.end(),le);
            int qq=lower_bound(q.begin(),q.end(),le)-q.begin();
            ll u2=r.end()-lower_bound(r.begin(),r.end(),le);
            u2 =max(u2,x-i);
            ll sum2=cnt+qs[b]-qs[b-u1]+rs[c]-rs[c-u2]-(u1+u2-y-x+i)*le;
            ans = max(ans,sum2);
        }
    cout<<ans<<endl;


}

Measured memory_bytes: 4992
#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 rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    double X;cin >> X;
    double T = 100;
    LL tmp = 0;
    int ans = 0;
    for(int i = 1;i <= 5000;i++){
        T *= 1.01;
        tmp = T;
        T = tmp;
        if(X <= T){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3724
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readLong() = readLn().toLong()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map(String::toInt)
private fun readLongs() = readStrings().map(String::toLong)

fun main() {
    val n = readInt()
    val a = readInts()
    println(a.filterIndexed { index, i -> index % 2 == 0 && i % 2 == 1 } .size)
}

Measured memory_bytes: 36484
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = get!(String);
    let len = s.len();
    let mut i = 0;
    while i < len {
        i += 1;
        let l = len - i;
        if l%2 == 1 { continue; }
        let ss = &s[0..l];
        if &ss[0..l/2] == &ss[l/2..l] {
            println!("{}", l);
            return;
        }
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

struct BIT{
private:
    vector<ll> bit;
    int N;
public:
    BIT(){init();}
    BIT(int N):N(N){init();}
    void init(){
        bit.clear();
        bit.resize(N+1,0);
    }
    ll sum(int i){
        ll s = 0;
        while(i>0){
            s += bit[i];
            i -= i&-i;
        }
        return s;
    }
    ll sum_range(int l,int r){
        return (sum(r)-sum(l-1));
    }
    void add(int i,ll x){
        while(i<=N){
        bit[i] += x;
        i += i&-i;
        }
    }
    ll sum0(int i){
        return sum(i+1);
    }
    void add0(int i,ll x){
        add(i+1,x);
    }
};


int Q;
ll query[200010][3];

int main(){
    cin >> Q;
    ll suma = 0,sumb = 0;
    vector<pair<ll,int>> compress;
    map<ll,int> m;
    for(int i=1;i<=Q;i++){
        cin >> query[i][0];
        if(query[i][0]==1){
            cin >> query[i][1] >> query[i][2];
            compress.push_back({query[i][1],i});
            sumb += query[i][2];
        }
    }
    compress.push_back({(ll)-2e9,0});
    sort(compress.begin(),compress.end());
    int N = compress.size();
    BIT resA(N),search(N);
    for(int i=1;i<N;i++){
        m[compress[i].second] = i;
        resA.add(i,compress[i].first);
        search.add(i,1);
        suma += abs(compress[i].first-compress[N/2].first);
    }
    vector<pair<ll,ll>> ans;
    ll n = N-1;
    ll argmin = compress[N/2].first;
    for(int i=Q;i>=1;i--){
        if(query[i][0]==2) ans.push_back({argmin,suma+sumb});
        else{
            sumb -= query[i][2];
            resA.add(m[i],-query[i][1]);
            search.add(m[i],-1);
            n--;
            ll l = 0,r = N;
            while(l+1<r){
                ll mid = (l+r)/2;
                if(search.sum_range(1,mid)>=(n+1)/2) r = mid;
                else l = mid;
            }
            argmin = resA.sum_range(r,r);
            suma = resA.sum_range(r+1,N-1)-resA.sum_range(1,r-1)-argmin*(n%2==0);
/*            cerr << r << endl;
            for(int i=1;i<=N-1;i++){
                cerr << resA.sum_range(i,i) << " ";
            }
            cerr << endl;
*/        }
    }
    reverse(ans.begin(),ans.end());
    for(auto x:ans) cout << x.first << " " << x.second << endl;
}

Measured memory_bytes: 24172
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define fa(a,c) for(auto &a:c)
#define yes "YES"
#define no "NO"




int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
ll a;
string s;
  cin>>a>>s;
if(a<3200) cout<<"red"<<endl;
else cout<<s<<endl;




	return 0;
}


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


Measured memory_bytes: 256
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(auto &x : A) cin >> x;

    int cnt = 0, idx = 0;
    while(1){
        if(cnt > n){
            cout << -1 << endl;
            break;
        }else{
            cnt++;
            if(A[idx] == 2){
                cout << cnt << endl;
                break;
            }
            else idx = A[idx] - 1;
        }
    }
    


    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#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=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

        string ToAlphabet(ll self)
        {
            if (self <= 0) return "";
            int n = self % 26;
            //n = (n == 0) ? 26 : n;
            char s = (char)(n + 'a');
            if (self == n) return "" + s;
            return ToAlphabet((self - n) / 26) + s;
        }
  
int main()
{
  ll N; cin >> N;
  string ans; int mod; ll tmp=0; ll max=0; ll X = N;
  if(N==0){cout << 'a' << endl;return 0;}
  do{
      mod = N % 26; 
      if(mod!=0){N-=mod;mod--;}else{N-=26;mod=25;}
      N = (ll)(N / 26);
      ans = (char)('a'+mod) + ans;
      tmp++;
  }while(N>0);
  //ans = ToAlphabet(N);
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K;cin >> N >> K;
  vector<ll> v(N+1,0);
  rep(i,N)cin >> v[i+1];
  rep(i,N) v[i+1] += v[i];

  map<ll,int> mp;
  rep(i,N) repp(j,i+1,N+1) ++mp[v[j] - v[i]];
  int M = 0;
  vector<PLI> w(mp.size());
  for(const PLI m : mp) w[M++] = m;
  ll x = 0;
  vector<bool> prv(M,true);
  int n_2 = 0;
  while((1ll<<n_2) <= v[N]) ++n_2;
  per(n,n_2){
    int count = 0;
    ll n_ = 1ll<<n;
    vector<bool> nxt(M,false);
    rep(i,M){
      if(!prv[i])continue;
      if(w[i].first&n_){
        count+=w[i].second;
        nxt[i] = true;
      }
    }
    if(count >= K){
      swap(prv,nxt);
      x |= n_;
    }
  }
  cout << x << endl;
  return 0;
}



Measured memory_bytes: 39552
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    vector<vector<char>> S(H, vector<char>(W));
    for(ll i=0;i<H;i++){
       for(ll j=0;j<W;j++){
           cin>>S[i][j]
       ;}
    ;}
    bool ans=1;
    for(ll i=0;i<H;i++){
       for(ll j=0;j<W;j++){
           if(S[i][j]=='#'){
               if(i-1>=0&&S[i-1][j]=='#')continue;
               if(i+1<H&&S[i+1][j]=='#')continue;
               if(j-1>=0&&S[i][j-1]=='#')continue;
               if(j+1<W&&S[i][j+1]=='#')continue;
               ans=0;
           }
       ;}
    ;}
    if(ans)print("Yes");
    else print("No");

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Sum of Integers II
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n, s;
			n = parseInt(line.substring(0, line.indexOf(' ')));
			s = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | s) == 0) return;

			long[][] dp = new long[n + 1][s + 1];

			dp[0][0] = 1;
			dp[1][0] = 1;

			for (int i = 1; i <= 100; i++) {
				for (int j = n; j >= 1; j--) {
					for (int k = i; k <= s; k++) {
						dp[j][k] += dp[j - 1][k - i];
					}
				}
			}

			System.out.println(dp[n][s]);
		}
	}
}

Measured memory_bytes: 26456
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

constexpr int MAXN = 100005;
int n;
int sod[MAXN];

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

    scanf(" %d", &n);
    for (int i = 0; i < 10; ++i) {
        sod[i] = i;
    }
    for (int i = 10; i <= n; ++i) {
        sod[i] = sod[i / 10] + (i % 10);
    }

    int ans = 1e9 + 7;
    for (int a = 1; a < n; ++a) {
        ans = min(ans, sod[a] + sod[n - a]);
    }

    printf("%d\n", ans);
    
    return 0;
}


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

int main() {
    string S;
    cin >> S;
    vector<int> v(4);
    for (int i = 0; i < 4; i++) {
        v[i] = S[i] - '0';
    }

    for (int i = 0; i < 8; i++) {
        int n = i;
        int result = v[0];
        string ans = to_string(v[0]);
        for (int j = 1; j <= 3; j++) {
            if (n % 2 == 0) {
                result += v[j];
                ans += "+" + to_string(v[j]);
            } else {
                result -= v[j];
                ans += "-" + to_string(v[j]);
            }
            n /= 2;
        }
        if (result == 7) {
            ans += "=7";
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int n;
    int w[100];
    int i;
    int s[2]={0,0};
    int sum=0;
    int k;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
        sum+=w[i];//printf("i,sum=%d,%d\n",i,sum);
    }
    
    i=0;
    while(s[0]<sum/2){
        s[0]+=w[i];
        i++;//printf("i,s=%d,%d\n",i,s[0]);
    }

    i=n-1;
    while(s[1]<sum/2){
        s[1]+=w[i];
        i--;//printf("i,s=%d,%d\n",i,s[0]);
    }
    //printf("0,1=%d,%d\n",s[0],s[1]);
    if(s[0]>s[1]){
        s[0]=s[1];//printf("0,1=%d,%d\n",s[0],s[1]);
    }
    s[1]=sum-s[0];

    printf("%d\n",abs(s[0]-s[1]));
    return 0;
}

Measured memory_bytes: 128
N,K=map(int,input().split())

result=0

if K%2==1:
    #全てKの倍数でないといけない
    result=(N//K)**3
else:
    #全てKの倍数
    result=(N//K)**3

    #またはすべて余りがk/2でなければならない
    if (N//K)*K+K/2<=N:
        result+=(N//K+1)**3
    else:
        result+=(N//K)**3

print(result)


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

const int INF = 1e9;
using lint = long long;
const lint LINF = 1e18;
#define bit(n) ((lint)1 << n);

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

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

    int n, m;
    cin >> n >> m;
    vector<lint> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<pair<int, lint>> bc(m);
    for (int i = 0; i < m; i++) {
        cin >> bc[i].first >> bc[i].second;
    }
    sort(bc.begin(), bc.end(), [](pair<int, lint> p, pair<int, lint> q) {
        return p.second > q.second;
    });

    int pos = 0;
    for (int i = 0; i < m; i++) {
        int b = bc[i].first, c = bc[i].second;
        while (b > 0 and pos < n) {
            if (a[pos] < c) {
                a[pos] = c;
                pos++;
                b--;
            } else {
                goto END;
            }
        }
    }

    END:
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        ans += a[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(x);
    out(x < 1200 ? "ABC" : "ARC");
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rei register int
using namespace std;
char s[2000],t[2000];
int main(){
	scanf("%s",s + 1);
	scanf("%s",t + 1);
	int lens = strlen(s + 1),lent = strlen(t + 1);
	int ans(0x7f7f7f7f);
	for(rei i = 1;i <= lens;++i){
		int cnt(0); if(i + lent - 1 > lens) continue;
		for(rei j = 1;j <= lent;++j) if(s[i + j - 1] != t[j]) ++cnt;
		ans = min(ans,cnt);
	} cout << ans; return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    int n; cin >> n;
    map<int,int> od;
    map<int,int> ev;
    rep(i, n) {
        int v; cin >> v;
        if(i&1) od[v]++;
        else ev[v]++;
    }
    if(od.size()==1 && ev.size()==1 && ev.begin()->first == od.begin()->first) {
        cout << n/2;
        return 0;
    }
    int ban = 0;
    int mx_e = 0;
    for(auto it=ev.begin();it!=ev.end();it++) {
        if(mx_e < it->second) {
            mx_e = it->second;
            ban = it->first;
        }
        //mx_e = max(mx_e, it->second);
    }
    int mx_o = 0;
    for(auto it=od.begin();it!=od.end();it++) {
        if(it->first == ban) continue;
        mx_o = max(mx_o, it->second);
    }
    int ans = 0;
    //printf("%d %d\n",ban,mx_o);
    ans += (n+1)/2 - mx_e;
    ans += n/2 - mx_o;
    //cout << ans;
    int ans2 = 0;
    ban = 0;
    mx_o = 0;
    mx_e = 0;
    for(auto it=od.begin();it!=od.end();it++) {
        if(mx_o < it->second) {
            mx_o = it->second;
            ban = it->first;
        }
    }
    for(auto it=ev.begin();it!=ev.end();it++) {
        if(it->first == ban) continue;
        mx_e = max(mx_e, it->second);
    }
    ans2 += (n+1)/2 - mx_e;
    ans2 += n/2 - mx_o;
    cout << min(ans, ans2);
}


Measured memory_bytes: 4992
#include <cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
vector<ll>to[100005];
int main() {
	ll n, m;
	cin >> n >> m;
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	vector<ll>dist(n, inf);
	vector<ll>pre(n, -1);
	queue<ll>que;
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();
		for (int id : to[v]) {
			if (dist[id] != inf)continue;
			dist[id] = dist[v] + 1;
			pre[id] = v + 1;
			que.push(id);
		}
	}
	cout <<"Yes"<< endl;
	for (int i = 1; i < n; i++) {
		cout << pre[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 13736
N, M, C = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
A = N.times.map { gets.split.map(&:to_i) }

puts N.times.select {|i|
  sum = M.times.inject(0) {|acc, j|
    acc + A[i][j] * B[j]
  } + C

  sum > 0
}.size

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

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

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

    set<int> s;
    for(int i = 0; i < n; i++){
        s.insert(v[i]);
    }
    cout << s.size() << endl;
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i64 N;
    cin >> N;
    i64 min_d = N + 1;
    for (i64 i = 2; i * i <= N; i++) {
        if (N % i == 0 && min_d > i + N / i) min_d = i + N / i;
    }
    cout << min_d - 2 << endl;

}


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

vector<int> v[100010];
bool vis[100010];
int ans,n,m,dist[100010];

int dfs(int u,int pr)
{
	vis[u]=1;
	int sum=1,maxv=0;
	for(int i=0;i<v[u].size();i++) if(v[u][i]!=pr){
		int val;
		if(dist[v[u][i]]==0) val=dfs(v[u][i],u);
		else val=dist[v[u][i]];
		maxv=max(maxv,val);
	}
	sum+=maxv;
	dist[u]=sum;
	return sum;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			ans=max(ans,dfs(i,-1));
		}
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 9600
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String n = sc.next();
		String ans = "";
		for(int i = 0; i < n.length(); i++){
			if(n.charAt(i) == '1') ans += "9";
			else if(n.charAt(i) == '9') ans += "1";
			else ans += n.charAt(i);
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#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 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;else 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;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<ll> k(3);
	cin >> k[0] >> k[1] >> k[2];
	SORT(k);
	cout << k[0]+k[1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int b[n] = {0};
  for (int i = 0; i < m; i++) {
    int q, w;
    cin >> q >> w;
    if (a[q-1] >= a[w-1]) {
      b[w-1] = 1;
    }
    if (a[w-1] >= a[q-1]) {
      b[q-1] = 1;
    }
  }
  long long count = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] == 0) count++; 
  }
  cout << count << '\n';
}

Measured memory_bytes: 4420
S = input()
N = len(S)

ans = 0
for i in range(2 ** (N - 1)):
    ptn = [' '] * (N - 1)
    for j in range(N - 1):
        if (i >> j) & 1:
            ptn[len(ptn) - j - 1] = '+'

    formula = ''.join([n + op for n, op in zip(list(S), ptn + [''])]).replace(' ', '')
    ans += eval(formula)

print(ans)

Measured memory_bytes: 9052
function main(arg) {
  const input = arg.split('\n');
  const ary = input[1].split(' ');
  
  var tmp = 0;
  for(var i = 0; i <input[0]; i++){
    tmp += 1/ary[i];
  }
  console.log(1/tmp);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct LongestCommonSubstring{
  struct node{
    int value;
    node *next;
    node(int value,node *next):value(value),next(next){}
  };
  const int INF=1LL<<55LL;
  string x,y;
  LongestCommonSubstring(){}
  LongestCommonSubstring(string x,string y):x(x),y(y){}
  string lcs(){
    int n=x.size(),m=y.size();
    map<char,vector<int> > M;
    for(int j=m-1;j>=0;j--) M[y[j]].push_back(j);
    vector<int> xs(n+1,INF);
    xs[0]=-INF;
    vector<node* > link(n+1);
    for(int i=0;i<n;i++){
      if(M.count(x[i])){
	vector<int> ys=M[x[i]];
	for(int j=0;j<(int)ys.size();j++){
	  int k=distance(xs.begin(),lower_bound(xs.begin(),xs.end(),ys[j]));
	  xs[k]=ys[j];
	  link[k]=new node(y[ys[j]],link[k-1]);
	}
      }
    }
    string res;
    int l=distance(xs.begin(),lower_bound(xs.begin(),xs.end(),INF-1))-1;
    for(node *p=link[l];p!=NULL;p=p->next)
      res.push_back(p->value);
    return res;
  }
};
//END CUT HERE
signed main(){
  int q;
  cin>>q;
  while(q--){
    string x,y;
    cin>>x>>y;
    LongestCommonSubstring lcs(x,y);
    cout<<lcs.lcs().size()<<endl;
  }
  return 0;
}
/*
verified on 2017/06/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C
*/

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

std :: vector < int > v ;
std :: unordered_set < int > S ;
std :: unordered_map < int, int > cnt ;

int main ( )  {
	int n, k ;
	scanf ( "%d%d", & n, & k ) ;

	for ( int i = 1 ; i <= n ; ++ i )  {
		int x ;
		scanf ( "%d", & x ) ;

		S.insert ( x ) ;
		++ cnt [x] ;
	}

	for ( std :: unordered_set < int > :: iterator it = S.begin ( ) ; it != S.end ( ) ; ++ it )  {
		v.push_back ( cnt.find ( * it ) -> second ) ;
	}

	std :: sort ( v.begin ( ), v.end ( ), [&] ( const int& a, const int& b ) {  return a > b ;  } ) ;

	int ans ( 0 ) ;

	for ( int i = k ; i < ( int ) v.size ( ) ; ++ i )  {
		ans += v [i] ;
	}

	return ! printf ( "%d\n", ans ) ;
}


Measured memory_bytes: 18576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
#define N 200010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,a,b,c,d;
char s[N];
signed main()
{
	n=read(),a=read(),b=read(),c=read(),d=read();
	scanf("%s",s+1);
	for (int i=1;i<n;i++) if (s[i]=='#'&&s[i+1]=='#'&&(a<=i&&c>i||b<=i&&d>i)) {cout<<"No";return 0;}
	if (c>d)
	{
		int pos=-1;
		for (int i=b;i<=d;i++) if (s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.') {pos=i;break;}
		if (pos==-1) {cout<<"No";return 0;}
		else cout<<"Yes";
	}
	else cout<<"Yes";
	return 0;
	//NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

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

	int N; cin >> N;
	vector<ll> B(100010, 0);

	ll ans = 0;

	for (int i = 0; i < N; i++) {
		ll a; cin >> a;
		B[a]++;
		ans += a;
	}

	int Q; cin >> Q;
	for (int q = 0; q < Q; q++) {
		ll b, c; cin >> b >> c;
		ll x = B[b];
		B[b] = 0;
		B[c] += x;

		ans += x * (c - b);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3564
<?php
  	$n = readline();
	$sor = readline();
	$ex = explode(" ", $sor);
	
	$avg = 0;
	$sum = 0;

	for($i = 0; $i<$n; $i++){
    	$sum = $sum+$ex[$i];
    }

	$avg = $sum/$n;
	$fel = ceil($avg);
	$le = floor($avg);

	$pFel = 0;
    $pLe = 0;

	for($i = 0; $i<$n; $i++){
    	$pFel = $pFel + (($ex[$i] - $fel)*($ex[$i] - $fel));
        $pLe = $pLe + (($ex[$i] - $le)*($ex[$i] - $le));
    }

if($pLe < $pFel){
  	echo $pLe;
}else{
 	echo $pFel;
}

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

int main(){
    
    // 1. 入力情報.
    double a, b, x;
    scanf("%lf %lf %lf", &a, &b, &x);
    
    // 2. 水筒を傾ける.
    double pi = acos(-1);
    // printf("pi=%.10lf\n", pi);
    double bottle = a * a * b;
    double theta = 0.0;
    
    // 2-1. 側面が台形(水が半分以上: x >= 0.5 * bottle)となる場合.
    // trapezoid = (a * b) - 0.5 * a * a * tan(θ)
    // x = a * trapezoid = bottle - 0.5 * a * a * a * tan(θ);
    // から, 角度を逆算してみる.
    if(x >= 0.5 * bottle) theta = atan((bottle - x) / (0.5 * a * a * a)) * 180.0 / pi;
    
    // 2-2. 側面が直角三角形(水が半分未満: x < 0.5 * bottle)となる場合.
    // triangle = 0.5 * b * b * tan(90 - θ)
    // x = a * triangle = 0.5 * a * b * b * tan(90 - θ)
    if(x < 0.5 * bottle) theta = 90.0 - atan(x / (0.5 * a * b * b)) * 180.0 / pi;
    
    // 3. 出力 ～ 後処理.
    printf("%.10lf\n", theta);
    return 0;
    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D,X;
  cin >> N >> D >> X;
  int ans = 0;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    int j = 1;
    while(j<=D){
      ans++;
      j+= a;
    }
  }
  cout << ans+X << endl;
}

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

class Main{
    static int largest;
    static int l,r,H;
    static int[] A;
    public static void main(String args[]){
	int i,j;
	A = new int[500001];
	try{
	    BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
	    String str = buffer.readLine();
	    H = Integer.parseInt(str);
	    StringTokenizer st = new StringTokenizer(buffer.readLine());
	    for(i=1;i<=H;i++){
		A[i] = Integer.parseInt(st.nextToken());
	    }
	}catch(Exception e){
	    System.out.println("error");
	}
	buildMaxHeap(A);
	StringBuffer sb = new StringBuffer();
	for(i=1;i<=H;i++){
	    sb.append(" "+A[i]);
	}
	System.out.println(sb);	
    }

    static void buildMaxHeap(int A[]){
	int i;
	for(i=H/2;i>0;i--){
	    maxHeapify(A,i);
	}
    }

    static int left(int x){
	return 2*x;
    }
    static int right(int x){
	return 2*x+1;
    }
    static void maxHeapify(int A[],int i){
	int temp;
	l = left(i);
	r = right(i);
	if(l <= H && A[l] > A[i]){
	    largest = l;
	}
	else{largest = i;}

	if(r <= H && A[r] > A[largest]){
	    largest = r;
	}
	if(largest != i){
	    temp = A[i];
	    A[i] = A[largest];
	    A[largest] = temp;
	    maxHeapify(A,largest);
	}
    }
}



Measured memory_bytes: 80612
X, Y, A, B, C = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

ANS_list = P[:X]
ANS_list.extend(Q[:Y])
ANS_list.sort()
c = 0
for i in range(len(R)):
  if ANS_list[i] >= R[i]:
    break
  c+=1

if i!=0:
  ANS_list[:c] = R[:c]
print(sum(R[:c])+sum(ANS_list[c:]))

Measured memory_bytes: 23328
n = int(input())
memo = dict()
for i in range(1,n+1):
    string_i = str(i)
    com = (string_i[0], string_i[-1])
    if com in memo:
        memo[com] += 1
    else:
        memo[com] = 1
ans = 0
for i in range(1,n+1):
    string_i = str(i)
    com = (string_i[-1], string_i[0])
    if com in memo:
        ans += memo[com]
print(ans)

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

void solve(std::string s)
{
    long long S_size = s.size();
    cout << s[0] << S_size - 2 << s[S_size - 1] << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	int N;
	getval(N);

	int ans = 0;
	if (N % 1000) {
		ans = 1000 - N % 1000;
	}
	printf("%d\n", ans);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  ll x;
  cin>>x;
  cout<<x/500*1000+(x%500)/5*5<<'\n';
  return 0;
}


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

using namespace std;
int main()
{
    string s;
    cin >> s;
    int l = s.length();
    bool f1 = 1, f2 = 1;
    for(int i = 0; i < l; i += 2)
        if(!(s[i]=='R'||s[i]=='U'||s[i]=='D'))
            f1 = 0;
    for(int i = 1; i < l; i+= 2)
        if(!(s[i]=='L'||s[i]=='U'||s[i]=='D'))
            f2 = 0;
    if(f1 && f2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double a, b;
	int A, B;
	scanf("%d%d", &A, &B);
	a = (double)A;
	b = (double)B;
	printf("%d %d %f\n", A / B, A % B, a / b);
	return 0;
}

Measured memory_bytes: 1796
{-# LANGUAGE BangPatterns #-}
import qualified Data.ByteString.Char8      as BSC8
import qualified Data.Vector.Unboxed        as VU

main :: IO ()
main = do
  n <- readLn :: IO Int
  c <- VU.unfoldrN n BSC8.uncons <$> BSC8.getLine
  print $ go c n 0 0 (n - 1)

go :: VU.Vector Char -> Int -> Int -> Int -> Int -> Int
go !c !n !res l r
  | l >= r || l >= n  || r < 0 = res
  | c VU.! l == 'R'              = go c n res (l + 1) r
  | c VU.! r == 'W'              = go c n res l (r - 1)
  | otherwise                  = go c n (res + 1) (l + 1) (r - 1)

Measured memory_bytes: 5392