akhauriyash/Code-Regression huggingface dataset:
/************************************************
┆  ┏┓　　　┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃　　　　　　　┃ ┆
┆┃　　　━　　　┃ ┆
┆┃　┳┛　┗┳　┃ ┆
┆┃　　　　　　　┃ ┆
┆┃　　　┻　　　┃ ┆
┆┗━┓　  　┏━┛ ┆
┆　　┃　  　┃　　┆　　　　　　
┆　　┃　  　┗━━━┓ ┆
┆　　┃　 AC代马 　　┣┓┆
┆　　┃　        　　┏┛┆
┆　　┗┓┓┏━┳┓┏┛ ┆
┆　　　┃┫┫　┃┫┫ ┆
┆　　　┗┻┛　┗┻┛ ┆
************************************************ */
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstring>
#include<cctype>
#include <math.h>
#include <cmath>
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define lb long double
#define LINF 0x3f3f3f3f3f3f3f3f
#define ull unsigned long long
#define random(x) (rand()%x)
#define rep(i, a, b) for(int i=a;i<b;i++)
#define req(j, a, b) for(int j=a;j<b;j++)
#define mem(a, b) memset(a, b, sizeof(a))
#define PI 3.14
#define K 20

using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5;
const double eps =0.0000000001;     //1e-14;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const int hash_mod = 19260817;

inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline double dbread()
{
    double X=0,Y=1.0; int w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=X*10+(ch^48),ch=getchar();
    ch=getchar();//读入小数点
    while(isdigit(ch)) X+=(Y/=10)*(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x)
{
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

ll gcd(ll a,ll b)//辗转相除法（欧几里德算法）求最大公约数
{
    return b ? gcd(b,a%b) : a;
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);//最小公倍数
}
ll q_pow(ll base, ll p)
{
    ll result = 1;
    while(p > 0)
    {
        if(p&1)
        {//此处等价于if(power%2==1)
            result = result * base % 1000;
        }
        p >>= 1;//此处等价于power=power/2
        base = (base * base) % 1000;
    }
    return result;
}

int sgn(double x)
{
    if(fabs(x) < eps)
        return 0;
    if(x < 0)
        return -1;
    else
        return 1;
}

const int N = 1e4 + 1;
int fri[N];
void  init()
{
    for(int i = 1; i <= N; i++)
        fri[i] = i;
}
int find(int a)		//查找根节点
{
    int tem1 = a,tem2;
    while(a != fri[a])
        a = fri[a];
    while(tem1 != a)
    {
        tem2 = fri[tem1];
        fri[tem1] = a;
        tem1 = tem2;
    }
    return a;
}
void Union(int a,int b)
{
    int fri_a = find(a);
    int fri_b = find(b);
    if(fri_a != fri_b)
        fri[fri_a] = fri_b;
}

struct node
{
    string a;
    set<int> s;
    int pos; 
}p[maxn];

bool cmp(node op1, node op2)
{
    if(op1.pos == op2.pos)
    	return op1.pos < op2.pos;
    else
    	return op1.s.size() > op2.s.size();
}

int main()
{
    int a, b, c;
	cin >> a >> b >> c;
	if(a == b && b != c && a != c || a != b && a != c && b == c || a != b && b != c && a == c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl; 
    return 0;
}




Measured memory_bytes: 62720
#include <bits/stdc++.h>
using namespace std;
int main() {
	int m, d; cin >> m >> d;
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= d; j++) {
			int x = j % 10, y = j / 10;
			if (x < 2 || y < 2) continue;
			if (x * y == i) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;

void solve() {
    ll a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
float c[8];j;
int f(int i){
	return c[i]*(c[(i+3)%6]-c[7])+c[(i+2)%6]*(c[7]-c[i+1])+c[6]*(c[i+1]-c[(i+3)%6]);
}
main(){for(;~scanf("%f",c+j++);j%8||puts(f(j=0)*f(2)>0&&f(2)*f(4)>0?"YES":"NO"));
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

  int n; cin >> n;
  ll ans = 0;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    ans += --a[i];
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100050
#define inf 0x3f3f3f3f
int f[maxn],g[maxn],h[maxn],sum;
int main(){
	int n;cin>>n;
	for(register int i=1;i<=n;++i)scanf("%d",&f[i]);
	for(register int i=0;i<=n;++i)g[i]=abs(f[i+1]-f[i]),sum+=g[i];
	for(register int i=1;i<=n;++i)h[i]=abs(f[i-1]-f[i+1]);
	for(register int i=1;i<=n;++i){
		printf("%d\n",sum-g[i-1]-g[i]+h[i]);
	}return 0;
}


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

int main(){

vector<int>a(3);
for(int i=0;i<3;i++)cin>>a.at(i);
sort(a.begin(),a.end());
cout<<a.at(0)<<" "<<a.at(1)<<" "<<a.at(2)<<endl;



}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define lli long long int

using namespace std;

int main() {

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

	lli n;
	cin >> n;

	vector<lli> a(n);
	lli stool = 0;
	for(lli i = 0; i < n; i++) {
		cin >> a[i];
		if(i > 0) {
			lli curr = max(a[i - 1] - a[i], (lli)0);
			a[i] += curr;
			stool += curr;
		}
		// cout << a[i] << '\n';
	}

	cout << stool << '\n';

	return 0;
}

Measured memory_bytes: 4772
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;



int main(){
  int n,m = 0;
  cin >> n >> m;
  if(n == m){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
 
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,k;
  scanf("%d %d",&n,&k);
  
  char s[n];
  scanf("%s",s);
  s[k-1]=s[k-1]+32;
  for(int i=0;i<n;i++){
  printf("%c",s[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>

using namespace std;

string S;
size_t cur;

int digit(){
  return S[cur++]-'0';
}

int number(){
  int n=digit();
  while(cur<S.size()&&isdigit(S[cur])){
    n=n*10+digit();
  }
  return n;
}

int expression();

int factor(){
  if(isdigit(S[cur]))return number();
  cur++;
  int n=expression();
  cur++;
  return n;
}

int term(){
  int t=factor();
  for(;cur<S.size()&&(S[cur]=='*'||S[cur]=='/');){
    if(S[cur++]=='*')t*=factor();
	else t/=factor();
  }
  return t;
}

int expression(){
  int t=term();
  for(;cur<S.size()&&(S[cur]=='+'||S[cur]=='-');){
    if(S[cur++]=='+')t+=term();
	else t-=term();
  }
  return t;
}

int main(){
  int n;
  cin>>n;
  for(;n--;){
    cur=0;
    cin>>S;
	cout<<expression()<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<vector<pair<UL, UL>>> E(N);
		rep(i, N - 1) {
			UL s, t, w; cin >> s >> t >> w;
			E[s].push_back({ t, w });
			E[t].push_back({ s, w });
		}
		vector<pair<UL, UL>> D(N);
		stack<UL> S;
		{
			vector<UL> F(N);
			queue<UL> Q; Q.push(0);
			while (Q.size()) {
				UL p = Q.front(); Q.pop();
				F[p] = 1;
				S.push(p);
				for (auto e : E[p]) {
					UL v = e.first;
					if (F[v]) continue;
					D[v] = { p, e.second };
					Q.push(v);
				}
			}
		}
		UL ans = 0;
		vector<UL> dp(N);
		while (S.size()) {
			UL p = S.top(); S.pop();
			if (p == 0) continue;
			ans = max(ans, dp[p] + D[p].second + dp[D[p].first]);
			dp[D[p].first] = max(dp[D[p].first], dp[p] + D[p].second);
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}



Measured memory_bytes: 10728
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,m,cnt[2],color[710];
bool dp[710],v[710][710];
void dfs(int x){
    cnt[color[x]]++;
    rep(i,n){
        if(v[x][i]){
            if(color[i]==-1){
                color[i]=1-color[x];
                dfs(i);
            }
            else{
                if(color[i]==color[x]){
                    puts("-1");
                    exit(0);
                }
            }
        }
    }
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,n){
        rep(j,n){
            if(i!=j)v[i][j]=true;
        }
    }
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a][b]=v[b][a]=false;
    }
    fill(color,color+n,-1);
    dp[0]=true;
    rep(i,n){
        if(color[i]==-1){
            cnt[0]=0,cnt[1]=0;
            color[i]=0;
            dfs(i);
            for(int j=700;j>=0;j--){
                if(dp[j]){
                    dp[j]=false;
                    if(j+cnt[0]<=700)dp[j+cnt[0]]=true;
                    if(j+cnt[1]<=700)dp[j+cnt[1]]=true;
                }
            }
        }
    }
    int ans=INF;
    rep(i,n+1){
        if(dp[i]){
            chmin(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
	#define int long long
	int n,m;
	cin >> n >> m;
	int l[m],r[m];
	for(int i = 0; i < m; i++)
	cin >> l[i] >> r[i];
	sort(l,l+m);
	sort(r,r+m);
	int max_left = l[m-1];
	int min_right = r[0];
	if(max_left > min_right)
	{
		cout << "0" << "\n";
	}
	else
	{
		cout << min_right-max_left+1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include<iomanip>
using namespace std;

int main()
{
    string S;
    cin >> S;
    int length;
    length = S.length();
    vector<int> ans;
    int num;
    num = 0;
    for (int i = 0; i < length; i++)
    {
        ans.push_back(num);
    }
    vector<int> change;
    for (int i = 0; i < length-1; i++)
    {
        if(S[i]!=S[i+1])change.push_back(i);
    }
    int counter = 0;
    int diff;
    int flag = 0;
    for (int i = 0; i < length; i++)
    {
        
        if (S[i]=='R')
        {
            if (flag == 2)   
            {
                counter = counter+2;
                flag = 0;
            }
            diff = change[counter]-i;
            if(diff%2 ==1)ans[change[counter]+1] = ans[change[counter]+1]+1;
            else ans[change[counter]]=ans[change[counter]]+1;
            flag = 1;
        }else{
            diff = i - change[counter];
            if(diff%2 ==1)ans[change[counter]+1] = ans[change[counter]+1]+1;
            else ans[change[counter]]=ans[change[counter]]+1;
            flag = 2;
        }
        
    }

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

Measured memory_bytes: 1592
#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];
    }
  }
  bool ans=true;
  for(int i=0; i<2; i++){
    for(int j=1; j<3; j++){
      if(c[i+1][0]-c[i][0] != c[i+1][1]-c[i][1]){
        ans=false;
      }
      if(c[i+1][0]-c[i][0] != c[i+1][2]-c[i][2]){
       ans=false;
      }
      if(c[i+1][1]-c[i][1] != c[i+1][2]-c[i][2]){
        ans=false;
      }
    }
   }
  if(ans)cout << "Yes" << endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        if (n % f(n) == 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

    static int f(int n)
    {
        var ans = 0;
        while (n != 0)
        {
            ans += n % 10;
            n /= 10;
        }
        return ans;
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

typedef pair<int, int> pii;
vector<pii> V;
vector<int> check;
int N, K;

int main() {
	cin >> N >> K;
	V.resize(N);
	for (int n = 0; n < N; n++) {
		cin >> V[n].second >> V[n].first;
		V[n].second--;
	}
	sort(V.begin(), V.end(), [](pii a, pii b) {
		return a.first > b.first;
	});
	check.resize(N, 0);
	long long sum = 0;
	long long kind = 0;
	for (int k = 0; k < K; k++) {
		sum += V[k].first;
		if (check[V[k].second] == 0)kind++;
		check[V[k].second]++;
	}
	priority_queue<pii,vector<pii>,greater<pii>> popvect;
	for (int k = 0; k < K; k++) {
		if (check[V[k].second] > 1)popvect.push(V[k]);
	}
	long long ans = sum + kind * kind;
	for (int k = K; k < N; k++) {
		if (check[V[k].second] > 0)continue;
		sum += V[k].first;
		check[V[k].second]++;
		bool able = false;
		while (!popvect.empty()) {
			pii next = popvect.top();
			popvect.pop();
			if (check[next.second] > 1) {
				sum -= next.first;
				able = true;
				break;
			}
		}
		if (!able)break;
		kind++;
		ans = max(ans, sum + kind * kind);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2044
#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;
  cin >> a >> b;
  string s(b, '0'+a);
  string t(a, '0'+b);
  if (a<b) cout << s << endl;
  else cout << t << endl;
  return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    l, r = list(map(int, input().rstrip('\n').split()))
    m = 10 ** 10
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            m = min(m, (i * j) % 2019)
            if m == 0:
                print(m)
                exit()
    print(m)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38896
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define n 1000006
int main()
{
    vector<ll>v(1000006),sum(1000006,0);
    sum[0]=0;
    v[0]=0;
    for(ll i=1;i<n;i++)
    {
        if(i%3==0||i%5==0)
        {
            v[i]=0;
        }
        else
        v[i]=i;
        sum[i]=sum[i-1]+v[i];
    }
    ll p;
    cin>>p;
    cout<<sum[p];
    return 0;
}

Measured memory_bytes: 18652
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int n;
vector<int> p, sz;
int par(int x) {
	while (x != p[x]) x = p[x];
	return x;
}
void uni(int x, int y) {
	x = par(x);
	y = par(y);
	if (x==y) return;
	if (sz[x] < sz[y]) {
		p[x] = y;
		sz[y] += sz[x];
	}
	else {
		p[y] = x;
		sz[x] += sz[y];
	}
}

int get(int a, int b, int tp) {
	if (tp==0) return min(a, b);
	else return max(a, b);
}

struct st {
	vector<int> t;
	int tp;
	st(int type) {
		tp = type;
		if (tp==0) t = vector<int>(2*n, n);
		else t = vector<int>(2*n, -1);
	}
	void upd(int pos, int val) {
		for (t[pos+=n]=val; pos>1; pos>>=1)
			t[pos>>1] = get(t[pos], t[pos^1], tp);
	}
	int qry(int l, int r) {
		int ans;
		if (tp==0) ans = n;
		else ans = -1;
		for (l+=n, r+=n; l<r; l>>=1, r>>=1) {
			if (l&1) ans = get(ans, t[l++], tp);
			if (r&1) ans = get(ans, t[--r], tp);
		}
		return ans;
	}
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	cin >> n;
	p = vector<int>(n);
	sz = vector<int>(n);
	vector<pair<pii,int>> a(n);
	for (int i=0; i<n; i++) {
		cin >> a[i].first.first >> a[i].first.second;
		a[i].first.first--;
		a[i].first.second--;
		a[i].second = i;
		p[i] = i;
		sz[i] = 1;
	}
	sort(a.begin(), a.end());
	
	vector<int> ypos(n);
	for (int i=0; i<n; i++) {
		int y = a[i].first.second;
		ypos[y] = i;
	}
	
	st amax(1), amin(0);
	for (int i=0; i<n; i++) {
		int id = ypos[i];
		int mx = amax.qry(0, id);
		int mn = amin.qry(0, id);
		if (0<=mx && mx<n) {
			int idx = ypos[mx];
			uni(id, idx);
		}
		if (0<=mn && mn<n) {
			int idx = ypos[mn];
			uni(id, idx);
		}
		amax.upd(id, i);
		amin.upd(id, i);
	}
	st bmax(1), bmin(0);
	for (int i=n-1; i>=0; i--) {
		int id = ypos[i];
		int mx = bmax.qry(id+1, n);
		int mn = bmin.qry(id+1, n);
		if (0<=mx && mx<n) {
			int idx = ypos[mx];
			uni(id, idx);
		}
		if (0<=mn && mn<n) {
			int idx = ypos[mn];
			uni(id, idx);
		}
		bmax.upd(id, i);
		bmin.upd(id, i);
	}
	vector<int> ans(n);
	for (int i=0; i<n; i++) {
		int id = a[i].second;
		ans[id] = sz[par(i)];
	}
	for (int x : ans) cout << x << '\n';
}

Measured memory_bytes: 15084
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, m, i;
	cin >> n >> m;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	int sum = accumulate(arr, arr + n, 0);
	double x = sum / (double)(4.0 * m);
	int cnt = 0;
	fo(i, 0, n) {
		if(arr[i] >= x)
		cnt++;
	}
	cout << (cnt < m ? "No" : "Yes");
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
//#define ll __int64
#define ll long long
#define P pair<ll,ll>

ll k;
int n,m;
int v[1000],w[1000];
vector<int> t[5];


int main(){
	cin>>n>>m;;
	rep(i,5)t[i].resize(0);

	int k;
	rep(i,n){
		cin>>w[i]>>v[i];
		k=w[0];
		t[k+3-w[i]].push_back(v[i]);
	}

	for(int i=0;i<=3;i++){
		//cout<<t[i].size()<<endl;
		sort(t[i].begin(),t[i].end(),greater<int>());
	}
	
	ll ans=0;
	rep(i,max(1,(int)t[0].size()+1)){
		rep(j,max(1,(int)t[1].size()+1)){
			rep(x,max(1,(int)t[2].size()+1)){
				rep(y,max(1,(int)t[3].size()+1)){
					ll tmp=0,we=0;
						rep(z,i)tmp+=t[0][z],we+=k+3;
						rep(z,j)tmp+=t[1][z],we+=k+2;
						rep(z,x)tmp+=t[2][z],we+=k+1;
						rep(z,y)tmp+=t[3][z],we+=k;
						//cout<<i<<" "<<j<<" "<<x<<" "<<y<<" "<<" "<<we<<" "<<tmp<<endl;
						if(we<=m)ans=max(ans,tmp);
				}
			}
		}
	}

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

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,m,l;
    int i,j,k;
    int a[100][100]={{0}};
    int b[100][100]={{0}};
    long c[100][100]={{0}};
     
    scanf("%d%d%d",&n,&m,&l);
     
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            scanf("%d",&a[i][j]);
        }
    }
     
    for(i=0; i<m; i++){
        for(j=0; j<l; j++){
            scanf("%d",&b[i][j]);
        }
    }
     
    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            for(k=0; k<m; k++){
                c[i][j] += a[i][k]*b[k][j];
            }
        }
    }
     
    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            printf("%ld",c[i][j]);
            if(j == l-1) putchar('\n');
            else putchar(' ');
        }
    }
     
    return 0;
}


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

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

	for(ll i = 1;; i++)
	{
		if((i * (i + 1)) / 2 >= x)
		{
			cout<<i<<endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
from math import gcd

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n = inp()
nums = [0] + inlt()
dp = [0 for i in range(n + 1)]
s = [0 for i in range(n + 1)]
s[1] = nums[1]
for i in range(3,n,2):
    s[i] = s[i - 2] + nums[i]
if n == 1:
    print(nums[0])
elif n == 2:
    print(max(nums[1],nums[2]))
elif n == 3:
    print(max(nums[3],nums[1],nums[2]))
elif n == 4:
    print(max(nums[1] + nums[3],nums[1] + nums[4],nums[2] + nums[4]))
else:
    dp[1] = nums[1]
    dp[2] = max(nums[1],nums[2])
    dp[3] = max(nums[3],nums[1],nums[2])
    dp[4] = max(nums[1] + nums[3],nums[1] + nums[4],nums[2] + nums[4])
    for i in range(5,n + 1):
        if i % 2 == 0:
            dp[i] = max(dp[i - 2] + nums[i], s[i - 1]) #if n % 2 == 0 take sum else dp[i - 1]
        else:
            dp[i] = max(dp[i - 2] + nums[i], dp[i - 1])
    print(dp[n])
#print('No')
#print()


Measured memory_bytes: 119492
#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: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main()
{
 
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n, q; cin >> n;
    int a[n]; 
    int s = 0;
    unordered_map<int, int> mpp;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        s += a[i];
        mpp[a[i]]++;
    }
    cin >> q;
    while (q--) {
        int b, c; cin >> b >> c;
            s -= mpp[b]*b;
            s += c*mpp[b];
            mpp[c] += mpp[b];
            mpp.erase(mpp.find(b));
       
        cout << s << endl;
    }
    
    return 0;
}

Measured memory_bytes: 7396
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    if(a == b)
    {
        cout << 2 * a << endl;
        return 0;
    }
    int n = max(a, b);
    int ans = n + n - 1;
    cout << ans << endl;
    return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="AAA" or s=="BBB") cout<<"No\n";
    else cout<<"Yes\n";
	return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 10000
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 505;
const int MAX_M = 200005;

struct Line{
  int L, R;
  bool operator < (const Line& l) const {
    return L < l.L;
  }
};

int N, M, Q;
Line lines[MAX_M];

int sumL[MAX_N][MAX_N];

signed main()
{
  cin >> N >> M >> Q;
  REP(q,M) {
    cin >> lines[q].L >> lines[q].R;
  }

  sort(lines, lines+M);

  int sl = 0;
  REP(l,N) {
    while(sl < M && lines[sl].L < l) {
      sl++;
    }
    FOR(m,sl,M) {
      sumL[l][lines[m].R]++;
    }
    REP(n,N) {
      sumL[l][n+1] += sumL[l][n];
    }
  }

  REP(q,Q) {
    int l,r; cin >> l >> r;
    cout << sumL[l][r] << endl;
  }

  return 0;
}

Measured memory_bytes: 6016
#include<stdio.h>

int main(void) {
int i;
int w,h,x,y,r;
int disx[2];
int disy[2];

scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

disx[0] = x - r;
disx[1] = w - x - r;
disy[0] = y - r;
disy[1] = h - y - r;

if (disx[0] >= 0 && disx[1] >= 0 && disy[0] >= 0 && disy[1] >= 0) {
printf("Yes\n");
} else {
printf("No\n");
}

return (0);
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n,k;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int c[k+1]={0};
        for(int i=0;i<n;i++)
            c[a[i]]=1;
        for(int i=1;i<=k;i++)
        {
            for(int j=0;j<n;++j)
                if(i-a[j]>=0&&!c[i-a[j]])
                  c[i]=1;
        }
        if(c[k])
            cout<<"First"<<endl;
        else
            cout<<"Second"<<endl;
        return 0;
    }

Measured memory_bytes: 640
def main():
    import sys
    from collections import deque
    input = sys.stdin.readline
    N = int(input())
    G = [[] for _ in range(N)]
    ans = {}
    queue = deque([])
    e = []
    for l in range(N-1):
        temp = list(map(int,input().split()))
        temp[0] -= 1
        temp[1] -= 1
        e.append(tuple(temp))
        ans[(temp[0],temp[1])] = 0
        ans[(temp[1],temp[0])] = 0
        G[temp[0]].append(temp[1])
        G[temp[1]].append(temp[0])
        if l == 0:
            queue.append(temp[0])
    #使えない色
    nuc = [[0] for _ in range(N)]
    #使った色
    auc = []
    #答え
    def bfs(x):
        k = 1
        for i in G[x]:
            if ans[(x,i)] ==0:
                queue.append(i)
                flag = 1
                while flag:
                    if k not in nuc[x]:         
                        ans[(x,i)] = k
                        ans[(i,x)] = k
                        nuc[x].append(k)
                        nuc[i].append(k)
                        if k not in auc:
                            auc.append(k)
                        flag = 0
                    else:
                        k += 1
                    
    while len(queue) > 0:
        next_ = queue.popleft()
        bfs(next_)
    print(len(auc))
    for m in e:
        print(ans[m])
if __name__ == '__main__':
    main()

Measured memory_bytes: 123680
import sys
input = sys.stdin.readline
from itertools import *
from collections import *

INF = float('inf')


def main():
    S = input().rstrip()
    str_odd = S[::2]
    str_even = S[1::2]

    if 'L' in str_odd or 'R' in str_even:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <stdio.h>

#define N 251

int main(){
  int n, i;
  int A[N];

  scanf("%d", &n);

  for(i = 1; i <= n; i++) scanf("%d", &A[i]);

  for(i = 1; i <= n; i++){
    printf("node %d: key = %d,", i, A[i]);
    if(i != 1) printf(" parent key = %d,", A[i / 2]);
    if(2 * i <= n) printf(" left key = %d,", A[2 *i]);
    if(2 * i + 1 <= n) printf(" right key = %d,", A[2 * i + 1]);
    printf(" \n");
}
  return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
/*int CurrMin(int b[],int a[],int i,int k)
{
    int min =INT_MAX;
    for(int j = 1; j <= k, i-j >= 0;j++)
    {
        if(b[i - j] + abs(a[i] - a[i-j]) < min)
            min = b[i - j] + abs(a[i] - a[i-j]);


    }

    return min;
}
*/

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i = 0 ;i < n; i++)
        cin>>a[i];
    int b[n] = {0};
    b[1] = abs(a[1] - a[0]);
    for(int i = 2; i < n; i++)
    {
        int min =INT_MAX;
        for(int j = 1; j <= k && i-j >= 0;j++)
        {
            if(b[i - j] + abs(a[i] - a[i-j]) < min)
                {
                    min = b[i - j] + abs(a[i] - a[i-j]);
                   // cout<<"j = "<<j<<"a[i] = "<<a[i]<<" b[i-j] = "<<b[i-j]<<endl;
                    //cout<<"CURR MIN = "<<min<<endl;
                }
        }
        b[i] = min;


        
    }    

    cout<<b[n-1];
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{

    char s[150],t[150],nw[150];
    scanf("%s",s);
    scanf("%s",t);

    int i,j,k;
    int okay=0;

    int l=strlen(s);

    for(k=1; k<=l; k++)
    {


        for(i=1,j=0; i<l ;i++,j++)
        {

            nw[i]=s[j];


        }
        nw[0]=s[l-1];

        nw[l]='\0';

        strcpy(s,nw);

        if(strcmp(nw,t)==0)
        {
             okay=1;
             break;
        }


    }

    if(okay==1)
    {

        printf("Yes\n");
    }
      else
      {
          printf("No\n");
      }

    return 0;


}


Measured memory_bytes: 128
#include <stdio.h>

char s[51];
char t[51];

int main()
{
    scanf("%s %s",s,t);
    int lens=0;
    for(;;lens++)if(s[lens]=='\0')break;
    int lent=0;
    for(;;lent++)if(t[lent]=='\0')break;
    
    bool able=false;
    for(int i=lens-lent;i>=0;i--)
    {
        bool judge=true;
        for(int j=i;j<i+lent;j++)
        {
            // printf("i=%d j=%d\n",i,j);
            if(s[j]!=t[j-i])
            {
                if(s[j]!='?')
                {
                    judge=false;
                    break;
                }
            }
        }
        if(judge)
        {
            for(int j=0;j<lens;j++)
            {
                if(s[j]!='?') printf("%c",s[j]);
                else
                {
                    if(i<=j&&j<i+lent) printf("%c",t[j-i]);
                    else printf("%c",'a');
                }
            }
            printf("\n");
            return 0;
        }
    }
    printf("UNRESTORABLE\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#define r(i,n) for(int i=0; i<n; i++)
long long k[100010]={};

long long calc(long long a){
  if(a==1)return 1;
  else if(k[a]!=0)return k[a];
  return k[a]=a*calc(a-1)%1000000007;
}

using namespace std;
int main(void){
  long long n, m;
  cin >> n >> m;
  if(abs(n-m)>1){cout << '0' << endl;}
  else if(abs(n-m)==1){cout << calc(n)*calc(m)%1000000007 << endl;}
  else{cout << calc(n)*calc(m)*2%1000000007 << endl;}

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    string s;
    cin>>s;
    vector<bool> ex(26,false);
    REP(i,SZ(s)) {
        if(ex[s[i]-'a']) {
            cout<<"no"<<endl;
            return 0;
        }
        ex[s[i]-'a']=true;
    }
    cout<<"yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ARC096_D___Static_Sushi
{
    class Program
    {
        static void Main(string[] args)
        {
            var NC = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var N = NC[0]; var C = NC[1];

            var x = new long[N];
            var v = new long[N];
            for (int i = 0; i < N; i++)
            {
                var xv = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
                x[i] = xv[0]; v[i] = xv[1];

            }
            var rx = new long[N];
            for (int i = 0; i < N; i++) rx[i] = C - x[N - i - 1];

            var cumV = new long[N + 1];
            var cumRV = new long[N + 1];
            for (int i = 1; i < N + 1; i++)
            {
                cumV[i] = cumV[i - 1] + v[i - 1];
                cumRV[i] = cumRV[i - 1] + v[N - i];
            }
            var max = new long[N + 1];
            var maxX = new long[N + 1];
            var maxR = new long[N + 1];
            var maxRX = new long[N + 1];
            for (int i = 1; i < N + 1; i++)
            {
                max[i] = Math.Max(max[i - 1], cumV[i] - x[i - 1]);
                maxX[i] = max[i] == max[i - 1] ? max[i - 1] : x[i - 1];
                maxR[i] = Math.Max(maxR[i - 1], cumRV[i] - rx[i - 1]);
                maxRX[i] = maxR[i] == maxR[i - 1] ? maxR[i - 1] : rx[i - 1];
            }

            long result = 0;
            for (int i = 1; i < N + 1; i++)
            {
                result = Math.Max(result, max[i] + maxR[N - i] - maxX[i]);
                result = Math.Max(result, max[i] + maxR[N - i] - maxRX[N - i]);
                result = Math.Max(result, max[i]);
                result = Math.Max(result, maxR[i]);
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 22200
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c=1,d,e,f=0;cin>>a>>b>>c>>e;
  rep(i,a-1){
    cin>>d;
    f+=min(c,(d-e)*b);
    e=d;
  }
  cout<<f;
  }


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

using namespace std;

vector<int> nums;
int h, w;

bool dfs(int idx, int x, int y) {
	if (idx == 10) {
		return true;
	}
	bool ok = false;
	int z = nums[idx];
	if (x < z) {
		ok = dfs(idx + 1, z, y);
		if (ok) {
			return true;
		}
	}
	if (y < z) {
		ok = dfs(idx + 1, x, z);
		if (ok) {
			return true;
		}
	}

	return false;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		nums.assign(10, 0);
		for (int j = 0; j < 10; j++) {
			cin >> nums[j];
		}
		bool ok = dfs(0, -1, -1);
		cout << (ok ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int n;
string a[101010];
string t;

int Judge(string s) {
	int S = s.size();
	string as, bs;
	for (int i = 0; i < S; i++) {
		if (s[i] == '?') {
			as += 'a';
			bs += 'z';
		}
		else {
			as += s[i];
			bs += s[i];
		}
	}
	if (t < as) return 1;
	if (t > bs) return -1;
	return 0;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	cin >> t;
	int x = 0, y = 0;
	for (int i = 0; i < n; i++) {
		int f = Judge(a[i]);
		if (f == -1) x++;
		if (f == 1) y++;
	}
	for (int i = x + 1; i <= n - y + 1; i++) {
		if (i != x + 1) cout << ' ';
		cout << i;
	}
	cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
 /* #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  string a,b,c;
  cin>>a>>b>>c;
  char p=('A'+char(a[0]-'a') );
  //cout<<"t "<<t<<endl;
 
  char q='A'+char(b[0]-'a');
  char r='A'+char(c[0]-'a');
  cout<<p<<q<<r<<endl;
 

}
return 0;
}


Measured memory_bytes: 256
// 66DTG
// 26052020
#include<bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef long double ld;
const ld pi=3.1415926535897932384626433;
const int mod = 1000000007;
const ll inf=3e18;
int main()
{
   bolt;
   
   ll k;
   cin>>k;
   string s;
   cin>>s;
   if (k>=s.size())
   {
      cout<<s;
      return 0;
   }
   else
   {
      for (ll i=0;i<k;i++)
      {
         cout<<s[i];
      }
      cout<<"...";
      return 0;
   }
   
}


Measured memory_bytes: 3612
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

unsigned char D[252004];
bool E[252004];
int Q[252004];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int n = N + 2;
	rep1(i, N) {
		int ij = n * i + 1;
		unsigned char kari = min(i - 1, N - i);
		unsigned char kari2 = 3;

		rep(j, kari) {
			D[ij++] = kari2++;
		}
		rep(j, N - kari - kari) {
			D[ij++] = kari + 3;
		}
		rep(j, kari) {
			D[ij++] = --kari2;
		}
	}

	int kotae = 0;
	rep(k, N * N) {
		int ij = getint();
		ij += (ij - 1) / N * 2 + N + 2;

		kotae += D[ij];
		E[ij] = 1;

		int p = 0, q = 0;
		Q[p++] = ij;

		while (p > q) {
			int ij = Q[q++];
			int d =	D[ij] - E[ij] + 1;

			if (D[ij - n] > d) {
				D[ij - n] = d;
				Q[p++] = ij - n;
			}
			if (D[ij + n] > d) {
				D[ij + n] = d;
				Q[p++] = ij + n;
			}
			if (D[ij - 1] > d) {
				D[ij - 1] = d;
				Q[p++] = ij - 1;
			}
			if (D[ij + 1] > d) {
				D[ij + 1] = d;
				Q[p++] = ij + 1;
			}
		}
	}

	printf("%d\n", kotae - 3 * N * N);



	Would you please return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>

int main()
{
	int A, B, C, D, E;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &D);
	scanf("%d", &E);
	
	int i, min = 10, sum = 0, time[5] = {A, B, C, D, E};
	for (i = 0; i < 5; i++) {
		if (time[i] % 10 != 0 && time[i] % 10 < min) min = time[i] % 10;
		sum += (time[i] + 9) / 10 * 10;
	}
	
	printf("%d\n", sum - (10 - min));
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

//#include<bits/stdc++.h>

using namespace std; 

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

    int n;
    cin >> n;

    vector<double> v(n);
    for(int i = 0; i < n; i++)cin >> v.at(i); // or v[i]?
    // the largest one happens when the average pair is taken in ascending order
    sort(v.begin(), v.end());

    double max = (v.at(0) + v.at(1))/2;
    for(int i = 2; i < n; i++){
        max = (max + v.at(i))/2;
    }
    cout << max;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int H, W, N;
  std::cin >> H >> W >> N;
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> a[i];
  }
  int idx = 0;
  std::vector<std::vector<int>> c(H, std::vector<int>(W));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < a[i]; ++j) {
      if ((idx / W) % 2) {
        c[idx / W][idx % W] = i;
      } else {
        c[idx / W][W - 1 - (idx % W)] = i;
      }
      ++idx;
    }
  }
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      std::cout << c[i][j] + 1 << " ";
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  while(1){
    int n;
    cin >> n;
    if(n == 0) break;

    int data[n];
    for(int i=0;i<n;i++){
      cin >> data[i];
    }
    
    int count = 0;
    int str[10005]={};
    bool flag = false;
    for(int cas=0;cas<2;cas++){
      for(int i=0;i<n;i++){
	if(data[i] > 0){
	  str[i]++;
	  count++;
	  data[i]--;
	}
	if(str[i] > 1) {
	  flag = true;
	  break;
	}
      }
    }
    
    if(flag) cout << count << endl;
    else cout << "NA" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3292
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    string s;
    cin >> s;
    int fx = 0;
    rep(i,0,s.size()){
        fx += (s[i] - '0');
    }
    int x = stoi(s);
    if(x % fx == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n;
  cin>>n;
  long long sum=0;
  for(int i=1;i<n;i++){
    sum+=i;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
def framod(x,p=10**9+7):
  a=1
  for i in range(1,x+1):
    a = (a*i)%p
  return a
#############################################
X,Y=map(int,input().split())
p=10**9+7

if (X+Y)%3!=0:
  print(0)
else:
  a = (2*X-Y)//3
  b = (2*Y-X)//3
  t = a+b
  if a<0 or b<0:
    print(0)
  else:
    S=framod(t)
    T=pow(framod(a),p-2,p)
    U=pow(framod(b),p-2,p)
    print(((S*T)%p)*U%p)

Measured memory_bytes: 3064