akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

void jagdeA( const string& str )
{
	int count = 0;
	int i;


	for( i = 2;i < str.size();i++ ){
		if( str[i] == '=' ) count++;
		else if( count && str[i] == '#' ) break;
		else{
			cout << "NA" << endl;
			return;
		}
	}
	if( i == str.size() ){
		cout << "NA" << endl;
		return;
	}

	i++;
	for(; i < str.size(); i++ ){
		if( str[i] == '=' ) count--;
		else if( str[i] == '~' ) break;
		else{
			cout << "NA" << endl;
			return;
		}
	}

	if( count || i == str.size() ) {
		cout << "NA" << endl;
		return;
	}

	cout << "A" << endl;
	return;
}

void jagdeB( const string& str )
{
	int count = 0;
	int i;

	for( i = 2;i < str.size();i += 2 ){
		if( i + 1 >= str.size() ){
			cout << "NA" << endl;
			return;
		}
		if( str[i] == 'Q' && str[i + 1] == '=' ){
			count++;
		} else if( str[i] == '~' && str[i + 1] == '~' && count ){
			cout << "B" << endl;
			return;
		} else {
			cout << "NA" << endl;
			return;
		}
	}

	cout << "NA" << endl;
	return;
}



int main(int argc, char const* argv[])
{
	int n;
	string str;

	cin >> n;

	for( int i = 0;i < n;i++ ){
		cin >> str;
		if( str.size() < 6 || str[0] != '>' ){
			cout << "NA" << endl;
			continue;
		}

		switch( str[1] ){
			case '\'':
				jagdeA( str );
				break;
			case '^':
				jagdeB( str );
				break;
			default:
				cout << "NA" << endl;
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>          // printf(), scanf(), getc(), ungetc()
#include <stdlib.h>         // abs()
#include <stdbool.h>

#define NX 4
#define NY 2

int puzz[NY][NX];
int lineno;

void
swap(int *a, int *b)
{
	int temp = *a;
	*a = *b;
	*b = temp;
}

int
cal()
{
	int sum = 0;
	for (int i = 0; i < 8; ++i)
	{
		int a = puzz[i / NX][i % NX];
		if (a)
			sum += abs(i / NX - a / NX) + abs(i % NX - a % NX);
	}

	return sum;
}

int
dfs(int x, int y, int p, int dep, const int lim)
{
	static const int dx[4] = { 0, 1, 0,-1};
	static const int dy[4] = { 1, 0,-1, 0};

	int h = cal();
	if (h == 0)
		return dep;

	if (dep + h > lim)
		return -1;

	for (int i = 0; i < 4; ++i)
	{
		int nx = x + dx[i], ny = y + dy[i];
		if (p != -1 && i == (p + 2) % 4)
			continue;

		if (0 <= nx && nx < NX && 0 <= ny && ny < NY)
		{
			swap(&puzz[y][x], &puzz[ny][nx]);
			int res = dfs(nx, ny, i, dep + 1, lim);
			if (res != -1)
				return res;

			swap(&puzz[y][x], &puzz[ny][nx]);
		}
	}

	return -1;
}

bool
ope_line()
{
	int buff[NY][NX];
	lineno++;

	int c = getc(stdin);
	if (c == EOF)
		return false;

	ungetc(c, stdin);
	int x, y;
	for (int i = 0; i < NY; ++i)
	{
		for (int j = 0; j < NX; ++j)
		{
			static int a = 0;
			scanf("%d", &a);
			puzz[i][j] = a;
			if (a == 0)
			{
				x = j;
				y = i;
			}
		}
	}

	for (int l = 0; l < 100; ++l)
	{
		for (int i = 0; i < NY; ++i)
		{
			for(int j = 0; j < NX; ++j)
				buff[i][j] = puzz[i][j];
		}

		int ans = dfs(x, y, -1, 0, l);
		if (ans != -1)
		{
			printf("%d\n", ans);
			break;
		}

		for (int i = 0; i < NY; ++i)
		{
			for(int j = 0; j < NX; ++j)
				puzz[i][j] = buff[i][j];
		}

		if (l >= 99)
			printf("%d\n", ans);
	}

	c = getc(stdin);
	if (c == EOF)
		return false;

	return true;
}

int
main(int argc, char **argv)
{
	lineno = 0;
	while (ope_line())
		;

	return 0;
}

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

int main() {
  long long N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  
  int flag[N], flag2[N];
  for (int i = 0; i < N; i++) flag[i] = flag2[i] = -1;
  
  long long now = 0;
  long long count = 0;
  while (count < K){
    if (S[now] == 'o'){
      flag[now] = count;
      now += C;
      count++;
    }
    now++;
  }
  
  now = N - 1;
  count = 0;
  while (count < K){
    if (S[now] == 'o'){
      flag2[now] = K - 1 - count;
      now -= C;
      count++;
    }
    now--;
  }
  
  for (int i = 0; i < N; i++){
    if (flag[i] == flag2[i] && flag[i] >= 0) cout << i + 1 << endl;
  }
}

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

int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int resultNum = a1 + a2 + a3;
    if(resultNum >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MOD = 1000000007;

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

long long comb(long long n, long long a, long long mod) {
  if (a == 0)
    return 1;

  long long res = 1;
  for (auto i = 1; i <= a; i++) {
    res = (res * (n - a + i)) % mod;
  }
  long long d = 1;
  for (auto i = 1; i <= a; i++) {
    d = (d * i) % mod;
  }

  res = (res * modpow(d, mod - 2, mod)) % mod;
  return res;
}

long long int n, a, b;

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

  int res = modpow(2, n, MOD) - 1;
  res = (res + MOD - comb(n, b, MOD)) % MOD;
  res = (res + MOD - comb(n, a, MOD)) % MOD;

  cout << res << endl;

  return 0;
}

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

int main(){
  
  long N, K, Q;
  
  cin >> N >> K >> Q;
  vector<long> P(N, 0);
  long tmp;
  
  for(long i = 0; i < Q; i++){
    cin >> tmp;
    P.at(tmp - 1) += 1;
  }
  
  for(long i = 0; i < N; i++){
    if (P.at(i) + K - Q > 0) cout << "Yes";
    else cout << "No";
    if(i != N - 1) cout << endl;
  }
  
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

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

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

int main() {
	int N, M; cin >> N >> M;
	vector<Pi> bomb(N); cin >> bomb;
	vint sa(N+1);
	vector<Pi> dat(M); cin >> dat;
	vector<vector<Pi>> G(N+1);
	vint ans(M, 0);

	sort(begin(bomb), end(bomb));

	sa[0] = bomb[0].second, sa[N] = bomb[N-1].second;
	for (int i = 1; i < N; i++) sa[i] = (bomb[i].second ^ bomb[i-1].second);

	for (int i = 0; i < M; i++) {
		auto &v = dat[i];
		int l = v.first, r = v.second;
		int posl = lower_bound(begin(bomb), end(bomb), Pi(l, -INF)) - begin(bomb);
		int posr = upper_bound(begin(bomb), end(bomb), Pi(r, INF)) - begin(bomb);
		v.first = posl, v.second = posr;
		if (posl == posr) continue;
		G[posl].emplace_back(posr, i);
		G[posr].emplace_back(posl, i);
	}
	
	vector<bool> flag(N+1);
	function<bool(int, int)> dfs = [&](int u, int index) -> bool {
		if (flag[u]) return (false);
		flag[u] = true;
		for (auto &v : G[u]) dfs(v.first, v.second);

		if (sa[u] == 1) {
			if (index == -1) return (true);
			int a = dat[index].first, b = dat[index].second;
			sa[a] = 1 - sa[a], sa[b] = 1 - sa[b];
			ans[index] = 1;
		}
		return (false);
	};

	for (int i = 0; i <= N; i++) {
		if (dfs(i, -1)) {
			cout << -1 << endl;
			return (0);
		}
	}
	
	vint ansd;
	for (int i = 0; i < M; i++) {
		if (ans[i]) ansd.push_back(i+1);
	}
	cout << ansd.size() << endl;
	
	if (ansd.size() == 0) { cout << endl; return (0); }
	cout << ansd[0];
	for (int i = 1; i < ansd.size(); i++) cout << " " << ansd[i];
	cout << endl;
	return (0);
}


Measured memory_bytes: 17532
#input
N = int(input())
S = str(input())

#output
import numpy as np
answer = 0
R = np.zeros(N, int)
G = np.zeros(N, int)
B = np.zeros(N, int)
for i in range(N):
    if S[i] == "R":
        R[i] = 1
    elif S[i] == "G":
        G[i] = 1
    elif S[i] == "B":
        B[i] = 1
R = np.cumsum(R)
G = np.cumsum(G)
B = np.cumsum(B)
RR = R[-1]
GG = G[-1]
BB = B[-1]

if N > 3:
    for i in range(1, N-1):
        if S[i] == "R":
            a = G[i]
            b = BB - B[i]
            c = B[i]
            d = GG - G[i]
            answer += a*b + c*d
            for j in range(1, min(i+1, N-i)):
                if S[i-j] != "R" and S[i+j] != "R" and S[i-j] != S[i+j]:
                    answer -= 1
        elif S[i] == "G":
            a = B[i]
            b = RR - R[i]
            c = R[i]
            d = BB - B[i]
            answer += a*b + c*d
            for j in range(1, min(i+1, N-i)):
                if S[i-j] != "G" and S[i+j] != "G" and S[i-j] != S[i+j]:
                    answer -= 1
        elif S[i] == "B":
            a = R[i]
            b = GG - G[i]
            c = G[i]
            d = RR - R[i]
            answer += a*b + c*d
            for j in range(1, min(i+1, N-i)):
                if S[i-j] != "B" and S[i+j] != "B" and S[i-j] != S[i+j]:
                    answer -= 1
        
print(answer)

Measured memory_bytes: 27136
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void){
  int j,i,n,m,best=0;
  char sn[100][10],tm[100][10];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%s",sn[i]);
  scanf("%d",&m);
  for(i=0;i<m;i++)scanf("%s",tm[i]);
  for(i=0;i<n;i++){
    int scr=0;
    for(j=0;j<n;j++){
      if(strcmp(sn[i],sn[j])==0)scr++;
    }
    for(j=0;j<m;j++){
      if(strcmp(sn[i],tm[j])==0)scr--;
    }
    if(best<scr) best=scr;
  }
  printf("%d",best);
  return 0;
}

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

int main() {
  int n,m;
  int l=0;
  cin >> n >> m;
  vector<int>a(m);
  for(int i=0;i<m;i++){
  cin >> a.at(i);
  l+=a.at(i);
  }
  cout << max(n-l,-1) << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N; cin >> N;
    vll a(N); rep(i, N) cin >> a[i];
    a.insert(a.begin(), 0);
    //for (auto elem : a) cout << elem << " "; cout << endl;

    vll balls(N + 1);
    for (int i = N; i > 0; i--) {
        ll j = i;
        ll cnt = 0;
        while (j <= N) {
            //cout << "J: " << j << ": " <<  balls[j] << endl;
            cnt += balls[j];
            j += i;
        }
        cnt = cnt % 2;
        //cout << "cnt: " << cnt << endl;
        //cout << "a[i]: " << a[i] << endl;
        if (cnt != a[i]) balls[i] = 1;
    }

    cout << count(all(balls), 1) << endl;
    rep(i, N + 1) {
        if (balls[i]) cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 4712
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
    	if (s[i] == 'U' || s[i] == 'D') continue;
    	if (i % 2 == 0) {
    		if (s[i] != 'R') return cout << "No", 0;
    	}
    	else {
    		if (s[i] != 'L') return cout << "No", 0;
    	}
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define INF (1<<29)

using namespace std;

template<class T>
struct treap{
  struct node_t{
    T val;
    T sum;
    node_t *lch, *rch;
    int pri;
    int cnt;
    node_t(T v, int p):val(v),pri(p),cnt(1),sum(v){
      lch=rch=NULL;
    }
  };
  node_t *root;
  treap():root(NULL){}

  int count(node_t *t){return t?t->cnt:0; }
  T   sum(node_t *t){return t?t->sum:INF;}
  int size(){return count(root);}

  node_t *update(node_t *t){
    t->cnt=count(t->lch)+count(t->rch)+1;
    t->sum=min(min(sum(t->lch),sum(t->rch)),t->val);
    return t;
  }
  node_t *merge(node_t *l, node_t *r){
    if(!l||!r) return l?l:r;
    if(l->pri>r->pri){
      l->rch=merge(l->rch,r);
      return update(l);
    }
    else{
      r->lch=merge(l,r->lch);
      return update(r);
    }
  }
  pair<node_t*,node_t*> split(node_t *t,int k){
    if(!t) return make_pair((node_t*)NULL,(node_t*)NULL);
    if(k<=count(t->lch)){
      pair<node_t*,node_t*>s=split(t->lch,k);
      t->lch=s.second;
      return make_pair(s.first,update(t));
    }
    else{
      pair<node_t*,node_t*>s=split(t->rch,k-count(t->lch)-1);
      t->rch=s.first;
      return make_pair(update(t),s.second);
    }
  }
  node_t *insert(node_t *t,int k,T val,int pri){
    pair<node_t*, node_t*>s=split(t,k);
    t=merge(s.first, new node_t(val,pri));
    t=merge(t,s.second);
    return update(t);
  }

  node_t *erase(node_t *t,int k){
    pair<node_t*, node_t*>s1,s2;
    s2=split(t,k+1);
    s1=split(s2.first,k);
    t=merge(s1.first,s2.second);
    return update(t);
  }

  void insert(int k,T val){root=insert(root,k,val,rand());}
  void erase(int k){root=erase(root,k);}

  void shift(int l,int r){
    pair<node_t*,node_t*>a,b,c;
    c=split(root,r);
    b=split(c.first,r-1);
    a=split(b.first,l);
    root=merge(a.first,b.second);
    root=merge(root,a.second);
    root=merge(root,c.second);
  }
  int query(int l,int r,node_t *t){
    int sz=count(t);
    if(sz<=l || r<=0)return INF;
    if(l<=0 && sz<=r)return sum(t);

    int c=count(t->lch);
    int vl=query(l,r,t->lch);
    int vr=query(l-c-1,r-c-1,t->rch);
    int res=min(vl,vr);
    if(l<=c && c<r)res=min(res,t->val);
    return res;
  }
};

int main(void){

  srand(time(NULL));
  int n,q;
  treap<int> t;

  cin >> n >> q;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    t.insert(i,a);
  }

  for(int i=0;i<q;i++){
    int x,y,z;
    cin >> x >> y >> z;

    if(x==0)t.shift(y,z+1);
    else if(x==1)cout << t.query(y,z+1,t.root) << endl;
    else if(x==2){
      t.erase(y);
      t.insert(y,z);
    }
  }

  return 0;
}

Measured memory_bytes: 13708
package main

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

const MaxBuf = 200100
var buf []byte = make([]byte,MaxBuf)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf,MaxBuf)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	sc.Scan()
	r,_ := strconv.Atoi(sc.Text())
	return r
}

func readInt64() int64 {
	sc.Scan()
	r,_ := strconv.ParseInt(sc.Text(),10,64)
	return r
}

func readFloat64() float64 {
	sc.Scan()
	r,_ := strconv.ParseFloat(sc.Text(),64)
	return r
}

func main() {
	h := readInt()
	w := readInt()
	a := make([]string,h)
	for i := 0; i < h ; i++ {
		a[i] = readString()
	}
	s := strings.Repeat("#",w+2)

	fmt.Println(s)
	for i := 0; i < h ; i++ {
		fmt.Printf("#%s#\n",a[i])
	}
	fmt.Println(s)


}

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

public class Hello{
    public static void Main(){
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        
        var l = 0;
        var r = 0;
        var count = 0;
        
        while(r < N){
            
            if(A[l] == A[r]){
                r++;
            }else{
                count += (r - l) / 2;
                l = r;
            }
            if(r == N){
                count += (r - l) / 2;
            }
            //Console.WriteLine(count);
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 13268
/* ex3-3
    kas056*/

#include<stdio.h>
#include<stdlib.h>

int main(void){
    int i,j;
    int row, column;
    char **ptr;
    int *judge_r, *judge_c;
    scanf("%d %d" ,&row, &column);

    

    //ptrのメモリ確保
    ptr = (char**)calloc(row, sizeof(char*));

    if(ptr == NULL){
        exit(1);
    }
    
    for(i=0; i<row; i++){
        ptr[i] = (char*)calloc(column, sizeof(char));
        if(ptr[i] == NULL){
            exit(1);
        }
    }

    //judge_rのメモリ確保
    judge_r = (int*)calloc(row, sizeof(int));
    if(judge_r == NULL){
        exit(1);
    }

    //judge_cのメモリ確保
    judge_c = (int*)calloc(column, sizeof(int));

    if(judge_c == NULL){
        exit(1);
    }


    for(i=0; i<row; i++){
        for(j=0; j<column; j++){
            scanf(" %c", &ptr[i][j]);
        }
    }

    //＃があるか判定
    for(i = 0; i < row; i++){//まず行を固定して
        for (j = 0; j < column; j++){//その行の各要素に対して
            if(ptr[i][j] == '#'){//＃と一致するものがあったら終了する。
                break;
            }
        }

        if(j == column){//最後まで＃がなかったら
            judge_r[i] = 1;
        }
    }

    for(j = 0; j < column; j++){//列を固定して、行の場合と同様の操作を行う
        for(i = 0; i < row; i++){
            if(ptr[i][j] == '#'){
                break;
            }
        }
        if(i == row){
            judge_c[j] = 1;
        }
    }

    for(i=0; i<row; i++){//ある行において＃があった時、かつ
        if(judge_r[i] == 0){
            for(j = 0; j<column; j++){//その列に＃があったとき、
                if(judge_c[j] == 0){
                    printf("%c", ptr[i][j]);//(i,j)番目の文字を一文字出力
                }
            }//折り返し。これをcolumnの数だけ繰り返す
            printf("\n");//終点で改行
        }
    }//これをrowの数だけ繰り返す

    //逆順に開放
    for(i=0; i<row;i++){
        free(ptr[i]);
    }
    free(ptr);

    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));
  ll ans = 0;
  REP(i, k) { ans += a[i]; }
  cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	int n;
	long mod=1000000000+7;
	
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		FermatCombination fc=new FermatCombination(h+w,mod);
		
		long sum=0;
		for(int i=0;i<h-a;i++){
			sum+=fc.combine(b-1+i, i)*fc.combine(w-b-1+h-1-i,w-b-1) %mod;
			sum%=mod;
		}
		System.out.println(sum);
		
	}
	class FermatCombination{
		
			long factrial[]; //階乗を保持 
			long inverse[];  //逆元を保持 
		    long MOD;
		    
		    FermatCombination(int size, long mod) { 
				 
	 		this.factrial = new long[size + 1]; 
		 		this.inverse = new long[size + 1]; 
		 		this.MOD = mod; 
		 		 
		 		this.factrial[0] = 1; 
		 		this.inverse[0] = 1; 
		 		 
		 		for (int i = 1; i <= size; i++) { 
		 			factrial[i] = (factrial[i - 1] * i) % MOD;  //階乗を求める 
		 			inverse[i] = pow(factrial[i], (int) MOD - 2) % MOD; // フェルマーの小定理で逆元を求める 
		 		} 
		 	} 

 	 
 	long combine(int n, int k) { 
 		
 		return ((factrial[n] * inverse[k]) % MOD * inverse[n - k] % MOD)%MOD;
 	} 
 	 
 	long pow(long x, int n) { //x^n 計算量O(logn) 
 		long ans = 1; 
 		while (n > 0) { 
 			if ((n & 1) == 1) { 
 				x %= MOD;
				ans = ans * x % MOD ; 
 			} 
 			x = x *  x % MOD; //一周する度にx, x^2, x^4, x^8となる 
 			x%=MOD;
 			n >>= 1; //桁をずらす n = n >> 1 
 		} 
 		return ans % MOD; 
 	} 
	}

}


Measured memory_bytes: 25940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n;cin>>n;
    cout<<(n+110)/111*111<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
	char a[5][3]={ "a", "e", "i", "o", "u"};
	string s;
	cin>>s;
	for(int i=0;i<5;i++){
		if(a[i]==s) {
			cout<<"vowel"<<endl;
			return 0;
		}
	}
	cout<<"consonant"<<endl;
	return 0;
} 


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

using namespace std;
int main()
{
    string s;
    cin>>s;
    
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==s[i+1])
        {
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
        if(i==s.size()-1)   break;
        if(s[i]==s[i+2])
        {
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
    return 0;
}

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

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

  vector<ll> s(a);
  rep(i, a) cin >> s[i];
  vector<ll> t(b);
  rep(i, b) cin >> t[i];
  vector<ll> x(q);
  rep(i, q) cin >> x[i];

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  rep(i, q) {
    ll ans = 2 * 10'000'000'000;
    int slb = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
    int tlb = lower_bound(t.begin(), t.end(), x[i]) - t.begin();

    if (slb < a && tlb < b) ans = min(ans, max(s[slb], t[tlb]) - x[i]);
    if (slb > 0 && tlb > 0) ans = min(ans, x[i] - min(s[slb - 1], t[tlb - 1]));
    if (slb < a && tlb > 0) {
      ll d1 = s[slb] - x[i];
      ll d2 = x[i] - t[tlb - 1];
      ans = min(ans, d1 + d2 + min(d1, d2));
    }
    if (slb > 0 && tlb < b) {
      ll d1 = x[i] - s[slb - 1];
      ll d2 = t[tlb] - x[i];
      ans = min(ans, d1 + d2 + min(d1, d2));
    }

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3712
#include<iostream>

using namespace std;

int main(){
    int N;
    cin >>N;
    
    long A[N+1];
    for(int i=0;i<N+1;i++){
        cin >> A[i];
    }

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

    long m = 0;
    long r = 0;
    
    for(int i=0; i< N;i++){
        if(A[i] > r){
            A[i]-=r;
            m+=r;
            if(A[i] < B[i]){
                m+=A[i];
                r= B[i] - A[i];
            }
            else{
                m+=B[i];
                r=0;
            }
        }
        else{
            m+=A[i];
            r=B[i];
        }
    }
    m+=min(A[N],r);

    cout << m;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    rep(i, INT_MAX){
        if(i * (i + 1) / 2 >= n){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    A = LI()
    B = LI()

    a = sum(A)
    b = sum(B)
    t = b - a
    if t < 0:
        print('No')
        return 
    a_cnt = 0
    b_cnt = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        if a > b:
            c = a - b
            b_cnt += c
        elif a < b:
            c = b - a
            if c % 2 == 0:
                a_cnt += (c // 2)
            else:
                a_cnt += (c // 2) + 1
                b_cnt += 1
    # print(a_cnt, b_cnt, t - a_cnt, t - b_cnt)
    a_left = t - a_cnt
    b_left = t - b_cnt
    if a_left >= 0 and b_left >= 0:
        if a_left * 2 == b_left:
            print('Yes')
    else:
        print('No')

                
            

if __name__ == '__main__':
    solve()



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

int main(){
    int W;
    int H;
    int x;
    int y;
    int r;
    cin >> W >> H >> x >> y >> r;
    
    if (0 <= x-r && 0 <= y-r && W >= x+r && H >= y+r){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      for(int i = 0; i < one.get(0); i++){
        String s = next();
        myout(s);
        myout(s);
      }
	}
	//Method addition frame start


  
	//Method addition frame end
}


Measured memory_bytes: 33008
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef long double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int SIZE=2*1e5;
const int INF=1LL<<30;
const LL p=7+1e9;
const int rev=10000;
const int rev2=rev*2;
Vpr edges[SIZE];
int dist[SIZE];
ld nokori[SIZE];
LL V,E;
ld dfs(int now,ld nowflow){
	ld ans=0;
	if(now==V-1){
		return nowflow;
	}
	REP(i,edges[now].size()){
		int next=edges[now][i].first;
		int noko=edges[now][i].second;
		if(dist[next]!=dist[now]+1) continue;
		if(nokori[noko]==0) continue;
		ld inc=dfs(next,min(nokori[edges[now][i].second],nowflow));
		nowflow-=inc;
		nokori[noko]-=inc;
		nokori[(noko+rev)%rev2]+=inc;
		ans+=inc;
	}
	return ans;
}
int bfs(){
	queue<int> qu;
	dist[0]=0;
	qu.push(0);
	while(!qu.empty()){
		int now=qu.front();
		qu.pop();
		REP(i,edges[now].size()){
			int next=edges[now][i].first;
			ld noko=nokori[edges[now][i].second];
			if(noko>0 && dist[next]==INF){
				dist[next]=dist[now]+1;
				qu.push(next);
			}
		}
	}
	return dist[V-1];
}
ld dinic(){
	ld ans=0;
	while(true){
		int dists;
		REP(i,V) dist[i]=INF;
		dists=bfs();
		//cout << dists << endl;
		if(dists==INF) return ans;
		ans+=dfs(0,INF);	
		//cout << ans << endl;
	}

}
LL solve(){
	cin >> V >> E;
	LL s,t;
	ld c;
	REP(i,E){
		cin >> s >> t >> c;
		if(c==1) c-=0.00001;
		nokori[i]=c;
		nokori[i+rev]=c;
		edges[s].PB(pr(t,i));
		edges[t].PB(pr(s,i+rev));
	}
	ld ans=dinic();
	return (int)ans;
}
int main(){
	int ans=solve();
	if(ans>1e4){
		cout << -1 << endl;
	}
	else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 8436
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    a, p = makeMultiInteger(input_string[0])
    #print(a, p)
    p += a*3
    #print(p)
    return p//2


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from collections import deque
INF = 1e9
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]


def bfs(sy, sx):
    if wall[sy][sx]=="#":
        return 0
    que = deque()
    que.append((sy, sx))
    d[sy][sx] = 0
    m = 0
    while len(que) > 0:
        y, x = que.popleft()

        for i in range(4):
            ny = y+dy[i]
            nx = x+dx[i]
            if 0 <= ny and ny < h and 0 <= nx and nx < w and wall[ny][nx] != "#" and d[ny][nx] == INF:
                que.append((ny, nx))
                d[ny][nx] = d[y][x]+1
                m = max(d[ny][nx],m)
    return m


h, w = map(int, input().split())
wall = [list(input()) for _ in range(h)]

ans = 0
for i in range(h):
    for j in range(w):
        d = [[INF]*w for _ in range(h)]
        a = bfs(i, j)
        ans = max(ans, a)
print(ans)


Measured memory_bytes: 3316
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double ans = 0;
        for (int i = 0; i < N; i++) {
            double x = sc.nextDouble();
            String u = sc.next();
            ans += u.equals("BTC") ? x * 380000.0 : x;
        }
        sc.close();
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int n;
double l;

int main(){
	cout<<syosu(9);
	cin>>n>>l;
	deque<pdd> deq;
	double sx=0,sy=0,t,v;
	cin>>t>>v;
	deq.push_back({0,0});
	cout<<t<<endl;
	sx+=v;
	sy+=t*v;
	deq.push_front({-sx,-sy});
	for(int i=1;i<n;i++){
		cin>>t>>v;
		sx+=v;
		sy+=t*v;
		pdd p;
		double L=l-sx;
		while(deq.back().first-eps>L){
			p=deq.back();
			deq.pop_back();
		}
		pdd tmp=deq.back();
		double lx=tmp.first,ly=tmp.second,rx=p.first,ry=p.second;
		deq.push_back({L,(ry-ly)*(L-lx)/(rx-lx)+ly});
		cout<<(deq.back().second+sy)/l<<endl;
		while(deq.size()>1){
			tmp=deq.front();
			deq.pop_front();
			p=deq.front();
			lx=tmp.first,ly=tmp.second,rx=p.first,ry=p.second;
			if((ly+sy)/(lx+sx)>(ry+sy)/(rx+sx)-eps){
				deq.push_front(tmp);
				break;
			}
		}
		deq.push_front({-sx,-sy});
	}
}

Measured memory_bytes: 18196
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll H, M, h, m, K;
	cin >> H >> M >> h >> m >> K;
	cout <<(h*60+m)-(H*60+M)-K << endl;



}



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

char buf[1024];
int M;
bool checkA(){
  if( buf[0] != '>' ) return false;
  if( buf[1] != '\'') return false;
  int cnt1=0,cnt2=0;
  bool f = false;
  int i;
  for(i=2;i<M;i++){
    if(!f){
      if( buf[i] == '=' ) cnt1++;
      else if( buf[i] == '#' ) f = true;
      else return false;
    } else {
      if( buf[i] == '=' ) cnt2++;
      else break;
    }
  }
  if( buf[i] != '~' ) return false;
  i++;
  if( i == M && cnt1 == cnt2 && cnt1>0 && f ) return true;
  return false;
}

bool checkB(){
  if( buf[0] != '>' ) return false;
  if( buf[1] != '^' ) return false;
  int i;
  bool f = false;
  for(i=2;i<M-2;i+=2){
    if( buf[i] != 'Q' ) return false;
    if( buf[i+1] != '=' ) return false;
    f = true;
  }
  if( f && buf[i] == '~' && buf[i+1] == '~' && i + 2 == M ) return true;
  return false;
}

int main(){
  int n; cin >> n;
  for(int i=0;i<n;i++){
    cin >> buf; M = strlen(buf);
    if( checkA() ) cout << "A" << endl;
    else if( checkB() ) cout << "B" << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 1156
int main( void )
{
	int card_num, number, count;
	int card_check[4][14] = {};
	int typ_cou,num_cou;
	char card_typ;

	
	scanf( "%d", &number );
	
	count = 0;
	
	for( count = 0; count <= number; count++ )
	{
		scanf( "%c %d\n", &card_typ, &card_num );
		
		if( card_typ == 'S' )
		{
			card_check[0][card_num] = card_num;
		}
		else
		if( card_typ == 'H' )
		{
			card_check[1][card_num] = card_num;
		}
		else
		if( card_typ == 'C' )
		{
			card_check[2][card_num] = card_num;
		}
		else
		if( card_typ == 'D' )
		{
			card_check[3][card_num] = card_num;
		}
	}

	for( typ_cou = 0; typ_cou < 4; typ_cou++ )
	{
		num_cou = 1;

		while( num_cou < 14 )
		{
			if( card_check[typ_cou][num_cou] != num_cou )
			{
				if( typ_cou == 0 )
				{
					printf( "S %d\n", num_cou );
				}else
				if( typ_cou == 1 )
				{
					printf( "H %d\n", num_cou );
				}else
				if( typ_cou == 2 )
				{
					printf( "C %d\n", num_cou );
				}else
				if( typ_cou == 3 )
				{
					printf( "D %d\n", num_cou );
				}
			}
			num_cou++;
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
import java.util.*;

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

        StringBuilder s = new StringBuilder(sc.next());
        if(s.charAt(0) != 'A'){
            s.insert(0, 'A');
        }
        int index = s.indexOf("HB");
        if(index != -1){
            s.insert(index + 1, "A");
        }
        index = s.indexOf("BR");
        if(index != -1){
            s.insert(index + 1, "A");
        }
        if(s.charAt(s.length() - 1) != 'A'){
            s.insert(s.length(), 'A');
        }

        System.out.println(s.toString().equals("AKIHABARA") ? "YES" : "NO");

    }
}


Measured memory_bytes: 21840
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r,a,b,c,d;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	a = x+r;
	b = x-r;
	c = y+r;
	d = y-r;
	
	if(0 <= a && a <= W && 0 <= b && b <= W && 0 <= c && c <= H && 0 <= d && d <= H)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define eps 0.000000001
using namespace std;
int n, a[200001], k, sum = 0, x, p, ans, cnt = 0;
double l, mx = LONG_MAX;
int calcK(double val){
    int ret = 0;
    for(int i = 0; i < n; i++){
        ret += ceil(a[i] * 1.0 / val);
    }
    return ret;
}
void go(double l, double r){
    if(cnt ++ > 1000)return;
    double m = (l + r) / 2.0;
    if(calcK(m) > k){
        go(m, r);
    }
    else {
        mx = min(mx, m);
        go(l, m);
    }
}
void solve(){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    k += n;
    go(0.0, 10000000001.0);
    ans = ceil(mx);
    cout << ans << endl;
}
main(){
    ios_base::sync_with_stdio(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


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

int main(){
                                                                     

    string s;

    int i;

    int k = 0;

    
    cin >> s;


    for( i = 0 ; i < s.size() ; i = i + 1 ){

         if( s.at(i) == '+' ) k += 1;

         else k -= 1;   

         }


    cout << k << endl;


    return 0;

    }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static long[][] route;
	static int N;
	static int R;
	static int[] r;
	static long cost=3641145141919810L;
	public static void main (String[] args){
		SC sc=new SC(System.in);
		N=sc.nextInt();
		int M=sc.nextInt();
		R=sc.nextInt();
		r=new int[R];
		for(int i=0; i<R; i++) {
			r[i]=sc.nextInt()-1;
		}
		route=new long[N][N];
		long INF=1_145_141_919_810_364L;
		for(int i=0; i<N; i++) {
			Arrays.fill(route[i],INF);
		}
		for(int i=0; i<M; i++) {
			int from=sc.nextInt()-1;
			int to=sc.nextInt()-1;
			long cost=sc.nextLong();
			route[from][to]=cost;
			route[to][from]=cost;
		}
		Warshall_Floyd();
		permute(r,r.length);
		pl(cost);
	}
	public static void permute(int[] v, int n) {
		if (n == 1) {
			long tmp=0;
			for(int i=0; i<R-1; i++) {
				tmp+=route[r[i+1]][r[i]];
			}
			cost=Math.min(cost, tmp);
		}
		else {
			for (int i = 0; i < n; i++) {
				permute(v, n-1);
				if (n % 2 == 1) {
					swap(v, 0, n-1);
				} else {
					swap(v, i, n-1);
				}
			}
		}
	}
	public static void Warshall_Floyd() {
		for(int k=0; k<N; k++) {
			for(int i=0; i<N; i++) {
				for(int j=0; j<N; j++) {
					route[i][j]=Math.min(route[i][j], route[i][k]+route[k][j]);
				}
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	private static void swap(int[] v, int i, int j) {
		int t = v[i]; v[i] = v[j]; v[j] = t;
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 30564
#include <iostream>

using namespace std;

int main()
{
    const int num_antenna = 5;
    int antennas[num_antenna] = {0};
    for (int i = 0; i < sizeof(antennas) / sizeof(antennas[0]); i++)
    {
        cin >> antennas[i];
    }
    int k;
    cin >> k;
    for (int i = 0; i < num_antenna - 1; i++)
    {
        for (int j = i + 1; j < num_antenna; j++)
        {
            if (abs(antennas[i] - antennas[j]) > k)
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
}


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

int main()
{
	int n, i, x[101], a=0, b=0;
	cin >> n;
	for(i=0;i<n;i++)cin>>x[i];

	sort(x, x+n, greater<int>());
	for(i=0;i<n;i++){
		if(i%2==0)a+=x[i];
		else b+=x[i];
	}
	cout << a-b << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    L, R, d = map(int, input().split())
    res = 0
    for i in range(L, R + 1):
        if i % d == 0:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9164
//
//  main.cpp
//  ALDS1_4_A
//
//  Created by ptyuan on 2018/10/22.
//  Copyright © 2018 YY. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;

int linearSearch(int *array, int n, int key) {
    *(array + n ) = key;
    int i = 0;
    while (array[i] != key) {
        i++;
    }
    return i == n ? -1 : i;
}

int main(int argc, const char * argv[]) {
    int n = 0;
    int S[10000 + 1] = {0};
    int q = 0;
    int sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", S + i);
    }
    
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        int key = 0;
        scanf("%d", &key);
        if (-1 != linearSearch(S, n, key)) {
            sum++;
        }
    }
    printf("%d\n", sum);
    
    return 0;
}



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

using namespace std;

int main()
{
    int n,k,sum=0;
    cin >> n >> k;
    vector<int> ar(n);
    for(int i=0;i<n;i++)
    {
        cin >> ar[i];
    }
    sort(ar.begin(),ar.end(),greater<int>());
    for(int i=0;i<k;i++)
    {
        sum += ar[i];
    }
    cout << sum << endl;
    return 0;
}


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

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

    bool flag = true;
    std::map<std::string, int> memory;
    string pre_word = "";
    for(int i=0;i<N;i++){
        string s;
        cin >> s;

        if(pre_word.size() != 0){
            if(pre_word[pre_word.size()-1] != s[0]){
                flag = false;
            }
        }
        if(memory.count(s) != 0){
            flag = false;
        }
        memory[s] = 1;
        pre_word = s;
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 300003, mod = 1e9 + 7, ch[8][2] = {{3, 1}, {5, 2}, {2, 2}, {4, 7}, {3, 3}, {6, 1}, {5, 5}, {3, 1}};
char str[N];
int n, dp[N][8];
inline void qmo(int &x){x += (x >> 31) & mod;}
int main(){
    scanf("%s", str); n = strlen(str); dp[n][1] = dp[n][2] = 1;
    for(Rint i = n - 1;~i;-- i)
        for(Rint j = 0;j < 8;++ j){
            if(str[i] != '0') dp[i][j] = dp[i + 1][ch[j][1]];
            if(str[i] != '1') qmo(dp[i][j] += dp[i + 1][ch[j][0]] - mod);
        }
    printf("%d\n", dp[0][0]);
}

Measured memory_bytes: 9856
#include <iostream>
#include <vector>

#define ll long long

using namespace std;


//0~nを2進数にした時の各桁の1の数を数える
ll count(ll n, ll d){

    if(n >= 0){
        ll int m = 1;
        for(int i = 0; i < d - 1; i++) m *= 2;
        ll tmp = (n + 1) / m;

        if(tmp % 2 == 0){
            return tmp / 2 * m;
        }else{
            return tmp / 2 * m + ((n + 1) % m);
        }
    }else return 0;

}

int main(){
    ll a,b;
    int d = 1;
    ll k = 1;
    ll sum = 0;

    vector<ll> v;

    cin >> a >> b;

    while(k <= b){

        v.push_back(count(b,d) - count(a - 1,d));
        d++;
        k *= 2;
    }

    k = 1;

    for(int i = 0; i < v.size(); i++){
        ll tmp = v[i] % 2;
        cerr << tmp << " ";
        sum = sum + tmp * k;
        k *= 2;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

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

  vector<int> wl(N + 1, 0), bl(N + 1, 0);
  for (int i = 0; i < N; i++) {
    if (S[i] == '.') {
      wl[i + 1] = wl[i] + 1;
      bl[i + 1] = bl[i];
    } else {
      wl[i + 1] = wl[i];
      bl[i + 1] = bl[i] + 1;
    }
  }

  int minv = INT_MAX;
  for (int i = 0; i <= N; i++) {
    minv = min(minv, (bl[i] - bl[0]) + (wl[N] - wl[i]));
  }
  cout << minv << endl;
  
  return 0;
}


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

using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << '\n';
	
	return 0;
}


Measured memory_bytes: 256