akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const LL mod=1000000007;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=200005;

int n, top, fron, x;
int stk[maxn], que[maxn];

int main()
{
    while(~scanf("%d", &n)){
        top=fron=0;
        scanf("%d", &x);
        stk[top++]=x;
        for(int i=1;i<n;i++){
            scanf("%d", &x);
            if((n-i)%2)stk[top++]=x;
            else que[fron++]=x;
        }
        printf("%d", stk[--top]);
        while(top--)printf(" %d", stk[top]);
        for(int i=0;i<fron;i++){
            printf(" %d", que[i]);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
// typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt1{}, tmp1{};
    rep(i,N){
        if(S[i] == '('){
            cnt1++;
        }
        else{
            if(cnt1 > 0) cnt1--;
            else tmp1++;
        }
    }    
    rep(i,cnt1){
        S += ')';
    }
    string T{};
    rep(i,tmp1){
            T += '(';
    }
    S = T + S;
    cout << S << endl;
}

Measured memory_bytes: 256
-- Your code here!
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
 
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a,b]<-getIntList
    print $ maximum [(a+b),(a-b),(a*b)]
    

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXWH 200

int c[10][10];
int b[MAXWH][MAXWH];

int main(){
  int h,w;cin>>h>>w;
  rep(i, 10)rep(j,10)cin>>c[i][j];

  rep(i, h)rep(j,w)cin>>b[i][j];

  rep(k, 10)rep(i, 10)rep(j, 10)c[i][j]=min(c[i][j], c[i][k]+c[k][j]);
  int result = 0;
  rep(i, h)rep(j,w)if(b[i][j]!=-1)result+=c[b[i][j]][1];

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 384
// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
#include <map>
#include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>

using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define arrsum for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define sz(a) (int)(a.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
    vi p, rank, setSize;                       // remember: vi is vector<int>
    int numSets;
public:
    UnionFind(int N) {
        setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
        p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
    void unionSet(int i, int j) { 
        if (!isSameSet(i, j)) { numSets--; 
        int x = findSet(i), y = findSet(j);
        // rank is used to keep the tree short
        if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
        else                   { p[x] = y; setSize[y] += setSize[x];
                                 if (rank[x] == rank[y]) rank[y]++; } } }
    int numDisjointSets() { return numSets; }
    int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int x;
    cin>>x;
    int ans = 0;
    for1(i,x) {
        ans += i;
        if(ans >= x) {
            cout<<i;
            return 0;
        }
    }

    return 0;
}   

Measured memory_bytes: 256
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let mut abc = stdin.lock().gets().split(' ').map(|x| x.parse().unwrap())
        .collect::<Vec<u32>>();
    abc.sort();
    println!("{}", if abc == [5, 5, 7] { "YES" } else { "NO" });
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#include "./Lib/Timer.h"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n;
	cin >> n;

	ll ans = 1e18;
	FOR(i, 1,std::sqrt(n) + 10) {
		if (n % i == 0) {
			MIN(ans, i - 1 + (n / i) - 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
extension String: CollectionType {
    static func getValues(separator: Character = " ") -> [String] {
        return readLine()!.split(separator)
    }
}

let values = String.getValues()
let A = Int64(values[0])!
let op = values[1]
let B = Int64(values[2])!

if op == "+" {
    print("\(A + B)")
} else {
    print("\(A - B)")
}

Measured memory_bytes: 4080
// g++ -I ~/Documents/programming/cppLib -std=gnu++14 -o test ~/Documents/programming/cppLib/test.cpp && ./test && rm test
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define rep( i, n )    for( lint i= 0  ; i <  (n) ; ++i )
#define all( v )       (v).begin(), (v).end()

//  modNの計算をするクラス
template <int mod>
struct mint{
    int data;
    mint( void ) :data(0) {}
    mint( int n ) :data( n>=0 ? n%mod : (mod - (-n)%mod) %mod ) {}
    operator int() { return data; }
    friend istream &operator>>(istream&is,mint&m){int n; is>>n; m=n; return is;}
    friend ostream &operator<<(ostream&os,mint&m){os<<(int)m; return os;}
    mint operator+ ( int n ) { return (data + n) % mod; }
    mint operator+ (mint m ) { return *this + (int)m; }
    void operator+=( int n ) { data = *this +      n; }
    void operator+=(mint m ) { data = *this + (int)m; }
    mint operator* ( int n ) { return (lint)data * n % mod; }
    mint operator* (mint m ) { return *this * (int)m; }
    void operator*=( int n ) { data = *this *      n; }
    void operator*=(mint m ) { data = *this * (int)m; }
    mint operator/ ( int n ) { return *this * mint(n).inv(); }
    mint operator/ (mint m ) { return *this * m.inv(); }
    void operator/=( int n ) { data = data * mint(n).inv(); }
    void operator/=(mint m ) { data = data * m.inv(); }
    bool operator==( int n ) { return data == n; }
    bool operator==(mint m ) { return data == m.data; }
    bool operator!=( int n ) { return data != n; }
    bool operator!=(mint m ) { return data != m.data; }
    mint pow(int n){mint a=1,b=data;while(n>0){if(n&1)a*=b;b*=b;n>>=1;}return a;}
    mint pow(mint m){ return (*this).pow((int)m); }
    mint inv(){int a=data,b=mod,c=1,d=0,e;while(b){e=a/b;swap(a-=e*b,b);swap(c-=e*d,d);}return c;}
};
using mint_7 = mint<1000000007>;
using mint_9 = mint<1000000009>;


int main() {
    int N;
    cin >> N;
    mint_7 ans = 1;
    for( int i=1; i<=N; i++ ) {
        ans *= i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=300050;
ll n,c[maxn],s[maxn],ans[maxn];
bool calc(int x,int k)
{
	if(s[x]>=x*k) return true;
	return false;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;
		c[x]++;
		s[c[x]]++;
	}
	for(int i=1;i<=n;i++) s[i]+=s[i-1];
	int t=n;
	for(int i=1;i<=n;i++)
	{
		while(t&&(!calc(t,i))) t--;
		ans[i]=t;
	}
	for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
	return 0;
}

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


// 関数定義
char alph(long amari) {
    if (amari == 1) {
        return 'a';
    }
    else if (amari == 2) {
        return 'b';
    }
    else if (amari == 3) {
        return 'c';
    }
    else if (amari == 4) {
        return 'd';
    }
    else if (amari == 5) {
        return 'e';
    }
    else if (amari == 6) {
        return 'f';
    }
    else if (amari == 7) {
        return 'g';
    }
    else if (amari == 8) {
        return 'h';
    }
    else if (amari == 9) {
        return 'i';
    }
    else if (amari == 10) {
        return 'j';
    }
    else if (amari == 11) {
        return 'k';
    }
    else if (amari == 12) {
        return 'l';
    }
    else if (amari == 13) {
        return 'm';
    }
    else if (amari == 14) {
        return 'n';
    }
    else if (amari == 15) {
        return 'o';
    }
    else if (amari == 16) {
        return 'p';
    }
    else if (amari == 17) {
        return 'q';
    }
    else if (amari == 18) {
        return 'r';
    }
    else if (amari == 19) {
        return 's';
    }
    else if (amari == 20) {
        return 't';
    }
    else if (amari == 21) {
        return 'u';
    }
    else if (amari == 22) {
        return 'v';
    }
    else if (amari == 23) {
        return 'w';
    }
    else if (amari == 24) {
        return 'x';
    }
    else if (amari == 25) {
        return 'y';
    }
    else if (amari == 0) {
        return 'z';
    }
    return 'a';
}

int main() {

    long N;
    cin >> N;

    string name = "";
    long count = N;
    long amari = 0;

    while (count >= 26) {
        amari = count % 26;
        count = count / 26;
        name = alph(amari)+ name;
        if (amari == 0) {
            count = count - 1;
        }
    }
    if (count == 0) {
    }
    else {
        amari = count % 26;
        name = alph(amari) + name;
    }
    cout << name << endl;
}



Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<String> blueCards = new ArrayList<>();
		Set<String> checkBlueCards = new HashSet<>();
 		for(int i = 0; i < N; i++) {
 			String tmp = sc.next();
			blueCards.add(tmp);
			checkBlueCards.add(tmp);
		}

		int M = Integer.parseInt(sc.next());
		ArrayList<String> redCards = new ArrayList<>();
		for(int i = 0; i < M; i++) {
			redCards.add(sc.next());
		}
		sc.close();

		int score = Integer.MIN_VALUE;
		for(String tmp : checkBlueCards) {
			int tmpScore = 0;
			for(int i = 0; i < blueCards.size(); i++) {
	 			if(blueCards.get(i).equals(tmp)) {
	 				tmpScore++;
	 			}
			}

			for(int i = 0; i < redCards.size(); i++) {
	 			if(redCards.get(i).equals(tmp)) {
	 				tmpScore--;
	 			}
			}

			score = Math.max(score, tmpScore);
		}
		if(score > 0) {
			System.out.println(score);
		}else {
			System.out.println(0);
		}

	}

}

Measured memory_bytes: 23252
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, m; cin>>n>>m;
    vector<string> a(n), b(m);
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<m; i++) cin>>b[i];

    bool ans = false;
    for(int i=0; i+m-1<n; i++){
        for(int j=0; j+m-1<n; j++){
            bool valid = true;
            for(int k=0; k<m; k++){
                for(int l=0; l<m; l++){
                    if(a[i+k][j+l] != b[k][l]) valid = false;
                }
            }
            if(valid) ans = true;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

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

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

    static class ARounding {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(in.nextInt() < in.nextInt() ? 0 : 10);
        }

    }
}



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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    string x;
    int k,n;
    cin>>n>>k>>x;
    x[k-1]=tolower(x[k-1]);
    cout<<x;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void ) {
	char ch;
	int i, count[ 4 ] = {}, min;

	while ( ( ch = getchar() ) != EOF )
		switch ( ch ) {
			case 'K': count[ 0 ]++; break;
			case 'U': count[ 1 ]++; break;
			case 'P': count[ 2 ]++; break;
			case 'C': count[ 3 ]++; break;
		}

	min = count[ 0 ];
	for ( i = 1; i < 4; i++ )
		if ( count[ i ] < min )
			min = count[ i ];

	printf( "%d\n", min );

	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(){

    int n;
    int amax, bmin, atemp, btemp;
    int i;

    // Nをnに格納
    scanf("%d", &n);

    // aの最大値をamaxに格納、その時のbをbminに格納
    amax = bmin = 0;
    for (i=0; i<n; i++){
        scanf("%d %d", &atemp, &btemp);
        if(atemp > amax){
            amax = atemp;
            bmin = btemp;
        }
    }

    printf("%d", amax + bmin);

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  int N; cin >> N;
  int boul=0;
  vector<int> a, b, ans;
  a.reserve(N+1); FILL(a, 0);
  b.reserve(N+1); FILL(b, 0);
  ans.reserve(N);

  REP1(i, N) cin >> a[i];
  // デフォルトが空であるとして, 後ろから見ていくことを考える
  // i の倍数の箱が条件を満たしていなかったら箱 i にボールを入れることで
  // 必ず「良いボールの入れ方」になることがわかる
  RREP1(i, N) {
      int cum = 0;
      int M = N/i;
      REP1(j, M) cum += b[i * j];  // i の倍数の箱: i*j s.t. j=1~N/i まで見る
      cum %= 2;
      if (cum != a[i]) {
          b[i] = 1;
          boul++;  // i番目の箱に入れないと条件を満たさない ならば 入れる
          ans.push_back(i);
      }
  }
  cout << boul << endl;
  REP0(i, boul) {
      cout << ans[i];
      if (i!=boul-1) cout << ' ';
  }
  cout << endl; 
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

Measured memory_bytes: 2816
def main():
    X = input()

    #ans = part(X)
    ans = editorial(X)
    print(ans)


def test_ans():
    X_ans = [
        ("TSTTSS", 4),
        ("SSTTST", 0),
        ("TSSTTTSS", 4),
    ]
    for X, ans in X_ans:
        assert part(X) == editorial(X) == ans


def editorial(X):
    stack = [X[0]]
    ans = len(X)
    for c in X[1:]:
        if stack and stack[-1] == "S" and c == "T":
            ans -= 2
            stack.pop()
        else:
            stack.append(c)

    return ans


def part(X):
    while True:
        n = len(X)
        for i in range(n-1):
            if X[i:i+2] == "ST":
                X = X[:i] + X[i+2:]
                break

        if n == len(X):
            break

    return len(X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5116
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    string s;
    cin >> s;

    print("ABC" + s);

}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <list>
#include <set>
using namespace std;
static const int MAX = 10000;
static const int INFTY = 1 << 29;

vector<int> g[MAX];
int n;
bool visited[MAX];
int prenum[MAX];
int parent[MAX];
int lowest[MAX];
int timer;

void dfs(int current, int prev)
{
	prenum[current] = lowest[current] = timer;
	timer++;

	visited[current] = true;

	int next;

	for (int i = 0; i < g[current].size(); i++) {
		next = g[current][i];
		if (!visited[next]) {
			parent[next] = current;
			dfs(next, current);
			lowest[current] = min(lowest[current], lowest[next]);
		}
		else if (next != prev) {
			lowest[current] = min(lowest[current], prenum[next]);
		}
	}
}

void art_points()
{
	for (int i = 0; i < n; i++) {
		visited[i] = false;
	}
	timer = 1;

	dfs(0, -1);

	set<int> ap;
	int np = 0;

	for (int i = 1; i < n; i++) {
		int p = parent[i];
		if (p == 0) np++;
		else if (prenum[p] <= lowest[i]) ap.insert(p);
	}

	if (np > 1) {
		ap.insert(0);
	}

	for (set<int>::iterator it = ap.begin(); it != ap.end(); it++) {
		cout << *it << endl;
	}
}

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

	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		g[s].push_back(t);
		g[t].push_back(s);
	}
	art_points();

	return 0;
}

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

int mid(vector<int>&a)
{
    int n=a.size();
    if(n&1) return a[n/2];
    else return a[n/2]+a[(n-1)/2];
}

void solve()
{   
   int n,i;
    cin>>n;
    vector<int>a(n),b(n);
    for(i=0;i<n;i++)cin>>a[i]>>b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int midb=mid(b);
   int mida=mid(a);
    int ans=midb-mida+1;
    cout<<ans<<endl;
}
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
 int t=1;
   // cin>>t; 
    while(t--)
     solve();   
    
}

Measured memory_bytes: 4720
from itertools import accumulate

N, M, *ab = map(int, open(0).read().split())
acc = [0] * (N + 1)
for a, b in zip(*[iter(ab)] * 2):
    if a > b:
        a, b = b, a
    acc[a - 1] += 1
    acc[b - 1] -= 1
acc = list(accumulate(acc, initial=0))
print("NO") if any(a % 2 for a in acc) else print("YES")


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  ll n, m, Q; cin >> n >> m >> Q;
  vvl dp(n+1, vl(n+1, 0));
  rep(i,m) {
    int l, r; scanf("%d %d", &l, &r);
    dp[l][r]++;
  }
  rep(i,n+1) rep(j,n) dp[i][j+1] += dp[i][j];
  rep(i,n) rep(j,n+1) dp[i+1][j] += dp[i][j];
  
  rep(i,Q) {
    int p, q; scanf("%d %d", &p, &q);
    ll ans = dp[q][q];
    ans -= dp[q][p-1];
    ans -= dp[p-1][q];
    ans += dp[p-1][p-1];
    printf("%lld\n", ans);
  }
  return 0;
}


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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

#define MAX_N 10000

struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);

    vector<int> record(100000);
    rep(i, N)
    {
        record.at(a.at(i))++;
    }

    int ans = 0;
    for (int i = 1; i < 99999; i++) {
        int sum = record.at(i - 1) + record.at(i) + record.at(i + 1);
        if (sum > ans) {
            ans = sum;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<math.h>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	string str,str2;
	int a=0,p=0;
	getline(cin,str);
	str2=str;
	while(1){
		if(str.find("apple",a)==string::npos){
			break;
		}
		else{
			a=str.find("apple",a);
			str2.replace(a,5,"peach");
			a++;
		}
	}
	while(1){
		if(str.find("peach",p)==string::npos){
			break;
		}
		else{
			p=str.find("peach",p);
			str2.replace(p,5,"apple");
			p++;
		}
	}
	cout << str2 <<endl;
	return 0;
}		

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <set>
#include<list>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int a, b, n;
    cin >> a >> b >> n;
    rep(i, n){
        int s, f;
        cin >> s >> f;
        if(!(b <= s || a >= f)){
            cout << 1 << "\n";
            return 0;
        }
    }
    cout << 0 << "\n";

    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
using namespace std;
int main(){
	double l;
	cin>>l;
	l=l/3.0;
	printf("%.7lf",l*l*l);
	return 0;
}


Measured memory_bytes: 256
// A - Hitachi String
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	int n = s.size();
	bool ans = true;
	if (n % 2) ans = false;
	for (int i = 0; i < n; i += 2)
		if (s[i] != 'h' || s[i + 1] != 'i') ans = false;
	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<tuple>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%MOD;
        a=a*a%MOD;
        x>>=1;
    }
    return res;
}
string s;
int g(int i){
    if(i<0) return 0;
    if(i==0) return 1;
    if(i==1&&s[1]==s[0]) return 1;
    if(s[i]!=s[i-1]) return g(i-1)+1;
    if(s[i]==s[i-1]) return g(i-3)+2;
}

int main(){
    cin>>s;
    int n=(int)s.size();
    cout<<g(n-1)<<endl;
    return 0;
}

Measured memory_bytes: 640
def bitcount(N):  # 立ってるbitの数
    bitcnt = [0]
    for _ in range(N):
        bitcnt += [i + 1 for i in bitcnt]
    return bitcnt


n, x = int(input()), input()

num, cnt = int(x, 2), x.count('1')
lbit = bitcount(18)
for i in range(n):
    ans = 1
    if x[i] == '0':
        ctmp = cnt + 1
        tmp = num % ctmp + pow(2, n - (i + 1), ctmp)
    elif x[i] == '1':
        if cnt == 1:
            print(0)
            continue
        ctmp = cnt - 1
        tmp = num % ctmp - pow(2, n - (i + 1), ctmp)
    tmp %= ctmp
    ctmp = lbit[tmp]
    while tmp > 0:
        ans += 1
        tmp %= ctmp
        ctmp = lbit[tmp]
    print(ans)


Measured memory_bytes: 87464
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
#define a_macro(args...) sum(args)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long ll;
const ll mod = 1e9+7;

int sum() { return 0; }

template<typename T, typename... Args>
auto sum(T a, Args... args) { return a + sum(args...); }
template<class T> bool uin(T &a,T b) {return a > b ? (a == b, true) : false; }
template<class T> bool uax(T &a,T b) {return a < b ? (a == b, true) : false; }
ll dp[3005][3005][2];
ll a[3005];
ll solve(int i,int j,int t){
	if(i>j)
		return 0;
	if(dp[i][j][t] != -1)
		return dp[i][j][t];
	if(t == 0)
		return	dp[i][j][0] = max(a[i] + solve(i+1,j,1),a[j] + solve(i,j-1,1));
	else
		return	dp[i][j][1] = min(solve(i+1,j,0),solve(i,j-1,0));
   
}
int main(int argc, const char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    ll n,i,j;
    cin>>n;
    ll sum=0;
    for(i=1;i<=n;++i){
    	cin>>a[i];
    	sum += a[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<2*solve(1,n,0) - sum<<"\n";
    
#ifndef LOCAL_DEFINE
    cerr << "Time elapsed: "<< 1e1 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL_DEFINE
    return 0;
}

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

int in[26], out[26], mv[26], graph[26][26];

void dfs(int s)
{
	mv[s]=1;
	for(int i=0; i<26; i++)
	{
		if(mv[i]) continue;
		if(!graph[s][i]) continue;
		dfs(i);
	}
}

int main()
{
	int N;
	while(cin >> N, N)
	{
		for(int i=0; i<26; i++)
		{
			in[i]=out[i]=mv[i]=0;
			for(int j=0; j<26; j++)
				graph[i][j]=0;
		}

		for(int i=0; i<N; i++)
		{
			string s;
			cin >> s;
			int u=s[0]-'a', v=s[s.size()-1]-'a';
			in[v]++;
			out[u]++;
			graph[u][v]=1;
		}

		bool flag=true;
		for(int i=0; i<26; i++)
		{
			if(in[i]!=0)
			{
				dfs(i); break;
			}
		}

		for(int i=0; i<26; i++)
		{
			if(in[i]!=out[i]||in[i]&&!mv[i])
			{
				flag=false;
				break;
			}
		}

		cout << (flag?"OK":"NG") << endl;
		

	}

}

Measured memory_bytes: 916
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    int t = 1;
    // cin >> t;
    for(int i = 0; i < t;++i){
        int a,b,c;
        cin >> a >> b >> c;
        int x= 0;
        int ans = 0;
        while(a > x){
            x += b;
            ans+=c;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
int main() {
	string s; cin >> s;
	string s_c = s;
	reverse(s.begin(), s.end());
	if (s == s_c)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

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

	  int[] array = new int[n];
	  for(int i = 0; i < k; i++){
	    int d = sc.nextInt();
	    for(int j = 0; j < d; j++){
	      array[sc.nextInt() - 1] = 1;
	    }
	  }

	  int count = 0;
	  for(int i = 0; i < n; i++){
	    if(array[i] != 1) count++;
	  }
	  System.out.print(count);
	}
}

Measured memory_bytes: 46296
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<62)-10e15;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
LL N,K;
 
LL ans = 0;
 
void solve(){
	vector<LL> num(K,0);
	for(int i=1;i<=N;i++) num[i%K]++;
	for(int i=0;i<K;i++){
		if((i*2)%K==0){
			if(i==0) ans += (num[0])*(num[0])*(num[0]);
			else ans += (num[i])*(num[i])*(num[K-i]);
		}
	}
}
 
int main(){
    cin >> N >> K;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
"use strict"

const arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
const target_str = arg_str

let return_val = ''
let head_str = target_str.slice(0, 2)
let head_int = parseInt(head_str)
let tail_str = target_str.slice(2, 4)
let tail_int = parseInt(tail_str)
let head_status = 0 // 0:MでもYでもない
let tail_status = 0 // 0:MでもYでもない

if(0 < head_int && head_int <= 12){
  head_status = 1 // Mの可能性もあるしYの可能性もある
}
if(0 < tail_int && tail_int <= 12){
  tail_status = 1 // Mの可能性もあるしYの可能性もある
}

if(head_status == 1 && tail_status == 1){
  return_val = 'AMBIGUOUS'
}else if(head_status == 0 && tail_status == 1){
  return_val = 'YYMM'
}else if(head_status == 1 && tail_status == 0){
  return_val = 'MMYY'
}else{
  return_val = 'NA'
}

console.log(return_val)

Measured memory_bytes: 7372
n = int(input())
a = list(map(int, input().split()))
num_list = [0] * 10 ** 5
for i in range(n):
    num_list[a[i]] += 1

res = 0
for i in range(1, 10 ** 5 - 1):
    res = max(res, num_list[i - 1] + num_list[i] + num_list[i + 1])

print(res)


Measured memory_bytes: 20764
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define reps(i,s,n) for (int i = s; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define per1(i,n) for (int i = n; i >= 1; --i)
#define all(c) begin(c),end(c)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
// if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W)
static const long double pi = acos(-1.0);
typedef complex<ld> cd;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;

        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;

        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

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

    int N,M;cin>>N>>M;
    UnionFind uf(N);

    vector<vector<int>> G(M);

    rep(i, N) {
        int n; cin >> n;
        rep(j, n) {
            int a; cin >> a; --a;
            G[a].push_back(i);
        }
    }

    rep(i, M) {
        if(G[i].size() < 2) continue;

        int n = G[i].size()-1;
        int one = G[i][0];
        rep1(j, n) {
            uf.merge(one, G[i][j]);
        }
    }

    int root = uf.root(0);
    rep1(i, N - 1) {
        if(uf.root(i) != root) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std; 
#define ll long long int
void readtxt()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int main() 
{ 
    //readtxt();
    ll a, b, c, k,sum=0;
    cin >> a >> b >> c >> k;
    if(a>=k) cout << k << endl;
    else if(a+b >=k) cout << a << endl;
    else cout << 2*a + b - k << endl;
    
} 

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

int main()
{
    int n,q;
    cin>>n;
    int* a= new int[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cin>>q;
    int* b= new int[q];
    for(int i=0;i<q;i++){
        cin>>b[i];
    }
    int sum=0;
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(a[j]==b[i]){
                sum++;
                break;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}



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

int main() {
	int N;
	int A[200];
	int cnt, mincnt = 999;

	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (A[i] % 2 == 1) {
			cout << 0 << endl;
			return 0;
		}
	}

	for (int i = 0; i < N; ++i) {
		cnt = 0;
		while(A[i] % 2 == 0) {
			A[i] = A[i] / 2;
			cnt++;
		}
		if (cnt < mincnt) mincnt = cnt;
	}
	cout << mincnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main(){

    while(1){
        std::vector<int> a;
        int a0,L;
        cin>>a0>>L;
        if(a0==0 && L==0) break;
        a.push_back(a0);

        std::vector<int> degit(L);

      int ptr=0,ans=-1;

        while(1){
            int t=a[ptr++];
             for(int i=1;i<=L;i++){
                if(t!=0){
                    degit[L-i]=t%10;
                    t/=10;
                }else{
                    degit[L-i]=0;
                }
            }

            int max=0,min=0;
            sort(degit.begin(),degit.end());
            for(int i=0;i<L;i++){
                min*=10;
                max*=10;
                min+=degit[i];
                max+=degit[L-i-1];
            }

            a.push_back(max-min);

            for(int i=0;i<a.size()-1;i++){
                if(a[a.size()-1]==a[i]){
                    cout<<i<<" "<<a[a.size()-1]<<" "<<a.size()-1-i<<endl;
                    ans=0;
                }                    
            }

            if(ans>=0) break;
        }
    }

}


Measured memory_bytes: 3144
N = int(input())
A = [int(x) for x in input().split()]

def SelectionSort(A):
    N = len(A)
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            A[i], A[minj] = A[minj], A[i]
            count += 1
    for k in range(N-1):
        print(A[k], end=" ")
    print(A[N-1])
    print(count)

SelectionSort(A)



Measured memory_bytes: 5612
#include <iostream>
#include <cmath>

int main(int argc, char const *argv[]) {
  int N;
  bool flag = false;
  long double ans = 1;
  std::cin >> N;
  for(int i = 0; i < N; i++) {
    long double tmp;
    std::cin >> tmp;
    ans *= tmp;
    if(ans > 1000000000000000000) {
      // std::cout << -1 << std::endl;
      // return 0;
      flag = true;
    }
    if(flag && tmp == 0) {
      std::cout << 0 << std::endl;
      return 0;
    }
  }
  if(flag) {
    std::cout << -1 << std::endl;
    return 0;
  }
  std::cout << (long long int)ans << std::endl;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vl as(n);
    cin>>as;

    ll m = LINF, M = -1;
    rep(i, n) {
        chmin(m, as[i]);
        chmax(M, as[i]);
    }
    if (M - m > 1) {
        cout<<"No"<<endl;
        return 0;
    }
    if (m == M) {
        if (m + 1 == n || m * 2 <= n) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
    }

    ll mc = 0, Mc = 0;
    rep(i, n) {
        if (as[i] == m) mc++;
        else Mc++;
    }
    if ((M - mc) * 2 > Mc || mc - 1 + 1 > m || mc - 1 + Mc / 2 < m) {
        cout<<"No"<<endl;
        return 0;
    }

    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)2e3+5;

ll dp[N][N],sum[N][N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,m;
    cin>>n>>m;
    vector<int> s(n+1),t(m+1);
    for(int i=1;i<=n;i++) {
        cin>>s[i];
    }
    for(int i=1;i<=m;i++) {
        cin>>t[i];
    }
    dp[0][0] = 1;
    for(int i=0;i<=m;i++) {
        sum[0][i] = 1;
    }
    for(int i=1;i<=n;i++) {
        memcpy(sum[i],sum[i-1],sizeof(sum[i]));
        for(int j=1;j<=m;j++) {
            if(s[i]==t[j]) {
                dp[i][j] = sum[i-1][j-1];
            }
            sum[i][j] += sum[i][j-1]-sum[i-1][j-1]+dp[i][j];
            sum[i][j] %= mod;
            if(sum[i][j]<0) sum[i][j] += mod;
        }
    }
    cout<<sum[n][m];
}


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

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

  int num = 0, score = 0;
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    if (A > num) {
      num = A;
      score = B;
    }
  }

  cout << num + score << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 1e9+7;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e5;

 

 
int main()
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	for(int i = 1; i<=3 ; i++)
	{
		if(i != a && i != b)
			cout<<i<<endl;
	}
	return 0;
	
}

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

int N, M, A[1010], total=0;

int main () {
	cin >> N >> M;
	for(int i=1; i<=N; i++) {
		cin >> A[i];
		total += A[i];
	}
	sort(A+1, A+N+1, greater<int>());
	if (A[M]*4*M >= total) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


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

	public static void main(String[] args) {
		//??\?????????
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] A = new int[n][m];
		int[] b = new int[m];
		int[] c = new int[n];
		for (int ni = 0; ni < n; ni++) {
			for (int mi = 0; mi < m; mi++) {
				A[ni][mi] = sc.nextInt();
			}
		}
		for(int mi = 0; mi < m; mi++) {
			b[mi] = sc.nextInt();
		}
		//?¨????
		for (int mi = 0; mi < m; mi++) {
			for (int ni = 0; ni < n; ni++) {
				c[ni] += A[ni][mi] * b[mi];
			}
		}
		//??????
		for (int ni = 0; ni < n; ni++){
			System.out.println(c[ni]);
		}
	}

}

Measured memory_bytes: 40808