akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string s;cin>>s;
    ll count = 0;
    ll wcount = 0;
    for(int i =0;i<s.size();++i){
            if(s[i]=='W'){
                count+=i-wcount;
                wcount++;
            }

    }
    cout << count << endl;

}

Measured memory_bytes: 3652
#include <vector>
#include <cassert>

template<class T>
struct potentialized_union_find {
    using value_type = T;
    using size_type = std::size_t;
private :
    size_type _size;
    std::vector<int> node;
    std::vector<value_type> potential;

public :
    potentialized_union_find (size_type n, const value_type &ie) : 
        _size(n), node(n, -1), potential(n, ie) { }

    size_type root (size_type x) {
        if (node[x] < 0) return x;
        int r = root(node[x]);
        potential[x] += potential[node[x]];
        return (node[x] = r);
    }

    value_type weight (size_type x) {
        root(x);
        return (potential[x]);
    }

    bool unite (size_type x, size_type y, value_type p) {
        p += (weight(x) - weight(y));
        if ((x = root(x)) == (y = root(y))) return false;
        if (node[x] > node[y]) {
            std::swap(x, y);
            p = -p;
        }
        node[x] += node[y];
        node[y] = x;
        potential[y] = p;
        _size--;
        return true;
    }

    bool same (size_type x, size_type y) {
        return (root(x) == root(y));
    }

    value_type diff (size_type x, size_type y) {
        assert(same(x, y));
        return (weight(y) - weight(x));
    }

    const size_type& size () const noexcept {
        return (_size);
    }

    size_type size (size_type x) {
        return (size_type(-node[root(x)]));
    }

};


#include <iostream>

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

    bool ok = true;
    potentialized_union_find<int> uf(n, 0);

    for (std::size_t i = 0; i < m; i++) {
        std::size_t x, y;
        int p;
        std::cin >> x >> y >> p;
        x--; y--;
        if (uf.same(x, y)) ok &= (uf.diff(x, y) == p);
        else uf.unite(x, y, p);
    }

    std::cout << (ok ? "Yes" : "No") << '\n';

    return 0;
}

Measured memory_bytes: 4032
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		double N = (double)reader.nextInt();
		double D = (double)reader.nextInt();
		System.out.println((int)Math.ceil(N/(D*2+1)));
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

vi prime, mnpf;
void preprime(int n) {
	prime.resize(0);
	mnpf.assign(n + 1, 1);
	rep1(i, n) {
		if (i < 2)continue;
		if (mnpf[i] != 1)continue;

		prime.push_back(i);
		mnpf[i] = i;
		int ii = i;
		while (ii <= n) {
			if (mnpf[ii] == 1)mnpf[ii] = i;
			ii += i;
		}
	}
}

V<ll> prft(0);
void pflz(ll n) {
	ll nn = n;
	int k = 0;
	while (nn > 1 && k < prime.size()) {
		if (nn % prime[k])k++;
		else { nn /= prime[k];prft.push_back(prime[k]); }
	}
	if (nn > 1)prft.push_back(nn);
	return;
}

int main() {

	preprime(1000020);
	ll n;
	cin >> n;
	pflz(n);

	map<ll, int> p;
	for (auto x : prft)p[x]++;

	int ans = 0;
	for (auto x : p) {
		int k = 1;
		while (k * (k + 1) / 2 <= x.second)k++;
		ans += k-1;
	}

	cout << ans << endl;

}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  explicit FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int A, B;
  cin >> A >> B;
  if(A >= 10 || B >= 10) {
    cout << -1 << endl;
  } else {
    cout << A * B << endl;
  }
}




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

int main(){
    char str[1010];
    
    while(1){
        cin >> str;
        if(str[0] == '0') break;
        int sum = 0;
        for(int i = 0; str[i] >= '0' && str[i] <= '9'; i++) sum += str[i] - '0';
        cout << sum << endl;
    }
    
    
    return 0;
}
    


Measured memory_bytes: 3088
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	a, _ := strconv.Atoi(s[0:2])
	b, _ := strconv.Atoi(s[2:4])
	//case YYMM
	if (a == 0 ||13 <= a) && a <=99 && 1 <= b && b <= 12 {
		fmt.Println("YYMM")
		return
	} else if 1 <= a && a <= 12 && 1 <= b && b <= 12 {
		fmt.Println("AMBIGUOUS")
		return
	} else if 1 <= a && a <= 12 && ( b == 0 || 13 <= b) && b <= 99{
		fmt.Println("MMYY")
		return
	} else {
		fmt.Println("NA")
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll   = long long;
using pll  = pair<ll,ll>;
using vll  = vector<pll>;
using vvll = vector<vll>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define dmax(a,b) a=max(a,b)

int main() {
    int n; cin >> n;
    vvll dp(1<<n, vll(2));
    rep(i,1<<n) {
        scanf("%ld", &dp[i][0].first);
        dp[i][0].second = i;
    }
    rep(b,1<<n) {
        rep(i,n) {
            int nb = b | (1<<i);
            if (nb == b) continue;
            if (dp[b][0].first > dp[nb][0].first) {
                if (dp[b][1].first > dp[nb][0].first) {
                    dp[nb][1] = dp[b][1];
                } else {
                    dp[nb][1] = dp[nb][0];
                }
                dp[nb][0] = dp[b][0];
            } else if (
                dp[b][0].first > dp[nb][1].first and
                dp[b][0].second != dp[nb][0].second
            ) {
                dp[nb][1] = dp[b][0];
            }
        }
    }
    ll ans = 0;
    rng(i,1,1<<n) {
        dmax(ans, dp[i][0].first + dp[i][1].first);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 21504
N, K = map(int, input().split())
XY = [[0, 0, 0] for _ in range(N)]
for i in range(N):
  x, y = map(int, input().split())
  XY[i] = [x, y, i]
X = sorted(XY)
Y = sorted(XY, key=lambda x: x[1])
rect = (X[-1][0] - X[0][0]) * (Y[-1][1] - Y[0][1])
for l in range(N - K + 1):
  for r in range(l + K - 1, N):
    for d in range(N - K + 1):
      for u in range(d + K - 1, N):
        if len([x for x in XY if X[l][0] <= x[0] <= X[r][0] and Y[d][1] <= x[1] <= Y[u][1]]) >= K:
          rect = min((X[r][0] - X[l][0]) * (Y[u][1] - Y[d][1]), rect)
print(rect)

Measured memory_bytes: 53340
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	enum COLOR{
		NO=0,
		R=1,
		W=2,
	};
	int N,M;
	cin>>N>>M;
	int *x = new int[M];
	int *y=new int[M];
	int *B=new int[N];
	int *n=new int[N];
	bool *enter=new bool[N];
	int i;
	B[0]=R;
	n[0]=1;
	enter[0]=true;
	for (i=1;i<N;i++){
		B[i]=W;
		n[i]=1;
		enter[i]=false;
	}
	for (i=0;i<M;i++){
		cin>>x[i]>>y[i];
		x[i]--;
		y[i]--;
	}
	for (i=0;i<M;i++){
		if (n[x[i]]>0){
			if (B[x[i]]==R){
				B[y[i]]=R;
				enter[y[i]]=true;
			}else{
				if (n[y[i]]==0){
					B[y[i]]=W;
					enter[y[i]]=false;
				}
			}
			n[y[i]]++;
			n[x[i]]--;
			if (n[x[i]]==0){
				B[x[i]]=NO;
				enter[x[i]]=false;
			}

		}
	}
	int num=0;
	for (i=0;i<N;i++){
		if (enter[i]==true){
			num++;
		}
	}
	cout<<num<<endl;
	delete[] x;
	delete[] y;
	delete[] B;
	delete[] n;
	delete[] enter;
	return 0;
}

Measured memory_bytes: 1920
//Minimum Spanning Tree
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

class DisjointSet {
public:
    vector<int> rank, p;
    DisjointSet(int size);
    void makeSet(int x);
    void unite(int x, int y);
    void link(int x, int y);
    int findSet(int x);
};

DisjointSet::DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i = 0; i < size; i++) makeSet(i);
}

void DisjointSet::makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
}

void DisjointSet::unite(int x, int y) {
    link(findSet(x), findSet(y));
}

void DisjointSet::link(int x, int y) {
    if(rank[x] > rank[y]) {
        p[y] = x;
    } else {
        p[x] = y;
        if(rank[x] == rank[y]) rank[y]++;
    }
}

int DisjointSet::findSet(int x) {
    if(x != p[x]) {
        p[x] = findSet(p[x]);
    }
    return p[x];
}

struct Edge {
public:
    int s, t, c;
    Edge(int s, int t, int c): s(s), t(t), c(c) {}
    bool operator < ( const Edge &e ) const {
        return c < e.c;
    }
};

int kruskal(int N, vector<Edge> E) {
    int t = 0;
    sort(E.begin(), E.end());
    DisjointSet D = DisjointSet(N);
    for(auto itr = E.begin(); itr != E.end(); itr++) {
        if(D.findSet(itr -> s) != D.findSet(itr -> t)) {
            D.unite(itr -> s, itr -> t);
            t += itr -> c;
        }
    }
    return t;
}

int main() {
    int N, M, s, t, c;
    vector<Edge> E;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        cin >> s >> t >> c;
        E.push_back(Edge(s, t, c));
    }

    cout << kruskal(N, E) << endl;
}


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

int main()
{
  int N;
  char C[200000];
  int Red = 0;
  int White = 0;
  
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> C[i];
    if (C[i] == 'R') Red++;
    //cout << Red << endl;
  }
  
  for (int i = 0; i < Red; i++)
  {
    if (C[i] == 'W') White++;
  }
  
  cout << White << endl;
}

Measured memory_bytes: 3824
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


n=l()[0]
A=[l() for i in range(n)]
ans=0
for i in range(n-1,-1,-1):
    if((A[i][0]+ans)%A[i][1]==0):
        continue
    ans+=(A[i][1]-(A[i][0]+ans)%A[i][1])
print(ans)

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

int main(){
  string a;
  getline(cin, a);
  for(int i=0; i<a.length(); i++){
    if('a'<=a[i] && a[i]<='z') a[i]+=('A'-'a');
  }
  cout<<a<<endl;
  return 0;
}

Measured memory_bytes: 1168
# Union-Find
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True


def same(x, y):
    return find(x) == find(y)


def size(x):
    return -par[find(x)]



N, M = map(int, input().split())
# 負のとき size, 非負のとき parent
par = [-1] * N
Bridge = [tuple(map(int, input().split())) for _ in range(M)]
Bridge = Bridge[::-1]
Ans = []
ans = N * (N-1) // 2
for (a, b) in Bridge:
    Ans.append(ans)
    if find(a-1) != find(b-1):
        x = size(a-1)
        y = size(b-1)
    else:
        x = 0
        y = 0
    unite(a-1, b-1)
    ans -= x * y


Ans = Ans[::-1]

for an in Ans:
    print(an)



Measured memory_bytes: 102744
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);

		int a = in.nextInt();

		System.out.println(a+a*a+a*a*a);

	}

}


Measured memory_bytes: 35592
class Dice 
    attr_reader :nums
    def initialize(nums)
        @nums = [nil] + nums
    end
    def top
        @nums[1]
    end
    def front
        @nums[2]
    end
    def right
        @nums[3]
    end
    def sorted_nums
        @nums.select{|n| n != nil}.sort
    end
    def rollx
        @nums[1], @nums[2], @nums[6], @nums[5] = @nums[5], @nums[1], @nums[2], @nums[6]
        self
    end
    def rolly
        @nums[1], @nums[3], @nums[6], @nums[4] = @nums[4], @nums[1], @nums[3], @nums[6]
        self
    end
    def rollz
        @nums[2], @nums[3], @nums[5], @nums[4] = @nums[4], @nums[2], @nums[3], @nums[5]
        self
    end
    def moveN
        rollx.rollx.rollx
    end
    def moveS
        rollx
    end
    def moveE
        rolly
    end
    def moveW
        rolly.rolly.rolly
    end
    def move(m)
        case m
        when 'N' then moveN
        when 'S' then moveS
        when 'E' then moveE
        when 'W' then moveW
        end
    end
    def move_all
        moves = [
            # top:1 front:2
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz, :moveN,
            # top:2 front:6
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz, :moveW,
            # top:3 front:6
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz, :moveW,
            # top:5 front:6
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz, :moveW,
            # top:4 front:6
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz, :moveN,
            # top:6 front:3
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz,
        ]
        moves.each do |m|
            if m == :y
                yield self
            else
                self.send(m)
            end
        end
    end
end

n = STDIN.gets.to_i

dices = []
n.times do |i|
    nums = STDIN.gets.split.map(&:to_i)
    dices << Dice.new(nums)
end

(0..(n - 2)).each do |i|
    ((i + 1)..(n - 1)).each do |j|
        d1 = dices[i]
        d2 = dices[j]
        next if d1.sorted_nums != d2.sorted_nums
        d1.move_all do |d|
            if d.nums == d2.nums
                puts "No"
                exit
            end
        end
    end
end

puts "Yes"

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

char F[102][102];


//????????´
void r(int y,int x){
 if(F[y][x]!='@'){
	return ;
 }

F[y][x]='.';

r(y-1,x);
r(y,x+1);
r(y+1,x);
r(y,x-1);

}
//??????
void k(int y,int x){
 if(F[y][x]!='#'){
	return ;
 }

F[y][x]='.';

k(y-1,x);
k(y,x+1);
k(y+1,x);
k(y,x-1);

}
//?????????
void m(int y,int x){
 if(F[y][x]!='*'){
	return ;
 }

F[y][x]='.';

m(y-1,x);
m(y,x+1);
m(y+1,x);
m(y,x-1);

}

int main(){
 int n,p;

while(1){
 cin>>n>>p;

 if(n==0&&p==0)break;

 for(int i=1;i<=n;i++)
	for(int g=1;g<=p;g++)
		cin>>F[i][g];

 int cnt=0;
 for(int i=1;i<=n;i++)
	for(int g=1;g<=p;g++){
		//????????´
		if(F[i][g]=='@'){
			cnt++;
			r(i,g);
		}
		//??????
		if(F[i][g]=='#'){
			cnt++;
			k(i,g);
		}
		//?????????
		if(F[i][g]=='*'){
			cnt++;
			m(i,g);
		}
	}
 cout<<cnt<<endl;
}

return 0;
}

		

Measured memory_bytes: 3532
import math
 
PI = math.pi
A, B, H, M = map(int, input().split())
 
arg_a = (float(H) + float(M)/60) / 12.0 * 360
arg_b = float(M) / 60.0 * 360
 
 
C = math.sqrt(A*A + B*B - 2*A*B* math.cos((arg_a-arg_b)/360*2*PI))
print(C)

Measured memory_bytes: 9344
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
char t[200010];
char d[200010];
int n,q;
string s;
int solve1(int now){
    for(int cnt = 0;cnt < q;cnt++){
        if(s[now] == t[cnt]){
            if(d[cnt] == 'L'){
                now--;
            }else{
                now++;
            }
        }
        if(now == -1)return 1;
        if(now == n)return 0;
    }
    return 0;
}
int solve2(int now){
    for(int cnt = 0;cnt < q;cnt++){
        if(s[now] == t[cnt]){
            if(d[cnt] == 'L'){
                now--;
            }else{
                now++;
            }
        }
        if(now == -1)return 0;
        if(now == n)return 1;
    }
    return 0;
}
signed main(){
    
    cin >> n >> q >> s;
    rep(i,q) cin >> t[i] >> d[i];
    //左に落ちる
    int fall = -1;
    int stay = n;  
    while(abs(fall - stay) > 1){
        int mid = (fall + stay)/2;
        if(solve1(mid))fall = mid;
        else stay = mid;
    }
    int l = fall + 1;
    //右に落ちる
    fall = n;
    stay = -1;
    while(abs(fall - stay) > 1){
        int mid = (fall + stay)/2;
        if(solve2(mid))fall = mid;
        else stay = mid;
    }
    int r = n - fall;
    cout << n - l - r << endl;

    
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://exawizards2019.contest.atcoder.jp/tasks/exawizards2019_a

Measured memory_bytes: 900
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
old = -12
ans = 0
for a in A:
    if old + 1 == a:
        ans += C[old - 1]
    
    ans += B[a - 1]
    old = a

print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;


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

	int sum = 0, tmp = 0;
	for (int i = 0; i < n; i++) {
		cin >> h;
		if (tmp <= h) {
			tmp = h;
			sum++;
		}
	}

	cout << sum << endl;

	//system("pause");

	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

int MOD = 1e9+7;

//ll po(ll b, ll p){ return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD;}
// ll pomd(ll a, ll k, ll md) { ll p; if (k == 0){ return 1; } p = pomd(a, k / 2, md); p = p * p % md; if (k % 2){ p = p * a % md; } return p; }
// counting divsrs: vi arr(N); for(int i{1}; i<N; ++i) for(int j=i; j<N; j+=i) d[j]++;

#define mp make_pair
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)

void setIO(string name = ""){
    freopen((name+".in").c_str(), "r", stdin); 
    freopen((name+".out").c_str(), "w", stdout);
}	

int main(){
 	ios_base::sync_with_stdio(0); cin.tie(0); 
	// setIO();
	int n,k ; cin >> n >> k;
	vector<ll> h(n);
	ll sum = 0;
	for(int i{}; i<n; i++){ 
		cin >> h[i];	
	}

	sort(all(h), greater<int> ());

	for(int i=k; i<n; i++){
		sum+=h[i];
	}

	cout << sum << "\n";
}





Measured memory_bytes: 4792
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int main()
{
    int a,  b;
    cin >> a >> b;
    cout << (a==b?"Yes":"No");
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<int> ss(m), c(m);
	for(int i = 0; i < m; i++) cin >> ss[i] >> c[i];
	for(int i = 0; i < 1000; i++){
		vector<int> s; int p = i;
		while(p){
			s.push_back(p % 10);
			p /= 10;
		}
		if(s.empty()) s.push_back(0);
		if(s.size() == n){
			int j;
			for(j = 0; j < m; j++) if(s[n - ss[j]] != c[j]) break;
			if(j == m){
				cout << i << '\n';
				return 0;
			}
		}
	}
	cout << -1 << '\n';
	return 0;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n, k; cin >> n >> k; k++;
    ll a[n]; f(i,0,n-1) cin >> a[i], a[i]--;
    deque <ll> visits;
    vector <bool> vis(n,false);
    ll curr = 0;
    while(!vis[curr]) vis[curr] = true, visits.pb(curr), curr = a[curr];
    visits.pb(curr);
    if(k <= sz(visits)) cout << visits[k-1] + 1;
    else {
        k -= sz(visits);
        while(visits[0] != visits[sz(visits)-1]) visits.pop_front();
        visits.pop_front();
        k--;
        cout << visits[k % sz(visits)] + 1;
    }
    return 0;
}

Measured memory_bytes: 6816
s = str(input())
S = list(s)

for i in range(len(S)):
    if S[i] == 'A':
        first_A = i
        break
for i in range(len(S)):
    if S[-(i+1)] == 'Z':
        last_Z = len(S) - i
        break
        
ans = last_Z - first_A
print(ans)

Measured memory_bytes: 4840
s = input()
l = list(s)
min = 1000
d=[0 for i in range(len(s))]
X=[0 for i in range(len(s))]

for i in range(len(s)-2):
    X[i] = int(l[i])*100+int(l[i+1])*10+int(l[i+2])
    d[i] = abs(X[i] - 753)
    if min > d[i]:
        min = d[i]

print(min)

Measured memory_bytes: 3064
#include<stdio.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<stack>
#include<string.h>
using namespace std;
long long int map[400000][200];
long long int b[400000],ba[200],dab[200];
int main() {
	long long int n, i,m,j;
	scanf("%lld", &n);
	for (i = 1; i <= n ; i++) {
		scanf("%lld", &b[i]);
	}
	for (i = 1; i <= n; i++) {
		long long int val = b[i],t=1;
		while (val != 0) {
			if (val % 2 == 1) { map[i][t] = 1; ba[t]++; }
			val /= 2;
			t++;
		}
	}
	long long int cnt = n;
	for (i = 1; i < n; i++) {
		for (j = 1; j <= 70; j++) {
			if (map[i][j] == 1) ba[j]--;
		}
		cnt--;
		for (j = 1; j <= 70; j++) {
			if (map[i][j] == 1) ba[j] = cnt - ba[j];
		}
		for (j = 1; j <= 70; j++) { dab[j] += ba[j]; dab[j] %= 1000000007; }
		for (j = 1; j <= 70; j++) {
			if (map[i][j] == 1) ba[j] = cnt - ba[j];
		}
	}
	long long int t = 1, ccount = 0;
	for (i = 1; i <= 70; i++) {
		ccount += (t * dab[i])%1000000007;
		ccount %= 1000000007;
		t *= 2;
		t %= 1000000007;
	}
	printf("%lld", ccount);
	return 0;
}

Measured memory_bytes: 473216
S = input()
n = len(S)
ans = 0
k = 0
agct = ['A','G','C','T']
for i in range(n):
    if S[i] in agct:
        k+=1
        continue
    ans = max(k,ans)
    k = 0

ans = max(ans,k)
print(ans)

Measured memory_bytes: 3060
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y) { return (x / gcd(x, y) * y); }

using pll = pair<long, long>;
using W_graph = vector<vector<pll>>;

vector<long> dijkstra(W_graph g, long s) {
	vector<long> dist(g.size(), INT_MAX);
	priority_queue<pll, vector<pll>, greater<pll>> Q;
	dist[s] = 0;
	Q.push(make_pair(dist[s], s));

	while (!Q.empty()) {
		long cost, now;
		tie(cost, now) = Q.top(); Q.pop();

		for (auto e : g[now]) {
			long path, next;
			tie(next, path) = e;
			if (cost + path >= dist[next]) continue;
			dist[next] = cost + path;
			Q.push(make_pair(dist[next], next));
		}
	}
	return dist;
}

int main() {
	long N, M ,r; cin >> N >> M >> r;
	W_graph g(N);

	for (int i = 0; i < M; i++) {
		long a, b, c; cin >> a >> b >> c;
		g[a].push_back(make_pair(b, c));
		//g[b].push_back(make_pair(a, c));
	}

	vector<long> res = dijkstra(g, r);

	for (int i = 0; i < N; i++) if (res[i] != INT_MAX) cout << res[i] << endl; else cout << "INF" << endl;
}


Measured memory_bytes: 30808
import math
def kochCurve(A):
    B = []
    for i in xrange(len(A)-1):
        p1 = A[i]
        p2 = A[i+1]
        s = ((A[i][0] * 2.0 + A[i+1][0] * 1.0)/3, (A[i][1] * 2.0 + A[i+1][1] * 1.0)/3)
        t = ((A[i][0] * 1.0 + A[i+1][0] * 2.0)/3, (A[i][1] * 1.0 + A[i+1][1] * 2.0)/3)
        x = t[0] - s[0]
        y = t[1] - s[1]
        rad = math.radians(60)
        ux = x * math.cos(rad) - y * math.sin(rad)
        uy = x * math.sin(rad) + y * math.cos(rad)
        u = (ux + s[0], uy + s[1])
        B.extend([p1, s, u, t])
    B.append(A[len(A)-1])
    return B

n = int(raw_input())
A = [(0, 0), (100, 0)]
for i in xrange(n):
    A = kochCurve(A)
for x in A:
    print x[0], x[1]

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

class Dice{
public:
  vector<int> side;
  Dice(){
    side = {};
  }

  Dice(vector<int> _side){
    side = _side;
  }
  void rotate(char c){
    vector<int> t;
    if(c == 'N') t = {1, 5, 2, 3, 0, 4};
    else if (c == 'S') t = {4, 0, 2, 3, 5, 1};
    else if (c == 'E') t = {3, 1, 0, 5, 4, 2};
    else if (c == 'W') t = {2, 1, 5, 0, 4, 3};
    else if (c == 'L') t = {0, 3, 1, 4, 2, 5};
    else if (c == 'R') t = {0, 2, 4, 1, 3, 5};
    vector<int> new_side(6);
    for(int i = 0; i < 6; i++) new_side[i] = side[t[i]];
    side = new_side;
  }
  void rotate(char c, int n){
    for(int i = 0; i < n; i++) rotate(c);
  }
};

bool isSameDice(const Dice &d1, const Dice &d2){
  Dice d1_cp = d1;
  for(int x = 0; x < 4; x++){
    for(int y = 0; y < 4; y++){
      for(int z = 0; z < 4; z++){
        d1_cp.rotate('N', x);
        d1_cp.rotate('E', y);
        d1_cp.rotate('L', z);
        if(d1_cp.side == d2.side){
          return true;
        }
        d1_cp = d1;
      }
    }
  }
  return false;
}
int main(){
  int n; cin >> n;
  vector<Dice> d(n);
  for(int i = 0; i < n; i++){
    vector<int> v(6);
    for(int j = 0; j < 6; j++) cin >> v[j];
    d[i] = Dice(v);
  }
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      if(isSameDice(d[i], d[j])){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}



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

const int M = 2e6 + 10;
const int MD = 1e9 + 7;
char s[M];
int k, n;

int f[M], rf[M];
int p25[M], p26[M];

void precalc() {
    f[0] = rf[0] = p25[0] = p26[0] = 1;
    for (int i = 1; i < M; i++) 
        p25[i] = 1ll * p25[i - 1] * 25 % MD,
        p26[i] = 1ll * p26[i - 1] * 26 % MD,
        f[i] = 1ll * f[i - 1] * i % MD; 

    rf[M - 1] = 331213222;
    for (int i = M - 2; i >= 0; i--)
        rf[i] = 1ll * rf[i + 1] * (i + 1) % MD;
}

int C(int n, int k) {
    if (k < 0 || k > n) return 0;
    return 1ll * f[n] * rf[n - k] % MD * rf[k] % MD;
}

int main() {
    precalc();
    while (scanf("%d %s", &k, s) == 2) {
        n = strlen(s);
        int res = 0;
        for (int len = n; len <= n + k; len++) {
            int tres = 1ll * C(len - 1, n - 1) * p25[len - n] % MD * p26[n + k - len] % MD;
            res = (res + tres) % MD;
        }
        printf("%d\n", res);
    }
}


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

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

  vi AC(100010,0);
  for(int i=1; i<S.length(); i++){
    AC[i] = AC[i-1];
    if(S[i-1] == 'A' && S[i] == 'C') AC[i]++;
  }
  
  for(int i=0; i<Q; i++){
    int l, r; cin >> l >> r;
    cout << AC[r-1] - AC[l-1] << endl;
  }

  
}

Measured memory_bytes: 1408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class BFizzBuzzSum {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt();
            long res = 0;
            for (int i = 1; i <= n; i++) {
                if (i % 3 == 0)
                    continue;
                if (i % 5 == 0)
                    continue;
                res += i;
            }
            w.println(res);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32676
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S; cin >> S;
    vector<int> nums(3);
    for (const char ch : S)
    {
        ++nums[static_cast<int>(ch - 'a')];
    }
    //　"abc"（およびその並び替え）を繰り返すことができればよい
    // 各文字の数の差が１以下であればよい
    for (int i = 0; i < 3; ++i)
    {
        if (abs(nums[(i + 1) % 3] - nums[i]) > 1)
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
}


Measured memory_bytes: 512
from math import gcd
from functools import reduce
def gcd_list(numbers):
   return reduce(gcd, numbers)
k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for x in range(1,k+1):
            ans+=gcd_list([i,j,x])
print(ans)

Measured memory_bytes: 69352
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    string s;
    cin >> s;
    int count=700;
    for(int i=0;i<3;i++){
        if(s[i]=='o'){
            count += 100;
        }
    }
    cout<<count<<endl;
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<vector<pii>> G(N);
    rep(i, 0, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    vi color(N, -1);
    auto dfs = [&](auto f, int v, int c) -> void {
        color[v] = c;
        for (pii e : G[v]) {
            int w, cost;
            tie(w, cost) = e;
            if (color[w] != -1) continue;
            if (cost % 2) {
                f(f, w, c ^ 1);
            } else {
                f(f, w, c);
            }
        }
    };
    dfs(dfs, 0, 0);
    for (int c : color) {
        cout << c << endl;
    }
    return (0^_^0);
}



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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define MOD 1000000007LL

int main(){
    ll N;
    cin >> N;
    
    vector<ll> A(N, 0);
    REP(i,0,N){
        cin >> A[i];
    }

    ll sum=0;
    REP(i,0,60){
        ll b = 0;
        REP(j,0,N){
            b += (A[j] >> i & 1LL);
        }
        ll t = (b * (N - b) % MOD) * ((1LL << i) % MOD);
        sum += t % MOD;
        sum %= MOD;
    }

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

Measured memory_bytes: 2560
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np

def main():
    INF = 10 ** 8
    N = int(input())
    weights = np.array(list(map(int, input().split()))).astype(int)
    
    dp_table = np.empty(N).astype(int)
    dp_table.fill(INF)
    dp_table[0] = 0
    dp_table[1] = abs(weights[1] - weights[0])
    
    for i in range(2, N):
        dp_table[i] = min(dp_table[i-1] + abs(weights[i] - weights[i-1]), dp_table[i-2] + abs(weights[i] - weights[i-2]))

    print(dp_table[N-1])
    return 0

if __name__ == "__main__":
    main()


Measured memory_bytes: 22784
#include "bits/stdc++.h"
#define ll long long
#define FOR(x) for(ll i = 0;i<(x);i++)
#define ALL(v) (v).begin(),(v).end()


using namespace std;


int main(){
ll a,b,c;
cin>>c>>a>>b;

cout<<c*a/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int input1;
int input2;

int main(){
    cin >> input1 >> input2;
    if(input1 >= 6 && input1 <= 12){
        int result = input2/2;
        cout << result;
    }    

    else if(input1 > 12){
        cout << input2;
    }

    else{
        cout << 0; 
    }
   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,a;
	set<int>s;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		s.insert(a);
	}
	if(s.size()==n)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 9600
import java.util.*;

class Main {
	public static void main(String[] args) {
		Comparator<Integer> comparator = new Comparator<Integer>() {
	        @Override
	        public int compare(Integer o1, Integer o2) {
	            return Integer.valueOf(o2).compareTo(Integer.valueOf(o1));
	        }
    	};
		Scanner sc = new Scanner(System.in);
		int Q = sc.nextInt();
		long b = 0;
		long ans=0;
		int cnt=0;
		long left_sum=0;
		long right_sum=0;
		Queue<Integer> pq1 = new PriorityQueue<Integer>(comparator);
		Queue<Integer> pq2 = new PriorityQueue<Integer>();

		for (int i=0;i<Q;i++) {
			int x=sc.nextInt();
			if (x==1) {
				int a=sc.nextInt();
				int B=sc.nextInt();
				b+=B;
				if (cnt!=0) {
					if (a<pq1.peek() || pq2.peek()<a)
					ans+=Math.min(Math.abs(pq1.peek()-a),Math.abs((pq2.peek()-a)));
				}
				pq1.add(a);
				pq2.add(a);
				cnt++;
				ans+=B;
				left_sum+=a;
				right_sum+=a;
				if (pq1.peek()>pq2.peek()) {
					int tmp_1=pq1.peek();
					int tmp_2=pq2.peek();
					pq1.remove();
					pq2.remove();
					pq1.add(tmp_2);
					pq2.add(tmp_1);
					left_sum+=-tmp_1+tmp_2;
					right_sum+=tmp_1-tmp_2;
				}
			} else if (x==2) {
				System.out.print(pq1.peek()+" ");
				System.out.println(ans);
//				System.out.println(b+pq1.peek()*cnt-left_sum+right_sum-pq2.peek()*cnt+pq2.peek()-pq1.peek());
			}
		}
	}
}

Measured memory_bytes: 156840
#include<stdio.h>
int main(){
  int n,i;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    int a[11]={0},b=0;
    for(i=0;n!=0;i++){
      a[i]=n%8;
      n/=8;
    }
    for(i--;i>-1;i--){
      if(a[i]>4)a[i]+=2;
      else if(a[i]>3)a[i]++;
      printf("%d",a[i]);
    }
    printf("\n");
  }
  return 0;
}
      
   

Measured memory_bytes: 604
#include <stdio.h>
//#include <conio.h>

int main(void)
{
	int i;
	int num[3];
	int num2[3]={0,0,0};
	int max, min, middle;
	int ma=0, mi=0;
	max = 0; min = 32000; middle = 0;
	
	scanf("%d %d %d", &num[0], &num[1], &num[2]);
	
	for(i=0; i<3; i++){
		if(max<num[i]){
			max = num[i];
			num2[i]=99;
			ma++;
			if(ma>=2) num2[i-1]=0;
		}
		
		if(min>num[i]) {
			min = num[i];
			num2[i]=99;
			mi++;
			if(mi>=2) num2[i-1]=0;
		}
	}
	
	for(i=0; i<3; i++){
		//if(max!=num[i] && min!=num[i]) middle = num[i];
		if(num2[i]==0) middle = num[i];
	}
	
	//if(ma>=2) middle = max;
	//if(mi>=2) middle = min;
	
	printf("%d %d %d\n" ,min, middle, max);
	//getch();
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N  =sc.nextInt();
        int [] List = new int[N];
        for(int i=0;i<N;i++) List[i]=sc.nextInt();
        Arrays.sort(List);
        int num=0;
        for(int i=0;i<N-2;i++){
            for(int j=i+1;j<N-1;j++) {
                for(int k=j+1;k<N;k++){
                    if(List[i]+List[j]>List[k])num++;
                    else break;
                }
            }
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 26776
import java.util.*

fun main(args : Array<String>) {
    val (n, m, q) = readLine()!!.split(" ").map { it.toInt() }
    val qq = mutableListOf<Item>()

    repeat(q) {
        val (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }
        qq.add(Item(a-1, b-1, c, d))
    }

    val dfs = Stack<IntArray>()
    dfs.push(IntArray(n){0})

    var max = 0

    while (dfs.isNotEmpty()) {
        val a = dfs.pop()
        if (a.last() != 0) {
            var score = 0
            qq.forEach {
                if (a[it.idx2] - a[it.idx1] == it.diff) score += it.score
            }
            max = Math.max(max, score)
            continue
        }

        if (a[0] == 0) {
            for (i in 1..m) {
                val newA = a.copyOf()
                newA[0] = i
                dfs.push(newA)
            }
            continue
        }

        val lastIdx = a.indexOfLast { it != 0 }
        for (i in a[lastIdx]..m) {
            val newA = a.copyOf()
            newA[lastIdx+1] = i
            dfs.push(newA)
        }
    }

    println(max)
}

data class Item(val idx1: Int, val idx2: Int, val diff: Int, val score: Int)

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	for (int i = k; i < n; i++) {
		if (A[i] > A[i-k]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

int main(void) {
  std::string s;

  std::cin >> s;
  std::vector<int> a(26, 0);
  for (char& ch : s) {
    a[ch - 'a'] = 1;
  }

  for (int i = 0; i < a.size(); ++i) {
    if (a[i] == 0) {
      std::cout << static_cast<char>('a' + i) << std::endl;
      return 0;
    }
  }

  std::cout << "None" << std::endl;

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

#define BSIZE 65536
int is;
char ib[BSIZE], ob[BSIZE], *ip, *op;
void mystart();
void myexit();
void put(char c);
char get();

short nextShort();
void printInt(int f);

int min(int a, int b){return a>b?b:a;}
int dif(short a, int b){return a<b?b-a:a-b;}

short N, j;
int l, i;
short A, B, C, L[8];
int a[4], b[4];
int ans, now;

int main(){
	mystart();
	N=nextShort();
	A=nextShort();
	B=nextShort();
	C=nextShort();
	for(i=0; i<N; i++){
		L[i]=nextShort();
	}
	ans = 2147483647;
	for(i=0, l=(1<<(N<<1)); i<l; i++){
		a[0]=a[1]=a[2]=a[3]=0;
		b[0]=b[1]=b[2]=b[3]=0;
		for(j=0; j<N; j++){
			a[(i>>(j<<1))&3] ++;
			b[(i>>(j<<1))&3] += L[j];
		}
		if(a[0]==0 || a[1]==0 || a[2]==0){continue;}
		now = (a[0]+a[1]+a[2]-3)*10 + dif(A, b[0])+dif(B, b[1])+dif(C, b[2]);
		ans = min(ans, now);
	}
	printInt(ans);
	put(10);
	myexit();
}

void mystart(){ip = ib + BSIZE; op = ob; is = 0;}
void myexit(){fwrite(ob, 1, op - ob, stdout);}
void put(char c){if(op==ob+BSIZE){fwrite(ob, 1, BSIZE, stdout); op = ob;} *op++ = c;}
char get(){if(ip==ib+BSIZE){is = fread(ib, 1, BSIZE, stdin); ip = ib;} return (ip==ib+is)?0:*ip++;}
short nextShort(){short f=0; char c=get(); while((c<'0')||('9'<c)){c=get();} while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=get();} return f;}
void printInt(int f){char c[16]; if(!f){put('0'); return;} char i=0; while(f){c[++i]=(f%10)^48; f/=10;} while(i){put(c[i--]);}}


Measured memory_bytes: 128