akhauriyash/Code-Regression huggingface dataset:
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
    bool hw(int aa)
    {
        int b[100];
        int cntaa=1;
        while (aa!=0)
        {
             b[cntaa]=aa%10;
             cntaa++;
             aa=aa/10;
        }
        for (int i=1;i<cntaa;i++)
             if (b[i]!=b[cntaa-i]) return false;
        return true;
    }
int main(){
    int a;
    int b;
    cin>>a>>b;
    int cnt=0;
    for (int i=a;i<=b;i++){
        if (hw(i)) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char c=getchar();
    bool f=false,f1=false;
    while (c!=EOF)
    {
        if (c=='C') f=true;
        if (c=='F'&&f==true) f1=true;
        c=getchar();
    }
    if (f==true&&f1==true) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (!h && !w)
      break;

    int answ = INF, ansh = INF;
    for (int hh = 150; hh >= 1; hh--) {
      for (int ww = 150; ww >= 1; ww--) {
        if (ww <= hh)
          continue;
        if (ww <= w && hh <= h)
          continue;
        if (hh * hh + ww * ww > h * h + w * w) {
          if (ansh * ansh + answ * answ > hh * hh + ww * ww ||
              ansh * ansh + answ * answ == hh * hh + ww * ww && ansh > hh) {
            ansh = hh;
            answ = ww;
          }
        }
        if (hh * hh + ww * ww == h * h + w * w) {
          //cout << "b h:" << hh << " w:" << ww << endl;
          if (h < hh) {
            //cout << "h:" << hh << " w:" << ww << endl;
            ansh = hh;
            answ = ww;
          }
        }
      }
    }

    cout << ansh << " " << answ << endl;
  }
  return 0;
}

Measured memory_bytes: 3080
import sys

#+++++
		
def main():
	n = int(input())
	ret = n*(n-1)//2
	print(ret)
	
	
#+++++


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <string>
#define int long long
#define pii pair<int, int>
using namespace std;

void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

const int N = 31;
int cnt[N];

signed main() {
	fast();
	int n, m;
	cin >> n >> m;
	int answ = 0;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int b;
			cin >> b;
			cnt[b]++;
			if (cnt[b] == n) answ++;
		}
	}
	cout << answ;
	return 0;
}

Measured memory_bytes: 256
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=3e5+5;
int n,m,k;
int hang[N],lie[N],mx1,mx2;
map<int,map<int,int> > ma;
vector<int> v1,v2;
int main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int i,j;
	cin>>n>>m>>k;
	if(k==1)
	{
		cout<<1<<endl;
		return 0;
	}
	for(i=1;i<=k;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		ma[x][y]++;
		hang[x]++;
		if(hang[x]>mx1)
		{
//			mi=x;
			mx1=hang[x];
		}
		lie[y]++;
		if(lie[y]>mx2)
		{
//			mj=y;
			mx2=lie[y];
		}
	}
	for(i=1;i<=n;i++)
	{
		if(hang[i]==mx1)
			v1.pb(i);
	}
	for(j=1;j<=m;j++)
	{
		if(lie[j]==mx2)
		{
			v2.pb(j);
		}
	}
	
	for(i=0;i<v1.size();i++)
	{
		for(j=0;j<v2.size();j++)
		{
			if(!ma[v1[i]][v2[j]]){
				cout<<mx1+mx2<<endl;
				return 0;
			}
		}
	}
	cout<<mx1+mx2-1<<endl;
}


Measured memory_bytes: 51944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long m = sc.NextLong();
        int mod = 1000000007;

        long answer = 1;

        for (long i = 1; i <= n; i++)
        {
            answer *= i;
            answer = answer % mod;
        }

        for (long i = 1; i <= m; i++)
        {
            answer *= i;
            answer = answer % mod;
        }

        if (n == m)
        {
            answer *= 2;
            answer = answer % mod;
        }

        if (Math.Abs(n - m) >= 2)
        {
            answer = 0;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 11220
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

string foo(string s, string t) {
	int ls = s.length(), lt = t.length();
	if (ls < lt) return s;
	if (ls > lt) return t;
	return min(s, t);
}

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		vector<string> s(N);
		for (int i = 0; i < N; i++)
			cin >> s[i];
		sort(s.begin(), s.end());
		s.erase(unique(s.begin(), s.end()), s.end());
		N = s.size();
		vector<bool> a(N, true);
		for (int i = 0; i < N; i++) {
			int l = s[i].length();
			for (int j = 0; j < N; j++) {
				if (j == i) continue;
				for (int k = 0; k + l <= s[j].length(); k++)
					if (s[j].substr(k, l) == s[i])
						a[i] = false;
			}
		}
		vector<string> _s;
		for (int i = 0; i < N; i++)
			if (a[i]) _s.push_back(s[i]);
		s = _s;
		N = s.size();
		vector< vector<string> > t(N, vector<string>(N));
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++) {
				int l = min(s[i].length(), s[j].length());
				for (;;) {
					if (s[i].substr(s[i].length() - l) == s[j].substr(0, l))
						break;
					l--;
				}
				t[i][j] = s[j].substr(l);
			}
		vector< vector<string> > dp(1 << N, vector<string>(N, string(101, 'z')));
		for (int i = 0; i < N; i++)
			dp[1 << i][i] = s[i];
		for (int S = 1; S < (1 << N); S++)
			for (int i = 0; i < N; i++) {
				if (!(S & (1 << i))) continue;
				int T = S - (1 << i);
				for (int j = 0; j < N; j++) {
					if (!(T & (1 << j))) continue;
					dp[S][i] = foo(dp[S][i], dp[T][j] + t[j][i]);
				}
			}
		string sss(101, 'z');
		for (int i = 0; i < N; i++)
			sss = foo(sss, dp[(1 << N) - 1][i]);
		cout << sss << endl;
	}
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;



int main() {
	
	int n, k;
	cin >> n >> k;
	VI v(k, 1);
	n -= k;
	v[0] += n;

	cout << v[0] - v[v.size() - 1] << endl;
}


Measured memory_bytes: 256
from fractions import gcd
a,b,c,d = map(int, input().split())
ci = b//c - (a-1)//c
di = b//d - (a-1)//d
e = c * d // gcd(c, d)
cdi = b//e - (a-1)//e
print(b-(a-1)-(ci+di-cdi))

Measured memory_bytes: 5048
N = int(input())
A = list(map(int,input().split()))
dif = []
s = 0
for i in range(N):
    dif.append(A[i]-(i+1))
dif.sort()
b = dif[int(len(dif)/2)]
ans = 0
for i in range(N):
    ans += abs(dif[i]-b)
print(ans)



Measured memory_bytes: 99796
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


//for(i=0; i<N; i++) cin >> a[i];

ll D;
ll c[26];
ll s[366][26];

ll calcScore(vector<ll> sche, ll e) {
  sche.push_back(e);
  ll score=0;
  ll i, j, k;
  ll p[26];
  for(i=0; i<26; i++) p[i]=-1;
  
  for(ll d=0; d<sche.size(); d++) {
    score+=s[d][sche[d]];
    
    p[sche[d]]=d;
    for(i=0; i<26; i++) score-=c[i]*(d-p[i]);
    
  }
  
  return score;
}

int main(void) {
  ll i, j, k;
  
  cin >> D;
  for(i=0; i<26; i++) cin >> c[i];
  for(i=0; i<D; i++) {
    for(j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }
  
  vector<ll> res;
  ll score=0;
  for(ll d=0; d<D; d++) {
    ll max=-INF;
    ll day=-1;
    for(i=0; i<26; i++) {
      if(calcScore(res, i)>max) {
        max=calcScore(res, i);
        day=i;
      }
    }
    
    res.push_back(day);
  }
  
  for(auto r: res) pt(r+1);
  
  
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K, X;
    cin >> K >> X;
    int min = X - K + 1;
    int max = X + K - 1;
    cout << min;
    for(int i = min + 1;i<=max;i++){
        cout << " " << i;
    }
    cout << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long int
int ans=0;
int h[1<<21]={0};
int dp[1<<22][22];
main() {
    int n;
    cin>>n;
    double a[n+5];
    double ans=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    ans=a[1];
    for(int i=2;i<=n;i++){
        ans=(double(ans+a[i]))/2;
    }
    printf("%.10lf",ans);
    // cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,ans=INT_MAX;
void fun(int x,int id)
{
	if(id==n)
    {
	  ans=min(ans,x);
      return;
    }
	fun(2*x,id+1);
	fun(x+k,id+1);
}
int main()
{
	cin>>n>>k;
	fun(1,0);
	cout<<ans;
	return 0;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int64_t i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int64_t i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll md = 1000000007;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    char c;
    cin >> c;
    if (tolower(c) == c) {
    	cout << "a\n";
    } else {
    	cout << "A\n";
    }

}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
  int N, ans = 0;
  cin >> N;
  if (N <= 99) ans += min(9,N);
  else if (N >=100 && N <= 999) ans += 9+N-99;
  else if (N >= 1000 && N <= 9999) ans += 909;
  else if (N >= 10000 && N <= 99999) ans += 909+N-9999;
  else ans += 90909;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
   int main(){
    int i,j;
     int w[10],k[10];
      for(i=0;i<10;i++){
        scanf("%d",&w[i]);
         }
      for(i=0;i<10;i++){
         scanf("%d",&k[i]);
           }
       for(i=0;i<10;i++){
            for(j=0;j<9;j++){
               if(w[j] < w[j+1]){
                  int x = w[j+1];
                     w[j+1] = w[j];
                         w[j] = x;
                              }
                               }
                                }
       for(i=0;i<10;i++){
            for(j=0;j<9;j++){
               if(k[j] < k[j+1]){
                  int y = k[j+1];
                     k[j+1] = k[j];
                         k[j] = y;
                              }
                               }
                                }
int sumw,sumk;
sumw = w[0]+w[1]+w[2];
sumk = k[0]+k[1]+k[2];
printf("%d %d\n",sumw,sumk);
return 0;
}

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

#define FOR(i, n) for (int i = 0; i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)

int main() {
	int R, G;

	cin >> R >> G;

	cout << 2 * G - R << endl;
}

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

signed main(){
	string S,T; cin>>S>>T;
	int N=S.size();
	bool ans=false;
	if(S==T) ans=true;
	for(int i=0;i<N and not ans;i++){
		string tmp;tmp+=S[N-1];
		S.insert(0,tmp);
		S.erase(S.begin()+N);
		//cout<<S<<endl;
		if(S==T) ans=true;
	}
	cout<<(ans ? "Yes" : "No")<<endl;
}

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

def isprime(x):
  for i in range(2, x//2+1):
    if x % i == 0:
      return False
  return True

def minp(x):
  res = x
  while True:
    if isprime(res):
      return res
    res += 1

print(minp(X))
  

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
	int n,m,d,i,j;
	pair<int,string>a[20];
	while(cin>>n,n)
	{
		int c[30][20]={};
		for(i=0;i<n;++i)
			for(cin>>a[i].second>>m;m--;)cin>>d,++c[d][i];
		for(i=0;i<n;++i)
			for(j=a[i].first=0;j<30;++j)
				if(c[j][i])
					a[i].first+=n+1-count(c[j],c[j+1],1);
		sort(a,a+n);
		cout<<a->first<<' '<<a->second<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;

    vector<int> A(X), B(Y), C(Z);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];
    sort(A.begin(), A.end(), greater<int>());
    sort(B.begin(), B.end(), greater<int>());
    sort(C.begin(), C.end(), greater<int>());
    vector<int> v;
    for(int i = 0; i < A.size(); i++) {
        for(int j = 0; j < B.size(); j++) {
            v.push_back(A[i] + B[j]);
        }
    }
    sort(v.begin(), v.end(), greater<int>());
    vector<int> vv;
    for(int i = 0; i < min(K, (int)v.size()); i++) {
        for(int j = 0; j < C.size(); j++) {
            vv.push_back(v[i] + C[j]);
        } 
    }
    sort(vv.begin(), vv.end(), greater<int>());
    for(int i = 0; i < min(K, (int)vv.size()); i++) {
        cout << vv[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 43360
#include <stdio.h>
#define MAX 100
#define INF 200000
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
int A[MAX][MAX];
int d[MAX];
int pi[MAX];
int color[MAX];
int n;

void prim(){
  int u,i,v;
  int mincost;
  for(i=0;i<n;i++){
    d[i]=INF;
    pi[i]=NIL;
    color[i]=WHITE;
  }    
  d[0]=0;
  
  while(1){
    mincost=INF;
      for(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(v=0;v<n;v++){
    if(color[v]!=BLACK && A[u][v]!=INF){
      if(A[u][v]<d[v]){
	pi[v] = u;
	d[v] = A[u][v];
	color[v]=GRAY;
      }
    }
  }
  }
}


int main(){
  int i,j;
  int sum=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
      if(A[i][j]==NIL)
	A[i][j]=INF;
    }
  d[i]=INF;
  pi[i]=NIL;
  color[i]=WHITE;
}
  prim();
    for(i=0;i<n;i++){
      if(pi[i]!=NIL){
	sum+=A[i][pi[i]];
      }
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n){
    cin >> p[i];
  }
  int count = 0;
  rep(i,n){
    if(p[i]!=i+1)count++;
  }
  if(count <= 2)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const int IINF = 1e9;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}
template <typename T>
void dumpvec(vector<T> vec) {
  for (T cnt : vec) {
    cout << cnt << ", ";
  }
  cout << endl;
}

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  // 降順
  priority_queue<int> reds = priority_queue<int>();
  for (int i = 0; i < A; i++) {
    int r;
    cin >> r;
    reds.push(r);
  }

  // 降順
  priority_queue<int> greens = priority_queue<int>();
  for (int i = 0; i < B; i++) {
    int r;
    cin >> r;
    greens.push(r);
  }

  // 降順
  priority_queue<int> nocolors = priority_queue<int>();
  for (int i = 0; i < C; i++) {
    int r;
    cin >> r;
    nocolors.push(r);
  }

  // 昇順
  priority_queue<int, vector<int>, greater<int>> used_reds;
  for (int i = 0; i < X; i++) {
    used_reds.push(reds.top());
    reds.pop();
  }

  // 昇順
  priority_queue<int, vector<int>, greater<int>> used_greens;
  for (int i = 0; i < Y; i++) {
    used_greens.push(greens.top());
    greens.pop();
  }

  while (nocolors.size() > 0) {
    // dump(nocolors.top());
    // dump(used_reds.top());
    // dump(used_greens.top());

    if (nocolors.top() < used_reds.top() &&
        nocolors.top() < used_greens.top()) {
      break;
    }
    // 採用したredsの最小値のほうがgreenのそれより小さいならそちらを交換対象にする
    if (used_reds.top() < used_greens.top()) {
      used_reds.pop();
      used_reds.push(nocolors.top());
      nocolors.pop();
    } else {
      used_greens.pop();
      used_greens.push(nocolors.top());
      nocolors.pop();
    }
  }

  ll sum = 0;
  while (used_greens.size()) {
    sum += used_greens.top();
    used_greens.pop();
  }
  while (used_reds.size()) {
    sum += used_reds.top();
    used_reds.pop();
  }

  cout << sum << endl;
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int c=0;
    cin>>n;
    vector<int> v1,v2;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        v1.push_back(t);
    }
    v2=v1;
    sort(v1.begin(),v1.end());
    for(int i=0;i<n;i++)
    {
        if(v1.at(i)!=v2.at(i))
        {
            c++;
        }
    }

    if(c<=2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }


}


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

const int _mx = 2e6;
int arr[_mx+5];

int main() {
    // freopen("in.txt", "r", stdin);

    int n, x = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];
    for (int i = 0; i < n; i++) {
        int mn = i;
        for (int j = i; j < n; j++) {
            if (arr[j] < arr[mn]) mn = j;
        }
        if (mn != i) swap(arr[i], arr[mn]), x++;
    }
    cout << arr[0];
    for (int i = 1; i < n; i++) cout << " " << arr[i];
    cout << endl << x << endl;

    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N,W;
int w[100000],v[100000];

ll dp[101][100001];
void solve(){
	rep(i,N){
		reps(j,W){
			dp[i + 1][j] = dp[i][j];
			if(j - w[i] >= 0){
				chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
			}
		}
	}
	cout<<dp[N][W]<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>N>>W;
	rep(i,N) {
		cin>>w[i]>>v[i];
	}
		solve();
	return 0;
}


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

int main(){
    int n, maxv, minv, r, a;
    scanf("%d",&n);

    scanf("%d",&r);
    minv = r;
    for(a = 1; a < n; a++){
        scanf("%d",&r);
        if(a == 1) maxv = r - minv;
        maxv = maxv < (r-minv) ? (r-minv) : maxv;
        minv = minv > r ? r : minv;
    }

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



Measured memory_bytes: 2144
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    for(int i=0; i<str.length(); i++){
      if(Character.isUpperCase(str.charAt(i))){
        System.out.print(Character.toLowerCase(str.charAt(i)));
      }else{
        System.out.print(Character.toUpperCase(str.charAt(i)));
      }
    }
    System.out.println("");
  }
}


Measured memory_bytes: 26872
#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()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	int k = n;
	vector<int> v;
	for (int i = 1; i <= n; i++) {
		k -= i;
		v.push_back(i);
		if (k <= 0) break;
	}
	sort(v.rbegin(), v.rend());
	int l = n;
	for (int i = 0; i < v.size(); i++) {
		if (l == 0) break;
		if (l - v[i] < 0) continue;
		cout << v[i] << endl;
		l -= v[i];
	}
}

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

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

typedef struct _Node {
    int x;
    struct _Node *prev;
    struct _Node *next;
} Node;

Node *head = NULL, *tail = NULL;

/* Print all elements to stdin */
void dump() {
    int hoge = 0;
    Node *p = head;
    while (p != NULL) {
        if (hoge == 0)  printf("%d",  p->x);
        else            printf(" %d", p->x);
        ++hoge;
        p = p->next;
    }
    printf("\n");
}

void insert(int x) {
    Node *nod = malloc(sizeof(Node));;
    nod->x = x;
    nod->prev = NULL;
    nod->next = NULL;

    if (head == NULL) {
        head = nod;
        tail = nod;
    } else {
        nod->next = head;
        head->prev = nod;
        head = nod;
    }
    //dump();

}

void delete(int x) {
    Node *p = head;
    int flg = 0;
    
    while (flg == 0 && p != NULL) {
        //printf("x = %d\n", p->x);
        if (p->x == x) {
            Node *c = p;
            if (c->prev != NULL) {
                p->prev->next = c->next;
            } else {    /* if delete head */
                head = c->next;
            }
            
            if (c->next != NULL) {
                p->next->prev = c->prev;
            } else {    /* if delete tail */
                tail = c->prev;
            }
            flg = 1;
        } else {
            p = p->next;
        }
    }
}

void deleteFirst() {
    if (head == tail) {
        head = NULL;
        tail = NULL;
    } else if (head != NULL) {
        if (head->next != NULL) head->next->prev = NULL;
        head = head->next;
    }
}

void deleteLast() {
    if (head == tail) {
        head = NULL;
        tail = NULL;
    } else if (tail != NULL) {
        if (tail->prev != NULL) tail->prev->next = NULL;
        tail = tail->prev;
    }
}

int main(int argc, char **argv) {

    int n;
    scanf("%d\n", &n);

    int i;
    int x;
    char buf[256];
    char tmp[256];
    for (i = 0; i < n; ++i) {
        fgets(buf, 256, stdin);
        
        if (buf[0] == 'i' || buf[6] == ' ') {
            /* read x */
            sscanf(buf, "%s %d", tmp, &x);

            if (buf[0] == 'i') insert(x);
            else               delete(x);     
        } else if (buf[6] == 'F') {
            deleteFirst();
        } else if (buf[6] == 'L') {
            deleteLast();
        }
    }

    dump();
    
    return 0;
}

Measured memory_bytes: 36056
// ABC112
// A - Programming Education
#include<bits/stdc++.h>

using namespace std;

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

    if(n==1) cout << "Hello World" << endl;
    else{
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}


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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    for(int i = 1; i <= k; i++){
        int d;
        cin >> d;
        while(d--){
            int x;
            cin >> x;
            mp[x]++;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans += (mp[i] == 0);
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(a, value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
 
typedef long long LL;
typedef pair<int, int> PII;

string s[100];
int dp[100][100];

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	FOR(i, 0, n)
		cin >> s[i];
	dp[0][0] = s[0][0] == '#';
	FOR(i, 0, n)
		FOR(j, 0, m)
		{
			if(i || j)
				dp[i][j] = 1000000;
			if(i)
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'));
			if(j)
				dp[i][j] = min(dp[i][j], dp[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));
		}
	cout << dp[n - 1][m - 1] << "\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

    long[] g = new long[5];
    for(int i=0;i<5;i++){
      g[i] = scan.nextLong();
    }

    long current = 0;

    for (int i=0;i<5;i++){
      if (current > base(n,g[i]) + i + 1){
        current += 1;
      }
      else{
        current = base(n,g[i]) + i + 1;
      }
    }

    Arrays.sort(g);
    System.out.println(4+base(n,g[0]));


  }

  static long base(long a, long b){
    long c = (long) a/b;
    if (b*c == a){
      return c;
    }
    return c+1;
  }
}


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

typedef long long int ll;
#define T int t,q; scanf("%d",&t); for(q=1;q<=t;q++)

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	ll f=0;
	for(int i=a;i<=b;i++){
		if(i%n==0){
			f=1;
			break;
		}
	}
	if(f)cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
vector<ll>a, b, c, Mix;
ll i, aa, bb, cc, x, y, temp, r, g, ans, k;
int main()
{
    cin >> x >> y >> aa >> bb >> cc;
    for(i=0;i<aa;i++)
    {
        cin >> temp;
        a.push_back(temp);
    }
    for(i=0;i<bb;i++)
    {
        cin >> temp;
        b.push_back(temp);
    }
    for(i=0;i<cc;i++)
    {
        cin >> temp;
        c.push_back(temp);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    for(i=aa-1,k=0;i>=0 && k<x;i--, k++)
        Mix.push_back(a[i]);
    for(i=bb-1, k=0;i>=0 && k<y;i--, k++)
        Mix.push_back(b[i]);
    temp = Mix.size();
    //cout << temp << endl;
    for(i=0;i<x+y-temp;i++)
        Mix.push_back(c[cc-i-1]);

    temp = Mix.size();
    sort(Mix.begin(), Mix.end());
//    for(i=0;i<Mix.size();i++)
//        cout << Mix[i] << endl;
    k = 0;
    for(;i<c.size();i++)
    {
        if(Mix[k]<c[cc-1-i])
        {
            Mix[k] = c[cc-1-i];
            k++;
        }
    }
    for(i=0;i<temp;i++)
        ans += Mix[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7692
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>

int main()
{
  long long n;
  scanf("%lld", &n);
  
  std::map<long long, long long> m[2];
  
  for (int i = 0; i < n; ++i)
  {
    long long a;
    scanf("%lld", &a);
    m[i & 1][a]++;
  }
  std::vector<std::pair<long long, long long>> freq[2];
  for (int i = 0; i < 2; ++i)
  {
    for (auto &p : m[i])
    {
      freq[i].emplace_back(-p.second, p.first);
    }
    std::sort(freq[i].begin(), freq[i].end());
  }

  long long ac, bc;
  if (freq[0][0].second != freq[1][0].second)
  {
    ac = freq[0].size() == 1 ? 0 : freq[0][0].first + (n / 2);
    bc = freq[1].size() == 1 ? 0 : freq[1][0].first + (n / 2);
  }
  else
  {
    ac = freq[0].size() == 1 ? 0 : freq[0][0].first + (n / 2);
    bc = freq[1].size() == 1 ? n / 2 : freq[1][1].first + (n / 2);
    int A = ac + bc;
    ac = freq[0].size() == 1 ? n / 2 : freq[0][1].first + (n / 2);
    bc = freq[1].size() == 1 ? 0 : freq[1][0].first + (n / 2);
    int B = ac + bc;
    printf("%lld\n", std::min(A, B));
    return 0;
  }
  printf("%lld\n", ac + bc);
  return 0;
}

Measured memory_bytes: 8824
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, M;
vector<int> G[1010];

vector<int> shortest_cycle(int s) {
    vector<int> dis(N, -1), pre(N, -1);
    dis[s] = 0;
    queue<int> que;
    que.push(s);
    int last = -1;
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int nv : G[v]) {
            if (!~dis[nv]) {
                dis[nv] = dis[v] + 1;
                pre[nv] = v;
                que.push(nv);
            } else if (nv == s) {
                last = v;
                break;
            }
        }
    }
    if (!~last) return vector<int>();
    vector<int> res;
    while (~last) {
        res.push_back(last);
        last = pre[last];
    }
    reverse(res.begin(), res.end());
    return res;
}

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

    cin >> N >> M;
    REP (i, M) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        G[A].push_back(B);
    }
    vector<int> ans;
    REP (i, N) {
        auto c = shortest_cycle(i);
        if (c.empty()) continue;
        if (ans.empty() || c.size() < ans.size()) ans = c;
    }
    if (ans.empty()) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size() << endl;
    REP (i, ans.size()) cout << ans[i] + 1 << endl;
}

Measured memory_bytes: 512
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    d = {}
    res = 0
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(n-1, -1, -1):
        if i+a[i] in d:
            res += d[i+a[i]]
        if i-a[i] not in d:
            d[i-a[i]] = 1
        else:
            d[i-a[i]] += 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 115180
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N;
	cin >> N;
	ll b, c;
  	ll x=-1,y=-1,z=-1;
	for (b = 1; b <= 3500; ++b) {
		for (c = 1; c <= 3500; ++c) {
			if (4*b*c-b*N-N*c>0 && N*b*c % (4 * b*c - b * N - N * c) == 0){
              x=N*b*c / (4 * b*c - b * N - N * c);
          	  y=b;
          	  z=c;}
		}
	}
  cout <<x<<" " << y << " " << z << endl;
}








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

int main(){
    string s;
    cin >> s;
    deque<char> dq;
    rep(i, s.length()) {
        if ( s[i] == '0' || s[i] == '1' ) {
            dq.push_back(s[i]);
        }
        else if ( dq.empty() ) {
            continue;
        }
        else if ( s[i] == 'B' ) {
            dq.pop_back();
        }
    }
    int dq_size = dq.size();
    rep(i, dq_size) {
        cout << dq.front();
        dq.pop_front();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// 	ITP1_4_B

#include<iostream>
#include<cstdio>
#define PI 3.141592653589
using namespace std; // define PI
int main(){
	double r;
	cin >> r;
	
	double area, circ;
	area = PI*r*r;
	circ =2*PI*r;
	printf("%.5f %.5f", area, circ);
	
	return 0;
}

Measured memory_bytes: 3260
n, m = gets.split.map(&:to_i)
s = []
c = []
1.upto(m) do |i|
  s[i], c[i] = gets.split.map(&:to_i)
end
0.upto(10 ** n - 1) do |i|
  next if i.to_s.length < n
  f = true
  1.upto(m) do |j|
    f = false if i.to_s[s[j] - 1] != c[j].to_s
  end
  if f
    puts i
    exit
  end
end
puts '-1'

Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static string N { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            N = CR.GetText();

            return N.Contains("7") ? "Yes" : "No";
        }
    }
}


Measured memory_bytes: 25896
use std::io::*;
use std::str::FromStr;

fn main() {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    println!("{}", if a + b >= c { b + c } else { a + b * 2 + 1 });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0].to!int;
    auto K = nk[1];
    auto AS = readln.split.to!(int[]);

    if (N == 1) {
        writeln(K%2 == 0 ? "" : AS[0].to!string);
        return;
    }

    auto FS = new int[](2*10^^5+1);
    FS[] = -1;
    auto LS = new int[](2*10^^5+1);
    LS[] = -1;
    auto NS = new int[](N);
    NS[] = -1;

    foreach (i; 0..N) if (FS[AS[i]] == -1) FS[AS[i]] = i;
    foreach_reverse (i; 0..N) {
        if (LS[AS[i]] != -1) NS[i] = LS[AS[i]];
        LS[AS[i]] = i;
    }

    auto memo = [0];
    int k = 1;
    int i;
    if (NS[0] == -1) {
        i = 1;
        ++k;
        memo ~= i;
    } else {
        i = NS[0] + 1;
    }
    while (i != N) {
        if (NS[i] == -1) {
            i = FS[AS[i]] + 1;
            ++k;
            memo ~= i;
        } else {
            i = NS[i] + 1;
        }
    }

    if (k == 1) {
        writeln("");
        return;
    }

    i = memo[K%k-1];
    int[] rr;
    while (i < N) {
        if (NS[i] == -1) {
            rr ~= AS[i];
        } else {
            i = NS[i];
        }
        ++i;
    }
    writeln(rr.to!(string[]).join(" "));
}

Measured memory_bytes: 22160
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int a, b;
	cin >> a >> b;
	if (a <= 5)cout << 0 << endl;
	else if (a <= 12)cout << b / 2 << endl;
	else cout << b << endl;
	return 0;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)
#define ar array

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
int ctoi(char c) {return c-'0';}
int slen(string s) {return s.length();}
int vsize(vi a) {return (int)a.size();}
int in() {int x;cin>>x;return x;}

string s,t;

int calc(int i) {
  int ans=0,k=0;
  for(int j=i;j<i+slen(t);j++) {
    if(s[j]!=t[k++])
      ans++;
  }
  return ans;
}

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

cin>>s>>t;
int mndiff=1e9;
for(int i=0;i<=slen(s)-slen(t);i++) {
  mndiff=min(mndiff,calc(i));
}
cout<<mndiff<<endl;
return 0;
}




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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1] << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
std::vector<int>v;
//見つからなかったら-1
int sarch(int num,int st, int ed) {
	int m = (st+ed)/2;
	if (v[m] == num)return m;
	else if (ed-st <= 1 && v[ed] != num)return -1;
	else if ( ed -st<= 1&&v[ed]==num)return ed;
	else if (v[m] < num)return sarch(num, m, ed);
	else if (v[m] > num)return sarch(num, st, m);
}
int main() {
	int count = 0;
	int n, m;
	std::cin >> n;
	v = std::vector<int>(n);
	for (auto&i : v)std::cin >> i;
	std::sort(v.begin(), v.end());
	std::cin >> m;std::vector<int>v2(m);
	for (auto& i : v2) { std::cin >> i; int ans = sarch(i, 0, v.size() - 1); if (ans != -1)v.erase(v.begin() + ans); else { ++count; break; }}
	 if(count == 0)std::cout << "YES" << std::endl;
	 else std::cout<<"NO" << std::endl;
	 return 0;
}

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

int A, B;
static const int L = 100;
string Grid[L];

int main() {
	cin >> A >> B;
	for (int i = 0; i < L; i++)for (int j = 0; j < L; j++) {
		if (i < 50) Grid[i] += "#";
		else Grid[i] += ".";
	}

	int x = 0;
	while (x < A - 1) {
		Grid[(x / 50) * 2][(x % 50)* 2 + 1] = '.';
		x++;
	}
	x = 0;
	while (x < B - 1) {
		Grid[(x / 50) * 2 + 51][(x % 50) * 2 + 1] = '#';
		x++;
	}

	cout << L << " " << L << endl;
	for (int i = 0; i < L; i++) {
		cout << Grid[i] << endl;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int heap[500005],top;
struct tree{
	int max;
}t[2000005];
struct link{
	int next,to;
}l[500005];
int n,sum,cnt,k;
int a[500005],p[500005],pre[500005],ans[500005],tmp[500005],head[500005];
inline int read(){
	int ret=0;char c=getchar();
	while((c<'0')||(c>'9'))c=getchar();
	while((c>='0')&&(c<='9'))ret=(ret<<1)+(ret<<3)+c-'0',c=getchar();
	return ret;
}
int P[20],pcnt;
void print(int x){
	if(x==0){puts("0");return;}
	while(x)P[++pcnt]=x%10,x/=10;
	while(pcnt)putchar(P[pcnt--]+'0');
	putchar('\n');
}
#define mid ((l+r)>>1)
#define lson index<<1
#define rson index<<1|1
inline int query(int L,int R,int l,int r,int index){
	if((L<=l)&&(R>=r))return t[index].max;
	if(R<=mid)return query(L,R,l,mid,lson);
	if(L>mid)return query(L,R,mid+1,r,rson);
	return max(query(L,R,l,mid,lson),query(L,R,mid+1,r,rson));
}
void updata(int l,int r,int index,int k,int x){
	t[index].max=x;
	if(l==r)return;
	if(k<=mid)updata(l,mid,lson,k,x);
	else updata(mid+1,r,rson,k,x);
}
void add(int u,int v){l[++cnt]=(link){head[u],v};head[u]=cnt;}
void ins(int x){
	heap[++top]=x;int k=top;
	while(k>1){
		if(heap[k>>1]>heap[k])swap(heap[k],heap[k>>1]);
		else break;
		k>>=1;
	}
}
void pop(){
	heap[1]=heap[top];int k=1;top--;
	while((k<<1)<=top){
		int v=k<<1;
		if(v<top)if(heap[v|1]<heap[v])v|=1;
		if(heap[v]<heap[k])swap(heap[k],heap[v]);
		else break;
		k=v;
	}
}
int main(){
	n=read();k=read();
	for(int i=1;i<=n;i++)p[i]=read(),a[p[i]]=i;
	for(int i=1;i<=n;i++){
		int r=min(n,a[i]+k-1);
		pre[i]=a[query(a[i],r,1,n,1)];
		updata(1,n,1,a[i],i);
	}
	for(int i=1;i<=n;i++)if(pre[i])add(pre[i],a[i]);
	for(int i=1;i<=n;i++)if(pre[i]==0)ins(a[i]);
	cnt=0;
	for(int i=1;i<=n;i++){
		int u=heap[1];ans[u]=++cnt;pop();
		for(int j=head[u];j;j=l[j].next)ins(l[j].to);
	}
	for(int i=1;i<=n;i++)print(ans[i]);
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double l;
    cin >> l;
    l /= 3.0;
    cout << fixed << setprecision(10) << l * l * l << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp34 {
    class Program {
        static void Main(string[] args) {
            int K = int.Parse(Console.ReadLine());

            int even = K / 2;
            int odd = (int)Math.Ceiling((double)K / 2);

            Console.WriteLine(even * odd);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 3e5+5;
int h, w, m, x[N], y[N];
map<pair<int,int>, int> mp;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w >> m;
    for(int i = 0; i < m; i++) {
        pair<int,int> a;
        cin >> a.first >> a.second;
        a.first--;
        a.second--;
        mp[a]++;
        x[a.first]++;
        y[a.second]++;
    }
    vector<pair<int,int>> xx, yy;

    for(int i = 0; i < h; i++) {
        xx.push_back(make_pair(x[i], i));
    }
    for(int i = 0; i < w; i++) {
        yy.push_back(make_pair(y[i], i));
    }

    sort(xx.begin(), xx.end());
    sort(yy.begin(), yy.end());

    int x1 = xx.back().second;
    assert(x[x1] == xx.back().first);

    int ans = 0;

    for(int i = 0; i < w; i++) {
        ans = max(ans, x[x1] + yy[i].first - mp[make_pair(x1, yy[i].second)]);
    }

    int y1 = yy.back().second;
    assert(y[y1] == yy.back().first);

    for(int i = 0; i < h; i++) {
        ans = max(ans, y[y1] + xx[i].first - mp[make_pair(xx[i].second, y1)]);
    }


    cout << ans;

    return 0;
}

Measured memory_bytes: 66476
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  vector<ll> alfa(26, 0);
  for (ll i = 0; i < S.size(); ++i) {
    alfa.at(S.at(i) - 'A') += 1;
  }
  ll cnt = 0;
  bool ok = true;
  for (ll i = 0; i < 26; ++i) {
    if (alfa.at(i) != 2) {
      if (alfa.at(i) != 0) {
        ok = false;
      }
    }
    else {
      cnt += 1;
    }
  }
  if (cnt == 2 && ok) {
    cout << "Yes" << "\n";
  }
  else {
    cout << "No" << "\n";
  }
}


Measured memory_bytes: 3604