akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << (n[0] == '9' || n[1] == '9' ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

int N;
int has[18] = {0};

int main()
{
    cin >> N;
    FO (i, N)
    {
        int a;
        cin >> a;
        ++has[a / 400];
    }
    int cnt = 0;
    FO (i, 8)
        cnt += bool(has[i]);
    int above = has[8] + has[9] + has[10] + has[11] + has[12];
    int mi = max(cnt, 1);
    int ma = cnt + above;
    cout << mi << " " << ma << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
char in[5];
int main(){
	scanf("%s",in);
	std::sort(in,in+4);
	if(in[0]==in[1]&&in[2]==in[3]&&in[1]!=in[2])printf("Yes\n");else printf("No\n");
}

Measured memory_bytes: 128
s=input()
n=len(s)
ans='Yes'
for i in range(n//2):
  if s[i]!=s[n-1-i]:
    ans='No'
for i in range(n//2//2):
  if s[i]!=s[n//2-1-i] or s[n//2+1+i]!=s[n-1-i]:
    ans='No'
print(ans)

Measured memory_bytes: 38516
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N,M;
vector<ll> D;
vector<int> g[100010];

#define BL 1
#define WH -1

int main(){
  cin>>N>>M;
  D.resize(N);
  rep(i,N) cin>>D[i];
  map<pair<int,int>,int> mp;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b) swap(a,b);
    mp[mkp(a,b)]=i;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> ans(M,0);

  vector<pair<ll,int>> v;
  rep(i,N) v.push_back(mkp(D[i],i));
  sort(v.begin(),v.end());

  vector<int> col(N,0);
  vector<int> check(N,0);// 黒頂点に対してのみ　条件を満たす接続を既に実現しているか
  for(int i=0;i<N;i++){
    int now=v[i].second;
    for(auto nex:g[now]){
        if(col[nex]==0) continue;

        int tar=D[nex];
        if(col[nex]==BL){
            if(check[nex]==0&&D[now]>D[nex]){
                cout<<-1<<endl;
                return 0;
            }
            tar=0;
            check[nex]=1;
        }
        if(D[now]==D[nex]&&col[nex]==WH) continue;// 後回し

        int a=now,b=nex;
        if(a>b) swap(a,b);
        ans[mp[mkp(a,b)]]=D[now]-tar;
        col[now]=WH;
    }

    if(col[now]==0) col[now]=BL;
    for(auto nex:g[now]){
        if(col[nex]==WH&&D[nex]==D[now]){
            int a=now,b=nex;
            if(a>b) swap(a,b);
            ans[mp[mkp(a,b)]]=D[now];
            check[now]=1;
        }
    }
  }

  for(int i=0;i<N;i++){
    if(col[i]==BL) cout<<'B';
    else cout<<'W';
  }
  cout<<endl;
  for(int i=0;i<M;i++) cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 24820
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
const int N = 1e5 + 5 ;
const int K = 50 ;
const ll mod =  1e9+7 ;
#define pb push_back
#define ft first 
#define sd second 
int dp[3002][3002];
int lcs(string &s, string &t, int n, int m){
    if(!n || !m) return dp[n][m]=0;
    int &res = dp[n][m];
    if(~res) return res;
    if(s[n-1]==t[m-1]) return res = 1 + lcs(s,t,n-1,m-1);
    return res = max(lcs(s,t,n-1,m), lcs(s,t,n,m-1));
}

void print(string &sol,int n,int m,string &s,string &t)
{
    if(!n || !m) return ;
    if(s[n-1]==t[m-1]) {
        print(sol, n-1,m-1,s,t);
        sol += s[n-1];
    }
    else{
        if(dp[n-1][m] > dp[n][m-1]) print(sol,n-1,m,s,t);
        else print(sol,n,m-1,s,t);
    }
}

int main(){
    string s,t;
    memset(dp,-1,sizeof dp);
    cin >> s >> t;
    int n = s.length(), m = t.length() ;
    lcs(s,t,n,m);
    string sol = "";
    print(sol,n,m,s,t);
    cout << sol << '\n';
    return 0;   
}

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

int main(int argc, char **argv)
{
	char a[50];
	char b[50];
	char c[50];
	char d[50];
	scanf("%s",a);
	for(int i=0;i<19;i++){
		if(i<=4){
			b[i]=a[i];
		}
	    else if(i>=6 && i<=12){
	    	c[i-6]=a[i];
	    }
        else if(i>=14){
        	d[i-14]=a[i];
        }
	}
	printf("%s %s %s\n",b,c,d);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
	int N;
	scanf("%d",&N);//トッピングの種類
	int a,b;
	scanf("%d %d",&a,&b);//a:生地の値段,b:トッピング１つの値段
	int c;//生地のカロリー
	scanf("%d",&c);
	int d[N];//トッピングのカロリー
	int i,j;
	for(i=0;i<N;i++){
		scanf("%d",&d[i]);
	}
	int goukei=c;
	int count=0;
	int max;
	for(i=0;i<N;i++){//生地よりもカロリーコストの高いものを追加
		max=0;
		for(j=0;j<N;j++){
			if(max<d[j]){
				max=d[j];
			}
		}
		for(j=0;j<N;j++){
			if(max==d[j]){
				if( (double)(goukei+d[j])/(a+(count+1)*b)>(double)goukei/(a+count*b) ){
					goukei+=d[j];
					count++;
					d[j]=-1;
				}
			}
		}
	}
	printf( "%d\n",goukei/( a+(b*count) ) );
	return 0;
}

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

int main() {
  vector<queue<char>> vec_input(3);
  rep(i, 3) {
    string str_input;
    cin >> str_input;
    rep(j, str_input.size()) {
      vec_input[i].push(str_input[j]);
    }
  }

  int current = 0;
  while(true) {
    if (vec_input[current].empty()) break;
    char card = vec_input[current].front();
    vec_input[current].pop();
    if (card == 'a') current = 0;
    else if (card == 'b') current = 1;
    else current = 2;
  }

  if (current == 0) cout << 'A' << endl;
  else if (current == 1) cout << 'B' << endl;
  else cout << 'C' << endl;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())

s = np.ones(n)



for i in range(n):
    s[i] = int(input())
    
sum_all = sum(s)

s.sort()

if sum_all%10!=0:
    ans = sum_all
else:
    for i in range(n):
        if s[i]%10 !=0:
            ans = sum_all - s[i]
            break
        elif i==n-1:
            ans =0
            
print(int(ans))


Measured memory_bytes: 12704
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())

data = [list(map(int, input().split())) for _ in range(Q)]
num = list(combinations_with_replacement(range(1, M+1), N))
ans = 0
for item in num:
    score = 0
    for a,b,c,d in data:
        if item[b-1]-item[a-1] == c:
            score += d
    ans = max(ans, score)
print(ans)

Measured memory_bytes: 84980
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int64_t>> s(m, vector<int64_t>(0));
	for (int i = 0; i < m; i++) {
		int64_t k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int64_t z;
			cin >> z;
			s.at(i).push_back(z);
		}
	}
	vector<int64_t> p(m);
	for (int i = 0; i < m; i++) cin >> p.at(i);
	int64_t ans = 0;
	//処理
	for (int bit = 0; bit < (1 << n); bit++) {
		//switch組み合わせbitについて
		bitset<10> bs(bit);
		bool suc = true;
		for (int i = 0; i < m; i++) {
			//電球iについて
			bool i_suc = true;
			//処理
			if (p.at(i)) i_suc = !i_suc;
			for (int j = 0; j < s.at(i).size(); j++) {
				if (bs[s.at(i).at(j)-1])i_suc = !i_suc;
			}
			if (!i_suc)suc = false;
		}
		if (suc)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;

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

int main() {
    int n;
    ll h[100005];
    cin >> n;
    rep(i, n) cin >> h[i];
    vector<ll> dp(n, INF);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

const int N = 3;
vector<ll> A(N);

int main()
{
	FOR(i,0,N){
		scanf("%lld",&A [i]);
	}

	if(accumulate(A.begin(),A.end(),0ll) % 2){
		puts("0");
		return 0;
	}
	FOR(i,1,1000000){
		vector<ll> _A = A;
		bool flag = false;
		FOR(i,0,N){
			int j = (i + 1) % N,k = (j + 1) % N;
			A [i] = (_A [j] + _A [k]) / 2;
			if(A [i] % 2){
				flag = true;
			}
		}
		if(flag){
			printf("%d\n",i);
			return 0;
		}
	}
	puts("-1");

	return 0;
}


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

vector<long long int> w;
vector<long long int> v;
vector<vector<long long int>> dp;

long long int find(int n, int W){
    if(n==0 || W==0){
        dp[n][W] = 0;
        return 0;
    }
    if(dp[n][W]!=-1) return dp[n][W];
    long long int output = 0;

    if(W-w[n-1]>=0){
        output = max(find(n-1,W), v[n-1] + find(n-1,W-w[n-1]));
    }
    else{
        output = find(n-1,W);
    }
    
    dp[n][W] = output;
    return output;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        int n,W;
        cin >> n >> W;
        w = vector<long long int>(n);
        v = vector<long long int>(n);
        for(int i=0 ; i<n ; i++){
            cin >> w[i] >> v[i];
        }

        dp = vector<vector<long long int>>(n+1,vector<long long int> (W+1,-1));
        
        long long int output = find(n,W);
        cout << output << "\n";
    }
    return 0;
}



Measured memory_bytes: 83048
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

const int MAX_N = 100;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int N, A[MAX_N];

void solve() {
  set<int> colors;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int a = A[i] / 400;
    if (a < 8) {
      colors.insert(a);
    } else {
      cnt++;
    }
  }

  int sz = colors.size();
  int mn = max(1, sz);
  int mx = sz + cnt;

  cout << mn << " " << mx << endl;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  solve();

  return 0;
}


Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let a: Vec<i32> = read_vec();
    let s = a[0];
    let w = a[1];

    if s > w {
        println!("safe");
    } else {
        println!("unsafe");
    }
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, K, Q; cin >> N >> K >> Q;
int A[Q], P[N]={0};
for(int i=0; i<Q; i++){ cin >> A[i]; P[A[i]-1]++; }
for(int i=0; i<N; i++){
  if(P[i]+K-Q>0){cout << "Yes" << "\n";}else{cout << "No" << "\n";}
}
}

Measured memory_bytes: 1408
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        long K = sc.nextLong();
        sc.close();

        if(K%2 == 0)
            System.out.println(A-B);
        else
            System.out.println(B-A);
    }
}

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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

signed main() {
  int n;cin>>n;
  vi a(n),sunu(n+1),arai(n+1);
  cin>>a;
  rep(i,n) sunu[i+1] = sunu[i] + a[i];
  int total = sunu[n];
  repi(i,n) arai[i] = total - sunu[i];
  int ans = LINF;
  repi(i,n-1) chmin(ans, abs(sunu[i]-arai[i]));
  cout << ans << endl;
}



Measured memory_bytes: 4992
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string S;
  cin >> S;
  REP(i, 0, S.size()) {
    REP(j, i, S.size()) {
      string s = S.substr(0, i) + S.substr(j, S.size() - i);
      // cout << i << "," << j << ":" << s << endl;
      if (s == "keyence") {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
// ITP1_8_D Ring
import java.io.*;

class Main {

   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         String s = br.readLine();
         String p = br.readLine();
         s = s + s;
         //if (s.equals("") || p.equals(""))
         //   System.exit(0);
         if (s.indexOf(p) != -1)
            System.out.println("Yes");
         else
            System.out.println("No");
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }
}

Measured memory_bytes: 17052
#include <iostream>
#include <algorithm>
using namespace std;
int n; long long a[200009];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	sort(a, a + n + 1);
	int pl = 0;
	long long ret = 0;
	for (int i = 1; i <= n + 1; i++) {
		if (i == n + 1 || a[i - 1] != a[i]) {
			ret += 1LL * (i - pl) * (i - pl - 1) / 2;
			pl = i;
		}
	}
	cout << ret << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
 
int main() {
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); i++){
		if (s[i] >= 'A' && s[i] <= 'Z')
			s[i] = s[i] + 32;
		else if (s[i] >= 'a' && s[i] <= 'z')
			s[i] = s[i] - 32;
	}
	cout << s;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
 
int main() {
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3556
#include<stdio.h>
#include<math.h>
const double eps = 1e-6;
int main()
{
	double x,y;
	double a,b,c,d,e,f;
	while (scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF)
	{
		double m,n,l;
		m=d/a;
		n=f-c*m;
		l=e-b*m;
		y=n/l;
		double z;
		z=c-b*y;
		x=z/a;
		if (fabs(x) < eps) x = fabs(x);
		if (fabs(y) < eps) y = fabs(y);
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
} 

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

int a[100000];

int main()
{
    long int i,h,n,s=0;
    scanf("%ld %ld",&h,&n);
    for(i = 0;i < n;i++)
    {
        scanf("%d",&a[i]);
        s = s+a[i];
    }
    if(s >= h)
        printf("Yes");
    else
        printf("No");
    return 0;
}

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

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<min(s1.length(),s2.length());i++)
    {
        cout<<s1[i]<<s2[i];
    }
    if(s1.length() >s2.length()){
        for(int i=min(s1.length(),s2.length());i<s1.length();i++)
            cout<<s1[i];
    }
    else{
        for(int i=min(s1.length(),s2.length());i<s2.length();i++)
            cout<<s2[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

typedef pair<int,int> pii;
struct Edge{
    int from,to;
    LL cost;
    Edge(int from,int to)
        : from(from),to(to) {};
};
typedef vector<vector<Edge>> Graph;

/*int anc(int now,int s,vector<vector<int>> &par){
    REP(i,18){
        if((s>>i)%2==1) now=par[i][now];
    }
    return now;
}*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,mdep=0;
    cin >> n;
    Graph T(n);
    vector<vector<int>> d(n);
    vector<int>par(n);
    REP(i,n) par[i]=-1;
    vector<int>dep(n);

    REP(i,n-1){
        int a,b;
        cin >> a >>b;
        a--;b--;
        T[a].PB(Edge(a,b));
        T[b].PB(Edge(b,a));
    }
    queue<int> Q;
    Q.push(0);
    par[0]=0;
    d[0].PB(0);
    while(!Q.empty()){
        int nx=Q.front();
        Q.pop();
        for(auto x: T[nx]){
            if(par[x.to]==-1){
                par[x.to]=x.from;
                Q.push(x.to);
                dep[x.to]=dep[x.from]+1;
                mdep=max(mdep,dep[x.to]);
                d[dep[x.to]].PB(x.to);
            }
        }
    }

    vector<int>l(n),u(n),ans(n);
    REP(i,n){
        l[i]=-INF;
        u[i]=INF;
    }
    int k,ev;
    cin >>k;
    REP(i,k){
        int a,b;
        cin >> a>>b;
        l[--a]=b;
        u[a]=b;
        if(i==0) ev=(dep[a]+b)%2;
        else if(ev!=(dep[a]+b)%2){
            cout << "No" <<endl;
            return 0;
        }
    }
    for(int i=mdep; i>0;--i){
        for(auto x : d[i]){
            if(l[x]>u[x]){
                cout << "No" <<endl;
                return 0;
            }
            l[par[x]]=max(l[par[x]],l[x]-1);
            u[par[x]]=min(u[par[x]],u[x]+1);
        }
    }
    if(l[0]>u[0]){
        cout << "No" <<endl;
        return 0;
    }else{
        queue<int> R;
        R.push(0);
        ans[0]=u[0];
        while(!R.empty()){
            int nx=R.front();
            R.pop();
            for(auto x: T[nx]){
                if(x.to!=par[x.from]){
                    ans[x.to]=min(ans[x.from]+1,u[x.to]);
                    R.push(x.to);
                }
            }
        }
    }
    cout <<"Yes"<<endl;
    REP(i,n)cout<< ans[i]<</*' ' <<u[i] <<' '<<l[i] <<*/endl;

    return 0;
}


Measured memory_bytes: 15360
# ABC154 -virtual
# A
if False:
    S,T=input().split()
    A,B=map(int,input().split())
    U=input()
    if U==S:
        A-=1
    else:
        B-=1
    print(A,B)
# B
if False: print('x'*len(input()))
# C
if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    print('YES' if len(A)==len(set(A)) else 'NO')
# D
if True:
    N,K=map(int,input().split())
    P=[int(i) for i in input().split()]
    E=[(p+1)/2 for p in P]
    # print(E)
    ans=tmp=sum(E[0:K])
    l,r=1,K
    while r<len(E):
        # print(l,r)
        tmp=tmp-E[l-1]+E[r]
        ans=max(ans,tmp)
        # print(ans)
        l+=1
        r+=1
    print(ans)
        
# E
# F

Measured memory_bytes: 24836
/// sultanov      

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()

using namespace std;
using namespace __gnu_pbds;
                                                          
template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

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

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    char c[n][m];
    ll dp[n][m];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> c[i][j], dp[i][j] = 0;
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            if (i && c[i - 1][j] == '.')
                dp[i][j] += dp[i - 1][j];
            if (j && c[i][j - 1] == '.')
                dp[i][j] += dp[i][j - 1];
            dp[i][j] %= MOD;
        }
    cout << dp[n - 1][m - 1];
    return false;                                                       
}


Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <math.h>
#include <complex>
using namespace std;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int i = 0;
    while (n > 0) {
        n = n / k;
        i++;
    }
    printf("%d\n", i);
}


Measured memory_bytes: 888
#include <bitset>
#include <cstdint>
#include <iostream>
#include <queue>
#include <utility>

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  queue<pair<int, int>> cur;
  {
    int Ch, Cw;
    cin >> Ch >> Cw;
    cur.push({Ch-1, Cw-1});
  }
  pair<int, int> goal;
  {
    int Dh, Dw;
    cin >> Dh >> Dw;
    goal = {Dh-1, Dw-1};
  }
  vector<string> maze(H);
  for (int h = 0; h < H; ++h) {
    cin >> maze[h];
  }
  int cost = 0;
  bool comp = false;
  vector<bitset<1000>> bs(H);
  queue<pair<int, int>> next;
  while(!cur.empty()) {
    const auto& now = cur.front();
    cur.pop();
    if (now == goal) { comp = true; break; }
    if (bs[now.first].test(now.second)) {
      if (cur.empty() && !next.empty()) {
        ++cost;
        cur.swap(next);
      }
      continue;
    }
    bs[now.first].set(now.second);
    bool up = false; bool right = false; bool down = false; bool left = false;
    if (now.first-1 >= 0) { // up
      if (maze[now.first-1][now.second] != '#') {
        if (!bs[now.first-1].test(now.second)) {
          cur.push({now.first-1, now.second});
        }
      } else {
        up = true;
      }
    }
    if (now.second+1 < W) { // right
      if (maze[now.first][now.second+1] != '#') {
        if (!bs[now.first].test(now.second+1)) {
	      cur.push({now.first, now.second+1});
        }
      } else {
        right = true;
      }
    }
    if (now.first+1 < H) { // down
      if (maze[now.first+1][now.second] != '#') {
        if (!bs[now.first+1][now.second]) {
          cur.push({now.first+1, now.second});
        }
      } else {
        down = true;
      }
    }
    if (now.second-1 >= 0) { // left
      if (maze[now.first][now.second-1] != '#') {
        if (!bs[now.first].test(now.second-1)) {
          cur.push({now.first, now.second-1});
        }
      } else {
        left = true;
      }
    }
    int h_start, h_end, w_start, w_end;
    if (up) { h_start = -2; w_start = -2; w_end = 2; }
    if (right) { w_end = 2; h_start = -2; h_end = 2; }
    if (down) { h_end = 2; w_start = -2; w_end = 2; }
    if (left) { w_start = -2; h_start = -2; h_end = 2; }
    if (up || right || down || left) {
      for (int h = h_start; h <= h_end; ++h) {
        int next_h = now.first + h;
        if (next_h < 0 || next_h >= H) continue;
      	for (int w = w_start; w <= w_end; ++w) {
          int next_w = now.second + w;
          if (next_w < 0 || next_w >= W) continue;
          if (maze[next_h][next_w] != '#' && !bs[next_h].test(next_w)) {
            next.push({next_h, next_w});
          }
        }
      }
    }
    if (cur.empty() && !next.empty()) {
      ++cost;
      cur.swap(next);
    }
  }
  if (!comp) cost = -1;
  cout << cost << endl;
  
  return 0;
}


Measured memory_bytes: 6120
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  VL a(n);
  REP(i, 0, n) cin >> a[i];
  REP(i, 0, n) a[i] = 10 * a[i] + 1;
  VL x(q);
  REP(i, 0, q) cin >> x[i];
  REP(i, 0, q) x[i] *= 10;
  VL acc(n + 1);
  VL acc2(n + 1);
  REP(i, 0, n) acc[i + 1] = acc[i] + a[i] / 10;
  acc2[1] = a[0] / 10;
  REP(i, 1, n) acc2[i + 1] = acc2[i - 1] + a[i] / 10;
  REP(i, 0, q) {
    ll fail = 1e11;
    ll pass = -1;
    while (fail - pass > 1) {
      ll mid = (pass + fail) / 2;
      int idx0 = lower_bound(a.begin(), a.end(), x[i] - mid) - a.begin();
      int idx1 = upper_bound(a.begin(), a.end(), x[i] + mid) - a.begin();
      if (n - idx1 >= idx1 - idx0) pass = mid;
      else fail = mid;
    }
    int idx0 = lower_bound(a.begin(), a.end(), x[i] - pass) - a.begin();
    int idx1 = upper_bound(a.begin(), a.end(), x[i] + pass) - a.begin();
    ll tot = 0;
    assert ((n - idx1) - (idx1 - idx0) >= 0);
    assert ((n - idx1) - (idx1 - idx0) <= 1);
    if (n - idx1 == idx1 - idx0) {
      tot += acc[n] - acc[idx1] + acc2[idx0];
    } else {
      tot += acc[n] - acc[idx1] + (idx0 >= 1 ? acc2[idx0 - 1] : 0);
    }
    cout << tot << "\n";
  }
}


Measured memory_bytes: 4864
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<climits>
#include<cmath>
#include<stdio.h>

using namespace std;
int main(){
    priority_queue<int> se1,se2;
    for(int i=0;i<10;i++){
        int j;
        cin>>j;
        se1.push(j);
    }
    for(int i=0;i<10;i++){
        int j;
        cin>>j;
        se2.push(j);
    }
    int a=0,b=0;
    for(int i=0;i<3;i++){
        a+=se1.top();
        se1.pop();
    }
    for(int i=0;i<3;i++){
        b+=se2.top();
        se2.pop();
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 1220
/*
[abc120] D - Decayed Bridges
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;
const int MAX_M = 1e5;

class UnionFind {
public:
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return false;
        }
        if (data[y] < data[x]) {
            swap(x, y);
        }
        data[x] += data[y];
        data[y] = x;

        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : (data[x] = root(data[x])); }
    int size(int x) { return -data[root(x)]; }
};

int N, M;
int A[MAX_M], B[MAX_M];

void solve() {
    UnionFind uf(N);
    ll ans[MAX_M + 1];
    ans[M] = (N - 1LL) * N;
    for (int i = M - 1; i >= 0; i--) {
        if (uf.same(A[i], B[i])) {
            ans[i] = ans[i + 1];
            continue;
        }
        ll as = uf.size(A[i]), bs = uf.size(B[i]);
        ans[i] = ans[i + 1] + (as - 1) * as + (bs - 1) * bs;
        ans[i] -= (as + bs - 1) * (as + bs);
        uf.unite(A[i], B[i]);
    }

    for (int i = 0; i < M; i++) {
        cout << ans[i + 1] / 2 << endl;
    }
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    solve();

    return 0;
}


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

const int maxn = 1e5 + 10;
int n, k, a[maxn], f[maxn];

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}
	for (int i = 2; i <= n; i++) {
		f[i] = 0x3f3f3f3f;
		for (int j = 1; i > j && j <= k; j++) {
			f[i] = min(f[i], f[i - j] + abs(a[i] - a[i - j]));
		}
	}
	printf("%d", f[n]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    
    string s;
    cin >> s;
    
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 3612
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int mod = 998244353;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n , k;
#define int long long
int fac[500010] , inv[500010];
inline int C(int n , int m) { if(n < 0 || m < 0) return 0; return n >= m ? (LL)fac[n] * inv[m] % mod * inv[n-m] % mod : 0; }

signed main()
{
	n = read(); k = read(); if(k < n) return puts("0") , 0;
	fac[0] = inv[0] = 1;
	for(int i = 1 ; i <= k ; ++i) fac[i] = (LL)fac[i-1] * i % mod;
	inv[1] = 1;
	for(int i = 2 ; i <= k ; ++i) inv[i] = (LL)inv[mod % i] * (mod - mod / i) % mod;
	for(int i = 1 ; i <= k ; ++i) inv[i] = (LL)inv[i] * inv[i-1] % mod;
	int ans = 0;
	for(int R = 1 ; R <= k ; ++R)
	{
		int B = k - R;
		if(R <  B) continue;
		if(R == B) B--;
		(ans += C(R + B , R) - C(R + B , 2 * R - n + 1) + mod) %= mod;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n, k;
    cin >> n >> k;
    string d[20];
    for (int i = 0; i < k; i++)
    {
        cin >> d[i];
    }
    for (int i = n; i <= 100000; i++)
    {
        string tmp = to_string(i);
        int hoge = 0;
        for (int j = 0; j < k; j++)
        {
            if (tmp.find(d[j]) != string::npos)
            {
                hoge = 1;
            }
        }
        if (hoge == 0)
        {
            cout << tmp << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#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 pb push_back
#define all(c) c.begin(),c.end()
#define show(x) cout<<#x<<" "<<x<<endl
using namespace std;
typedef long long ll;
const ll NO=1e15;
ll ex(const string& s,int& it);

ll dig(const string& s,int &it){
	if(s[it]=='0'&&isdigit(s[it+1])) return NO;
	ll x=0;
	while(isdigit(s[it])){
		x=x*2+s[it]-'0';
		it++;
	}
	return x;
}
ll fac(const string& s,int& it){
	if(isdigit(s[it])){
		return dig(s,it);
	}
	if(s[it]=='-'){
		it++;
		ll ret=fac(s,it);
		if(ret==NO) return NO;
		return -ret;
	}
	if(s[it]=='('){
		it++;
		ll ret=ex(s,it);
		if(ret==NO) return NO;
		if(s[it]!=')') return NO;
		it++;
		return ret;
	}
	return NO;
}

ll term(const string& s,int& it){
	ll ret=fac(s,it);
	if(ret==NO) return NO;
	while(s[it]=='*'){
		it++;
		ll x=fac(s,it);
		if(x==NO) return NO;
		ret*=x;
	}
	return ret;
}

ll ex(const string& s,int& it){
	ll ret=term(s,it);
	if(ret==NO) return NO;
	while(s[it]=='+' || s[it]=='-'){
		bool isp=(s[it]=='+');
		it++;
		ll x=term(s,it);
		if(x==NO) return NO;
		if(isp) ret+=x;
		else ret-=x;
	}
	if(s[it]!=')' && s[it]!='$') return NO;
	return ret;
}
bool eq(const string& s){
//	cout<<s<<endl;
	int N=s.size();
	int e=-1;
	rep(i,N){
		if(s[i]=='='){
			if(e==-1) e=i;
			else return 0;
		}
	}
	if(e==-1) return 0;
	int it=0;
	string X=s.substr(0,e)+"$";
	ll x=ex(X,it);
	if(X[it]!='$') x=NO;
	if(x==NO) return 0;
	it=0;
	string Y=s.substr(e+1)+"$";
	ll y=ex(Y,it);
	if(Y[it]!='$') y=NO;
	if(y==NO) return 0;
	return x==y;
}

string S;
string rs="01+-*()=";
vector<char> cs;
int sel[8];
int K;
int ans;
void dfs(int d){
	if(d==K){
		string s=S;
		rep(i,K){
			rep(j,s.size()) if(s[j]==cs[i]) s[j]=rs[sel[i]];
		}
		if(eq(s)) ans++;
		return;
	}
	rep(i,8){
		bool canuse=1;
		rep(j,d) if(sel[j]==i) canuse=0;
		if(!canuse) continue;
		sel[d]=i;
		dfs(d+1);
	}
}
int main(){
	cin>>S;
	rep(i,S.size()) if(isalpha(S[i])){
		cs.pb(S[i]);
	}
	sort(all(cs));
	cs.erase(unique(all(cs)),cs.end());
	K=cs.size();
	if(K>8){
		puts("0");
		return 0;
	}
	dfs(0);
	cout<<ans<<endl;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
#define v(n) vector<n>
using namespace std;
signed main(){
    int n,k; cin>>n>>k;
    v(P) ab(n);
    rep(i,n) cin>>ab.at(i).first>>ab.at(i).second;
    sort(ab.begin(),ab.end());
    int ans=0,sum=0;
    rep(i,n){
        sum+=ab.at(i).second;
        if(sum>=k){
            ans=ab.at(i).first;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<queue>
using namespace std;
int N,q;
queue<pair<string,int> >Q;
int main()
{
	int total_time=0;
	cin>>N>>q;
	string name;
	int t;
	for(int i=0;i<N;i++){
		cin>>name>>t;
		Q.push(make_pair(name,t));
	}
	pair<string,int>temp;
	while(!Q.empty()){
	 temp=Q.front();Q.pop();
	 if(temp.second<=q){
		total_time+=temp.second;
		cout<<temp.first<<" "<<total_time<<endl;
	 }
	 else{
		total_time+=q;
		temp.second-=q;
		Q.push(temp);
	 }
	}
	return 0;

}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  string s;
  while (cin >> s) {
    vector<int> v;
    each (c, s) v.push_back(c - '0');
    int mn = 1 << 29;
    for (int i = 0; i + 2 < v.size(); ++i) {
      setmin(mn, abs(753 - (v[i] * 100 + v[i + 1] * 10 + v[i + 2])));
    }
    cout << mn << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  int v, n, c=0;
  int sumv=0, aven=0;
  while (scanf("%d,%d", &v, &n) == 2) {
    ++c;
    sumv += v*n;
    aven += n;
  }
  aven = (int)round((double)aven/c);
  printf("%d\n%d\n", sumv, aven);

  return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n,m,q;
 cin>>n>>m>>q;
 vector<ll> a(q),b(q),c(q),d(q);
 for(ll i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
 vector<ll> r(n+m-1,0);
 for(ll i=0;i<n;i++) r[i]=1;
 sort(r.begin(),r.end() );
 ll res = 0;
 do{
  vector<ll> A(n);
  ll cnt = 1;
  ll id = 0;
  for(ll i=0;i<r.size();i++){
   if( r[i] == 1 ){
    A[id++] = cnt;
   }else{
    cnt++;
   }
  }
  ll sum = 0;
  
  for(ll i=0;i<q;i++){
   if( A[b[i]-1]-A[a[i]-1] == c[i] ) sum += d[i];
  }

  /*cout<<sum<<endl;
  for(auto i:A)cout<<i<<' ';
  cout<<endl;
  */
  res = max( res , sum );

 }while(next_permutation(r.begin(),r.end()) );

 cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3612
/* ac */
/* gcc ac.c -o ac */

#include <stdio.h>
#include <string.h>


int main()
{
char s[201];
char mae[101], ato[101];
int len;
int half;

scanf("%s", s);
len = strlen(s);

do{
len = len -2;
strncpy(s, s, len);
s[len]='\0';

half = len/2;

strncpy(mae, s, half);
ato[half]='\0';

strncpy(ato, s+half, half);
mae[half]='\0';

}
while(strcmp(mae, ato)!= 0);

printf("%d", len);


return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
inputs = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
for i in range(2 ** N):
    bit = format(i, 'b').zfill(N)
    flag = True
    for j in range(M):
        count = 0
        item = inputs[j][1:]
        for number in item:
            if bit[number-1] == '1':
                count += 1
        if count % 2 != P[j]:
            flag = False
    if flag:
        ans += 1

print(ans)


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

using namespace std;

using ll = long long;

bool check(int a, int c, const string& s) {
    int cur = a;
    while (cur < c) {
        if (s[cur + 1] == '.') {
            cur++;
            continue;
        }

        if (cur + 2 >= s.size()) return false;

        if (s[cur + 2] == '.') {
            cur += 2;
            continue;
        }

        return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--; b--; c--; d--;
    string s;
    cin >> s;

    bool ans = false;
    if (c < b || c < d) {
        ans = (check(a, c, s) && check(b, d, s));
    } else {
        ans = check(b, d, s);
        bool f = false;
        if (ans) {
            int cur = b;
            while (cur < d) {
                if (cur - 1 >= 0 && s[cur - 1] == '.' && cur + 1 < s.size() && s[cur + 1] == '.') {
                    s[cur] = '#';
                    f = true;
                    break;
                }

                if (s[cur + 1] == '.') {
                    cur++;
                    continue;
                }

                if (cur + 2 >= s.size()) break;

                if (s[cur + 2] == '.') {
                    cur += 2;
                    continue;
                }

                break;
            }

            if (cur == d && s[cur - 1] == '.' && s[cur + 1] == '.') {
                s[cur] = '#';
                f = true;
            }

            if (!f) ans = false;
            else ans = check(a, c, s);
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll n,x;cin>>n>>x;
	ll d[n+1],l[n+1];
	d[0]=0;
	for(ll i=0;i<n;i++)cin>>l[i];
	for(ll i=1;i<=n;i++)
	{
		d[i]=d[i-1]+l[i-1];
	}
	ll cnt=0;
	for(ll i=0;i<n+1;i++)
	{
		if(d[i]<=x)cnt++;
	}
	cout<<cnt;
}



Measured memory_bytes: 256
N=int(input())
H=list(map(int, input().split()))

can_move = 0
move = 0

for i in range(N):
    if i == N-1:
        break
    elif H[i] >= H[i+1]:
        move += 1
        if can_move <= move:
            can_move = move
    else:
        move = 0

print(can_move)

Measured memory_bytes: 14252
fun main(args: Array<String>) {
    val A = readLine()!!.toInt()
    val B = readLine()!!.toInt()
    val C = readLine()!!.toInt()
    val X = readLine()!!.toInt()
    var cnt = 0
    for(a in 0..A) {
        for (b in 0..B) {
            for (c in 0..C) {
                if (X==500*a+100*b+50*c) {
                    cnt+=1
                }
            }
        }
    }
    println(cnt)
}

Measured memory_bytes: 29784
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

const long MOD = 1e9 + 7;
int main()
{
  long n, m;
  cin >> n ;
  vector<long> v(5, 0);

  for (int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    if (s[0] == 'M')v[0]++;
    if (s[0] == 'A')v[1]++;
    if (s[0] == 'R')v[2]++;
    if (s[0] == 'C')v[3]++;
    if (s[0] == 'H')v[4]++;
  }

  long count=0;

  for (int i = 0; i < 3; ++i){
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        count+= v[i]*v[j]*v[k];
        // count %= MOD;
      }
    }
  }




  cout << count << endl;

  return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string s;cin >> s;
   for(int i = 0;i < s.length();i++) {
       if(i%2==0) {
           cout << s[i];
       } else {

       }
   }
   cout << endl;
}

Measured memory_bytes: 592