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

int main()
{
	ll k;
	cin >> k;
	ll ans[50];
	for (ll q = 0; q < 50; q++)
	{
		ans[q] = q + k/50;
	}
	ll extra = k%50;
	for (ll q = 0; q < extra; q++)
	{
		int idx = 0;
		for (int w = 0; w < 50; w++)
		{
			if (ans[w] < ans[idx])
			{
				idx = w;
			}
		}
		for (int w = 0; w < 50; w++)
		{
			ans[w]--;
		}
		ans[idx]+=51;
	}
	cout << "50\n";
	for (int q = 0; q < 50; q++)
	{
		cout << ans[q] << " ";
	}
	cout << "\n";
	return 0;
}


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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    
    if(abs(x - a) > abs(x - b))
    {
        cout << "B" << endl;
        return 0;
    }
    else
    {
        cout << "A" << endl;
    }
    return 0;
}


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

using namespace std;

int main(){

    int N;
    string S;

    cin >> N;
    cin >> S;

    int ans = 2000000;

    int leftB = 0;
    int rightW = 0;

    for(int i = 0; i < N; i++){
	if(S.at(i) == '.') rightW++;
    }
        
    for(int i = 0; i < N; i++){
	ans = min(leftB+rightW, ans);
	if(S.at(i) == '.'){
	    rightW--;
	}else{
	    leftB++;
	}
    }
    ans = min(leftB+rightW, ans);
    
    cout << ans << endl;
    
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = sum(B)
for i in range(N-1):
    if A[i+1]-A[i]==1:
        ans+=C[A[i]-1]
print(ans)

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

int main()
{
	ll a,b,c,k,x=0,y=0;
    cin>>a>>b>>c;
    cin>>k;
    
    
   while(b-a<=0)
   {
       b=b*2;
       x++;
   }
    
    while(c-b<=0)
    {
        c=c*2;
        y++;
    }
    
    if(x+y<=k)
    {cout<<"Yes";}
    
    else
    {cout<<"No";}
    
    
	return 0;
}

Measured memory_bytes: 3552
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 1000000000000000000LL
    #define MOD 1000000007
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

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

    int dy[]={0, 0, 1, -1, 0};
    int dx[]={1, -1, 0, 0, 0};


    int main()
    {
        int n,k;
        cin>>n>>k;
        vector<int> x(n,0);
        REP(i,n) cin>>x[i];
        int sum=0;
        for(int i=0; i<n; i++)
        {
            sum+=min(x[i],k-x[i]);
        }
        cout<<sum*2<<endl;
    }



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

using namespace std;

int main() {
  int n,m,a,b;
  scanf("%d%d%d%d",&n,&m,&a,&b);
  for(int i=1;i<=b;i++) {
  	for(int j=1;j<=a;j++) putchar('1');
  	for(int j=a+1;j<=m;j++) putchar('0');
  	putchar('\n');
  }
  for(int i=b+1;i<=n;i++) {
  	for(int j=1;j<=a;j++) putchar('0');
  	for(int j=a+1;j<=m;j++) putchar('1');
  	putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    if(X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

// AtCoder Beginner Contest 138
//オーバーフローに注意！！
//焦らずに！！
int main(){

    int n; cin >> n;
    vector<long double> a(n);
    rep(i, n)cin >> a[i];
    sort(all(a));

    long double ans = (a[0] + a[1]) / 2.0;
    for(int i = 2; i < n; i++){
        ans = (ans + a[i]) / 2;
    }

    cout << setprecision(15) << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100];
    char a[100],d[100];
    cin>>a>>s>>d;
    if(a[0]>='a' && a[0]<='z')
    a[0]-=32;
    if(s[0]>='a' && s[0]<='z')
    s[0]-=32;
    if(d[0]>='a' && d[0]<='z')
    d[0]-=32;
    cout<<a[0]<<s[0]<<d[0];
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    map<int, int> mp;
    mp[A]++;
    mp[B]++;
    mp[C]++;
    if(mp[5] == 2 && mp[7] == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k,q; cin >> n >> k >> q;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int ans=1e9;
	for(int p:a){
		vector<int> c;
		multiset<int> s;
		for(int i=0;i<=n;i++){
			if(i==n||p>a[i]){
				sort(c.begin(),c.end());
				for(int j=0;j<=(int)c.size()-k;j++){
					s.insert(c[j]);
				}
				c.clear();
			}
			else{
				c.push_back(a[i]);
			}
		}
		if(s.size()<q)continue;
		auto it=s.begin();
		for(int j=0;j<q-1;j++){
			it++;
		}
		ans=min(ans,*it-p);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

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

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N, X;
	cin >> N >> X;
	vector<LL> M;

	LL mst = 0;
	for(int i=0; i<N; i++){
		LL m;
		cin >> m;
		mst += m;
		M.push_back(m);
	}

	LL rem = X - mst;
	sort(M.begin(), M.end());
	LL ans = rem / M[0];
	printf("%lld\n", ans+N);
	return 0;
}



Measured memory_bytes: 3728
from itertools import combinations_with_replacement

n,m,q = map(int,input().split())
s_list = [list(map(int,input().split())) for _ in range(q)]

ans = 0
for c in combinations_with_replacement(range(1,m+1),n):
    v = 0
    for s in s_list:
        if c[s[1]-1] - c[s[0]-1] == s[2]:
            v+=s[3]
    
    ans = max(ans,v)
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W;cin>>H>>W;
  vector<string> a(H);
  vint x,y;
  repeat(i,H){
    cin>>a[i];
    repeat(j,W)if(a[i][j]=='#'){
      x.push_back(j);
      y.push_back(i);
    }
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  x.erase(unique(x.begin(),x.end()),x.end());
  y.erase(unique(y.begin(),y.end()),y.end());
  repeat(i,y.size()){
    repeat(j,x.size()){
      cout<<a[y[i]][x[j]];
    }
    cout<<endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;
const int maxn = 2e5 + 10;
//union find
int par[maxn];
int rankk[maxn];
int sz[maxn];

void init(int n)
{
    for(int i=0;i<n;i++)
    {
        par[i]=i;
        rankk[i]=0;
    }
}

int find(int x)
{
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
}

void unite(int x,int y)
{
    x=find(x);
    y=find(y);
    if(x==y) return ;

    if(rankk[x]<rankk[y]) {
        par[x]=y;
        sz[y] += sz[x];
    }
    else
    {
        par[y]=x;
        sz[x] += sz[y];
        if(rankk[x]==rankk[y]) rankk[x]++;
    }
}

bool  same(int x,int y)
{
    return find(x)==find(y);
}

int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif

    int n, m;
    cin >> n >> m;
    init(n + 1);
    fill(sz, sz + n + 1, 1);
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        if(same(u, v)) continue;
        unite(u, v);
    }

    int ans = -1;
    for(int i = 1; i <= n; i++){
        ans = max(ans , sz[find(i)]);

    }

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

Measured memory_bytes: 5964
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h, n, ele;
    cin >>h >>n;
    int x = 0;
    for(int i = 0; i < n; i++){
    	cin >>ele;
    	x += ele;
    }
    if(x >= h)
    	cout <<"Yes";
   	else 
   		cout <<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
long long int X,Y,D,A,ans;
long long int mul(long long int x,long long int n){
  long long int res=1;
  while(n>0){
    if(n&1)res*=x;
    x*=x;
    n >>=1;
  }
  return res;
}
int main(){
  cin >> X >> Y;
  D=Y/X;
  
  for(long long int i=1;i<=63;i++){
   
    A=mul(2,i);
   
    if(A>D) {ans=i;break;}
  }
  cout << ans << endl;
  return 0;
}


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

list_aaa =[]

for i in range(26):
    for j in range(26):
        list_aaa.append((i*4)+(j*7))
list_aaa = sorted(list_aaa)

# print(list_aaa)

if N in list_aaa:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    vector<vector<pll>> edge(n);

    rep(i,m){
        ll a,b;cin>>a>>b;a--;b--;
        edge[a].emplace_back(b,-1);
        edge[b].emplace_back(a,-1);
    }
    vl ans(n,-1);
    queue<pll> q;
    q.emplace(0,0);
    while(!q.empty()){
        ll p,c; tie(p,c)=q.front();q.pop();
        if(ans[p]!=-1)continue;
        ans[p]=c;
        for(auto&e:edge[p]){
            if(ans[e.fs]==-1){
                e.sc=p+1;
                q.emplace(e.fs,p+1);
            }
        }
    }
    puta("Yes");
    range(i,1,n)puta(ans[i]);
    return 0;
}

Measured memory_bytes: 17920
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans(0);
  string x;
  cin >> n;
  vector<string>s(n);
  vector<int>time(n);
  for(int i = 0;i<n;i++){
    cin >> s.at(i) >> time.at(i);
    ans += time.at(i);
  }
  cin >> x;
  for(int i = 0;i<n;i++){
    if(s.at(i) != x){
      ans -= time.at(i);
    }else{
      ans -= time.at(i);
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = input().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])
counta = 0
if a == b:
    if c % a == 0:
        counta += 1
else:
  for i in range(a,b+1):
      if c % i == 0:
          counta += 1
print(counta)

Measured memory_bytes: 7668
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	int N, c{0};
	vector<int> a;
	cin>>N;
	a.resize(N);
	for(auto &i:a){
		cin>>i;
	}
	for(int i=1;i<=a.size();i++){
		c+=(i&1)&(a[i-1]&1);
	}
	cout<<c<<endl;
}


Measured memory_bytes: 3648
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
print(s[:3])

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

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

  int n, m;
  cin >> n >> m;

  vector<int> vh(n, 0);
  vector<int> v(n, 1);
  for (int i = 0; i < n; i++)
  {
    int h;
    cin >> h;
    vh.at(i) = h;
  }

  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    if(vh.at(a-1) > vh.at(b-1)) v.at(b-1) = 0;
    if(vh.at(a-1) < vh.at(b-1)) v.at(a-1) = 0;
    if(vh.at(a-1) == vh.at(b-1))
    {
      v.at(a-1) = 0;
      v.at(b-1) = 0;
    }
  }

  int cnt = 0;
  for (int i = 0; i < v.size(); i++)
  {
    if(v.at(i)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3988
import collections

N = int(input())
a = [int(input()) for _ in range(N)]

d = collections.deque()
used = [False] * N
used[0] = 1 
d.append([0, 0])

while len(d) != 0:
    temp, count = d.popleft()
    next_a = a[temp] - 1

    if temp == 1:
        break

    if not used[next_a]:
        d.append([next_a, count + 1])
        used[next_a] = True
else:
    count = -1

print(count)

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

#define MAX_N 100010
ll N, K;
ll a[MAX_N];
ll sum_a[MAX_N];
ll sum_aa[MAX_N];

int main(){
    ios::sync_with_stdio(false);
    cin >> N >> K;
    REP(i,N) cin >> a[i];
    REP(i,N) sum_a[i+1] = sum_a[i] + a[i];
    REP(i,N) sum_aa[i+1] = sum_aa[i] + max(a[i], 0LL);
    ll sum = 0;
    ll ans = 0;
    p term;
    FOR(i,K,N+1) {
        sum = max(0LL,sum_a[i]-sum_a[i-K]);
        ans = max(ans,(i!=K?sum_aa[i-K]:0)+sum+sum_aa[N]-sum_aa[i]);
        //cout << i << "," << sum_aa[i-K] << "," << sum << "," << sum_aa[N]-sum_aa[i] << "," << ans << endl;
    }
    
    cout << ans << endl;
    return 0;
}

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

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

const double EPS = 1e-10;

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

class DisjointSet{
    public:
        vector<ll> rank,p,siz;

        DisjointSet(){}
        DisjointSet(ll size){
            rank.resize(size,0);
            p.resize(size,0);
            siz.resize(size,1);
            rep(i,size) makeSet(i);
        }

        void makeSet(ll x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(ll x, ll y){
            return root(x) == root(y);
        }

    
        void unite(ll x, ll y){
            x = root(x);
            y = root(y);
            if(rank[x] > rank[y]){
                siz[x] += siz[y];
                p[y] = x;
            }
            else{
                siz[y] += siz[x];
                p[x] = y;
                if(rank[x] == rank[y]) rank[y]++;
            } 
        }
        ll root(ll x){
            if(x != p[x]){
                p[x] = root(p[x]);
            }
            return p[x];
        }

        ll size(ll x){
            return siz[root(x)];
        }

};


int main(){
    int n,m; cin >> n >> m;
    DisjointSet uf(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        if(!uf.same(a,b)) uf.unite(a,b);
    }
    int ans = 0;
    rep(i,n){
        ans = max((ll)ans,uf.size(i));
    }
    cout << ans << endl;
}



Measured memory_bytes: 7956
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

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

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


int main() {
    string s;
    cin >> s;
    int a, b;
    rep(i, s.length()) if (s[i] == 'A') {
            a = i;
            break;
        }
    repr(i, s.length()) if (s[i] == 'Z') {
            b = i;
            break;
        }
    cout << b - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;

const int MAXB = 21;
const int MAXN = 200001;
bool bits[MAXN][MAXB];
int bitlen[MAXN];
int A[MAXN];
int N;

int main() 
{
    // freopen("./input.txt", "r", stdin);
    // freopen("./output.txt", "w", stdout);
	
	scanf("%d", &N);
	memset(bits, false, sizeof(bits));
	memset(bitlen, 0, sizeof(bitlen));
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		int n = A[i];
		int digit = 0;
		while (n > 0) {
			if (n % 2 != 0) {
				bits[i][digit] = true;
			}
			// cout << bits[i][digit] << " ";
			digit++;
			n = n / 2;
		}
		bitlen[i] = digit;
		// cout << "\n";
	}
	int tot[MAXB];
	int first[MAXB];
	bool wrong[MAXB];
	memset(first, -1, sizeof(first));
	memset(wrong, false, sizeof(wrong));
	memset(tot, 0, sizeof(tot));
	int tail = 0;
	long long ans = 0;
	int head = tail;
	while (tail < N) {
		int old_head = head;
		while (head < N) {
			bool go = true;
			for (int i = 0; i < bitlen[head]; i++) {
				if (bits[head][i] && tot[i] == 1) {
					go = false;
					wrong[i] = true;
				}
			}
			if (go) {
				for (int i = 0; i < bitlen[head]; i++) {
					if (bits[head][i]) {
						tot[i] = 1;
						first[i] = head;
					}
				}
				head++;
			} else {
				break;
			}
		}
		long long num = head - tail;
		long long dup = old_head - tail;
		ans += num * (num - 1) / 2 - dup * (dup - 1) / 2;
		// cout << tail << " to " << head << "\n";
		// cout << ans << "\n";
		if (head == N) {
			tail = N;
			continue;
		}
		int new_tail = tail + 1;
		for (int i = 0; i < bitlen[head]; i++) {
			if (wrong[i]) {
				wrong[i] = false;
				new_tail = max(new_tail, first[i] + 1);
			}
		}
		for (int i = tail; i < new_tail; i++) {
			for (int j = 0; j < bitlen[i]; j++) {
				if (bits[i][j]) {
					tot[j] = 0;
				}
			}
		}
		tail = new_tail;
	}
	
	printf("%lld\n", ans + N);

	return 0;
}

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

#define MAXN 300007

int n ;
string a ;

int pref[ MAXN ] ;
int suff[ MAXN ] ;

void input ( ) {
    cin >> n ;
    cin >> a ;
}

void solve ( ) {
    int i ;
    for ( i = 1 ; i <= n ; i ++ ) {
        pref[ i ] = pref[ i - 1 ] ;
        if ( a[ i - 1 ] == 'W' ) { pref[ i ] ++ ; }
    }
    for ( i = n ; i >= 1 ; i -- ) {
        suff[ i ] = suff[ i + 1 ] ;
        if ( a[ i - 1 ] == 'E' ) { suff[ i ] ++ ; }
    }
    int ans = n ;
    for ( i = 1 ; i <= n ; i ++ ) {
        if ( ans > pref[ i - 1 ] + suff[ i + 1 ] ) {
            ans = pref[ i - 1 ] + suff[ i + 1 ] ;
        }
    }
    cout << ans << "\n" ;
}

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


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

using namespace std;
using ll = long long;

int n, m, Q;
int d[510][510];

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

    cin >> n >> m >> Q;

    for(int i = 0; i < m; ++i){
        int l, r;
        cin >> l >> r;
        ++d[l][r];
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            d[i+1][j+1] += d[i][j+1]+d[i+1][j]-d[i][j];
        }
    }
    for(int i = 0; i < Q; ++i){
        int p, q;
        cin >> p >> q;
        cout << d[q][q]-d[q][p-1]-d[p-1][q]+d[p-1][p-1] << endl;
    }
    return 0;
}


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    vector<string> A, B;
    cin >> n >> m;
    A.resize(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    B.resize(n + 2);
    for (int i = 0; i <= n + 1; i++)
        B[i].assign(m + 2, '#');
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            B[i+1][j+1] = A[i][j];
        }
    }
    for (int i = 0; i <= n + 1; i++) {
        cout << B[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
'use strict'
function Main(input) {
    let Nums = input.trim().split(' ').map(x => x*1);
    let gcd = (n1,n2)=>{
      return n2 == 0 ? n1 : gcd(n2 , n1 % n2);
    }
    let targetNum = gcd(Nums[0],Nums[1]);
  
    let answer = 1;
    for(let i = 2; i*i <= targetNum; i++) {
        if(targetNum % i === 0) {
            answer++;
          while(targetNum % i === 0) 
              {
                targetNum /= i;
              };
        }
    }
    
    if(targetNum !== 1) {
        answer++;
    }
      
   	console.log(answer);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9932
def main():
    N,M,X = map(int,input().split())
    A = list(map(int,input().split()))
    left = 0
    right = 0
    for i in range(N):
        if i == X:
            continue
        elif i < X and i in A:
            left += 1
        elif i > X and i in A:
            right += 1

    ans = min(left,right)
    return ans

print(main())


Measured memory_bytes: 9144
long M=998244353,D[90001],P[90001],s=1;
N,S,i,j;
main(a)
{
	*D=*P=1;
	for(scanf("%*d");~scanf("%d",&a);)
	{
		for(j=S;~j;j--)
		{
			D[j+a]=(D[j+a]+D[j])%M,D[j]=D[j]*2%M;
			P[j+a]=(P[j+a]+P[j])%M;
		}
		S+=a;
		s=s*3%M;
	}
	for(int i=-~S/2;i<=S;i++)s=(s-D[i]*3%M+M)%M;
	if(~S%2)s=(s+P[S/2]*3%M)%M;
	printf("%d",s);
}

Measured memory_bytes: 1536
N, L = map(int, input().split())
total = N * (L - 1) + N * (N + 1) // 2
tmp = total
sub = abs(total)
for i in range(N):
    if sub > abs(L + i):
        sub = abs(L + i)
        tmp = total - (L + i)
print(tmp)


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <map>
#include <set>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;



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

    //行のボタンを押すと
    //列のボタンを押すと
    //行を1個、列を1個使用すると、1*1個反転する
    //行を2個、列を1個使用すると、2*1個反転する
    //行を3個、列を3個使用すると、3*3個反転する
    string res = "No";
    //n行m列
    //行
    for(int i = 0; i <= n; ++i)
    {
        //列
        for(int j = 0; j <= m; ++j)
        {
            int tmp = m * i + n * j - i * j * 2;
            //cout << i << "," << j << ":" << tmp << endl;
            if(tmp == k)
            {
                res = "Yes";
            }
        }
    }
    cout << res << 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)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int l;
string s;

int main() {
	cin >> s;
	l = (int)s.length();
	
	int last = 0;
	int ans = 0;
	reps(i,1,l) {
		if (s[i] != s[last]) {
			last = i;
			ans++;
		}
	}
	cout << ans << ln;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long dp[105][100005];
int main()
{
  int n,w;
  long long m[105],v[105];

  cin>>n>>w;
  for(int i=0; i<n; i++){
    cin>>m[i]>>v[i];
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<=w; j++){
      if(m[i]<=j){
	dp[i+1][j]=max(dp[i][j-m[i]]+v[i],dp[i][j]);
      }else{
	dp[i+1][j]=dp[i][j];
      }
    }
  }
  cout<<dp[n][w]<<'\n';
  return 0;
}


Measured memory_bytes: 79360
#include<iostream>
#include<queue>
#include<map>
using namespace std;
 
int A[4][5]={
  {1,2,3,15,19},
  {7,8,9,13,10},
  {1,4,7,10,16},
  {3,6,9,12,13}
};
int B[4][5]={
  {28,29,30,16,21},
  {22,23,24,18,12},
  {24,27,30,21,18},
  {22,25,28,19,15}
};
 
 
struct state{
  int  t[31];
  bool operator < (const state &p) const {
    for(int i=1;i<=30;i++){
      if(t[i]==p.t[i])continue;
      return t[i]<p.t[i];
    }
    return false;
  }
 
  bool checkA(){
    int key=t[1],key2=t[22];
    for(int i=1;i<=9;i++){
      if(key!=t[i])return false;
      if(key2!=t[i+21])return false;
    }
    return true;
  }
  bool checkB(){
    return (t[10]==t[11]&&t[11]==t[12]) && (t[19]==t[20]&&t[20]==t[21]);
  }
  bool checkC(){
    return (t[13]==t[14]&&t[14]==t[15]) && (t[16]==t[17]&&t[17]==t[18]);
  }
};
 
 
void solve(state x){
  queue<state> Q;
  map<state,int> visited;
  Q.push(x);
  visited[x]=1;
 
  while(!Q.empty()){
 
    state s = Q.front();Q.pop();
    int cnt=visited[s];
 
 
    if(s.checkA()&&s.checkB()&&s.checkC()){
      cout<<cnt-1<<endl;
      return;
    }
 
    for(int i=0;i<4;i++){
      for(int j=0;j<5;j++)swap(s.t[A[i][j]],s.t[B[i][j]]);
      if(visited[s]==0){
        visited[s]=cnt+1;
        Q.push(s);
      }
      for(int j=0;j<5;j++)swap(s.t[A[i][j]],s.t[B[i][j]]);
    }
  }
 
}
 
int main(){
  int N;
  cin>>N;
  while(N--){
    state s;
    for(int i=1;i<=30;i++)cin>>s.t[i];
    solve(s);
  }
  return 0;
}

Measured memory_bytes: 1272
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
const int K = 5;
int dp[200000][K + 1];
int main(){
    string s;
    cin >> s;
    int n = (int) s.size();
    rep(i,n+1)rep(j,K+1)dp[i][j] = -1;
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= K; j++){
            if(dp[i][j]<0)continue;
            string t = s.substr(i-j,j);
            string tt;
            for(int k = 1; k <= K and i + k <= n; k++){
                tt += s[i-1+k];
                if(t != tt)dp[i+k][k] = max(dp[i+k][k], dp[i][j] + 1);
            }
        }
    }
    cout << *max_element(dp[n],dp[n]+K+1) << endl;
}

Measured memory_bytes: 5252
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;
void solve(){
  string s; cin >> s;
  int st, e, n = s.size();
  for(int i = 0; i < n; i++){
    if(s[i] == 'A'){
      st = i;
      break;
    }
  }
  for(int i = n - 1; i >= 0; i--){
    if(s[i] == 'Z'){
      e = i;
      break;
    }
  }
  cout << e - st + 1 << endl;;
  return;
}

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


Measured memory_bytes: 640
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

N,blue,red = list(map(int, stdin.readline().rstrip().split()))
total = blue + red
x = N // total
ans = blue*x
ans += min(N%total,blue)
print(ans)

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

int main(){
  double N,M;
  cin >> N >> M;
  vector<double> A(N);
  double sum = 0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum += A.at(i);
  }
  sort(A.begin(), A.end(), greater<double>() );
  double a = sum/(4*M);
  if(A.at(M-1)<a)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

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

#define int long long
#define INF 1000000007
 const int n1=500;

 
int32_t main() 
{
    string s;
    cin>>s;
    if((s[2]==s[3]) && (s[4]==s[5]))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String mojiretu = br.readLine();
        	if (mojiretu.equals("-"))
        		break;
        	int kaisu = Integer.parseInt(br.readLine());
        	for (int i = 0; i < kaisu; i++)
        	{
        		int shaffle = Integer.parseInt(br.readLine());
        		String cut = mojiretu.substring(0, shaffle);
        		String nokori = mojiretu.substring(shaffle);
        		mojiretu = nokori + cut;
        	}
        	System.out.println(mojiretu);
        }
	}

}

Measured memory_bytes: 24240
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;
typedef pair<int,int> P;


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	COMinit();
    lint N,K;
    cin >> N >> K;

    for(lint i=1;i<K+1;++i){
    	cout << COM(N-K+1,i)*COM(K-1,i-1)% MOD << endl;
    }


}


Measured memory_bytes: 12160
#include<stdio.h>
int main(){
	int n[1006]={0},m[1006]={0},k=0,i,N,M;
	for(;;k=0){
		scanf("%d%d",&N,&M);
		if(M==0)break;
		for(i=0;i<N;i++)scanf("%d",&n[i]);
		for(i=0;i<M;i++)scanf("%d",&m[i]);
		for(i=0;;i++){
			k+=m[i];
			k+=n[k];
			if(k>=N-1)break;
		}	
		printf("%d\n",i+1);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

const int N = 100;
const int W = 1e5 + 1;
long long dp[W];

void relax(long long& a, long long b) {
	a = max(a, b);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, W;
	cin >> n >> W;
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	while (n--) {
		int w, v;
		cin >> w >> v;	
		for (int j = W - w; j >= 0; --j) {
			if (dp[j] != -1) {
				relax(dp[j + w], dp[j] + v);
			}
		}
	}
	cout << *max_element(dp, dp + W + 1) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int n, x, y, b, p;
    int i;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d %d %d %d", &x, &y, &b, &p);
        
        if (b >= 5 && p >= 2)
        {
            printf("%.f\n", ((x * b) + (y * p)) * 0.8);
        } else if (b >= 5 && p < 2)
        {
            if ((x * b + y * p) > ((x * b + y * 2) * 0.8)) {
                printf("%.f\n", (x * b + y * 2) * 0.8);
            } else {
                printf("%d\n", (x * b) + (y * p));
            }
        } else if (b < 5 && p >= 2)
        {
            if ((x * b + y * p) > ((x * 5 + y * p) * 0.8))
            {
                printf("%.f\n", ((x * 5 + y * p) * 0.8));
            } else {
                printf("%d\n", (x * b) + (y * p));
            }
        } else {
            printf("%d\n", (x * b) + (y * p));
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 1860
import kotlin.math.abs

fun main(args: Array<String>) {
    val n = readInt()
    val p = List(n) { readIntList() }

    var bt = 0
    var bx = 0
    var by = 0
    p.forEach { (t, x, y) ->
        if (t % 2 != (x + y) % 2) {
            println("No")
            return
        }

        if (abs(x - bx) + abs(y - by) > t - bt) {
            println("No")
            return
        }
        bt = t
        bx = x
        by = y
    }
    println("Yes")
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 66932
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005

void solve()
{
	ll n,a,b;
	cin>>n>>a>>b;
	if(a>b)
		swap(a,b);
	if((b-a)%2==0)
	{
		cout<<(b-a)/2<<endl;
		return;
	}
	ll ans1=(b-a-1)/2+a;
	a=n+1-a;
	b=n+1-b;
	ans1=min(ans1,(a-b-1)/2+b);
	cout<<ans1<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = sorted([int(input()) for _ in range(N)])
ans = sum(S)
if ans % 10 == 0:
    updated = False
    for s in S:
      if s % 10 == 0:
        continue
      ans -= s
      updated = True
      break
    if not updated:
      ans = 0
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1005;
const int MOD = 1e9 + 7;
int H, W;
char grid[MAX][MAX];
int dp[MAX][MAX];
int solve() {
    int i, j;
    if(grid[0][0] == '#')
        return 0;
    memset(dp, 0, sizeof(dp)); dp[0][0] = 1;
    for(i = 1; i < H; i++) {
        if(grid[i][0] != '#') dp[i][0] = dp[i - 1][0];
        else break;
    }
    for(j = 1; j < W; j++) {
        if(grid[0][j] != '#') dp[0][j] = dp[0][j - 1];
        else break;
    }
    for(i = 1; i < H; i++) {
        for(j = 1; j < W; j++) {
            if(grid[i][j] == '#') continue;
            if(grid[i - 1][j] == '.') dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
            if(grid[i][j - 1] == '.') dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
        }
    }
    return dp[H - 1][W - 1];
}
int main() {
    int i;
    scanf("%d %d", &H, &W);
    for(i = 0; i < H; i++)
        scanf("%s", grid[i]);
    printf("%d\n", solve());
    return 0;
}

Measured memory_bytes: 5120
using System;
public class Class1
{
	public static void Main()
	{
		while(true)
		{
		string dataSet =Console.ReadLine();
		if(dataSet=="0")
		{
			break;
		}
		//char[] cs=dataSet.ToCharArray();
		int sum=0;
		
		for(int i=0;i<dataSet.Length;i++)
		{
			
			sum+=int.Parse(dataSet[i].ToString());
		}
		
		Console.WriteLine(sum);
	}
	}
}

Measured memory_bytes: 9040
/*WELCOME TO AYUSH RANJAN CODE'S*/
/*EVERY PROBLEM HAS A SOLUTION SOMETIMES ELEGENT OTHERWISE COMPLEX ELEGENCE*/

#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int chkpower2(int x){
    return (x&&!(x&x-1));
}
int n;


void solve(){
    ll n,d;
    cin>>n>>d;
    ll a[n][2];
    for(int i1=0;i1<n;i1++){
        cin>>a[i1][0]>>a[i1][1];
    }
    ll ans=0;
    for(int i1=0;i1<n;i1++){
        if(a[i1][0]*a[i1][0]+a[i1][1]*a[i1][1]<=d*d){
               // cout<<a[i1][0]<<" "<<a[i1][1]<<endl;

            ans++;
        }
    }
    cout<<ans;
    return;
}

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

    int t;
    t=1;//cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 6776
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());降順ソート
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10

int main() {
	string str[3];

	cin >> str[0] >> str[1] >> str[2];
	int len = str[0].size();
	if (str[0][len-1] != str[1][0]) {
		cout << "NO" << endl;
	}
	else {
		len = str[1].size();
		if (str[1][len-1] != str[2][0]) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum(int n){
  int sum=0;
  while(n%2==0){
    n=n/2;
    sum++;
  }
  return sum;
}
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> vec(n+1);
  int i;
  for(i=1;i<=n;i++){
    int a=sum(i);
    vec.at(i)=make_pair(a,i);
  }
  sort(vec.begin(),vec.end()); 
  reverse(vec.begin(),vec.end());
  cout << vec.at(0).second;
}
      

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

int main(){
	int a[10], b[10];
	for(int i = 0; i < 10; i++) cin >> a[i];
	for(int i = 0; i < 10; i++) cin >> b[i];
	sort(a, a + 10);
	reverse(a, a + 10);
	sort(b, b + 10);
	reverse(b, b + 10);
	cout << a[0] + a[1] + a[2] << ' ' << b[0] + b[1] + b[2] << endl;
	return 0;
}


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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	int n, m, sum = 0;
	cin >> n >> m;
	vi a(n);
	loop(n) cin >> a[i], sum += a[i];
	sort(riter(a));
	cout << (a[m - 1] * 4 * m >= sum ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 998244353;
const int e = 5e5 + 69;
const int base = 311;
// dung igt thay cho gt luc tinh giai thua
// 10
// cach tao hoan vi tu n so : n*(n+1)/2;
ll gt[e];
ll igt[e];
ll dp[e];
ll n;
ll a[e];

int main()
{
    ll n;
    cin >> n;
    map<ll,ll>kt;
    set<ll>s;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        kt[a[i]]++;
        s.insert(a[i]);
    }
    ll ans = 0 ;
    for(auto j : s)
    {
        //cout << j <<" ";
        ans += kt[j]*(kt[j] - 1)/2;
    }
    for(int j=1; j<=n; j++)
    {
        ll cur = ans;
        cur -=  kt[a[j]]*(kt[a[j]] - 1)/2;
        cur += (kt[a[j]]-1)*(kt[a[j]]-2)/2;
        cout << cur <<"\n";
    }
}


Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
int main(){
    string s, t;
    cin>>s>>t;
    int ans = 0;
    rep(i,3){
        if(s[i]==t[i])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612