akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> c(n);
    for(int i = 0; i < m; i++){
        cin >> c[i];
    }
    ll dp[50010];
    for(int i = 0; i <= n; i++){
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < m; j++){
            if(i-c[j] >= 0){
                dp[i] = min(dp[i], dp[i-c[j]]+1);
            }
        }
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
vector<int> st,d[205];
queue<pair<int,int>> q[205];
int a[205][205],c[205],n,ans,cc[205][205];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        scanf("%01d",&a[i][j]);
        if(a[i][j])d[i].push_back(j);
    }
    for(int i=0;i<n;i++)if(a[i][i]){
        printf("-1");
        return 0;
    }
    st.push_back(0);
    c[0]=1;
    while(!st.empty()){
        int nod=st[st.size()-1];
        st.pop_back();
        for(int i: d[nod]){
            if(c[i]){
                if(c[nod]==c[i]){
                    printf("-1");
                    return 0;
                }
            }
            else{
                c[i]=-c[nod];
                st.push_back(i);
            }
        }
    }
    for(int i=0;i<n;i++){
        int k=0;
        q[i].emplace(i,1);
        cc[i][i]=1;
        while(!q[i].empty()){
            int nod=q[i].front().first,dist=q[i].front().second;
            k=dist;
            q[i].pop();
            for(int j: d[nod])if(!cc[i][j]){
                cc[i][j]=1;
                q[i].emplace(j,dist+1);
            }
        }
        ans=max(ans,k);
    }
    printf("%d",ans);
}

Measured memory_bytes: 768
class UnionFind():
    def __init__(self, n):
        self.parent = [-1]*n
    def root(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]
    def union(self, x,y):
        root_x = self.root(x)
        root_y = self.root(y)
        if root_x == root_y:
            return False
        if self.parent[root_x] < self.parent[root_y]:
            self.parent[root_x] += self.parent[root_y]
            self.parent[root_y] = root_x
        else:
            self.parent[root_y] += self.parent[root_x]
            self.parent[root_x] = root_y
        return True

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
ans = 0
for i in range(m):
    UF = UnionFind(n)
    use = ab[::]
    use.pop(i)
    for a, b in use:
        UF.union(a-1, b-1)
    if sum([j<0 for j in UF.parent]) -1:
        ans += 1
print(ans)


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<typename T>
class BinaryIndexedTree {
    int N;
    vector<T> data;
public:
    BinaryIndexedTree(int N) : N(N) {
        data.resize(N + 1, 0);
    }

    T sum(int k) {
        T res = 0;
        for (; k > 0; k -= k & -k) {
            res += data[k];
        }
        return res;
    }

    void add(int k, T x) {
        for (; k <= N; k += k & -k) {
            data[k] += x;
        }
    }

    /**
     * v1 + v2 + ⋯ + vx ≧ W となる最小の 𝑥 を求める
     */
    int lowerBound(int w) {
        if (w <= 0) return 0;
        int x = 0;
        int k = 1;
        while (k * 2 <= N) k *= 2;
        for (; k > 0; k /= 2) {
            if (x + k <= N && data[x + k] < w) {
                w -= data[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

void solve() {
    ll N, Q;
    cin >> N >> Q;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    BinaryIndexedTree<ll> bit(N + 1);
    rep(i, N) {
        bit.add(i + 1, A[i]);
    }
    rep(q, Q) {
        ll y;
        cin >> y;
        if (y) {
            ll l, r;
            cin >> l >> r;
            l++;
            r++;
            cout << bit.sum(r - 1) - bit.sum(l - 1) << '\n';
        } else {
            ll p, x;
            cin >> p >> x;
            p++;
            bit.add(p, x);
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 12168
import java.math.BigDecimal;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        int cnt = 0;

        for (int i=0; i<s.length; i++) {
            if (s[i]!=t[i]) cnt++;
        }

        System.out.print(cnt);
    }
}


Measured memory_bytes: 41756
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
const ll INF = 5e9;
#define REP(i, N) for (int i = 0; i < (int)N; i++)

vector<vector <ll>> worshallFloyd(vector<vector <ll>> d) {
  int V = d.size();
  for(int k = 0; k < V; k++) {
    for(int i = 0; i < V; i++) {
      for(int j = 0; j < V; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
  return d;
}

int main () {
  int V, E;
  cin >> V >> E;
  vector<vector <ll>> d(V, vector<ll>(V, INF));
  for(int i = 0; i < V; i++) d[i][i] = 0;
  for(int i = 0; i < E; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    d[s][t] = w;
  }

  d = worshallFloyd(d);

  for(int i = 0; i < V; i++) if(d[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
  }
  for(int i = 0; i < V; i++) {
    for(int j = 0; j < V; j++) {
      if(j != 0) cout << ' ';
      if(d[i][j] > 2e9) {
        cout << "INF";
      } else {
        cout << d[i][j];
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 1372
#include<bits/stdc++.h>
#define ll long long
using namespace std;
//namespace  model{
    const ll mod=1e9+7;
    ll ksm(ll a,ll b){
        int ans=1ll;a%=mod;
        while(b){
            if(b&1) ans=ans*a%mod;
            b>>=1;
            a=a*a%mod;
        }
        return ans;
    }
    const int maxn=5e5+7;
    ll fac[maxn+10],inv_fac[maxn+10];

    void init(){
        fac[0]=1;
        for(int i=1;i<=maxn;i++) fac[i]=(fac[i-1]*i)%mod;
        inv_fac[maxn]=ksm(fac[maxn],mod-2);
        for(int i=maxn-1;i>=0;i--) inv_fac[i]=(inv_fac[i+1]*(i+1))%mod;
    }

    ll C(int n,int m){
        if(n < 0 || m < 0 || m > n) return 0;
        if(m == 0 || m == n) return 1;
        return fac[n]*inv_fac[n-m]%mod*inv_fac[m]%mod;
    }
//}

//const ll mod = 1e9+7;

int main (){
    init();
    //cout<<model::C(5,2)<<endl;
	int a,b,h,w;cin>>h>>w>>a>>b;
	ll ans=0;
	for(int i=b+1;i<=w;i++) ans=(ans+(C(h-a-1+i-1,i-1)*C(a-1+w-i,a-1))%mod)%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    unsigned long x = 0;            // 目標額
    unsigned long deposit = 100;    // 預金額100円
    double interest = 0.01;         // 利子1%
    int temp = 0;

    scanf("%lu", &x);

    while(1){
        deposit = deposit * (1 + interest);
        temp += 1;
        if (x <= deposit){
            break;
        }
    }

    printf("%d", temp);

    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str="";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}

int main() {
	string a, b; cin >> a >> b;
	int num = atoi((a + b).c_str());
	if (integer(sqrt(num))) cout << "Yes";
	else cout << "No";

	

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    long long int n , a , b ;
    cin >> n >> a >> b ;

    if((a + b) % 2 == 0){
        cout << abs(a - b) /2 << endl;
    }else{
        if(a > b){
            long long int temp = b ;
            b = a ;
            a = temp ;
        }
        long long int ans = 0 ;
        if( n - b <= a -1 ){
            ans += n - b + 1 ;
            a += n - b + 1 ;
            ans += abs(n -a) / 2 ;
            cout << ans << endl;
        }else{
            ans += a - 1 + 1;
            b -= a - 1 + 1 ;
            ans += abs(1 - b ) / 2 ;
            cout << ans << endl;

        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int h,w;
  cin>>h>>w;
  vector<string>s(h);
  rep(i,h)cin>>s[i];
  rep(i,h){
    cout<<s[i]<<endl;
    cout<<s[i]<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f1(n) for(int i=0;i<n;++i)
#define f2(n) for(int i=1;i<=n;++i)
#define lson(x) x<<1
#define rson(x) x<<1|1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double llf;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const int maxn = 4e5 + 5;
const int mod = 0x3f3f3f3f;
const ll Mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const ll Inf = (ll)1e15;
int gcd(int a, int b) {  //a,b的最大公余数
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

int exgcd(int a, int b, int& x, int& y) {  //ax+by=gcd(a,b)  不定方程的解x,y，函数返回gcd(a,b)
	if (b == 0) {
		x = 1, y = 0;
		return a;
	}
	int ans = exgcd(b, a % b, x, y);
	int tx = x;
	x = y;
	y = tx - a / b * y;
	return ans;
}

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

	int a;
	cin >> a;
	int b = a / 500;
	int c = a % 500;
	int d = c / 5;
	cout << b * 1000 + d * 5 << endl;

	
	
	
	return 0;
}

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

int main(){
  int K,N;
  cin >> K >> N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N-1;i++){
    B.at(i) = A.at(i+1)-A.at(i);
  }
  B.at(N-1) = K - A.at(N-1) +A.at(0);
  sort(B.begin(),B.end());
  int X;
  X = K -B.at(N-1);
  cout << X << endl;
}
    
    

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

int n_max = (int) 1e5 + 5;
vector<int> dp(n_max, 0);
vector<bool> visited(n_max, 0);
vector<vector<int> > edges(n_max);

void dfs(int start) {
	visited[start] = true;
	
	for(int i=0; i<(int) edges[start].size(); i++) {
		if(!visited[edges[start][i]]) dfs(edges[start][i]);
		dp[start] = max(dp[start], dp[edges[start][i]] + 1);
	}
}

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

	for(int i=0; i<m; i++) {
		int u, v;
		cin>>u>>v;
		edges[u].emplace_back(v);
	}
	
	for(int i=1; i<=n; i++) if(!visited[i]) dfs(i);
	cout<<*max_element(dp.begin(), dp.end())<<endl;
	return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String result = "";
		for(int i = 0; i < str.length(); i++) {
			switch(str.substring(i, i+1)) {
				case "0":
					result += "0";
					break;
				case "1":
					result += "1";
					break;
				case "B":
					if(result.length() != 0) {
						result = result.substring(0, result.length()-1);
					}
			}
		}
		System.out.println(result);

	}

}


Measured memory_bytes: 21844
//Sinhov : "Hi stalker!"
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
int main() {
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    ll f=0,t=0,n,i;
    cin>>n;
    vector<ll>arr(n);
    for(i=0;i<n;i++)
        cin>>arr[i];
    for(i=0;i<n;i++){
        if(arr[i]%4==0)
            f++;
        else if(arr[i]%2==0)
            t++;
    }
    if(f+t/2>=n/2)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define BINF 0x7fffffff
#define INF 0x3f3f3f3f
#define LINF 9223372036854775807
#define END(s) {cout<<s;return 0;}
#define CON(s) {cout<<s;continue;}
#define BRE(s) {cout<<s;break;}
#define pb push_back
#define all(a) a.begin(),a.end()
#define sz(a) (int)a.size()
#define F first
#define S second
#define LOCAL_JUDGE 1 //remember to change
using namespace std;
int main(){
	int t;
	cin>>t;
	rep(HateAtcoder,t){
		long long x,y;
		cin>>x>>y;
		long long pro=x*y;
		long long sq=floor(sqrt(pro));
		long long cnt=sq*2-1;
		if(sq*sq==pro && !(sq==x && sq==y)) cnt--;
		if(sq==x && sq==y) cnt--;
		else if(sq>=x) cnt--;
		else if(sq>=y) cnt--;
		if(sq*(sq+1)<pro) cnt++;
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int L, R;
    scan(L, R);

    if (R - L < 2019) {
        ll mn = INF64;
        FOR(i, L, R) {
            FOR(j, i + 1, R + 1) { chmin(mn, (ll)i * j % 2019); }
        }
        print(mn);
    } else {
        print(0);
    }

    return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 100007 << 1;

int n,nn,m,val[_];

inline int able(int sept)
{
	int tran=sept+sept+1;
	for(int i=tran;i<=nn;i++)if(val[i]+val[nn+tran-i]<m)return 0;
	return 1;
}

int main()
{
	n=ty(),m=ty(),nn=n+n;
	for(int i=1;i<=nn;i++)val[i]=ty();
	
	sort(val+1,val+nn+1);

	int l=0,r=n;
	while(r>l)
	{
		int mid=(l+r)>>1;
		if(able(mid))r=mid;
		else l=mid+1;
	}

	int tran=r+r,ans=0;
	for(int i=1;i<=tran;i++)ans=max(ans,(val[i]+val[tran-i+1])%m);
	for(int i=tran+1;i<=nn;i++)ans=max(ans,(val[i]+val[nn+tran-i+1])%m);
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{   
    fast;
    int n;
    cin>>n;
    int a[200005];
    int ans=0;
    for(int i=0;i<n;i++)
    {    cin>>a[i];
         ans=(ans^a[i]);
    }
    for(int i=0;i<n;i++)
    {
        cout<<(ans^a[i])<<" ";
    }
    return 0;
}

Measured memory_bytes: 4444
#include<stdio.h>
#include<limits.h>
int main(void){
    long  long int n, h[100000];
    scanf("%lld", &n);
    for(long long int i=0; i<n; i++){
        scanf("%lld", &h[i]);
    }
    long long int b=h[0], p=0, m=0;
    for(long long int i=1; i<n; i++){
        if(h[i]<=b){
            p++;
        }else{
            if(p>m){
                m=p;
                
            } 
            p=0; 
        }
        b=h[i];
    }
    if(p>m){
        m=p;
    }
    printf("%lld", m);
    return 0;
}

Measured memory_bytes: 896
#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>;

const ll INF = 1001001005;

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> c(n);
  rep(i,n){
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
  
  ll cost =INF;
  
  for (int bit = 0; bit < (1<<n); ++bit) {
    vector<int> al(m);
    ll tc =0;
    bool condition=true;
    for (int i = 0; i < n; ++i) {
      if (bit & (1<<i)) { // 列挙に i が含まれるか
        rep(j,m) al[j] += a[i][j];
        tc += c[i];
      }
    }
    
    rep(k,m){
      if(al[k] < x) condition=false;
      //cout << al[k] << ' ';
      //cout << endl;
      //cout << condition << endl;
    }
    if(condition) cost = min(tc, cost);
  }
  if(cost==INF) cost = -1;
  cout << cost << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 5e5+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

int N,Q;
int c[maxn];
int last[maxn],nx[maxn];
int root[maxn];
struct Tree
{
	struct node{
		int l,r;
		int sum;
	}tr[maxn*4 + maxn*19];
	int tail = 0;
	int build(int l,int r){
		int cur = ++tail;
		if(l == r) return cur;
		int mid = (l+r)>>1;
		tr[cur].l = build(l,mid);
		tr[cur].r = build(mid+1,r);
		return cur;
	}
	int insert(int pre,int l,int r,int x){
		int cur = ++tail;
		tr[cur] = tr[pre];
		if(l == r){
			tr[cur].sum++;
			return cur;
		}else{
			int mid = (l+r)>>1;
			if(x <= mid) tr[cur].l = insert(tr[pre].l,l,mid,x);
			else tr[cur].r = insert(tr[pre].r,mid+1,r,x);
			tr[cur].sum = tr[tr[cur].l].sum + tr[tr[cur].r].sum;
			return cur;
		}
	}
	int query(int cur,int pre,int l,int r,int R){
		if(l == r){
			if(R>l) return tr[cur].sum - tr[pre].sum;
			else return 0;
		}else{
			int mid = (l+r)>>1;
			if(R<=mid) return query(tr[cur].l,tr[pre].l,l,mid,R) + tr[tr[cur].r].sum - tr[tr[pre].r].sum;
			else return query(tr[cur].r,tr[pre].r,mid+1,r,R);
		}
	}
}tree;
void init(){
	for(int i = 1;i<=N;i++){
		if(last[c[i]]){
			nx[last[c[i]]] = i;
		}
		last[c[i]] = i;
	}
	for(int i = 1;i<=N;i++)  if(nx[i] == 0) nx[i] = N+1;
}
void solve(){
	root[0] = tree.build(1,N+1);
	for(int i = 1;i<=N;i++){
		root[i] = tree.insert(root[i-1],1,N+1,nx[i]);
	}
	while(Q--){
		int l,r;cin>>l>>r;
		int ans = tree.query(root[r],root[l-1],1,N+1,r);
		cout<<ans<<'\n';
	}
}
int main(){
	// debug;
	ios;

	cin>>N>>Q;
	for(int i =1;i<=N;i++) cin>>c[i];
	init();
	solve();
	
	return 0;
}


Measured memory_bytes: 138028
#include<bits/stdc++.h>
using namespace std;
char s[100];
int main(){
	long long n,si;scanf("%lld",&n);
	while(n){
		s[si++]='a'+(n-1)%26;
		n=(n-1)/26;
	}
	for(int i=0;i<si-i-1;i++)swap(s[i],s[si-i-1]);
	puts(s);
	return 0;
} 

Measured memory_bytes: 3736
#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>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n; cin>>n;
    vector<P> ans;
    if(n%2==1){
        for(int i=1; i<=n; i++){
            for(int j=i+1; j<=n; j++){
                if(i+j == n) continue;
                
                ans.eb(P(i, j));
            }
        }
    }
    else{
        for(int i=1; i<=n; i++){
            for(int j=i+1; j<=n; j++){
                if(i+j == n+1) continue;
                
                ans.eb(P(i, j));
            }
        }
    }

    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); i++){
        cout << ans[i].fs << " " << ans[i].sc << endl;;
    }
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
a.sort()
c = a[-1]
if n%2 == 0:
  n1 = n//2-1
  for i in range(n1):
    a1 = a[n-2-i]
    c += a1*2
else:
  n2 = n//2
  a3 = a[n-n2-1]
  c += a3
  for i in range(n2-1):
    a2 = a[n-2-i]
    c += a2*2
print(c)

Measured memory_bytes: 31504
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_A&lang=jp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, j) for(int i = 0; i < (int)(j); i++)
constexpr int INF = 1 << 28;
using EdgeList = vector<vector<int>>;
// ?????£?????????????????°?????? E ????????£????????????????§£(Tarjan's algorithm)
// O(N + M) N: ????????°, M: ?????°
vector<vector<int>> strongly_connected_components(const EdgeList &E) {
    int N = E.size();
    vector<int> ord(N, -1), low(N);
    int cnt = 0;
    stack<int> stk;
    vector<bool> on_stack(N);
    vector<vector<int>> scc;    
    function<void(int, int)> dfs = [&] (int now, int pre) {
        stk.push(now);
        on_stack[now] = true;
        ord[now] = cnt++;
        low[now] = ord[now];
        for(int nxt : E[now]) {
            if(ord[nxt] < 0) {
                // not visited
                dfs(nxt, now);
                low[now] = min(low[now], low[nxt]);
            } else if(on_stack[nxt]) {
                // visited
                low[now] = min(low[now], ord[nxt]);
            } 
        }
        if(ord[now] == low[now]) {
            scc.push_back({});
            while(true) {
                int v = stk.top(); stk.pop();
                scc.back().push_back(v);
                on_stack[v] = false;
                if(v == now) break;
            }
        }
    };
    // ??£?????°????????????dfs(0)????????§OK
    rep(i, N) if(ord[i] < 0) dfs(i, -1);
    return scc;
}
// ????????°?????????????????????????????????????????????
bool detect_cycle(const EdgeList &E) {
    auto scc = strongly_connected_components(E);
    bool res = false;
    for(auto &g : scc) res |= g.size() > 1;
    return res;
}
int main() {
    int N, M; cin >> N >> M;
    EdgeList E(N);
    rep(i, M) {
        int a, b; cin >> a >> b;
        E[a].push_back(b);
    }
    cout << (detect_cycle(E) ? 1: 0) << endl;
    return 0;
}

Measured memory_bytes: 3168
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    P = list(map(int, input().split()))
    tmp = 0
    CNT = 0
    for i in range(N):
        if P[i] == i+1:
            if i == 0:
                CNT += 1
                tmp = i
            elif i > 1 and tmp != i-1:
                CNT += 1
                tmp = i
            else:
                tmp = 0
    print(CNT)


if __name__ == '__main__':
    main()

Measured memory_bytes: 20804
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s, t;
  cin >> s >> t;

  bool flag = true;
  for (int i = 0; i < 3; i++) if (s[i] != t[2-i]) flag = false;

  // 解答
  cout << (flag ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
a = ((x+y)/3 + (x-y))/2
b = ((x+y)/3 - (x-y))/2

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if a.is_integer() and a>=0 and b>=0:
    print(cmb(int(a+b),int(a))%((10**9)+7))
else:
    print(0)

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

int main() {

  int A,B,C;
  cin >> A >> B >> C;
	string ans = "No";
	if(A == B){
      ans = "Yes";
    }
	if(B == C){
      ans = "Yes";
    }
	if(C == A){
      ans = "Yes";
    }
	if(A == B && B == C && C == A){
      ans = "No";
    }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define INF 1000000007
using P = pair<int, int>;
int main(){
    int n;
    bool ans=true;
    cin>>n;
    string s[100];
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]==s[j])ans=false;
        }
    }
    for(int i=0;i<n-1;i++){
        if(s[i][s[i].size()-1]!=s[i+1][0])ans=false;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> h(n);
    for(i = 0;i < n;++i){
        cin >> h.at(i);
    }
    vector<ll> dp(n);
    dp.at(0) = 0;
    dp.at(1) = abs(h.at(1) - h.at(0));
    for(i = 0;i+2 < n;++i){
        dp.at(i+2) = min(dp.at(i+1) + abs(h.at(i+2) - h.at(i+1)), dp.at(i) + abs(h.at(i+2) - h.at(i)));
    }
    cout << dp.at(n-1) << endl;
    return 0;
}

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

int main(void)
{
	int n = 0;
	long long ans = 0;
	cin >> n;
	
	for (int i = 1;i <= n; ++i)
		ans += 1ll * (n/i) * (n/i + 1) * i / 2;
	cout << ans << '\n';
	
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	ll A, B, C, D;
	int n;
	cin >> n >> A >> B >> C >> D;
	n--;
	for(ll dd = 0; dd <= n; dd++){
		ll l1 = A - D * dd;
		ll r1 = A - C * dd;
		ll uu = n - dd;
		ll l2 = l1 + C * uu;
		ll r2 = r1 + D * uu;
		if (l2 <= B && B <= r2){
			printf("YES\n");
			return;
		}
	}
	printf("NO\n");
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

n = int(input())
dic = {}
cdic = {}
d = 0
for i in range(1,n+1):
    matsubi = i%10
    sentou = i//(10**d)
    if sentou >= 10:
        d += 1
        sentou = i//(10**d)
    #print(sentou,matsubi)

    if sentou == matsubi:
        if sentou not in cdic:
            cdic[sentou] = 0
        cdic[sentou] += 1
        continue

    sw = False
    if sentou > matsubi:
        sentou,matsubi = matsubi,sentou
        sw = True

    if (sentou,matsubi) not in dic:
        dic[(sentou,matsubi)] = [0,0]

    if not sw:
        dic[(sentou,matsubi)][0] += 1
    else:
        dic[(sentou,matsubi)][1] += 1

ans = 0

for item in cdic:
    ans += cdic[item]*(cdic[item])

for item in dic:
    ans += dic[item][0]*dic[item][1]*2

print(ans)


Measured memory_bytes: 9232
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    K = int(readline())
    
    if K == 1:
        print(1)
        return
    elif K % 2 == 0:
        print(-1)
        return
        
    n = 7 % K
    seen = [False] * K
    for i in range(1, 10 ** 8):
        if n == 0:
            print(i)
            return
        elif seen[n]:
            print(-1)
            return
        else:
            seen[n] = True
            n = (n * 10 + 7) % K
            
    
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 70472
n=int(input())
a=list(map(int,input().split()))
a.sort()

l={}
for i in range(n):
    if a[i] in l:
        l[a[i]]+=1
    else:
        l[a[i]]=1

ans=0

for i in l:
    cnt=l[i]
    if i-1 in l:
        cnt+=l[i-1]
    if i+1 in l:
        cnt+=l[i+1]
    ans=max(cnt,ans)

print(ans)

Measured memory_bytes: 13964
#include <iostream>
#include <cstring>
#include <cstdio>

#define Maxn 200010

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int n, k, c, l[Maxn], r[Maxn];
char ch[Maxn];

int main() {
    n = read(); k = read(); c = read();
    scanf(" %s", ch + 1);
    int j = 0;
    for(int i = 1; i <= n; ++i) {
        if(ch[i] == 'o' && i > j) {
            l[i] = l[i - 1] + 1;
            j = i + c;
        }
        else l[i] = l[i - 1];
    }
    j = n + 1;
    for(int i = n; i; --i) {
        if(ch[i] == 'o' && i < j) {
            r[i] = r[i + 1] + 1;
            j = i - c;
        }
        else r[i] = r[i + 1];
    }
    for(int i = 1; i <= n; ++i) {
        if(ch[i] == 'o' && l[i - 1] + r[i + 1] + 1 == k) printf("%d\n", i);
    }
    return 0;
}

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

using namespace std;

int main(){
  long long n, a[100009], b[100009];
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i] >> b[i];
  long long sm=0;
  for(int i=n-1;i>=0;i--){
    if((a[i]+sm)%b[i]==0)continue;
    sm += ((a[i]+sm-1)/b[i]+1)*b[i] - (a[i]+sm);
  }
  cout << sm << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;


// Input: WeightedGraph, Number of nodes, Starting node
// O( (|V| + |E|) * log(|V|) )
void dijkstra(const WeightGraph& WG, int (&D)[100100], const int& N, const int& S, const int& T) {
  // setup1 (priority queue with smallest second element on top)
  auto compare = [](const Pi& l, const Pi& r) { return l.second >  r.second; };
  priority_queue<Pi, vector<Pi>, decltype(compare)> PQ(compare);
  // setup2 (distance vector)
  // int D[N];
  // setup3 (vector that denotes done:2, doing:1, unseen:0)
  int C[N];

  // initialization1
  for (int i = 0; i < N; i++) {
    D[i] = LLONG_MAX;
    C[i] = 0;
  }
  // initialization2
  D[S] = 0; // starting point
  PQ.push(make_pair(S, 0)); // (vertex S, distance 0)

  while (!PQ.empty()) {
    Pi nearest = PQ.top(); PQ.pop();
    int v = nearest.first;
    int d = nearest.second;
    C[v] = 2;

    if (D[v] < d) continue;
    
    for (auto adjacent: WG[v]) {
      int nv = adjacent.first;
      int nd = adjacent.second;
      
      if (C[nv] == 2) continue;
      if (D[nv] > D[v] + nd) {
        D[nv] = D[v] + nd;
        PQ.push(make_pair(nv, D[nv]));
        C[nv] = 1;
      }
    }
  }
  // for (int i = 0; i < N; i++) {
  //   cout << D[i] << endl; // Distance from Node S
  // }
}

signed main() {
  int N, M, S, T; scanf("%lld %lld %lld %lld", &N, &M, &S, &T);// cin >> N >> M >> S >> T;
  S--; T--;
  WeightGraph AWG(N);
  WeightGraph BWG(N);
  for (int i = 0; i < M; i++) {
    int u, v, a, b; scanf("%lld %lld %lld %lld", &u, &v, &a, &b);// cin >> u >> v >> a >> b;
    u--; v--;
    AWG[u].push_back(make_pair(v, a));
    AWG[v].push_back(make_pair(u, a));
    BWG[u].push_back(make_pair(v, b));
    BWG[v].push_back(make_pair(u, b));
  }

  vector<int> Ans(N);

  int AD[100100];
  int BD[100100];
  dijkstra(AWG, AD, N, S, T);
  dijkstra(BWG, BD, N, T, S);
  
  int ans = LLONG_MAX;
  for (int i = N-1; i >= 0; i--) {
    int tempA = AD[i];
    int tempB = BD[i];
    // cout << i << " " << tempA << " "<< tempB << endl;
    ans = min(tempA + tempB, ans);
    Ans[i] = ans;
  }

  for (int i = 0; i < N; i++) {
    cout << setprecision(15) << 1e15 - Ans[i] << endl;
  }
  
}


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

int main () {
    int t;
    std::cin >> t;
    int h = t / 3600;
    int m = (t % 3600) / 60;
    int s = t % 60;
    //std::cout << h + ':' + m + ':' + s << std::endl;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    string s; cin >> s;
    // string res = "";
    char res[10];
    int p = 0;
    rep(i, s.size()){
        switch(s[i]){
            case '0':
                res[p] = '0'; p++;
                break;
            case '1':
                res[p] = '1'; p++;
                break;
            case 'B':
                if(p > 0) p--;
                break;
        }
    }
    res[p] = '\0';
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a,b;
string t;
string s[]={"a","SAT","FRI","THU","WED","TUE","MON","SUN"};
int main(void){
    cin>>t;
    for(int i=0;i<8;i++){
        if(t==s[i]){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A,B;
  cin>>A>>B;
  string ans;
  if(A.size()>B.size()) ans="GREATER";
  else if(A.size()<B.size()) ans="LESS";
  else {
    for(int i=0;i<A.size();i++){
      if(A.at(i)>B.at(i)){
        ans ="GREATER";
        break;
      }
      if(A.at(i)<B.at(i)){
        ans="LESS";
        break;
      }
        if(i==A.size()-1) ans="EQUAL";
      }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split(' '))

def absdiff(x, K):
    return abs(x - K)

def culc(N, K):
    if K == 1:
        print(0)
        return

    if N*2 == K:
        print(N)
        return

    if N%K == 0:
        print(0)
        return

    x = N % K
    min = x
    while min >= x:
        #print(min, x)
        min = x
        x = absdiff(x, K)
        if min == 1:
            break

    print(min)
    return


culc(N, K)


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map({it.toInt()})
    println(a.reduce(::gcd))
}

fun gcd(a: Int, b: Int): Int =
    if (b > a) gcd(b, a)
    else if (b == 0) a
    else gcd(b, a%b)


Measured memory_bytes: 51888
#include <iostream>
#include <algorithm>

int main(){
	
	int N, M, X;

	std::cin >> N >> M >> X;

	int l = 0, r = 0;
	for(int i = 0; i < M; ++i){
		int input;
		std::cin >> input;

		if(input < X){
			++l;
		}
		else{
			++r;
		}
	}

	std::cout << std::min(l, r) << std::endl;

	return 0;
}


Measured memory_bytes: 888
// #include <iostream>
// #include <string>
// #include <math.h>
// #include <map>
// #include <vector>
// #include <tuple>
// #include <algorithm>
// #include <queue>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;
int main(){
  string s, t;
  cin >> s;
  cin >> t;
  int cnt = 0;
  F(i, 3){
    if (s[i] == t[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main() {
	int n, u, k, v, c, i, j, d[100][100], m[100][100], o, p[100] = { 0 }, e, q = 0;
	memset(m, 0x7f, sizeof(m));
	memset(d, 0x7f, sizeof(d));
	d[0][0] = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> u >> k;
		for (j = 0; j < k; j++) {
			cin >> v >> c;
			m[u][v] = c;
		}
	}
	p[0] = 1;
	for (i = 1; i < n; i++) {
		o = d[0][n - 1];
		for (j = 0; j < n; j++) {
			d[i][j] = min(d[i][j], m[q][j] + d[i - 1][q]);
			d[i][j] = min(d[i][j], d[i - 1][j]);
			if (o >= d[i][j] && p[j] == 0) {
				e = j;
				o = d[i][j];
			}
		}
		p[e] = 1;
		q = e;
	}
	for (i = 0; i < n; i++)cout << i << ' ' << d[n - 1][i] << endl;
	return 0;
}


Measured memory_bytes: 3160
#include<stdio.h>

int main()
{
  int p[10],i,max=0,max_i,n,sum=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&p[i]);
    }   
	

  for(i=0;i<n;i++)
    {   
      if(max<p[i])
	{
          max=p[i];
	  max_i=i;
        }
    }   

  for(i=0;i<n;i++)
    {
      if(i==max_i)
	{
          p[max_i]/=2;
	}
          sum+=p[i];
    }

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

  return 0;
}

Measured memory_bytes: 128
s=input()
a=s[0]
b=s[1]
c=s[2]
d=s[3]
if a==b==c==d:
  print('No')
elif (a==b and c==d) or (a==c and b==d) or (a==d and b==c):
  print('Yes')
else:
  print("No")

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

long long gcd( long long a, long long b )
{
	if( b == 0 )
	{
		return a;
	}
	else
	{
		return gcd( b, a%b );
	}
}
long long glm( long long a, long long b )
{
	return a / gcd( a, b ) *  b;
}

int main()
{
	int n;
	cin >> n;
	long long ans;
	cin >> ans;
	long long times;
	for( int i = 0; i < n-1; i++ )
	{
		cin >> times;
		ans = glm( ans, times );
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int sum=0,n,threes,fives,fifteens;
	cin>>n;
	threes=floor(n/3);
	threes=3*(threes)*(threes+1)/2;
	fives=floor(n/5);
	fives=5*(fives)*(fives+1)/2;
	fifteens=floor(n/15);
	fifteens=15*fifteens*(fifteens+1)/2;
	sum=(n*(n+1)/2)+fifteens-fives-threes;
	cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];
    cin >> M;
    vl B(M);
    rep(i, M) cin >> B[i];

    ll ans = 0;
    rep(i, M){
        rep(j, N) if(B[i]==A[j]){
            ans++;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3184
'use strict';
(function(stdin) {
  var lines = stdin.toString().split('\n');
  var Command = function(str) {
    this.text = str;
    this.buf = [];
  };
  Command.prototype.exec = function(command,args,option) {
    var self = this;
    var commands = {
      print : function(args) {
        self.buf.push(self.text.slice(args[0],args[1] + 1));
      },
      reverse : function(args) {
        var chars = self.text.split('');
        var reverse = chars.splice(args[0],args[1] - args[0] + 1).reverse().join('');
        chars.splice(args[0],0,reverse);
        self.text = chars.join('');
      },
      replace : function(args) {
        var chars = self.text.split('');
        chars.splice(args[0],args[1] - args[0] + 1,option);
        self.text = chars.join('');
      }
    };
    commands[command](args);
  }
  var result = (function(source ,commands) {
    var command = new Command(source);
    commands.forEach(function(v) {
      command.exec(v[0],v.slice(1,3).map(Number),v[3]);
    });
    return command.buf.join('\n');
  }(lines.shift(),lines.slice(0,lines.shift()).map(function(v){return v.split(' ')})
    ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 9500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main
{

	public static void main(String[] args) throws IOException
	{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		double i = Double.parseDouble(str);
		String str2 = BigDecimal.valueOf(i * i * Math.PI).toPlainString();
		String str3 = BigDecimal.valueOf(2 * i * Math.PI).toPlainString();
		System.out.println(str2 + " " + str3);
	}

}



Measured memory_bytes: 24888
/*
2020-05-02
atcoder ABC
C - Rally
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    ull A, B, N;
    cin >> A >> B >> N;
    if(N >= (B - 1)){
        cout << (A * (B - 1)) / B << endl;
    } else {
        cout << (A * N) / B << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const int mxn(1e5 + 10), mxm(4e5 + 10);
const long long modl(1e9 + 7);
long long nm, n, m, p, t, k, ans, l, r;
long long a[mxn], b[mxn], h[mxn];
long long binpow(long long o, long long u) {
  o %= modl;
  long long res = 1;
  while (u) {
    if (u & 1) res = res*o % modl;
    o = o*o % modl;
    u >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
//  freopen("in.txt", "r", stdin);///////////////////////////
//  cin >> nm;
  while (cin >> n) {
    ans = (binpow(10, n) - 2*binpow(9, n) + binpow(8, n)) % modl;
    ans = (ans + modl) % modl;
    cout << ans;
    cout << endl;////////////////////////
  }
  return 0;
}
////////////////////////////////////////////////////////////////////////////////


Measured memory_bytes: 3636