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

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

typedef pair<int, int> P;

bool pairCompare1(const P& firstElof, const P& secondElof)
{
    return firstElof.first > secondElof.first;
}
bool pairCompare2(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}
bool pairCompare3(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}
bool pairCompare4(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main() {
    int n; cin >> n;
    vector<P> p;
    int tx,ty;
    rep(i, n) {
        cin >> tx >> ty;
        p.push_back(make_pair(tx, ty));
    }

    vector<P> sabun;

    rep(i, n) rep(j, n) {
        if(i != j) {
            sabun.push_back(make_pair(p[i].first-p[j].first, p[i].second-p[j].second));
        }
    }
    sort(sabun.begin(), sabun.end());
    sabun.erase(unique(sabun.begin(), sabun.end()), sabun.end());

    int ans = n;

    for(int i=0; i < sabun.size(); i++) {
        int tmp_ans = 0;
        rep(j, n) rep(k, n) {
            if(sabun[i].first == p[j].first - p[k].first &&
                sabun[i].second == p[j].second - p[k].second) {
                    tmp_ans++;
                    break;
            }
        }
        ans = min(ans, n-tmp_ans);
    }

    cout << ans << endl;

}

/**
10
1 1
3 7
3 3
5 9
502 502
504 504
10 100
400 100
3000000 3131
513 1
 **/

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    vector<int> a(N);
    vector<int> b(N);

    Scd(N);
    Rep(i,N){
        Scd(a[i]);
    }
    Rep(i,N){
        Scd(b[i]);
    }

    long long int u = 0;
    long long int d = 0;
    int cnt = 0;
    Rep(i,N){
        long long int t = a[i]-b[i];
        if( t > 0 ){
            u += t;
        }else{
            d -= t/2;
        }
    }

    YesNo( u <= d );

    return 0;
}

/*
3
1 1 1
2 0 2

3
1 1 1
4 0 2
*/


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

//----------------------------------------------------------------

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

  vec a(m);
  rep(i,m){
    cin >> a[i];
  }

  vecll pat(n+1);
  // simple DP a_(n+2) = a_(n+1) + a_(n)
  rep(i,n+1){
    if(i==0){pat[i]=1; continue;}
    if(i==1){pat[i]=1; continue;}
    pat[i] = pat[i-1] + pat[i-2];
    pat[i] = pat[i] % mod;
  }

  if(m>1){
    rep(i,m-1){
      if(a[i+1]-a[i]==1){
        prt(0); return 0;
      }
    }
  }

  ll ans=1;
  if(m==0){
    ans = pat[n];
  } else {
    a.push_back(-1);
    a.push_back(n+1);
    sort(all(a));

    rep(i,m+1){
      ans *= pat[a[i+1]-a[i]-2];
      ans = ans % mod;
    }
  }

  prt(ans);

}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	int i = 0;
	int j = n - 1;
	
	int count = 0;
	while ( i < j ) {
		if (s[i] == 'W' && s[j] == 'R') {
			s[i] = 'R';
			s[j] = 'W';
			i++;
			j--;
			count++;
		} else if (s[i] == 'R' && s[j] == 'R') {
			i++;
		} else if (s[i] == 'W' && s[j] == 'W') {
			j--;
		} else if (s[i] == 'R' && s[j] == 'W') {
			j--;
		}
	}
	
	int cw = 0;
	bool flag = false;
	for (i = 0; i < n; i++) {
		if (s[i] == 'W') {
			cw++;
		}
		
		if (s[i] == 'R') {
			flag = true;
		}
		
		if (flag) {
			count += cw;
			cw = 0;
			flag = false;
		}
	}
	
	cout << count;
	return 0;
}

Measured memory_bytes: 3720
def check(h,w):
	s = A[h][w]
	tf = A[h].count(s) > 1 or B[w].count(s) > 1 or C[h/3][w/3].count(s) > 1
	return "*" if tf else " "
R = range(9)
for r in range(input()):
	if r > 0: print
	A = [raw_input().split() for i in R]
	B = [[A[h][w] for h in R] for w in R] 
	C = [[A[h][w:w+3]+A[h+1][w:w+3]+A[h+2][w:w+3] for w in [0,3,6]] for h in [0,3,6]]
	P = [[check(h,w) for w in R] for h in R] 
	for h in R:
		print "".join([P[h][w]+A[h][w] for w in R])

Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
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;
}

int main() {

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        int x;
        cin >> x;
        a[i] = x - (i+1);
    }
    sort(all(a));

    ll b = a[n/2];
    ll ans = 0;
    rep(i, n){
        ans += abs(a[i] - b);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
    using namespace std;
     
    int main(){
      long Q,H,S,D,N;
      cin>>Q>>H>>S>>D>>N;
     
      long ans=0;
      if(Q*2<=H){
        H=Q*2;
      }
      if(H*2<=S){
        S=H*2;
      }
      if(S*2<=D){
        D=S*2;
      }
     
      long d= N/2;
      N-=d*2;
      ans+=d*D;
      long s=N/1;
      N-=s;
      ans+=s*S;
      long h=N/0.5;
      N-=h*0.5;
      ans+=h*H;
      long q=N/0.25;
      N-=q*0.25;
      ans+=q*Q;
      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<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int h, w, n;
    cin >> h >> w >> n;

    int a[100][100] = {};
    int ans = 0;
    int cnt = 0;
    rep(i, min(h,w)){
        ans++;
        rep(j, max(h, w)){
            a[i][j] = 1;
            cnt++;            
            if(cnt >= n){
                cout << ans << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var aa, bb, cc int
	fmt.Scanf("%d %d %d", &aa, &bb, &cc)
	var result string
	if aa+bb+cc > 21 {
		result = "bust"
	} else {
		result = "win"
	}
	fmt.Printf("%s\n", result)
}


Measured memory_bytes: 512
building = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())

for _ in range(n):
    b, f, r, v = input().split(" ")
    building[int(b)-1][int(f)-1][int(r)-1] += int(v)



for i, b in enumerate(building):
    for f in b:
        for r in f:
            print(" %d"%(r), end="")
        print("")
    if i != 3:
        print ("#" * 20)

Measured memory_bytes: 7752
#include <bits/stdc++.h>
#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 rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    sort(l.begin(),l.end());
    int tot=0;
    rep(i,n-1)tot+=l[i];
    if(tot>l[n-1]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


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

int main() {
  LL r, g, b, n;
  cin >> r >> g >> b >> n;

  LL ans = 0;
  for (LL i = 0; i*r <= n; i ++) {
    for (LL j = 0; i*r + j*g <= n; j ++) {
      LL x = n - (r * i + g * j);
      if (x % b == 0) ans ++;
    }
  }

  cout << ans << endl;
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

ll a[int(2e5)+1],b[int(2e5)+1];
int main(){
	IOS;
	int n,m,i,k,j;
	cin>>n>>m>>k;
	REP(i,0,n-1) cin>>a[i];
	REP(i,0,m-1) cin>>b[i];
	int ans=0;
	ll sum=0;
	i=0;
	j=0;
	vi v;
	while(i<n){
		if(sum+a[i]>k) break;
		sum+=a[i];
		v.EB(a[i]);
		i++;
		ans++;
	}
	int temp=ans;
	while(i>=0&&j<m){
		while(sum<k&&j<m){
			if(sum+b[j]>k) break;
			sum+=b[j];
			j++;
			temp++;
		}
		ans=max(ans,temp);
		dbg(sum,temp);
		if(v.empty()) break;
		temp--;
		sum-=v.back();
		v.pop_back();
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7408
fun main(args: Array<String>) {
    val inputs = readInputLine().split(" ").map { Integer.parseInt(it) }
    val s = readInputLine()
    
    val k = inputs[1]

    val charList = s.toCharArray().mapIndexed { i, c -> if (i + 1 == k) {c.toLowerCase()} else {c}}

    var res = ""
    for (c in charList) {
        res = res + c.toString()
    }
    println(res)
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 38024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  while(n--){
    string s,ans;
    cin>>s;
    ans=s[0];
    int l=0,r=0,p=0,len=s.size();
    for(int i=2;i<len;i+=3){
      if(s[i]=='>') p++;
      else p--;
      if(r<p) ans+=s[i+1],r=p;
      if(p<l) ans=s[i+1]+ans,l=p;      
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3148
# -*- coding: utf-8 -*-
# 整数の入力
n,m= map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))
yoko=0
tate=0
for i in range (0,len(x)):
  yoko+=(n-2*i-1)*x[i]
for i in range (0,len(y)):
  tate+=(m-2*i-1)*y[i]

print(yoko*tate%(10**9+7))

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

template <class T>
inline bool uin(T& a, T b) { return a > b ? (a = b, true) : false; }
template <class T>
inline bool uax(T& a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;
const int nax = 5010;

int N, K;
int len, A[nax];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K;
	len = 0;
	int ans = N;
	for (int i = 1; i <= N; i++) {
		int x;
		cin >> x;
		if (x >= K) {
			ans--;
		} else {
			A[len++] = x;
		}
	}
	sort(A, A + len);
	int tmp = 0;
	while (len >= 2) {
		tmp += A[len - 1];
		if (A[len - 2] + tmp < K) {
			len--;
			continue;
		}
		if (A[0] + tmp >= K) {
			ans = 0;
			break;
		}
		int l = 0, r = len - 2;
		while (l + 1 < r) {
			int mid = (l + r) / 2;
			if (tmp + A[mid] >= K) {
				r = mid;
			} else {
				l = mid;
			}
		}

		ans = ans - (len - r);
		len = r;
	}
	cout << ans << endl;
	return 0;
}

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

int n,m,v,p,a[100005],sum[100005];

signed main()
{
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	sum[0] = 0;
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a + 1,a + n + 1);
	for (int i = 1; i <= n; i++)
	{
		sum[i] = sum[i - 1] + a[i];
	}
	int ans = p;
	for (int i = 1; i <= n - p; i++)
	{
		if (a[i] + m < a[n - p + 1]) continue;
		int tmp = m * v - i * m - (p - 1) * m - (a[i] + m) * (n - p + 1 - i) + (sum[n - p + 1] - sum[i]);
		if (tmp <= 0) ans++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>

using namespace std;

int main() {
	int a;
	cin >> a;
	if(a%4 == 0 || a%7==0) {
		cout << "Yes";
		return 0;
	}
	for(int n = 1;n < 25;n++) {
		for(int j = 1;j < 15;j++) {
			if(a%(4*n+7*j)==0){
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;


		
}


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

int main()
{
    string s; cin >> s;
    int ans = 700 + 100 * ((s[0] == 'o') + (s[1] == 'o') + (s[2] == 'o'));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = 1000000

sieve = Array.new(N + 1, 0)
2.upto(Math.sqrt(N).to_i) do |i|
  next if sieve[i].nonzero?
  2.upto(N / i) {|j| sieve[i * j] = 1}
end

num = (2..N).select {|i| sieve[i].zero?}

until (n = $<.gets.to_i).zero?
  co = 0
  num.each do |a|
    b = n - a
    break if a > b
    co += 1 if sieve[b].zero?
  end
  puts co
end


Measured memory_bytes: 15428
def f(num,N,S):
    alphabet = ["a","b","c","d","e","f","g","h","i","j"]
    if N == num:
        for i in S:
          print(i)
        return
    else:
        tmp = []
        length = len(S)
        for i in S:
            ttmp = sorted(list(i))
            for j in range(alphabet.index(ttmp[-1])+2):
                tmp.append(i+alphabet[j])
        f(num+1,N,tmp)
 
N = int(input())
f(1,N,["a"])

Measured memory_bytes: 14564
S = input()
x = [str(i) for i in str(S)]
a = x[0]
b = x[1]
c = x[2]
d = x[3]
if a == b == c == d:
    print('No')
elif a == b and c == d: 
    print('Yes')
elif b == c and a == d:
    print('Yes')
elif a == c and b == d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
N , K = input().split()
N = int(N)
K = int(K)

p = input().split()

for i in range (N) :
    p[i] = int(p[i]) + 1

q = 0

for i in range (K) :
    q += p[i]

expt = [q]

for i in range (K , N) :
    q -= p[i - K]
    q += p[i]
    expt.append(q)

ans = max(expt) / 2

print (ans)


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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = ll(1e9 + 7);



int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	ll g;

	ll a = C, b = D;
	if (a < b) swap(a, b);
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	g = C / b * D / b * b;

	ll ans = B - B / C - B / D + B / g;
	--A;
	ans -= A - A / C - A / D + A / g;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
   
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#define in inline
#define re register
#define int long long
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();	
	while(v<'0'||v>'9'){
	v=getchar();
	}	
	while(v>='0'&&v<='9'){		
	t=(t<<3)+(t<<1)+(v^48);		
	v=getchar();	}
	return t;
}
int f[4][30002],a,b,c,d,lst[12],sum;
char s[30002];
signed main(){
	cin>>a;
scanf("%s",s);
for(re int i=0;i<a;++i){
	f[1][i]=1;
}
for(re int i=a-1;i>=0;--i){
f[2][i]=sum;
	sum-=lst[s[i]-'0'];
	lst[s[i]-'0']=f[1][i];
	sum+=lst[s[i]-'0'];
	
}
sum=0;
memset(lst,0,sizeof(lst));
for(re int i=a-1;i>=0;--i){	f[3][i]=sum;
	sum-=lst[s[i]-'0'];
	lst[s[i]-'0']=f[2][i];
	sum+=lst[s[i]-'0'];

}
sum=0;
memset(lst,0,sizeof(lst));
for(re int i=a-1;i>=0;--i){
	sum-=lst[s[i]-'0'];
	lst[s[i]-'0']=f[3][i];
	sum+=lst[s[i]-'0'];
}
cout<<sum;
}

Measured memory_bytes: 1024
let [|n;k|] = stdin.ReadLine().Split() |> Array.map int
let p = stdin.ReadLine().Split() |> Array.map float
let sum = p |> Array.map (fun x -> (x+1.0)/2.0)

let va l = sum.[l..(l+k-1)] |> Array.sum
let rec f i v max = if i=n-k+1 then max
                    else
                        let value = v-sum.[i-1]+sum.[i+k-1]
                        f (i+1) value (Array.max [|max;value|])
f 1 (va 0) (va 0) |> stdout.WriteLine

Measured memory_bytes: 32220
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>
#include <climits>

using namespace std;

int main() {

	int n = 0;
	cin >> n;

	int cnt = 0;
	int ans = 0;

	for (int j = 0; j <= n; ++j) {
		int num = j;
		cnt = 0;
		if (num % 2 == 1) {
			for (int i = 1; i <= num; ++i) {
				if (num%i == 0) {
					//printf("%d ", i);
					cnt++;
					if (cnt == 8) {
						//cout << j << endl;
						//return 0;
						ans++;
					}
				}
			}

		}
	}

	cout << ans << endl;


	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int larger = 0;
        int count = 0;

        if (a > b) {
        	larger = a;
        } else {
        	larger = b;
        }

        for (int i = 1; i <= a; i++) {
        	for (int j = 1; j <= larger; j++) {
        		if (i == j) {
        			count++;
        			//System.out.println(i + "月" + j + "日");
        		}
        	}
        }
        //System.out.println(count);
        if (a > b) {
			count--;
		}
        System.out.println(count);
	}
}

Measured memory_bytes: 21460
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
   ll a,b,c,k,ans=0,cnt=0;
   cin>>a>>b>>c>>k;
   if(a>=k){cout<<k<<endl;return 0;}
   else
   {

       if(b>=(k-a)){cout<<a<<endl;return 0;}
       else
       {
           ans=2*a+b-k;
           cout<<ans<<endl;
           return 0;
       }

   }

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define maxn 200010
#define ll long long
int a[maxn];
ll dp[maxn];
int n;
main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    if(a[1]>0)return 0*puts("-1");
    for(int i=2;i<=n;i++)
    {
        if(a[i]-a[i-1]>=2)return 0*puts("-1");
        if(a[i]==a[i-1]+1)dp[i]=dp[i-1]+1;
        else dp[i]=dp[i-1]+a[i];
    }
    printf("%lld\n",dp[n]);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define sz(x) x.size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}
template <class T> inline T gcd(T a, T b) {if (b) return gcd(b, a % b); else return a;}
template <class T> inline T lcm(T a, T b) {return (a * b) / gcd(a,b);}

signed main()
{
//	freopen("THREEPRIMES.inp", "r", stdin); freopen("THREEPRIMES.out", "w", stdout);
	fastio();

	set<int> s;
	int n, a; cin >> n;
	for (int i = 0; i < n; i++) {
        cin >> a;
        s.insert(a);
	}
	if (s.size() != n) cout << "NO";
	else cout << "YES";
}


Measured memory_bytes: 9600
#include <iostream>
#include <string.h>
using namespace std;

int main(){
  int n, y;
  int i, j;
  cin >> n >> y;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= n-i; j++) {
      if(i*1000+j*5000+(n-i-j)*10000==y){
        if(n-i-j<0){
          break;
        }
        printf("%d %d %d\n", n-i-j, j, i);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

    int s = sc.nextInt();
    int h = 60 * 60;
    int hour = s / h;
    int m = s % h;
    int minute = m / 60;
    int second = m - minute * 60;

    System.out.println(hour + ":" + minute + ":" + second);
    sc.close();
  }
}


Measured memory_bytes: 26408
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

class Program
{
	static void Main(string[] args)
	{
		if(Regex.IsMatch(Console.ReadLine(), "^[A-Z]+$"))
			Console.WriteLine("A");
		else
			Console.WriteLine("a");
	}

	/// <summary>
	/// アナグラム
	/// </summary>
	/// <param name="word1"></param>
	/// <param name="word2"></param>
	/// <returns></returns>
	static bool IsAnagramOf(string word1, string word2)
	{
		return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
	}
	/// <summary>
	/// 最小公倍数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Lcm(long a, long b)
	{
		return a * b / Gcd(a, b);
	}

	/// <summary>
	/// 最大公約数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Gcd(long a, long b)
	{
		if (a < b)
			// 引数を入替えて自分を呼び出す
			return Gcd(b, a);
		while (b != 0)
		{
			var remainder = a % b;
			a = b;
			b = remainder;
		}
		return a;
	}
}




//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 26880
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll n, m;   
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    if (n<2) n = 1;
    else n -= 2;
    if (m<2) m = 1;
    else m -= 2;
    cout << n*m << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << (a >= 13 ? b : (a >= 6 ? b / 2 : 0)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
    
    ll n,m;
    cin>>n>>m;
    ll a[n][m];
    ll b[n][m];
    ll c[n][m];
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        for(int j=0;j<m;j++)
        {
            if(s[j]=='.') a[i][j]=0;
            else a[i][j]=-1;
        }
    }
    //for(int i=0;i<n;i++) cout<<a[i];
  //  for(int i=0;i<n;i++){
    //    for(int j=0;j<m;j++) cout<<a[i][j]<<" ";
      //  cout<<endl;
    //}
    ll l=0;
    for(int i=0;i<n;i++){
        l=0;
        for(int j=0;j<m;j++){
            if(a[i][j]==-1) {
                if(l==0) b[i][l]=j;
                else b[i][l]=j-l;
                l=j+1;
            }
           
        }
         b[i][l]=m-1-l+1;
    }
    l=0;
    
        for(int i=0;i<m;i++){
        l=0;
        for(int j=0;j<n;j++){
            if(a[j][i]==-1) {
                if(l==0) c[l][i]=j;
                else c[l][i]=j-l;
                l=j+1;
            }
            
        }
        c[l][i]=n-1-l+1;
        
    }
    
    ll p=0,sum=0;
    
        for(int i=0;i<m;i++){
        p=0;sum=0;
        for(int j=0;j<n;j++){
            if(a[j][i]==-1){
                sum=0;
                p=1;
            }
            else{
                sum+=c[j][i];
                c[j][i]=sum;
                
            }
        }
        /*sum=0;
        if(p==0){
            for(int j=n-1;j>=0;j--){
                sum+=c[j][i];
                c[j][i]=sum;
            }
        }
        */
    }
    
    sum=0;
    
        for(int i=0;i<n;i++){
        p=0;sum=0;
        for(int j=0;j<m;j++){
            if(a[i][j]==-1){
                sum=0;
            }
            else{
                sum+=b[i][j];
                b[i][j]=sum;
                p=1;
            }
        }
        /*sum=0;
        if(p==0){
            for(int j=m-1;j>=0;j--){
                sum+=b[i][j];
                b[i][j]=sum;
            }
        }
        */
    }
    sum=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            sum=max(sum,b[i][j]+c[i][j]);
        }
    }
/*
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cout<<b[i][j]<<" ";
        cout<<endl;
    }
    cout<<endl;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cout<<c[i][j]<<" ";
        cout<<endl;
    }
  */  
  cout<<sum-1;
    return 0;
}

Measured memory_bytes: 93952
#include<bits/stdc++.h>
using namespace std;
#define sz 10010
#define MOD 998244353
#define ll long long

inline ll add(ll a, ll b)
{
	a = ((a % MOD) + MOD) % MOD;
	b = ((b % MOD) + MOD) % MOD;
	return (a + b) % MOD;
}

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

	int n, s; cin >> n >> s;
	vector<int>a(n);
	for (auto &it : a)
		cin >> it;
	vector<vector<ll>>dp(n + 1, vector<ll>(s + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= s; j++)
		{
			dp[i + 1][j] = add(dp[i + 1][j], add(dp[i][j], dp[i][j]));
			if (j + a[i] <= s)
				dp[i + 1][j + a[i]] = add(dp[i + 1][j + a[i]], dp[i][j]);
		}
	}
	cout << dp[n][s];

	return 0;
}

Measured memory_bytes: 73652
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
string s;
int a[10];
int main(){
    cin >> s;
    for(int i=0;i<4;i++) a[i] = s[i]-'0';
    if((a[0]+a[1]+a[2]+a[3])==7) printf("%d+%d+%d+%d=%d\n",a[0],a[1],a[2],a[3],7);
    else if((a[0]+a[1]+a[2]-a[3])==7) printf("%d+%d+%d-%d=%d\n",a[0],a[1],a[2],a[3],7);
    else if((a[0]+a[1]-a[2]+a[3])==7) printf("%d+%d-%d+%d=%d\n",a[0],a[1],a[2],a[3],7);
    else if((a[0]+a[1]-a[2]-a[3])==7) printf("%d+%d-%d-%d=%d\n",a[0],a[1],a[2],a[3],7);
    else if((a[0]-a[1]+a[2]+a[3])==7) printf("%d-%d+%d+%d=%d\n",a[0],a[1],a[2],a[3],7);
    else if((a[0]-a[1]+a[2]-a[3])==7) printf("%d-%d+%d-%d=%d\n",a[0],a[1],a[2],a[3],7);
    else if((a[0]-a[1]-a[2]+a[3])==7) printf("%d-%d-%d+%d=%d\n",a[0],a[1],a[2],a[3],7);
    else if((a[0]-a[1]-a[2]-a[3])==7) printf("%d-%d-%d-%d=%d\n",a[0],a[1],a[2],a[3],7);

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
n, m = map(int, input().split())
g = [[] for i in range(n)]
for  i in range(m):
    a, b = map(int, input().split())
    a-=1; b-=1
    g[a].append(b)
    g[b].append(a)

used = [False] * n
ans = 0
def dfs(itr, n, cnt=0):
    ans = 0
    if len(itr)==n:
        return 1
    else:
        ans = cnt
        for e in g[itr[-1]]:
            if used[e]:
                continue
            used[e] = True
            ans+=dfs(itr+[e], n)
            used[e] = False
    return ans

used[0] = True
print(dfs([0], n, 0))

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

int sumofdigits(int x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }

  return sum;
}//各桁の和を計算する関数
 
int main() {
  
  int N,K,snake=0;

  cin >> N >> K;

  vector<int> l(N);

  for(int i=0;i<N;i++){
    cin >> l.at(i);
  }

  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());

  for(int i=0;i<K;i++){
    snake+=l.at(i);
  }
 
  cout << snake << endl;
 
  return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

const int maxn = (int) 1e5 + 5, maxx = 16;
int dp[(1 << maxx)];

void precalc() {
  dp[0] = 0;
  for (int msk = 1; msk < (1 << maxx); msk++) {
    int x = 0;
    for (int i = 0; i < maxx; i++) {
      if (msk & (1 << i)) {
        x ^= i;
      }
    }
    if (!x) {
      dp[msk] = 0;
      for (int sub = msk; sub > 0; sub = (sub - 1) & msk) {
        if (dp[sub] == -1) {
          continue;
        }
        dp[msk] = max(dp[msk], dp[sub] + 1);
      }
    } else {
      dp[msk] = -1;
    }
  }
}

int n;
int a[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    a[i] = 0;
  }
  for (int i = 0; i < n - 1; i++) {
    int v, u, x;
    scanf("%d%d%d", &v, &u, &x);
    a[v] ^= x;
    a[u] ^= x;
  }
  return true;
}

int cnt[maxx];

void solve() {
  for (int i = 0; i < maxx; i++) {
    cnt[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    cnt[a[i]]++;
  }
  int res = n - cnt[0];
  cnt[0] = 0;
  int msk = 0;
  for (int i = 0; i < maxx; i++) {
    res -= cnt[i] / 2;
    cnt[i] %= 2;
    if (cnt[i]) {
      msk ^= (1 << i);
    }
  }
  assert(dp[msk] != -1);
  res -= dp[msk];
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

int main(){
    int n;
    cin >>n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i,n){
        if(s[i] != s[i+1]) ans+=1;
    }
    cout<<ans<<endl;
}

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

int main() {
string s ;
cin>>s ;
int c=0, y=0 ;
  for(int i=0 ; i<4;i++)
  {
      if(s[i]=='+')
      {
          c+=1;
      }
      else if(s[i]=='-')
      {
          y+=1 ;
      }
  }
  cout<< c-y ;

return 0 ;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
	using System;
	namespace ClassLibrary1
	{
		using System;
		class Program
		{
			static void Main(string[] args)
			{
				int K = int.Parse(Console.ReadLine());

				string S = "ACL";
				string output = "";

				for (int i = 0; i <= K - 1; i++)
				{
					output += S;
				}

				Console.WriteLine(output);
			}
		}

	}
}


Measured memory_bytes: 27412
function main(input) {
  const input_array = input.split(' ');
  const sum_price = input_array[1];
  const paper_money_count = input_array[0];
  

  for(count_10000=0; count_10000<=paper_money_count ;count_10000++){
    maximum_price = 10000 * count_10000 + 5000 * (paper_money_count - count_10000);
    minimum_price = 10000 * count_10000 + 1000 * (paper_money_count - count_10000);
    if(sum_price > maximum_price || sum_price < minimum_price){
      continue;
    }
    for(count_5000=0; count_5000<=paper_money_count - count_10000 ;count_5000++){
      count_1000 = paper_money_count - (count_10000 + count_5000)
      if(count_10000 * 10000 + count_5000 * 5000 + count_1000 * 1000 == sum_price){
        console.log(`${count_10000} ${count_5000} ${count_1000}`);
        return;
      }
    }
  }

  console.log('-1 -1 -1');
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
import sys
def calc(i,j):
    if i == j:
        return 0
    elif j-i == 1:
        return A[i][0]*A[i][1]*A[j][1]
    else:
        if d[i][j]:
            return d[i][j]
        else:
            ret = sys.maxsize
            for k in range(i,j):
                tmp = calc(i,k)+calc(k+1,j)+A[i][0]*A[k][1]*A[j][1]
                if tmp < ret:
                    ret = tmp
            d[i][j] = ret
            return ret

n = int(input())
A = []
d = [[None for _ in range(n)] for _ in range(n)]
for i in range(n):
    a,b = [int(i) for i in input().split()]
    A.append((a,b))
print(calc(0,n-1))


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

#define ll long long
#define ull unsigned long long
#define ld long double

#define tiii tuple < int, int, int >
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >
#define pis pair < int, string >

#define vi vector < int >
#define vd vector < double >
#define vld vector < ld >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >
#define vpis vector < pis >

#define pb push_back
#define mt make_tuple
#define gt0 get < 0 >
#define gt1 get < 1 >
#define gt2 get < 2 >

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 9;

ll a[maxn], f[maxn];

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

    fast;

    int n, k;

    cin >> n >> k;

    for(int i = 1; i <= n; i++) cin >> a[i];

    f[n] = 0;

    for(int i = n - 1; i > 0; i--){
        f[i] = 1e18;

        for(int j = 1; j <= k; j++){
            if(i + j > n) continue;

            f[i] = min(f[i], f[i + j] + abs(a[i] - a[i + j]));
        }
    }

    cout << f[1] << endl;

    return 0;
}


Measured memory_bytes: 5124
s = input()
n = 3
for i in range(2 ** n):
    sign = [False] * n
    for j in range(n):
        if (i >> j) & 1:
            sign[j] = True
    cal = int(s[0])
    for i in range(n):
        if sign[i]:
            cal += int(s[i+1])
        else:
            cal -= int(s[i+1])
    if cal == 7:
        print(s[0], end = '')
        for i in range(n):
            if sign[i]:
                print('+' + s[i+1], end = '')
            else:
                print('-' + s[i+1], end = '')
        print('=7')
        break

Measured memory_bytes: 9208
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{

        int inputCount = int.Parse(Reader.ReadLine());
        long[] tm = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        int divOther = 0;
        int div2 = 0;
        int div4 = 0;
        for (int i = 0; i < tm.Length; i++) {
            if(tm[i] %4==0) {
                div4++;
            } else if(tm[i]%2==0) {
                div2++;
            } else {
                divOther++;
            }
        }
        div2 = div2 % 2;
        string ans = "Yes";
        if(div2+divOther>div4 + 1) {
            ans = "No";
        }
        Console.WriteLine(ans);
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



6
2 7 1 8 2 8



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 22880
#include<stdio.h>
struct tbl_t {
	int c;
	int l;
	unsigned char b; // LSB aligned
} tbl[]= {
	{'A', 6, 0x25},
	{'B', 8, 0x9a},
	{'C', 4, 0x05},
	{'D', 4, 0x01},
	{'E', 3, 0x06},
	{'F', 5, 0x09},
	{'G', 8, 0x9b},
	{'H', 6, 0x10},
	{'I', 4, 0x07},
	{'J', 8, 0x98},
	{'K', 4, 0x06},
	{'L', 5, 0x04},
	{'M', 8, 0x99},
	{'N', 8, 0x9e},
	{'O', 5, 0x05},
	{'P', 3, 0x07},
	{'Q', 8, 0x9f},
	{'R', 4, 0x08},
	{'S', 5, 0x06},
	{'T', 5, 0x07},
	{'U', 8, 0x9c},
	{'V', 8, 0x9d},
	{'W', 6, 0x02},
	{'X', 8, 0x92},
	{'Y', 8, 0x93},
	{'Z', 8, 0x90},
	{' ', 3, 0x05},
	{'.', 6, 0x11},
	{',', 6, 0x03},
	{'-', 8, 0x91},
	{'\'',6, 0x00},
	{'?', 6, 0x01},
};
int index(int c){
	int i;
	for(i=0;i<sizeof(tbl)/sizeof(*tbl);i++)
		if(tbl[i].c==c)
			return i;
	exit(1);
}
int main(){
	int c,b=0,l=0,i;
	while(c=getchar(),c+1){
		if(c=='\n'){
			if(l){
				b<<=5-l;
				putchar(tbl[b&31].c);
				l=0;
			}
			putchar('\n');
		} else {
			i=index(c);
			b=b<<tbl[i].l|tbl[i].b;
			l+=tbl[i].l;
			while(l>=5){
				putchar(tbl[b>>(l-5)&31].c);
				l-=5;
			}
		}
	}
	return 0;
}

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

int n,m,g[3000][3000],dp[3000],e[3000],vis[3000],x,y,f;

void dfs(int p,int t)
{
	if(vis[p])
	{
		if(vis[p]!=t+1)
			f=1;
		return;
	}
	vis[p]=t+1;
	if(t) 
		x++;
	else
		y++;
	for(int i=1; i<=n; i++)
		if(i!=p&&!g[p][i])
			dfs(i,t^1);
}

int calc(int x)
{
	return x*(x-1)/2;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,a,b; i<=m; i++)
	{
		scanf("%d%d",&a,&b);
		g[a][b]=g[b][a]=1;
	}
	memset(dp,0,sizeof dp);
	dp[0]=1;
	for(int i=1; i<=n; i++)
	{
		if(vis[i])
			continue;
		x=0,y=0;
		dfs(i,0);
		memset(e,0,sizeof e);
		for(int j=n; j>=0; j--)
			e[j+x]|=dp[j],e[j+y]|=dp[j];
		for(int j=0; j<=n; j++)
			dp[j]=e[j];
	}
	if(f)
	{
		puts("-1");
		return 0;
	}
	int ans=n*n*2;
	for(int i=0; i<=n; i++)
		if(dp[i])
			ans=min(ans,calc(i)+calc(n-i));
	printf("%d",ans);
	return 0;
}

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

using namespace std;

const int N = 2e5 + 6;

int bit[N];
int get(int x) {
  int r = 0;
  for (; x < N; x += x&-x)
    r += bit[x];
  return r;
}

void upd(int x, int d) {
  for (; x; x -= x&-x)
    bit[x] += d;
}

int add[N], n;
vector<int> que[N];
vector<int> ins[N];

int main() {
  scanf("%d", &n);
  vector<pair<int, int> > p;
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    add[a]++;
    add[b]--;
    que[b].push_back(a);
    ins[a].push_back(b);
  }
  int now = 0, ans1 = 1;
  for (int i = 0; i < N; ++i) {
    now += add[i];
    ans1 = max(ans1, now);
  }
  int ans2 = 1;
  for (int i = 0; i < N; ++i) {
    for (int x : que[i]) {
      ans2 = max(ans2, get(x+1));
    }
    for (int x : ins[i])
      upd(x, +1);
  }
  printf("%d %d\n", ans2, ans1);
  return 0;
}

Measured memory_bytes: 18988
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const ll MOD = 1e9 + 7;

inline ll addmod(ll a, ll b){
    return (a+b)%MOD;
}

const int N = 1e5 + 5;

int n,m;
bool nope[N];
int dp[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    cin>>n>>m;
    REP(i,1,m){
        int x;
        cin>>x;
        nope[x] = true;
    }
    
    dp[0] = 1;
    REP(i,1,n){
        if(nope[i])continue;
        dp[i] = dp[i-1];
        if(i-2 >= 0)dp[i] = addmod(dp[i], dp[i-2]);
    }
    
    cout << dp[n] << endl;
    
    return 0;
}

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

int main () {
  
  int a;
  cin >> a;
  
  int A = 0;
  int B = 0;
  
  vector<int> vec(a);
  for( int i = 0; i < a; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
    for( int i = 0; i < a; i++) {
      
      if ( i % 2 == 0){
        A += vec.at(i);
      }
      else {
        B += vec.at(i);
      }  
        

     } 
  
  cout << A - B << endl;
}

    

Measured memory_bytes: 764
#15rectangle
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    for i in range(H-1):
        S=""
        for j in range(W):
            S+="#"
        print(S)
    S=""
    for j in range(W):
        S+="#"
    print(S, end="")
    H,W=(int(i) for i in input().split())
  #  if H!=0 or W!=0:
    print("\n")

Measured memory_bytes: 7724
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int a[100010];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,l=1<<30,r=0,k=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
	a[i]=gi();
	l=min(l,a[i]),r=max(r,a[i]);
    }
    if(r-l>1) return puts("No"),0;
    if(l==n-1) return puts("Yes"),0;
    for(int i=1;i<=n;i++)
	if(a[i]<r) ++k;
    if(k<r&&r-k<=(n-k)/2) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}




int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int x;
	cin >> x;
	x = x % 10;

	if(x == 3){
		cout << "bon" << endl;
	}
	else if(x == 0 || x == 1 || x == 6 || x == 8){
		cout << "pon" << endl;
	}
	else{
		cout << "hon" << endl;
	}

	return 0;
}

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

using namespace std;

void solve()
{
	int x, h;
	while(cin >> x >> h, x, h)
	{
		double height = sqrt((double)x / 2 * x / 2 + h * h);
		double sum = 0;
		sum += x * x;
		sum += x * height * 2;
		printf("%.6f\n", sum);
	}
}

int main()
{
	solve();
	return(0);
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		
		if((X*2<=Y)&&(Y<=X*4)&&(Y%2==0)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}

}

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

int main() {
    int N;
    cin >> N;
    long long ans=0;
    vector<int> V (3*N);
    for (int i=0 ; i<3*N ; i++)
        cin >> V.at(i);
    sort(V.begin(),V.end());
    for (int i=N ; i<3*N ; i+=2){
        ans+=V.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
a,b=map(int,input().split())
s=input()
if a+b+1!=int(len(s)):
    print("No")
    exit()
for i in range(int(len(s))):
    if i==a:
        if s[i]!="-":
            print("No")
            exit()
    else:
        if s[i] not in ["0","1","2","3","4","5","6","7","8","9"]:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 61944