akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> H(N);
	REP(i, N) scanf("%d", &H[i]);
	sort(ALL(H), greater<int>());
	ll ans = 0;
	FOR(i, K, N) ans += H[i];
	cout << ans << endl;
}


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

int main(){
	int N, M; cin >> N >> M;
	vector<pair<long long, long long>> drink(N);
	for(int i = 0; i < N; ++i){
		cin >> drink[i].first >> drink[i].second;
	}
	sort(drink.begin(), drink.end());
	long long ans = 0, cnt = 0;
	for(int i = 0; i < N; ++i){
		if(M - drink[i].second > 0){
			ans += drink[i].first * drink[i].second;
			M -= drink[i].second;
		}
		else{
			ans += drink[i].first * M;
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int k = in.nextInt();
        int q = in.nextInt();
        int[] d = in.nextIntArray(k);
        for (int i = 0; i < q; i++) {
            long n = in.nextInt();
            long x = in.nextInt();
            long m = in.nextInt();
            long sum = 0, zero = 0;
            for (int j = 0; j < k; j++) {
                sum += d[j] % m;
                if (d[j] % m == 0) {
                    zero++;
                }
            }
            sum = x + sum * ((n - 1) / k);
            zero *= (n - 1) / k;
            for (int j = 0; j < (n - 1) % k; j++) {
                sum += d[j] % m;
                if (d[j] % m == 0) {
                    zero++;
                }
            }
            out.println(n - 1 - sum / m + x / m - zero);
        }
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 39180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Min_Max
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            List<int> nums = new List<int>();
            for (int i = 0; i < input.Length; ++i)
            {
                nums.Add(int.Parse(input[i]));
            }
 
            nums.Sort();
 
            Console.WriteLine(nums[0]+" "+nums[2]);
        }
    }
}


Measured memory_bytes: 18040
import sys

a, b, c = map(int, input().split())
k = int(input())

flag = True

if max([a, b, c]) == a:
    for i in range(k):
        a = a*2

    flag = False
    print(a+b+c)

if max([a, b, c]) == b and flag:
    for i in range(k):
        b = b*2

    flag = False
    print(a+b+c)

if max([a, b, c]) == c and flag:
    for i in range(k):
        c = c*2

    print(a+b+c)


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

public class Main {

	static int[] rmq;
	static int n;

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();

		n = sc.nextInt();
		int q = sc.nextInt();
		int[] com = new int[q];
		int[] x = new int[q];
		int[] y = new int[q];
		rmq = new int[n<<1];
		for (int i=0; i<n<<1; i++) {
			rmq[i] = Integer.MAX_VALUE;
		}

		for (int i=0; i<q; i++) {
			com[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}

		for (int i=0; i<q; i++) {
			if (com[i] == 0) {
				update(x[i], y[i]);
			} else {
				find(x[i], y[i]);
			}
		}

	}

	static void update(int x, int y) {
		rmq[x+n] = y;
		for (int i=x+n; i>1; i>>=1) {
			rmq[i>>1] = Math.min(rmq[i], rmq[i^1]);
		}
	}

	static void find(int x, int y) {
		int ret = Integer.MAX_VALUE;
		for (int i=x+n, j=y+n; i<=j; i=(i+1)>>1, j=(j-1)>>1) {
			if ((i&1)==1) {
				ret = Math.min(ret, rmq[i]);
			}
			if ((j&1)==0) {
				ret = Math.min(ret, rmq[j]);
			}
		}
		System.out.println(ret);
	}
}

class FastScanner {
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() { if (hasNextByte()) return buffer[ptr++]; else return -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 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();
}
}
public int nextInt() {
if (!hasNext()) throw new NoSuchElementException();
int 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: 48584
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> A, ll Q, std::vector<ll> B,
           std::vector<ll> C) {
  ll sum = 0;
  map<ll, ll> cntm;
  rep(i, N) {
    sum += A.at(i);
    if (cntm.count(A.at(i))) {
      cntm.at(A.at(i))++;
    } else {
      cntm.insert({A.at(i), 1});
    }
  }

  rep(i, Q) {
    B.at(i);
    C.at(i);

    ll c = cntm[B.at(i)];
    cntm[B.at(i)] = 0;
    cntm[C.at(i)] += c;
    sum += (C.at(i) - B.at(i)) * c;
    cout << sum << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  ll Q;
  scanf("%lld", &Q);
  std::vector<ll> B(Q);
  std::vector<ll> C(Q);
  for (int i = 0; i < Q; i++) {
    scanf("%lld", &B[i]);
    scanf("%lld", &C[i]);
  }
  solve(N, std::move(A), Q, std::move(B), std::move(C));
  return 0;
}


Measured memory_bytes: 11692
#include<bits/stdc++.h>
using namespace std;
struct edge{long long to,cost;};
typedef pair<long long,int>P;
#define INF 1145141919810893
long long V;
vector<edge>G[10*10*10*10*10*5];
long long d[10*10*10*10*10*5];
void dijkstra(long long s){
	//greater<P>を指定することでfirstを小さい順に取り出せるようにする
	priority_queue<P,vector<P>,greater<P> >que;
	fill(d,d+V,INF);
	d[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		long long v=p.second;
		if(d[v]<p.first){
			continue;
		}
		for(long long i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}

	}
}
int main(){
	long long M;
	cin>>V>>M;
	for(long long i=0;i<M;i++){
		long long l,r,c;
		cin>>l>>r>>c;
		l--;
		r--;
		struct edge a;
		a.to=r;
		a.cost=c;
		G[l].push_back(a);
	}
	for(long long i=V-1;i>0;i--){
		long long l,r,c;
		struct edge x;
		x.to=i-1;
		x.cost=0;
		G[i].push_back(x);
	}
	dijkstra(0);
	if(d[V-1]==INF){
		d[V-1]=-1;
	}
	cout<<d[V-1]<<endl;

	
}


Measured memory_bytes: 20728
#include<stdio.h>

int main(void) {
  char S[2000000];
  char T[2000000];
  int i, j;
  int num = 0;
  
  scanf("%s", S);
  scanf("%s", T);
  for(i=0; S[i]!='\0'; ++i);
  for(j = 0; j <= i; j++){
    if(S[j] != T[j]){
      num++;
    }
  }  
  printf("%d", num);
  return 0;
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;
template<typename F> ll bsearch(ll ok, ll ng, F f) {
	while (abs(ok - ng) > 1) {
		ll middle = (ok + ng) / 2;
		(f(middle) ? ok : ng) = middle;
	}
	return ok;
}
int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	string s; cin >> s;
	ll ma = s.size(), ma2 = s.size();
	FOR(i, 1, s.size() / 2 + 1) {
		if (s[i] != s[i - 1]) ma = min<ll>(ma, s.size() - i);
	}
	FOR(i, 1, s.size() / 2 + 1) {
		if (s[s.size() - i - 1] != s[s.size() - i]) ma2 = min<ll>(ma2, s.size() - i);
	}

	cout << min(ma, ma2) << endl;

	return 0;
}


Measured memory_bytes: 512
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():


    n, h= LI()
    huri = [0 for _ in range(n)]
    nage = [0 for _ in range(n)]
    use = []
    
    for i in range(n):
        huri[i], nage[i] = LI()

    mx = max(huri)

    for katana in nage:
        if katana >= mx:
            use.append(katana)

    use.sort(reverse=True)
    ans = 0
    for used in use:
        h -= used
        ans += 1
        if h<=0:
            break

    if h>0:
        ans += (h+mx-1)//mx

    print(ans)



main()


Measured memory_bytes: 81332
#include<iostream>
using namespace std;
long long n, m;
long long a[100000];
bool search(long long v);
int main(){
 
    cin >> n >> m;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int l, r;
    l = 0; r = 100000 * 10000;
    while (r-l>1){
        long long mi = (l + r) / 2;
        if (search(mi))r = mi;
        else l = mi;
    }
        cout << r << endl;
}
bool search(long long v){
    long long n2=0, m2=0,b=0;
    while (n2 < n&&m2 < m){
        if (b + a[n2] <= v){
            b += a[n2];
            n2++;
        }
        else{
            b = 0;
            m2++;
        }
    }
    if (n2 == n&&m2 < m)return true;
    return false;
}


Measured memory_bytes: 3892
#include<iostream>
using namespace std;
int main(){
	int year,month,day;
	while(cin >>year>>month>>day){
		if(year<1868){cout<<"pre-meiji"<<endl;}
		else if(year == 1868 && month<9){cout<<"pre-meiji"<<endl;}
		else if(year == 1868 && month == 9 && day<8){cout<<"pre-meiji"<<endl;}
		else{
			if(year<1912){cout <<"meiji "<<year-1867<<" ";}
			else if(year == 1912 && month<7){cout <<"meiji "<<year-1867<<" ";}
			else if(year == 1912 && month == 7 && day<30){cout <<"meiji "<<year-1867<<" ";}
			else if(year<1926){cout <<"taisho "<<year-1911<<" ";}
			else if(year == 1926 && month<12){cout <<"taisho "<<year-1911<<" ";}
			else if(year == 1926 && month == 12 && day<25){cout <<"taisho "<<year-1911<<" ";}
			else if(year<1989){cout <<"showa "<<year-1925<<" ";}
			else if(year == 1989 && month<1){cout <<"showa "<<year-1925<<" ";}
			else if(year == 1989 && month == 1 && day<8){cout <<"showa "<<year-1925<<" ";}
			else{cout <<"heisei "<<year-1988<<" ";}
			cout<<month<<" "<<day<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        long m = Long.parseLong(sc.next());
        
        System.out.println(Math.abs((n-2) * (m-2)));
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=5e4+9;
const int mod=1e9+7;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    int x=s[s.size()-1]-'0';
    if(x==2||x==4||x==5||x==7||x==9)cout<<"hon";
    if(x==3)cout<<"bon";
    if(x==0||x==1||x==6||x==8)cout<<"pon";
   

    
    
   

}
    

Measured memory_bytes: 3632
import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Set<Integer> nums = new HashSet<>();
      for(int i = 0; i < n; i++) {
        int num = sc.nextInt();
        if(nums.contains(num))
          nums.remove(num);
        else
          nums.add(num);
      }
      System.out.println(nums.size());
  }
}


Measured memory_bytes: 61760
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define COUT(x) cout << (x) << endl
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n, x;
    cin >> n >> x;
    vector<int> L(n);
    rep(i, n) cin >> L[i];
    int ans = 1, cnt = 0;
    rep(i, n) {
        cnt += L[i];
        if(cnt > x) {
            COUT(ans);
            return 0;
        }
        ans++;
    }
    COUT(ans);
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace  std;
struct NodeA
{
    int key;
    NodeA *left;
    NodeA *right;
};
NodeA *head = NULL;
void insert(int key)
{
    NodeA *next = head;
    NodeA *prev = NULL;
    bool isLeft = true;
    while (next != NULL)
    {
        prev = next;
        if ((*next).key >= key)
        {
            next = (*next).left;
            isLeft = true;
        }
        else if ((*next).key <= key)
        {
            next = (*next).right;
            isLeft = false;
        }
    }
    if (prev == NULL)
    {
        head = (NodeA *)malloc(sizeof(NodeA));
        (*head).key = key;
        (*head).left = NULL;
        (*head).right = NULL;
        return;
    }
    if (isLeft)
    {
        (*prev).left = (NodeA *)malloc(sizeof(NodeA));
        (*(*prev).left).key = key;
        (*(*prev).left).left = NULL;
        (*(*prev).left).right = NULL;
    }
    else
    {
        (*prev).right = (NodeA *)malloc(sizeof(NodeA));
        (*(*prev).right).key = key;
        (*(*prev).right).left = NULL;
        (*(*prev).right).right = NULL;
    }
     
}
void inOrder(NodeA *h)
{
    if (h == NULL)return;
    inOrder((*h).left);
    cout << " " << (*h).key;
    inOrder((*h).right);
}
void preOrder(NodeA *h)
{
    if (h == NULL)return;
    cout << " " << (*h).key;
    preOrder((*h).left);
    preOrder((*h).right);
}
void print()
{
    inOrder(head);
    cout << endl;
    preOrder(head);
    cout << endl;
}
int main()
{
    int m;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        string inst;
        cin >> inst;
        if (inst.compare("insert") == 0)
        {
            int key;
            cin >> key;
            insert(key);
        }
        else if (inst.compare("print") == 0)
        {
            print();
        }
    }
    return 0;
}


Measured memory_bytes: 18700
#include "bits/stdc++.h"
using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    vector< int> v(n);
    for(int &e: v) cin >> e;
    long long res = 0;
    for(int i = 1; i < n; i++) {
        if(v[i] + v[i - 1] > x) {
           int k = v[i] + v[i - 1] - x;
           res += k;
           v[i] = max(0, v[i] - k);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 640
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]

    res = 0

    for i in range(K, N+2):
        a = (i-1)*i//2
        c = N-i
        b = N*(N+1)//2 - c*(c+1)//2
        # print(a, b)
        res += b - a +1

    print(res % (10**9 +7))

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9200
##C - City Savers
#1行目
hoge = gets.chomp.to_i

#2,3行目読み込み
x = gets.chomp.split(" ").map!{|i | i.to_i} 
y = gets.chomp.split(" ").map!{|i | i.to_i} 

unchi = 0

for i in 0..(hoge-1) do
  if x[i] >= y[i]
    unchi = unchi + y[i]
  elsif x[i] + x[i+1] > y[i]
    x[i+1] = x[i+1] -y[i] + x[i]
    unchi = unchi + y[i]
  else
    unchi = unchi + x[i] + x[i +1]
    x[i+1] = 0
  end
end

print unchi

Measured memory_bytes: 15652
x = int(input())
c = []
d = []

for i in range(-1000,1000):
    a = int(i**5)
    c.append(a)
    d.append(i)

for j in range (len(c)):
    for k in range (len(c)):
        if c[j]-c[k] == x:
            s = str(d[j])
            t = str(d[k])
            break

print(s + ' ' + t)


Measured memory_bytes: 9248
#include <bits/stdc++.h>
#define REP(i,a) for(long i=0;i<(a);++i)
#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)

typedef double Weight;
const Weight WEIGHT_INF = std::numeric_limits<Weight>::max();
struct Edge {
    int src, dst;
    Weight weight;
};
bool operator<(const Edge& a, const Edge& b) {
    return (a.weight < b.weight);
};
bool operator>(const Edge& a, const Edge& b) {
    return (a.weight > b.weight);
};
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;
Graph g;
std::vector<Weight> costs;
std::vector<int> trace;
void dijkstra(int start){
    int n = g.size();
    costs.resize(n, WEIGHT_INF);
    costs[start] = 0;
    trace.resize(n, -2);

    std::priority_queue<Edge, std::vector<Edge>, std::greater<Edge>> q;
    q.push((Edge){-1, start, 0});
    while(!q.empty()) {
        Edge e = q.top();
        q.pop();

        if(trace[e.dst] != -2) continue;
        trace[e.dst] = e.src;
        EACH(it, g[e.dst]) {
            if(costs[it->dst] > e.weight + it->weight){
                costs[it->dst] = e.weight + it->weight;
                q.push((Edge){it->src, it->dst, e.weight + it->weight});
            }
        }
    }
}

int xs, ys, xt, yt;
int N;
std::vector<int> x, y, r;

int main() {
    int i, j, k;
    double w;

    std::cin >> xs >> ys >> xt >> yt;
    std::cin >> N;

    x.resize(N+2), y.resize(N+2), r.resize(N+2);
    x[0] = xs;   y[0] = ys;   r[0] = 0;
    for(i=1; i<=N; ++i) {
        std::cin >> x[i] >> y[i] >> r[i];
    }
    x[N+1] = xt; y[N+1] = yt; r[N+1] = 0;

    g.resize(N+2);
    for(i = 0; i < N+2; ++i) {
        for(j = 0; j < N+2; ++j) {
            double d = (i == j) ? 0.0 : std::max(0.0, std::sqrt(std::pow(1.*x[i]-x[j], 2.0) + std::pow(1.*y[i]-y[j], 2.0)) - (r[i] + r[j]));
            g[i].push_back(Edge{i, j, d});
        }
    }
    dijkstra(0);
    std::cout << std::fixed << std::setprecision(10) << costs[N+1] << std::endl;
}

Measured memory_bytes: 22264
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


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

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

//メモ用の大きさに迷う
//int dp[];



int main(){

    ll x;
    cin >> x;

    //6,5で毎回転がせばよい
    ll quo = x / 11;
    ll rem = x % 11;

    //あまりが6より大きい時, 0のとき, 1~6のときで場合分け
    if(rem>6) cout << 2*(quo + 1) << endl;
    else if(rem == 0) cout << 2*quo << endl;
    else cout << 2*quo + 1 << endl;

}

Measured memory_bytes: 256
# ABC131D - Megalomania
import sys
input = sys.stdin.readline

from itertools import accumulate


def main():
    N = int(input())
    A = sorted([tuple(map(int, input().split())) for _ in range(N)], key=lambda x: x[1])
    T, D = zip(*A)  # tasks, deadlines
    T = list(accumulate(T))
    flg = all(t <= d for t, d in zip(T, D))  # all tasks finish within each deadline?
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 45928
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        int ans = 0;
        for (int i = 0; i < s.length() / 2; i++) {
            if(s.charAt(i) != s.charAt(s.length() - i - 1)) ans++;
        }
        System.out.println(ans);
    }



    private static class FastScanner {
        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() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            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 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();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}



Measured memory_bytes: 24404
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste
// #include "UnionFind.h"
// #include "power.h"

signed main() {
    int N;
    cin >> N;
    vector<int> L(2 * N);
    for (int i = 0; i < 2 * N; ++i) {
        cin >> L[i];
    }
    sort(L.begin(), L.end(), greater<>());
    int ans = 0;
    for (int i = 0; i < 2 * N; i += 2) {
        ans += L[i + 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())

cases = ['AC', 'WA', 'TLE', 'RE']
ans = [0, 0, 0, 0]
for _ in range(n):
    s = input()
    for i, case in enumerate(cases):
        if s == case:
            ans[i] += 1

for i in range(4):
    print("{} x {}".format(cases[i], ans[i]))


Measured memory_bytes: 9200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int k = in.nextInt();
		String s = in.next();

		if(s.length() <= k) {
			System.out.println(s);
		}else {
			System.out.println(s.substring(0,k) + "...");
		}
	}

}


Measured memory_bytes: 38632
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200000
typedef long long i64;

int n;
int a, b, c, d, e, k;

int input() {
	if (scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k) < 0) return 0;
	return 1;
}

void init() {
}

int solve() {
	return k>=e-a;
}

void output(int ans) {
	printf("%s\n", ans? "Yay!": ":(");
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Measured memory_bytes: 128
def main():
    n, m = map(int, input().split())
    a = [0] * m
    count = 0
    for i in range(n):
        l = list(map(int, input().split()))
        l.pop(0)
        for j in l:
            a[j-1] += 1
            if a[j-1] == n:
                count += 1
    print(count)

if __name__ == '__main__':
    main()


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

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

    int a,b;
    cin >> a >> b;

    if(a > 8 || b > 8){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 105;
vector<pair<int,int>> adj[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;

	vector<pair<int,pair<int,int>>> edges;

	for(int i = 0; i < m; i++) {
		int u, v, c;
		cin >> u >> v >> c;
		u--, v--;
		edges.push_back(make_pair(c, make_pair(u, v)));
		adj[u].push_back(make_pair(v, c));
		adj[v].push_back(make_pair(u, c));
	}

	auto dist = [&](int s, int t) {
		vector<int> d(n, 1e9);
		d[s] = 0;
		priority_queue<pair<int,int>> pq;
		pq.push(make_pair(0, s));
		while(!pq.empty()) {
			int now = pq.top().second;
			pq.pop();
			for(pair<int,int> v : adj[now]) {
				if(d[v.first] > d[now] + v.second) {
					d[v.first] = d[now] + v.second;
					pq.push(make_pair(-d[v.first], v.first));
				}
			}
		}
		return d[t];
	};

	int ans = 0;

	for(auto m : edges) {
		if(dist(m.second.first, m.second.second) < m.first) ans++;
	}
	
	cout << ans;



	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb emplace_back
#define mp std::make_pair
//
#define endl "\n"
//using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
//
constexpr ll MOD=1e9+7;
//constexpr ll MOD=998244353;
//constexpr ll MOD=10000000;
//constexpr ll MOD=1e5;
constexpr ll MAX=1e7;
constexpr ll INF=(1ll<<62);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
const ll N=26;
ll solve(ll D,vii &A,vi &C,vi &S){
    vi last(N,-1);
    ll a=0;
    rep(i,0,D){
        ll memo; memo=S[i];
        last[memo]=i;
        a+=A[i][memo];
        rep(j,0,N) a-=(i-last[j])*C[j];
    }
    return a;
}
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    srand((unsigned)time(NULL));
    ll D; cin>>D;
    vi C(N);
    rep(i,0,N) cin>>C[i];
    vii A(D,vi(N));
    rep(i,0,D){
        rep(j,0,N) cin>>A[i][j];
    }
    vi last(N,-1);
    vi ans(D);
    rep(i,0,D){
        ll max=0,memo=0;
        rep(j,0,N){
            if(max<A[i][j]+(i-last[j])*C[j]){
                max=A[i][j]+(i-last[j])*C[j];
                memo=j;
            }
        }
        last[memo]=i;
        ans[i]=memo;
    }
    ll max=solve(D,A,C,ans);
    rep(_,0,45){
        if(_%2==0){
            rep(i,0,D){
                rep(j,0,N){
                    vi S=ans;
                    S[i]=j;
                    ll X=solve(D,A,C,S);
                    if(max<X){
                        max=X;
                        ans[i]=j;
                    }
                }
            }
        }
        else{
            per(i,D-1,0){
                rep(j,0,N){
                    vi S=ans;
                    S[i]=j;
                    ll X=solve(D,A,C,S);
                    if(max<X){
                        max=X;
                        ans[i]=j;
                    }
                }
            }
        }
    }
    rep(i,0,D) cout<<ans[i]+1<<endl;
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
ll table[300];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll X;
    cin >> X;

    FILL0(table);

    rep(i, 300)
    {
        table[i]=pow(i, 5);
    }

    rep(i, 300)
    {
        rep(j, 300)
        {
            if(table[i]-table[j]==X)
            {
                cout << i << " " << j << endl;
                return 0;
            }


            if(table[i]+table[j]==X)
            {
                cout << i << " " << -1*j << endl;
                return 0;
            }
        }
    }




 

 

    return 0;
}



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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

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

    ll a[200006];

    FOR(i,0,n)
    {
        cin>>a[i];
    }

    if (k>=n)
    {
        cout<<0<<endl;
        return 0;
    }
    else
    {
        sort(a,a+n, greater<ll>());
        ll sum = 0;
        FOR(i,k,n)
        {
            sum += a[i];
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int N = nextInt();
		int[][] A = new int[2][];
		A[0]=nextInts();
		A[1]=nextInts();

		pw.println(f(0,0,1,N-1,A,0));

	}

	public static int f(int x,int y,int gx, int gy ,int[][] A ,int sum) {
		if(x>gx||y>gy) {
			return sum;
		}
		int max = sum;
		if(x==0) {
			max=Math.max(max, f(x+1,y,gx,gy,A,sum+A[x][y]));
		}
		max=Math.max(max, f(x,y+1,gx,gy,A,sum+A[x][y]));
		return max;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> kvec;

    for (int i=1; i<=100; i++) {
        if (A % i == 0 && B % i == 0) {
            kvec.push_back(i);
        }
    }
    sort(kvec.begin(), kvec.end(), greater<int>() );
    cout << kvec.at(K-1) << endl;
    return 0;
}

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

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

	if (a < b) {
		cout << "a < b" << endl;
	}
	else {
		if (a > b) {
			cout << "a > b" << endl;
		}
		else {
			cout << "a == b" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3084
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	int n, m;
	(void)scanf("%d %d", &n, &m);
	vector<int> b(m);
	vector<int> c(n,0);
	vector<vector<int> > a(n, vector<int>(m, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			(void)scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0; i < m; i++) {
		(void)scanf("%d", &b[i]);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			c[i] += b[j] * a[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}


Measured memory_bytes: 2792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define INF 0x7f
#define MOD 1000000007

int max(int a,int b)
{
    if(a >= b)
    {
        return a;
    }
    else
    {
        return b;
    }
}

int main()
{
    int n,m,a[100000],mcount = 0;
    scanf("%d %d",&n,&m);
    for (int i = 0; i < m; i++)
    {
        scanf("%d",&a[i]);
    }
    
    int dp[100010];
    memset(dp,0,sizeof(dp));

    dp[0] = 1;

    for (int i = 1; i <= n ; i++)
    {
        if(i == a[mcount]){
            mcount++;
            dp[i] = 0;
        }
        else
        {
            if(i >= 2)dp[i] = dp[i - 2];
            dp[i] += dp[i - 1];
            dp[i] = dp[i] % MOD;
        }
        //for (int j = 0; j <= i; j++){printf("%d ",dp[j]);}printf("\n");
        
    }
    printf("%d",dp[n]);
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;
typedef long long int ll;

int main(){

  ll n, k, ans=0;
  cin >> n >> k;
  
  if(k==0){
    cout << n*n << endl;
    return 0;
  }
  for(int i=k+1; i<=n; i++){
    ans+=(i-k)*(n/i);
    if(n%i>=k){
      ans+=(n%i)-k+1;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<bool> VB;
typedef std::vector<VB> VBB;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  int h, a;
  std::cin >> h >> a;
  cout((int)std::ceil(1.*h/a));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
typedef double db;
int n;db d,x,ans;
int main(){
    scanf("%d%lf%lf",&n,&d,&x);
    db nn=n+n;
    for(RI i=n;i>=1;--i) {
        ans+=d+(nn-1)/2*x;
        db dd=d+(2*d+5*x)/nn;
        db xx=x+4*x/nn;
        x=xx,d=dd,nn-=2;
    }
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
import bisect

N = int(input())
A = sorted([int(x) for x in input().split()])
B = [int(x) for x in input().split()]
C = sorted([int(x) for x in input().split()])

ans = 0
for j in range(N):
    x = bisect.bisect_left(A, B[j])
    y = N - bisect.bisect_right(C, B[j])
    ans += x * y
print(ans)


Measured memory_bytes: 23616
_s = input()
s = [_s[i] for i in range(len(_s))]

count = 0
# BB...BW...->WBBBBBB...
# つまり連続している分だけカウントが増える
# そして連続数は変わらない
# WWとなったら連続=0とする
b = 0
# 各wにおいて自分より左にあるBの数だけカウントされる
for i in range(len(s)):
    if s[i] == "B":
        b += 1
    else:
        count += b
print(count)


Measured memory_bytes: 5096
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

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

    ios::sync_with_stdio(false);
    cin.tie(0);

    string s; cin >> s;
    string s_wo_x = "";
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != 'x') s_wo_x += s[i];
    }
    if (s_wo_x.size() == 0) {
        cout << 0 << endl;
        return 0;
    }
    string s_wo_x_inv = s_wo_x;
    reverse(s_wo_x_inv.begin(), s_wo_x_inv.end());
    if (s_wo_x != s_wo_x_inv) {
        cout << -1 << endl;
        return 0;
    }
    
    int len = (int)s_wo_x.size() + 1;
    
    vector<int> x_cnt(len, 0);
    int ind = 0;
    
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'x') x_cnt[ind]++;
        else ind++;
    }
    
    int ans = 0;
    for (int i = 0; i < len / 2; i++) {
        ans += abs(x_cnt[i] - x_cnt[len - 1 - i]);
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 976
#include <iostream>

using namespace std;

int abss(int a){
    if(a < 0)
        return a * (-1);
    return a;
}

int absss(int a, int b){
    if(a > b)
        return a - b;

    return b - a;
}

int main(){

    int N, K;
    int a[100001];

    cin >> N >> K ;
    for(int i = 0; i < N; i++)
        cin >> a[i];

    int min = 1000000000;
    int diff = N - K + 1;
    for(int i = 0; i < diff; i++){
        int x = abss(a[i]);
        int y = abss(a[i + K-1]);
        int z = absss(a[i], a[i + K-1]);
        if(x + z < min)
            min = x + z;
        if(y + z < min)
            min = y + z;
    }

    cout << min << '\n';

}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int n;
   cin>>n;
   vector <int> a(n);
   int k=1;
   for (int i=0;i<n;i++)
   {
      cin>>a[i];
      if (a[i]==k)
         k++;
   }
   if (k==1)
   {
      cout<<-1;
   }
   else
   {
      cout<<n-(k-1);
   }
}


Measured memory_bytes: 1024
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    std::string s;
    std::cin >> s;
    int n = s.size();
    rep(i, n) {
        repeat(j, i, n) {
            if(s.substr(0, i) + s.substr(j, n - j) == "keyence") {
                std::cout << "YES" << std::endl;
                return;
            }
        }
    }
    std::cout << "NO" << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
import math
from sys import stdin


def get_result(data):
    A, B, H, M = data
    h_deg = (H + M/60.0) * 30.0
    m_deg = M * 6.0
    theta = math.radians(abs(m_deg - h_deg))
    ans = math.sqrt(A**2+B**2 - 2*A*B*math.cos(theta))
    return ans


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)


Measured memory_bytes: 62640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
 
 
int main(){
ll N,K;
  cin >> N>> K;
  vl vec(N);
  rep(i,N){
    cin >> vec.at(i);
  }
  ll ans =0;
  sort(vec.begin(), vec.end());
    rep(j,K){
    ans += vec.at(j);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h> 
using namespace std;   
using ll = long long;
const int INF = 1e9 + 5;
int main() 
{ 
	int n; cin >> n;
	vector<int > h(n);
	for(int& x : h) cin >> x;
	vector<int > dp(n, INF);
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j : {i + 1, i + 2}) {
			if(j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n-1];

    return 0; 
} 

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

long long func(long long n){
	if(n == 1){
		return 1;
	}else{
		return n*func(n-1);
	}
}

int main(){

	long long n;
	scanf("%lld",&n);
	printf("%lld\n",func(n));

    return 0;
}



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

namespace ARC068
{
    class C
    {
        static void Main(string[] args)
        {
            long x = long.Parse(Console.ReadLine());

            long a = x / 11;
            long b = x % 11;

            if (a == 0 && b <= 6) { Console.WriteLine(1); return; }
            else if (a == 0 && 6 < b) { Console.WriteLine(2); return; }

            if (0 < a && 0 <= b)
            {
                if (0 < b && b <= 6) { Console.WriteLine(2 * a + 1); return; }
                else if (6 < b) { Console.WriteLine(2 * a + 2); return; }
                else if (b == 0) { Console.WriteLine(2 * a); return; }
            }
        }
    }
}


Measured memory_bytes: 11092