akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  long h, w;
  cin >> h >> w;
  if((h%3)*(w%3)==0){
    cout << 0;
  }
  else {
    long ret = min(h, w);
    for(int i=0; i<h; i++){
      if(w%2==0){
        ret = min(ret, abs(i*w-(h-i)*w/2));
      }
      else {
        long dif = max({i*w, (h-i)*(w-1)/2, (h-i)*(w+1)/2})-min({i*w, (h-i)*(w-1)/2, (h-i)*(w+1)/2});
        ret = min(ret, dif);
      }
    }
    for(int i=0; i<w; i++){
      if(h%2==0){
        ret = min(ret, abs(i*h-(w-i)*h/2));
      }
      else {
        long dif = max({i*h, (w-i)*(h-1)/2, (w-i)*(h+1)/2})-min({i*h, (w-i)*(h-1)/2, (w-i)*(h+1)/2});
        ret = min(ret, dif);
      }
    }
    cout << ret;
  }
  return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int M, K;
    cin >> M >> K;

    if (M == 0) {
        cout << (K == 0 ? "0 0" : "-1") << endl;
    }

    if (M == 1) {
        cout << (K == 0 ? "0 0 1 1" : "-1") << endl;
    }

    if (M >= 2) {
        if (K >= (1 << M)) {
            puts("-1");
            return 0;
        }
        
        vector<int> a;
        for_(i,0,1<<M) if (i != K) a.push_back(i);
        vector<int> b = a;
        reverse(ALL(b));

        int m = a.size();
        for (int x : a) cout << x << " ";
        cout << K << " ";
        for (int x : b) cout << x << " ";
        cout << K << endl;
    }
}

Measured memory_bytes: 2936
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
'''
p = 10 ** 9 + 7
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
'''


#a = list(map(int, input().split()))

s = input()
ans = "No"
if(s == "hi"):
    ans ="Yes"
if(s == "hihi"):
    ans ="Yes"
if(s == "hihihi"):
    ans ="Yes"
if(s == "hihihihi"):
    ans ="Yes"
if(s == "hihihihihi"):
    ans ="Yes"
print(ans)

Measured memory_bytes: 64364
// ABC 087 D
// Depth First Search
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int INF = 1000000007;
int N, M, l, r, d;
vector<pair<int,int>> G[100001];
vector<int> x(100001,INF);

int c = 1;
void dfs(int n){
    if(!G[n].size()){
        x[n] = n;
        return;
    }
    for(auto e: G[n]){
        if(x[e.first]==INF){
            x[e.first] = x[n] + e.second;
            dfs(e.first);
        }else{
            if(x[e.first] != x[n] + e.second){
                c = 0;
                return;
            }
        }
    }
}


int main() {
    cin >> N >> M;
    REP(i,M){
        cin >> l >> r >> d;
        l--; r--;
        G[l].push_back(make_pair(r,d));
        G[r].push_back(make_pair(l,-d));
    }
    REP(i,N){
        if(x[i]==INF){
            x[i] = i;
            dfs(i);
            if(c==0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 11008
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  vector<ll>t(5);
  cin>>n;
  rep(i,5)cin>>t[i];
  ll mi=1e17;
  rep(i,5)chmin(mi,t[i]);
  cout<<(n-1)/mi+5<<endl;


  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define mid (low+high)/2
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004

using namespace std;

ll n,m,s,t,a,b,c,mod=1e9+7;
vector < pi > graph[N];
ll dist[N][2],ways[N][2];
vector < pair < pi,ll > > edges;

void dijkstra(ll root,ll id)
{
    rep(i,0,n+1)
    {
        dist[i][id] = -1;
        ways[i][id] = 0;
    }

    dist[root][id] = 0;
    ways[root][id] = 1;

    priority_queue < pi > pq;
    pq.push(mp(0,root));

    while(!pq.empty())
    {
        pi cur = pq.top();
        pq.pop();

        if(-cur.first > dist[cur.second][id])
            continue;

        rep(i,0,graph[cur.second].size())
        {
            ll v = graph[cur.second][i].first;
            c = graph[cur.second][i].second;

            if(dist[v][id] == -1 || dist[v][id] > dist[cur.second][id] + c)
            {
                dist[v][id] = dist[cur.second][id] + c;
                ways[v][id] = ways[cur.second][id];
                pq.push(mp(-dist[v][id],v));
            }
            else if(dist[v][id] == dist[cur.second][id]+c)
                ways[v][id] = (ways[v][id] + ways[cur.second][id])%mod;
        }
    }

    return;
}

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

    cin >> n >> m;
    cin >> s >> t;

    rep(i,0,m)
    {
        cin >> a >> b >> c;
        graph[a].push_back(mp(b,c));
        graph[b].push_back(mp(a,c));
        edges.push_back(mp(mp(a,b),c));
    }

    dijkstra(s,0);
    dijkstra(t,1);

    ll ans = (ways[t][0]*ways[s][1])%mod;
    ll S = dist[t][0];

    // meet at vertex

    rep(i,1,n+1)
    {
        if(dist[i][0] == dist[i][1] && dist[i][0] + dist[i][1] == S)
        {
            ll paths = (ways[i][0]*ways[i][1])%mod;

            ans = (ans - (paths*paths)%mod + mod)%mod;
        }
    }

    // meet at edge

    rep(i,0,m)
    {
        ll u = edges[i].first.first;
        ll v = edges[i].first.second;
        c = edges[i].second;

        if(dist[u][0] + dist[v][1] + c == S)
        {
            if(dist[u][0] < S/2.0 && dist[v][0] > S/2.0)
            {
                //cout << "meet from " << u << " to " << v << endl;
                ll paths = (ways[u][0]*ways[v][1])%mod;
                ans = (ans - (paths*paths)%mod + mod)%mod;
            }
        }
        if(dist[v][0] + dist[u][1] + c == S)
        {
            if(dist[v][0] < S/2.0 && dist[u][0] > S/2.0)
            {
               // cout << "meet from " << v << " to " << u << endl;
                ll paths = (ways[u][1]*ways[v][0])%mod;
                ans = (ans - (paths*paths)%mod + mod)%mod;
            }
        }
    }

    cout << ans;

    return 0;
}

/*
5 6
1 5
1 2 1
1 3 1
2 4 1
3 4 1
4 5 1
1 5 100

5 7
1 5
1 2 1
1 3 1
3 4 1
3 5 2
5 2 2
5 4 1
2 4 1

6 7
1 5
1 2 1
1 3 1
2 4 1
3 4 1
4 5 2
5 6 1
6 4 1

7 8
1 5
1 2 1
1 3 1
2 4 1
3 4 1
7 4 1
7 6 1
6 5 1
7 5 2

*/


Measured memory_bytes: 32428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[3005][3005];
char a[3005],b[3005];
ll max(ll x, ll y)
{
    if(x>=y)return x;
    return y;
}
int main(void) {
	// your code goes here
	int n,k,i;
	int m;
	scanf("%s",&a);
	scanf("%s",&b);
	for(n=0;a[n];n++);
	for(m=0;b[m];m++);
	int j;
	for(i=1;i<=n;i++)
	{
	    for(j=1; j<=m;j++)
	    {
	        if(a[i-1] == b[j-1])dp[i][j]=dp[i-1][j-1] + 1;
	        else dp[i][j] =max(dp[i][j-1],dp[i-1][j]);
	    }
	}
	i = n;
	j = m;
	string ans  = "";
	while(i > 0 && j>0)
	{
	    
	        if(a[i-1]==b[j-1])
	   { ans += a[i-1];
	    i--;j--;
	    }
	    else {
	        if(dp[i-1][j] > dp[i][j-1])i--;
	        else j--;
	    }
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}



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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

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

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

void solve(){
	int n;
	string s;
  	cin>>n;
	map<string, int> mp;
	for(int i=0;i<n;i++){
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<"\n";
	cout<<"WA x "<<mp["WA"]<<"\n";
	cout<<"TLE x "<<mp["TLE"]<<"\n";
	cout<<"RE x "<<mp["RE"]<<"\n";
}

int main(){
	solve();
}

Measured memory_bytes: 3584
// @author: hzy
//#pragma G++ optimize("O3")

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <list>
#include <forward_list>
#include <stack>
#include <unordered_set>
#include <vector>
#include <limits.h>

#define DISPLAY_A 0

using namespace std;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    unsigned long long ans = 1, a;
    const unsigned long long MAX = 1e18;
    cin >> n;
    unsigned long long v[n];
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a == 0) {
            cout << 0 << endl;
            return 0;
        }
        v[i] = a;
    }
    for (int i = 0; i < n; i++) {
        if (ans > MAX / v[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans *= v[i];
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	vl s(n+1);
	FOR(i,0,n) s[i+1] = s[i] ^ a[i];
	
	ll m = 1 << 20;
	vl last_occ(m,-1), dp(m), sdp(m);

	vl zero_count(n+1);
	FOR(i,0,n) zero_count[i+1] = zero_count[i] + (s[i] == 0);

	FOR(i,0,n+1) {
		ll x = s[i];
		if (x > 0) {
			if (last_occ[x] >= 0) {
				ll cnt = zero_count[i] - zero_count[last_occ[x]];
				dp[x] = (dp[x] + cnt * sdp[x]) % MOD;
				sdp[x] = (sdp[x] + dp[x]) % MOD;
			} else {
				dp[x] = sdp[x] = 1;
			}
		}
		last_occ[x] = i;
	}
	
	if (s[n] > 0) {
		cout << dp[s[n]] << endl;
	} else {
		ll res = 1;
		FOR(i,0,zero_count[n]-1) res = 2*res % MOD;
		
		FOR(x,0,m) if (last_occ[x] >= 0) res = (res + sdp[x]) % MOD;
		cout << res << endl;
	}

}



Measured memory_bytes: 36608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  ll K;
  cin >> K;
  ll i = 1;
  ll current_ll = 0;
  while (K > 0) {
    vec N;
    ll icopy = i;
    while (icopy > 0) {
      N.push_back(icopy % 10);
      icopy /= 10;
    }
    if (N.size() == 1) {
      K--;
      current_ll = i;
      i++;
      continue;
    }
    IFOR(j, N.size(), 1) {
      if (abs(N[j] - N[j - 1]) > 1) {
        i += pow(10, j - 1);
        break;
      }
      if (j == 1) {

        K--;
        current_ll = i;
        i++;
      }
    }
  }

  cout << current_ll << endl;

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int	line1[3];
	int	line2[3];
	int	line3[3];
	int	diff1 = 0;
	int	diff2 = 0;
	int	diff3 = 0;

	scanf("%d %d %d", &line1[0], &line1[1], &line1[2]);
	scanf("%d %d %d", &line2[0], &line2[1], &line2[2]);
	scanf("%d %d %d", &line3[0], &line3[1], &line3[2]);

	for (int i = 0; i < 2; i++)
	{
		diff1 = line1[i] - line1[i + 1];
		diff2 = line2[i] - line2[i + 1];
		diff3 = line3[i] - line3[i + 1];
		if (!(diff1 == diff2 && diff1 == diff3 && diff2 == diff3))
		{
			printf("No\n");
			return (0);
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#define INF 200000000
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> Q;
int w[2],h[2],x[2],y[2];
int cos[2][500][500];
int d[2][500][500];
int dx[4]={-1,0,0,1};
int dy[4]={0,1,-1,0};
vector<int> m[2];
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
void calc(int n){
	int i,j;
	for(i=0;i<h[n];i++)for(j=0;j<w[n];j++)d[n][i][j]=INF;
	d[n][y[n]][x[n]]=1;
	priority_queue< Q,vector<Q>,greater<Q> > que;
	que.push(Q(1,P(y[n],x[n])));
	while(!que.empty()){
		Q q=que.top();que.pop();
		P p=q.second;
		if(q.first>d[n][p.first][p.second])continue;
		for(i=0;i<4;i++){
			int nx=p.first+dx[i];
			int ny=p.second+dy[i];
			if(nx>=0&&nx<h[n]&&ny>=0&&ny<w[n]){
				int cost=max(cos[n][nx][ny],d[n][p.first][p.second]);
				if(d[n][nx][ny]>cost){
					d[n][nx][ny]=cost;
					que.push(Q(cost,P(nx,ny)));
				}
			}
		}
	}
}
int main(){
	int r;
	int i,j,k;
	while(1){
	scanf("%d",&r);
	if(r==0)return 0;
	m[0].clear();
	m[1].clear();
	for(i=0;i<2;i++){
		scanf("%d %d %d %d",&w[i],&h[i],&x[i],&y[i]);
		x[i]--;y[i]--;
		for(j=0;j<h[i];j++){
			for(k=0;k<w[i];k++)scanf("%d",&cos[i][j][k]);
		}
	}
	calc(0);
	calc(1);
	for(i=0;i<2;i++){
		m[i].push_back(0);
		for(j=0;j<h[i];j++){
			for(k=0;k<w[i];k++)m[i].push_back(d[i][j][k]);
		}
		sort(m[i].begin(),m[i].end());
	}
	int ans=INF;
	for(i=0;i<=r;i++){
		if(i>w[0]*h[0])break;
		if(r-i>w[1]*h[1])continue;
		int a,b;
		a=m[0][i];
		if(r-i<0)b=0;
		else b=m[1][r-i];
		ans=min(ans,a+b);
	}
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 7508
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int n = sc.nextInt();
		//String[][] array = new String[100][500];
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int c = Math.abs(a-b);
		if(c%2==0) {
			if(a<b) {
				System.out.println(a+c/2);
			}
			else {
				System.out.println(a-c/2);
			}

		}
		else {
			System.out.println("IMPOSSIBLE");
		}
	}

}

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

using namespace std;

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

	typedef vector<int> IntVector;
	IntVector a(n, 0);

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

	IntVector::const_reverse_iterator ritEnd = a.rend();
	for (IntVector::const_reverse_iterator rit = a.rbegin(); rit != ritEnd; ++rit)
	{
		cout << *rit;
		if (rit == ritEnd - 1)
			cout << endl;
		else
			cout << " ";
	}

	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int sum,n;
    int ans=0,x;
    scanf("%d %d",&sum,&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        ans+=x;
    }
    if(ans>=sum){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	string s;
	bool found = 0;

	cin >> s;
	
	for (int i = 0; i < s.size(); ++i) {
		if (i + 1 < s.size() && s[i] == s[i + 1]) {
			found = 1;
			cout << i + 1 << " " << i + 2 << endl;
			break;
		}

		if (i + 2 < s.size() && s[i] == s[i + 2]) {
			found = 1;
			cout << i + 1 << " " << i + 3 << endl;
			break;
		}
	}

	if (!found) {
		cout << "-1 -1" << endl;
	}

	return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  vector<ll> v;
  v.push_back(abs(a1 - a2));
  v.push_back(abs(a1 - a3));
  v.push_back(abs(a3 - a2));
  sort(all(v));
  ll ans = v.at(0) + v.at(1);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#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()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> X(n), Y(n);
  vector<char> U(n);
  map<char, vector<pair<ll, ll>>> mp;
  rep(i, n) {
    cin >> X[i] >> Y[i] >> U[i];
    mp[U[i]].push_back({X[i], Y[i]});
  }
  ll ans = longinf;
  {
    map<ll, vector<pair<ll, char>>> mpv;
    for(auto ele: mp['U']) mpv[ele.first].push_back({ele.second, 'U'});
    for(auto ele: mp['D']) mpv[ele.first].push_back({ele.second, 'D'});
    for(auto& ele: mpv) {
      auto& v = ele.second;
      sort(all(v));
      if(v.size() > 1) {
        rep(i, v.size()-1) {
          if(v[i].second=='U' && v[i+1].second=='D') {
            ans = min((v[i+1].first-v[i].first)*5, ans);
          }
        }
      }
    }
  }
  {
    map<ll, vector<pair<ll, char>>> mpv;
    for(auto ele: mp['R']) mpv[ele.second].push_back({ele.first, 'R'});
    for(auto ele: mp['L']) mpv[ele.second].push_back({ele.first, 'L'});
    for(auto& ele: mpv) {
      auto& v = ele.second;
      sort(all(v));
      if(v.size() > 1) {
        rep(i, v.size()-1) {
          if(v[i].second=='R' && v[i+1].second=='L') {
            ans = min((v[i+1].first-v[i].first)*5, ans);
          }
        }
      }
    }
  }
  vector<pair<char, char>> P = {{'R', 'U'}, {'U', 'L'}, {'L', 'D'}, {'D', 'R'}};
  rep(k, 4) {
    map<ll, vector<pair<ll, char>>> mpv;
    char c1 = P[k].first, c2 = P[k].second;
    for(auto ele: mp[c1]) {
      ll x = ele.first-100000, y = ele.second-100000;
      rep(i, k) { // rotate 90 deg
        ll nx = y, ny = -x;
        x = nx, y = ny;
      }
      x += 100000, y += 100000;
      mpv[x+y].push_back({x, c1});
    }
    for(auto ele: mp[c2]) {
      ll x = ele.first-100000, y = ele.second-100000;
      rep(i, k) { // rotate 90 deg
        ll nx = y, ny = -x;
        x = nx, y = ny;
      }
      x += 100000, y += 100000;
      mpv[x+y].push_back({x, c2});
    }
    for(auto& ele: mpv) {
      auto& v = ele.second;
      sort(all(v));
      if(v.size() > 1) {
        rep(i, v.size()-1) {
          if(v[i].second==c1 && v[i+1].second==c2) {
            ans = min((v[i+1].first-v[i].first)*10, ans);
          }
        }
      }
    }
  }
  if(ans == longinf) cout << "SAFE" << "\n";
  else               cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 31160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll N;
    ll ans = 1e12;
    cin >> N;
    for(ll i = 1; i * i <= N; i++) {
        if(N % i == 0) {
            ans = min(ans, i + N / i - 2);
        }
    }

    cout << ans << endl;
}


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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	ll a, b;
	string s;

	cin >> a >> s;
	b = atoi(s.erase(s.find("."), 1).c_str());

	cout << (a * b / 100) << endl;

	return 0;
}


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

int N, W, v[100], w[100], dp[101][10001];

int main() {
  cin >> N >> W;
  for (int i = 0; i < N; i++) {
    cin >> v[i] >> w[i];
  }
  for (int i = 0; i < W; i++) {
    dp[0][i] = 0;
  }

  for (int i = 0; i < N; i++) {    // i 番目以降の品物
    for (int j = 0; j <= W; j++) { // j 以下の重さ
      if (w[i] <= j) {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }

  cout << dp[N][W] << '\n';

  return 0;
}


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

int main() {
    int n;
    bool is_four = false;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s[0] == 'Y') {
            is_four = true;
            break;
        }
    }

    if (is_four == true) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	string s;
	cin >> s;
	sort(s.begin(),s.end());
	if(s[0]=='A'&&s[2]=='B')
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}

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

ll fe(ll a, ll b) {
	if (b == 0) return 1;
	ll h = fe(a, b/2);
	if (b%2 == 0) return h*h%M;
	else return (h*h%M)*a%M;
}

int main() {
	int x; cin>>x;
	cout<<(fe(10,x) + fe(8,x) - 2*fe(9,x) + 2*M)%M<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int k, a, b;

	cin >> k >> a >> b;

	long long ans = 1;
	long long money = 0;

	for (int i = 0; i < k; i++) {
		if (money == 0 && ans >= a && b - a > 2 && i != k - 1) {
			ans -= a;
			money++;
		}
		else if (money == 1) {
			money--;
			ans += b;
		}
		else {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int k, x;
    cin >> k >> x;
    for(int i = x-k+1; i < x+k; i++){
        cout << i << " ";
    }
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define tezi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define ll long long
#define ull unsigned long long
#define traverse(c,it) for(auto it=c.begin();it!=c.end();it++)
#define lowerb(v,a) lower_bound(v.begin(),v.end(),a)
#define lowerbarr(v,n,a) lower_bound(v,v+n,a)
#define upperb(v,a) upper_bound(v.begin(),v.end(),a)
#define upperbarr(v,n,a) upper_bound(v,v+n,a)
#define maxval(v) max_element(v.begin(),v.end())
#define maxarr(v,n) max_element(v,v+n)
#define minval(v) min_element(v.begin(),v.end())
#define minarr(v,n) min_element(v,v+n)
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define mem0(v) memset(v,0,sizeof(v))
#define memf(v) memset(v,false,sizeof(v))
#define memt(v) memset(v,true,sizeof(v))
#define mem(v,a) memset(v,a,sizeof(v))
#define npos string::npos
#define MAX 10000000
#define MOD 1000000009
                    /**************SIEVE****************/

/*bool prime[MAX+1];
vector<int> v;
void sieve(){ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true.
   
    memset(prime, true, sizeof(prime)); 
  
    for (long p=2; p*p<=MAX; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (long i=p*p; i<=MAX; i += p) 
                prime[i] = false; 
        } 
    } 
  for(int i=0;i<=MAX;i++)if(prime[i])v.pb(i);
  
   
    
   
} 
 
                                        /**************gcd****************/

ll gcd(ll a,ll b) 
{ if(a>b)swap(a,b);
    if (a == 0) 
        return b; 
   return gcd(b%a, a); 
}
 
 
 
                                         /**************POWER****************/
 ll binpow(ll a, ll b) {
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2)%MOD;
    if (b % 2)
        return ((ull)res * (ull)res * (ull)a)%MOD;
    else
        return ((ull)res * (ull)res)%MOD;
}
   

 
 
 
 
                                     /**************MAIn****************/





int main()
{   tezi
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("put.txt","w",stdout);
  #endif

  int T=1;
  //cin>>T;
  
  
  while(T--)
  {ll n;
    cin>>n;
    ll a[n];
    loop(i,0,n)cin>>a[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
      dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];

      



    

  }
  
  
   
    
    
    
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";

    

}
  
   




   
   

    
 
   
  

 
   
 
 
 
 
 
  
 
 

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

const int INF = 1e9;

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> c(10, vector<int>(10));
	rep(i, 10) rep(j, 10) cin >> c[i][j];
	rep(k, 10) rep(i, 10) rep(j, 10) {
		c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
	}
	int ans = 0;
	rep(i, h) rep(j, w) {
		int a;
		cin >> a;
		if (a >= 0) ans += c[a][1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll dp[MAX];
vi v;
int main()
{
	int n;
	cin>>n;
	string a,b;
	cin>>a>>b;
	for(int i=0;i<n;i++)
	{
		if(a[i]==b[i])
			v.pb(1);
		else
		{
			i++;
			v.pb(0);
		}
		//cout<<v[v.size()-1]<<endl;
	}
	if(v[0]==0)
		dp[0]=6;
	else
		dp[0]=3;
	for(int i=1;i<v.size();i++)
	{
		if(v[i]==0)
		{
			if(v[i-1]==1)
			dp[i]=2*dp[i-1];
			else
				dp[i]=3*dp[i-1];
			dp[i]%=MOD;
		}
		else
		{
			if(v[i-1]==0)
			dp[i]=dp[i-1];
			else
				dp[i]=2*dp[i-1];
			dp[i]%=MOD;
		}
		//cout<<dp[i]<<endl;
	}
	cout<<dp[v.size()-1]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

struct Info{
	Info(){
		L = a = b = 0.0;
	}
	double L,a,b;
};


int main(){

	int N,M,limit,count;

	scanf("%d %d",&N,&M);

	int work[M],work_index;
	limit = pow(2,N);
	Info info[N];

	double maximum = 0.0,tmp_sum;

	for(int i = 0; i < N; i++){
		scanf("%lf %lf %lf",&info[i].L,&info[i].a,&info[i].b);
	}

	for(int i = 0; i < limit; i++){
		count = 0;
		for(int k = 0; k < N; k++){
			if(i & (1 << k))count++;
		}
		if(count != M)continue;

		work_index = 0;
		for(int k = 0; k < N; k++){
			if(i & (1 << k)){
				work[work_index++] = k;
			}
		}

		tmp_sum = 0;

		for(int a = 0; a < work_index-1;a++){
			for(int b = a+1; b < work_index;b++){
				tmp_sum += (info[work[a]].L-info[work[b]].L)*(info[work[a]].L-info[work[b]].L)+(info[work[a]].a-info[work[b]].a)*(info[work[a]].a-info[work[b]].a)
						+(info[work[a]].b-info[work[b]].b)*(info[work[a]].b-info[work[b]].b);
			}
		}

		maximum = max(maximum,tmp_sum);
	}

	printf("%.10lf\n",maximum);

	return 0;
}

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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a * b == 15)
		cout << "*" << endl;
	else if (a + b == 15)
		cout << "+" << endl;
	else
		cout << "x" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	private static int calculate(String date) {
		Deque<Integer> d1 = new ArrayDeque<>();
		//数字入栈，操作符入栈，一个操作符取出两个数组计算
		String sc = "+-*/";
		for (String s : date.split(" ")) {
			
			if (sc.indexOf(s) == -1) {
				//System.out.println(s);
				d1.push(Integer.valueOf(s));
			}
				
			else {
				Integer i2 = d1.pop();
				Integer i1 = d1.pop();
				switch(s) {
				case "+": d1.push(i1 + i2); break;
				case "-": d1.push(i1 - i2);break;
				case "*": d1.push(i1 * i2);break;
				case "/": d1.push(i1 / i2);break;
				}
				//System.out.println(d1);
		}
			
		}
		return d1.pop();
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//System.out.println(Integer.valueOf('0'));
		String date = scan.nextLine();
		System.out.println(calculate(date));
	}
}



Measured memory_bytes: 26236
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var left = new long[ai.Length + 1];
            var right = new long[ai.Length + 1];
            for (int i = 0, j = ai.Length - 1; i < ai.Length && j >= 0; i++, j--)
            {
                left[i + 1] = GCD(left[i], ai[i]);
                right[j] = GCD(right[j + 1], ai[j]);
            }
            var gcds = new long[ai.Length];
            for (var i = 0; i < gcds.Length; i++)
            {
                gcds[i] = GCD(left[i], right[i + 1]);
            }

            Console.WriteLine(gcds.Max());
        }

        static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    }
}


Measured memory_bytes: 30044
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string ans = "ABC";
    if (n >= 1000) ans = "ABD";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m,a[100011]={},b,c;
	cin>>n>>m;
	int mx=0;
	cin>>b;
	FOR(i,1,n){
		cin>>c;
		int t=c-b;
		mx+=t;
		if(mx>0)a[i-1]=mx;
		else{
			a[i-1]=0;
			mx=0;
		}
		b=c;
	}
	sort(a,a+n-1);
	mx=a[n-2];
	int k=upper_bound(a,a+n-1,mx)-lower_bound(a,a+n-1,mx);
	cout<<k<<endl;
    return 0;
}


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int cnt =0;
  rep(i,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(){
  int r,x,d;
  scanf("%d%d%d",&r,&d,&x);
  int a[11];
  a[0]=x;
  for(int i=0;i<10;i++){
    a[i+1]=r*a[i]-d;
    printf("%d\n",a[i+1]);
  }
  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> H(N);
  rep(i, N) {
    cin >> H[i];
  }
  
  sort(H.begin(), H.end());
  
  long long kaisu = 0;
  if (H.size() > K) {
    rep(i, N-K) {
      kaisu += H[i];
    }
  } 
  
  
  cout << kaisu << endl;
}
  

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        int cntr = 0;
        for(int i = 0; i < n; i++){
            if(s.charAt(i) == 'R'){
                cntr++;
            }
        }
        int cnt = 0;
        for(int i= 0 ;i < cntr; i++){
            if(s.charAt(i) == 'R'){
                cnt++;
            }
        }
        System.out.println(cntr - cnt);
    }
}


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

int main()
{
	char c; int d,x=1,y=0;

	int dt[128][128]={0};
	while(cin >> d)
	{
		c=cin.get();

		dt[y][x]=d;
		if(c=='\n')
		{
			x=1; y++;
		}
		else
		{
			x++;
		}
	}

	int h=y;
	for(y=1; y<(h+1)/2; y++)
	for(x=1; x<y+2; x++)
	{
		dt[y][x] += max(dt[y-1][x-1],dt[y-1][x]);
	}

	for(; y<h; y++)
	for(x=1; x<h-y+1; x++)
	{
		dt[y][x] += max(dt[y-1][x],dt[y-1][x+1]);
	}
	
	cout << dt[h-1][1] << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    ll n, m, x, ans = 0;
    priority_queue <ll> pq;

    cin >> n >> m;

    while (n--) {

        cin >> x;
        pq.push(x);
    }

    while (m--) {

        ll t = pq.top();
        pq.pop();
        pq.push(t/2ll);
    }

    while (!pq.empty()) {

        ans += pq.top();
        pq.pop();
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        //int Nall = pow(fac(N));
        //int[][] matrixArray = new int[4][Nall];
        int alpha=0;
        int sum =0;

        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                for(int k=1;k<=N;k++){
                    //System.out.println(k);
                    alpha=gcd(i,j);
                    sum += gcd(alpha,k);
                }
            }
        }
        System.out.println(sum);
    }
    public static int fac(int N){
        if(N == 1){
            return 1;
        }else{
            return fac(N -1)*N;
        }
    }
    public static int pow(int N){
        return N*N*N;
    }
    public static int gcd(int a,int b){
        int c = a%b;
        if(c == 0){
            return b;
        }else{
            return gcd(b,c);
        }
    }
}

Measured memory_bytes: 35736
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

x=gets.to_i
if x==7 or x==5 or x==3
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
const int N=5e5+5;
int n,q;

ll bit[N];
void update(int i,ll x){
    i++;
    while(i<=n){
        bit[i]+=x;
        i+=(i&-i);
    }
}

ll query(int i){
    ll res=0;
    while(i>0){
        res+=bit[i];
        i-=(i&-i);
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>n>>q;
    for(int i=0;i<n;i++){
        ll x;cin>>x;
        update(i,x);
    }
    ll mode,x,y;
    while(q--){
        cin>>mode>>x>>y;
        if(mode==0){
            update(x,y);
        }
        else{
            cout<<query(y)-query(x)<<endl;
        }
    }
}


Measured memory_bytes: 8248
A, B, K = map(int, input().split())

value = []

if B - A < K or B <= K:
    value.extend([i for i in range(A, B+1)])
    
else:
    value.extend([i for i in range(A, A+K)])
    value.extend([i for i in range(B-K+1, B+1)])    

num = list(set(value))
num.sort()

for i in range(len(num)):
    print(num[i])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	vector<ll> A(N + 1), B(M + 1);
	FOR(i, 1, N + 1) cin >> A[i];
	FOR(i, 1, M + 1) cin >> B[i];

	REP(i, N) { A[i + 1] += A[i]; }
	REP(i, M) { B[i + 1] += B[i]; }

	ll ans = 0;
	int j = M;
	REP(i, N + 1) {
		if (A[i] > K) break;

		while (A[i] + B[j] > K) j--;
		if (i + j > ans) ans = i + j;
	}

	cout << ans << endl;
	return 0;
}

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

import itertools

n, m = map(int, input().split())

dests = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    dests[a-1].append(b-1)
    dests[b-1].append(a-1)

res = 0
p =  list(itertools.permutations(range(n)))

for l in p:
    if l[0] != 0: continue
    flg = True
    for i in range(n-1):
        if not(l[i+1] in dests[l[i]]):
            flg = False
            break

    if flg == True: res += 1

print(res)


Measured memory_bytes: 8052
N, X = map(int, input().split())

Total = [1]
Patties = [1]

for i in range (1, N+1):
	Total.append(Total[i-1]*2+3)
	Patties.append(Patties[i-1]*2+1)

def Burger(N,X):
	if N== 0:
		if X <= 0:
			return (0)
		else:
			return (1)
	elif X <= 1+Total[N-1]:
		return Burger(N-1, X-1)
	else:
		return Patties[N-1]+1+Burger(N-1, X-2-Total[N-1])

print(Burger(N,X))

Measured memory_bytes: 9012
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi v(n);
    vp a(100001),b(100001);
    rep(i,n){
        cin>>v[i];
        int t;
        if(i%2){
            t=b[v[i]].fi;
            b[v[i]]=mp(t+1,v[i]);
        }
        else{
            t=a[v[i]].fi;
            a[v[i]]=mp(t+1,v[i]);
        }
    }
    sort(all(a));
    sort(all(b));
    reverse(all(a));
    reverse(all(b));
    if(a[0].se==b[0].se){
        cout<<n-max(a[0].fi+b[1].fi,a[1].fi+b[0].fi)<<endl;
    }
    else{
        cout<<n-a[0].fi-b[0].fi<<endl;
    }
}

Measured memory_bytes: 4224
from sys import exit
from math import gcd
n = int(input())
a = list(map(int, input().split()))
g = gcd(a[0], a[1])
for i in range(2, n):
	g = gcd(g, a[i])
if g > 1:
	print("not coprime")
	exit()

MAX = 1000001
nxt = [i for i in range(MAX)]
for i in range(2, MAX):
	if nxt[i] < i:
		continue
	for j in range(i, MAX, i):
		nxt[j] = min(nxt[j], i)

fac = set()
ok = True
for x in a:
	tmp = set()
	while x > 1:
		tmp.add(nxt[x])
		x //= nxt[x]
	for p in tmp:
		if p in fac:
			ok = False
			break
		fac.add(p)
	if not ok:
		break
print("pairwise coprime" if ok else "setwise coprime")

Measured memory_bytes: 204556
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;



int main()
{
	int n;
	cin >> n;
	queue<int> a;
	int destroy = 0;

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		a.push(tmp);
	}
	int number = 1;

	while (!a.empty()) {
		if (a.front() == number) {
			number++;
		} else {
			destroy++;
		}
		a.pop();
	}

	printf("%d", number == 1 ? -1 : destroy);

	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
    int maxplus = 0;
    int result = 0;
    for (int i=0; i<5; i++) {
        int a;
        cin >> a;
        int aplus = ((a%10 == 0)? 0 : 10 - a%10);
        maxplus = max(aplus, maxplus);
        result += a + aplus;
    }
    cout << result - maxplus << endl;
}

Measured memory_bytes: 3684
fun main(args:Array<String>) {
    val (a,b,k) = readLine()!!.split(" ").map { it.toInt() }
    var idx = 1
    for(i in (1..100).reversed()) {
        if(a%i == 0 && b % i == 0) {
            if(idx == k) {
                println(i)
                return
            }
            idx++
        }
    }
}


Measured memory_bytes: 37856
#include<stdio.h>
#include<math.h>

int main(void){
	long long a,b,c;
	long double S;
	scanf("%lld",&a);
	scanf("%lld",&b);
	scanf("%lld",&c);
	S=sqrtl(a*b);
	if(a+b+2*S<c)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256