akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    vector<int> p(N);
    for(int i = 0; i<N; i++){cin >> p[i];}

    vector<int> s(N);
    for(int i = 0; i<N; i++){s[i] = i+1;}

    bool can = false;

    if(p == s){
        can = true;
    }else{
    for(int j = 0; j<N; j++){
        

    for(int k = j+1; k<N; k++){
        vector<int> a(N);
    a = p;
        swap(a[j],a[k]);
        if(a == s){
            can = true;
        }
    }
    }
    }

    if(can){cout << "YES" <<endl;}
    else{cout << "NO" <<endl;}

}

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

using namespace std;

vector <int> g[100005];
int n;
int pred[100005];

void dfs(int u, int par, int h){
    pred[u]=par;
    if(u==n-1){
        int v=u;
        for(int i=0;i<(h-1)/2;i++){
            v=pred[v];
        }
        g[v].erase(remove(g[v].begin(),g[v].end(),pred[v]),g[v].end());
        g[pred[v]].erase(remove(g[pred[v]].begin(),g[pred[v]].end(),v),g[pred[v]].end());
        return;
    }
    for(auto v:g[u]){
        if(v!=par){
            dfs(v,u,h+1);
        }
    }
}

void dfssiz(int u, int par, int &siz){
    siz++;
    for(auto v:g[u]){
        if(v!=par){
            dfssiz(v,u,siz);
        }
    }
}

int main(){
    cin >> n;
    for(int i=0,u,v;i<n-1;i++){
        cin >> u >> v;
        u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0,-1,0);
    int siz0=0,sizn=0;
    dfssiz(0,-1,siz0);
    dfssiz(n-1,-1,sizn);
    if(siz0>sizn){
        cout << "Fennec" << endl;
    }
    else{
        cout << "Snuke" << endl;
    }
    return 0;
}

Measured memory_bytes: 12416
package main

import "fmt"

func main() {
	var b, ans string
	fmt.Scan(&b)
	switch b {
	case "A":
		ans = "T"
	case "C":
		ans = "G"
	case "G":
		ans = "C"
	case "T":
		ans = "A"
	}
	fmt.Println(ans)
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int x;
  cin >> x;
  if (x == 3 || x == 5 || x == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
import collections
N = int(input())
ans1 = ["a"]
ans2 = ["aa", "ab"]
ans3 = []
ans4 = []
ans5 = []
ans6 = []
ans7 = []
ans8 = []
ans9 = []
ans10 = []
def count(s):
    return(len(collections.Counter(s)))
    
for x in ans2:
    for i in range(count(x)+1):
        ans3.append(x+chr(97+i))
for x in ans3:
    for i in range(count(x)+1):
        ans4.append(x+chr(97+i))
for x in ans4:
    for i in range(count(x)+1):
        ans5.append(x+chr(97+i))         
for x in ans5:
    for i in range(count(x)+1):
        ans6.append(x+chr(97+i)) 
for x in ans6:
    for i in range(count(x)+1):
        ans7.append(x+chr(97+i)) 
for x in ans7:
    for i in range(count(x)+1):
        ans8.append(x+chr(97+i)) 
for x in ans8:
    for i in range(count(x)+1):
        ans9.append(x+chr(97+i)) 
for x in ans9:
    for i in range(count(x)+1):
        ans10.append(x+chr(97+i)) 

ans=[ans1, ans2, ans3, ans4, ans5, ans6, ans7, ans8, ans9, ans10]
for x in ans[N-1]:
    print(x)

Measured memory_bytes: 14868
#include<bits/stdc++.h>
using namespace std;
#define N 805
char mp[N][N];
int n,m,k;
int ans=1e9;
int xx[4]={-1,0,1,0},yy[4]={0,-1,0,1};

struct msg{int x,y,step;};
queue<msg >q;
int main(){
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++) scanf("%s",mp[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(mp[i][j]=='S')
                q.push((msg){i,j,0});
    while(!q.empty()){
        msg v=q.front();q.pop();
        int x=v.x,y=v.y;
        ans=min(ans,(min(min(x-1,n-x),min(y-1,m-y))+k-1)/k+1);
        for(int i=0;i<4;i++){
            int nx=x+xx[i],ny=y+yy[i];
            if(1<=nx&&nx<=n&&1<=ny&&ny<=m&&mp[nx][ny]=='.'&&v.step<k){
                mp[nx][ny]='x';
                q.push((msg){nx,ny,v.step+1});
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  string s; cin >> s;
  ll i = 0;
  ll ans = 0;
  ll ac = 0;
  while (i < s.size()-1) {
    if (s.at(i) == 'A') {
      ac++; i++;
    } else if (s.at(i) == 'B' && s.at(i+1) == 'C') {
      if (ac > 0) {
        ans += ac; i += 2;
      } else {
        i++;
      }
    } else {
      ac = 0; i++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
int n,a[1000];
int main()
{
	ll sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		sum+=a[i]*a[j];
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {

  int n;
  ll a, b, x[100010];
  cin >> n >> a >> b;
  rep(i, n) cin >> x[i];

  ll ans = 0;
  for (int i = 1; i < n; i++) {
    if ((x[i] - x[i - 1]) * a > b) ans += b;
    else ans += (x[i] - x[i - 1]) * a;
  }
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 1024
#include <stdio.h>
#include <limits.h>

int main(void){
	int i, j, n, min = 0, max;
	int Rt[200000];
	scanf("%d", &n);
	for(i = 1; i <= n; i++){
		scanf("%d", &Rt[i]);
	}
	
	min = Rt[1];
	max = Rt[2] - Rt[1];
	for(i = 2; i <= n; i++){
		if(max < Rt[i] - min){
			max = Rt[i] - min;
		}
		if(min > Rt[i]){
			min = Rt[i];
		}
	}

	printf("%d\n", max);
	return 0;
}


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

int main()
{
	int a, b, c;
	cin >> a; //3
	cin >> b; //2
	cin >> c; //1
	if (a < b&&b < c) {  //3<2<1
		cout<<"Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
using namespace std;

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

  int a, b; cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;
}


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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main() {
	faster;

	ll n, k;
	cin >> n >> k;

	vector<ll> h(n), dp(n + 1, 0);

	for (auto &x : h)
		cin >> x;

	dp[0] = 0;

	for (ll i = 1; i < n; i++) {
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		for (int j = 1; (j < k) && (j < i); j++) {
			dp[i] = min(dp[i], dp[i - 1 - j] + abs(h[i] - h[i - 1 - j]));
		}
	}

	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 4784
#include<stdio.h>

int main(void){
  
  int A,B,K;
  int result,k_th = 0;
  
  scanf("%d %d %d",&A,&B,&K);
  
  if(A > B){
    result = A;
  }else{
    result = B;
  }
  
  while(k_th != K){
    if(A % result == 0 && B % result == 0){
     k_th++; 
    }
    if(k_th != K){
     result--; 
    }
  }
  
  printf("%d",result);
  return 0;
}

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

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  long long power = 1;
  for (int i = 1; i <= N; i++) {
    power *= i;
    power %= (int)pow(10, 9) + 7;
  }
  cout << power << endl;
}

int main() {
  answer1();
}


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

using namespace std;

int main() {
  long long N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  if (D == 0) {
    puts(A == B ? "YES" : "NO");
    return 0;
  }
  A = abs(A - B);
  auto cof = C + D; 
  auto minX = (A + (N - 1) * C + cof - 1) / cof;
  auto maxX = (A + (N - 1) * D) / cof;
  puts(minX <= maxX && minX <= N - 1 ? "YES" : "NO");
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<pair<long long, int>> a(n);
    for (int i = 0; i < n; i++) {
        long long x;
        cin >> x;
        a.at(i) = make_pair(x, i);
    }

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

    for (int i = 0; i < n; i++) {
        if (a.at(n - 1).second == i) cout << a.at(n - 2).first << endl;
        else cout << a.at(n - 1).first << endl;
    }
}   

Measured memory_bytes: 4736
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

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

	ld ans = 0;

	if (d) {
		ans = 2.0 * (n - d) / n / n;
	} else {
		ans = 1.0 / n;
	}
	ans *= m - 1;
	setp(10);
	co(ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s,t;
int a,b;
cin>>s>>t>>a>>b;
string u;
cin>>u;
if(u==s){
    a-=1;
}
else{
    b-=1;
}
cout<<a<<" "<<b<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long A,B,k;
    cin >> A >> B >> k ;
    if (A>=k){
        cout << A-k << " " << B << endl;
    }
    else if (A+B-k>0){
        cout << 0 << " " << A+B-k << endl;
    }
    else{
        cout << 0 << " " << 0 << endl;
    }
    
}  

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] a = new int[N];

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

    sc.close(); 

    long max = 0;

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

    System.out.println(max);

  }

}

Measured memory_bytes: 25944
#include <stdio.h>

int main(void)
{
    int inputA, inputB, current = 1, Acount = 0;
    scanf("%d%d", &inputA, &inputB);
    while (current < inputB)
    {
        current = current - 1 + inputA;
        Acount++;
    }
    printf("%d", Acount);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;

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

  int n; cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];

  sort(all(a));
  sort(all(b));
  sort(all(c));

  ll ans = 0;
  rep(i, n) {
    // A < B
    int cntAB = lower_bound(all(a), b[i]) - a.begin();
    // B < C
    int cntBC = c.end() - upper_bound(all(c), b[i]);
    ans += (ll)cntAB*cntBC;
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
  int n; cin >>n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >>a.at(i);
  sort(a.begin(), a.end());
  int ans = a.at(n-1)-a.at(0);
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] H = new int[n];
        for (int i = 0; i < n; i++) H[i] = sc.nextInt();
        System.out.println(helper(H));
        sc.close();
    }

    public static int helper(int[] A) {
        int res = 0, max = A[0];
        for (int a : A) {
            if (a >= max) {
                max = a;
                res++;
            }
        }
        return res;
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 1000005
#define PI 3.14159265358979323846264338327950
 
#define ll    long long int
#define mod  1000000007
ll t ,  ans;
int main()
{
	FAST;
	ll n;
	string s1, s2;
	cin >> s1 >> s2;
	for(ll i = 0; i < s1.size(); i++){
		if(s1[i] != s2[i]){
			ans ++;
		}
	}
	cout << ans;
	return 0;
}

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


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

    while (true) {
        int N, K, S;
        cin >> N >> K >> S;
        if (N == 0 and K == 0 and S == 0) {
            break;
        }

        VVVI dp(N + 2, VVI(K + 2, VI(S + 2, 0)));
        dp[1][0][0] = 1;

        FOR(i, 1, N + 1) {
            FOR(j, 0, K + 1) {
                FOR(k, 0, S + 1) {

                    // not use
                    dp[i + 1][j][k] += dp[i][j][k];

                    // use
                    if (j + 1 < dp[0].size() and k + i <= S) {
                        dp[i + 1][j + 1][k + i] += dp[i][j][k];
                    }
                }
            }
        }

        print(dp[N + 1][K][S]);
    }
    return 0;
}


Measured memory_bytes: 3276
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#ifdef BOI
#include "debug.h"
#else
#define debug(args...)
#endif
#define endl '\n'
using ll = long long;
using namespace std;

const int maxn = 1e3 + 69;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
#ifdef BOI
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int x; cin >> x;
    cout << (x >= 30 ? "Yes" : "No");
    return 0;
}


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

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

  ll N, K;
  cin >> N >> K;

  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);

  vector<ll> F(N);
  for (ll i = 0; i < N; i++) cin >> F.at(i);

  sort(A.begin(), A.end());
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());

  ll left = -1, right = 1e12, ans = right, mid;

  while (right - left > 1) {
    mid = (left + right) / 2;

    ll sum = 0;

    for (ll i = 0; i < N; i++) {
      ld diff = A[i] * F[i] - mid;

      if (diff > 0) {
        sum += ceil(diff / F[i]);
      }
      
      if (sum > K)
        break;
    }

    if (sum > K) {
      left = mid;
    } else {
      right = mid;
      ans = mid;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3456
# -*- coding: utf-8 -*-
"""
Created on Mon May 27 22:13:19 2019

@author: Yamazaki Kenichi
"""

N, M = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))

S = [0 for i in range(M)]
for i in range(M):
    for j in range(1,ks[i][0]+1):
        S[i] += 2**(ks[i][j]-1)

ans = 0
for bit in range(1<<N):
    now = [0 for i in range(M)]
    for i in range(N):
        if bit & 1<<i:
            for j in range(M):
                now[j] += S[j]//(1<<i)
    flg = True
    for j in range(M):
        if now[j]%2 != p[j]:
            flg = False
    ans += flg
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(){
	char s[100], p[100], cp[200];
	scanf("%s %s", s, p);
	strcpy(cp, s);
	strcat(cp, s);
	if ( strstr(cp, p) == NULL ) printf("No\n");
	else printf("Yes\n");
}


Measured memory_bytes: 2104
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}		
int a[114514],b[114514];
string ss[114514];
signed main(){
	sc(s)
	if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi"){
		c("Yes")
	}
	else{
		c("No")
	}
}		

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 52;
const int maxk = 102;
int v[maxn], f[maxn][maxk], g[maxn][maxk];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n; ++i)
		cin >> v[i];

	int lim = n;
	for (int i = 0; i <= lim; ++i)
		for (int j = 0; j <= k; ++j)
			f[i][j] = g[i][j] = INT_MIN;

	f[0][0] = g[0][0] = 0;
	for (int i = 1; i <= lim; ++i) {
		for (int j = i; j <= min(k, 2*i); ++j) {
			if (f[i-1][j-1] != INT_MIN)
				f[i][j] = max(f[i][j], f[i-1][j-1] + v[i-1]);
			if (j > 1)
				f[i][j] = max(f[i][j], f[i-1][j-2]);

			if (g[i-1][j-1] != INT_MIN)
				g[i][j] = max(g[i][j], g[i-1][j-1] + v[n-i]);
			if (j > 1)
				g[i][j] = max(g[i][j], g[i-1][j-2]);

			// printf("%d %d:%d %d\n", i, j, f[i][j], g[i][j]);
		}
	}
	
	for (int i = 1; i <= lim; ++i)
		f[i][0] = g[i][0] = 0;
	for (int i = 1; i <= k; ++i)
		f[0][i] = g[0][i] = 0;

	for (int i = 1; i <= lim; ++i)
		for (int j = 1; j <= k; ++j) {
			f[i][j] = max(f[i][j], f[i-1][j]);
			g[i][j] = max(g[i][j], g[i-1][j]);
		}

	for (int i = 1; i <= lim; ++i)
		for (int j = 1; j <= k; ++j) {
			f[i][j] = max(f[i][j], f[i][j-1]);
			g[i][j] = max(g[i][j], g[i][j-1]);
		}

	long long ans = 0;
	for (int i = 0; i <= lim; ++i)
		for (int j = 0; j <= k; ++j)
			ans = max(ans, (long long)f[i][j] + g[n-i][k-j]);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,m,l;
int d[100][100];
int t[1000],pl[1000];
vector<vi> e;

int p[2000]; bool v[2000];
bool rec(int s)
{
	if(s<0)return 1;
	fr(i,e[s])if(!v[*i])
	{
		v[*i]=1;
		if(rec(p[*i]))return p[s]=*i,p[*i]=s,1;
	}
	return 0;
}

int main()
{
	while(scanf("%d%d%d",&n,&m,&l),n)
	{
		rep(i,n)rep(j,n)d[i][j]=i==j?0:inf;
		rep(i,m)
		{
			int a,b,c; scanf("%d%d%d",&a,&b,&c);
			d[a][b]=d[b][a]=c;
		}
		rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		
		rep(i,l)scanf("%d%d",pl+i,t+i);
		e.clear(); e.resize(2*l);
		rep(i,l)rep(j,l)if(i!=j&&d[pl[i]][pl[j]]<=t[j]-t[i])
		e[i].pb(j+l),e[j+l].pb(i);
		
		int ans=l;
		rep(i,2*l)p[i]=-1;
		rep(i,l)
		{
			rep(j,2*l)v[j]=0;
			if(rec(i))ans--;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 6280
MODINT = 10**9+7
n, k = map(int, input().split())

ans = 0

"""
dp[i] =　gdc がi となる場合のgcdの総和
"""
dp = [0] * (k+100)
for i in range(k, 0, -1):
    dp[i] = pow(k//i, n, MODINT)
    for j in range(i*2, k+1, i):
        dp[i] -= dp[j]
    ans += (dp[i]*i)%MODINT
print(ans%MODINT)

Measured memory_bytes: 11304
from collections import defaultdict
n = int(input())
nums = [int(i) for i in input().split()]

num_freq = defaultdict(int)
for num in nums:
    num_freq[num] += 1

ans = 0
for num, freq in num_freq.items():
    if num > freq:
        ans += freq
    else:
        ans += freq - num

print(ans)


Measured memory_bytes: 18676
n = int(input())
print_list = []
for i in range(1, n+1):
    tmp_val = i
    # 3の倍数
    if tmp_val % 3 == 0:
        print_list.append(i)
    else:
        while tmp_val != 0:
            # 3が含まれる
            if tmp_val % 10 == 3:
                print_list.append(i)
                break
            else:
                tmp_val = tmp_val // 10

for i in range(len(print_list)):
    print(" ", print_list[i], sep="", end="")
print("")


Measured memory_bytes: 6444
ary = gets.chomp.chars.map(&:to_s).sort!
t = nil
hash = {}
ary.each do |v|
  if hash[v]
    hash[v] += 1 
  else
    hash[v] = 1
  end
end

hash.each do |k, v|
  if v != 2
    t = "No"
    break
  end
  t = "Yes"
end
puts t

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int k, t;
  cin >> k >> t;
  vecint a(t, 0);
  REP(i, t) cin >> a[i];
  sort(all(a), greater<int>());
  int sum = 0;
  FOR(i, 1, t) { sum += a[i]; }
  cout << max(0, a[0] - sum - 1) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.at(0)== s.at(1) || s.at(1)== s.at(2) || s.at(2)== s.at(3)){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 3580
n = int(input())
data = [input().split() for i in range(n)]
for i in range(n - 2):
    if int(data[i][0]) == int(data[i][1]) and int(data[i + 1][0]) == int(data[i+1][1]) and int(data[i+2][0]) == int(data[i+2][1]):
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 9180
#include <iostream>

using namespace std;

int main()
{
   int N, resto=0;

   cin>>N;

   resto = N%10;

   if(N>=10 && N<=99){
        if(((N-resto)/10)==9){
            cout<<"Yes";
        }else{
            if(resto==9){
                cout<<"Yes";
            }else{
                cout<<"No";
       }
     }
   }


    return 0;
}

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

int main(){
	int a[4],b[4];
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
		int hit=0,blow=0,f=0,b;
		for(int i=0;i<4;i++)f |= 1<<a[i];
		for(int i=0;i<4;i++){
			cin>>b;
			if(b==a[i])hit++;
			else if(1<<b & f)blow++;
		}
		cout<<hit<<' '<<blow<<endl;
	}
	return 0;
}

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

void outputsunuke(int* sunuke, int n) {
    printf("snuke ---\n");
    for(int i=0; i<n; i++) {
        cout<< "i=" << i << " " << sunuke[i] << endl;
    }
}

void apply(int* sunuke) {
    int d;
    int list;
    cin >> d;
    for(int i=0; i<d; i++) {
        cin >> list;
        sunuke[list-1] += 1;
    }
    return;
}

int main() {
    int n, k;
    cin >> n >> k;
    int sunuke[n] = {0};
//    outputsunuke(sunuke, n);
    for(int i=0; i<k; i++) {
        apply(sunuke);
    }
    int cnt = 0;
    for(int i=0; i<n; i++) {
        if(!sunuke[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
int main(){
  int n,m,r=0;
  cin>>n>>m;
  vector<pii> ab(m);
  vector<bool> con(n-1,true);
  for(int i=0;i<m;++i)cin>>ab[i].first>>ab[i].second;
  sort(ab.begin(),ab.end(),[](pii a,pii b){return a.second<b.second;});
  int x=-1;
  for(int i=0;i<m;++i){
    if(ab[i].first-1<=x)continue;
    if(con[ab[i].second-2]){
      con[ab[i].second-2]=false;
      x=ab[i].second-2;
      r++;
    }
  }
  cout<<r;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){

  int n,m,i,a[10000],b[10000],k,j;
  m=0;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d",&b[i]);
  }


  for(j=0;j<k;j++){

    for(i=0;i<n;i++){

      if(a[i]==b[j]){
	m++;
	break;
      }
    }
  }
  printf("%d\n",m);
  return 0;
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void Main() {
  int n; cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  sort(all(a));
  vector<int> d(n), f(n);
  for (int i = 0; i < n; i++) {
    d[i] = a[i];
    if (i) d[i] += d[i - 1];
  }
  int ans = 1;
  f[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (f[i + 1] && d[i] * 2 >= a[i + 1]) {
      f[i] = 1;
      ans++;
    }
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  cerr << "- ---- -- ----- <3\n";
#endif
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


Measured memory_bytes: 5540
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n=Readint();
            //string[] str = Console.ReadLine().Split(' ');

            int d= int.Parse(Console.ReadLine());
            Console.ReadLine();

            for(int i = 0; i < d; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                int max = 0;
                int maxn = 0;
                for(int j = 0; j < 26; j++)
                {
                    int temp = int.Parse(str[j]);
                    if (temp >= max)
                    {
                        max = temp;
                        maxn = j;
                    }
                }
                Cout(maxn+1);
            }



            //ここまで
        }

        static void Cout(string s)
        {
            Console.WriteLine(s);
            return;
        }

        static void Cout(int n)
        {
            Console.WriteLine(n);
            return;
        }

        static void Cout(long n)
        {
            Console.WriteLine(n);
            return;
        }

        static int Readint()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] ReadArray(int n)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i=0; i < n; i++){ a[i] = int.Parse(str[i]); }
            return a;
        }
        static long[] ReadArray(long n)
        {
            string[] str = Console.ReadLine().Split(' ');
           long[] a = new long[n];
            for (long i = 0; i < n; i++) { a[i] = long.Parse(str[i]); }
            return a;
        }

        static long Readlong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int Min(int a, int b)
        {
            if (a < b) return a;
            return b;
        }

        static int Max(int a, int b)
        {
            if (a > b) return a;
            return b;
        }


    }

}


Measured memory_bytes: 27880
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <utility>
using namespace std;

string S;
int A, B;

int main(){
	cin >> A >> B;
	cin >> S;
	
	for(int i = 0; i<A; i++){
		if(!isdigit(S[i])){ cout << "No" << endl; return 0;}
	}
	
	if(S[A] != '-'){ cout << "No" << endl; return 0; }
	
	for(int i = A+1; i<A+B+1; i++){
		if(!isdigit(S[i])){ cout << "No" << endl; return 0;}
	}
	
	cout << "Yes" << endl; 
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=2000+19;

char s[N][N];
int s1[N][N],s2[N][N],s3[N][N],A[N][N];
int n,m,q,X1,Y1,X2,Y2;
int res;

int cal(int s[N][N],int X1,int Y1,int X2,int Y2){
	return s[X2][Y2]-s[X2][Y1-1]-s[X1-1][Y2]+s[X1-1][Y1-1];
}

int main(){
	n=IN(),m=IN(),q=IN();
	For(i,1,n+1) scanf("%s",s[i]+1);
	For(i,1,n+1) For(j,1,m+1) A[i][j]=s[i][j]-'0';
	For(i,1,n+1) For(j,1,m) s2[i][j]=(A[i][j]&&A[i][j+1]);
	For(i,1,n) For(j,1,m+1) s3[i][j]=(A[i][j]&&A[i+1][j]);
	For(i,1,n+1) For(j,1,m+1){
		s1[i][j]=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1]+A[i][j];
		s2[i][j]=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1]+s2[i][j];
		s3[i][j]=s3[i-1][j]+s3[i][j-1]-s3[i-1][j-1]+s3[i][j];
	}
	while (q--){
		X1=IN(),Y1=IN(),X2=IN(),Y2=IN();
		res=0;
		res+=cal(s1,X1,Y1,X2,Y2);
		res-=cal(s2,X1,Y1,X2,Y2-1);
		res-=cal(s3,X1,Y1,X2-1,Y2);
		printf("%d\n",res);
	}
}

Measured memory_bytes: 69376
using System;
using System.Linq;

namespace InsertionSort
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            InsertionSort(arr);


        }

        static void InsertionSort<T>(T[] arr) where T : IComparable<T>
        {
            
            var before = string.Join(" ", arr).TrimEnd();
            Console.WriteLine(before);
            for (var i = 1; i < arr.Length; i++)
            {
                for (var j = i; j >= 1 && arr[j - 1].CompareTo(arr[j]) > 0; j--)
                {
                    Swap(ref arr[j], ref arr[j - 1]);
                }
                
                var result = string.Join(" ", arr).TrimEnd();
                Console.WriteLine(result);
            }
        }

        static void Swap<T>(ref T a, ref T b) where T : IComparable<T>
        {
            var tmp = a;
            a = b;
            b = tmp;
        }
    }
}


Measured memory_bytes: 18324
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,p[100000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>p[i];
    map<int,int>mp,rev;
    vector<pair<int,int>>v;
    for(int i=0;i<n;i++)
        v.emplace_back(p[i],i);
    sort(v.rbegin(),v.rend());
    mp[n]=rev[1]=0;
    int ans=0;
    for(int i=0;i<n;i++){
        int af,as,bf,cf,df,ef;
        af=v[i].second,as=v[i].first;
        df=mp.upper_bound(af)->first;
        bf=-rev.upper_bound(-af)->first;
        if(df==n)
            ef=n;
        else
            ef=mp.upper_bound(df)->first;
        if(bf==-1)
            cf=-1;
        else
            cf=-rev.upper_bound(-bf)->first;
        ans+=((bf-cf)*(df-af)+(ef-df)*(af-bf))*as;
        mp[af]=rev[-af]=as;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 15088
#include<stdio.h>
#define INF 1000000000
int cost[101][101];
int d[101];
int flag[101];
int n;

int main(){
    int i,j;
    int u,k,v,c;
    scanf("%d",&n);

    for(i=0;i<n;i++) d[i] = INF;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++) cost[i][j] = INF;

    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d%d",&v,&c);
            cost[u][v] = c;
        }
    }
    d[0] = 0;
    while(1){
        int v = -1;
        for(i=0;i<n;i++){
            if(flag[i]==0 && (v==-1 || d[i] < d[v])){
                v = i;
            }
        }
        if(v == -1) break;
        flag[v] = 1;
        for(i=0;i<n;i++){
            int tmp = d[v]+cost[v][i];
            d[i] = d[i] < tmp ? d[i] : tmp;
        }
    }

    for(i=0;i<n;i++){
        printf("%d %d\n",i,d[i]);
    }

    return 0;
}



Measured memory_bytes: 2088
N = int(input())
s = [input() for _ in range(N)]

ab = 0
b_a = 0
b_ = 0
_a = 0
for i in range(N):
  ab += s[i].count('AB')
  if s[i][0] == 'B':
    if s[i][-1] == 'A':
      b_a += 1
    else:
      b_ += 1
  elif s[i][-1] == 'A':
    _a += 1
if b_a == 0:
  print(ab + min(b_, _a))
else:
  ans = ab + b_a - 1 + min(b_ - 1, _a - 1) + 2
  if b_ == 0 and _a == 0:
    ans -= 1
  print(ans)

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

void trace(int a[], int n) {
    rep(i,n) {
        cout << a[i];
        if (i < n-1)  cout << ' ';
        else  cout << '\n';
        }
}

void insertionSort(int a[], int n) {
    int v, j;
    for (int i = 1; i < n; i++) {
        v = a[i];
        j = i-1;
        while (j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        trace(a,n);
    }
}

int main()
{
    int n;  cin >> n;
    int a[n];
    rep(i,n)  cin >> a[i];

    trace(a,n);
    insertionSort(a,n);
}


Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<tuple>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;



long double pi = 3.14159265359;

int itew,iter;
int n;
int ans;
string s;

int main(){
    cin >> n;
    cin >> s;
    iter = n;
    itew = 0;
    while(itew <= iter){
        if(s[iter] == 'R' && s[itew] == 'W'){
            s[iter] = 'W';
            s[itew] = 'R';
            iter --;
            itew ++;
            ans++;
            continue;
        }
        if(s[iter] != 'R'){
            iter--;
        }
        if(s[itew] != 'W'){
            itew++;
        }

    }
    cout << ans << endl;


return 0;
}

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

int main(){
		
		int n,k;
		cin>>n>>k;
		long int h[n];
		
		for(int i=0;i<n;i++)
			cin>>h[i];
		
		int a,b;
		vector<long> vc[n];
		for(int i=0;i<k;i++){
				cin>>a>>b;
				vc[a-1].push_back(b-1);
				vc[b-1].push_back(a-1);
		}
		
		int count= 0;
		for(int i=0;i<n;i++){
				bool flag = true;
				for(int j=0;j<vc[i].size();j++){
						if(h[i] <= h[vc[i][j]])
							flag = false;
				}
				if(flag)
					count++;
		}
		
		cout<<count<<endl;
		return 0;
}




Measured memory_bytes: 10236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> p, m;
  p.push_back(0);
  m.push_back(0);
  REP(i, n) {
    ll a;
    cin >> a;
    if (a >= 0) {
      p.push_back(a);
    } else {
      m.push_back(-a);
    }
  }
  sort(ALL(p));
  sort(ALL(m));

  ll ans = 1e18;
  REP(i, min(k + 1, SZ(p))) {
    if (k - i >= SZ(m)) {
      continue;
    }
    ll t1 = p[i];
    ll t2 = m[k - i];
    ll t = min(t1 + 2 * t2, 2 * t1 + t2);
    ans = min(ans, t);
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define f0(i,b)   for(int i=0;i<(b);i++)
#define f1(i,b)   for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define forr(i,n)    for(i=0; i<n; i++)
#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld",a)

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);
//scanf("%d",&x);
//printf("%d\n",x);

//vector <int> A;
//deque <int> A;
//queue <int> A;
//stack <int> A;
//set <int> A;
//map <int,int> A;
//pair <int,int> A ;
//vector <pair <int,int>> A ;
//char ch;
string S, T, U;
ll i, j, k, a, b, c, d, f, g, h, l, m, n, p, q, r, s, t, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

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

    while(cin>>x>>y)
    {
        n=x+y;
        cnt=0;
        while(n>0)
        {
            cnt++;
            n/=10;
        }
        cout<<cnt<<endl;
    }

    return 0;
}



Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e17 + 3)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 105;

 
llong nCk (int n, int k) {
    int res = 1;
    REP(i,k){
        res*= n - i;
        res /= i + 1;
    }
    return res;
}

signed main(){
    int n,a,b;
    cin >> n >> a >> b;
    int v[n];
    REP(i,n) cin >> v[i];
    sort(v,v + n);
    reverse(v,v + n);
    double summ = 0.0;
    REP(i,a) summ += v[i];
    cout << fixed << setprecision(10) << double(summ / a) << endl;
    int left,right;
    left = -1;
    right = n;
    REP(i,n){
        if(left == -1 and v[i] == v[a-1]) left = i;
        if(left != -1 and v[i] != v[a-1]){
            right = i;
            break;
        }
    }


    if(left != 0){
        cout << nCk(right - left, a - left) << endl;
    }
    else{
        int tmp = a;
        int ans = 0;
        while( min(b,right) >= tmp){
            ans += nCk(right , tmp);
            tmp ++;
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 256
r, g, b, n = map(int, input().split())
ans = 0
for i in range(3001):
    if r * i > n:
        break
    for j in range(3001):
        if r * i + g * j > n:
            break
        if (n - r * i - g * j) % b == 0:
            ans += 1
print(ans)

Measured memory_bytes: 42456
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b; cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256