akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
     int a,q=0;
     string s;
     cin>>a>>s;
     for(int i=0;i<=a;i++){
     	if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C'){
     	q++;
		}
	}
	cout<<q;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
    if i == 0 or l[i] - 1 >= l[i - 1]:
        l[i] -= 1
res = all(l[i] >= l[i - 1] for i in range(1, n))
print("Yes" if res else "No")

Measured memory_bytes: 14224
#include <iostream>
#include <vector>

using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;

  vector<int> a(N);

  for(int i=0;i<N;i++){
    a[i] = 0;
  }

  for(int j=0;j<M;j++){
    int s,e;
    cin >> s >> e;
    for(int i=0;i<N;i++){
      if(s==i+1) a[i]++;
      if(e==i+1) a[i]++;
    }
  }

  for (int i=0;i<N;i++){
    cout << a[i] << endl;
  }  

}

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

int main()
{
	long long int i,j,k,l,n1,n2;
	string s1,s2,s3;
	cin>>s1;
	cin>>s2;
	cin>>n1>>n2;
	cin>>s3;
	if(s3==s1)
	{
		n1--;
	}
	else if(s3==s2)
	{
		n2--;
	}
	cout<<n1<<" "<<n2;
	

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
bool comp(pll x , pll y){
    return x.S < y.S;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    ll n , x, y;
    cin >> n;
    pll A[n];
    for(int i= 0 ;i < n ;i++){
        cin >> x >> y;
        A[i] = mp(x , y);
    }
    sort(A , A+n , comp);
    ll st = 0;
    bool q = true;
    for(int i = 0 ;i < n ; i++){
        if(st+A[i].F > A[i].S){
            q = false;
            break;
        }
        else
            st += A[i].F;
    }
    if(q)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;

    int l_ac[n+1];

    int left=0;
    for(int i=0; i<=n;i++){
        if(i==0 || i==1){
            l_ac[i]=0;
            continue;
        } 
        string tmp = s.substr(i-2, 2);
        if(tmp=="AC") left++;
        l_ac[i]=left;
    }
    // REP(i, n+1) cout << l_ac[i]<< " ";cout << endl;

    REP(i, q){
        int li, ri;
        cin >> li >> ri;
        cout << l_ac[ri] - l_ac[li]<< endl;
    }
    return 0;
}

Measured memory_bytes: 1472
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] S = new int[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextInt();
			}
			
			int q = sc.nextInt();
			int ans = 0;
			for(int i=0; i<q; i++) {
				int T = sc.nextInt();
				for(int j=0; j<n; j++) {
					if(T == S[j]) {
						ans++;
						break;
					}
				}
			}
			System.out.println(ans);
		}
	}	
}



Measured memory_bytes: 40144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  
  int count=0;
  for (int i=0; i<=A; i++){
    for (int j=0; j<=B; j++){
      for (int k=0; k<=C; k++){
        if (500*i+100*j+50*k == X)
          count++;
      }
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN = 100+10 ;

int a[MAXN][MAXN];

int main(void)
{
    int n,u,v,t;
    cin>>n;
    for(int i = 1; i <= n; ++i)
    {
        cin>>u>>t;
        for(int j = 1; j <= t; ++j)
        {
            cin>>v;
            a[u][v] = 1;
        }
    }
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 1; j < n; ++j)
        {
            cout<<a[i][j]<<' ';
        }
        cout<<a[i][n]<<'\n';
    }
}



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

int main() {
  char A;
  cin >> A;
  if (A == 'A') {
    cout << 'T' << endl;
  }
  if (A == 'T') {
    cout << 'A' << endl;
  }
  if (A == 'C') {
    cout << 'G' << endl;
  }
  if (A == 'G') {
    cout << 'C' << endl;
  }
}

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

int main() {
	int n;cin>>n;
	vector<int> s(n);
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	vector<int> c(10001,0);
	c[0]=1;
	for(int i=0;i<n;i++){
		for(int j=10000;j>=0;j--){
			if(c[j]){
				c[j+s[i]]=1;
			}
		}
	}
	int ans=0;
	for(int i=0;i<10001;i++){
		if(c[i]){
			if(i%10){
				ans=i;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  long long int n,a,b;
  cin>>n>>a>>b;
  if(a+b==0){
    cout<<0<<"\n";  
  } 
  else if(a==0){
    cout<<0<<"\n";  
  }
  else if(b==0){
    cout<<n<<"\n";  
  }
  else{
    long long int t = (n/(a+b))*a;
    long long int p =min(a,(n%(a+b)));
    cout<<t+p<<"\n"; 
  }
 
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author KY2001
 */


#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}
unordered_map<int, int> element_num; //change type if you need
template <class T>
void counter(T container) {
  for (int i = 0; i < container.size(); i++) {
    element_num[container[i]] += 1;
  }
}

class CNotSoDiverse {
public:
  int solve(std::istream &cin, std::ostream &cout) {
    element_num = {};
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) {
      cin >> A[i];
    }
    counter(A);
    vector<int> B;
    int num = 0;
    rep(i, N + 1) {
      if (element_num[i]){
        num += 1;
        B.emplace_back(element_num[i]);
      }
    }
    sort(ALL(B));
    int ans = 0;
    rep(j, B.size()) {
      if (num <= K) {
        break;
      } else if (B[j]) {
        ans += B[j];
        num -= 1;
      }
    }
    cout << ans << endl;
  }
};


signed main() {
	CNotSoDiverse solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 13740
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}
const int maxn= 1000004;
ll bad;
ll primes[maxn];
vi prime;
void solve()
{
    for(ll i=1;i<maxn;i++)primes[i]=i;
    for(ll i=2;i<maxn;i++)
    {
        
        if(primes[i]==i)
        {prime.pb(i);
            for(ll j=i;j<maxn;j+=i)primes[j]=i;
        }
    }
    ll n;cin>>n;
    ll ans = 0;
    for(auto it:prime)
    {
        ll mul = it;
        while(n%mul==0)
        {
            
            n/=mul;ans++;
            mul*=it;
            
        }
      
    }
    
    if(n>1000000)ans++;
    cout<<ans<<endl;
        
}
signed main()
{
   Need_for_speed(activated);
    
//satisfy
//    {
//   solve();
//   }

    solve();
    return 0;
}



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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

using Graph = vector<vector<int>>;


int main(void)
{
  int n;
  cin >> n;
  Graph G(n);
  int u, k;
  REP(j, n) {
    cin >> u >> k;
    u--;
    REP(i, k) {
      int v;
      cin >> v;
      v--;
      G[u].push_back(v);
      //      G[v].push_back(u);
    }
  }

  vector<int> dist(n, -1);
  queue<int> que;

  dist[0] = 0;
  que.push(0);

  while(!que.empty()) {
    int v = que.front(); que.pop();

    for(int nv : G[v]) {
      if(dist[nv] != -1) continue;

      dist[nv] = dist[v] + 1;
      que.push(nv);
    }
  }
  REP(i, n) cout << i + 1 << " " << dist[i] << endl;

}



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

int main(){
    int n;
    long long ans=0;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s.at(i);
        sort(s.at(i).begin(), s.at(i).end());
    }
    sort(s.begin(), s.end());
    
    int i=0;
    while(i<n-1){
       int cnt=0; 
        int j=i+1;
        while(j<n && s.at(i)==s.at(j)){
            cnt++;
            ans+=cnt;
            j++;
        }
        i=j;
    }
    cout << ans;
}

Measured memory_bytes: 7808
s = input()
count, flag = 0, 1
for i in ('A','C','G','T'):
    if i in s:
        break
else:
    flag = 0
    print(count)
if flag:
    ans,count = 0,1
    for i in range(1, len(s)+1):
        if s[i-1] == 'A' or s[i-1] == 'C' or s[i-1] == 'G' or s[i-1] == 'T':
            count += 1
            ans = max(count,ans)
        else:
            count = 1
    print(ans-1)

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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

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

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

    long long a, b;
    cin >> a >> b;

    vector<long long> cnt(64, 0);
    for (long long i = 1, j = 0; i <= b; i *= 2, j++) {
        long long p = b / (i << 1);
        long long q = b % (i << 1);

        cnt[j] += p * i;
        cnt[j] += max(0LL, q - (i << 1) / 2 + 1);
    }

    if(a!=0)
        a--;

    for (long long i = 1, j = 0; i <= a; i *= 2, j++) {
        long long p = a / (i << 1);
        long long q = a % (i << 1);

        cnt[j] -= p * i;
        cnt[j] -= max(0LL, q - (i << 1) / 2 + 1);
    }

    long long ans = 0;
    long long t = 1;
    rep(i, 64) {
        if(cnt[i]%2){
            ans += t;
        }
        t *= 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, h[N];
int32_t main(){_

   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>h[i];
   }

   int ans = 0;
   for (int i = 0; i < n; ++i)
   {
      bool yes = true;
      for (int j = i-1; j >= 0; --j)
      {
         yes &= (h[i] >= h[j]);
      }
      if(yes)ans++;
   }

   cout<<ans;

   return 0;
}

// Common sense: do smth instead of nothing

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

int main(){
    int K,A,B;
    bool judge=false;
    cin >> K >> A >> B;
    for(int i=A; i<=B; i++){
        if(i%K == 0){
            judge=true;
            break;
        }
    }
    if(judge){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		System.out.println(Main.count(N));
	}

	public static long count(long N) {
		if (N==0) {
			return 0;
		}
		return count(N/2)*2+1;
	}
}

Measured memory_bytes: 35812
#include <iostream>
#include <cstdio>
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
int N;
int64 S,X[MAXN],P[MAXN],ans;
void Solve() {
    scanf("%d%lld",&N,&S);
    for(int i = 1 ; i <= N ; ++i) {
    	scanf("%lld%lld",&X[i],&P[i]);
    }
    int L = 1,R = N;
    int dir = 0;
    while(1) {
    	if(X[L] >= S) {ans += X[R] - S;break;}
    	if(X[R] <= S) {ans += S - X[L];break;}
    	if(P[L] >= P[R]) {
    		if(dir != 1) {dir = 1;ans += X[R] - X[L];}
    		P[L] += P[R];R--;
    	}
    	else {
    		if(dir != 2) {dir = 2;ans += X[R] - X[L];}
    		P[R] += P[L];L++;
    	} 
    }
    printf("%lld\n",ans);
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}

Measured memory_bytes: 1792
#B
n,d = list(map(int, input().split(' ')))
x = [list(map(int,input().split(' '))) for i in range(n)]
count = 0
for i in range(n-1):
    for p in range(i+1,n):
        a = 0
        for s in range(d):
            a += (x[i][s]-x[p][s])**2
        a = a**(1/2)
        if a.is_integer() == True:
            count += 1
print(count)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		for(int i= x - (k-1);i<x+k;i++) {
			System.out.print(i+" ");
		}
		System.out.println();
	}
}

Measured memory_bytes: 22228
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iostream>
#include <deque>
#include <math.h>
#include <cstdio>
#include <functional>
#include <set>
#include <iomanip>
#include <cctype>
#include <tuple>
typedef  long long ll;
using namespace std;

int main(void) {
	int n, m;
    cin >> n >> m;
    vector<int> a(n);
    ll total = 0;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
        total += a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    if (a[m - 1] >= double((double)total / (double)(4 * m)))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
  char s[50];
  char t[51];
  gets(s);
  gets(t);
  int x=strlen(s),y=strlen(t),i,j,flag=0;
  if(s[0]==t[0])
  {
      for(i=1;i<x;i++)
      {
          if(s[i]!=t[i])
          {
              printf("No\n");
              flag=1;
              break;
          }
      }
      if(flag==0)  printf("Yes\n");
  }
  
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 1484
#include<bits/stdc++.h>
using namespace std;
#define ll      long long int
#define MOD     1000000007
#define pb      push_back
#define mp      make_pair
#define all(v)  (v).begin(),(v).end();
#define T		int t;cin>>t;while(t--)
#define IOS     ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {



	//coding a recursive Solution :

	int n, W;
	cin >> n >> W;

	ll w[n], v[n];
	ll sum = 0;
	for (int i = 0 ; i  < n ; i++) {
		cin >> w[i] >> v[i];
		sum += v[i];
	}

	ll dp[n][sum + 1];

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

	}

	for (int i = 0 ; i < n ; i ++)dp[i][0] = 0;


	dp[0][v[0]] = w[0];

	// Sort the elements....


	for (int i = 1; i < n ; i++) {

		for (int j = 1 ; j <= sum ; j++) {

			if (j >= v[i]) {

				dp[i][j]  =   min( w[i] + dp[i - 1][j - v[i]] , dp[i - 1][j] );

			}

			else {

				dp[i][j] = dp[i - 1][j];
			}


		}
	}

//	cout << dp[n - 1][W] << endl;
	ll  ans = -1;

	for (ll j = sum ; j >= 0; j--) {

		if ( dp[n - 1][j] <= W) {
			ans = j;
			break;
		}

	}

	cout << ans << endl;
}




Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M;
  cin >> N;
  vector<int> T(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
    sum += T[i];
  }
  cin >> M;
  vector<int> P(M);
  vector<int> X(M);
  vector<int> ans(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i] >> X[i];
  }
  for (int i = 0; i < M; i++) {
    ans[i] = sum - T[P[i] - 1] + X[i];
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

int main() {
  int a, b, c, x, y;
  scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

  int low = min(x,y);
  int ab = min(a+b, 2*c);
  int price = low*ab;
  if(x>y) {
    price += (x-y)*min(a, 2*c);
  } else {
    price += (y-x)*min(b, 2*c);
  }
  printf("%d\n", price);
}


Measured memory_bytes: 128
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    n:usize,
    s:[Chars;n],
     }
    let mut v = vec![0; 4];
    for cs in s {
        if cs[0] == 'A' {
            v[0] += 1;
        }
        if cs[0] == 'W' {
            v[1] += 1;
        }
        if cs[0] == 'T' {
            v[2] += 1;
        }
        if cs[0] == 'R' {
            v[3] += 1;
        }
    }
    println!("AC x {}", v[0]);
    println!("WA x {}", v[1]);
    println!("TLE x {}", v[2]);
    println!("RE x {}", v[3]);
}


Measured memory_bytes: 7808
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int):
    z = X
    c = 0
    while z <= Y:
        z *= 2
        c += 1
    return c


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    print(solve(X, Y))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    std::string s,t;
    cin >> s >> t;
    int out = 0;
    rep(i,3){
        if(s[i] == t[i]){
            out++;
        }
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
//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

int x,y,a,b,c;

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);

    ll x;
    cin>>x;
    ll ans = 0;
    ans = (x / 500) * 1000;
    x %= 500;
    ans += (x / 5) * 5;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//Lowest Common Ancestor
//最小共通先祖
//二部探索を用いる方法
/*
int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    a = max(a, b);
    a = max(max(a, b), max(c, d));

}*/

#include<bits/stdc++.h>
using namespace std;
#define MAX_V 100010
#define MAX_LOG_V 100
vector<int> G[MAX_V];                   //グラフの隣接リスト
int root;                               //根の頂点番号
int parent[MAX_LOG_V][MAX_V];           //parent[i][j] := 頂点jから2^i親をたどって到達する頂点
int depth[MAX_V];                       //根からの深さ

void dfs(int v, int p, int d){
    parent[0][v] = p;
    depth[v] = d;

    for(int i = 0; i < G[v].size(); i++){
        if(G[v][i] != p) dfs(G[v][i], v, d + 1);
    }
}

void init(int V){
    //parent[0]とdepthを初期化する
    dfs(root, -1, 0);
    //parentを初期化する
    for(int k = 0; k + 1 < MAX_LOG_V; k++){
        for(int v = 0; v < V; v++){
            if(parent[k][v] < 0) parent[k + 1][v] = -1;
            else parent[k + 1][v] = parent[k][parent[k][v]];
        }
    }
}

//uとvのLCAを求める
int lca(int u, int v){
    //uとvの深さが同じになるまで親をたどる
    if(depth[u] > depth[v]) swap(u, v);
    for(int k = 0; k < MAX_LOG_V; k++){
        if((depth[v] - depth[u] >> k) & 1){    //これあテクい
            v = parent[k][v];
        }
    }

    if(u == v) return u;


    //二部探索でLCAを求める
    for(int k = MAX_LOG_V - 1; k >= 0; k--){
        if(parent[k][u] != parent[k][v]){
            u = parent[k][u];
            v = parent[k][v];
        }
    }

    return parent[0][u];      //uの親を返す
}

int main(){

    //0-indexed
    int V; cin >> V;
    root = 0;
    for(int i = 0; i < V; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int c; cin >> c;
            G[i].push_back(c);
            G[c].push_back(i);
        }
    }
    init(V);
    int q; cin >> q;

    for(int i = 0; i < q; i++){
        int u, v; cin >> u >> v;
        cout << lca(u, v) << endl;
    }

    return 0;
}


Measured memory_bytes: 52688
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto s = RD!string;
	long l, r;
	foreach (i; 0..s.length)
	{
		if (s[i] == 'A')
		{
			l = i;
			break;
		}
	}
	foreach_reverse (i; 0..s.length)
	{
		if (s[i] == 'Z')
		{
			r = i;
			break;
		}
	}

	writeln(r-l+1);
	stdout.flush();
	debug readln();
}

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

using namespace std;

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

  int N;
  cin >> N;
  vector<int> nums;
  nums.reserve(N);
  vector<decltype(nums.begin())> its;
  for (int i = 1; i <= N; ++i) {
    int A;
    cin >> A;
    nums.push_back(A);
    its.push_back(nums.end() - 1);
  }
  sort(its.begin(), its.end(), [](auto&& a, auto&& b) { return *a < *b; });
  for (auto it : its) {
    auto idx = it - nums.begin();
    cout << (idx + 1) << " ";
  }
  cout << endl;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9+7;
const lint INF = mod;
const int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    int a[n], x[n][n], y[n][n];
    rep(i, n){
        scanf("%d", &a[i]);
        rep(j, a[i]){
            scanf("%d%d", &x[i][j], &y[i][j]);
            --x[i][j];
        }
    }

    int ans=0;
    rep(S, 1<<n){
        int cnt=0;
        bool flag=true;
        rep(i, n)if((S>>i)&1){
            ++cnt;
            rep(j, a[i]){
                if(((S>>x[i][j])&1)!=y[i][j]){
                    flag=false;
                    break;
                }
            }
        }
        if(flag) chmax(ans, cnt);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let x: usize = sc.read();

    let ans = 8 - (x - 400) / 200;
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2244
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(x...) cerr << __LINE__ << ": " << #x << " = "; DBG::_print(x)
#else
#define DEBUG(x...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;


int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, K;
   cin >> N >> K;
   VI H(N);
   REP(i, N)
      cin >> H[i];
   sort(H.begin(), H.end());

   int res = H[K-1] - H[0];
   for (int i = K; i < N; ++i)
      res = min(res, H[i] - H[i-K+1]);

   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 640
open System
open System.Collections.Generic

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a  

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start

type Graph = ResizeArray<int> array

let main () =
  let (N, M, K) = readInts () |> triple

  let friends =
    let g = Array.init N (fun _ -> ResizeArray<int>())
    for _ in 1..M do
      let (A, B) = readInts() |> Array.map dec |> pair
      g.[A].Add B
      g.[B].Add A
    g

  let blocks =
    [ for _ in 1..K -> readInts() |> Array.map dec |> pair ]
  
  let (group, groupCount) =
    let seen = Array.create N false
    let group = Array.zeroCreate N

    let rec dfs root node =
      if seen.[node] then 0
      else
        seen.[node] <- true
        group.[node] <- root
        1 + (friends.[node].ToArray() |> Array.sumBy (fun c -> dfs root c))

    let result = Array.init N (fun n -> dfs n n)
    let groupCount = Array.init N (fun i -> result.[group.[i]])
    (group, groupCount)
  
  let result =
    let r =
      groupCount
      |> Array.mapi (fun i c -> c - 1 - friends.[i].Count)
    blocks
    |> List.iter (fun (c, d) ->
      if group.[c] = group.[d] then do
        Array.modify r c dec
        Array.modify r d dec
    )
    r
  
  result
  |> Array.iter (printf "%d ")

main()


Measured memory_bytes: 40024
W, H, N = map(int, input().split())
check = [list(map(int, input().split())) for i in range(N)]

rect = [["W" for i in range(W)] for j in range(H)]

for x in check:
    if x[2] == 1:
        for h1 in range(H):
            for w1 in range(x[0]):
                rect[h1][w1] = "B"

    elif x[2] == 2:
        for h2 in range(H):
            for w2 in range(x[0], W, 1):
                rect[h2][w2] = "B"
    elif x[2] == 3:
        for h3 in range(x[1]):
            for w3 in range(W):
                rect[h3][w3] = "B"

    elif x[2] == 4:
        for h3 in range(x[1], H, 1):
            for w3 in range(W):
                rect[h3][w3] = "B"


count = 0
for y in rect:
    count += y.count("W")
print(count)


Measured memory_bytes: 73912
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>

#define INF 1000000005

using namespace std;

const long long MOD = 1000000007;

int n, m;
int tab[1020][1020];
int dp[1020][1020];
char ch;
long long socre;

int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);
        
    cin >> n >> m;
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> ch;
            tab[i][j] = ch;
        }
        
        
    }
    
    dp[0][0] = 1;
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            
            if(i > 0 && tab[i - 1][j] != '#'){
                dp[i][j] += dp[i - 1][j];
            }
            if(j > 0 && tab[i][j - 1] != '#'){
                dp[i][j] += dp[i][j - 1];
            }
            dp[i][j] %= MOD;
        }
    }
    /*
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cout << dp[i][j] << " ";
        }cout << "\n";
    }*/
    cout<<dp[n - 1][m - 1];
}



Measured memory_bytes: 8320
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        for(int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
        }
        Tuple[] tuple = new Tuple[N];
        for(int i = 0; i < N; i++) {
            tuple[i] = new Tuple(A[i], B[i]);
        }
        
        Arrays.sort(tuple, new Comparator<Tuple>() {
            public int compare(Tuple t1, Tuple t2) {
                return t1.getA() - t2.getA();
            }
        });
        
        long money = 0;
        outer: for(int i = 0; i < N; i++) {
            for(int j = 0; j < tuple[i].getB(); j++) {
                money += tuple[i].getA();
                M--;
                if(M == 0) {
                    break outer;
                }
            }
        }
        
        
        System.out.println(money);
    }   
}

class Tuple {
    private int a;
    private int b;
    
    public Tuple(int a, int b) {
        this.a = a;
        this.b = b;
    }
    
    public int getA() {
        return a;
    }
    
    public int getB() {
        return b;
    }
}

Measured memory_bytes: 88196
package main

import(
	"fmt"
)

func main() {
	var K int
	fmt.Scan(&K)
	
	if K % 2 == 0 {
		fmt.Println((K / 2) * (K / 2))
	} else {
		fmt.Println((K / 2) * (K / 2 + 1))
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<list>
using namespace std;

int main()
{
	list<int> L;
	string s;int k;
	int n;cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s[0]=='i')
		{
			cin>>k;
			L.push_front(k);
		}
		else if(s[6]=='F')
		{
			L.pop_front();
		}
		else if(s[6]=='L')
		{
			L.pop_back();
		}
		else
		{
			cin>>k;
			for(list<int>::iterator it=L.begin();it!=L.end();it++)
			{
				if(*it==k)
				{
					L.erase(it);
					break;
				}
			}
		}
	}
	int i=0;
	for(list<int>::iterator it=L.begin();it!=L.end();it++)
	{
		if(i++)cout<<" ";
		cout<<*it;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 34308
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll weights[100001];

ll max(ll a, ll b)
{
    if (a>b)
    {
        return a;
    }
    return b;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,w,a,b;
    cin>>n>>w;
    while (n--)
    {
        cin>>a>>b;
        for (int i=w;i-a>=0;--i)
        {
            weights[i]=max(weights[i],weights[i-a]+b);
        }
    }
    ll ans=0;
    for (int i=0;i<=w;++i)
    {
        ans=max(ans,weights[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char ch[11][1010];
int bel[11],tot,sum[11];
int nxt(int x){
    memset(sum,0,sizeof(sum));
    int p=x;
    while(x<=m){
        bool pd=1;
        for(int i=1;i<=n;i++){
            sum[bel[i]]+=ch[i][x]-'0';
            if(sum[bel[i]]>k) pd=0;
        }
        if(!pd) break;
        x++;
    }
    if(p==x) return -1;
    return x;
}
int main(){
    int minn=2e9;
    scanf("%d %d %d",&n,&m,&k);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) scanf(" %c",&ch[i][j]);
    }
    for(int i=(1<<(n-1))-1;i>=0;i--){
        bel[1]=tot=1;
        for(int j=2;j<=n;j++){
            if(i&(1<<(j-2))) bel[j]=bel[j-1];
            else bel[j]=++tot;
        }
        int x=1,ans=0;
        while(x!=-1&&x<=m) x=nxt(x),ans++;
        if(x!=-1) minn=min(minn,ans+tot-2);
    }
    printf("%d\n",minn);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,i,j,k,d=0;
	int a[110];
	cin >>n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	for(i=0;i<n-2;i++){
		for(j=i+1;j<n-1;j++){
			if(a[i]==a[j])
				continue;
			for(k=j+1;k<n;k++){
				if(a[i]==a[k] || a[j]==a[k]){
					continue;
				}
				if(a[i]+a[j]>a[k]){
					d++;
				}
			}
		}
	}
	cout << d << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

const ll MOD = (ll)1e9 + 7 ;
const int MAXN = 1e5 + 100;

void solve(){
    int x, y, a, b , c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> A(a), B(b), C(c);
    for(auto & x: A)
        cin >> x;
    for(auto & x: B)
        cin >> x;
    for(auto & x: C)
        cin >> x;
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());
    //Take first x , first y 
    vector<ll> fin(x + y);
    int id = 0;

    for(int i = 0; i < x; ++i)
        fin[id++] = A[i];
    for(int i = 0; i < y; ++i)
        fin[id++] = B[i];
    ll sum = 0;
    for(auto & x: fin)
        sum += x;
    sort(fin.rbegin(), fin.rend());
    //Now take until diff C[i] - fin[Lastid] is > 0;
    id = 0;
    bool valid = true;
    int j = fin.size() - 1;
    //cout << sum << '\n';
    while( id < c and valid ){
        ll diff = C[id] - fin[j];
        if( diff > 0){
            sum += diff;
            j--; id++;
        } else {
            valid = false;
            break;
        }
    }
    cout << sum << '\n';
    
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}


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

int main() {
	// your code goes here
	long long n,w;
	long long ans=-1;
	int m_val=0;
	cin>>n>>w;
	vector<long long> wei (n , 0);
	vector<long long> val (n , 0);
	for(int i=0;i<n;i++){
		cin>>wei[i]>>val[i];
		m_val+=(val[i]);
	}
	vector<vector<long long>> dp (n + 1, vector<long long> (m_val+1 , w+1));
	for(int i=0;i<=n;i++){
		dp[i][0]=0;
	}
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<=m_val;j++){
			dp[i][j]=dp[i-1][j];
			if(j>=val[i-1]){
				dp[i][j]=min(dp[i][j], dp[i-1][j-val[i-1]]+wei[i-1]);
			}
		}
	}
	
	
	for(long long i=0;i<=m_val;i++){
		if(dp[n][i]<=w){
			ans=max(ans,i);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 83224
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var array = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        var n = array[0];
        var m = array[1];
        var A = new string[n];
        var B = new string[m];
        var Hash = new HashSet<string>();
        var target = "";
        for(var i = 0;i < n;i++){
            A[i] = Console.ReadLine();
        }
        
        for(var i = 0;i < m;i++){
            B[i] = Console.ReadLine();
            target += B[i];
        }
        
        for(var a = 0;a < n - m + 1;a++){
            for(var b = 0;b < n - m + 1;b++){
                var temp = "";
                for(var y = 0;y < m;y++){
                       temp += A[a + y].Substring(b,m); 
                }
                Hash.Add(temp);
            }
        }
        
        if(Hash.Contains(target)){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
       
    }
}


Measured memory_bytes: 14164
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

using Graph = vector<vector<int>>;
Graph G;
vector<int> A, T;

void dfs1(int v, int p, int d){
    A[v] = d;
    for(auto nv: G[v]){
        if(nv == p) continue;
        dfs1(nv, v, d+1);
    }
}

void dfs2(int v, int p, int d){
    T[v] = d;
    for(auto nv: G[v]){
        if(nv == p) continue;
        dfs2(nv, v, d+1);
    }
}


int main(){
    int n, u, v;
    cin >> n >> u >> v;
    G.assign(n, vector<int>());
    rep(i, n-1){
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    A.resize(n, INF);
    T.resize(n, INF);

    dfs1(v-1, -1, 0);
    dfs2(u-1, -1, 0);

    

    int ans = 0;
    rep(i, n){
        if(T[i] <= A[i]){
            int m = 0;
            //int diff = A[i] - T[i];
            //if(diff%2 == 1) m = 1;
            chmax(ans, A[i] - m);
        } 
    }

    cout << ans-1 << endl;
}

Measured memory_bytes: 10368
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
int main()
{
	int a;
	cin >> a;
	if (a < 30)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3148
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N, K;
	cin >> N >> K;
	vector<int>p(N);
	rep(i, N)cin >> p[i];
	sort(p.begin(), p.end());
	int ans = 0;
	rep(i, K)ans += p[i];
	cout << ans;
}

Measured memory_bytes: 3592
stack1 = []
stack2 = []

total_area = 0
cur_pos = 0

gets.chomp.each_char do |char|
  if char == '\\'
    stack1.push(cur_pos)
  elsif char == '/' && !stack1.empty?
    last_pos = stack1.pop
    total_area += cur_pos - last_pos
    sub_area = cur_pos - last_pos
    while !stack2.empty? && stack2.last[0] > last_pos
      sub_area += stack2.pop[1]
    end
    stack2.push([last_pos, sub_area])
  end

  cur_pos += 1
end

puts total_area
print stack2.size
print ' ' + stack2.map {|arr| arr[1] }.join(' ') unless stack2.empty?
puts

Measured memory_bytes: 9116
#include<iostream>
using namespace std;
int p[1001];
int main()
{
	int i,n,cnt=0;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>p[i];
	for(i=2;i<=n-1;i++)
	{
		if((p[i]>p[i-1]&&p[i]<p[i+1])||(p[i]<p[i-1]&&p[i]>p[i+1]))
			cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 256