akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k <= a) {
        cout << k << endl;
    } else if (k <= a + b) {
        cout << a << endl;
    } else {
        cout << a - (k - a - b) << endl;
    }
}

Measured memory_bytes: 3632
#include <stdio.h>
int H[251];

int main(){
  int i,n;
 
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&H[i]);

  for(i=1;i<n+1;i++){
    printf("node %d: key = %d, ",i,H[i-1]);
    if(i/2>=1) printf("parent key = %d, ",H[i/2-1]);
    if(i*2<n+1) printf("left key = %d, ",H[i*2-1]);
    if(i*2+1<n+1) printf("right key = %d, ",H[i*2+1-1]);
    printf("\n");

}


  return 0;
}

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

using namespace std;


vector<string> A;
vector<string> B,C;
string str;

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

    for(int i=0;i<m;i++) {
        cin>>str;
        A.push_back(str);
        B.push_back(str);
        C.push_back(str);
    }

    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
            B[i][j] = C[i][j] = '.';


    if(n==2 || n == 1 || m == 2 || n == 2) {
        for(int i=0;i<m;i++) cout<<B[i]<<endl; cout<<endl;
        for(int i=0;i<m;i++) cout<<B[i]<<endl; cout<<endl;
        return 0;
    }


    for(int i=0;i<n;i++) {
        B[0][i] = C[m-1][i] = '#';
    }


    for(int i=1;i<n-1;i++)
    for(int j=1;j<m-1;j++) {

        if(i%2 == 0) C[j][i]='#';
        else B[j][i]='#';

    }



    if(n%2 != 0) {
        for(int i=1;i<m-1;i++) C[i][n-1]='#';
    }

    for(int i=1;i<n-1;i++) {
        for(int j=1;j<m-1;j++) {
            if(i%2==0) {
                if(A[j][i] == '#') B[j][i]='#';
            } else {
                if(A[j][i] == '#') C[j][i]='#';
            }
        }
    }

    //cout<<"\n\n\n";

    for(int i=0;i<m;i++){
        cout<<B[i]<<endl;
    } cout<<endl;

    for(int i=0;i<m;i++){
        cout<<C[i]<<endl;
    } cout<<endl;

}


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

int main()
{
  int a,b,x[10000];
  int i=0, j=0;
  char op;

  while (op != '?') {
    cin >>a >>op >>b;
    if (op == '+') {
      x[i]=a+b;
    }
    if (op == '-') {
      x[i]=a-b;
    }
    if (op == '*') {
      x[i]=a*b;
    }
    if (op == '/') {
      x[i]=a/b;
    }
    i++;
  }
  for(j=0; j<i-1; j++){
    cout << x[j] <<endl;
  }

}

Measured memory_bytes: 1168
#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; 
typedef long long int ll;
#define ull unsigned long long int
#define all(a) a.begin(),a.end()s
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define hell 1000000007
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define pb push_back
#define MAX 10000001
int main()
{
    string s;
    cin>>s;
    ll n = s.size();
    string str="",str1="";
    for(ll i=0;i<(n-1)/2;i++)
        str+=s[i];
    for(ll i =(n+3)/2-1;i<n;i++)
        str1+=s[i];
    reverse(str1.begin(),str1.end());
    ll flag=0;
    for(ll i=0;i<(n-1)/4;i++)
    {
        if(s[i]!=s[(n-1)/2-1-i])
        {
            flag=1;
            break;
        }
    }
    if(flag==0&&str==str1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

int a, b;
char c;

void init()
{
	cin >> a >> c >> b;
}



void solve()
{
	if (c == '+') cout << a + b << endl;
	else cout << a - b << endl;
}



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

int a, b;

int main(){
	scanf("%d%d", &a, &b);
	a = (a + 13) % 15;
	b = (b + 13) % 15;
	if (a == b){
		return printf("Draw\n"), 0;
	}
	return printf(a > b ? "Alice\n" : "Bob\n"), 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int a[60];
int main()
{
	int n,i,j;
	while(~scanf("%d",&n))
	{
		int sum=0;
		for(i=1;i<=n;i++)
		    scanf("%d",&a[i]);
		for(i=1;i<=n-1;i++)
		for(j=i+1;j<=n;j++)
			sum+=a[i]*a[j];
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    ll N; cin >> N;
    vel a(N);
    vel b(N);
    rep(i,N) {
        cin >> a[i];
        b[i] = a[i];
    }

    sort(rall(b));

    ll max1 = b[0];
    ll max2 = b[1];

    if(b[0] == b[1]){
        rep(i,N) cout << max1 << endl;
    }

    else{
        rep(i,N) {
            if(a[i] == max1) cout << max2 << endl;
            else cout << max1 << endl;
        }
    }
}

Measured memory_bytes: 4736
#include<stdio.h>
int main(void){
  int a,b,c,d;
  scanf("%d%d",&a,&b);
  c=a/b;
  d=a%b;
  if(d==0){
    printf("%d\n",c);
  }else{
    printf("%d\n",c+1);
  }
  return 0;
}
  

Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

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

	const int size = n + 3;
	vector<vector<int>> triangle;
	for(int i = 0; i < size; ++i)
		triangle.emplace_back(i + 2, 0);


	for(int i = 0; i < m; ++i) {
		int a, b, x;
		cin >> a >> b >> x;

		++triangle[a][b];
		--triangle[a][b + 1];
		--triangle[a + x + 1][b];
		++triangle[a + x + 2][b + 1];
		++triangle[a + x + 1][b + x + 2];
		--triangle[a + x + 2][b + x + 2];
	}

	for(int i = 0; i < size; ++i) {
		for(int j = 0; j < i; ++j) {
			triangle[i][j + 1] += triangle[i][j];
		}
	}

	for(int i = 0; i < size; ++i) {
		for(int j = i + 1; j < size; ++j) {
			triangle[j][i] += triangle[j - 1][i];
		}
	}

	for(int i = 0; i < size; ++i) {
		for(int j = 1; i + j < size; ++j) {
			triangle[i + j][j] += triangle[i + j - 1][j - 1];
		}
	}

	int ans = 0;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= i; ++j) {
			if(triangle[i][j] > 0) ++ans;
		}
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 50100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,r;
    cin>>s>>r;
    int n=s.length();
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=r[i])
        {

            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x, y;
	cin >> x >> y;
	int cnt = 0;
	while (x <= y) {
		x *= 2;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 30; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline void maxch(int& a, int b) { if (a < b) a = b; }

int bfs(int n, vector<vector<int>> &edge, map<pair<int,int>,int> &ecol) {
  queue<int> q;
	q.push(0);

	int maxcol = 0;

	while(!q.empty()){
		int col = 1, parcol = 0;
	  int par = q.front();
		q.pop();
		for (int v : edge[par]) {
		  if (ecol.at({par,v}) == 0) q.push(v);
			parcol = max(parcol, ecol.at({ par,v }));
		}
		// 色を付ける
		for (int v : edge[par]) {
		  if (col == parcol) col++;
			if (ecol.at({par,v}) == 0) {
			  ecol.at({par,v}) = col;
				ecol.at({v,par}) = col;
				maxcol = max(maxcol, col);
			  col++;
			}
		}
	}

	return maxcol;
}

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

	map<pair<int,int>,int> col;
	vector<pair<int,int>> es(n-1);
	vector<vector<int>> edge(n, vector<int>());
	rep(i, n - 1) {
	  int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
		col.insert({{a,b},0});
		col.insert({{b,a},0});
		es[i] = {a,b};
	}

	int k = bfs(n,edge,col);

	cout << k << endl;
	for (auto e : es) {
		 cout << col.at(e) << endl;
	}

}

Measured memory_bytes: 19328
#include <bits/stdc++.h>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(v) begin(v),end(v)
typedef long long ll;
using namespace std;

ll n,rec,k;
ll a[100010],b[100010];
int main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
    rec+=a[i];
  }

  ll wa=n*(n+1)/2;

  if(rec%wa!=0){
    cout<<"NO"<<endl;
    return 0;
  }else{
    k=rec/wa;
  }

  for(int i=0;i<n-1;i++){
    b[i]=a[i+1]-a[i];
    b[i]-=k;
  }

  b[n-1]=a[0]-a[n-1];
  b[n-1]-=k;

  //for(int i=0;i<=n-1;i++)cout<<b[i];

  bool flag=true;
  ll temp=0;
  for(int i=0;i<=n-1;i++){
    if(b[i]%n!=0){
      flag=false;
    }else{
      temp+=b[i]/n;
      if(temp>0)flag=false;
    }
  }

  //cout<<"temp="<<temp<<"k="<<k<<endl;

  if(-temp!=k)flag=false;

  if(flag)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = int ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

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

	ll h,w ;
	cin >> h >> w ;
	vvll a(h+2,vll(w+2,0)),b(h+2,vll(w+2,0)) ;
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) cin >> a.at(i).at(j) ;
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){ cin >> b.at(i).at(j) ; a.at(i).at(j) = abs(a.at(i).at(j)-b.at(i).at(j)) ;}
	vector<vvll> dp(h+2,vvll(w+2,vll(12810,0))) ;
	dp[1][1][a.at(1).at(1)] = 1 ;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i==1&&j==1) continue ;
			for(int k=0;k<12810;k++){
				if(i!=1){
					if(dp[i-1][j][k]){
						dp[i][j][k+a.at(i).at(j)] = dp[i][j][abs(k-a.at(i).at(j))] = 1 ;
					}
				}
				if(j!=1){
					if(dp[i][j-1][k]){
						dp[i][j][k+a.at(i).at(j)] = dp[i][j][abs(k-a.at(i).at(j))] = 1 ;
					}
				}
			}
		}
	}
	for(int i=0;i<=12810;i++){
		if(dp[h][w][i]){
			cout << i << endl ;
			return 0 ;
		}
	}
}


Measured memory_bytes: 343168
const main = input => {
  let [_, ...a] = input.trim().split(/\s|\n/).map(e => Number.parseInt(e))
  let i = 0
  while(a.findIndex((e, i, s) => [s[i] /= 2, e % 2 > 0][1]) < 0) i++
  return i
}; // Implement this function

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8'))); // Common part

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

from heapq import heappop, heappush

N, M = map(int, input().split())

# 隣接リスト
g = [[] for i in range(N)]
e = []
for i in range(M):
    a, b, c = map(int, input().split())
    g[a-1].append((b-1, c))
    g[b-1].append((a-1, c))
    e.append((a-1, b-1, c))

def dijkstra(nodeCnt, start, edges):

    # 始点からのコスト
    costs = [-1 for i in range(nodeCnt)]

    # 確定フラグ
    done = [False for i in range(nodeCnt)]

    # priority queue
    q = []

    costs[start] = 0
    heappush(q, (0, start))

    while len(q) > 0:
        # 確定ノードを取り出す
        doneNode = heappop(q)[1]

        # 確定フラグを立てる
        done[doneNode] = True

        # 接続先ノードの情報を更新
        for to,edge_cost in edges[doneNode]:
            cost = costs[doneNode] + edge_cost
            if costs[to] < 0 or cost < costs[to]:
                costs[to] = cost
                if to not in q:
                    heappush(q, (cost, to))

    return costs

dist = [dijkstra(N, i, g) for i in range(N)]
# print(dist)

# edge(i,j)が最短経路に含まれているとき、
# dist(s,i) + edge(i,j) = dist(s,j)を満たす
ans = 0
for i, j, cost in e:
    isUsed = False
    for s in range(N):
        if dist[s][i] + cost == dist[s][j]:
            isUsed = True
            break
    if not isUsed:
        ans += 1
print(ans)


Measured memory_bytes: 3652
#include <stdio.h>
int main(int argv, const char * argc[]){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b && b<c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;

int main(void) {
	string S, T;
	cin >> S >> T;
	bool ans = true;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i]) {
			ans = false;
			break;
		}
	}
	printf(ans ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  int loop,amari;
  long long int half=0,full=0;
  long long int ans=0;
  cin>>n>>k;
  loop=n/k;
  amari=n%k;
  half+=loop; full+=loop;
  if(amari>=k/2 && k%2==0) half++;
  if(k%2 !=0) half=0;
  ans+=half*half*half;
  ans+=full*full*full;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
#define mp make_pair

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
//const int MAX=;



int main(){
	string S;
	cin>>S;
	string T;
	rep(i,sz(S)){
		if(S[i]=='A')T.push_back('A');
		else if(S[i]=='B' && S[i+1]=='C'){
			T.push_back('D');
			i++;
		}
		else T.push_back('X');
	}
	ll ans=0;
	ll tmp=0;
	rep(i,sz(T)){
		if(T[i]=='A')tmp++;
		else if(T[i]=='D')ans+=tmp;
		else tmp=0;
	}
	cout<<ans<<endl;
}

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

int main() {
    int n;cin>>n;
    double v[n];
    for(int i=0;i<n;++i){
        cin>>v[i];
    }
    sort(v,v+n);
 
    double ans=(v[0]+v[1])/2;
    for(int i=2;i<n;++i){
        ans=(ans+v[i])/2;
    }

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

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

using namespace std;

long long t,n,i,j,m,k,sum,a,b,c,nr;
string s,x;
long long q[10000005];

int main() 
{
    cin>>n;
    
    for (i=2; i<=n; i++)
     for (j=2; j<=n/i; j++)
        q[i*j]++;
        
    long long sum = 0;
    for (i=1; i<=n; i++)
        sum+=(q[i]+2)*i;
    
    cout<<sum-1;
}

Measured memory_bytes: 81720
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e9;

ll n;
ll id;
vector<ll>a,b,c,ans;
vector<bool>seen;
Graph g;

void dfs(ll x,ll &id){
    seen[x]=true;
    ans[x]=c[id];
    for(ll t:g[x]){
        if(seen[t])continue;
        id++;
        dfs(t,id);
    }
}

int main(){
    cin >> n;
    c.resize(n);
    g.resize(n);
    rep(i,n-1){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,n)cin>>c[i];
    sort(c.begin(),c.end());
    ll s = 0;
    rep(i,n-1)s += c[i];
    cout << s << endl;
    ans.resize(n);
    seen.resize(n,false);
    reverse(c.begin(),c.end());
    id = 0;
    dfs(0,id);
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4364
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int m, k, z[270000] = {};
    cin >> m >> k;
    if (k >= (1 << m)) {cout << -1; return 0;}
    if (m == 1) {
        if (k == 0) cout << "0 0 1 1";
        else cout << -1;
        return 0;
    }
    for (int i = 0; i < (1 << m); i++) if (i != k) cout << i << ' ';
    cout << k << ' ';
    for (int i = (1 << m) - 1; i >= 0; i--) if (i != k) cout << i << ' ';
    cout << k;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<long long> number(10, 0);
int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < W+2; i++)
	{
		cout << "#";
	}
	cout << endl;


	for (int i = 0; i < H; i++)
	{
		
		string str;
		cin >> str;
		cout << "#" << str << "#" << endl;
	}


	for (int i = 0; i < W+2; i++)
	{
		cout << "#";
	}
	cout << endl;

}



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

#define all(v)  begin(v), end(v)
#define endl    '\n';
#define int     long long
#define pii     pair<int, int>
#define sz(x)   (int) x.size()

void test_case() {
    int n, m, k;
    cin >> n >> m >> k;

    vector<vector<char>> grid(n, vector<char>(m));
    for (auto& v : grid) {
        for (auto& x : v) cin >> x;
    }

    vector<int> xa(n), xb(m);
    for (int i = 0; i < n; i++) xa[i] = i;
    for (int i = 0; i < m; i++) xb[i] = i;

    vector<vector<int>> a, b;

    for (int i = 0; i < (1 << n); i++) {
        vector<int> tmp;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                tmp.push_back(xa[j]);
            }
        }
        a.push_back(tmp);
    }

    for (int i = 0; i < (1 << m); i++) {
        vector<int> tmp;
        for (int j = 0; j < m; j++) {
            if (i & (1 << j)) {
                tmp.push_back(xb[j]);
            }
        }
        b.push_back(tmp);
    }

    int ans = 0;

    // db(a, b)

    for (vector<int>& v : a) {
        int nn = v.size();
        for (vector<int>& w : b) {
            int mm = w.size();

            auto gc = grid;
            for (int i = 0; i < nn; i++) {
                int idx = v[i];
                for (int j = 0; j < m; j++) {
                    gc[idx][j] = 'r';
                }
            }
            for (int j = 0; j < mm; j++) {
                int idx = w[j];
                for (int i = 0; i < n; i++) {
                    gc[i][idx] = 'r';
                }
            }

            int cnt = 0;
            for (auto& v : gc) {
                for (auto& x : v) {
                    cnt += x == '#';
                }
            }

            if (cnt == k) ans++;

        }
    }

    cout << ans << endl;

}

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

    int t = 1;
    // cin >> t;

    while (t--) { 
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3648
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))
last = [0]*26
t = []
    
ans = 0

for day in range(D):
    st = s[day]
    tt = st.index(max(st)) + 1
    t.append(tt)
    print(tt)

Measured memory_bytes: 9504
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
    
  print(prod)
main ()

Measured memory_bytes: 21648
#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, Q; cin >> N >> Q;
		string S; cin >> S;
		vector<pair<char, char>> A(Q);
		rep(i, Q) cin >> A[i].first >> A[i].second;
		UL L, R;
		UL l = 0, r = N + 1;
		while(l + 1 < r){
			UL m = (l + r) >> 1;
			UL p = m - 1;
			rep(i, Q) {
				if (S[p] == A[i].first) {
					if (A[i].second == 'L') p--;
					if (A[i].second == 'R') p++;
				}
				if (p == -1) break;
				if (p == N) break;
			}
			if (p == -1) l = m; else r = m;
		}
		L = l;
		l = 0; r = N + 1;
		while (l + 1 < r) {
			UL m = (l + r) >> 1;
			UL p = m - 1;
			rep(i, Q) {
				if (S[p] == A[i].first) {
					if (A[i].second == 'L') p--;
					if (A[i].second == 'R') p++;
				}
				if (p == -1) break;
				if (p == N) break;
			}
			if (p == N) r = m; else l = m;
		}
		R = l;
		UL ans = R - L;
		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: 1028
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll A,B,C,K;
    cin >> A >> B >> C >> K;

    ll ans = A-B;
    if( (K+2)%2 != 0 ) ans = -ans; 

    if( abs(ans) <= 1e17  ) cout << ans << endl;
    else cout << "Unfair" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;

ll N, K;

void input() {
    cin >> N >> K;
}

bool solve() {
    return (N + 1) / 2 >= K;
}

int main() {
    input();
    cout << (solve() ? "YES" : "NO") << endl;
    
    return 0;
}



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

int main(){
    int n,k;cin>>n>>k;
    int ans=0;
    string s;cin>>s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1]) ans++;
    }
    ans=n-1-ans;
    cout<<min(n-1,ans+2*k)<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define N 100001
#define prob "DP_A"
#define io freopen(prob".inp","r",stdin); freopen(prob".out","w",stdout);
using namespace std;
int n,W;
ll v[N],w[N];
ll f[101][N];
void read()
{
    cin>>n>>W;
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<w[i];j++) f[i][j]=f[i-1][j];
        f[i][w[i]]=max(f[i-1][w[i]],v[i]);
        ans=max(ans,f[i][w[i]]);
        for(int j=w[i]+1;j<=W;j++)
        {
            f[i][j]=f[i-1][j];
            if(f[i-1][j-w[i]]!=0)
                f[i][j]=max(f[i][j],f[i-1][j-w[i]]+v[i]);
            ans=max(ans,f[i][j]);
        }
    }
    cout<<ans;
}
int main()
{
//    io
    read();
}


Measured memory_bytes: 79360
let read conv = stdin.ReadLine() |> conv
let reads n =
    let acc = System.Collections.Generic.List<int>()
    let mutable max = 0
    let mutable max' = 0
    for i = 1 to n do
        let x = (stdin.ReadLine() |> int)
        if max <= x then max' <- max; max <- x;
        elif max' <= x then max' <- x;
        acc.Add(x)
    (acc, max, max')

let n = read int
let (ls, fst, snd) = reads n
for i = 0 to (n-1) do
    printfn "%d" (if ls.[i] = fst then snd else fst)


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

using namespace std;
#define int64_t long long
int64_t mod = 1000000007;
  int64_t kaizyo(int x){
    if(x==0)return 1;
    return x*kaizyo(x-1)%mod;
  }

// a^n mod を計算する
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a) {
    return modpow(a, mod - 2);
}


int main(){
  int x,y;
  cin>>x>>y;
  if(!(0.5*x<=y&&y<=2*x&&(x+y)%3==0)){
    cout<<0<<endl;
    return 0;
  }
  int a=(x+y)/3;
  int b=(x+y)*2/3-x;
  int c=a-b;
  int64_t d=kaizyo(a);
  int64_t e=kaizyo(b);
  int64_t f=kaizyo(c);
  cout<<d*modinv(e)%mod*modinv(f)%mod<<endl;
}
  
  

Measured memory_bytes: 10624
N = list(input())

ans = 0

N_len = len(N)
judge = True
if(N_len==1):
    print(int(N[0]))
else:
    for i in range(1,N_len):
        if int(N[0]) < int(N[i]):
            judge = False
            break
    
    if judge :
        for i in range(N_len):
            ans = ans + int(N[0])*10**i
    else :            
        for i in range(N_len):
            ans = ans + (int(N[0])+1)*10**i

    print(ans)


Measured memory_bytes: 3064
N=int(input())
rate=[0]*8
tourist=0
a=list(map(int,input().split()))
for i in a:
  if i<400:
    rate[0]+=1
  elif i<800:
    rate[1]+=1
  elif i<1200:
    rate[2]+=1
  elif i<1600:
    rate[3]+=1
  elif i<2000:
    rate[4]+=1
  elif i<2400:
    rate[5]+=1
  elif i<2800:
    rate[6]+=1
  elif i<3200:
    rate[7]+=1
  else:
    tourist+=1
print(max(8-rate.count(0),1),max(1,8-rate.count(0)+tourist))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    if ( s.length() == 2 ) cout << s << endl;
    else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = new int[n].Select(_ => int.Parse(Console.ReadLine())).ToArray();

		var r = 0L;
		for (int i = 0; i < n; i++)
		{
			var x = Math.Max(0, (a[i] - 1) / 2);
			r += x;
			a[i] -= 2 * x;
		}
		for (int i = 0; i < n; i++)
			if (a[i] == 2)
			{
				r++;
				a[i] = 0;
			}
			else if (a[i] == 1 && i < n - 1 && a[i + 1] > 0)
			{
				r++;
				a[i]--;
				a[i + 1]--;
			}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 17436
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	double sum=0;
	double a[105];
		double b[105];
	for(int i=0;i<n;i++)
	{cin>>a[i];
	sum=sum+a[i];}
	double  x=(sum*1.0)/(n*1.0);
	int f=1;
	double min=100000000;
double ans=0;
int p;
	for(int i=0;i<n;i++)
	{	
	  b[i]=fabs(a[i]-x);
	  if(b[i]<min)
	  {
	  	min=b[i];
		  p=i; 
	  } 
	  ans=ans+b[i];
	}
	if(ans/n==b[0])
	cout<<"0";
	else
	cout<<p;
	
} 

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

int main() {
  string ans="Yes";
  vector<vector<int>> c(3,vector<int>(3));
  for(int i=0;i<9;i++) cin >> c.at(i/3).at(i%3);
  for(int i=0;i<3;i++) {
    int a=min(min(c[i][0],c[i][1]),c[i][2]);
    c[i][0]-=a;
    c[i][1]-=a;
    c[i][2]-=a;
  };
  if(c[0][0]!=c[1][0]) ans="No";
  if(c[1][0]!=c[2][0]) ans="No";
  if(c[0][1]!=c[1][1]) ans="No";
  if(c[1][1]!=c[2][1]) ans="No";
  if(c[0][2]!=c[1][2]) ans="No";
  if(c[1][2]!=c[2][2]) ans="No";
  cout << ans << endl;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

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

    int x;

    cin>>x;

    int t = x / 500;

    int ans = t * 1000;

    int r = x % 500;

    ans += (r / 5) * 5;

    cout<<ans<<endl;

    return 0;
}


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

int main()
{
	
   double l;
    cin>>l;
       
    std::cout << std::fixed;
 	 std::cout << std::setprecision(12) <<(l*l*l)/(27)<<endl;
	return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Monad
import Control.Applicative
import Data.List

showingList :: [Int] -> String
showingList (x:[]) = show x
showingList (x:xs) = (show x) ++ " " ++ (showingList xs)

main :: IO ()
main = do
    [a, b] <- map read . words <$> getLine
    print $ a * b


Measured memory_bytes: 3888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    string s; cin>>s;
    if(s[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }
    ll cnt=0;
    ll c;
    for(int i=2;i<=s.size()-2;i++){
        if(s[i]=='C'){
            cnt++;
            c=i;
        }
    }
    if(cnt!=1){
        cout<<"WA"<<endl;
        return 0;
    }
    for(int i=1;i<s.size();i++){
        if(i!=c){
            if(s[i]<='Z'&&'A'<=s[i]){
                cout<<"WA"<<endl;
                return 0;
            }
        }
    }
    cout<<"AC"<<endl;

}








Measured memory_bytes: 256
x, k, d =map(int, input().split()) 
ans = 0; x = abs(x)

if int(x/d) >= k:
	ans = x-d*k
else:
	k = k - int(x/d)
	x = abs(x - d*int(x/d))
	if (k - int(x/d)) % 2 == 1:
		ans = abs(x - d)
	else:
		ans = x


print(ans)


Measured memory_bytes: 9176
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

int main(){
    int N,p[50],m[50],count=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>p[i];
        m[i]=i+1;
        if(p[i]==m[i])count++;
    }
    if(count==N-2||count==N)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

int main(){
  int h, n;
  std::cin >> h >> n;
  std::vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    sum += a[i];
  }
  if(sum >= h){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }
  return 0;
}



Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#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 <complex> // complex
#include <math.h> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

struct UnionFind{
    vector<int> p;

    UnionFind(int n) : p(n,-1) { }

    int root(int x){
        if(p[x] < 0) return x;
        else return p[x] = root(p[x]);
    }

    bool merge(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(p[x] > p[y]) swap(x,y);
        p[x] += p[y];
        p[y] = x;
        return true;
    }

    int size(int x){
        return -p[root(x)];
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> x(N),y(N);
    vector<vector<int>> G_X(100100);
    vector<vector<int>> G_Y(100100);
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i];
        G_X[x[i]].emplace_back(i);
        G_Y[y[i]].emplace_back(i);
    }
    UnionFind uf(N);
    for(int i=0; i<100100; i++){
        for(int j=1; j<G_X[i].size(); j++){
            uf.merge(G_X[i][0],G_X[i][j]);
        }
    }
    for(int i=0; i<100100; i++){
        for(int j=1; j<G_Y[i].size(); j++){
            uf.merge(G_Y[i][0],G_Y[i][j]);
        }
    }
    // root x軸 y軸
    map<int,pair<set<int>,set<int>>> mp;
    for(int i=0; i<N; i++){
        int r = uf.root(i);
        mp[r].first.insert(x[i]);
        mp[r].second.insert(y[i]);
    }
    ll ans = 0;
    for(auto m: mp){
        ll X,Y;
        X = m.second.first.size();
        Y = m.second.second.size();
        ll num = uf.size(m.first);
        ans += X*Y - num;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 18688
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst = [a,b,c,d,e]
last = 10
ttl = 0
for i in range(5):
    if lst[i]%10 != 0:
        ttl += (lst[i]+(10-lst[i]%10))
    if lst[i]%10 == 0:
        ttl += lst[i]
    if 0 <(lst[i]%10) <= last:
        last = lst[i]%10
print(ttl-(10-last))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  string s{}; cin >> s;
  auto ans = boost::count_if(s, [](char c){ return c == '1'; });
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

int p[10], q[10];

double cal(double mid) {
	double ans = 0;
	for (int i = 0; i < 6; i++)
		ans += max(p[i] * mid / 100, q[i] * (1 - mid) / 100);
	return ans;
}

int main() {
	for (int i = 0; i < 6; i++) scanf("%d", &p[i]);
	for (int i = 0; i < 6; i++) scanf("%d", &q[i]);
	double ans = min(cal(0), cal(1));
	for (int i = 0; i < 6; i++) {
		if (p[i] == 0 && q[i] == 0) continue;
		double x = 1.0 * q[i] / (p[i] + q[i]);
		ans = min(ans, cal(x));
	}
	printf("%.12f\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
struct UnionFind {
    //If the vertex is a parent, this value will be the number of vertices that belongs to the set, multiplied by -1
    //Otherwise, this value will be the parent's id
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};
 
 
int main() {
    int N, M;
    cin >> N >> M;
 
    //Make friends-sets
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }
 
    //Find the maximum friends-set
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, UF.size(i));
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3676
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    long A = sc.nextLong();
    long B =sc.nextLong();
    long C =sc.nextLong();
    long D =sc.nextLong();
    long E =(A-1)/C;long F =B/C;
    long G =(A-1)/D;long H =B/D;
    long I =C*D;
    long s =C%D;
    while(s!=0){
      s=C%D;
      C=D;
      D=s;}
    long J =I/C;
    long K =(A-1)/J;long L =B/J;
    long ans =B-A+1-F+E+G-H+L-K;
    System.out.println(ans);
  }
}

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

signed main()
{
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	string s1="",s2="";
	for(int i=1;i<=b;i++) s1+=char(a+48);
	for(int i=1;i<=a;i++) s2+=char(b+48);
	if(s1<s2) cout<<s1<<endl;
	else cout<<s2<<endl;
	return 0;
}

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

int n, p, a[51];
long long ans, dp[51][2];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> p;
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		for(int j = i-1; j >= 0; j--) {
			dp[i][0] += dp[j][a[i] % 2];
			dp[i][1] += dp[j][a[i] % 2 ^ 1];
		}
		ans += dp[i][p];
	}
	cout << ans + !p;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        vector<vector<int>> schedule(n,vector<int>(16));
        rep(i,0,n) for(int& in:schedule[i]) cin >> in;

        set<tuple<int,int,int>> done;
        const int mask=(1<<3)-1;
        function<bool(int,int,int)> dfs=[&](int day,int pos,int cnt){
            tuple<int,int,int> state(day,pos,cnt);
            if(done.find(state)!=done.end()) return false;
            done.insert(state);
            if(schedule[day][pos] or schedule[day][pos+1] or schedule[day][pos+4] or schedule[day][pos+5]) return false;
            int cnt1=cnt&mask,cnt2=(cnt>>3)&mask,cnt3=(cnt>>6)&mask,cnt4=(cnt>>9)&mask;
            ++cnt1;
            ++cnt2;
            ++cnt3;
            ++cnt4;
            if(pos==0) cnt1=0;
            if(pos==2) cnt2=0;
            if(pos==8) cnt3=0;
            if(pos==10) cnt4=0;
            if(cnt1>6 or cnt2>6 or cnt3>6 or cnt4>6) return false;
            if(day==n-1) return true;
            int next_cnt=cnt1|(cnt2<<3)|(cnt3<<6)|(cnt4<<9);
            int x=pos%4,y=pos/4;
            bool res=false;
            rep(d1,-2,3) rep(d2,-2,3){
                if(d1!=0 and d2!=0) continue;
                int nx=x+d1,ny=y+d2;
                if(nx<0 or 2<nx or ny<0 or 2<ny) continue;
                int next_pos=nx+ny*4;
                res|=dfs(day+1,next_pos,next_cnt);

            }
            return res;
        };

        if(dfs(0,5,0)) cout << 1 << endl;
        else cout << 0 << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

Measured memory_bytes: 17376
def ini(): return int(input())
def inli(): return list(map(int, input().split()))
def inf(): return float(input())
def inlf(): return list(map(float, input().split()))
def inl(): return list(input())
def pli(): return "".join(list(map(str, ans)))

a=inli()

if a[1]-a[2] >= 0:
    print("delicious")
elif (a[0]+a[1])-a[2]>=0:
    print("safe")
else:
    print("dangerous")


Measured memory_bytes: 3064
/* #                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/
void sol() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);

    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<vector<int>> adj(n);
	for(int i = 1; i < n; ++ i){
		int u, v;
		cin >> u >> v, -- u, -- v;
		adj[u].push_back(v), adj[v].push_back(u);
	}
	vector<vector<int>> rem(3);
	for(int i = 1; i <= n; ++ i){
		rem[i % 3].push_back(i);
	}
	vector<vector<int>> g(2);
	function<void(int, int, int)> dfs = [&](int u, int p, int s){
		g[s].push_back(u);
		for(auto v: adj[u]){
			if(v != p){
				dfs(v, u, !s);
			}
		}
	};
	dfs(0, -1, 0);
	if(g[0].size() > g[1].size()){
		swap(g[0], g[1]);
	}
	vector<int> res(n);
	if(g[0].size() <= rem[0].size()){
		for(auto u: g[0]){
			res[u] = rem[0].back();
			rem[0].pop_back();
		}
		for(int i = 0; i < 3; ++ i){
			for(auto c: rem[i]){
				res[g[1].back()] = c;
				g[1].pop_back();
			}
		}
	}
	else{
		for(auto c: rem[1]){
			res[g[0].back()] = c;
			g[0].pop_back();
		}
		for(auto u: g[0]){
			res[u] = rem[0].back();
			rem[0].pop_back();
		}
		for(auto c: rem[2]){
			res[g[1].back()] = c;
			g[1].pop_back();
		}
		for(auto u: g[1]){
			res[u] = rem[0].back();
			rem[0].pop_back();
		}
	}
	copy(res.begin(), res.end(), ostream_iterator<int>(cout, " "));
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 21144
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void B();

int main()
{
	B();
	fflush(stdout);
	return 0;
}

static void B()
{
	std::string N;
	get(N);

	int len = N.length();
	int sum = 0;
	for (int i = 0; i < len; i++) {
		int num = N[i] - '0';
		sum += num;
	}
	printf("%s\n", (sum % 9) ? "No" : "Yes");
}


Measured memory_bytes: 3752