akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define SZ(a) (int)a.size()
#define MP make_pair

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

struct Spell {
	int A;
	int B;

	Spell() {}
	Spell(int A, int B): A(A), B(B) {}
};

int dp[10002];

int main() {

	int H,N;
	scanf("%d%d", &H, &N);

	memset(dp, 0x7f, sizeof(dp));
	dp[H] = 0;

	vector<Spell> sp;
	for(int i = 1; i <= N; i++) {
		int a,b;
		scanf("%d%d", &a, &b);

		for(int j = H; j > 0; j--) {
			if(j-a >= 0) {
				dp[j-a] = min(dp[j-a], dp[j] + b);
			} else {
				dp[0] = min(dp[0], dp[j] + b);
			}
		}
	}

	printf("%d\n", dp[0]);

	return 0;
}


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

using namespace std;

#define fo(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define lli long long int
#define all(c) c.begin(),c.end()
#define lower(c) tolower(c)
#define upper(c) toupper(c)
#define max(c) *max_element(c.begin(),c.end())
#define min(c) *min_element(c.begin(),c.end())
#define len(c) c.size()
const int MOD = 1000000007;
const int MX = 2e5 + 5;
const int INF = 1e9 + 10;
const lli LINF = 1e18;

void solve() {
	long long n;
	cin >> n;
	long long sum=0;
	for(int i=1;i<=n+1;i++){
		lli low = i;
		lli h = (n/i)*i;
		lli c = h/i-low/i+1;
		sum+=(c*(low+h))/2;
	}
	cout << sum << endl;
}


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


    return 0;
}






Measured memory_bytes: 3552
#include<iostream>
using namespace std;
int main(){
char c=getchar_unlocked();
  int x=0;
  do{
  if(c=='x')x++;
  c=getchar_unlocked();
  }while(c=='o'||c=='x');
  if(x>=8)cout<<"NO\n";
  else cout<<"YES\n";
}

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

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

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


int main()
{
	long long int n;
	cin>>n;
	long double nsd;
	nsd = sqrt(n);
	int nsi = nsd;
	for(size_t i = 0; i<=nsi; i++)
	{
		if(n%(nsi-i)==0)
		{
			cout<<((nsi-i)+n/(nsi-i)-2)<<endl;
			break;
		}

	}
	
	return 0;
}



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

const int MAX_N=1e5+10;
vector<int> primes,is_prime(MAX_N,1);

void sieve(){
    is_prime[0]=is_prime[1]=0;
    for (int i=2;i<MAX_N;++i){
        if (is_prime[i]){
            primes.emplace_back(i);
            for (int j=2*i;j<MAX_N;j+=i) is_prime[j]=0;
        }
    }
}

int m,a,b,n,M,p,q;

void solve(){
    M=0;
    for (int i=0;i<n;++i){
        if (m<primes[i]*primes[i]) break;
        for (int j=i;j<n;++j){
            if (m<primes[i]*primes[j]) break;
            if (primes[j]*primes[i])
            if (primes[j]*a<=primes[i]*b&&M<primes[i]*primes[j]){
                p=primes[i],q=primes[j]; M=p*q;
            }
        }
    }
    cout << p << ' ' << q << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sieve();
    n=primes.size();
    while(cin >> m >> a >> b,m){
        solve();
    }
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
const int INF =1000000007;


int main(){
	string a;
	ci(a);
	if(a[1]=='B'){
		a[1]='R';
	}
	else{
		a[1]='B';
	}
	co(a);
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll r, x, d, i;
    cin >> r >> d >> x;
    for(i = 1; i <= 10; i++)
    {
        cout << r * x - d << endl;
        x = r * x - d;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int tmp = n, num = 0;
  while (tmp) {
    num += tmp%10;
    tmp /= 10;
  }
  if (n%num)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

int main() {
	int a, b;

	vector<string> v;
	while (cin >> a >> b) {
		if (a == 0 && b == 0) {
			break;
		}

		stringstream ss;
		if (a <= b) {
			ss << a << " " << b;
		}
		else {
			ss << b << " " << a;
		}
		v.push_back(ss.str());
	}

	for (int i = 0; i < v.size(); i++) {
		cout << v[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3276
#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;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long M, std::vector<long long> L, std::vector<long long> R, std::vector<long long> C){
  priority_queue<pll,vector<pll>,greater<pll>> q;
  q.push(pll(0,1));
  vector<pair<pll,ll>> v(M);
  REP(M)v[i]=make_pair(pll(L[i],C[i]),R[i]);
  sort(v.begin(),v.end());
  dump(v);
  REP(M){
    while(!q.empty()&&q.top().second<v[i].first.first){
      q.pop();
    }
    if(q.empty()){
      break;
    }
    if(q.top().second<v[i].second){
      ll tmp=q.top().first;
      q.push(pll(tmp+v[i].first.second,v[i].second));
    }
    dump(q.top());
  }
  while(!q.empty()&&q.top().second<N){
    q.pop();
  }
  if(q.empty()){
    cout<<-1<<endl;
  }else{
    cout<<q.top().first<<endl;
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> L(M);
    std::vector<long long> R(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&L[i]);
        scanf("%lld",&R[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, M, std::move(L), std::move(R), std::move(C));
    return 0;
}


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

int main()
{
  long long n, a, b;
  cin >> n >> a >> b;
  long long x = 0;
  if(a == 0)
  {
    cout << 0;
    return 0;
  }
  long long z = n / (a + b);
  long long rem = n % (a + b);
  x = z * a;
  x += min(rem, a);
  cout << (x);
  
  return 0;
}

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

using namespace std;

struct UF {
	vector <int> U;
	UF(int n) {
		U.reserve(n + 1);
		for (int i = 0; i < n; i++){
			U[i] = i;
		}
	}
	void makeset(int x){
		// コンストラクタでやったけど一応かいとく
		U[x] = x;
	}
	int find(int x){
		if (U[x] == x){
			return x;
		}
		else {
			int root = find(U[x]);
			U[x] = root;
			return root;
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	void uni(int x, int y){
		U[find(x)] = find(y);
	}
};

int main(void)
{
	int n, q;
	int com, x, y;

	cin >> n >> q;

	UF uf(n);
	while (q--){
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0){
			// unite
			uf.uni(x, y);
		}
		else {
			printf("%d\n", (int)uf.same(x, y));
		}
	}

	return 0;
}

Measured memory_bytes: 1360
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>

using namespace std;

bool p_ord(pair<int, int> a_b, pair<int, int> c_d) {
    return a_b.second < c_d.second || (a_b.second == c_d.second && a_b.first >= c_d.second);
}


int main()
{
    int N;  cin >> N;
    int a, b;
    vector<pair<int, int> > ab_s;
   
    for(int i = 0; i < N; i++){
        cin >> a >> b;
        ab_s.push_back(make_pair(a, b));
    }

   sort(ab_s.begin(), ab_s.end(),  p_ord);

   int t = 0;
   for(int i = 0; i < N; i++){
       t += ab_s[i].first;
       if(t > ab_s[i].second){
           cout << "No" << endl;
           return 0;
       }
   }
   cout << "Yes" << endl;

   return 0;
}


Measured memory_bytes: 2420
// 153 E

#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <utility>
#include <climits>

using namespace std;

void view(vector<int> v){
    for(int i=0; i<v.size(); i++){
        cout << v.at(i) << " ";
    }
    cout << endl;
}

int main(){
    int n, h, count=0;
    cin >> h >> n;
    pair<int, int> tmp;
    vector<pair<int, int>> v;
    for(int i=0; i<n; i++){
        cin >> tmp.first >> tmp.second;
        v.push_back(tmp);
    }

    vector<int> dp(h, INT_MAX);
    for(int i=0; i<h; i++){
        for(int j=0; j<n; j++){
            if(i-v.at(j).first < 0){
                int buf = v.at(j).second;
                if(dp.at(i) > buf) dp.at(i) = buf;

            }
            else{
                int buf = dp.at(i-v.at(j).first) + v.at(j).second;
                if(dp.at(i) > buf) dp.at(i) = buf;
            }
        }
    }
    cout << dp.back() << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt(), b = sc.nextInt();
        int count = 0;
        for (int i = a; i <= b; i++) {
            String s = String.valueOf(i);
            StringBuilder sb1 = new StringBuilder(s.substring(0, s.length() / 2));
            StringBuilder sb2 = new StringBuilder();
            if (s.length() % 2 == 0) {
                sb2.append(s.substring(s.length() / 2, s.length()));
            } else {
                sb2.append(s.substring(s.length() / 2 + 1, s.length()));
            }
            if (sb1.toString().equals(sb2.reverse().toString())) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 41172
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a, b, c, n, k;
    string s, t;
    ll ans;
    double dans;
    string sans;


    cin  >> a >> b;
    ans = max(a+b, max(a-b, a*b));

    std::cout << ans << endl; 
    // std::cout << sans << endl; 
    
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
def main():
    from queue import Queue
    k = int(input())
    q = Queue()
    for i in range(1,10):
        q.put(i)
    cnt = 0
    while cnt!= k:
        x = q.get()
        cnt += 1
        if x%10!=0:
            q.put(x*10+x%10-1)
        q.put(x*10+x%10)
        if x%10!=9:
            q.put(x*10+x%10+1)
    print(x)

            
if __name__ == "__main__":
    main()

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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  for(int i=0; i<N; i++){
    cin >> m[i];
  }
  
  int min_m=X;
  int tmp = X;
  for(int i=0; i<N; i++){
    tmp-=m[i];
    min_m = min(min_m, m[i]);
  }
  
  cout << N + tmp/min_m << endl;
  
  return 0;
}

Measured memory_bytes: 256
import math
A,B = map(int,input().split())
ans = 0
for i in range (A,B+1):
    s = str(i)
    kai = True
    for j in range (0, math.ceil(len(s)/2)):
        if s[j] != s[-j - 1]:
            kai = False
            break
    if kai == True:
        ans += 1
print(ans)

Measured memory_bytes: 3060
S = input()

list_dmy = S.split('/')

year = int(list_dmy[0])
month = int(list_dmy[1])
day = int(list_dmy[2])

if year <= 2018:
	print('Heisei')

elif year == 2019 and month <= 4 and day <= 30:
	print('Heisei')
else:
	print('TBD')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
vector<vector<ll>> A(3,vector<ll>(3));
  for(ll i=0;i<3;i++) {
    for(ll j=0;j<3;j++) {
cin>>A[i][j];
    }
  }
  vector<vector<bool>> bingo(3,vector<bool>(3));
  ll N;
  cin>>N;
  for(ll i=0;i<N;i++) {
ll b;
    cin>>b;
  for(ll i=0;i<3;i++) {
for(ll j=0;j<3;j++) {
  if(A[i][j]==b) {
bingo[i][j]=true;
  }
}
  }
  }
  
  
  bool j=false;
  for(ll i=0;i<3;i++) {
    ll count=0;
for(ll j=0;j<3;j++) {
  if(bingo[i][j]) {
count++;
  }
}
    if(count==3) {
j=true;
    }
  }
  
  
 for(ll i=0;i<3;i++) {
   ll count=0;
for(ll j=0;j<3;j++) {
  if(bingo[j][i]) {
count++;
  }
}
   
   if(count==3) {
j=true;
   }
 }
    
  ll count=0;
  for(ll i=0;i<3;i++) {
    if(bingo[i][i]) {
count++;
    }
  }
    
if(count==3) {
j=true;
}
  ll t=0;
  for(ll i=0;i<3;i++) {
    if(bingo[i][2-i]) {
t++;
    }
  }
    
if(t==3) {
j=true;
}
  
  
 
    if(j) {
cout<<"Yes"<<endl;
  }
else {
cout<<"No"<<endl;
}
}




  
  
  
  
  

  


Measured memory_bytes: 3556
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
int main() {
	int N;
	cin>>N;
	vint P;
	for(int i=0;i<N;i++){
		int p;
		cin>>p;
		P.pb(p);
	}
	int ans=0;
	for(int i=1;i<N-1;i++){
		if((P[i-1]<P[i] && P[i+1]>P[i]) || (P[i-1]>P[i] && P[i+1]<P[i]))
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int n,m,q;
vector<int> a,b,c,d;
int score(vector<int> &A){
  int ans = 0;
  rep(i,q){
    if(A.at(b.at(i))-A.at(a.at(i))==c.at(i)){
      ans+=d.at(i);
    }
  }
  return ans;
}
int dfs(vector<int> &A){
  if(A.size()==n){
    return score(A);
  }
  int ans = 0;
  int res = A.empty()?0:A.back();
  for(int i=res; i<m; i++){
    A.push_back(i);
    ans=max(dfs(A),ans);
    A.pop_back();
  }
  return ans;
}
int main() {
  cout << fixed << setprecision(10);
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i,q){
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    a.at(i)--; b.at(i)--;
  }
  vector<int> A;
  cout << dfs(A) << endl;
}


Measured memory_bytes: 3632
w,h,n = gets.chomp.split.map(&:to_i)
xs,ys,as = n.times.map{gets.chomp.split.map(&:to_i)}.transpose

x_l = y_d = 0
x_r = w
y_u = h
as.each_with_index do |a,i|
  case a
  when 1
    x_l = xs[i] if xs[i] > x_l
  when 2
    x_r = xs[i] if xs[i] < x_r
  when 3
    y_d = ys[i] if ys[i] > y_d
  when 4
    y_u = ys[i] if ys[i] < y_u
  end
end

if x_r - x_l < 0
  w = 0
else
  w = w - (w - x_r) - x_l
end

if y_u - y_d < 0
  h = 0
else
  h = h - (h - y_u) - y_d
end
puts w * h


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

int main(int argc, void **arg)
{
    char s[100000+1];
    int count = 0;

    scanf("%s", s);

    for (int i = 1; i < strlen(s); i++)
    {
        if( s[i-1] == s[i] )
        {
            s[i] = s[i] == '0' ? '1' : '0';
            count++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long k;
	long long ans[50];
	cin >> k;
	cout << "50" << endl;
	for (int i = 0; i < 50; i++) {
		ans[i] = i;
	}
	for (int i = 0; i < k % 50; i++) {
		for (int j = 0; j < 50; j++) {
			if (ans[j] == 0) {
				ans[j] += 50;
			}
			else {
				ans[j]--;
			}
		}
	}
	for (int i = 0; i < 50; i++) {
		cout << ans[i] + k / 50;
		if (i != 49) {
			cout << " ";
		}
	}
	cout << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define watch(x) cout << (#x) << " is: " << (x) << endl
#define vw(v)                        \
    cout << endl                     \
         << endl                     \
         << (#v) << " is: " << endl; \
    for (ll B : (v))                 \
    {                                \
        cout << B << " ";            \
    }                                \
    cout << endl
#define check(x) cout << "here " << (x) << "?" << endl
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a) for (long long i = (a - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rv(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
ll const MAX = 2147483647, REALMAX = 9223372036854775806;
// ll const N = ;

int main()
{
    FAST_IO
    int x , y;
    cin>>x>>y;
    if(x * 500 >= y)
    cout<<"Yes";
    else cout<<"No";
}

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

int main(){
  int H ,R ,R2;
  cin >> H >> R;

  R2 = -R;

  if(R2 == H) cout << "0" <<endl;
  if(R2 < H ) cout << "1" << endl;
  if(R2 > H) cout << "-1" << endl;
  
  }

   
  




Measured memory_bytes: 3096
#include<stdio.h>

int main()
{
    int r,c;
    int i=0, j=0;
    int rc[101][101]={0};
    
    scanf("%d %d",&r, &c);//空白いる？
    for(i=0; i<r; i++){
        for(j=0; j<c; j++){
            scanf("%d",&rc[i][j]); //空白いる？
        }
    }
    
    for(i=0; i<r; i++){
        for(j=0; j<c; j++){
            rc[i][c] += rc[i][j];//c+1にしてた
        }
    }
    
    for(i=0; i<r; i++){
        for(j=0; j<c+1; j++){
            rc[r][j] += rc[i][j];//r+1にしてた
        }
    }
/*
    for(i=0; i<r+1; i++){
        for(j=0; j<c+1; j++){
            printf("%d ",rc[i][j]);
        }
        printf("\n");
    }
*/
    for(i=0; i<r+1; i++){
        for(j=0; j<c; j++){
            printf("%d ",rc[i][j]);
        }
        printf("%d\n",rc[i][c]);
    }
    return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

bool isOdd(int n) {
	if (n % 2 == 0) {
		return false;
	}
	return true;
}

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

	for (int i = 0; i < k; i++) {
		if (isOdd(i)) {
			// b
			if (isOdd(b)) {
				b--;
			}
			b /= 2;
			a += b;
		}
		else {
			// a
			if(isOdd(a)) {
				a--;
			}
			a /= 2;
			b += a;
		}
	}

	cout << a << " " << b << endl;

	return 0;
}


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

 
int main() {
    int N, Q; cin >> N >> Q;
    string str; cin >> str;

    // 累積和
    vector<int> s(N+1, 0);
    for (int i = 0; i < N; ++i) {
        if (i+1 < N && str[i] == 'A' && str[i+1] == 'C') s[i+1] = s[i] + 1;
        else s[i+1] = s[i];
    }

    // クエリ
    for (int q = 0; q < Q; ++q) {
        int l, r; cin >> l >> r;
        --l, --r; // 0-indexed にする
        cout << s[r] - s[l] << endl;
    }
}   



Measured memory_bytes: 1536
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main :: IO ()
main = do
  [h, k] <- map read . words <$> getLine :: IO [Int]
  h <- drop k . reverse . sort <$> getInts :: IO [Int]

  print $ sum h


Measured memory_bytes: 32124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = buffer[0];
            var L = buffer[1];
            var S = new string[N];
            for (int i = 0; i < N; i++)
            {
                S[i] = Console.ReadLine();
            }
            Array.Sort(S);
            foreach (var s in S)
            {
                Console.Write(s);
            }
            Console.WriteLine();

        }
    }
}


Measured memory_bytes: 3288
// you**can**do**anything :)  
#include <bits/stdc++.h>
#include<iostream> 
#include<algorithm> 
#include<vector> 
#define ll long long
const int maxn=5e5+10;
using namespace std;
 
int main() {
 ll N ,sum=0 ,m=15;
 cin>>N;

while(m<=N ){
	sum+=m;
	m+=15;
}
//cout<<m;
 ll all= N*(N+1)/2;

 ll S1 = ((N / 3)) * (2 * 3 + (N / 3 - 1) * 3) / 2; 
 ll  S2 = ((N / 5)) * (2 * 5 + (N / 5 - 1) * 5) / 2; 
 
 	 cout<<all+sum-S1-S2;
}

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

ll grundy(vector<vector<ll>>& connection, vector<bool>& already, ll now) {
  already.at(now) = true;
  vector<ll> res;
  for (ll i = 0; i < connection.at(now).size(); ++i) {
    ll next = connection.at(now).at(i);
    if (already.at(next)) {
      continue;
    }
    already.at(next) = true;
    res.push_back(grundy(connection, already, next) + 1);
  }
  ll temp = 0;
  for (ll i = 0; i < res.size(); ++i) {
    temp ^= res.at(i);
  }
  // cout << "now" << now << " grundy " << temp << "\n";
  return temp;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<vector<ll>> connection(N);
  vector<bool> already(N, false);
  for (ll i = 0; i < N - 1; ++i) {
    ll x, y;
    cin >> x >> y;
    x -= 1;y -= 1;
    connection.at(x).push_back(y);
    connection.at(y).push_back(x);
  }
  ll ans = grundy(connection, already, 0);
  // cout << ans << "\n";
  if (ans == 0) {
    cout << "Bob" << "\n";
  }
  else {
    cout << "Alice" << "\n";
  }
}


Measured memory_bytes: 19476
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,t,sum = 0;
  bool frag = false;
  string s,X;
  vector<int> minute;
  vector<string> name;
  cin >> N;
  for(int i = 0;i<N;i++){
  	cin >> s >> t;
    minute.push_back(t);
    name.push_back(s);
  }
  cin >> X;
  for(int i = 0; i<N;i++){
    if(frag){sum += minute.at(i);}
    if(name.at(i) == X){frag = true;}
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std; 
int main() {
    int n;cin >>n;
    string t,h;
    int taro=0,hanako=0;
    for (int i = 0; i < n; i++)
    {
        cin >> t >> h;
        if(t.compare(h) > 0){
            taro += 3;
        }else if(t.compare(h)==0){
            taro++;
            hanako++;
        }else {
            hanako +=3;
        }
    }
    cout << taro <<" " << hanako << endl;
    
    return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vld vector < ld >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < long , long >
# define pDD pair < D , D >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

string vow = "aeiou";

void solve ( int test_case )
{
    ll n ; cin >> n ;

    ll ans = (n*(n-1)*(n-2)) + n + 3 * ((n*(n-1)) ) ;
    cout << ans ; line

}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
	int x;

	cin >> x;
	if (x == 0)
    {
      cout << 1 << endl;
    }
	if (x == 1)
    {
	  cout << 0 << endl;
    }
	return (0);
}

Measured memory_bytes: 3668
#include <iostream>

using namespace std;
int main(void){
    
    int n,num;
    string symbol;
    cin >> n;
    
    int S[13],H[13],C[13],D[13];
    
    for(int i=0;i<13;i++){
        S[i]=0;
        H[i]=0;
        C[i]=0;
        D[i]=0;
    }
    
    for(int i=0;i<n;i++){
        cin >> symbol >> num;
        if(symbol=="S"){
            S[num-1]=1;
        }else if(symbol=="H"){
            H[num-1]=1;            
        }else if(symbol=="C"){
            C[num-1]=1;
        }else{
            D[num-1]=1;
        }
    }
    
    for(int i=0;i<13;i++){
        if(S[i]==0) cout << "S " << i+1 << endl;
    }
    for(int i=0;i<13;i++){
        if(H[i]==0) cout << "H " << i+1 << endl;
    }
    for(int i=0;i<13;i++){
        if(C[i]==0) cout << "C " << i+1 << endl;
    }
    for(int i=0;i<13;i++){
        if(D[i]==0) cout << "D " << i+1 << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
Scanf.scanf "%d %d" (fun h n ->
    let ab = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun a b -> a, b)) in
    let mm = 1_000_000_000_000_000_000 in
    let l = Array.make (h + 1) mm in
    l.(h) <- 0;
    for i = h downto 1 do
        if l.(i) <> mm then (
            Array.iter (fun (a, b) ->
                let k = max 0 (i - a) in
                let bb = b + l.(i) in
                l.(k) <- min l.(k) bb) ab
        )
    done;
    Printf.printf "%d\n" l.(0)
)

Measured memory_bytes: 2944
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		String T=stdIn.next();
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		String U=stdIn.next();
		if(U.equals(S))
			System.out.println((A-1)+" "+B);
		else
			System.out.println(A+" "+(B-1));
	}
}


Measured memory_bytes: 24276
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int l;
    cin >> l;
    stack<int> st;
    vector<int> exist(107);
    for (int i = 0; i < l; i++) {
        int c;
        cin >> c;
        if (st.size() >= 1) {
            if (c < 0) {
                if (st.top() != abs(c)) {
                    cout << i + 1 << '\n';
                    return 0;
                }
                st.pop();
                exist[abs(c)]--;
            } else {
                if (exist[c] >= 1) {
                    cout << i + 1 << '\n';
                    return 0;
                }
                st.push(c);
                exist[c]++;
            }
        } else {
            if (c < 0) {
                cout << i + 1 << '\n';
                return 0;
            }
            st.push(c);
            exist[c]++;
        }
    }
    cout << "OK" << '\n';
    return 0;
}




Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n){
    int in;
    cin >> in;
    in--;
    a.at(i) = in;
  }
  vector<int> tr(n, -1), itr;
  int now = 0;
  int co = 0;
  while(1){
    if(tr.at(now) != -1) break;
    tr.at(now) = co;
    itr.push_back(now);
    co++;
    now = a.at(now);
  }
  vector<int> lp(n, -1), ilp;
  int n2 = now;
  co = 0;
  while(1){
    if(lp.at(n2) != -1) break;
    lp.at(n2) = co;
    ilp.push_back(n2);
    co++;
    n2 = a.at(n2);
  }

  // rep(i, n){
  //   cerr << lp.at(i) << " ";
  // }
  // cerr << endl;
  // for(auto i : ilp){
  //   cerr << i << " ";
  // }
  // cerr << endl;
  
  now = 0;
  for(ll i= 0; i < k+1; i++){
    if(i == k){
      // cerr << "tst" << endl;
      cout << itr.at(i)+1 << endl;
      return 0;
    }
    if(lp.at(now) != -1){
      k -= i;
      break;
    }
    now = a.at(now);
  }
  k %= ilp.size();
  cout << ilp.at(k)+1 << endl;
  return 0;
}

Measured memory_bytes: 7900
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

int main()
{
    int a,b,n;
    cin >> a >> b >> n;
    int s[n],e[n];
    for(int i=0;i<n;i++)
        cin >> s[i] >> e[i];
    for(int i=0;i<n;i++){
        if((s[i]<=a&&e[i]>a)||(s[i]<b&&e[i]>=b)||(s[i]>=a&&e[i]<=b)){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}



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

int x[MAXN],bb[MAXN],w[MAXN];
int i,j,k,l,r,s,t,n,m;
ll c;

template<class T>inline void read(T &res)
{
	static char ch;T flag=1;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
}

int main()
{
	read(n);read(l);read(t);
	for (int i=1;i<=n;i++)
    	scanf("%d%d",&x[i],&w[i]);
    for (int i=1;i<=n;i++)
    {
        if (w[i]==2)
        	w[i]=-1;
        r=x[i]+w[i]*t;
        if (r>0)
        	(c+=r/l)%=n;
        else if (r<0) (c+=(r+1)/l-1)%=n;
        bb[i]=(r%l+l)%l;
    }
    sort(bb+1,bb+n+1);
    c=(c+n)%n;
    for (int i=c+1;i<=n;i++)
    	printf("%d\n",bb[i]);
    for (int i=1;i<=c;i++)
    	printf("%d\n",bb[i]);
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int cal[4][4] = {{0, 1, 2, 3}, {1, 0, 3, 2}, {2, 3, 0, 1}, {3, 2, 1, 0}};
  int mul[4][4] = {{1, 1, 1, 1}, {1, -1, 1, -1}, {1, -1, -1, 1}, {1, 1, -1, -1}};
  int n;
  while(cin>>n && n){
    while(n--){
      int a[4], b[4];
      REP(i, 4) cin>>a[i];
      REP(i, 4) cin>>b[i];
      int c[4] = {};
      REP(i, 4)REP(j, 4) c[cal[i][j]] += a[i] * b[j] * mul[i][j];
      REP(i, 4) {
        printf("%d", c[i]);
        putchar((i == 3) ? '\n' : ' ');
      }
    }
  }
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) < abs(x - b)) cout << 'A';
    else cout << 'B';
    cout << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-12;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

void add(ll &x, ll y, ll mod = MOD) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

ll sum(ll x, ll y, ll mod = MOD) {
    add(x, y, mod);
    return x;
}

ll mult(ll x, ll y, ll mod = MOD) {
    return (x * y) % mod;
}

ll div(ll x, ll y, ll mod) {
    return x * power(y, mod - 2, mod);
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

const int N = 303;

int n, m;
int a[N][N];
bool used[N];
int cnt[N];

void run() {
    cin >> n >> m;
    rep(i, 1, n + 1) {
        rep(j, 1, m + 1) cin >> a[i][j];
    }
    
    int ans = INF;
    rep(iter, 0, m) {
        memset(cnt, 0, sizeof cnt);
        pair<int, int> cur = {0, 1};
        
        rep(i, 1, n + 1) {
            rep(j, 1, m + 1) {
                int ind = a[i][j];
                if (!used[ind]) {
                    cnt[ind]++;
                    maxi(cur, mp(cnt[ind], ind));
                    break;
                }
            }
        }
        
        mini(ans, cur.first);
        used[cur.second] = 1;
    }
    
    cout << ans << "\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int A,B,C,D;

    cin >> A >> B >> C >> D;

    cout << max(0, min(B, D) - max(A, C)) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int result;

int main() {
	int n, m, a, b, c, s[10000] = {}, s2[10000] = {}, x, y,max=-105,min=105;
	scanf("%d%d%d%d",&n,&m,&x,&y);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &s[i]);
		if (max <= s[i]) {
			max = s[i];
		}
	}
	for (int i = 1; i <= m; i++) {
		scanf("%d", &s2[i]);
		if (min >= s2[i]) {
			min = s2[i];
		}
	}
	if (min >= y) {
		min = y;
	}
	if (max <= x) {
		max = x;
	}
	if (min - max >= 1 && y - x >= 1) {
		printf("No War");
	}
	else {
		printf("War");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int A,B;

int main(){
	cin>>A>>B;
	if(max(A,B)<9) cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (N,K) = readLine()!!.split(" ").map(String::toInt)
    var A = readLine()!!.split(" ").map(String::toInt)
    var dic :MutableMap<Int,Int> = mutableMapOf()
    A.map{
        if(dic[it] == null) dic[it] = 0
        dic[it] = dic[it]!! + 1
    }
    var s = dic.toList().sortedBy {it.second}.slice(0..dic.size-K-1)
    println(s.map{it.second}.sum())  
    
}


Measured memory_bytes: 96524
#include<iostream>
using namespace std;
static const int N = 100;

int main(){
  int M[N][N];
  int n,u,k,v;

  cin >> n;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j] = 0;
    }
  }

  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 3092
@dir = [[0, 0, 1], [0, 1, 0], [1, 0, 0],
  [0, 1, 1], [0, 1, -1], [1, 0, 1], [1, 0, -1], [1, 1, 0], [1, -1, 0],
  [1, 1, 1], [1, 1, -1], [1, -1, -1], [1, -1, 1]]

def out(dir, x, y, z, n, j)
  dir.zip([x, y, z]).any?{ |a, b| n <= a * j + b || a * j + b < 0 }
end

def check(balls, ok, n, m, turn)
  n.times do |x|
    n.times do |y|
      n.times do |z|
        if balls[x][y][z] == turn
          13.times do |i|
            if ok[turn][x][y][z][i]
              is_ok = true
              m.times do |j|
                if out(@dir[i], x, y, z, n, j)
                  is_ok = false
                  break
                end
                space = balls[x + @dir[i][0] * j][y + @dir[i][1] * j][z + @dir[i][2] * j]
                if !space
                  is_ok = false
                elsif space == 1 - turn
                  (0..j).each do |k|
                    ok[turn][x + @dir[i][0] * k][y + @dir[i][1] * k][z + @dir[i][2] * k][i] = false
                  end
                  is_ok = false
                  break
                end
              end
              return true if is_ok
            end
          end
        end
      end
    end
  end
  false
end

loop do
  n, m, p = gets.split.map(&:to_i)
  break if n == 0
  z_plane = n.times.map{ [0] * n }
  fin = false
  balls = n.times.map{ n.times.map{ [false] * n } }
  ok = 2.times.map{ n.times.map{ n.times.map{ n.times.map { [true] * 13 } } } }
  p.times do |i|
    x, y = gets.split.map(&:to_i)
    next if fin
    z = (z_plane[y - 1][x - 1] += 1)
    balls[x - 1][y - 1][z - 1] = i % 2
    if check(balls, ok, n, m, i % 2)
      printf "%s %d\n" % [['Black', 'White'][i % 2], i + 1]
      fin = true
    end
  end
  puts 'Draw' unless fin
end

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

using namespace std;

#define MOD 1000000007

int main(void){
    int n, m;
    cin >> n >> m;
    vector<int> dp(n + 1, 0);
    vector<bool> b(n + 1, 0);
    for(int i = 0; i < m; i++){
        int x;
        cin >> x;
        b[x] = 1;
    }
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        if(!b[i]){
            if(i - 2 >= 0)
                dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
            else
                dp[i] += dp[i - 1] % MOD;
        }
    }
    cout << dp[n] % MOD << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#define  N  100
int  main( )
{
  int total,i,j,tmp,count=0;
  int  A[N];
  scanf("%d",&total);
    for( i=0; i<total; i++ )
       scanf("%d",&A[i]);
    for(j=total;j>1;j--){
    for( i=0; i<total-1; i++ ){
            if ( A[i]>A[i+1] )
              {
                tmp=A[i];
                A[i]=A[i+1];
                A[i+1]=tmp;
                count++;
              }
          }
    }
    for( i=0; i<total; i++ )
      {
        if(i){
          printf(" ");
        }
        printf("%d",A[i]);
      }
    printf("\n");
    printf("%d",count);
    printf("\n");
    return  0;
}




Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)1000000000000
int main() {
  int N,M;
  cin>>N>>M;
  ll S[N],T[M];
  rep(i,N){cin>>S[i];}
  rep(i,M){cin>>T[i];}
  ll dp[N+1][M+1];
  rep(i,N+1){rep(j,M+1){dp[i][j]=0ll;}}
  rep(i,N+1){dp[i][0]=1ll;}
  rep(i,M+1){dp[0][i]=1ll;}
  rep(i,N){
    rep(j,M){
      dp[i+1][j+1]+=dp[i+1][j];
      dp[i+1][j+1]+=dp[i][j+1];
      if(S[i]!=T[j]){dp[i+1][j+1]-=dp[i][j];}
      dp[i+1][j+1]+=MOD;
      dp[i+1][j+1]%=MOD;
    }
  }
  cout<<dp[N][M];
}

Measured memory_bytes: 34892