akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define int long long

signed main() {
  int n,m,v,p;
  cin >> n >> m >> v >> p;

  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(),a.rend());

  int ok = -1, ng = n;

  auto is_good = [&]() {
    int mid = (ng + ok) >> 1;
    if(mid < p) return true;
    int val = a[mid] + m;
    if(val < a[p - 1]) return false;
    int sum = 0;
    sum += (p - 1) * m;
    sum += (n - mid) * m;
    for (int i = p - 1; i < mid; i++) {
      sum += min(m, max(0LL, val - a[i]));
    }
    return sum >= m*v;
  };

  while(abs(ng - ok) > 1) {
    int mid = (ng + ok) >> 1;
    if(is_good()) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok + 1 << '\n';
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<int> a(n+5);
  reps(i,n){
    cin >> a[i];
  }

  int res = 0;
  reps(i,n){
    int tmp = a[i] / 2;
    res += tmp;
    a[i] -= tmp * 2;
    tmp = min(a[i],a[i+1]);
    res += tmp;
    a[i+1] -= tmp;
  }

  cout << res << '\n';

  return 0;
}

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

typedef long long ll;
using namespace std;

int N;
vector<ll> A, S;

int get_max_min(int s, int t){
    int lb = s;
    int ub = t;
    
    while(ub-lb>1){
        int mid = (lb+ub)/2;
        
        ll val;
        if(s == 0)
            val = S[t-1]-S[mid]*2;
        else
            val = (S[t-1]-S[s-1])-(S[mid]-S[s-1])*2;
        
        if(val >= 0)
            lb = mid;
        else
            ub = mid;
    }
    return lb;
}

int main(){
    cin >> N;
    A.resize(N); S.resize(N);
    
    for(auto &v: A)
        cin >> v;
    
    for(int i=0; i<N; i++)
        S[i] = A[i];
    
    for(int i=1; i<N; i++)
        S[i] += S[i-1];
    
    ll ans = 1LL<<40;
    for(int i=1; i<N-2; i++){
        int x = get_max_min(0, i+1);
        int y = get_max_min(i+1, N);
        
        for(int xt=0; xt<2; xt++){
            for(int yt=0; yt<2; yt++){
//                if(x+xt == i || y+yt == N-1)
//                    continue;
                
                vector<ll> values = {S[x+xt], S[i]-S[x+xt], S[y+yt]-S[i], S[N-1]-S[y+yt]};
                ll tans = *max_element(values.begin(), values.end()) - *min_element(values.begin(), values.end());
                ans = min(ans, tans);
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main{
    public static void main(String [] args){
        Main m = new Main();
        m.run();
    }

    void run(){
        Scanner sc = new Scanner(System.in);

        for(;;){
            int n = sc.nextInt();
            if(n == 0) break;

            int[] seq = new int[n];
            for(int i = 0; i < n ;i++){
                seq[i] = sc.nextInt();
            }

            long ans = solve(seq);
            System.out.println(ans);
        }
    }

    long solve(int[] seq){
        int n = seq.length;
        long ans = -Long.MAX_VALUE;

        long[] sum =  new long[n+1];

        for(int i = 0; i< n; i++){
            sum[i+1] = sum[i] + seq[i];
        }

        for(int start = 0; start < n; start++){
            for(int end = start+1; end < n+1 ; end++){
                ans = Math.max(ans, sum[end] - sum[start]);
            }
        }
        return ans;
    }
}

Measured memory_bytes: 35480
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N, K;
int a[110];
int dp[110][100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> K;
  REP(i, N) cin >> a[i];
  REP(i, N+1) dp[i][0] = 1;
  REP(i, N) FOR(j, 1, K+1) {
    int add = (dp[i+1][j-1] + dp[i][j]) % MOD;
    if (j-1-a[i] >= 0) (add += MOD-dp[i][j-1-a[i]]) %= MOD;
    (dp[i+1][j] += add) %= MOD;
  }
  cout << dp[N][K] << endl;

  return 0;
}

Measured memory_bytes: 79360
//An algorithm must be seen to be believed.
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e5+10;
char s[mx];
int main(){
  int k;
  scanf("%s %d",s,&k);
  int n=strlen(s);
  for(int i=0;i<n;i++){
    for(char ch='a';ch<s[i];ch++){
      int dx='z'-s[i]+1+ch-'a';
      if(dx<=k){
        k-=dx;
        s[i]=ch;
        break;
      }
    }
  }
  k%=26;
  s[n-1]=(s[n-1]-'a'+k)%26+'a';
  printf("%s\n",s);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
  ll a, b;
  cin >> a >> b;
  cout << (a+b) % 24 << endl;
    return 0;
}


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

int main(){
    int S,h,m,s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600)/60;
    s = (S % 3600)%60;
    cout << h <<":"<< m << ":"<< s << endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define lr(n) for(ll i=0;i<n;i++)

	int main(){
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		cout.tie(0);
		ll n,k;
		cin>>n>>k;
		if(n==k){
			cout << "1\n";
			return 0;
		}
		cout << n-k+1 << "\n";
		return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626 
 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;
// vector<int> arr[100010],children[100010];
// int n,mod;
// pair<int,int> down[100010],up[100010];
// vector<pair<int,int>> downs[100010],pref[100010],suff[100010];
// pair<int,int> merge(pair<int,int> arr,pair<int,int>arr2)
// {
// 	int a=(arr.ff*arr2.ff)%mod;
// 	int b=(((arr.ss*(arr2.ff+arr2.ss))%mod)+arr.ff*arr2.ss)%mod;	
// 	return make_pair(a,b);
// }
// pair<int,int> process(pair<int,int> a)
// {
// 	return mp(a.ff,(a.ff+a.ss)%mod);
// }
// void dfs_one(int v,int par)
// {
// 	pair<int,int> res{1,0};

// 	for(auto itr:arr[v])
// 	{
// 		if(itr!=par)
// 		{
// 			//do something
// 			children[v].pb(itr);
// 			dfs_one(itr,v);
// 			res=merge(res,down[itr]);
// 			downs[v].pb(down[itr]);
// 		}
// 	}
// 	down[v]=process(res);
// }
// void dfs_two(int v,int par)
// {
// 	pair<int,int> res{1,0};
// 	for(int i=0;i<arr[v].size();i++)
// 	{

// 	}
// }

// cin>>n>>mod;
// 	for(int i=1;i<n;i++)
// 	{
// 		int x,y;
// 		cin>>x>>y;
// 		arr[x].pb(y);
// 		arr[y].pb(x);
// 	}

// 	dfs_one(1,-1);	

// 	// suffix sum and prefix sum
// 	for(int i=1;i<=n;i++)
// 	{
// 		pair<int,int> a{1,0};
// 		for(int j=0;j<downs[i].size();j++)
// 		{
// 			a=merge(a,downs[i][j]);
// 			pref.pb(a);
// 		}
// 		a={1,0};
// 		for(int j=(downs[i].size()-1);j>=0;j--)
// 		{
// 			a=merge(a,downs[i][j]);
// 			suff.pb(a);
// 		}
// 		reverse(all(suff));
// 	}
// 	dfs_two(1,-1);


// const int nax=2e5+5;
// vector<pair<int,int>> arr[nax];
	
	//https://leetcode.com/problems/word-ladder-ii/
	//https://leetcode.com/problems/sum-of-subarray-minimums/
	//https://leetcode.com/problems/subsets-ii/discuss/30168/C%2B%2B-solution-and-explanation	

	// int n,m;
	// cin>>n>>m;
	// for(int i=0;i<m;i++)
	// {
	// 	int a,b,c;
	// 	cin>>a>>b>>c;
	// 	arr[b].pb(mp(a,c));
	// }
	// for(int i=1;i<=n;i++)
	// {
		
	// }
signed main() {

	fastio();
//	#define LOCAL_DEFINE	
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(i%2)
		{
			if(s[i]=='L' || s[i]=='U' || s[i]=='D')
			{

			}else{
				cout<<"No"<<endl;
				return 0;
			}
		}else{
			if(s[i]=='R' || s[i]=='U' || s[i]=='D')
			{	

			}else{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes";
 	return 0;
}


Measured memory_bytes: 384
n, m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]
a.sort()
l = -float('inf')
r = float('inf')
for x, y in a:
    if x <= r:
        l = max(l, x)
        r = min(r, y)
    else:
        print(0)
        exit()
print(r-l+1)

Measured memory_bytes: 27776
from collections import deque
n,m,p=map(int,input().split())
edges=[None for i in range(m)]
natural=[[] for i in range(n)]
reverse=[[] for i in range(n)]
for i in range(m):
  a,b,c=map(int,input().split())
  a-=1;b-=1;c-=p
  natural[a].append(b)
  reverse[b].append(a)
  edges[i]=(a,b,-c)
from0=set([0])
fromG=set([n-1])
visited=[False]*n
visited[0]=True
queue=deque([0])
while queue:
  v=queue.popleft()
  for i in natural[v]:
    if visited[i]:continue
    visited[i]=True
    from0.add(i)
    queue.append(i)
for i in range(n):
  visited[i]=False
visited[-1]=True
queue.append(n-1)
while queue:
  v=queue.popleft()
  for i in reverse[v]:
    if visited[i]:continue
    visited[i]=True
    fromG.add(i)
    queue.append(i)
points=from0&fromG
use=[]
for i in edges:
  if i[0] in points and i[1] in points:
    use.append(i)
def BellmanFord(edges,num_v,source):
  #グラフの初期化
  inf=10**15
  global dist
  dist=[inf for i in range(num_v)]
  dist[source]=0
  Ncycle=False
  #辺の緩和
  for i in range(num_v):
    for edge in edges:
      if edge[0]!=inf and dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
        if i==num_v-1: return False
  
  return dist[-1]
flag=0
for i in use:
  if i[2]!=0:
    flag=1
    break
if flag==0:print(0);exit()
if BellmanFord(use,n,0)==False:print(-1)
else:
  print(max(0,-BellmanFord(use,n,0)))


Measured memory_bytes: 51052
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	string S;
	cin >> S;
	
	char pre = 'x';
	int ans = 0;
	
	
	for(int i = 1; i < S.size(); i++) {
		while( S.size() > 0 && ((  S.at(i) == '0' && S.at(i-1) == '1'  ) || (S.at(i) == '1' && S.at(i-1) == '0'))){
			//消える候補
			S.erase(S.begin()+i-1);
			S.erase(S.begin()+i-1);
			
	//		cout << "dbg S is " << S << ", i is " << i << endl;
			
			if(i >= S.size()){
				i = S.size() - 1;
			} else if(i > 1) {
				i--;
			}
			ans += 2;
			if (S.size() < 2) break;
		}
	}
	cout << ans << endl;
		
	return 0;
}


Measured memory_bytes: 512
L = int(input())

xs = []

for m in range(21):
    if (2 << m) > L:
        break
    xs.append((m+1, m+2, 0))
    xs.append((m+1, m+2, 1 << m))

b = 1 << m
x = L - b

for i in range(m - 1, -1, -1):
    c = 1 << i
    if x >= c:
        xs.append((i+1, m+1, b))
        x -= c
        b += c

print(m + 1, len(xs))

for x in xs:
    print(*x)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string o, e;
    cin >> o >> e;

    string ans = "";
    for(int i = 0; i < o.size(); i++){
        ans += o[i];
        if(i < e.size()){
            ans += e[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().rstrip().split(' '))
frog_lst = list(map(int, input().rstrip().split(' ')))
frog_jump_lst = []

def frog_jump(frog_jump_lst=[], index=0):
  if not frog_jump_lst:
    frog_jump_lst.append(0)
  else:
    now_pos = frog_lst[index]
    k = min(K, len(frog_jump_lst))
    pattern = [abs(now_pos - frog_lst[index-i]) + frog_jump_lst[-i] for i in range(1,k+1)]
    frog_jump_lst.append(min(pattern))

for j in range(N):
  frog_jump(frog_jump_lst, j)
print(frog_jump_lst[-1])

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

int main() {
 int A, B, T;

 cin >> A >> B >> T;

 int roopNum = (T + 0.5) / A;
 int total = 0;
 
 for(int i = 0; i < roopNum; i++) {
	total = total + B;
 }

 cout << total << endl;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

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=1e5+10;
const int INF=1e9+10;


int N, M;
int id[1010], co[1010];
void input(){
	cin>>N>>M;
	rep1(i, M){
		int nb;
		cin>>co[i]>>nb;
		rep(_, nb){
			int k;
			cin>>k;
          	k--;
			id[i] = id[i] | (1<<k);
		}
	}
}

int dp[1010][1<<12];
void solve(){
	rep(i, M+1)rep(b, 1<<N)dp[i][b]=INF;
	dp[0][0]=0;
	rep1(i, M)rep(b, 1<<N){
		dp[i][b] = min(dp[i][b], dp[i-1][b]);
		dp[i][b | id[i]] = min(dp[i][b | id[i]], dp[i-1][b]+co[i]);
	}
	int ans = dp[M][(1<<N) -1];
	if(ans == INF) cout<<-1;
	else cout<<ans;
}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
using vpi = vector<Pi>;
using vpl = vector<Pl>;

#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
  cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
  return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
  cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
  return out;
}
template<class S,class T> ostream &operator << (ostream& out, const pair<S,T>& p){
  cout << "{" << p.first << "," << p.second << "}" << '\n';
  return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
  for (auto& i : arr)cin >> i; return in;
}

/////////////////////////////////////////////////////////////////////////
int main(int argc, char const* argv[])
{
  int n,m;cin >> n >> m;
  dsu uf(n);
  for (int i = 0; i < m; i++) {
    int a,b;cin >> a >> b;
    uf.merge(a-1,b-1);
  }
  cout << uf.groups().size() - 1 << '\n';
  return 0;
}


Measured memory_bytes: 9104
#include <stdio.h>

int main(void)
{
    int a=0,b=0,c=0,k=0,max=0;
    scanf("%d %d %d %d",&a,&b,&c,&k);

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

    printf("%d",max);
    return 0;
}


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

int main()
{
	int i, n, a, b, c, minm;
	vector<int> v1, v2, v3;

	cin >> n;
	cin >> a >> b >> c;

	int l[n], ch[n];

	for(i=0; i<n; i+=1)
		cin >> l[i];

	minm=10000000;

	int x=pow(4, n);
	for(i=0; i<x; i+=1)
	{
		int y, j;

		memset(ch, 0, sizeof(ch));
		y=i;
		j=0;
		while(y>0)
		{
			ch[j]=y%4;
			y/=4;
			j+=1;
		}

		v1.clear(); v2.clear(); v3.clear();
		for(j=0; j<n; j+=1)
		{
			if(ch[j]==1)
				v1.push_back(l[j]);
			else if(ch[j]==2)
				v2.push_back(l[j]);
			else if(ch[j]==3)
				v3.push_back(l[j]);
			else
				;
		}

		int t1=v1.size(), t2=v2.size(), t3=v3.size(), temp, f1, f2, f3, p1, p2, p3;
		f1=f2=f3=0;

		if(t1!=0)
		{
			f1=1;
			temp=0;
			for(j=0; j<t1; j+=1)
				temp+=v1[j];
			if(temp>=a)
				p1=temp-a+10*(t1-1);
			else
				p1=a-temp+10*(t1-1);
		}
		if(t2!=0)
		{
			f2=1;
			temp=0;
			for(j=0; j<t2; j+=1)
				temp+=v2[j];
			if(temp>=b)
				p2=temp-b+10*(t2-1);
			else
				p2=b-temp+10*(t2-1);
		}
		if(t3!=0)
		{
			f3=1;
			temp=0;
			for(j=0; j<t3; j+=1)
				temp+=v3[j];
			if(temp>=c)
				p3=temp-c+10*(t3-1);
			else
				p3=c-temp+10*(t3-1);
		}

		if((f1 & f2) & f3)
			minm=min(minm, p1+p2+p3);
	}
	cout << minm << endl;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = input()
ans = 0
for i in range(N):
    d1 = Counter(S[:i])
    d2 = Counter(S[i:])
    tmp = 0
    for alphabet in 'abcdefghijklmnopqrstuvwxyz':
        tmp += min(d1[alphabet], d2[alphabet], 1)
    print
    ans = max(ans, tmp)
print(ans)

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

  int sum(long long int n){
    int sum=0;
    while (n>0){
      sum+=n%10;
      n/=10;
    }
    return sum;
  }

  int main(){
    long long int n;
    cin>>n;
    long long int ans=sum(n);
    if(n%ans==0) cout<<"Yes";
    else cout<<"No";
  }


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

int dp[10][3000];
vector<int> book[10]; vector<int> value[10];

int dfs(int a, int cnt){ 
  // a(0-indexed)ジャンル目まででcnt個売る時の売値の最高値を求める
  if( a < 0 || cnt < 0){ return 0;}
  if( dp[a][cnt] != -1){ return dp[a][cnt];}
  
  int res = dfs(a-1,cnt);
  
  for(int i = 1; i <=min( (int)value[a].size(), cnt); i++){
    res = max( res, dfs(a-1, cnt-i)+value[a][i-1]);
  }
  
  return dp[a][cnt] = res;
}
  

    
    
    
    
int main(){

  int n,k; cin >> n >> k;
  vector<int> book[10];
  for(int i = 0; i < n; i++){
    int c,g; cin >> c >> g; g--;
    book[g].push_back(c);
  }
  
  for(int i = 0 ; i < 10; i++){
    for(int j = 0; j < 3000; j++){
      dp[i][j] = -1;
    }
  }
  
  for(int i = 0; i < 10; i++){
    if(book[i].empty()){ continue;}
    sort(book[i].rbegin(),book[i].rend());
  }
  
  
  //ここまでOK
  for(int i = 0 ; i < 10; i++){
    if(book[i].size() < 2){ continue;}
    for(int j = 0; j < (int)book[i].size()-1; j++){
      book[i][j+1] += book[i][j];
    }
  }
  
  
  
  for(int i = 0; i < 10; i++){
    if(book[i].empty()){ continue;}
    
    for(int j = 1; j <= (int)book[i].size(); j++){
      value[i].push_back(book[i][j-1]+j*j-j);
    }
  }
 
  
  cout << dfs(9,k) << endl; return 0;}
  
  


Measured memory_bytes: 3272
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N;
	cin >> N;

	int mae = 1e9;
	int kotae = 0;
	rep(i, N) {
		int p;
		cin >> p;

		if (mae > p) {
			kotae++;
			mae = p;
		}
	}
	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
  int counter = 0;
  string S;
  string T;
  cin >> S;
  cin >> T;
  for(int i = 0; i < S.length();i++)
  {
   // cout << S[i] << T[i] << endl;
    if(S[i] != T[i])
    {
      counter++;
    }
  }
  cout << counter << endl;
}

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

//typedef
typedef long long LL;
typedef unsigned int UINT;
typedef unsigned long long ULL;
typedef set<int, greater<int> > setdownINT;
typedef set<long long, greater<long long> > setdownLL;
typedef priority_queue<int, vector<int>, greater<int> > priqueupINT;
typedef priority_queue<long long, vector<long long>, greater<long long> > priqueupLL;
//container utill
#define ALL(v) (v).begin(),(v).end()
#define sortdown(v) sort((v).begin(),(v).end()), reverse((v).begin(),(v).end())
#define PB(a) push_back(a)
#define MP make_pair
#define MT make_tuple
//constant
#define PI 3.141592653589793

int main(){
    //input
    LL N,K;
    cin >> N >> K;

    //calc
    LL ans=0;
    LL b;
    for(b=K+1; b<=N; b++){
        ans+=(b-K)*(N/b);
        ans+=max(N%b-(K-1LL),0LL);
    }
    if(K==0){
        ans-=N;
    }

    //output
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,x,y,nn,d;
	int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
	int xx[200],yy[200];
	int mx,mn;
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		xx[0]=0;	yy[0]=0;
		for(i=1;i<n;i++)	{
			scanf("%d %d",&nn,&d);
			xx[i]=xx[nn]+dx[d];
			yy[i]=yy[nn]+dy[d];
		}
		mx=-1000;	mn=1000;
		for(i=0;i<n;i++)	{
			mx=max(mx,xx[i]);
			mn=min(mn,xx[i]);
		}
		x=mx-mn+1;
		mx=-1000;	mn=1000;
		for(i=0;i<n;i++)	{
			mx=max(mx,yy[i]);
			mn=min(mn,yy[i]);
		}
		y=mx-mn+1;		
		printf("%d %d\n",x,y);
	}
	return 0;
}


Measured memory_bytes: 1028
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector> 
using namespace std;

int N, M;
vector<pair<int, int > > work;

int main(void){
    scanf("%d %d",&N,&M);
    for(int i=0;i<N;i++) {
        int a,b;
		scanf("%d %d",&a,&b);
        work.push_back({a, b});
    }
    sort(work.begin(), work.end());
    priority_queue<int> q;
    int pos=0;
    int ans=0;
    for(int i=1;i<=M;i++) {
        while(work[pos].first<=i&&pos<N){
            q.push(work[pos].second);
            pos++;
        }
        if(q.empty()) continue;
        ans+=q.top();
        q.pop();
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1908
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,n){
        ans += (ll)(i+1)*(n-i);
    }
    rep(i,n-1){
        int u,v;
        cin >> u >> v;
        if(u>v)swap(u,v);
        ans -= (ll)(u)*(n-v+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3164
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
using namespace std;

int main()
{
	int n, a;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end(), greater<int>());
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) sum += v[i];
		else sum -= v[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;

ll ar[N];
int main() {
    fast;

    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> ar[i];

    ll sum = 0, m = ar[0];


    for(int i = 1; i < n; i++) {
        m = max(m, ar[i]);
        sum += (m - ar[i]);
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 5208
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int32_t main()
{
	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	int vis[n+1]={0};
	vector<int> v;
	int i=0,x;
	while(1)
	{
	    x=a[i%n];
		if(vis[x]==0)
		{
			v.push_back(x);
			vis[x]=1;
			i=x-1;
		}
		else
		{
			break;
		}
		
		if(v.size()==k)
		break;
	}
	if(v.size()==k)
	{
		cout << v[k-1];
		return 0;
	}
	
	vector<int> cycle;
	int vis2[n+1]={0};
	while(1)
	{
		if(vis2[x]==0)
		{
			cycle.push_back(x);
			vis2[x]=1;
			x=a[x-1];
			
		}
		else
		{
			break;
		}
	}
	int temp=v.size()-cycle.size();
	k-=temp;
	int raj=k%cycle.size();
	if(raj!=0)
	cout << cycle[raj-1];
	else
	cout << cycle[cycle.size()-1];
}


Measured memory_bytes: 11128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    int k, x; cin >> k >> x;
    if (500 * k >= x) {
        cout << "Yes" << endl;
    } else {
        cout <<  "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#define ll long long 
using namespace std;	      
int main()
{
	string s,t;
    cin>>s;
    cin>>t;
    ll cn=0;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
           cn++;
    }cout<<cn;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
string S;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> S;
}

int solve(){
    vector<int> idr,idg,idb;
    set<int> idb_set;
    for (size_t i = 0; i < S.length(); i++)
    {
        if(S[i]=='R') idr.push_back(i+1);
        if(S[i]=='G') idg.push_back(i+1);
        if(S[i]=='B') {idb.push_back(i+1); idb_set.insert(i+1);}
    }
    // DBG(idr)
    // DBG(idg)
    // DBG(idb)
    ll ans=0;
    for(auto r:idr) for(auto g:idg){
        ans += idb.size();
        int b;
        if((r+g)%2==0){
            b=(r+g)/2;
            if(idb_set.find(b)!=idb_set.end()) ans--;
        } 
        int M=max(r,g);
        int m=min(r,g);
        b = 2*m-M;
        if(m>b && b>0 && idb_set.find(b)!=idb_set.end()) ans--;
        b = 2*M-m;
        if(b>M && b<=N && idb_set.find(b)!=idb_set.end()) ans--;
    }
    cout << ans << endl;

    return 0;
}   

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


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

using namespace std;

#define INPUT_OUTPUT { \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout); \
}
#define ll long long

int main()
{
    // INPUT_OUTPUT;
    int k, x, i, p;
    cin >> k >> x;
    p = x-(k-1);
    for(i = 0; i < k-1; i++) {
        cout << p << ' ';
        p++;
    }
    cout << x << ' ';
    p = x;
    for(i = 0; i < k-1; i++) {
        x++;
        cout << x << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws IOException {

        BigDecimal x1 = new BigDecimal("1");
        BigDecimal y = new BigDecimal("30");
        BigDecimal z = new BigDecimal("10");

        //足し算
        //        BigDecimal z1 = x.add(y);
        //        //引き算
        //        BigDecimal z2 = x.subtract(y);
        //        //掛け算
        //        BigDecimal z3 = x.multiply(y);
        //割り算
        BigDecimal z4 = x1.divide(y, 5, BigDecimal.ROUND_FLOOR);
        //割り算
        BigDecimal z5 = x1.divide(z, 5, BigDecimal.ROUND_FLOOR);

        BigDecimal z1 = new BigDecimal("1");
        BigDecimal z6 = z1.add(z4);

        //        System.out.println(z1);
        //        System.out.println(z2);
        //        System.out.println(z3);
        //        System.out.println(z4);
        //        System.out.println(z5);
        //        System.out.println(z6);

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");

        String n = arr01[0];
        int l = n.length();

        switch (l) {
        case 1:
            System.out.println(Integer.valueOf(n));
            break;
        case 2:

            System.out.println(9 - 1 + 1);
            break;
        case 3:
            System.out.println(9 - 1 + 1 + Integer.valueOf(n) - 100 + 1);

            break;
        case 4:

            System.out.println(9 - 1 + 1 + 999 - 100 + 1);
            break;
        case 5:
            System.out.println(9 - 1 + 1 + 999 - 100 + 1 + Integer.valueOf(n) - 10000 + 1);

            break;
        case 6:

            System.out.println(9 - 1 + 1 + 999 - 100 + 1 + 99999 - 10000 + 1);
            break;

        }

    }

}

Measured memory_bytes: 21332
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
    for j in range(i, n):
        k = j + (j - i)
        if k >= n:
            break
        if s[i] != s[j] != s[k] != s[i]:
            ans -= 1

print(ans)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define pi acos(-1)
#define lli long long int
using namespace std;

int main() 
{
    FIO
    lli t,n, b,i,j,d,a;
    cin >> a >> b;
    if(a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    return 0;
}
    

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

#define pb      push_back
#define all(v)  v.begin(),v.end()
#define endl    "\n"
#define FAST    ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long     ll;
typedef long double   ld;
typedef pair<int,int> ii;

const int    inf = 2e9;
const ll     INF = 4e17;
const int    mod = 1e9+7;
const double eps = 1e-9;

int main() {
	set<int> st;
	int n, x;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {scanf("%d", &x); st.insert(x);}
	printf("%d\n", st.size());
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

void add_mod(ll& val, ll add_val) {
	val = (val + add_val) % 100000007;
}

int main (int argc, char* argv[]) {
	ll n, k, q;
	cin >> n >> k >> q;
	// you have to win at least this many times
	auto allowance = q - k + 1;
	vector<ll> wins(n);
	for (ll i = 0; i < q; i++) {
		ll winner;
		cin >> winner;
		winner--;
		wins[winner]++;
	}
	for (ll i = 0; i < n; i++) {
		if (wins[i] >= allowance) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 1408
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u64,
        b: u64,
    }

    let mut ans = 0;
    if b - a < 16 {
        for i in a..b + 1 {
            ans ^= i;
        }
    } else {
        for i in a..(a + 3) / 4 * 4 {
            ans ^= i;
        }
        for i in b / 4 * 4..b + 1 {
            ans ^= i;
        }
    };

    println!("{}", ans);
}


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

int main(void) {
    vector<int> height;
    vector<int> width;
    int n = 0;
    while (true) {
        int h, w;
        cin >> h >> w;
        height.push_back(h);
        width.push_back(w);
        if (h == 0 && w == 0) {
            break;
        }
        n++;
    }
    for (int i = 0; i < n; i++) {
        for (int x = 0; x < width.at(i); x++) {
            cout << "#";
        }
        cout << endl;
        for (int y = 2; y < height.at(i); y++) {
            cout << "#";
            for (int x = 2; x < width.at(i); x++) {
                cout << ".";
            }
            cout << "#" <<
            endl;
        }
        for (int x = 0; x < width.at(i); x++) {
            cout << "#";
        }
        cout << endl;
        cout << endl;
        
    }
    return 0;
}



Measured memory_bytes: 3160
/// Zhupengfei 2018
/// Hereby declare: this program is in public domain.

/// Solution for problem: ARC100C

#include <bits/stdc++.h>

using namespace std;

long long A[200001]={};

int main(){
	ios::sync_with_stdio(false);
	int N;
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>A[i];
	}
	for(int i=1;i<=N;i++){
		A[i]=A[i]-i;
	}
	sort(A+1, A+N+1);
	
	int b=-A[N/2+1];
	long long ans=0;
	for(int i=1;i<=N;i++) {
		ans+=abs((long long)(b+A[i]));
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
	int A, B;
	cin >> A;
	cin >> B;
	int s = A*B;
	int s1 = (A + B) * 1 - 1;
	int s2 = s - s1;
	cout << s2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int data[8+1+1][8+1+1];

void func(int x,int y){
	data[y][x] = 0;
	for(int i=-3;i<=3;i++){
		if(x+i<0 || x+i > 9)continue;
		if(data[y][x+i] == 1)func(x+i,y);
	}
	for(int j=-3;j<=3;j++){
		if(y+j<0 || y+j>9)continue;
		if(data[y+j][x] == 1)func(x,y+j);
	}
}

void PrintBoard(){
	for(int i=1;i<=8;i++){
		for(int j=1;j<=8;j++){
			cout<<data[i][j];
		}
		cout<<endl;
	}
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			data[i][j] = 0;
		}
	}
	char tmp;
	int x,y;
	for(int k=1;k<=n;k++){
		for(int i=1;i<=8;i++){
			for(int j=1;j<=8;j++){
				cin>>tmp;
				data[i][j] = tmp-'0';
			}
		}
		cin>>x;
		cin>>y;
		func(x,y);
		cout<<"Data "<<k<<":"<<endl;
		PrintBoard();
	}
	return 0;
}

/*
Sample Input
2

00010010
00000100
10001001
00100010
01000000
00001000
10100010
01010010
2
5

00010010
00000100
10001001
00100010
01000000
00001000
10100010
01010010
2
5
Output for the Sample Input
Data 1:
00000000
00000100
10001001
00100000
00000000
00001000
10100000
00000000
Data 2:
00000000
00000100
10001001
00100000
00000000
00001000
10100000
00000000
*/

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

string s, t, u;
int a, b;

int main() {
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (s == u) {
        cout << a - 1 << ' ' << b;
    }
    else {
        cout << a << ' ' << b - 1;
    }

    return 0;
}


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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;

//iostream::sync_with_stdio(false);

int main()
{
    int n, m;
    cin >> n >> m;
    if(n > m)
    {
        cout << "safe";
    }
    else
    {
        cout << "unsafe";
    }
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long long int lli;
typedef unsigned long long int ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define fin(ans) cout << (ans) << endl;
//３つ以上の値をセットに(3より多いときはカッコ内を増やす)\
sort -> p -> q -> r
#define mt(p, q, r) make_tuple(p, q, r)
#define all(a) a.begin(), a.end()

template <typename T>
void V(T &n)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i];
  }
}

template <typename T, typename U>
void V2(T &n, U &m)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i];
  }
}

template <typename T>
void Sort(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b));
  }
}

template <typename T>
void Down(T &n, ll a = 0, ll b = 0)
{
  if (b == 0)
  {
    return (sort(n.begin() + a, n.end(), greater<ll>()));
  }
  else
  {
    return (sort(n.begin() + a, n.begin() + b, greater<ll>()));
  }
}

void Main()
{
  ll a, b; cin >> a >> b;
  if(a == b) {fin(a + b) exit(0);}
  else fin(max(a, b) * 2 - 1)
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;

int main(){
  string s;
  while(cin >> s){
    string ans;
    if(s == "Sunny") ans = "Cloudy";
    else if(s == "Cloudy") ans = "Rainy";
    else if(s == "Rainy") ans = "Sunny";
    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	int week,money=100000,i;
	scanf("%d",&week);
	for(i=1;i<=week;i++){
		money=money*1.05;
		if(money%1000!=0){
			money=money+(1000-money%1000);
		}
	}
	printf("%d\n",money);
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st a,b,c;
  	ci(a>>b>>c);
  ll A=a.sz,B=b.sz,C=c.sz;
  if(a[A-1]==b[0]&&b[B-1]==c[0]) co("YES")
    else co("NO")
    }

Measured memory_bytes: 256