akhauriyash/Code-Regression huggingface dataset:
n = str(input())
d = []
p = []
i = 1
s = 1
l = 1
for k in n:
 if i % 2 == 0:
  if k == "L" or k == "U" or k == "D":
   pass
  else:
   s = 0
 else:
  if k == "R" or k == "U" or k == "D":
   pass
  else:
    l = 0
 i = i + 1
#print(s,l)
if s and l == 1:
 print("Yes")
else:
 print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<int,int>
#define mp make_pair
using namespace std;
int n,m,A,B;
int a[5005][5005];
int main() {
    cin>>n>>m>>A>>B;
    for(int i=0;i<B;i++)
    {
        for(int j=0;j<A;j++)
            a[i][j] = 1;
    }
    for(int i=B;i<n;i++)
    {
        for(int j=A;j<m;j++)
        {
            a[i][j] = 1;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {printf("%d",!a[i][j]);}
        cout<<endl;
    }
    return 0;
}
/*
1 1 1 1
0 0 0 0
1 1 1 1
0 0 0 0
 */


Measured memory_bytes: 20480
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0596"

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif

#undef call_from_test

vector<int> bfs(int s,vector< vector<int> > G){
  int n=G.size();
  vector<int> dp(n,-1);
  queue<int> que;
  dp[s]=0;
  que.emplace(s);
  while(!que.empty()){
    int v=que.front();que.pop();
    for(int u:G[v]){
      if(~dp[u]) continue;
      dp[u]=dp[v]+1;
      que.emplace(u);
    }
  }
  return dp;
}

signed main(){
  int n,k;
  cin>>n>>k;

  vector<int> cs(n),rs(n);
  for(int i=0;i<n;i++) cin>>cs[i]>>rs[i];

  vector<vector<int> > G(n);
  for(int i=0;i<k;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }

  vector< vector<int> > di(n);
  for(int i=0;i<n;i++) di[i]=bfs(i,G);

  const int INF = 1e9;
  vector<int> dp(n,INF);
  vector<int> used(n,0);
  dp[0]=0;

  for(int i=0;i<n;i++){
    int u=-1;
    for(int j=0;j<n;j++){
      if(used[j]||dp[j]==INF) continue;
      if(u<0||dp[u]>dp[j]) u=j;
    }
    if(u<0) break;
    used[u]=1;
    for(int j=0;j<n;j++){
      if(di[u][j]>rs[u]) continue;
      chmin(dp[j],dp[u]+cs[u]);
    }
  }

  cout<<dp[n-1]<<endl;
  return 0;
}



Measured memory_bytes: 101264
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj),rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 30);
int n, m, sum; string s, t;
const ll MOD= 1000000007;
int main() {
    cin >> n; n %= 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon" << endl;
    }
    else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "bon" << endl;
    }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    int ans=m;
    rep(i,n-m+1){
        int cnt=0;
        for(int j=0;j<m;++j){
            if(s[j+i]==t[j])cnt++;
        }
        ans=min(ans,m-cnt);
    }
    cout<<ans<<endl;
}


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

int main(){
  long long int n,k;
  cin >> n >> k;
  long long int x=n/k;
  long long int y=n/(k/2)-x;
  if(k%2==0){
    cout << x*x*x+y*y*y << endl;
  }else{
    cout << x*x*x << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    vector <int> v;
    int k,n;
    cin>>k>>n;
    int m=n;
    while(n--)
    {
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    v.push_back(k+v[0]);
    a=0;
    for(int i=1;i<v.size();i++)
    {
        a=max(a,v[i]-v[i-1]);
    }
    a=k-a;
    cout<<a;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int A[114514];
    cin>>N;
    int plus=0,zero=0,minus=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if (A[i]>0){
            plus++;
        }
        else if(A[i]==0){
            zero++;
        }
        else{
            minus++;
        }
    }
    if (zero>0){
        long long int ans=0;
        for(int i=0;i<N;i++){
            ans+=abs(A[i]);
        }
        cout<<ans<<endl;
    }
    else{
        if (minus%2==0){
            long long int ans=0;
            for(int i=0;i<N;i++){
                ans+=abs(A[i]);
            }
            cout<<ans<<endl;
        }
        else{
            int m=abs(A[0]);
            long long int ans=0;
            for(int i=0;i<N;i++){
                ans+=abs(A[i]);
                m=min(m,abs(A[i]));
            }
            cout<<ans-2*m<<endl;
        }
    }
    return 0;
}


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

static const int N = 100;
static const int inf = (1 << 30);
static const int white = 0;
static const int gray = 1;
static const int black = 2;

int n, M[N][N];

void dijkstra(int s) {
	int color[N], d[N];
	for (int i = 0; i < n; i++) {
		color[i] = white;
		d[i] = inf;
		//p[n] = inf;
	}
	d[s] = 0;
	color[s] = gray;
	int u = -1;
	while (true) {
		int mincost = inf;
		for (int i = 0; i < n; i++) {
			if (color[i] != black && d[i] < mincost) {
				mincost = d[i];
				u = i;
			}
		}
		if (mincost == inf) {
			break;
		}
		color[u] = black;
		for (int v = 0; v < n; v++) {
			if (color[v] != black && M[u][v] != inf) {
				if (d[v] > d[u] + M[u][v]) {
					d[v] = d[u] + M[u][v];
					color[v] = gray;
					//p[v] = u;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == inf ? -1 : d[i]) << '\n';
	}
	//return  0;
}

int main() {
	int u, k, v, c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = inf;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			M[u][v] = c;
		}
	}
/*	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (M[i][j] == inf) {
				cout << -1  << " ";
			} else {
				cout << M[i][j] << " ";
			}
		}
		cout << '\n';
}
*/
	dijkstra(0);
	return 0;
}



Measured memory_bytes: 3120
#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((a + b) > (c + d)) cout << "Left" << endl;
  if ((a + b) == (c + d)) cout << "Balanced" << endl;
  if ((a + b) < (c + d)) cout << "Right" << endl;
}

Measured memory_bytes: 256
N,T=map(int,input().split())
W=[list(map(int,input().split())) for i in range(N)]
flag=0
cost=0
W.sort(key=lambda x:x[0])

for i in range(N):
    if (W[i][1]<=T):
        flag=1
        cost=W[i][0]
        break

if flag==1:
    print(cost)
else:
    print("TLE")

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <set>
#define pb push_back
#define tam 520004
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define ptr tre*
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
ll val[tam];
int main()
{
    ll n,t;
    cin>>n>>t;
    forr(i,0,n)
    {
        cin>>val[i];
    }
    ll tot=t;
    forr(i,0,n-1)
    {
        tot+=min(val[i+1]-val[i],t);
    }
    cout<<tot<<endl;
}


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

vector<pair<int, int>> A;
int32_t main(){
	int n;
	cin >> n;
	int sum_digit = 0, ans = 0;
	for(int i = 0; i < n; i++){
		int v1, v2;
		cin >> v1 >> v2;
		A.push_back({v1, v2});
		sum_digit += v1 * v2;
		ans += v2;
	}
	ans += (sum_digit - 1) / 9;
	cout << ans - 1 << endl;
}

Measured memory_bytes: 6384
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String answer = "";
        switch (str) {
            case "A":
                answer = "T";
                break;
            case "T":
                answer = "A";
                break;
            case "C":
                answer = "G";
                break;
            case "G":
                answer = "C";
                break;
        }
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define hell 100000000
using namespace std;

int main()
{
  IOS
  string s;
  cin>>s;
  ll i;
  for(i=0;i<3;i++)
  	if(s[i]==s[i+1])
  	{
  		cout<<"Bad";
  		return 0;
  	}
  	cout<<"Good";
  return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


struct UnionFind {  // UnionFind uni(N);
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N), siz(N, 1){ //最初は全てが根であるとして初期化、頂点数N
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        siz[ry] += siz[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) { // 素集合のサイズ
        return siz[root(x)];
    }
};




int main() {
    LL N,M;cin >> N >> M;
    vector<LL> A(M);
    vector<LL> B(M);
    rep(i,M){
        int a,b;cin >> a >> b;
        a--;b--;
        A[i] = a;
        B[i] = b;
    }

    UnionFind uni(N);

    LL ans = 0;
    rep(i,M){
        uni.unite(A[i],B[i]);
    }

    map<int,int> m;
    rep(i,N){
        int tmp = uni.root(i);
        if(m[tmp] == 0){
            m[tmp]++;
            ans++;
        }
    }

    cout << ans - 1 << endl;
}

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

#define                                 pai                                         acos(-1)
#define                                 ll                                          long long
#define                                 pb                                          push_back
#define                                 mp                                          make_pair
#define                                 pll                                         pair<ll,ll>
#define                                 sz(a)                                       (ll)a.size()
#define                                 endl                                        "\n"
#define                                 gcd(a, b)                                   __gcd(a, b)
#define                                 lcm(a, b)                                   (((a)*(b))/gcd(a,b))
#define                                 all(vec)                                    vec.begin(),vec.end()
#define                                 ms(a, b)                                    memset(a,b,sizeof(a))
#define                                 TEST_CASE(t)                                for(int www=1;www<=t;www++)
#define                                 PRINT_CASE                                  printf("Case %d: ",z)
#define                                 fii                                         freopen("input.txt","r",stdin);
#define                                 foo                                         freopen("output.txt","w",stdout);
#define                                 fast                                        ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll mod  = 1e9 +07;
const ll mxn  = 1e6 +10;

int  main()
{
    ll i,j,k,a,b,c,d=0,n,m,t,h,u,v,x,y,z;
    cin>>n>>m;
    set<ll>st;
    while(m--)
    {
        cin>>t;
        while(t--)
        {
            cin>>h;
            st.insert(h);
        }
    }
    ll cnt=0;
    for(i=1;i<=n;i++)
    {
        if(st.find(i)==st.end())
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 3616
n, m = list(map(int, input().split()))
par = list(range(n+1))
dis = [0] * (n+1)

def root(x):
  if x == par[x]:
    return x
  r = root(par[x])
  dis[x] += dis[par[x]]
  par[x] = r
  return r

def cost(x):
  # xからxの根までのコスト
  if x == par[x]:
    return 0
  return dis[x] + cost(par[x])

for _ in range(m):
  l, r, d = list(map(int, input().split()))
  # 根が違ってればマージ
  # 同じなら入力されたdistanceがこれまでの入力データからなる
  # 現在の木の構造から計算した数値とあっているか判断
  # rootl, rootr = root(l), root(r)
  # 確かめ用
  rootl = root(l)
  rootr = root(r)
  if rootl != rootr:
    if r != rootr:
      # 直接yにつなげる
      dis[rootl] = d - cost(l)
    else:
      # 根につなげる
      dis[rootl] = d - (cost(l) - cost(r)) # (dis[l] - dis[r])
    # ここで親を更新
    par[rootl] = r
  else:
    if d != cost(l) - cost(r):
      print("No")
      exit()

  """
  ちょっとなにがダメなのかわかんないので確かめる
  if rootl != rootr:
    # lをrにマージする
    if r == rootr:
      dis[rootl] = d - cost(l)
    else:
      dis[rootl] = d - (dis[l] - dis[r]) # (cost(l) - cost(r))
    par[rootl] = r
  else:
    # コストが同じかどうか
    if d == cost(l) - cost(r):
      continue
    else:
      print("No")
      exit()
  """
print("Yes")

Measured memory_bytes: 9456
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
const int INF = 1e9 + 5;
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> h(n);
    for (int& x : h) {
		scanf("%d", &x);
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j <= i + k; ++j) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	printf("%d\n", dp[n-1]);
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

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

  cout<< d[N/2]-d[N/2-1] << endl;
  


  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

void print_vector(vector<ll> vt){
    for(auto v: vt){
        cout << v;
    }
    cout << endl;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    ll MAX=a[0], tmp=a[0]/2;

    vector<bool> flag(1000000005, 0);
    for(int i=1; i<n; i++){
        if(tmp<a[i]){
            a[i]=MAX-a[i];
            flag[a[i]]=true;
        }
    }
    sort(a.begin()+1, a.end(), greater<ll>());
    cout << MAX << ' ';
    if(flag[a[1]]) cout << MAX-a[1];
    else cout << a[1];
    cout << endl;
    

    return 0;
}


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

int selectionSort(int A[], int N)
{
  int s = 0;
  for(int i = 0, minj; i < N; i++){
    minj = i;
    for(int j = i; j < N; j++)
      if(A[j] < A[minj])
	minj = j;
    if(i != minj){
      swap(A[i], A[minj]);
      s++;
    }
  }
  return s;
}
     

int main()
{
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++)
    cin >> A[i];
  int s = selectionSort(A, N);
  for(int i = 0; i < N; i++)
    if(i)
      cout << " " << A[i];
    else 
      cout << A[i];
  cout << endl << s << endl;
}

Measured memory_bytes: 1160
M,K = readline.chomp.split.map(&:to_i)

if M == 0
  if K == 0
    puts "0 0"
  else
    puts -1
  end
elsif M == 1
  if K == 0
    puts "0 1 1 0"
  else
    puts -1
  end
else
  if K < 2**M
    ans = []
    (2**M).times do |i|
      ans << i if i != K
    end
    a = ans + [K] + ans.reverse + [K]
    puts a.join(' ')
  else
    puts -1
  end
end



Measured memory_bytes: 11380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll h,m,n,i,s=0,j,k,l,a,p,x=0,y=0;
	cin>>n>>h;
	vector<ll> v;
	for(i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
	}
	sort(v.rbegin(),v.rend());
	for(i=h;i<v.size();i++)
	{
		s=s+v[i];
	}
	cout<<s;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h> 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vv = vector<vector<int>>;
using P = pair<int,int>;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt=0;
  for(int i=0;i<n;i++){
    if( i==0 ){
      cnt++;
      continue;
    }
    if( s.at(i) == s.at(i-1) ) continue;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 512
from itertools import permutations

N = int(input())
Ps = tuple(map(int, input().split()))
Qs = tuple(map(int, input().split()))

noP, noQ = 0, 0
for no, Rs in enumerate(permutations(range(1, N+1), r=N), start=1):
    if Ps == Rs:
        noP = no
    if Qs == Rs:
        noQ = no

print(abs(noP-noQ))


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

using namespace std;

int main() {
	string s;
	cin >> s;
	bool v[26] = {false};
	for (int i = 0; s[i] != '\0'; i++) {
		v[s[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; i++) {
		if(!v[i]) {
			cout << (char(i + 'a')) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<ll> divisors(ll n) {
    vector<ll> v;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i * i != n) {
                v.push_back(n / i);
            }
        }
    }
    return v;
}

void solve() {
    ll n;
    cin >> n;
    vl b(n + 1, 1);
    for (ll i = 2; i <= n; i++) {
        // if (b[i] != 0) continue;
        for (ll j = i; j <= n; j += i) b[j]++;
        // printv(b);
    }
    ll ans = 1;
    for (ll i = 2; i <= n; i++) ans += i * b[i];
    cout << ans << endl;

}


Measured memory_bytes: 81316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

template <typename T>
using Vec = std::vector<T>;

int main() {
	int n;
	std::string s;
	std::cin >> n >> s;

	Vec<Vec<int>> dp(n, Vec<int>(n, 0));

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

	for (int i = 1; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			const int v = dp[i - 1][j - 1];

			if (s[i] == s[j]) {
				if (i + v < j)
					dp[i][j] = v + 1;
				else
					dp[i][j] = v;
			}
		}
	}

	int ans = 0;
	for (auto&& vec : dp)
		ans = std::max(ans, *std::max_element(vec.begin(), vec.end()));

	std::cout << ans << std::endl;
}

Measured memory_bytes: 98176
N = input() 
S = input()

a = {}

for i in range(len(S)):
    m = S[i]
    if m in a:
        a[m] += 1
    else:
        a[m] = 1

n = 1
for i in a.values():
    n = n * (i + 1)
n -= 1

print(n % 1000000007)

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

int compare_char(const void *a, const void *b){
    return *(char*)a - *(char*)b;
}

int nextInt();
char nextChar();
int maxa(int a, int b){return a<b?b:a;}

int N, M, L, max, now, i, j;
int dp[10011];
char A[9];
char d[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(){
	N=nextInt();
	M=nextInt();
	for(i=0; i<M; i++){
		A[i]=nextChar();
	}
    qsort(A, M, sizeof(char), compare_char);
	dp[10] = 1;
	for(i=10, L=N+10; i<=L; i++){
		max = 0;
		for(j=0; j<M; j++){
			max = maxa(max, dp[i-d[A[j]]]);
		}
		if(max!=0){
			dp[i] = max+1;
		}
	}
	now = N+10;
	for(i=dp[N+10]-1; i>=1; i--){
		for(j=M-1; j>=0; j--){
			if(dp[now-d[A[j]]] == i){
				putchar('0'+A[j]);
				now -= d[A[j]];
				break;
			}
		}
	}
	putchar(10);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}
char nextChar(){
	char f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  int a, b;
  cin >> a >> b;
  if (a*b==1) {
    cout << "Draw";
  } else if (a==1&&b!=1) {
    cout << "Alice";
  } else if (a!=1&&b==1) {
    cout << "Bob";
  } else if (a==b) {
    cout << "Draw";
  } else if (a>b) {
    cout << "Alice";
  } else {
    cout << "Bob";
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())

def dig_sum(n):
    res = 0
    while(not n<10):
        res += n % 10
        n = n//10
    res += n
    return res

ans = 100000000000000
for A in range(2, 2+N//2):
    B = N - A
    tmp = dig_sum(A) + dig_sum(B)
    ans = min(ans, tmp)

print(ans)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD=1e9+7;
const ll inf=1e10;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

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

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

bool isVowel(char c){
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u')
		return true;
	return false;
}

const int sz=1e5+10;


int main()
{
    fast;
    
    ll t;
    //~ cin>>t;
    t=1;
    while(t--){
        ll n;
        cin>>n;
        
		ll a[n];
		for(int i=0;i<n;i++)cin>>a[i];
		
		ll dp[n+1]={};
		dp[2]=abs(a[1]-a[0]);
		for(int i=2;i<n;i++){
			dp[i+1]=min(dp[i]+abs(a[i]-a[i-1]),dp[i-1]+abs(a[i]-a[i-2]));
			//~ cout<<dp[i+1]<<endl;
		}
		cout<<dp[n];
	}
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int A1,A2,A3;
    
    scanf("%d %d %d",&A1,&A2,&A3);
    
    if (A1+A2+A3 >= 22) {
        printf("bust\n");
    } else{
        printf("win\n");
    }
    
    return 0;
}


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

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	long long n,zb=0;
	cin >> n;
	for (long long i=1;i<=n;i++)
    {
	    if(i%3!=0 && i%5!=0)
            zb+=i;
    }
	cout << zb;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> P;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int n;
cin >> n;
rep(i,n){
    int a;
    cin >> a;
    if(a%2==0){
        if(a%3!=0&&a%5!=0){
            fin("DENIED");
            return 0;
        }
    }
}
fin("APPROVED");

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

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

    --n;
    cout << n * (n + 1) / 2 << endl;

    return 0;
}


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

int main() {
  string N, result ="Yes";
  cin >> N;
  int n = 0, i = 0, num = 0;
  char ca;
  
  for (char c: N) {
    if (i == 0){
      ca = c;
      i++;
    }
    if (c != ca) {
      if (num == 2) {
        result = "No";
        break;
      }
      n++;
      ca = c;
    }
    else {
      num++;
    }
    if (n > 1) {
      result = "No";
      break;
    }
  }
  cout << result << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n,i;cin>>n>>i;
    cout<<n-i+1<<endl;
    return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long K, std::string S){

    if(S.size()<=K)cout<<S<<endl;
    else{
        REP(i,0,K)cout<<S[i];
        cout<<"...";
        cout<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    func(K, S);
    return 0;
}


Measured memory_bytes: 3692
N, K = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))

before = 1
start = 0
end = 0

if K <= N:
    for i in range(K):
        before = a[before]
    print(before)

# 周期がどこからどこまでかっていうのを求めると逆に時間がかかってしまうので、N回移動したあとの街っていうのをマークしたほうがはやい
    
else:
    market_town = 0
    for i in range(N):
        before = a[before]
    marked_town = before
    K -= N
    counter = 1
    while marked_town != a[before]:
        before = a[before]
        counter += 1
    K = K % counter
    for i in range(K+1):
        before = a[before]
    print(before)

Measured memory_bytes: 32200
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using namespace std;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif


bool col[8] = {};
int ans = 0;
int N, a, MAX;
int ov = 0;

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

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a;
		if(a > 3199){
			ov++;
		}else if( !(col[a/400]) ){
			col[a/400] = true;
			ans++;
		}
	}
	MAX = ans+ov;
	if(ans == 0) ans++;
	cout << ans << " " << MAX;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int r, c;
    while(true){
        cin >> r >> c;
        if(r + c == 0) break;
        
        if(r * c % 2 == 0) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 2992
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int key = scan.nextInt();
        String text = scan.next();
        String ans = "";
        for(int i=0; i<text.length(); i++){
            int a = (text.charAt(i) + key);
            if(a>=91)a-=26;
            char b = (char)a;
           ans = ans + String.valueOf(b);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 149588
program main
  implicit none
  integer :: k, a, b
  read *, k
  read *, a, b
  if (possible(k, a, b)) then
    print "(a)", "OK"
  else
    print "(a)", "NG"
  end if
  contains
  logical function possible(k, a, b)
    integer, intent(in) :: k, a, b
    integer :: i
    possible = .false.
    do i = a, b
      if (modulo(i, k) == 0) possible = .true.
    end do
  end function possible
end program main


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

int main(){
  char A,B;
  cin >> A >> B;
  if (A > B){
    cout << '>' << endl;
  }
  else if (A < B){
    cout << '<' << endl;
  }
  else {
    cout << '=' << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ull unsigned long long
#define ll long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define sz size()
#define db double
#define pb push_back
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
using namespace std;
struct Data
{
    int a;
    int b;
    int c;
};
int main()
{
    int n;
    cin >> n;
    Data d[n+1],h[n+1];
    for(int i=1;i<=n;i++)
    {
        int x,y,z;
        cin >> x >> y >> z;
        h[i].a=x;
        h[i].b=y;
        h[i].c=z;
    }
    d[1]=h[1];
    for(int i=2;i<=n;i++)
    {
        d[i].a=h[i].a+max(d[i-1].b,d[i-1].c);
        d[i].b=h[i].b+max(d[i-1].c,d[i-1].a);
        d[i].c=h[i].c+max(d[i-1].a,d[i-1].b);
    }
    cout << max(d[n].a,max(d[n].b,d[n].c)) << endl;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  string s;
  cin >> s;
  if(s=="SUN")cout << 7;
  else if(s=="MON")cout << 6;
  else if(s=="TUE")cout << 5;
  else if(s=="WED")cout << 4;
  else if(s=="THU")cout << 3;
  else if(s=="FRI")cout << 2;
  else if(s=="SAT")cout << 1;
}




Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	
	int A,B;
	char op;
	cin>>A>>op>>B;
	switch(op)
	{
		case'+':
		cout<<A+B;
		break;
		case'-':
		cout<<A-B;
		break;
	
	}
	
		return 0;
}

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

#define whole(xs) (xs).begin(),(xs).end()
#define uniq(xs) ((xs).erase(unique((xs).begin(), (xs).end()), (xs).end()))

int N;
string s, t;

bool input() {
    cin >> N;
    if (N == 0) return false;
    cin >> s >> t;
    return true;
}

const int INF = 20;

int dfs(int index, vector<int>& ds) {
    if (index == N) return 0;
    int ret = INF;
    int d = ds[index];
    if (d == 0) { return dfs(index + 1, ds); }
    vector<int> backup = ds;
    for (int i = index; i < N; i++) {
        ds[i] = (ds[i] + 10 - d) % 10;
        ret = min(ret, dfs(index + 1, ds) + 1);
    }
    ds = backup;
    return ret;
}

void solve() {
    vector<int> ds;
    for (int i = 0; i < N; i++) {
        int a = int(s[i] - '0');
        int b = int(t[i] - '0');
        ds.push_back( (a + 10 - b) % 10 );
    }
    cout << dfs(0, ds) << endl;
}

int main() {
    while (input()) solve();
    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b>c*d){
    cout<<a*b<<endl;
  }
  else{
    cout<<c*d<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,m,x,a[100];
	int i,j=0,k,count=0,min=100;
	
	scanf("%d %d %d",&n,&m,&x);
	for(k=0;k<m;k++){
		scanf("%d",&a[k]);
	}	
	
	for(i=0;i<=x;i++)
		for(j=0;j<k;j++){
			if(i == a[j]){
				count++;
				break;
			}
		}
		
	if(min > count)
		min = count;
	
	count = 0;
	i--;
	
	for(;i<=n;i++)
		for(j=0;j<=k;j++){
			if(i == a[j]){
				count++;
				break;
			}
		}
		
	if(min > count)
		min = count;
		
	printf("%d\n",min);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll dp[2050][2050];

int main(){
    int n; cin >> n;
    vector<Pl> a(n);
    rep(i,n) cin >> a[i].first,a[i].second = i;
    sort(a.rbegin(),a.rend());
    rep(i,2050)rep(j,2050) dp[i][j] = -1;
    dp[0][0] = 0;
    rep(i,n){
        rep(j,i+1){
            if(dp[i][j] == -1) continue;
            int n1 = n-j-1;
            int n2 = i-j;
            if(n1-a[i].second >= 0) dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+(n1-a[i].second)*a[i].first);
            if(a[i].second-n2 >= 0) dp[i+1][j] = max(dp[i+1][j],dp[i][j]+(a[i].second-n2)*a[i].first);
        }
    }
    ll ans = 0;
    rep(i,n+1){
        ans = max(ans,dp[n][i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 36444
#pragma region Include/Defines
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <limits.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>
#include <cassert>
#include <map>
#include <set>
#include <iostream>
#include <queue>
#include <time.h>

using namespace std;
typedef long long lli;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<pii> vpii;
typedef vector <pll> vpll;
typedef long double ld;
#define all(a) std::begin(a), std::end(a)

const int INF = 0x3f3f3f3f;
const lli LINF = 0x3f3f3f3f3f3f3f3f;

template<typename T, typename T2> inline void _max(T &a, T2 b) { a = max((T)a, (T)b); }
template<typename T, typename T2> inline void _min(T &a, T2 b) { a = min((T)a, (T)b); }

#ifdef _DEBUG
#define epr(...) fprintf(stderr,__VA_ARGS__)
#else
#define epr(...) 
#endif
#pragma endregion

int x, a, b;

void clear() {
}

void read() {
}

void solve() {
	int d = a - b;
	if (d >= 0) printf("delicious\n");
	else if (abs(d) <= x) printf("safe\n");
	else printf("dangerous\n");
}

int main() {
#ifdef _LOCAL_VAN
	freopen("in.txt", "r", stdin);
#endif
	while (scanf("%d%d%d", &x, &a, &b) == 3) {
		clear();
		read();
		solve();
#ifndef _LOCAL_VAN
		return 0;
#endif
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
s = input().strip()

from collections import deque

red_pos = deque([])
white_pos = deque([])
for i, v in enumerate(s):
    if v == 'R':
        red_pos.append(i)
    else:
        white_pos.append(i)

ans = 0
while True:
    if len(red_pos) == 0 or len(white_pos) == 0:
        break
    if red_pos[-1] < white_pos[0]:
        break
    ans += 1
    white_pos.popleft()
    red_pos.pop()

print(ans)


Measured memory_bytes: 73156
def chk_fizzbuzz(i):
    if i % 3 == 0 or i % 5 == 0 or i % 15 == 0:
        return 0
    else:
        return i

N = int(input().rstrip())
ret = 0
for i in range(N+1):
    ret += chk_fizzbuzz(i)
print(ret)


Measured memory_bytes: 9164
#include<stdio.h>
#include<math.h>
inline void read(int&x)
{
	register bool t=0;register char c=getchar();for(;c<'0'||'9'<c;t|=c=='-',c=getchar());
	for(x=0;'0'<=c&&c<='9';x=(x<<3)+(x<<1)+(c^48),c=getchar());if(t)x=-x;
}
int n,d,x,y,ans;
main()
{
	for(read(n),read(d);n--;)
	{
		read(x);read(y);
		if(sqrt(1ll*x*x+1ll*y*y)<=d)++ans;
	}
	printf("%d",ans);
}

Measured memory_bytes: 2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) {return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1;}


ll nck(int n, int k) {
    ll ret = 1;
    rep(j, k) { ret *= n - j; ret /= j + 1; }
    // 先にまとめてかけて後でまとめて割るとオーバーフロー
    return ret;
}

ll solve(int n, int p, vector<int> a) {
    int o = 0, e = 0;
    rep(i, n) {
        if (a[i] % 2 != 0) o++;
        else e++;
    }
    // out(o << " " << e);
    
    ll ans = 0;
    
    for (int i = (p == 0 ? 0 : 1); i < o + 1; i += 2) {
        ans += nck(o, i);
    }
    
    if (ans == 0 && p == 0) ans = 1;
    ans *= pow(2, e);
    
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, p;
    cin >> n >> p;
    // n = 21; p = 1;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    // a[i] = 1;
    out(solve(n, p, a));
    
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(3*n);
    rep(i,3*n) cin >> a.at(i);
    // ジグザグに配置するのが一番強い
    sort(a.begin(), a.end(), greater<>());
    int64_t res = 0;
    rep(i,2*n){
        if(i%2 == 1) res += a.at(i);
    }
    cout << res << endl;
}

Measured memory_bytes: 2560
n=int(input())
p=list(map(int,input().split()))
# print(p)

p_ans = sorted(p)
# print(p_ans)
cnt=0
for i in range(len(p)):
    if p[i] == p_ans[i]:
        pass
    else:
        cnt+=1

if cnt<=2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 38512
#include<stdio.h>
#define MAX 10000
#define FALSE -1

typedef struct
{
  int parent;
  int left;
  int right;
}Tree;

Tree A[MAX];
int n;

void pPato(int k)
{
  if(k==FALSE)return;
  printf(" %d",k);
  pPato(A[k].left);
  pPato(A[k].right);
}

void mPato(int k)
{
  if(k==FALSE)return;
  mPato(A[k].left);
  printf(" %d",k);
  mPato(A[k].right);
}

void lPato(int k)
{
  if(k==FALSE)return;
  lPato(A[k].left);
  lPato(A[k].right);
  printf(" %d",k);
}

int main()
{
  int i,pnum,lnum,rnum,pass;

  scanf("%d",&n);
  for(i=0;i<n;i++)A[i].parent=FALSE;
  for(i=0;i<n;i++)
    {
      scanf("%d %d %d",&pnum,&lnum,&rnum);
      A[pnum].left=lnum;
      A[pnum].right=rnum;
      if(lnum!=FALSE)A[lnum].parent=pnum;
      if(rnum!=FALSE)A[rnum].parent=pnum;
    }
  for(i=0;i<n;i++)if(A[i].parent==FALSE)pass=i;
  printf("Preorder\n");
  pPato(pass);
  printf("\n");
  printf("Inorder\n");
  mPato(pass);
  printf("\n");
  printf("Postorder\n");
  lPato(pass);
  printf("\n");

  return 0;
}

Measured memory_bytes: 616
import math

A,B,H,M = map(float, input().split())

angleH = H*30+0.5*M
angleM = M*6

if abs(angleH - angleM) < 180:
    angle = float(abs(angleH - angleM))
elif abs(angleH - angleM) > 180:
    if angleH > angleM:
        angle = float(360 - angleH + angleM)
    else:
        angle = float(360 - angleM + angleH)

elif abs(angleH - angleM) == 180:
    angle = 180
    
elif angleH==angleM:
    angle = 0


a2 = float(A**2 + B**2 - 2*A*B*math.cos(math.radians(angle)))
ans = float(a2**0.5)
print(f'{ans:.20f}') 

Measured memory_bytes: 9536