akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int n, s, k;

int dfs(int i, int cnt, int total){
  if(cnt == k){
    return total == s ? 1 : 0;
  }else if(i > n){
    return 0;
  }

  int ret = 0;
  for(int j=i;j<=n;j++){
    if(total + j <= s){
      ret += dfs(j + 1, cnt + 1, total + j);
    }
  }

  return ret;
}

int main(){
  while(true){
    cin >> n >> k >> s;
    if(n == 0) break;
    cout << dfs(1, 0, 0) << endl;
  }
}

Measured memory_bytes: 3092
/* 
Rohit645
Rohit Kumar 
*/

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end() 
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main() {
	fastIo();
	ll a, b; cin >> a >> b;
	cout << ceil(((b-1)*1.0)/(a-1)) << endl;;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
input = sys.stdin.readline
inp = lambda: input().rstrip('\n')
n = int(input())
freq = defaultdict(int)
for _ in range(n):
    s = inp()
    freq[s] += 1
print('AC', 'x', freq['AC'])
print('WA', 'x', freq['WA'])
print('TLE', 'x', freq['TLE'])
print('RE', 'x', freq['RE'])

Measured memory_bytes: 74000
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

#define mid ((l+r)>>1)
const int N=1e4+9;
const int Inf=1e9+7;

struct node
{
	int x,y;
}p[N];

struct pts
{
	int x,id;
	bool operator < (pts o)const
	{
		return x<o.x;
	}
}pt[N<<1];

int n,ans=0;
vector<int> g[N<<3];
int low[N<<1],pre[N<<1],scc[N<<1],scccnt,dfn;
int rp[N<<1],stk[N<<1],top,ptop;

inline void chkmin(int &a,int b){if(a>b)a=b;}
inline void chkmax(int &a,int b){if(a<b)a=b;}

inline void add(int u,int v)
{
	g[u].push_back(v);
}

inline void dfs(int u)
{
	low[u]=pre[u]=++dfn;
	stk[++top]=u;
	for(int i=0,e=g[u].size(),v;i<e;i++)
		if(!low[(v=g[u][i])])
		{
			dfs(v);
			chkmin(low[u],low[v]);
		}
		else if(!scc[v])
			chkmin(low[u],pre[v]);
	if(low[u]==pre[u])
	{
		scccnt++;
		do
			scc[stk[top]]=scccnt;
		while(stk[top--]!=u);
	}
}	

inline void build(int x,int l,int r)
{
	if(l==r)
		return;
	build(x<<1,l,mid);
	build(x<<1|1,mid+1,r);
	add((x<<1)+ptop,x+ptop);
	add((x<<1|1)+ptop,x+ptop);
}

inline void adds(int x,int l,int r,int dl,int dr,int id)
{
	if(dl==l && r==dr)
	{
		add(id,x+ptop);
		return;
	}
	if(dr<=mid)
		adds(x<<1,l,mid,dl,dr,id);
	else if(mid<dl)
		adds(x<<1|1,mid+1,r,dl,dr,id);
	else
	{
		adds(x<<1,l,mid,dl,mid,id);
		adds(x<<1|1,mid+1,r,mid+1,dr,id);
	}
}

inline bool judge(int k)
{
	dfn=scccnt=0;
	for(int i=0;i<ptop;i++)
		g[i].clear();
	memset(low,0,sizeof(low));
	memset(scc,0,sizeof(scc));

	//build(1,1,ptop);
	//for(int i=0;i<ptop;i++)
	//	adds(1,1,ptop,pt[i].x-k,pt[i].x,pt[i].id);

	
	for(int i=0;i<ptop;i++)
	{
		for(int j=i-1,cnt=1;~j && pt[j].x+k>pt[i].x && cnt<=9;j--,cnt++)
		{
			add(pt[i].id,pt[j].id^1);
			add(pt[j].id,pt[i].id^1);
		}
	}
	

	for(int i=0;i<ptop;i++)
		if(!low[i])
			dfs(i);
	for(int i=0;i<n;i++)
		if(scc[i<<1]==scc[i<<1|1])
			return false;
	return true;
}

int main()
{
	n=read();
	int l=0,r=0,mids,ans=0;
	for(int i=0;i<n;i++)
	{
		p[i].x=read();
		p[i].y=read();
		if(p[i].x>p[i].y)swap(p[i].x,p[i].y);
		chkmax(r,p[i].y);
		pt[i<<1].x=p[i].x;pt[i<<1].id=i<<1;
		pt[i<<1|1].x=p[i].y;pt[i<<1|1].id=i<<1|1;
	}
	ptop=n*2;
	sort(pt,pt+ptop);
	while(l<=r)
	{
		mids=l+r>>1;
		if(judge(mids))
			ans=mids,l=mids+1;
		else
			r=mids-1;
	}

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


Measured memory_bytes: 6272
import math

a, b ,x = map(int, input().split())

if x/a >= a*b/2:
    tmp = (b - ( 2 * x /(a*a) -b))/a
    ans  = math.degrees(math.atan(tmp))
else :
    ans = 90 - math.degrees(math.atan(2*x / a / b/ b))
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll p[3];
    cin>>p[0]>>p[1]>>p[2];
    sort(p,p+3);
    ll ans=p[0]+p[1];
    cout<<ans;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
import copy
N,C=map(int,input().split())
L=[]
for i in range(N):
    x,v=map(int,input().split())
    L.append([x,v])

LR=copy.deepcopy(L)
L=[[0,0]]+L
#print(L)
LR=LR[::-1]

for i in range(N):
    LR[i][0]=C-LR[i][0]
LR=[[0,0]]+LR
#print(LR)
Lr=[0]
S=0
for i in range(1,N+1):
    S+=L[i][1]
    Lr.append(S-L[i][0])
#print(Lr)
LC=[0]

for i in range(1,N+1):
    LC.append(max(LC[-1],Lr[i]))
#print(LC)

LRr=[0]
S=0
for i in range(1,N+1):
    S+=LR[i][1]
    LRr.append(S-LR[i][0])
#print(LRr)
LRC=[0]
for i in range(1,N+1):
    LRC.append(max(LRC[-1],LRr[i]))
#print(LRC)

ans=0
for i in range(N+1):
    cnt=LC[i]-L[i][0]+LRC[N-i]
    ans=max(ans,cnt)
for i in range(N+1):
    cnt=LRC[i]-LR[i][0]+LC[N-i]
    ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 128732
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, T b ) { if ( a < b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, T b ) { if ( a > b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )


int 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: 888
#include <bits/stdc++.h>
using namespace std;

int trans (string s) {
	return (s[0]-'0')*10 + s[1]-'0';
}
int main () {
	string s; cin >> s;
	int a = trans(s.substr(0,2));
	int b = trans(s.substr(2,2));
	bool f1 = (a <= 12 && a >= 1);
	bool f2 = (b <= 12 && b >= 1);
	if (f1 && f2) cout << "AMBIGUOUS" << endl;
	else if (f1) cout << "MMYY" << endl;
	else if (f2) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int K, X;

    static void input()
    {
        cin = new Scanner();
        K = cin.nextInt();
        X = cin.nextInt();
    }
    static void solve()
    {
        input();
      
        WriteLine(String.Join(" ",Enumerable.Range(X - K + 1,2 * K - 1)));
    }
    class Scanner
    {
        string[] s;
        int i;

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

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

        public int nextInt()
        {
            return int.Parse(next());
        }

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

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

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


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

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

    sort(v.begin(), v.end(), greater<int>());
    int ans = v[0] / 2;
    for (int i = 1; i < n; i++) {
        ans += v[i];
    }

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

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

int main() {
  int ans,N,K;
  cin>>N>>K;
  ans=K;
  if(N!=1){
  for(int i=0;i<N-1;i++){
    ans*=(K-1);
  }
  }
  cout<<ans<<endl;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

struct BIT{
  int n;
  vector<ll> bit;
  BIT(int size):n(size),bit(size+1,0){}

  void init(){
    rep(i,bit.size())bit[i]=0;
  }

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

  void add(int i,ll v){
    if(i==0)return ;
    while(i<=n){
      bit[i]+=v;
      i+=i&-i;
    }
  }

  ll lower_bound(ll w){
    if(w<=0)return 0;
    ll x=0,r=1;
    while(r<n)r<<=1;
    for(ll k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;
  }
};

int N;
vector<int> A[100010];
map<vector<int>,int> num,rnum;
ll B[100010],sgn[100010];
ll idx[100010];

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

  cin>>N;
  rep(i,N)A[i].resize(3);
  rep(j,3){
    rep(i,N){
      cin>>A[i][j];
      A[i][j]--;
    }
  }

  rep(i,N){
    vector<int> vs;
    rep(j,3){
      vs.push_back(i*3+j);
    }
    num[vs]=i;
    reverse(all(vs));
    rnum[vs]=i;
  }

  set<int> st;
  rep(i,N){
    if(num.find(A[i])!=num.end()){
      B[i]=num[A[i]];
      sgn[i]=+1;
      st.insert(B[i]);
    }else if(rnum.find(A[i])!=rnum.end()){
      B[i]=rnum[A[i]];
      sgn[i]=-1;
      st.insert(B[i]);
    }else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  if((ll)st.size()!=N){
    cout<<"No"<<endl;
    return 0;
  }

  rep(i,N){
    // dbg(B[i]); dbg(sgn[i]);
    if(B[i]%2!=i%2){
      cout<<"No"<<endl;
      return 0;
    }
    idx[B[i]]=i;
  }

  ll suma=0,sumb=0;
  BIT bit(N);
  for(ll i=0;i<N;i+=2){
    ll j=idx[i];
    suma+=bit.sum(N)-bit.sum(j+1);
    bit.add(j+1,1);
  }

  bit.init();
  for(ll i=1;i<N;i+=2){
    ll j=idx[i];
    sumb+=bit.sum(N)-bit.sum(j+1);
    bit.add(j+1,1);
  }

  // dbg(suma); dbg(sumb);
  ll sa=0,sb=0;
  rep(i,N){
    if(i%2==0){
      if(sgn[i]==-1)sa++;
    }else{
      if(sgn[i]==-1)sb++;
    }
  }
  // dbg(sa); dbg(sb);

  if(sa<=2*suma+sumb&&sb<=2*sumb+suma&&sa%2==sumb%2&&sb%2==suma%2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N, A=0, ans=0;
  cin >> N;
  REP(i,N) {
    int H;
    cin >> H;
    if(H >= A) {
      ans++;
    }
    chmax(A,H);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int sum[2],num,i,j;

	for(i = 0;i < 2;i++){
		sum[i] = 0;
		for(j = 0;j < 4;j++){
			scanf("%d",&num);
			sum[i] += num;
		}
	}

	printf("%d\n",sum[0]<sum[1] ? sum[1] : sum[0]);

	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int x;
  cin >> x;
  if (x < 100) {
    cout << "0\n";
    return 0;
  }
  int b=x%100,a=(x-b)/100;
  if(a*5<b){
    cout << "0\n";
    return 0;
  }

  cout << "1\n";
  return 0;
}


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

using namespace std;
int main() {
	int N(0), K(0);
	int sum_max(0);
	cin >> N >> K;
	vector<int> l(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	for (size_t i = 0; i < K; i++)
	{
		sum_max += l[N - 1 - i];
	}
	cout << sum_max;
	return 0;
}

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

int main() {
  
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a == b) cout << c << endl;
  else if(a == c) cout << b << endl;
  else cout << a << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x, y;
    cin >> x >> y;
    rep(t, 0, x + 1) {
        int k = x - t;
        if (t * 2 + k * 4 == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
int n,m,k;
int sx,sy,ex,ey;
queue<pair<int,pii> >q;
int main(){
	cin>>n>>m>>k;
	cin>>sx>>sy>>ex>>ey;
	sx--;sy--;ex--;ey--;
	vector<string>c(n,"");
	rep(i,n)cin>>c[i];
	vector<vector<int> >dp(n,vector<int>(m,INF));
	
	q.push(make_pair(0,pii(sx,sy)));
	dp[sx][sy]=0;
	while(!q.empty()){
		int cost=q.front().first,tx=q.front().second.first,ty=q.front().second.second;
		q.pop();
//		cout<<tx<<' '<<ty<<' '<<dp[tx][ty]<<endl;
		rep(i,4){
			int ncost=cost+1;
			int nx=tx,ny=ty;
			rep(j,k){
				nx+=dx[i];ny+=dy[i];
				if(nx<0||nx>=n||ny<0||ny>=m||c[nx][ny]=='@')break;
				if(dp[nx][ny]>ncost){
					dp[nx][ny]=ncost;
					q.push(make_pair(ncost,pii(nx,ny)));
				}
				else if(dp[nx][ny]==ncost)continue;
				else break;
			}
		}
	}
	if(dp[ex][ey]==INF)cout<<-1<<endl;
	else cout<<dp[ex][ey]<<endl;
	return 0;
}


Measured memory_bytes: 12036
# def sort(A):
#     if len(A) < 2:
#         return A
#     c = len(A)//2
#     return merge(sort(A[:c]), sort(A[c:]))

# def merge(X, Y):
#     if len(X) < 1:
#         return Y
#     if len(Y) < 1:
#         return X
#     if (X[0] < Y[0]):
#         return [Y[0]]+ merge(X, Y[1:])
    # else:
#         return [X[0]] + merge(X[1:], Y)

N, K = map(int, input().split())
enemyHP = list(map(int, input().split()))
# enemyHP = sort(enemyHP)
enemyHP.sort(reverse=True)
if(len(enemyHP) <= K):
    print(0)
else:
    print(sum(enemyHP[K:]))



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

int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  for(int i = 0;i < k;i++) {
    if(b < c && (b*2) < c) {
      b = b * 2;
    } else {
      c = c * 2;
    }
  }
  if(a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
n=int(input())
ans=n
for i in range(n+1):
    c=0
    t=i
    while(t>0):
        c+=t%6
        t//=6
    t=n-i
    while(t>0):
        c+=t%9
        t//=9
    if(ans>c):ans=c
print(ans)

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

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

    vector<int> m(n);

    int count = 0,MIN=1e5;

    for(int i=0; i<n; i++){
        cin>>m[i];
        count++;
         x -= m[i];
         MIN = min(MIN,m[i]);
    }

    while(1){
        x -= MIN;
        if( x < 0 )break;
        count++;
    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n1,n2;
    cin>>n1>>n2;
    if(n1==1 && n2>1 )
    {
        printf("Alice\n");
    }
    else if(n2==1 && n1>1)
    {
        printf("Bob");
    }
    else if(n1==n2)
    {
        printf("Draw\n");
    }
    else if(n1>n2)
    {
        printf("Alice\n");
    }
    else if(n1<n2)
    {
        printf("Bob\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  int n;
  cin>>n;
  ll x,p;
  vector<P> v;
  for(i=0;i<n;i++){
    cin>>x>>p;
    v.pb(P(x+p,x-p));
  }
  sort(v.begin(),v.end());
  ll z=-INF;
  ll cnt=0;
  for(i=0;i<n;i++){
    if(z<=v[i].se){
      cnt++;
      z=v[i].fi;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>

using namespace std;

int main (void) {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int left = A + B;
    int right = C + D;
    if ( left > right )
        cout << "Left";
    else if ( left < right )
        cout << "Right";
    else
        cout << "Balanced";
    cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <vector>

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

  std::deque<int> deq;
  bool is_rev = false;

  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;

    if (is_rev) {
      deq.push_front(a);
    } else {
      deq.push_back(a);
    }

    is_rev = !is_rev;
  }

  std::vector<int> ans;
  for (auto it = deq.begin(); it != deq.end(); it++) {
    ans.push_back(*it);
  }

  if (is_rev) {
    std::reverse(ans.begin(), ans.end());
  }

  for (int i = 0; i < n; i++) {
    std::cout << ans[i];
    std::cout << (i == n - 1 ? "\n" : " ");
  }

  return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long ans=0,s=0;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		ans=ans+s*a;
		ans=ans%1000000007;
		s+=a;
		s=s%1000000007;
	}
	cout<<ans;
} 

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll l,r,i,j,k,n,m,x;
	cin>>n;
	ll ar[10005]={0};
	for(i=1;i<=100;i++)
	{
		for(j=1;j<=100;j++)
		{
			for(k=1;k<=100;k++)
			{
//				cout<<i<<' '<<j<<' '<<k<<endl;
				ll x=i*i+j*j+k*k+i*j+j*k+k*i;
				if(x<=n) ar[x]++;
			}
		}
	}
	for(i=1;i<=n;i++)
	cout<<ar[i]<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,mk,num[100005],cc,bs[100005],col[100005];
bool pp=true,bi[100005];
long long ss;
vector<int>pos;
bool ch(int mm)
{
	int r=mm,rr=0;
	memset(bs,0,sizeof(bs));
	memset(col,0,sizeof(col));
	bool p=true;
	if(pos.size()!=0)
	{
		int aa=pos.size();
		if(r-aa<=0)return false;
		for(int i=1;i<=n;i++)
		{
			if(bi[i])continue;
			else
			{
				bs[rr+aa]++;
				col[i]=rr+aa;
				rr++;
				rr%=(r-aa);	
			}
		}
		for(int i=0;i<aa;i++)
		{
			bs[i]++;
			col[pos[i]]=i;
		}
		for(int i=1;i<=n;i++)
		{
			if(bs[col[i]]==1)
			{
				if(num[i]!=r-1)p=false;
			}
			else
			{
				if(num[i]!=r)p=false;	
			}
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			bs[rr]++;
			col[i]=rr;
			rr++;
			rr%=(r);
		}
		for(int i=1;i<=n;i++)
		{
			if(bs[col[i]]==1)
			{
				if(num[i]!=r-1)p=false;
			}
			else
			{
				if(num[i]!=r)p=false;	
			}
		}
	}
	/*for(int i=1;i<=n;i++)
	{
		printf("%d ",col[i]);
	}*/
	return p;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    	scanf("%d",&num[i]);
    	mk=max(num[i],mk);
    	ss+=num[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(num[i]<mk)cc++,pos.push_back(i),bi[i]=true;
		if(num[i]<mk-1)pp=false;
	}
	if(ch(mk))
	{
		printf("Yes");
	}
	else
	{
		if(ch(mk+1))
		{
			printf("Yes");
		}
		else
		{
			printf("No");
		}
	}
}

Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;


int main()
{
	int a[10];
	for (int s=0; s <= 9; s++)
	{
		cin >> a[s];
	}
	sort(a, a + 10, greater<int>());
	cout << a[0] << endl << a[1] << endl << a[2] << endl;
	return 0;
}

Measured memory_bytes: 1176
N = int(input())
curMin = 10**12+1
for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        chk = (i - 1) + (N//i - 1)
        if curMin <= chk:
            break
        else:
            curMin = min(curMin, (i - 1) + (N//i - 1))
print(curMin)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int n,a,b;
	scanf("%d %d %d",&n,&a,&b);
	if(a==n||b==n){
		if(a>b){
			printf("%d %d",b,b);
		}else{
			printf("%d %d",a,a);
		}
	}else if(a+b>=n){
		if(a>b){
			printf("%d %d",b,a+b-n);
		}else{
			printf("%d %d",a,a+b-n);
		}
	}else{
		if(a>b){
			printf("%d 0",b);
		}else{
			printf("%d 0",a);
		}
	}
}

Measured memory_bytes: 128
import math

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

def angle():
  wa = 0.5
  wb = 6
  w = wb-wa
  t = H*60 + M
  wnew = (w*t)%360
  if wnew>=180:
    wnew = 360 - wnew
  return wnew


cos_angle = math.cos(math.radians(angle()))
distance = A**2 + B**2 - 2*A*B*cos_angle
answer = distance**0.5
print(answer)

Measured memory_bytes: 9492
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
ll a[100000][3];
ll dp[100000][3];

int main() {
    cin >> n;
    rep(i,n) rep(j,3) cin >> a[i][j];
    rep(i,3) dp[0][i] = a[0][i];
    for (int i = 1; i < n; i++) {
        rep(j,3) {
            rep(k,3) {
                if (j == k) continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
            }
        }
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}



Measured memory_bytes: 4992
fun main(args: Array<String>) {
    val (a,b,c) = readLine()!!.split(" ").map { it.toInt() }
    if(a and b and c and 1 == 1) {
        println(listOf(1L * a * b, 1L * a * c, 1L * c * b).min())
    } else {
        println(0)
    }
}

Measured memory_bytes: 38004
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

ll d[200][200];
void warshall_floyd(int n) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){ 
    int n, m, r; cin >> n >> m >> r;
    vector<int> rute(r);
    rep(i, r) {cin >> rute[i]; rute[i]--;}
    rep(i, 200){
        rep(j, 200){
            d[i][j] = 1e18;
        }
    }
    rep(i, m){
        int a, b; ll c; cin >> a >> b >> c; a--; b--; 
        d[a][b] = c;
        d[b][a] = c;
    }

    warshall_floyd(n);
    sort(all(rute));
    ll res = 1e18;
    do{
        ll dist = 0;
        rep(i, rute.size()-1){
            dist += d[rute[i]][rute[i+1]];
        }
        chmin(res, dist);
    }while(next_permutation(all(rute)));
    cout << res << ln;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int MOD = 1e9+7;

int main() {

	int h, w; cin >> h >> w;
	vector<vector<int>> a(10, vector<int>(10));
	rep(i, 10) rep(j, 10) cin >> a[i][j];

	rep(k, 10) {
		rep(i, 10) rep(j, 10) {
			a[i][j] = min(a[i][j], a[i][k]+a[k][j]);
		}
	}

	// rep(i, 10) rep(j, 10) cout << a[i][j] << ((j==9)?"\n":" ");

	int ans = 0;
	rep(i, h*w) {
		int x; cin >> x;
		if(x==-1 || x==1) continue;
		ans += a[x][1];
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		int k = sca.nextInt();
		long loop = 1;
		long loop_hantei = 0;
		int[] keta = new int[12];
		boolean flag_runrun = true;
		while(k != 0) {
			flag_runrun = true;
			loop_hantei = loop;
			int i = 0;
			// 桁数を求める
			do {
				keta[i] = (int)(loop_hantei % 10);
				loop_hantei /= 10;
				i++;
			} while(loop_hantei != 0);
			// ルンルン数かどうかを判定する
			for(int j = i-1; j >= 1; j--) {
				if(keta[j] - keta[j-1] > 1 || keta[j-1] - keta[j] > 1) {
					flag_runrun = false;
					loop += (int)(Math.pow(10, (j-1)));
					/* 例えばもしも13000で非ルンルンと判定したとき、
					次に調べる数を14000(=13000+10の3乗)にする */
					break;
				}
			}
			if(flag_runrun == true) {
				loop++;
				k--;
			}
			else {
			}
		}
		System.out.println(loop - 1);

		// 後始末
		sca.close();
	}
}

Measured memory_bytes: 23992
//
//  main.cpp
//  code_festival_2016_B
//
//  Created by 김영주 on 2016. 9. 25..
//  Copyright © 2016년 김영주. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    int R[100001] = {0};
    int n;
    cin >> n;
    for (int i = 1; i<=n; i++)
        cin >> R[i];
    int cnt = 0;
    for (int i = 1; i<=n; i++)
        if (i == R[R[i]])
            cnt++;
    cout << cnt / 2 << endl;
    return 0;
}


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

using namespace std;

char tab[10][10];
char dr[10][10];

int main()
{
    int i, j, n, m, w=0, k, ok, st, tz, f;
    cin >> n >> m >> k;
    for(i=0; i<n; i++){
        cin >> tab[i];
    }
    st=pow(2, n+m);
    for(i=0; i<st; i++){
        tz=i;
        for(j=0; j<n; j++){
            for(f=0; f<m; f++){
                dr[j][f]=tab[j][f];
            }
        }
        for(j=0; j<n; j++){
            if(tz%2){
                for(f=0; f<m; f++){
                    dr[j][f]='.';
                }
            }
            tz/=2;
        }
        for(j=0; j<m; j++){
            if(tz%2){
                for(f=0; f<n; f++){
                    dr[f][j]='.';
                }
            }
            tz/=2;
        }
        ok=0;
        for(j=0; j<n; j++){
            for(f=0; f<m; f++){
                if(dr[j][f]=='#'){
                    ok++;
                }
            }
        }
        if(ok==k){
            w++;
            //cout << i << ' ';
        }
    }
    cout << w << '\n';
    return 0;
}


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

bool even_string(string &S, int N){
	if(N % 2 == 1){
		return false;
	}
	for(int i = 0; i < N / 2; i++){
		if(S[i] != S[N / 2 + i]){
			return false;
		}
	}
	return true;
}

int main(){
	int i;
	string S;
	cin >> S;
	for(i = S.size() - 1; i >= 0; i--){
		if(even_string(S, i)){
			printf("%d\n", i);
			return 0;
		}
	}
}

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

int main() {
  int64_t h, ans, tmp;
  cin >> h;
  
  ans = 0;
  tmp = 0;
  
  while (true) {
    if (h == 1) {
      ans += pow(2.0, tmp);
      break;
    } else {
      h /= 2;
      ans += pow(2.0, tmp);
      tmp++;
    }
  }
  
  cout << ans << endl;
}

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

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

    getchar();
    cin>>s;

    for(int i=0;i<s.length();i++)
    {
        if(int(s[i])+n<=90)
        {
            s[i] = char(int(s[i])+n);
        }
        else
        {
            s[i] =char((int(s[i])+n)-90+64);
        }
    }
    cout<<s<<endl;

   /* for(int i=0;i<s.length();i++)
    {
        cout<<char(int(s[i])+n)<<" ";
    }
*/
    return 0;
}


Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

ll com(ll num){
    return num*(num-1)/2;
}

int main(){
  int n;
  cin>>n;
  VI a(n);
  map<int,int> mp;
  map<int,pair<ll,ll>> ans;
  map<int,ll> result;
  rep(i,n){
    cin>>a[i];
    mp[a[i]]++;
  }
  
  ll res=0,mem;
  for(const auto& x:mp){
     ans[x.first].first=com(x.second);
     ans[x.first].second=com(x.second-1);
     res+=ans[x.first].first;
  }

  mem=res;
  for(const auto& x:mp){
    result[x.first]=res-ans[x.first].first+ans[x.first].second;
    res=mem;
  }
  rep(i,n){
    cout<<result[a[i]]<<endl;
  }

  
  


}


Measured memory_bytes: 24064
#include <iostream>
using namespace std;
 
int N;
int A[10 * 10 * 10 * 10 * 10 + 1];
int B[10 * 10 * 10 * 10 * 10];
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N + 1; ++i) cin >> A[i];
    for (int j = 0; j < N; ++j) cin >> B[j];
  
    int res = 0;
    int counter = 0;
    long long beat = 0; 
  
  	while(counter <= N - 1) {
      if (B[counter] >= A[counter]) {
        beat += A[counter];
        res = B[counter] - A[counter];
        if (res <= A[counter + 1]) {
 		  beat += res;
          A[counter + 1] = A[counter + 1] - res;
        } else {
          beat += A[counter + 1];
          A[counter + 1] = 0;
        }
      } else {
        beat += B[counter];
      }
      counter += 1;
    }
  
    cout << beat;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
n = int(input())
bango = [int(input()) for k in range(n)]
if a in bango and b in bango and c in bango:
    print("Yes")
elif d in bango and e in bango and f in bango:
    print("Yes")
elif g in bango and h in bango and i in bango:
    print("Yes")
elif a in bango and d in bango and g in bango:
    print("Yes")
elif b in bango and e in bango and h in bango:
    print("Yes")
elif c in bango and f in bango and i in bango:
    print("Yes")
elif a in bango and e in bango and i in bango:
    print("Yes")
elif c in bango and e in bango and g in bango:
    print("Yes")
else:
    print("No")

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

int main()
{
	int S;

	cin >> S;

	if (0 <= S && S < 86400)
	{
		int h = S / 3600; 
		int m = (S - h * 3600) / 60; 
		int s = (S - h * 3600) - (m * 60);
		cout << h << ":" << m << ":" << s << "\n";
	}
	else
	{
		cout << "error" ;
	}

	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){

  string str;

  cin>>str;

  int cnt=0;
  
  for(int i=0;i<str.length();i++){
    if(str[i]=='2'){
      cnt++;
    }

  }

  cout<<cnt<<endl;

  return 0;

}


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

int main() {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	if (a > b) {
		ans += a;
		a--;
	}
	else {
		ans += b;
		b--;
	}
	if (a > b) {
		ans += a;
		a--;
	}
	else {
		ans += b;
		b--;
	}
	cout << ans << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    
    ll res = 0;
    rep(i,n)res ^= a[i];
    
    ll ans = 0;
    for(int i=30;i >= 0;i--){
        if(res & (1<<i)){
            rep(j,n){
                ll t = a[j] ^ (a[j]-1);
                if(t+1 == (1<<(i+1))){
                    res ^= t;
                    ans++;
                    break;
                }
            }
        }
    }
    if(res == 0)out(ans);
    else out(-1);
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	char a[4];
	
	scanf("%s",a);
	
	if(a[0] == 'R' && a[1] == 'R' && a[2] == 'R'){
		printf("3");
	}else if(a[0] == 'R' && a[1] == 'R'){
		printf("2");
	}else if(a[1] == 'R' && a[2] == 'R'){
		printf("2");
	}else if(a[0] == 'S' && a[1] == 'S' && a[2] == 'S'){
		printf("0");
	}else{
		printf("1");
	}
	
	
	return 0;
}

Measured memory_bytes: 1640
import java.io.PrintWriter
fun main(args: Array<String>) {
    val (X, Y, Z, K) = readLine()!!.split(" ").map(String::toInt)
    val A = readLine()!!.split(" ").map(String::toLong).sortedDescending()
    val B = readLine()!!.split(" ").map(String::toLong).sortedDescending()
    val C = readLine()!!.split(" ").map(String::toLong).sortedDescending()
    val ab = mutableListOf<Long>(0)
    for (a in A) {
        for (b in B) {
            ab.add(a + b)
        }
    }
    ab.sortDescending()
    val li = mutableListOf<Long>(0)
    for (i in 0 until X * Y) {
        if (i > 3002) break
        for (j in 0 until Z) {
            if (i > 60 && j > 60) break
            li.add(ab[i] + C[j])
        }
    }
    li.sortDescending()
    val pw = PrintWriter(System.out)
    for (i in 0 until K) {
        pw.println(li[i])
    }
    pw.flush()
}

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

struct node {
	int maxv;
	node *son[2];
} *root, pool[0x200000 + 10];

int n, k, idx;
const int N = 0x100000;
void build(node*, const int&, const int&);
void modify(node*, const int&, const int &, const int&, const int&);
int query(node*, int, int, const int&, const int&);

int main() {
	build(root = &pool[idx++], 0, N);
	scanf("%d%d", &n, &k);
	while (n--) {
		int a; scanf("%d", &a);
		int val = query(root, a - k, a + k + 1, 0, N);
		modify(root, a, val + 1, 0, N);
	}
	printf("%d\n", query(root, 0, N, 0, N));
	return 0;
}

void build(node *p, const int &l, const int &r) {
	p->maxv = 0;
	if (l + 1 == r)
		p->son[0] = p->son[1] = nullptr;
	else {
		const int mid = l + r >> 1;
		build(p->son[0] = &pool[idx++], l, mid);
		build(p->son[1] = &pool[idx++], mid, r);
	}
}

void modify(node *p, const int &i, const int &x, const int &l, const int &r) {
	if (l + 1 == r) {
		p->maxv = x;
		return;
	}
	const int mid = l + r >> 1;
	if (i < mid)
		modify(p->son[0], i, x, l, mid);
	else
		modify(p->son[1], i, x, mid, r);
	p->maxv = max(p->son[0]->maxv, p->son[1]->maxv);
}

int query(node *p, int l, int r, const int &L, const int &R) {
	l = max(l, L), r = min(r, R);
	if (l >= r)
		return 0;
	if (l == L && r == R)
		return p->maxv;
	const int mid = L + R >> 1;
	return max(query(p->son[0], l, r, L, mid), query(p->son[1], l, r, mid, R));
}



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int n, k;
  cin >> n >> k;
  combination C(2*n);
  auto H = [&](int n, int r) {
    return C(n+r-1, r);
  };

  mint ans = 0;
  for(int i = 0; i <= min(n-1, k); ++i) {
    ans += C(n, i) * H(n-i, i);
  }
  cout << ans.x << endl;
}


Measured memory_bytes: 6528
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    T = input().rstrip('\n')
    NS = len(S)
    NT = len(T)
    ans = 10000000
    for i in range(NS - NT + 1):
        tmp = 0
        for j in range(NT):
            if S[i+j] != T[j]:
                tmp += 1
        ans = min(ans, tmp)
    print(ans)


if __name__ == '__main__':
    main()


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

ll N, A[3], AI;
lf dp[305][305][305];

lf solve(ll a, ll b, ll c) {
	if (a == 0 && b == 0 && c == 0) return 0;
	if (a < 0 || b < 0 || c < 0) return 0;
	if (dp[a][b][c] >= 0) return dp[a][b][c];
	ll total = a+b+c;
	lf s = 0;
	return dp[a][b][c] = (lf)N/total + (lf)a/total * solve(a-1, b, c) + (lf)b/total * solve(a+1, b-1, c) + (lf)c/total * solve(a, b+1, c-1);
}

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

	cin >> N;
	for (ll i = 0; i < N; i++) {
		cin >> AI;
		A[AI-1]++;
	}

	for (ll i = 0; i < 305; i++) {
		for (ll j = 0; j < 305; j++) {
			for (ll k = 0; k < 305; k++) {
				dp[i][j][k] = -1;
			}
		}
	}

	cout << fixed << setprecision(12) << solve(A[0], A[1], A[2]) << "\n";

}

Measured memory_bytes: 443776
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int ans[500][500] = {};
void u(int a,int b,int now){
  ans[a][b] = now;
  ans[b][a] = now;
}
void dfs(int t,int cnt, int now){
  if(cnt == 2){
    u(t,t+1,now);
  }else if(cnt == 3){
    u(t,t+1,now);
    u(t,t+2,now);
    u(t+1,t+2,now+1);

  }else{
    bool dd = cnt%2;
    int nt = t + cnt/2;
    rep(i,cnt/2)rep(j,cnt/2+dd){
      u(i+t,nt+j,now);
    }
    dfs(t,cnt/2,now+1);
    dfs(nt,cnt/2+dd,now+1);
  }
}
int main(){
  int n; cin >> n;
  dfs(0,n,1);
  rep(i,n){
    rep(j,n){
      if(i == j) continue;
      if(i > j)  continue;
      cout << ans[i][j];
      if(j != n-1) cout << ' ';
    }
    cout << endl;
  }
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
     cout << fixed << setprecision(20);

     ll a,b,k; cin >> a>> b >> k;
     if(a > k) cout << a-k << ' ' << b << '\n';
     else if(b > k-a) cout << 0 << ' ' << b-k+a << '\n';
     else cout << 0 << ' ' << 0 << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256