akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(2);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int q;
    cin>>q;
    cin>>hex;
    cout<<hex;
    while(q--){
        vector<unsigned> n(9);
        rep(i,9)cin>>n[i];
        unsigned k=0;
        rep(i,32){
            unsigned t=0;
            rep(j,8)t+=n[j];
            if(((1u<<i)&t)!=((1u<<i)&n[8])){
                k|=1u<<i;
                rep(j,8)n[j]^=(1u<<i)&k;
            }
        }
        cout<<k<<endl;
    }
}


Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
using namespace std;

char N[4], n[4];
int L, S, d;

int main()
{
  while(true)
  {
    cin >> N;
    if(N[0] == '0' && N[1] == '0' && N[2] == '0' && N[3] == '0')
      break;
    if(N[0] == N[1] && N[1] == N[2] && N[2] == N[3])
    {
      cout << "NA" << endl;
      continue;
    }
    for(int i = 0; i < 10; i++)
    {
      if(N[0] == '6' && N[1] == '1' && N[2] == '7' && N[3] == '4')
      {
        cout << i << endl;
        break;
      }

      L = S = 0;
      sort(N, N + 4);
      for(int j = 0; j < 4; j++)
        S += (N[j] - '0') * pow(10, 3 - j);
      reverse(N , N + 4);
      for(int j = 0; j < 4; j++)
        L += (N[j] - '0') * pow(10, 3 - j);
      d = L - S;
      for(int j = 0; j < 4; j++)
      {
        N[j] = (d / (int)pow(10, 3 - j)) + '0';
        d -= (N[j] - '0') * (int)pow(10, 3 - j);
      }
    }
  }
}

Measured memory_bytes: 1200
import java.util.*

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
    var S = (sc.next()).plus("Z")
    var ans = 0L
    var a = 0
    var i = 0
    val len = S.length-1
    while (i < len){
        if (S[i] == 'A'){
            a += 1
        }
        else if(S[i] == 'B' && S[i+1] == 'C'){
            ans += a
            i += 1
        }else{
            a = 0
        }
        i += 1
    }
    println(ans)
}

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

int K;
int N;

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

    vector<int> A(N,0);
    for(int i = 0; i < N; i++) cin >> A[i];

    int tmp = 0;
    int diff = 0;
    for(int i = 0; i < N; i++)
    {
        if(i == N - 1)
        {
            tmp = A[0] - A[N - 1] + K;
            diff = max(diff, tmp);
        }
        else 
        {
            tmp = A[i + 1] - A[i];
            diff = max(diff, tmp);
        }
    }


    cout << K - diff << endl;
}

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

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

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    string s;
    cin >> s;
    int a = 0;
    int n = sz(s);
    for(int i = 0; i < n; i++) {
        int c = 0;
        while(i < n && s[i] == 'R') {
            c++;
            i++;
        }
        a = max(a,  c);
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3644
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int count = 0;
	for(int i = a; i<= b; i++) {
		if(i/10000 == i % 10 && (i/1000) % 10 == (i/10) % 10) {
			count++;
		}
	}
	System.out.println(count);
}
}


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

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

    string X = "";
    string Y = "";
    int ans = 0;
    for (int i = 1; i < N; i++) {
        int res = 0;
        X = S.substr(0, i);
        Y = S.substr(i);
        sort(X.begin(), X.end());
        for (int j = 0; j < i; j++) {
            if (X[j] == X[j - 1]) {
                continue;
            }
            for (int k = 0; k < N - i; k++) {
                if (X[j] == Y[k]) {
                    res++;
                    break;
                }
            }
        }
        ans = max(ans, res);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
        int i, n;
        double x1, y1, x2, y2, x3, y3, x4, y4;
        scanf ("%d", &n);
        for (i=0; i<n; i++){
                scanf ("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
                if ((y2-y1)/(x2-x1) == (y4-y3)/(x4-x3)){
                        puts ("YES");
                } else {
                        puts ("NO");
                }
        }
        return 0;
}

Measured memory_bytes: 0
// 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> res(N, 0);
    for (int i = 1; i <= N - 1; ++i)
    {
        for (int j = i + 1; j <= N; ++j)
        {
            int d1 = j - i;
            int d2 = abs(j - Y) + abs(X - i) + 1;
            int d = min(d1, d2);
            ++res[d];
        }
    }
    for (int k = 1; k <= N - 1; ++k)
    {
        cout << res[k] << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
//#define for(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define print(x) std::cout << x << std::endl;

using namespace std;

typedef long long ll;

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first = 0, bool replace_empty = 0);
bool isContain(int value, int under, int top);
vector<int> range(int x);

int main(void) {
	//Program Start

	string S;
	cin >> S;
	int N = S.length();

	int count = 0;

	int res1 = 0;
	for (int i = 0; i < N; i++) {
		count++;
		count %= 2;
		if (to_string(count)[0] != S[i]) res1++;
	}

	count = 1;
	int res2 = 0;
	for (int i = 0; i < N; i++) {
		count++;
		count %= 2;
		if (to_string(count)[0] != S[i]) res2++;
	}

	cout << min(res1, res2) << endl;



ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}


vector<int> range(int y) {
	vector<int> result(y);
	for (int i = 0; i < y; i++)
		result[i] = i;
	return result;
}

bool isContain(int value, int under, int top) {
	if (under <= value && value <= top) return true;
	return false;
}

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first, bool replace_empty) {
	using S = std::string;
	using C = std::string::value_type;
	using N = std::string::size_type;
	struct {
		auto len(const S& s) { return s.size(); }
		auto len(const C* p) { return std::char_traits<C>::length(p); }
		auto len(const C  c) { return 1; }
		auto sub(S* s, const S& t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C* t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C  t, N pos, N len) { s->replace(pos, len, 1, t); }
		auto ins(S* s, const S& t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C* t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C  t, N pos) { s->insert(pos, 1, t); }
	} util;

	N target_length = util.len(target);
	N replacement_length = util.len(replacement);
	if (target_length == 0) {
		if (!replace_empty || replacement_length == 0) return s;
		N n = s.size() + replacement_length * (1 + s.size());
		s.reserve(!replace_first ? n : s.size() + replacement_length);
		for (N i = 0; i < n; i += 1 + replacement_length) {
			util.ins(&s, replacement, i);
			if (replace_first) break;
		}
		return s;
	}

	N pos = 0;
	while ((pos = s.find(target, pos)) != std::string::npos) {
		util.sub(&s, replacement, pos, target_length);
		if (replace_first) return s;
		pos += replacement_length;
	}
	return s;
}


Measured memory_bytes: 760
loop do
    n = gets.to_i
    break if n == 0
    lines = (0..n-1).map { gets.chomp }

    stack = []
    (0..lines.size-1).each do |i|
        line = lines[i]
        level = line.count(?.)

        if stack.size > level
            j = stack.pop until stack.size == level
            if level > 0
                (j+1..i-1).each do |k|
                    lines[k] = ?. * (level - 1) + ?| + lines[k][level..-1]
                end
            end
        end
        stack << i
    end

    lines.each do |line|
        line.sub!(/\.(\w)/, '+\1')
        line.gsub!(/\./, ' ')
    end

    puts lines
end

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

constexpr int kNumberCount = 1e5 + 10;
constexpr int kNumberMax = 1e5 + 10;

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

  static int hit[kNumberMax];
  for (int i = 0; i < n; ++i) {
    int tmp;
    scanf("%d", &tmp);
    ++hit[tmp];
    ++hit[tmp + 1];
    if (tmp > 0) {
      ++hit[tmp - 1];
    }
  }

  int max_hit = hit[0];
  for (int i = 1; i < kNumberCount; ++i) {
    max_hit = std::max(max_hit, hit[i]);
  }

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


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int count = 0;
	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '1')
		{
			count++;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
S=input()
dp=[[0 for _ in range(13)] for _ in range(len(S))]
MOD=10**9+7
if S[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(S[0])]+=1
for i in range(1, len(S)):
  cur_nums=[i for i in range(10)] if S[i]=='?' else [int(S[i])]
  for cur in cur_nums:
    for rem in range(13):
      dp[i][(10*rem+cur)%13]=(dp[i][(10*rem+cur)%13]+dp[i-1][rem])%MOD
print(dp[-1][5])


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

int main() {
  int N;
  cin >> N;
  int M = 100;
  for(int i = 0; i < N; i++) {
    int A;
    cin >> A;
    int k = 0;
    while(A % 2 == 0) {
      A /= 2;
      k++;
    }
    if(k < M)
      M = k;
  }
  cout << M << endl;
      
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,i,j;
	cin>>n;
	double sum=0.0;
	double dum;
	for(i=0;i<n;i++){
	    cin>>j;
	    sum+=1.0/j;
	}
	dum=1.0/sum;
	cout<<dum;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> //sort,二分探査など
#include <atcoder/segtree>
//#include<bitset>
//#include<cmath>//pow,logなど
//#include<deque>
//#include<functional>
//#include<iterator>
//#include<map>
//#include<numeric>//gcd,lcm
//#include<queue>
//#include<set>
//#include<stack>
//#include<string>
//#include<utility>//pair

//QCFium法
#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")

using namespace std;
using namespace atcoder;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;

constexpr i64 INF = 1010000000000000017LL;
constexpr u64 MOD = 1000000007LL;
constexpr f80 PI = 3.14159265358979323846;

#define _overload3(_1, _2, _3, name, ...) name
#define repi(i, start, end) for (int i = (int)(start); i < (int)(end); ++i)
#define _rep(i, n) repi(i, 0, n)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(i, start, end) for (int i = (int)(start); i > (int)(end); --i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()

#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef v(int) vi;

#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>

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

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

//sort(rng(P),[](const vi &a, const vi &b){return a[1]<b[1];});

int op(int a, int b) { return max(a, b); }
int e() { return -1; }
int target;
bool f(int v) { return v < target; }

void Main()
{
  int N, K;
  cin >> N >> K;

  v(int) X(300001, 0);
  segtree<int, op, e> seg(X);

  rep(i, N)
  {
    int a;
    cin >> a;

    int b = seg.prod(max(0, a - K), min(300001, a + K + 1)) + 1;
    seg.set(a, b);
  }

  cout << seg.prod(0, 300001) << "\n";
}

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

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

using namespace std;

int ap[100001][2];

int n;

int main()
{
    cin >> n;
    int nr;
    for(int i = 1; i <= n; i ++)
    {
        cin >> nr;
        ap[nr][i & 1] ++;
    }

    int mn[2][2];
    int pn[2][2];
    mn[0][0] = mn[1][0] = mn[1][1] = mn[0][1] = (n >> 1);
    for(int i = 1; i <= 100000; i ++)
    {
        for(int j = 0; j <= 1; j ++)
        {
            if((n >> 1) - ap[i][j] <= mn[j][0])
            {
                mn[j][1] = mn[j][0];
                pn[j][1] = pn[j][0];

                mn[j][0] = (n >> 1) - ap[i][j];
                pn[j][0] = i;
            }

            else
                if((n >> 1) - ap[i][j] < mn[j][1])
                {
                    pn[j][1] = i;
                    mn[j][1] = (n >> 1) - ap[i][j];
                }

        }
    }

    if(pn[0][0] == pn[1][0])
        cout << min(mn[0][0] + mn[1][1], mn[0][1] + mn[1][0]) << "\n";

    else
        cout << mn[0][0] + mn[1][0] << "\n";

  //  cout << mn[0] << " " << mn[1] << "\n";

  //  cout << mn[0] + mn[1] << "\n";

    return 0;
}


Measured memory_bytes: 1024
def m():
    Sdash = input()
    T = input()

    diff = len(Sdash) - len(T)

    if diff < 0:
        print('UNRESTORABLE')
        return

    index = -1
    for i in range(diff+1):
        Sp = Sdash[i:i+len(T)]
        for j in range(len(T)):
            if T[j] == Sp[j] or Sp[j] == '?':
                pass
            else:
                break
        else:
            index = i
    if index < 0:
        print('UNRESTORABLE')
        return

    res = Sdash.replace('?', 'a')
    res = res[0:index] + T + res[index+len(T):]
    print(res)


if __name__ == '__main__':
    m()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
        int n,w;
        cin >> n >> w;
        vector<pp> wv(n);
        rep(i,n){
                int a,b;
                cin >> a >> b;
                wv.at(i) = make_pair(a,b);
        }
        vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));
        for(int i=1;i<=n;i++)rep(j,w+1){
                if(wv.at(i-1).first > j) dp[i][j] = dp[i-1][j];
                else dp[i][j] = max(dp[i-1][j],dp[i-1][j-wv.at(i-1).first]+wv.at(i-1).second);
        }
        cout << dp[n][w] << endl;
        
}



Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int N;
    double sum;
    vector<pair<double, string>> xu; 
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        double price;
        string kind;
        cin >> price;
        cin >> kind;
        if (kind == "BTC") {
            price = price * 380000;
        }
        sum += price;
    }
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 384
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: u32,
    }

    println!("{}", 1110 - n);
}


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

vector<P> p;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    int n;
    cin >> n;
    int zero = 0;
    map<pair<ll,ll>,P> mp;
    rep(i,n) {
        ll x, y;
        cin >> x >> y;
        if (x == 0 && y == 0) {
            zero++;
            continue;
        }
        ll g = gcd(x,y);
        x /= g;
        y /= g;
        if (y < 0) x = -x, y = -y;
        if (y == 0 && x < 0) x = -x, y = -y;
        bool rot90 = (x <= 0);
        if (rot90) {
            ll tmp = x;
            x = y; y = -tmp;
        }
        if (rot90) mp[{x,y}].first++;
        else mp[{x,y}].second++;
    }

    mint ans = 1;
    for (auto p : mp) {
        int s = p.second.first;
        int t = p.second.second;
        mint now = 1;
        now += mint(2).pow(s) - 1;
        now += mint(2).pow(t) - 1;
        ans *= now;
    }

    ans -= 1;

    ans += zero;
    cout << ans << endl;

    return 0;
    // g++ -std=c++17 main5_col.cppで実行
}

Measured memory_bytes: 16128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var cnt int
var err error
var inputReader *bufio.Reader

func main(){
	inputReader = bufio.NewReader(os.Stdin)
	var counterA,counterB int
	var input string
	input, err = inputReader.ReadString('\n')
	input = strings.Replace(input, "\n", "", -1)
	counterA, err = strconv.Atoi(input)
	//fmt.Scanf("%d",&temp)
	A := make([]int, counterA, 100000)
	for i := 0; i < counterA; i++ {
		if i==counterA-1{
			input, err = inputReader.ReadString('\n')
			input = strings.Replace(input, "\n", "", -1)
			A[i], err = strconv.Atoi(input)
		}else {
			input, err = inputReader.ReadString(' ')
			input = strings.Replace(input, " ", "", -1)
			A[i], err = strconv.Atoi(input)
			//fmt.Scanf("%d",&A[i])
		}
	}
	input, err = inputReader.ReadString('\n')
	input = strings.Replace(input, "\n", "", -1)
	counterB, err = strconv.Atoi(input)
	//fmt.Scanf("%d",&temp)
	B := make([]int, counterB, 100000)
	for i := 0; i < counterB; i++ {
		if i==counterB-1{
			input, err = inputReader.ReadString('\n')
			input = strings.Replace(input, "\n", "", -1)
			B[i], err = strconv.Atoi(input)
		}else {
			input, err = inputReader.ReadString(' ')
			input = strings.Replace(input, " ", "", -1)
			B[i], err = strconv.Atoi(input)
			//fmt.Scanf("%d",&A[i])
		}
	}
	findLinear(A,counterA,B,counterB)

}
func findLinear(A []int,cA int,B []int,cB int){
	flag:=0
	for i:=0;i<cB ;i++  {
		for j:=0;j<cA ;j++  {
			if A[j]==B[i] {
				flag++
				break
			}
		}
	}
	fmt.Println(flag)
}


Measured memory_bytes: 1420
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func run() {
	
	a := nextInt()
	b := nextInt()
	ans := 0
	cur := 1
	for cur < b {
		cur = cur + a - 1
		ans++
	}
	Println(ans)
}
 
// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}

Measured memory_bytes: 2816
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

const MAX = 55555

var pN [MAX]int

func initPrime() {
	for i := 2; i < MAX/2; i++ {
		for j := i * 2; j < MAX; j += i {
			if pN[j] == 0 {
				pN[j] = i
			}
		}
	}
}

func main() {
	sc.Split(bufio.ScanWords)

	initPrime()

	N := getInt()

	cnt := 0
	for i := 2; i < MAX; i++ {
		if pN[i] == 0 && (i-1)%5 == 0 {
			fmt.Print(i, " ")
			cnt++
		}
		if cnt == N {
			break
		}
	}
	fmt.Println("")
}


Measured memory_bytes: 1024
def 解():
    iN = int(input())
    aA = [int(_) for _ in input().split()]

    iD = sum(aA)
    iF = 0
    minDiff = 10**9 * 2
    for a in aA[:-1] :
        iF += a
        thisDiff = abs(iD - 2*iF)
        minDiff = min(minDiff , thisDiff)
    print(minDiff)
解()


Measured memory_bytes: 23788
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
"""
x = ai(p+0.5)
0.5が入っていると整数として扱いづらいので、aiが偶数であることを利用して以下のように変形
x = ai'(2p+1)
ai' = 2ai
ここで2p+1が奇数であることから、xおよびai'が2で割れる回数は同じでなければならない。
2で割れる回数をtとすると、
x' = ai''(2p+1)
x' = x/(2^t)
ai'' = ai'/(2^t)
Mも2^tで割っておく。
M' = M/(2^t)
Xとして何が考えられるかは、まずai''の最小公倍数Lが考えられる
lcm(ai'') = L
さらに、Lの奇数倍も考えられる
したがって答えは、M'/2Lの小数点以下切り上げたもの
"""

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

def func(x):
    """2で何回割れるか"""
    res = 0
    while x%2 == 0:
        x //= 2
        res += 1
    return res

#from math import gcd # v3.5以降
from fractions import gcd # v3.4以前
from functools import reduce

def lcm_base(x, y):
    """2つの値の最小公倍数"""
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    """3つ以上の値の最小公倍数"""
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    """3つ以上の値の最小公倍数"""
    return reduce(lcm_base, numbers, 1)

def main(n,m,a):
    ans = 0
    # a -> a'
    for i in range(n):
        if a[i]%2 == 1:
            print(0)
            return
        a[i] //= 2

    # a' -> a''
    t = func(a[0])
    for i in range(n):
        if func(a[i]) != t:
            print(0)
            return
        a[i] >>= t # a[i] //= 2^t
    m >>= t

    l = 1
    for i in range(n):
        l = lcm(l, a[i])
        if l > m:
            print(0)
            return

    m //= l
    ans += (m+1)//2
    print(ans)
    
main(n,m,a)

Measured memory_bytes: 14244
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
const int N = 1e5 + 7;
int n, q, x[N], nxt[N][20], l;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  cin >> n;
  rep(i, 0, n) cin >> x[i];
  cin >> l;
  int tmp = 0;
  rep(i, 0, n) {
  	while (tmp + 1 < n && x[tmp + 1] <= x[i] + l) tmp++;
  	nxt[i][0] = tmp;
	}
	rep(j, 1, 20)
		rep(i, 0, n) nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
	cin >> q;
	rep(i, 0, q) {
		int a, b; cin >> a >> b; a--; b--;
		if (a > b) swap(a, b);
		int ans = 1;
		per(j, 0, 20) if (nxt[a][j] < b) ans += pw(j), a = nxt[a][j];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf p
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int ka[214514],inv[214514],p;
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int res = 1;
	while(k>1){
		if(k%2)res = (res*x)%inf;
		x = (x*x)%inf;
		k >>=1;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if( k<0 || n<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
int ans[4000];
signed main(){
	cin>>p;
	vector<int> a(p);
	for(int i=0;i<p;i++){
		cin>>a[i];
	}
	setkaijo(10000);
	setinv(10000);
	vector<int> c;
	for(int i=0;i<p;i++){
		int tmp = ( a[i] * inv[p-1] ) % p;
		c.pb(tmp);
	}
	vector<int> seki;
	seki.pb(1);
	for(int i=0;i<p;i++){
		vector<int> nseki;
		for(int j=0;j<seki.size();j++){
			nseki.pb( (seki[j]*i) % p );
		}
		nseki.pb(1);
		for(int j=0;j<seki.size()-1;j++){
			nseki[j+1] += seki[j];
			nseki[j+1] %= p;
		}
		seki = nseki;
	}
	for(int i=0;i<p;i++){
		vector<int> shou,kari;
		kari = seki;
		for(int j=p;j>=1;j--){
			shou.pb( kari[j] );
			kari[j-1] -= kari[j] * (p-i);
			kari[j-1] += p*p;
			kari[j-1] %= p;
		}
		reverse( shou.begin(), shou.end() );
		for(int j=0;j<p;j++){
			//cout<<shou[j]<<" ";
			ans[j] += shou[j]*c[i];
			ans[j] %= p;
		}
		//cout<<endl;
	}
	for(int i=0;i<p;i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

int main()
{
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if (a + b > c + d) {
    printf("%s\n", "Left");
  } else if (a + b < c + d) {
    printf("%s\n", "Right");
  } else {
    printf("%s\n", "Balanced");
  }
}

Measured memory_bytes: 128
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = do
  [n,m,q] <- readInts
  replicateM q readInts >>= output . solve n m

solve :: Int -> Int -> [[Int]] -> _
solve n m xs = fst $ maximum $  map (\v -> (f v, v)) all
  where
    f vec = sum $ map (\[a,b,c,d] -> if ((vec!!(b-1)) - (vec!!(a-1)))==c then d else 0) xs

    -- gen m 0 _ = [ [] ]
    -- gen m n a = [ i:is | i <- [a..m], is <- gen m (pred n) i ]
    all = [ [x1,x2,x3,x4,x5,x6,x7,x8,x9,x10] | x1 <- [1..m], x2 <- [x1..m], x3 <- [x2..m], x4 <- [x3..m], x5 <- [x4..m], x6 <- [x5..m], x7 <- [x6..m], x8 <- [x7..m], x9 <- [x8..m], x10 <- [x9..m]]

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

Measured memory_bytes: 6648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  ll A[N+1];
  for(int i=1; i<=N; i++) cin >> A[i];

  ll B[N+1];
  B[1] = 0;
  for(int i=2; i<=N; i=i+2) B[1] -= A[i];
  for(int i=1; i<=N; i=i+2) B[1] += A[i];
  B[2] = A[1];
  for(int i=2; i<=N; i=i+2) B[2] += A[i];
  for(int i=3; i<=N; i=i+2) B[2] -= A[i];
  
  for(int i=1; i+2 <= N; i=i+2){
    B[i+2] = B[i] + 2*A[i+1] - 2*A[i];
  }
  for(int i=2; i+2 <= N; i=i+2){
    B[i+2] = B[i] + 2*A[i+1] - 2*A[i];
  }
  for(int i=1; i<=N; i++){
    cout << B[i] << " ";
  }
  cout << endl;

  
  
  return 0;
}

Measured memory_bytes: 2816
#include<stdio.h>
int main()
{
    int i=0;
    char s[100];
	    // 文字列の入力
	scanf("%s",s);//S,Tの入力
	do{
		printf("x");
		i++;
	}while(s[i]!='\0');
	
	printf("\n");

	    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long lli;
using namespace std;
struct Edge{
	lli nxt,to;
}e[400010];
lli n,m,cnt;
lli col[100010],h[100010];
void add(lli u,lli v)
{
	e[++cnt].to=v;
	e[cnt].nxt=h[u];
	h[u]=cnt;
}
void dfs(lli u,lli c)
{
	col[u]=c;
	for(lli i=h[u];i;i=e[i].nxt){
		lli v=e[i].to;
		if(!col[v]) dfs(v,-c);
		if(col[v]==c){
			printf("%lld",n*(n-1)/2-m);
			exit(0);
		}
	}
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for(lli a,b,i=1;i<=m;i++){
		scanf("%lld%lld",&a,&b);
		add(a,b);
		add(b,a);
	}
	dfs(1,1);
	lli a=0,b=0;
	for(lli i=1;i<=n;i++){
		if(col[i]==1) a++;
		else b++;
	}
	printf("%lld",a*b-m);
}

Measured memory_bytes: 6784
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    int N,x;
    cin>>N>>x;
    if(x==1||x==2*N-1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        set<int> st;
        REP2(i,1,2*N) st.insert(i);
        vl ans(2*N-1,0);
        ans[N-2]=x-1;
        ans[N-1]=x;
        ans[N]=x+1;
        st.erase(x-1);
        st.erase(x);
        st.erase(x+1);
        REP(i,2*N-1){
            if(ans[i]!=0) continue;
            auto itr = st.begin();
            ans[i]=*itr;
            st.erase(itr);
        }
        REP(i,2*N-1) cout<<ans[i]<<endl;
        
    }
}

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

#define int ll
#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define pb push_back
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
constexpr int inf = 1ll<<61;

vvi dist(2,vi(1e5,inf));
vector<vector<bool>> visit(2,vector<bool>(1e5,false));
vector<vector<pii>> g(1e5,vector<pii>(2)),f(1e5);
class dijkstra{
public:
  ll ans;

  dijkstra(ll s,ll t){ // sからtへの最短経路
    vector<vector<vector<pii>>> G(2);
    G[0] = move(g);
    G[1] = move(f);
    
    vector<priority_queue<pii,vector<pii>,greater<pii>>> que(2);
    que[0].emplace(dist[0][s]=0,s);
    que[1].emplace(dist[1][t]=0,t);
    ll mu = inf;

    while(!que[0].empty() and !que[1].empty()){
      if(que[0].top().first + que[1].top().first >= mu) break;
      ll k = (que[0].top().first > que[1].top().first)?0:1;
      ll d,v; tie(d,v) = que[k].top();
      que[k].pop();

      if(visit[k^1][v]) goto L;
      visit[k][v] = true;

      rep(i, G[k][v].size()){
	auto n = G[k][v][i];
	ll tmp = d + n.second;
	if(dist[k][n.first] > tmp){
	  mu = min(mu, dist[k][v] + n.second + dist[k^1][n.first]);
	  dist[k][n.first] = tmp;
	  que[k].emplace(tmp,n.first);
	}
      }
    }
  L:
    g = move(G[0]);
    f = move(G[1]);

    ans = inf;
    rep(i,g.size()) ans = min(ans, dist[0][i]+dist[1][i]);
  }
};

main(){
  int k; cin >> k;
  rep(i,k){
    g[i][0] = pii((i+1)%k,1);
    g[i][1] = pii((i*10)%k,0);
    
    f[(i+1)%k].pb(pii(i,1));
    f[(i*10)%k].pb(pii(i,0));
  }
  dijkstra d(1,0);
  cout << d.ans+1 << endl;
}

Measured memory_bytes: 18672
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    string S; cin >> S;
    replace(_all(S), ',', ' ');

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, k, s;
  cin >> n >> k >> s;
  rep(i, k) {
    cout << s << " ";
  }
  ll t = 1e9;
  if (t == s) t = 1;
  rep(i, n-k) {
    cout << t << " " ;
  }
  cout << endl;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a<b){
            System.out.println("a < b");
        }
        if(a==b){
            System.out.println("a == b");
        }
        if(a>b){
            System.out.println("a > b");
        }
        
    }
}


Measured memory_bytes: 26244
n = gets.to_i

for i in 1..n
    
    if i % 3 == 0
        print " #{i}"
    else
        x = i
        for j in 1..4
            
            if x  == 0
                break
            elsif x % 10 == 3
                print " #{i}"
                break
            end
            
            x /= 10
        end
    end
end

puts ""


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

int main() {
    int L; cin >> L;
    printf("%.12f\n", (double)L * L * L / 27);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    if(a[n-1]-a[0] >= 2) 
    {
        cout << "No" << endl;
    }
    else if(a[n-1]-a[0] == 1) 
    {
        int cnt0 = 0, cnt1 = 0;
        for(int i=0;i<n;i++) 
        {
            if(a[i]==a[0]) cnt0++;
            else cnt1++;
        }
        if(cnt0 <= a[0] && (a[0]-cnt0+1)*2 <= cnt1) 
        cout << "Yes" << endl;
        else 
        cout << "No" << endl;
    } 
    else if(a[n-1]-a[0] == 0) 
    {
        if(n == a[0]+1 || n >= a[0]*2) 
        cout << "Yes" << endl;
        else 
        cout << "No" << endl;
    }
}

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

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

void calcu(){
}

int main ()
{
        string str;
        cin>>str;
        vector <int> number(4);
        vector <char> operat(3,'-');//true='+',false='-'を表す
        int sum=0;

        rep(i,4)
        {
                number.at(i)=str.at(i)-48;
        }

        rep(i,8)
        {
                sum=number.at(0);//1つめ代入

                int buf=i;
                //演算子の組み合わせは2^3=8パターン
                if(buf-4>=0) {operat.at(0)='+'; buf=buf-4;}
                if(buf-2>=0) {operat.at(1)='+'; buf=buf-2;}
                if(buf-1>=0) {operat.at(2)='+'; buf=buf-1;}

                //足し算する
                rep(j,3)
                {
                        if(operat.at(j)=='+') {sum+=number.at(j+1);}
                        else{sum-=number.at(j+1);}
                }

                if(sum==7)
                {
                        rep(k,3)
                        {
                                cout<<number.at(k)<<operat.at(k);
                        }
                        cout<<number.at(3)<<"=7"<<endl;
                        break;
                }

                rep(l,3){
                        operat.at(l)='-';

                }

        }

}


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

int main(){
  string s, t;
  cin >> s >> t;
  long long int x = -1, y = 0, ans = 0;
  
  vector<long long int> memo[30];
  rep(i,s.size(),0){
    int a = s[i]-97;
    memo[a].push_back(i);
  }
  
  rep(i,t.size(),0){
    int b = t[i]-97;
    if(memo[b].size() == 0){
      ans = -1;
      break;
    }
    else{
      if(memo[b][(memo[b].size()-1)] > x){
        if(memo[b].size() < 400){
          for(int u : memo[b]){
            if(u > x){
              x = u;
              break;
            }
          }
        }
        else{
          rep(k,s.size(),x+1){
            if(t[i] == s[k]){
              x = k;
              break;
            }
          }
        }
      }
      else{
        x = memo[b][0];
        y++;
      }
    }
  }
  if(ans != -1) ans = s.size()*y + x + 1;
  cout << ans << endl;
}

Measured memory_bytes: 1724
#include <iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int a=N/1000000000;
    int b=(N/100000000)%10;
    int c=(N/10000000)%10;
    int d=(N/1000000)%10;
    int e=(N/100000)%10;
    int f=(N/10000)%10;
    int g=(N/1000)%10;
    int h=(N/100)%10;
    int i=(N/10)%10;
    int j=N%10;
    int x=a+b+c+d+e+f+g+h+i+j;
    if(N%x==0){cout<<"Yes";}
    else{cout<<"No";}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

vp in(){
    vp ret;
    string s;
    while(cin >> s, s != "$"){
        int a;
        cin >> a;
        ret.push_back(pii(s[0],a));
    }
    return ret;
}
void print(vp a){
    cout << endl;
    rep(i,a.size())cout << char(a[i].first) << " " << a[i].second << endl;
}

signed main(void) {
    int i,j;
    vp a,b,c;
    a = in();
    b = in();
    c = in();
    vp t;
    bool ans = true;
    rep(i,a.size()){
        bool p = true;
        rep(j,b.size()){
            if(j == 0 || j == b.size()-1){
                if(a[i+j].first != b[j].first || a[i+j].second < b[j].second){
                    p = false;
                }
            }else{
                if(a[i+j].first != b[j].first || a[i+j].second != b[j].second){
                    p = false;
                }
            }
        }
        if(p && ans){
            a[i+b.size()-1].second -= b.back().second;
            if(b.size() > 1 && a[i].second-b[0].second){
                if(t.size() && t.back().first == a[i].first) t.back().second += a[i].second-b[0].second;
                else t.push_back(pii(a[i].first,a[i].second-b[0].second));
            }
            rep(j,c.size()){
                if(t.size() && t.back().first == c[j].first){
                    t.back().second += c[j].second;
                }else{
                    t.push_back(c[j]);
                }
            }
            ans = false;
            i += b.size()-2;
        }else{
            if(t.size() && t.size() && t.back().first == a[i].first){
                t.back().second += a[i].second;
            }else if(a[i].second){
                t.push_back(a[i]);
            }
        }
    }

    rep(i,t.size()){
        cout << char(t[i].first) << " " << t[i].second << " ";
    }
    cout << "$" << endl;

}



Measured memory_bytes: 3268
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  const val = lines[1].split(" ");
  const cost = lines[2].split(" ");
  const num = Number(lines[0]);
  var gain = 0;
  
  for(i = 0; i < num; i++) {
    gain = (Number(val[i]) - Number(cost[i]) > 0) ? gain + Number(val[i]) - Number(cost[i]) : gain;
  }
  
  console.log(gain);
});

Measured memory_bytes: 7628
import std.stdio;

void main()
{
    int a, b;
    readf("%d %d\n", &a, &b);
    if (!a && !b) return;
    int c = 0;
    for (int i = 1; i <= a; i++)
        for (int j = i + 1; j <= a; j++)
            for (int k = j + 1; k <= a; k++)
            {
                if (i + j + k > b) break;
                if (i + j + k == b)
                    c++;
            }
    writeln(c);
    main();
}



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

int main(void)
{
	string S;
	cin >> S;
	int n = int(S.size());
	if(n == 26)
	{
		for(int i = n-1;i >= 0;i--)
		{
			int ans = int(1e9)+5;
			for(int j = i+1;j < n;j++)
			{
				if(S[i] < S[j]) ans = min(ans, int(S[j]));
			}
			if(ans != int(1e9)+5)
			{
				cout << S.substr(0, i)+char(ans) << "\n";
				exit(0);
			}
		}
	}
	else
	{
		for(int i = 0;i < 26;i++)
		{
			bool cando = 1;
			for(auto it: S)
			{
				if(it == char('a'+i))
				{
					cando = 0;
					break;
				}
			}
			if(cando)
			{
				string T = S+char('a'+i);
				cout << T << "\n";
				exit(0);
			}
		}
	}
	cout << -1 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> bkt(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
        bkt.at(i)=0;
    }
    for(int i=0; i<N; i++)
    {
        bkt.at(A.at(i)-1)++;
    }
    int count=0;
    for (int i = 0; i < N; i++)
    {
        if(bkt.at(i)!=0)
        {
            count++;
        }
    }
    if(K>=count)
    {
        cout << 0 << endl;
    }
    else
    {
        sort(bkt.begin(),bkt.end());
        int ans=0;
        int cntloop=0;
        for(int i=0; i<N; i++)
        {
            if(bkt.at(i)==0)
            {
                continue;
            }
            else
            {
                ans+=bkt.at(i);
                cntloop++;
                if(cntloop>=count-K)
                {
                    break;
                }
            }
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 4772
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()

from itertools import product

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

ABC = ABC[:K]

print(*ABC, sep='\n')


Measured memory_bytes: 147760