akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=200005;
//i_am_noob

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cout << fixed << setprecision(12);
	int a,b,c;
	cin >> a >> b >> c;
	print1(max(0ll,b+c-a));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

int main() {
	float l;

	cin >> l;
	int k;
	float size = 0;
	// for (int i = 1; i <= l; i++) {
	// 	for(int j = 1; j <= l - i; j++) {
	// 		k = l - i - j;
	// 		int temp = i * j * k;
	// 		size = max(size, temp);
	// 	}
	// }
	// cout << size << endl;
	size = (l / 3) * (l / 3) * (l / 3);
	printf("%f\n", size);
	// cout << size << endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()

    /*  ペア関連
    //vector<pair<long long, long long> > pairs(N);
    for(long long i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    
    //sort(pairs.begin(), pairs.end(),greater<pair<int,int> >());
	sort(pairs.begin(), pairs.end());
    */

 	//stack<int> sta;   
    //queue<int> que;


int main(){
	
	long long N,M,K;
	string s;
    
	std::cin >> N;
    //std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    
	std::vector<long long> v(N);
	std::vector<long long> w(N);
	std::vector<long long> x(N);
	std::vector<long long> y(N);
    //std::cin >> s;
    
    
    // 配列入力
    
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
	}
	
	
	for(long long i=0; i<N; i++){
		std::cin >> w[i];
	}
	for(long long i=0; i<N; i++){
		x[i]=0;
		y[i]=0;
	}
	
	//ソート
    //std::sort(v.begin(),v.end());//昇順ソート
    //std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
    //std::sort(w.begin(),w.end());//昇順ソート
    //std::sort(w.begin(),w.end(),std::greater<long long>());//降順ソート
    int sum,sum2;
	sum=0;
	sum2=0;
	int flg,flg1,cnt,cnt1;
	flg=0;
	flg1=0;
	cnt=0;
	cnt1=0;

    
	for(long long i=0; i<N; i++){
		if(i==0){
			x[i]=v[i];
		}
		else{
			x[i]=x[i-1]+v[i];
		}
	}
	for(long long i=0; i<N; i++){
		if(i==0){
			y[i]=w[i];
		}
		else{
			y[i]=y[i-1]+w[i];
		}
	}
	int max;
	max=x[N-1]+w[N-1];
	for(long long i=0; i<N; i++){
		if(max<x[i]+y[N-1]-y[i]+w[i]){
			max=x[i]+y[N-1]-y[i]+w[i];
		}
	}
	
	//文字列入力
	/*
	for(long long i=0; i<s.length(); i++){
		
		if(s[i]!='1'){
	}
	*/
    if(1){
    	printf("%d",max);
    	//puts("Yes");
    	//文字列の出力
    	//std::cout << s << std::endl;
	}
	else{
		//puts("No");
	}
	return 0;
}

Measured memory_bytes: 768
/*Shivam Bhalla */
/* f2016941@pilani.bits-pilani.ac.in */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
long long maxv = 1e9;

int main(){
	string str;
	cin>>str;
	for(int i=0;i<str.length()-1;i++){
		if(str[i]==str[i+1]){
			cout<<"Bad";
			return 0;
		}
	}
	cout<<"Good";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
using namespace std;
int main(){
    int n,q;
    queue<int> tim;
    queue<string> nam;
    cin >> n >> q;
    for(int i = 0;i < n;i++){
        int a; 
        string s;
        cin >> s >> a;
        nam.push(s);
        tim.push(a);
    }
    int t = 0;
    while(!tim.empty()){
        if(tim.front() <= q){
            t += tim.front();
            cout << nam.front() << " " << t << endl;
            tim.pop();
            nam.pop();
        }
        else{
            t += q;
            string v = nam.front();
            nam.pop();
            nam.push(v);
            int w = tim.front();
            tim.pop();
            tim.push(w - q);
        }
    }
    return 0;
}



Measured memory_bytes: 5836
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    cout << (n % 2 == 1 ? n * 2: n) << endl;
    return 0;
}




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

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input().rstrip()

def win(s):
    if s == 'r':
        return 'p'
    elif s == 's':
        return 'r'
    elif s == 'p':
        return 's'
    else:
        return 'x'
        
def point(s):
    if s == 'r':
        return R
    elif s == 's':
        return S
    elif s == 'p':
        return P
    else:
        return 0

ans = 0
tmp = ''
for i in range(len(T)):
    if i < K:
        tmp += T[i]
    elif T[i] != tmp[i-K]:
        tmp += T[i]
    else:
        tmp += 'x'

for i in range(len(T)):
    ans += point(win(tmp[i]))


print(ans)




Measured memory_bytes: 3444
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N%2==0:
    print(B[N//2-1] + B[N//2] - (A[N//2-1] + A[N//2]) + 1)
else:
    print(B[(N-1)//2] - A[(N-1)//2] + 1)

Measured memory_bytes: 104428
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b; cin >> a >> b;

    cout << a * b - ( a + b - 1 ) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
//Graph I - Depth First Search - stack version
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_B

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

//WHITE -> ????¨?????????????
//GRAY  -> ?¨????????????????(?¨?????????????????¨???????????????????????????????????????§???????????????)
//BLACK -> ?¨??????????????????????(????¨???????????????????????????????????????????)

int n, M[N][N];
int color[N];//?????????????¨??????¶???
int d[N];//????????????
int f[N];//????????????
int tt;//time stamp
int nt[N];

//u?????£??\??????v?????????????????????
int next( int u )
{
	for( int v = nt[u]; v < n; v++ ){
		nt[u] = v + 1;
		if( M[u][v] ) return v;
	}
	return -1;
}
//stack?????¨????????±???????????¢?´¢
void dfs_visit( int r )
{
	for( int i = 0; i < n; i++ ) nt[i] = 0;

	stack<int> S;
	S.push( r );
	color[r] = GRAY;
	d[r] = ++tt;

	while( !S.empty() )
	{
		int u = S.top();
		int v = next(u);
		if( v != -1 )
		{
			if( color[v] == WHITE ){
				color[v] = GRAY;
				d[v] = ++tt;
				S.push(v);
			}
		}else{
			S.pop();
			color[u] = BLACK;
			f[u] = ++tt;
		}
	}
}
void dfs(){
	//?????????
	for( int i = 0; i < n; i++ ){
		color[i] = WHITE;
		nt[i] = 0;
	}
	tt = 0;
	//????¨??????? u ???????§?????????¨????????±???????????¢?´¢
	for( int u = 0; u < n; u++ ){
		if( color[u] == WHITE ) dfs_visit( u );
	}
	for( int i = 0; i < n; i++ ){
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;
	}
}
int main()
{
	int u;//???????????????
	int k;//??????u?????£??\?????????????????????
	int v;//??????u????¬???°

	cin >> n;

	for( int i = 0; i < n; i++ ){
		for( int j = 0; j < n; j++ ){
			M[i][j] = 0;
		}
	}
	for( int i = 0; i < n; i++ ){
		cin >> u >> k;
		u--;
		for( int j = 0; j < k; j++ ){
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	dfs();
	return 0;
}

Measured memory_bytes: 3224
n=int(input())
l=[int(i) for i in input().split()]
if 0 not in l:
    dic={}
    ll=[]
    for i in l:
        if i not in ll:
            ll.append(i)
            dic[i]=1
        else:
            dic[i]+=1
        if len(ll)>3:
            break
    if len(ll)==3:
        x,y,z=ll[0],ll[1],ll[2]
        nx,ny,nz=dic[x],dic[y],dic[z]
        if max(nx,ny,nz)-min(nx,ny,nz)<=1 and x^y==z:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    l.sort()
    if l[-1]==0:
        print("Yes")
    else:
        cnt=l.count(l[-1])
        zcnt=n-cnt
        if n%3==0:
            if cnt==zcnt*2:
                print("Yes")
            else:
                print("No")
        elif n%3==1:
            if zcnt==(n+2)//3 or zcnt==(n-1)//3:
                print("Yes")
            else:
                print("No")
        else:
            if zcnt==(n+1)//3 or zcnt==(n-2)//3:
                print("Yes")
            else:
                print("No")


Measured memory_bytes: 60784
s=[int(x) for x in list(input())]


e = [0, 1] * (int(len(s)/2) + 1)

h = [0, 0]
h[0] = sum([x == ei for x, ei in zip(s,e[0:len(s)])])
h[1] = sum([x == ei for x, ei in zip(s,e[1:len(s)+1])])

print(min(h))

Measured memory_bytes: 6172
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
//#define int long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 1001110;
const int M = 1e9+7;
int n,m,ok;

string s;
int dp[maxn][2];

signed main()
{
	cin>>s;
	n = s.size();
	dp[0][1] = 1;
	for(int i = 1; i <= n; i++) 
	{
		dp[i][0] = min(dp[i-1][0],dp[i-1][1]+1)+(s[i-1]-'0');
		dp[i][1] = min(dp[i-1][0],dp[i-1][1]-1)+(10-(s[i-1]-'0'));
	}
	cout<<min(dp[n][0],dp[n][1]+1)<<endl;
	return 0;
}

Measured memory_bytes: 9220
#define ENABLE_LL
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);


void init() {
     
}

void solve() {
    int t1, t2, a1, a2, b1, b2;
    scanf(III,&t1,&t2,&a1); scanf(III,&a2,&b1,&b2);
    a1 -= b1; a2 -= b2;
    if (a1 > 0) { a1 = -a1; a2 = -a2; }
    int a = a1*t1 + a2*t2;
    int b = -a1*t1;
    if (a < 0) puts("0");
    else if (a == 0) puts("infinity");
    else printf(IN,b/a + (b-1)/a + 1);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int fx[]={0,1,0,-1};
int fy[]={-1,0,1,0};
int main()
{
    long long N,b,ans=0,i;
    cin>>N;
    vector<long long> a(N);
	for(i=0;i<N;++i)
	{
		cin>>a[i];
		a[i]= a[i]-(i+1);
	}
	sort(a.begin(),a.end());
	b=a[(N)/2];
	for(i=0;i<N;++i){
	    ans+=abs(a[i]-b);
    }
    cout<<ans<<endl;
	return 0;
}


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

int main() {
	int A, B, count = 0;
	cin >> A >> B;
	for (int i = 1; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				int x = i * 10001 + j * 1010 + k * 100;
				if (A <= x && x <= B) count++;
			}
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit 
N = int(input())
# 再帰の深さを増やしておく
sys.setrecursionlimit(10**9+1)

nodes = [[] for _ in range(N+1)]
for i in range(N-1):
      a,b,c, = map(int, input().split())
      # a->bとb->aの両方について保存
      nodes[a].append((b,c))
      nodes[b].append((a,c))

memo = [0] * (N+1)

# searchedというdistを持たせて調べた場所を管理するのも可能か
def dfs(cur, prev, dist):
      # ある地点（K）から現在地点までのコストを記入しておくことで、最終的にKから他のノードまでの距離が記入される
      memo[cur] = dist
      # nodes[a]から移動できる先と距離を取り出す
      for next, cost in nodes[cur]:
            # 移動前に戻ると無限ループするので飛ばす。searchedなりを持たせてもいい
            if next == prev:
                  continue
            # 移動先について探索を行う
            dfs(next, cur, dist+cost)

Q,K = map(int, input().split())
dfs(K, 0, 0)
for _ in range(Q):
      x,y = map(int, input().split())
      print(memo[x]+memo[y])

Measured memory_bytes: 131632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
ll quick(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1)
			ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
ll inv(ll a){return quick(a,mod-2);}
const int maxn=1e6+7;
ll fac[maxn];
void db()
{
	fac[0]=1;
	for(int i=1;i<maxn;i++)
		fac[i]=fac[i-1]*i%mod;
}
ll C(int n,int m)
{
	return fac[n]*inv(fac[n-m])%mod*inv(fac[m])%mod;
}
int main()
{
	db();
	int n,m,k;
	cin>>n>>m>>k;
	ll ans=0;
	ll cur=1;
	for(int t=0;t<=m+k;t++)
	{
		ans=(ans+cur*C(t+n-1,n-1)%mod*quick(3,m+k-t)%mod)%mod;
		cur=cur*2%mod;
		if(t+1>m)
			cur=(cur-C(t,m)+mod)%mod;
		if(t+1>k) cur=(cur-C(t,t-k)+mod)%mod;
	}
	cout<<ans<<endl;
}


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

#define IO  ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define endl '\n'
#define f first
#define s second
#define ll long long
#define ld long double
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int M=2e5+5;

int main() {
    IO
    int k,n,x,freq[M]={},ans=0;
    set<int>s;
    set<int>::iterator it;
    vector<int>v;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x;
        freq[x]++;
        s.insert(x);
    }
    if(s.size()<=k){
        return cout<<0,0;
    }
    for(it=s.begin();it!=s.end();it++){
        v.push_back(freq[*it]);
    }
    sort(v.rbegin(),v.rend());
    for(int i=k;i<v.size();i++)
        ans+=v[i];
    cout<<ans;

    return 0;
}


Measured memory_bytes: 14228
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
	double a,b,c,d,e,f;
	while(cin >> a >> b >> c >> d >> e >> f){
		double t = 1 / (a*e - b*d);
		double x = (e*c - b*f);
		x *= (x == 0.0) ? 0.0 : t;
		double y = (a*f - c*d) ;
		y *= (y == 0.0) ? 0.0 : t;
		printf("%.3f %.3f\n", round(x*1000)/1000.0, round(y*1000)/1000.0);
	}
	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

const int MOD = 998244353;

signed main() {
    int N;
    cin >> N;
    map<int, int> mp;
    vi dis(N);
    rep(i, N) {
        cin >> dis[i];
        mp[dis[i]]++;
    }

    if(mp[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    int res = 1;
    FOR(i, 1, N) {
        res *= mp[dis[i]-1];
        res %= MOD;
    }
    cout << res << endl;

    
    return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
    #include<stdlib.h>
    int main(){
      int n,sum;
      int *a;
      scanf("%d",&n);
     
      a = (int *)calloc(n,sizeof(int));
      if(a == NULL) exit(-1);
     
      sum = 0;
      for(int i = 0;i < n; i++){
        scanf("%d",&a[i]);
        a[i]--;
        sum += a[i];
      }
      free(a);
      printf("%d",sum);
      return 0;
    }

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);
		
		int i = br.readLine().indexOf("AC");
		
		if(i >= 0) writer.println("Yes");
		else writer.println("No");
		
		br.close();
		writer.close();
	}
}

Measured memory_bytes: 21204
#include <iostream>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int n , k;
  cin >> n >> k;
  string s;
  cin >> s;
  if(s[k-1] == 'A')s[k-1] = 'a';
  else if(s[k-1] == 'B')s[k-1] = 'b';
  else s[k-1] = 'c';
  cout << s << endl;
}



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

void lcm(int &a,int b){
  a=a*b/__gcd(a,b);
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n,m,a=1;cin>>n>>m;bool f=0;
  while(n--){
    int b;cin>>b;
    if(f&&(a%__gcd(a<<1,b)!=(b>>1)%__gcd(a<<1,b)))fin(0);f=1;
    lcm(a,b/2);
    if(m<a)fin(0);
  }
  cout<<((m/a+1)/2)<<endl;
}


Measured memory_bytes: 256
def count_ones(num):
    num = (num & 0x55555555) + (num >> 1 & 0x55555555) 
    num = (num & 0x33333333) + (num >> 2 & 0x33333333)
    num = (num & 0x0F0F0F0F) + (num >> 4 & 0x0F0F0F0F)
    num = (num & 0x00FF00FF) + (num >> 8 & 0x00FF00FF)
    num = (num & 0x0000FFFF) + (num >>16 & 0x0000FFFF)
    return num
ans = 0
cnt = 0
check = 0
n = int(input())
temp_n = 2**n-1
# print(bin(temp_n^255))
# print(count_ones(temp_n^255))
ls_xy = [[0,0] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        if y == 1:
            ls_xy[i][0] += 2**(x-1)
        elif y == 0:
            ls_xy[i][1] += 2**(x-1)

for i in range(2**n):
    check = 0
    for j in range(n):
        if i&(2**j) == 0:
            # print("c",i,j)
            continue
        if (~i & (2**n-1)) & ls_xy[j][0] > 0 or i & ls_xy[j][1] > 0:
            check = 1
            # print("b",i,j)
            break
    if check == 0 and count_ones(i) > ans:
        ans = count_ones(i)
print(ans)




Measured memory_bytes: 41200
n = int(input())

D = list(map(int, input().split()))

m = int(input())

T = list(map(int, input().split()))

D = sorted(D)
T = sorted(T)

import collections

A = collections.Counter(D)
B = collections.Counter(T)

ok = 0
for i in B:
    if A[i] >= B[i]:
        continue
    else:
        ok = 1
        break
if ok == 1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 127572
#include <bits/stdc++.h>
using namespace std;
int main(){
	int c[3][3];
	for( int i=0; i<3; i++ ){
		for( int j=0; j<3; j++ ){
			cin >> c[i][j];
		}
	}
	
	int temp;
	for( int i=0; i<3; i++ ){
		temp = c[0][i] - c[0][(i+1)%3];
		for( int j=1; j<3; j++ ){
			if( c[j][i] - c[j][(i+1)%3] != temp ){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	for( int i=0; i<3; i++ ){
		temp = c[i][0] - c[(i+1)%3][0];
		for( int j=1; j<3; j++ ){
			if( c[i][j] - c[(i+1)%3][j] != temp ){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
using namespace std;

int main()
{
  int n;
  cin>>n;
  if(n==1)
    cout<<"1.0000000000"<<endl;
  else if(n%2==0)
    cout<<"0.5000000000"<<endl;
  else if(n%2==1)
  {
      float h=((n/2+1)*1.0)/n;
      printf("%.6f\n",h);
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	int n;
	cin >> n;

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

}

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

using namespace std;

int main() {
	int W, H, x;
	vector<pair<int, int>> P;
	cin >> W >> H;
	for (int i = 0; i < W; i++)
		cin >> x, P.push_back({x, 0});
	for (int i = 0; i < H; i++)
		cin >> x, P.push_back({x, 1});
	sort(P.begin(), P.end(), [](pair<int,int> a, pair<int,int> b) {
		return a.first < b.first;
	});
	W++, H++;
	long long r = 0;
	for (auto &p : P) {
		if (p.second)
			r += W * p.first, H--;
		else
			r += H * p.first, W--;
	}
	cout << r;
	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main() {
	int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if (sx > tx) x = -x;
		if (sy > ty) y = -y;
		a[i] = {x, y};
	}
	if (sx > tx) sx = -sx, tx = -tx;
	if (sy > ty) sy = -sy, ty = -ty;
	sort(a.begin(), a.end());
  vector<int> val;
  for (int i = 0; i < n; i++) {
    if (
			sx <= a[i].first && a[i].first <= tx &&
			sy <= a[i].second && a[i].second <= ty
		) {
      val.push_back(a[i].second);
    }
  }
	int sz = val.size();
	vector<int> lis;
	for (auto crr : val) {
		auto lb = lower_bound(lis.begin(), lis.end(), crr);
		if (lb == lis.end()) lis.push_back(crr);
		else *lb = crr;
	}
	double pi = acos(0) * 2;
  double w = tx - sx;
  double h = ty - sy;
  int cnt = lis.size();
  double ret = 100LL * (w + h);
  ret += cnt * (20 * pi / 4 - 20);
  if (w < cnt || h < cnt) ret += 20 * pi / 4;
  cout << setprecision(12) << ret << endl;
  return 0;
}


Measured memory_bytes: 4084
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<String> = get_vec();
    if v[0] == "H" && v[1] == "H" || v[0] == "D" && v[1] == "D" {
        println!("{}", "H");
    }
    else {
        println!("{}", "D");
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  ll n;
  cin >> n;
  vecll b(61, 0);
  REP(i, n) {
	ll e;
    cin >> e;
    REP(bit, 61) {
      if ((e >> bit) & 1) {
        b[bit]++;
      }
    }
  }
  vecll powmod(61, 0);
  powmod[0] = 1LL;
  REP(i, 60) { powmod[i + 1] = powmod[i] * 2LL % MOD; }
  ll ans = 0;
  REP(i, 61) {
    ans += (powmod[i] * b[i] % MOD) * (n - b[i]) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

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

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

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

    // start
    vector<char> s(4);
    rep(i, 4) cin >> s.at(i);
    rep(i, 3)
    {
        if (s.at(i) == s.at(i + 1))
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll sum = 0;
  vi A(n);
  for(auto &a:A){cin>>a;sum += a;sum%=MOD;}
  ll ans = 0;
  for(int i=0;i<n;i++){
    ans += (A[i]*(sum-A[i]+MOD))%MOD;
    sum-=A[i];
    sum = (sum+MOD)%MOD;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

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

    string s; cin >> s;
    int n = s.size();

    // 桁 dp
    // dp[i][j] : i = digit, j = less
    int dp[20][2] = {};
    rep(i, n) rep(j, 2){
        if(i == 0 && j == 1) continue;
        int lim = j ? 9:s[i]-'0';
        rep(d, lim+1){
            chmax(dp[i+1][j || d<lim], dp[i][j]+d);
        }
    }
    cout << max(dp[n][0], dp[n][1]) << endl;

    return 0;
}



Measured memory_bytes: 256
import sys,os,re
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations
sys.setrecursionlimit(10**6)

while 1:
    n,x=map(int,input().split())
    cnt=0
    if (n,x)==(0,0):
        break
    a=list(range(1,n+1))
    b=list(combinations(a,3))
    for i in b:
        if sum(i)==x:
            cnt+=1
    print(cnt)


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

int main(void){
    int n;
    string s,rs;
    cin>>n>>s;
    rs = s;
    vector<int> lw(n), re(n);
    int pre = 0;
    rep(i,n){
        lw[i] = pre;
        if(s[i] == 'W'){
            pre++;
        }
    }
    pre = 0;
    for(int i = n-1; i>=0; i--){
        re[i] = pre;
        if(s[i] == 'E'){
            pre++;
        }
    }
    int res = n;
    rep(i,n){
        res = min(lw[i]+re[i],res);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3332
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    a,b,c,d = IR(4)
    print(min(a,b)+min(c,d))

#B
def B():
    n = I()
    d,x = LI()
    a = IR(n)
    for i in range(1,d+1):
        for j in a:
            if (i-1)%j == 0:
                x += 1
    print(x)
#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 39280
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()
N = len(S)
K = INT()

subs = set()
for i in range(N):
    for j in range(i+1, N+1):
        # K文字以下だけ
        if j-i > K:
            break
        subs.add(S[i:j])

subs = sorted(subs)
print(subs[K-1])


Measured memory_bytes: 4588
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

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

    int root_n;
    for(root_n=1; root_n*root_n<n; ++root_n);

    // initialize container
    vector<int> array(n, 0);
    vector<int> blocks(root_n, 0);

    rep(_, 0, q)
    {
        int com;
        cin >> com;

        if (com == 0)
        {
            int s, t, x;
            cin >> s >> t >> x;
            --s, --t;

            // ex)
            //  s       t 
            // AAA BBB CCC
            //  0   1   2
            // block_s -> 1
            // block_t -> 1
            int block_s = s/root_n + 1;
            int block_t = t/root_n - 1;
            // cout << block_s << ' ' << block_t << endl;
            
            rep(i, block_s, block_t+1)
                blocks[i] += x;
            for(int i=s; i<block_s*root_n and i <=t; ++i)
                array[i] += x;

            // if s and t are at same block
            if (block_s-1==block_t+1) continue;

            for (int i=(block_t+1)*root_n; i<=t; ++i)
                array[i] +=x;

            // cout << "*-----------" << endl;
            // pvec(blocks);
            // pvec(array);
        }
        else
        {
            int t;
            cin >> t;
            --t;
            printf("%d\n", array[t] + blocks[t/root_n]);
        }
    }
    return 0;
}


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    double t,a;
    cin>>n>>t>>a;
    int ans=-1;
    double mindiff=INF;
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        if(abs(a-(t-h*0.006))<mindiff){
            mindiff=abs(a-(t-h*0.006));
            ans=i+1;
        }
    }
    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int A[100000];

int  partition(int p, int r){
    int x = A[r];
    int i = p-1;
    for( int j = p; j < r; j++){
        if( A[j] <= x){
            i++;
            int o = A[j];
            A[j] = A[i];
            A[i] = o;
        }
    }
    A[r] = A[i+1];
    A[i+1] = x;
    return i+1;
}

int main(){
    int n;
    scanf("%d", &n);
    for( int k = 0; k < n; k++){
        scanf("%d", &A[k]);
    }
    int q = partition( 0, n-1);

    for( int l = 0; l < n; l++){
    	if( l ) printf(" ");
        if( l == q ) printf("[");
        printf("%d", A[l]);
        if( l == q) printf("]");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[5];
    for(int i=0;i<5;i++){
        cin >> a[i];
    }
    int k;
    cin >> k;
    bool flag=true;
    for(int i=0;i<=5;i++){
        for(int j=i+1;j<5;j++){
            if(a[j]-a[i]>k){
                flag=false;
                break;
            }
        }
    }
    if(flag){
        cout << "Yay!" << endl;
    }
    else cout << ":(" << endl;

}


Measured memory_bytes: 256
def insert_sort(nums, n):
    for i in range(1, n):
        nums_str = map(str, nums)
        print(" ".join(nums_str))
        v = nums[i]
        j = i - 1
        while j >= 0 and nums[j] > v:
            nums[j+1] = nums[j]
            j-=1

        nums[j+1] = v

    nums_str = map(str, nums)
    print(" ".join(nums_str))


if __name__=="__main__":
    n = int(input())
    nums = list(map(int, input().split()))
    insert_sort(nums, n)


Measured memory_bytes: 5600
#include<algorithm>
#include<iostream>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
long long s[MN+5];
int n,a[MN+5];
bool Solve(int x)
{
	long long y=s[x];
	for(int i=x+1;i<=n;++i)
		if(y*2<a[i]) return false;
		else y+=a[i];
	return true;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i) s[i]=s[i-1]+a[i];
	int l=1,r=n,mid,res=n+1;
	while(l<=r)
	{
		mid=l+r>>1;
		if(Solve(mid)) res=mid,r=mid-1;
		else l=mid+1;	
	}
	printf("%d\n",n-res+1);
	return 0;
}



Measured memory_bytes: 1408
#include <cstdio>

int g[120000];
int i,k1,k2,n,l,r,mid;
long long t;

int main()
{
	scanf("%d%d%d",&n,&k1,&k2);
	for (i=1;i<=n;i++)
		scanf("%d",&g[i]);
	l=1,r=1000000000;
	while (l<r)
	{
		mid=(l+r)/2;
		t=0;
		for (i=1;i<=n;i++)
			if (g[i]>=1LL*mid*k2)
				t=t+(g[i]-1LL*mid*k2+k1-k2-1)/(k1-k2);
		if (t<=mid)
			r=mid;
		else
			l=mid+1;
	}
	printf("%d",l);
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    map<int, int> ma;
    rep(i, N) {
        cin >> p[i];
        ma[p[i]] = 3;
    }

    ll diff = INF;
    int ans;
    for (int i = -1000; i < 1000; i++) {
        if (ma[i] == 3)
            continue;
        if (abs(i - X) < diff) {
            diff = abs(i - X);
            ans = i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3728
#include <iostream>
using namespace std;
int main()
{
  int N, A, B;
  string S;
  cin >> N >> A >> B >> S;
  int cnt1 = 0;
  int cnt2 = 0;
  for (int i = 0; i < N; i++)
  {
    string ans = "No";
    if (S[i] == 'a')
    {
      if (cnt1 < A + B)
      {
        ans = "Yes";
        cnt1++;
      }
    }
    else if (S[i] == 'b')
    {
      if (cnt1 < A + B && cnt2 < B)
      {
        ans = "Yes";
        cnt1++;
        cnt2++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D){
  cout << "Left" << endl;
  }
  else if(A + B == C + D){
  cout << "Balanced" << endl;
  }
  else{
  cout << "Right" << endl;
  }
}

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

int n, m, ar[111];
int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        cin >> n>> m;
        for (int i = 0; i < n; i++) {
                int a;
                cin >> a;
                while ( a-- ) {
                        int b;
                        cin >> b;
                        ar[b]++;
                }
        }
        int an = 0;
        for (int i = 1; i <= m; i++) {
                if (ar[i] == n) an++;
        }
        cout << an;
return 0;
}


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

int N, M;
const int MAX_NM = 30;
int K[MAX_NM];
int A[MAX_NM][MAX_NM];

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++){
        cin >> K[i];
        for (int j = 0; j < K[i]; j++){
            cin >> A[i][j];
        }
    }

    int fav[M];
    memset(fav, 0, sizeof fav);
    for (int i = 0; i < N; i++){
        for (int j = 0; j < K[i]; j++){
            fav[A[i][j] - 1]++;
        }
    }
    
    int ans = 0;
    for (int i = 0; i < M; i++){
        if (fav[i] == N) ans++;
    }
    cout << ans << endl;
    return 0;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ctime>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
#define all(x) (x).begin(), (x).end()   // sort(all(v)) instead sort(v.begin(),v.end())
int binary(vector<int> arr,int ele,int beg=1)
{   int l=arr.size()-1,mid;
    while(beg<=l)
    {
        mid=(beg+l)/2;
        if(arr[mid]==ele)
            return mid;
        else if(arr[mid]>ele)
            l=mid-1;
        else
            beg=mid+1;
    }
    return -1;

}
ll powe(ll base,ll pow)
{
    ll res=1;
    while(pow>0)
    {
        if(pow&1)
            res*=base;
        else
            base*=base,pow/=2;
    }
    return res;
}
int main() {
    fast;
    int ti = 1;
    //cin >> ti;

    while (ti--){
        ll n,k,d;
        cin>>n>>k>>d;
        if(d==abs(n))
        {
            if(k&1)
                cout<<0;
            else
                cout<<abs(n);
            continue;
        }
        else if(d<abs(n)) {
            ll ans = abs(n) % d;
            ll moves= abs(n)/d;
            if(moves==k)
                cout<<ans;
            else if(moves>k)
            {
                cout<<abs(n)-k*d;
            }
            else {
                k-=moves;
                if(k&1)
                    cout<<d-ans;
                else cout<<ans;
            }

        }
        else {
            ll ans=abs(n)-d;
            if(k&1)
                cout<<abs(ans);
            else
                cout<<abs(n);
        }

    }

}


Measured memory_bytes: 3612
n = int(input())
nt, nx, ny = 0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    now = t-nt
    location = abs(nx-x) + abs(ny-y)
    if location <= now and (now-location)%2 == 0:
        nt, nx, ny = t, x, y
    else:
        print('No')
        exit()
print('Yes')

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    bool t[30] = { false };
    int a;
    for (int i = 0; i < 28; i++) {
        cin >> a;
        t[a-1] = true;
    }
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < 30; i++) {
        if (!t[i]) {
            if (!ans1) ans1 = i + 1;
            else {
                ans2 = i + 1;
                break;
            }
        }
    }
    cout << ans1 << '\n' << ans2 << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <complex>
#include <cstdio>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef complex<double> Point;

//円と円の交点. 接する場合も空のvectorを返す.
vector<Point> kouten_CC(Point c1, double r1, Point c2, double r2) {
	Point r = c2 - c1;
	if (norm(r) >= (r1 + r2) * (r1 + r2)) { return vector<Point>(); }
	if (min(r1, r2) + abs(r) <= max(r1, r2)) { return vector<Point>(); }
	double theta = acos((norm(r) + r1 * r1 - r2 * r2) / (2 * r1 * abs(r)));
	Point R = (r1 / abs(r)) * r;
	Point res1 = R * exp(Point(0, 1) * theta);
	Point res2 = R * exp(Point(0, 1) * (-theta));
	vector<Point> ret;
	ret.push_back(c1 + res1);
	ret.push_back(c1 + res2);
	return ret;
}

int n, K;
double x[60], y[60], c[60];

//答えがA以下か？
bool check(double A) {
	double r[60];
	int i, j, k;
	
	rep(i, n) r[i] = A / c[i];
	
	vector<Point> ps;
	rep(i, n) {
		ps.push_back(Point(x[i], y[i]));
		for (j = i + 1; j < n; j++) {
			ps.push_back((Point(x[i], y[i]) + Point(x[j], y[j])) * (double)0.5);
			vector<Point> p = kouten_CC(Point(x[i], y[i]), r[i], Point(x[j], y[j]), r[j]);
			rep(k, p.size()) {
				ps.push_back(p[k]);
				//cout << p[k] << endl;
			}
			if (p.size() == 2) {
				ps.push_back((p[0] + p[1]) * (double)0.5);
			}
		}
	}
	
	//交点ps[i]がK個以上の円に含まれるか判定.
	//誤差が無い場合、円jが交点ps[i]をギリギリ含むことがある。
	//誤差が無い場合、解hを小さくすることで誤魔化すのは難しい。(交点しか見ないため）
	//そこで、円jを少しだけ大きくしておいて判定する。
	double EPS = 1e-11;
	rep(i, n) r[i] += EPS;
	rep(i, ps.size()) {
		int cnt = 0;
		rep(j, n) {
			Point diff = Point(x[j], y[j]) - ps[i];
			if (abs(diff) <= r[j]) cnt++;
		}
		if (cnt >= K) return true;
	}
	return false;
}

int main() {
	int i;
	
	cin >> n >> K;
	rep(i, n) {
		cin >> x[i] >> y[i] >> c[i];
	}
	
	double st = 0, ed = 1e+7, mid;
	for (i = 0; i < 100; i++) {
		mid = (st + ed) / 2;
		if (check(mid)) { ed = mid; }
		else { st = mid; }
	}
	printf("%.14f\n", ed);
	return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }


signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, K; cin >> N >> K;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	map<int, int>mp;
	map<int, int>rev;
	rep(i, 0, N) {
		if (not mp.count(A[i])) {
			int m = mp.size();
			rev[m] = A[i];
			mp[A[i]] = m;
		}
		A[i] = mp[A[i]];
	}
	vector<vector<int>>idx(N);
	rep(i, 0, N) {
		idx[A[i]].eb(i);
	}
	rep(i, 0, N) {
		idx[A[i]].eb(i + N);
	}

	vector<pii>x(N);
	vector<int>visited(N);//idx
	rep(i, 0, N) {
		auto ub = upper_bound(all(idx[A[i]]), i);
		dump(i,idx[A[i]],*ub);
		x[i].first = ((*ub) + 1) % N;
		x[i].second = ((*ub)>= N);
		if (x[i].first == 0)x[i].second++;
	}
	dump(x);
	pii p;
	while (not visited[p.first]) {
		visited[p.first] = 1;
		p.second += x[p.first].second;
		p.first = x[p.first].first;
	}
	dump(p);
	K %= p.second;
	if (K == 0) {
		cout << endl; return 0;
	}
	dump(K);
	rrep(i, 0, N) {
		if (x[i].second)continue;
		x[i].second = 1;
		x[i].first = x[x[i].first].first;
	}
	dump(x);

	int cur = 0;
	loop(K - 1) {
		cur = x[cur].first;
	}
	dump(cur);
	vector<int>ans;
	set<int>st;
	rep(i, cur, N) {
		dump(ans);
		if (st.count(A[i])) {
			while (st.count(A[i])) {
				st.erase(ans.back());
				ans.pop_back();
			}
		}
		else {
			st.insert(A[i]);
			ans.eb(A[i]);
		}
	}

	rep(i, 0, ans.size()) {
		cout << rev[ans[i]] << (i == ans.size() - 1 ? '\n' : ' ');
	}


	return 0;
}


Measured memory_bytes: 54640