akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;
Vi s;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    a.resize(n);
    s.resize(n+1,0);
    rep(i,n){
        cin>>a[i];
        s[i+1] += a[i]+s[i];
    }
    ll tmp = 0;
    ll ans = INF;
    ll sum = 0;
    rep(i,n){
        sum += a[i];
        if(i%2==0){
            if(sum >= 0){
                tmp += sum + 1;
                sum = -1;
            }
        }else{
            if(sum <= 0){
                tmp += abs(sum) + 1;
                sum = 1;
            }
        }
    }
    chmin(ans,tmp);
    tmp = 0;
    sum = 0;
    rep(i,n){
        sum += a[i];
        if(i%2==1){
            if(sum >= 0){
                tmp += sum + 1;
                sum = -1;
            }
        }else{
            if(sum <= 0){
                tmp += abs(sum) + 1;
                sum = 1;
            }
        }
    }
    chmin(ans,tmp);
    print(ans);
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define all(m) m.begin(), m.end()
#define uid uniform_int_distribution
#define init(m, x) memset(m, x, sizeof(m));
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int G = 5000;
ll a,k;
ll c[G], p[G], cyc[G], sz = 0;

ll ga(ll st){
    sz = 0;
    ll ps = st, o = 0;
    for(ll q=0; q==0 || ps!=st; q++){
        ps = p[ps];
        cyc[sz++] = c[ps];
    }
    ll full = accumulate(cyc, cyc+sz, 0LL), tk = k;
    ll cnt = tk/sz, ost = tk%sz;
    if(cnt) cnt--, ost += sz;
    ll fl = 0;
    if(full>0 && cnt) o += full*cnt, fl = 1;
    ll mxo = LONG_LONG_MIN, prs = 0;
    for(int q=0; q<ost; q++){
        prs += cyc[q-(q<sz ? 0 : sz)];
        mxo = max(mxo, prs);
    }
    if(fl) mxo = max(mxo, 0LL);
    return mxo+o;
}

int main() {
    cin>>a>>k;
    for(int q=0; q<a; q++) cin>>p[q], p[q]--;
    for(int q=0; q<a; q++) cin>>c[q];
    ll o = LONG_LONG_MIN;
    for(int q=0; q<a; q++){
        //cout<<q+1<<": "<<ga(q)<<endl;
        o = max(ga(q), o);
    }
    cout<<o;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int sum = 0;
  for(int i = 1; i < N+1; i++){
    int a = i/10000 + (i%10000)/1000 + (i%1000)/100 + (i%100)/10 + (i%10);
    if(a > A-1 && a < B+1) {
      sum += i;
    }//if
  }//for
  cout << sum << endl;
}//main



Measured memory_bytes: 256
count = int(input())
S = [1,2,3,4,5,6,7,8,9,10,11,12,13]
C = [1,2,3,4,5,6,7,8,9,10,11,12,13]
H = [1,2,3,4,5,6,7,8,9,10,11,12,13]
D = [1,2,3,4,5,6,7,8,9,10,11,12,13]

for i in range(count):
	suit, num = input().split(" ")
	if suit == "S":
		S.remove(int(num))
	elif suit == "C":
		C.remove(int(num))
	elif suit == "H":
		H.remove(int(num))
	elif suit == "D":
		D.remove(int(num))

if len(S) != 0:
	for j in range(len(S)):
		print("S " + str(S[j]))
if len(H) != 0:
	for j in range(len(H)):
		print("H " + str(H[j]))
if len(C) != 0:
	for j in range(len(C)):
		print("C " + str(C[j]))
if len(D) != 0:
	for j in range(len(D)):
		print("D " + str(D[j]))

Measured memory_bytes: 7792
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  
  string s;
  cin >> s;
  
  for (int i = 1; i <= n - 1; i++) {
    if (s[i-1] == '#' && s[i] == '#') {
      if ((a <= i && i <= c) || (b <= i && i <= d)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  if (c < d) {
    cout << "Yes" << endl;
    return 0;
  }
  
  for (int i = b - 1; i <= d - 1 && i <= n - 2; i++) {
    if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') {
      cout << "Yes" << endl;
      return 0;
    }
  }
    
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

bool bm_augment(const vector<vector<int> >& g, int u, vector<int>& match_to, vector<int>& visited) // {{{
{
  if (u < 0) {
    return true;
  }

  for (vector<int>::const_iterator it(g[u].begin()); it != g[u].end(); ++it) {
    if (!visited[*it]) {
      visited[*it] = true;
      if (bm_augment(g, match_to[*it], match_to, visited)) {
        match_to[u] = *it;
        match_to[*it] = u;
        return true;
      }
    }
  }
  return false;
} // }}}

int bipartite_matching(const vector<vector<int> >& g)  // {{{
{
  const int N = g.size();
  vector<int> match_to(N, -1);
  int match = 0;
  for (int u = 0; u < N; u++) {
    vector<int> visited(N, false);
    if (bm_augment(g, u, match_to, visited)) {
      match++;
    }
  }
  return match;
} // }}}

int main()
{
  int N, M, L;
  while (scanf("%d %d %d", &N, &M, &L) != EOF && N != 0) {
    static const int INF = 10000000;
    vector<vector<int> > dist(N, vector<int>(N, INF));
    for (int i = 0; i < N; i++) {
      dist[i][i] = 0;
    }
    for (int i = 0; i < M; i++) {
      int u, v, d;
      scanf("%d %d %d", &u, &v, &d);
      dist[u][v] = min(dist[u][v], d);
      dist[v][u] = min(dist[v][u], d);
    }
    vector<pair<int,int> > pt(L);
    for (int i = 0; i < L; i++) {
      scanf("%d %d", &pt[i].first, &pt[i].second);
    }

    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }

    vector<vector<int> > g(2*L);
    for (int i = 0; i < L; i++) {
      for (int j = 0; j < L; j++) {
        if (i == j) {
          continue;
        }
        const int u = pt[i].first;
        const int v = pt[j].first;
        if (dist[u][v] <= pt[j].second - pt[i].second) {
          g[i].push_back(j+L);
        }
      }
    }
    const int r = bipartite_matching(g);
    printf("%d\n", L-r);
  }
  return 0;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;

  int c = 0;
  for ( int i = 1; i <= N; i += 2 ) {
    c++;
  }

  if ( c >= K ) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
const int mod = 1e9 + 7;
long long fact(int n) {
  if (n <= 1) { return 1; }
  else {
	  return n * fact(n - 1) % mod;
	}
}

long long mypow(int n, int k) {
  if (k == 0) {
	  return 1;
	}
  if (k == 1) {
	  return n;
	}
  if (k % 2 == 1) {
	  return n * mypow(n, k - 1) % mod;
	}
  else {
	  long long a = mypow(n, k / 2);
	  return a * a % mod;
	}
}

long long myinv(int n) {
  return mypow(n, mod - 2);
}

int main() {
  int X, Y;
  cin >> X >> Y;
  if ((X + Y) % 3 != 0) {
	  cout << 0 << endl;
	  return 0;
	}
  int steps = (X + Y) / 3;
  if (abs(X - Y) > steps || (steps + X - Y) % 2 == 1) {
	  cout << 0 << endl;
	  return 0;
	}
  int a         = steps;
  int b         = (steps - X + Y) / 2;
  long long ans = fact(a);
  ans = ans * myinv(fact(b)) % mod;
  ans = ans * myinv(fact(a - b)) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10624
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

struct ryouri{
	int time;
	int machi;
	int r_time;
};

int main(){
	struct ryouri r[5],temp;
	int sum = 0;
	
	for(int i=0;i<5;i++){
		cin >> r[i].time;
		syc(r[i].time,1,123);
	}
	
	for(int i=0;i<5;i++){
		r[i].r_time=((r[i].time+9)/10)*10;
		r[i].machi=r[i].r_time-r[i].time;
	}
	
	for(int i=0;i<4;i++){
		for(int j=i+1;j<5;j++){
			if(r[i].machi>r[j].machi){
				temp=r[i];
				r[i]=r[j];
				r[j]=temp;
			}
		}
	}
	
	r[4].r_time=r[4].time;
	
	for(int i=0;i<5;i++){
		sum += r[i].r_time;
	}
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N-1)]

for i in range(N-1):
    t = 0
    for c,s,f in src[i:]:
        t = max(t,s)
        t = -(-t//f)*f
        t += c
    print(t)
print(0)

Measured memory_bytes: 3188
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    left = min(a[i], b[i])
    ans += left
    a[i] -= left
    b[i] -= left

    right = min(a[i+1], b[i])
    ans += right
    a[i+1] -= right
    b[i] -= right


print(ans)


Measured memory_bytes: 82148
import heapq as hp
n = int(input())
if n%2 ==0:
    m = n//2 + 1
else:
    m = (n+1) //2
a,b = [],[]
for i in range(0,n):
    c = list(map(int, input().split()))
    a.append(c[0])
    b.append(c[1])
la = hp.nlargest(m,a)
lb = hp.nlargest(m,b)
if n%2 == 0:
    c = la[-1] + la[-2] 
    d = lb[-1] + lb[-2] 
    print(d-c+1)
else:
    print(lb[-1]-la[-1]+1)

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

int main(){

  string s;
  cin >> s;

  bool flg = true;
  for(int i=0;i<s.size();i++){
    if(s[0] < s[i]) flg = false;
  }

  if(flg){
    for(int i=0;i<s.size();i++) s[i] = s[0];
  }
  if(!flg){
    char c = ++s[0];
    for(int i=0;i<s.size();i++) s[i] = c;
  }

  cout << s << endl;

}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
using namespace std;
int n,ans;
int t[10],a[5];
void dfs(int step,int x,int y,int z,int cnt)
{
	if(step==n){
		if(!x||!y||!z)
			return ;
		ans=min(ans,cnt+abs(x-a[1])+abs(y-a[2])+abs(z-a[3]));
		return ;
	}
	dfs(step+1,x,y,z,cnt);
	if(!x)
		dfs(step+1,x+t[step+1],y,z,cnt);
	if(!y)
		dfs(step+1,x,y+t[step+1],z,cnt);
	if(!z)
		dfs(step+1,x,y,z+t[step+1],cnt);
	if(abs(x+t[step+1]-a[1])<=abs(x-a[1]))
		dfs(step+1,x+t[step+1],y,z,cnt+10);
	if(abs(y+t[step+1]-a[2])<=abs(y-a[2]))
		dfs(step+1,x,y+t[step+1],z,cnt+10);
	if(abs(z+t[step+1]-a[3])<=abs(z-a[3]))
		dfs(step+1,x,y,z+t[step+1],cnt+10);
}
int main()
{
	scanf("%d%d%d%d",&n,&a[1],&a[2],&a[3]);
	for(int i=1;i<=n;i++)
		scanf("%d",&t[i]);
	ans=0x3f3f3f3f;
	dfs(0,0,0,0,0);
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

const int NMAX = 1e5;

int v[NMAX+2], N, M;
long long ans = 0;

int main()
{
    cin >> N >> M;
    if( N >= M ) {
        cout << "0\n";
        return 0;
    }
    for( int i = 1;  i <= M;  ++i ) cin >> v[i];
    sort( v + 1, v + M + 1 );
    vector<int> difs;
    for( int i =  2;  i <= M;  ++i ) difs.push_back(v[i] - v[i - 1]);
    sort(difs.begin(), difs.end());
    for( int i = 1;  i <= M - N;  ++i )
        ans += difs[i - 1];
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  int bit = 0;
  int k;
  cin >> k;
  rep(i, k) {
    int b;
    cin >> b;
    bit |= (1<<b);
  }
  vint ans;
  for(int sub = bit; ; sub = (sub-1)&bit) {
    ans.push_back(sub);
    if(!sub) break;
  }
  sort(all(ans));
  rep(i, ans.size()) {
    cout << ans[i] << ":";
    rep(j, n) if((ans[i]>>j)&1) cout << " " << j;
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 4724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N,K; cin >> N >> K;
    int ans = 0;
    while(N){
        ans++;
        N /= K;
    }
    cout << ans << endl;

}


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

void solve()
{
	int n;
	
	cin >> n;
	
	int a;
	cin >> a;
	int min = a;
	int count = 1;
	
	for(int i = 2; i <= n; i++)
	{
		cin >> a;
		
		if(a <= min)
		{
			count++;
			min = a;
		}
	}
	
	cout << count;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("ABC")) {
            System.out.println("ARC");
        } else if (s.equals("ARC")) {
            System.out.println("ABC");
        }
    }
}

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

const int N=5e5 +10;
vector<int>ql[N], qid[N], tree(N);
int n, q;

void update(int id, int val) {
    while(id<=n) {
        tree[id]+=val;
        id+=(id&-id);
    }
}
int query(int id) {
    int ans=0;
    while(id>0) {
        ans+=tree[id];
        id-=(id&-id);
    }
    return ans;
}
int get(int l, int r) {
    return query(r)-query(l-1);
}

int main() 
{ 
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n; cin>>q;
	int l,r,x; int c[n+1], a[n+1]={0}, ans[q];
	for(int i=1; i<=n; i++) {
	    cin>>c[i];
	}
	
	for(int i=0; i<q; i++) {
        cin>>l>>r;
        ql[r].push_back(l);
        qid[r].push_back(i);
    }
    
    for(int i=1; i<=n; i++) {
        if(a[c[i]] > 0) update(a[c[i]], -1);
        update(i, 1);
        a[c[i]] = i;
        
        for(int j=0; j<ql[i].size(); j++) {
            ans[qid[i][j]] = get(ql[i][j], i);
        }
    }
    
    for(int i=0; i<q; i++)  cout<<ans[i]<<"\n";
	return 0; 
} 


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


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

  cout << ((a%3==0 || b%3==0 || (a+b)%3==0) ? "Possible" : "Impossible") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, T; cin >> N >> T;
    vector<int> a(N);
    vector<int> b(N);
    for(int i=0; i<N; i++) cin >> a[i];

    int minv = a[0];
    for(int i=0; i<N; i++){
        b[i] = a[i] - minv;
        minv = min(minv, a[i]);
    }

    sort(b.begin(), b.end(), greater<int>());
    int cnt = 1;
    for(int i=1; i<N && b[i] == b[0]; i++) cnt++;

    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;

int main() {
	int K;
	int N;
	int A;
	

	cin >> K >> N;
	vector<int> a(N);
	vector<int> a2(N);
	int t = -300;
	int t2 = 0;
	int c = 0;

	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}
	
	for (int i = 0; i < N; i++) {
		if (i < N - 1) {
			t2 = a.at(i+1) - a.at(i);
		}
		else {
			t2 = K - a.at(i) + a.at(0);
		
		}

		if (t < t2) {
				t = t2;
				c = i;
		}
		a2.at(i) = t2;
		
	}

	
	int x = 0;
	for (int i = 0; i < N; i++) {
		if (i != c) {
			x = x + a2.at(i);
			
		}
	}
	cout << x << endl;
	
	return 0;


}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    string a;
    cin>>a;
    if(a[0]==a[1]&&a[1]==a[2])cout<<"No";
    else cout<<"Yes";
    return 0;
}

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

#define ll long long
#define ld long long

int main() {
    int N; cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    int i = 0, ans = 1;
    for (int j = 1; j < N; j++) {
        if (S.at(i) != S.at(j)) {
            ans++;
            i = j;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9556
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


int n, ans;
int main() {
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	sort(all(v));

	for (ll mid = n - 1; mid >= 0; --mid) {
		for (ll low = mid - 1; low >= 0; --low) {
			auto itr = lower_bound(all(v), v[mid] + v[low]);
			ans += (n - 1 - mid) - distance(itr, v.end());
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(b.fi==a.fi)return (b.se>=a.se);
    return (b.fi>a.fi);
}
signed main()
{
    fastio;
    R(n);
    string s[n];
    map<string,int>m;
    fr(i,0,n)
    {
        cin>>s[i];
        m[s[i]]+=1;
    }
    int mn=0;
    vector<string>ans;
    for(auto it=m.begin();it!=m.end();it++)
    {
        if(it->se>mn)
        {
            mn=it->se;
            ans.clear();
            ans.pb(it->fi);
        }
        else
            if(it->se==mn)
        {
            ans.pb(it->fi);
        }
    }
    fr(i,0,ans.size())
    {
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 27120
import java.util.Scanner;
import java.util.Arrays;

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

		while(true){
			int m = scanner.nextInt();
			int f = scanner.nextInt();
			int r = scanner.nextInt();

			if(m == -1 && f == -1 && r == -1){
				break;
			}

			if(m == -1 || f == -1){
				System.out.println("F");
			}else if(m + f >= 80){
				System.out.println("A");
			}else if(m + f >= 65){
				System.out.println("B");
			}else if(m + f >= 50){
				System.out.println("C");
			}else if(r >= 50){
				System.out.println("C");
			}else if(m + f >= 30){
				System.out.println("D");
			}else{
				System.out.println("F");
			}
		}
	}

}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N, K;
	cin >> N >> K;
	
	long long ans = 1;
	for_(i,0,N-1) ans += (ans / (K - 1) + (ans % (K - 1) ? 1 : 0));
	cout << ans - 1 << endl;
}

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

int H, W;

void update(vector<string>& S, int x, int y) {
    if (S[x][y] == '#') {
        return;
    }
    int ans = 0;
    for (int i = -1; i <= 1; ++i) {
        for (int j = -1; j <= 1; ++j) {
            int nx = i + x;
            int ny = j + y;
            if (nx >= 0 && nx < H && ny >= 0 && ny < W && S[nx][ny] == '#') {
                ++ans;
            }
        }
    }
    S[x][y] = char(ans + '0');
}

int main() {
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; ++i) {
        cin >> S[i];
    }
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            update(S, i, j);
        }
    }
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << S[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		n = sc.nextInt();
		a = new int[n][3];
		score = new int[n];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < n; j++) {
				boolean f = true;
				for (int k = 0; k < n; k++) {
					if (j != k && a[j][i] == a[k][i]) {
						f = false;
					}
				}
				if (f) {
					score[j] += a[j][i];
				}
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.println(score[i]);
		}
	}
}

Measured memory_bytes: 20824
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p,num[1000000];
  num[0]=0;
  for(int i=1;i<1000000;++i) num[i]=1;
  for(int i=2;i*i<1000000;++i)
    if(num[i-1])
      for(int j=2;i*j<1000000;++j) num[i*j-1]=0;
  while(cin>>n>>p&&n!=-1&&p!=-1){
    vector<int>add;
    int cnt=0,data[100];
    ++n;
    while(cnt!=p){
      if(num[n-1]){
	data[cnt]=n;
	++cnt;
      }
      ++n;
    }
    for(int i=0;i<p;++i)
      for(int j=i;j<p;++j)
	add.push_back(data[i]+data[j]);
    sort(add.begin(),add.end());
    cout<<add[p-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 7016
import java.awt.geom.*;
import java.io.*;
import java.util.*;


public class Main {
	//0128 start
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			long [] llist = new long[n];
			int [] bitlist = new int[n];
			for(int i = 0; i < n; i++){
				int m = sc.nextInt();
				llist[i] = sc.nextLong();
				int nowbit = 0;
				for(int j = 0; j < m; j++){
					int s = sc.nextInt() - 6;
					int t = sc.nextInt() - 6;
					for(int k = s; k < t; k++){
						nowbit= (nowbit | (1 << k));
					}
				}
				bitlist[i] = nowbit;
			}
			int len = (1 << (22 - 6));
			long [] dp = new long[len];
			long max = 0;
			for(int i = 0; i < n; i++){
				for(int j = 0; j < len; j++){
					if((bitlist[i] & j) == 0){
						int next = bitlist[i] | j;
						long value = dp[j] + llist[i];
						dp[next] = Math.max(dp[next], value);
						max = Math.max(max, value);
					}
				}
			}
			
			System.out.println(max);
		}
	}
	
	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 13000
#include<stdio.h>
#include<string.h>
int main(void)
{
	char a[10000];
	int j,len;
	int cnta=0,cntb=0,cntc=0,cntd=0;
	int max=0;
	scanf("%s",a);
	len=strlen(a);
	max=10000;
	for(j=0;j<len;j++){
		if(a[j]=='K'){
			cnta++;
		}
		if(a[j]=='U'){
			cntb++;
		}
		if(a[j]=='P'){
			cntc++;
		}
		if(a[j]=='C'){
			cntd++;
		}
	}
	if(cnta<max){
		max=cnta;
	}
	if(cntb<max){
		max=cntb;
	}
	if(cntc<max){
		max=cntc;
	}
	if(cntd<max){
		max=cntd;
	}
	printf("%d\n",max);
	return 0;
}

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

using namespace std;

unsigned long long fact(unsigned long long x){
    if (x==0){
        return 1;
    }else return ((x%1000000007)*fact(x-1)%1000000007)%1000000007;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    unsigned long long n;cin>>n;
    cout<<fact(n)<<endl;
    return 0;
}

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

int main(void){
    int N;cin>>N;
    set<string> color_selection;
    int rainbow = 0;
    for (int i = 0; i < N; i++){
        int score;cin>>score;
        if (1 <= score && score < 400) color_selection.insert("gray");
        else if (400 <= score && score < 800) color_selection.insert("brown");
        else if (800 <= score && score < 1200) color_selection.insert("green");
        else if (1200 <= score && score < 1600) color_selection.insert("skyblue");
        else if (1600 <= score && score < 2000) color_selection.insert("blue");
        else if (2000 <= score && score < 2400) color_selection.insert("yellow");
        else if (2400 <= score && score < 2800) color_selection.insert("orange");
        else if (2800 <= score && score < 3200) color_selection.insert("red");
        else rainbow++;
    }
    cout << max((int)color_selection.size(), 1) << " " <<  color_selection.size() + rainbow << endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = ~~arg[0].split(" ")[0];
    const B = ~~arg[0].split(" ")[1];
    const C = ~~arg[0].split(" ")[2];
    
    const min = Math.min(A, B);
    const max = Math.max(A, B);
    
    console.log(C <= max && min <= C ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x, t; cin >> x >> t;
  cout << max(0LL, x-t) << endk;
  return 0;
}


Measured memory_bytes: 3580
import bisect

n = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

ans = 0
for b in B:
  a_ind = bisect.bisect_left(A, b)
  c_ind = bisect.bisect_right(C, b)
  ans += a_ind*(n-c_ind)
  
print(ans)

Measured memory_bytes: 29548
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ab = [LI() for _ in range(n-1)]
m = I()
uv = [LI() for _ in range(m)]

edge = [[] for i in range(n)]
lst = [[None]*n for i in range(n)]
cnt = 0
for i,[a,b] in enumerate(ab):
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    lst[a-1][b-1] = i
    lst[b-1][a-1] = i

L = []
for u,v in uv:
    stack = deque()
    stack.append(u-1)
    flg = [True]*n
    par = [None]*n
    par[u-1] = -1
    while stack:
        x = stack.pop()
        if x == v-1:
            break
        flg[x] = False
        for y in edge[x]:
            if flg[y]:
                par[y] = x
                stack.append(y)
    tmp = v-1
    tmp2 = []
    while 1:
        if par[tmp] == -1:
            break
        tmp2.append(lst[tmp][par[tmp]])
        tmp = par[tmp]
    tmp2.sort()
    L.append(tmp2)

e = [0]*m
for i in range(m):
    x = 0
    for j in L[i]:
        x |= 1<<j
    e[i] = x

ans = 0
for i in range(1<<m):
    black = 0
    cnt = 0
    for j in range(m):
        if (i>>j & 1):
            cnt += 1
            black |= e[j]
    cnt2 = 0
    for j in range(n-1):
        if (black>>j & 1):
            cnt2 += 1
    if cnt % 2:
        ans -= 1<<(n-1-cnt2)
    else:
        ans += 1<<(n-1-cnt2)
print(ans)



Measured memory_bytes: 43676
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  using namespace chrono_literals;
  chrono::high_resolution_clock clock;
  auto be = clock.now();
  int D;
  cin >> D;
  array<int, 26> c;
  for (auto& e : c) cin >> e;
  vector<array<int, 26>> d(D);
  for (auto& r : d)
    for (auto& e : r) cin >> e;
  auto eval = [&](vector<int> t) {
    int S = 0;
    array<int, 26> last = {};
    for (int i = 0; i < D; ++i) {
      S += d[i][t[i]];
      last[t[i]] = i + 1;
      for (int j = 0; j < 26; ++j) S -= c[j] * (i + 1 - last[j]);
    }
    return S;
  };

  mt19937 mt(random_device{}());
  uniform_int_distribution<int> dist_type(0, 25), dist_day(0, D - 1);
  vector<int> t(D);
  for (int i = 0; i < D; ++i)
    t[i] = distance(cbegin(d[i]), max_element(cbegin(d[i]), cend(d[i]))) + 1;
  int S = eval(t);
  int cnt = 0;
  while (clock.now() - be < 1900ms) {
    int day = dist_day(mt);
    int prv = t[day];
    t[day] = dist_type(mt);
    int score = eval(t);
    if (score > S) {
      S = score;
      continue;
    }
    t[day] = prv;
    if (++cnt > 10000) {
      cnt = 0;
      generate(begin(t), end(t), [&]() { return dist_type(mt); });
    }
  }
  for (const auto& e : t) cout << (e + 1) << '\n';
}


Measured memory_bytes: 3660
#include<cstdio>

int main(){
    int I,h,m,s;
    scanf("%d", &I);
    h=I/3600;
    m=(I-h*3600)/60;
    s=I-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2764
from collections import deque
n, m = map(int, input().split())
INF = 1000000
to_room = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    to_room[a].append(b)
    to_room[b].append(a)
dp = [INF] * (n + 1)
dp[1] = 0
seen_room = deque()
seen_room.append(1)
ans = [0] * (n + 1)
while seen_room:
    v = seen_room.popleft()
    for next in to_room[v]:
        if dp[next] <= dp[v] + 1:
            continue
        dp[next] = dp[v] + 1
        ans[next] = v
        seen_room.append(next)
#     print(seen_room)
# print(to_room)
# print(dp)
if 0 in ans[2:]:
    print("No")
else:
    print("Yes")
    for a in ans[2:]:
        print(a)



Measured memory_bytes: 98772
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
  string s;
  cin >> s;
  if(s[0] != s[1] && s[1] != s[2] && s[2] !=s[0]){
     cout <<"Yes\n";
  }else{
     cout <<"No\n";
  }
  return 0;
}

Measured memory_bytes: 3600
from collections import Counter
def main():
    N = int(input())
    cards = list(map(int, input().split()))

    counter = Counter(cards)
    # print(counter)

    A = list(map(lambda x: x%2, counter.values()))

    pure= sum(1 for x in A if x == 1)
    needpairs = sum(1 for x in A if x == 0)
    # print(pure)
    # print(needpairs)

    answer = pure + needpairs - (1 if needpairs%2==1 else 0)
    print(answer)

def intifp(x):# {{{
    try:
        return int(x)
    except:
        return x# }}}

def strifp(x):# {{{
    try:
        return str(x)
    except:
        return x# }}}

if __name__ == "__main__":
    main()


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

ll solve(ll x,ll i){
    ll rec=1;
    rep(j,i){
        rec=rec*x%MOD;
    }
    return rec;
}

int main()
{
    ll n;
    cin>>n;
    ll ans=solve(10,n)-solve(9,n)-solve(9,n)+solve(8,n);
    ans%=MOD;
    ans=(ans+MOD)%MOD;
    cout<<ans<<endl;
}

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define urng(i, a, b) for(int i = int(b) - 1; i >= int(a); i--)
#define urep(i, b) urng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, a, b, ans = 0, x;
  //string s;
  cin >> n >> x;
  //vector<int> v(n), c(n);
  if(500 * n >= x) cout << "Yes\n";
  else cout << "No\n";
  //for(int i = 0; i < n; i++){}
}

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

int main() {
  int n, d, x;
  int a, total;

  cin >> n;
  cin >> d >> x;

  total = x;
  for (int i = 0; i < n; i++) {
    cin >> a;
    total += ((d - 1) / a) + 1;
  }

  cout << total << endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
vector<vector<pi > > G;
vector<bool > seen;
vector<ll > cost;

void dfs(ll idx, ll from = -1){
    seen[idx] = true;

    for(ll i = 0; i < G[idx].size(); i++){
        //次の行き先は？
        ll to = G[idx][i].first;
        //探査済み
        if(seen[to] == true){
            continue;
        }
        cost[to] += cost[idx];
        dfs(to , idx);
    }
}

int main(){
    ll N, Q;
    cin >> N >> Q;
    //初期化
    G.assign(N, vector<pi >());
    seen.assign(N, false);
    cost.assign(N, 0);
 
    //グラフ入力
    for(ll i = 0; i < N-1; i++){
        ll u, v, w;
        w = 0;
        cin >> u >> v;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }

    for(ll i = 0; i < Q; i++){
        ll p, c; cin >> p >> c;
        cost[p-1] += c;
    }

    dfs(0);

    for(ll i = 0; i < N; i++){
        cout << ( i ? " " : "" ) << cost[i];
    }

}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    
    unordered_set<int> us;
    rep(i, p.size()) us.emplace(p[i]);

    int best = 0;
    int cost = 1e8;
    rep(i, 102) {
        if (us.count(i) <= 0) {
            int c = abs(x - i);
            if (c < cost) {
                best = i;
                cost = c;
            }
        }
    }

    put(best);

    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define    ll   long long int
#define    sz   200010
#define    md   1000000007
#define    py   printf("Yes\n")
#define    pn   printf("No\n")

using namespace std;


ll ara[sz];


int main()
{


    string s;

    cin>>s;

    sort(s.begin(),s.end());

    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2])py;
    else
        pn;




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;


int main() {
	IOS;
#ifdef xiaofan
	freopen("in.txt","r",stdin);
#endif
	
	map<string,int>q;
	int n;
	cin>>n;
	int ma=-1;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		q[s]++;
		ma=max(ma,q[s]);
	}
	for(auto i:q){
		if(i.se==ma){
			cout<<i.fi<<endl;
		}
	}
		


	return 0;
}



Measured memory_bytes: 24760
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define mem(f, x) memset(f, x, sizeof(f))
#define INF 0x3f3f3f3f
using namespace std;
const int M = 2*1e5 + 5;
const int N = 1e5 + 5;
int ct0, ct1;
char s[N];
char ss[2][M];

int main( ){
    while( scanf( "%s", s ) != EOF ){
        ct0 = ct1 = 0;
        int cs, t, f;
        char c;
        scanf( "%d", &cs );
        int flag = 0; //Õý
        while( cs-- ){
            scanf( "%d", &t );
            if( t == 1 )
                flag = ( flag + 1 )%2;
            else if( t == 2 ){
                scanf( "%d %c", &f, &c );
                f--;
                f = ( f + flag )%2;
                if( f == 0 )
                    ss[0][ct0++] = c;
                else
                    ss[1][ct1++] = c;
            }
        }
        ss[0][ct0] = '\0';
        ss[1][ct1] = '\0';

        if( !flag ){
            for( int i = ct0-1; i >= 0; i-- )
                printf( "%c", ss[0][i] );
            printf( "%s", s );
            printf( "%s\n", ss[1] );
        }
        else{
            for( int i = ct1 - 1; i >= 0; i-- )
                printf( "%c", ss[1][i] );
            int len = strlen( s );
            for( int i = len - 1; i >= 0; i-- )
                printf( "%c", s[i] );
            printf( "%s\n", ss[0] );
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

Measured memory_bytes: 256
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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



int main() {
	llong N;
    cin >> N;
    string S;
    cin >> S;
    int cb=0;
    int cw=0;
    int cb_n = 0;
    int cw_n =0;
    REP(i,N){
        if(S[i]=='#'){
            cb++;
        }else{
            cw++;
        }
    } 
    int c;
    llong cost = INF;
    cost = cb_n + (cw - cw_n);
    REP(i,N){
        if(S[i]=='#'){
            cb_n++;
        }else{
            cw_n++;
        }
        c = cb_n + (cw - cw_n);
        if(c < cost){
            cost = c;
        }
    }    
    cout << cost << endl;





}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        string S = Console.ReadLine();
        var W = new int[N+2];
        for (int i = 1; i <= N; i++) {
            W[i] = W[i - 1] + (S[i - 1] == 'W' ? 1 : 0);
        }

        int ans = int.MaxValue;
        for (int i = 1; i <= N; i++) {
            int tmp = W[i - 1] + N - i - W[N] + W[i];
            ans = Math.Min(ans, tmp);
        }

        Console.WriteLine(ans);
        Console.ReadLine();
    }
}

Measured memory_bytes: 13280
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        long sum = 0;
        for (int i = 1; i < n; i++) {
            if (a[i] < a[i - 1]) {
                sum += (a[i - 1] - a[i]);
                a[i] = a[i - 1];
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 61760
s = str(input())
kekka = 1
n = len(s)
if s != s[::-1]:
    kekka = -1
if s[:(n-1)//2] != s[(n-3)//2::-1]:
    kekka = -1
if s[(n+1)//2:] != s[n-1:(n-1)//2:-1]:
    kekka = -1
if kekka == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064