akhauriyash/Code-Regression huggingface dataset:
#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;

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

	vector<bool> p(n+1,false);
	vector<int>  q(n+1,0);

	int ac = 0, wa = 0;
	rep(i, m) {
	  int pi;
		string s;
		cin >> pi >> s;

		if( !p[pi] && s == "AC") { ac++; wa += q[pi]; p[pi] = true; }
		else if (!p[pi] && s == "WA") q[pi]++;
	}

	cout << ac << " " << wa << endl;

}


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

int main() {
    int n;
    cin >> n;
    vector<int> a;
    int multiple_of_2 = 0;
    int multiple_of_4 = 0;
    int other = 0;
    rep(i,n) {
        int x;
        cin >> x;
        if (x % 4 == 0) multiple_of_4++;
        else if (x % 2 == 0) multiple_of_2++;
        else other++;
    }
    string ans;
    if (multiple_of_2 == 0) {
        if (multiple_of_4 + 1 >= other) ans = "Yes";
        else ans = "No";
    }
    else {
        if (multiple_of_4 >= other) ans = "Yes";
        else ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI(n) for(int i = 0; i < n; ++i)
#define FJ(n) for(int j = 0; j < n; ++j)
#define INT_MAX 2147483647
#define l first
#define r second
#define mp make_pair
#define pb push_back
using namespace std;
ofstream coutf;
ifstream cinf;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD=1000000007;
int solve()
{
    long long  n,a,b,c;
    cin>>n;
    for(int a=1;a<=3500;a++)
    {
        for(int b=1;b<=3500;b++)
        {
            ll x=n*a*b;
            ll y=4*a*b-n*(b+a);
            if((y>0)&&(x%y==0))
            {
                cout<<a<<" "<<b<<" "<<x/y<<endl;
                return 0;
            }
        }
    }

    return 0;
}
int main()
{

    coutf.open("output.txt");
    cinf.open("input.txt");
    solve();
    cinf.close();
    coutf.close();
    return 0;
}


Measured memory_bytes: 384
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
map<long long, long long> mp;
const int mod = 1e9+7;
string s[112345];
int main(){
	int n; scanf("%d", &n);
	for(int i(1); i <= n; ++i){
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		
	}
	sort(s + 1, s + n + 1);
	long long ans(0), cnt(1);
	for(int i(2); i <= n; ++i){
		if(s[i] == s[i - 1]){
			++cnt;
		}
		else{
			ans = ans + (cnt - 1)*cnt;
			cnt = 1;
		}
	}
			ans = ans + (cnt - 1)*cnt;
	printf("%lld\n", ans / 2);
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int k,n,a[200010];
signed main(){
    cin>>k>>n;
    rep(i,n)cin>>a[i];
    int ans=a[n-1]-a[0];
    rep(i,n){
        int x=a[i];
        int y=a[(i+1)%n];
        chmin(ans,x+k-y);
    }
    cout<<ans<<endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, L;
    vector<string> S;
    cin >> N >> L;
    S.resize(N);
    rep(i, N) cin >> S[i];
    sort(S.begin(), S.end());
    iter(s, S) cout << s;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))

a_max=max(a)

min1=0
max1=a_max

while max1-min1>1:
  zantei=(min1+max1)//2
  ans=0
  for x in range(n):
    if a[x]%zantei==0:
      ans+=a[x]//zantei-1
    else:
      ans+=a[x]//zantei
  if ans<=k:
    max1=zantei
  else:
    min1=zantei
    
print(max1)

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

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  REP(i, N){
    cin >> P[i];
  }
  int minp = P[0], cnt = 1;
  FOR(i, 1, N){
    if(minp >= P[i]){
      cnt++;
    }
    minp = min(minp, P[i]);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
/*
author : nit1n
*/
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int a[3][3] ; 
bool vis[3][3] ; 
void check(int u)
{
	for(int i = 0 ;i < 3; ++i)
	{
		for(int j = 0; j < 3 ; ++j)
		{
			if(a[i][j] == u)
				vis[i][j] = true ; 
		}
	}
}
bool bingo()
{
	for(int i = 0; i < 3; ++i)
	{
		if(vis[i][0] == true && vis[i][1] == true && vis[i][2] == true )
			return true  ; 
	}
	for(int j = 0 ; j < 3 ;++j)
	{
		if(vis[0][j] == true && vis[1][j] == true && vis[2][j] == true)
			return true ;
	}
	if(vis[1][1] == true && vis[0][0] == true && vis[2][2] == true)
		return true ; 
	if(vis[2][0] == true && vis[1][1] == true && vis[2][0] == true)
		return true ; 
	return false ; 		
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	for(int i = 0 ; i < 3 ;++i)
	{
		for(int j = 0; j < 3 ; ++j)
			cin >>a[i][j] ; 
	}
	int n ;
	cin >>n  ;
	for(int i = 0 ; i  <n ; ++i)
	{
		int u ; 
		cin >> u ; 
		check(u) ; 
		
	}
	bool ans = bingo() ; 
	if(ans)
		cout << "Yes" ; 
	else 
		cout << "No" ;

}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))

def buy(money, stock, p):
    amount = money // p
    return (money - amount * p), amount

def sell(money, stock, p):
    return (money + stock * p), 0

money = 1000
stock = 0
for i, (p, q) in enumerate(zip(a[:-1], a[1:])):
    if stock == 0 and p < q:
        money, stock = buy(money, stock, p)
    elif stock and p > q:
        money, stock = sell(money, stock, p)

if stock:
    money += stock * a[-1]

print(money)


Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,k,a,i,dp[10000001],m=1e9+7,j;
main(){
	cin>>n>>k;
	dp[k]=1;
	for(i=0;i<n;i++){
		cin>>a;
		for(j=k;j>=0;j--)dp[j]+=dp[j+1];
		for(j=0;j<k;j++)dp[j]=(dp[j]-dp[j+a+1])%m;
	}
	cout<<dp[0];
}


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

int main() {
  int n; cin >> n;
  int sum = 0;
  int maxv = 0;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    sum += a;
    maxv = max(maxv, a);
  }
  sum -= maxv/2;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
int a, b, c, k;
int main() {
    IOS; cin >> a >> b >> c >> k;
    int dosad=k;
    int suma=0;
    suma += min(dosad, a);
    dosad-=min(dosad, a);
    dosad-=min(dosad, b);
    suma -= min(dosad, c);
    cout << suma;
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>

using namespace std;

int main(){

    unsigned int n, m, l;
    unsigned int i, j, k;
    unsigned int nxm[100][100] = {0}, mxl[100][100] = {0};
    unsigned long answer[100][100] = {0};

    cin >> n >> m >> l;

    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> nxm[i][j];
        }
    }

    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            cin >> mxl[i][j];
        }
    }

    /*   m
        1 2
    n   0 3
        4 5
    
          l
        1 2 1
    m   0 3 2
    */

    for(i=0;i<n;i++){
        for(j=0; j<l;j++){
            for(k=0;k<m;k++){
	            answer[i][j] += nxm[i][k] * mxl[k][j];
            }   
        }
    }

    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            if(j == 0){
                cout << answer[i][j];
            }else{
                cout << " " << answer[i][j];
            }
        }
        cout << endl;
    }

    return 0;

}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    rep(i, s.length() - 1) {
        if ((s[i] == 'A') && (s[i + 1] == 'C')) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];

  vector<int> r(n);
  rep(i, n) r[i] = i+1;

  int a, b;
  int i = 0;
  do {
    bool same_p = true, same_q = true;
    rep(j, n) if (p[j] != r[j]) same_p = false;
    rep(j, n) if (q[j] != r[j]) same_q = false;
    if (same_p) a = i;
    if (same_q) b = i;
    i++;
  } while (next_permutation(r.begin(), r.end()));
  int ans = abs(a - b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3492
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using T = ll;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;

ll dp[5000][5000][4];
int main(){
    ll r, c, K;
    cin >> r >> c >> K;
    vector<vector<ll>> fld(r, vector<ll>(c, 0));
    rep(i, K){
        ll a, b, v;
        cin >> a >> b >> v;
        a--;b--;
        fld[a][b] = v;
    }

    rep(i, r){
        rep(j, c){
            REP(k, 1, 3){
                chmax(dp[i + 1][j + 1][k], dp[i + 1][j][k]);
                if(k > 0)chmax(dp[i + 1][j + 1][k], dp[i + 1][j][k - 1] + fld[i][j]);
                else dp[i + 1][j + 1][k] = max({dp[i + 1][j][k], dp[i][j + 1][3] + fld[i][j], fld[i][j]});
                chmax(dp[i + 1][j + 1][k], dp[i][j + 1][3] + fld[i][j]);
            }
        }
    }
    cout << dp[r][c][3] << endl;
    /*
    rep(i, r + 1){rep(j, c + 1)cout << dp[i][j][3] << " ";cout << endl;}
    cout << endl;
    rep(i, r){rep(j, c)cout << fld[i][j] << " " ;cout << endl;}
    */
}



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

int main() {
	int N;
  cin>>N;
  string S;
  cin>>S;
  int cnt=0;
  if(N==1){cout<<1<<endl;}
  else{
  for(int ia=0;ia<N-1;ia++){
    if(S.at(ia)!=S.at(ia+1)){
      cnt++;
    }
  }
    cout<<cnt+1<<endl;
}
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**8)
n=int(input())
inp=[list(map(int,input().split())) for i in range(n)]
inp.sort(key=lambda tup:tup[0])
data=[[-1]*3 for i in range(n)]
D=[-1]*n

for e in inp:
    for i in range(2,len(e)):
        data[e[i]][0]=e[0]
        if i==2:
            data[e[0]][1]=e[i]
        else:
            data[l][2]=e[i]
        l=e[i]

for i in range(n):
    if data[i][0]==-1:
        r=i

def defth(node,p):
    D[node]=p
    if data[node][1]!=-1:
        defth(data[node][1],p+1)
    if data[node][2]!=-1:
        defth(data[node][2],p)

defth(r,0)

for i in range(n):
    if i==r:sta='root'
    elif len(inp[i])==2:sta='leaf'
    else: sta='internal node'
    print(f'node {i}: parent = {data[i][0]}, depth = {D[i]}, {sta}, {inp[i][2:]}')








Measured memory_bytes: 132324
A, B, C, D, E, F=map(int, input().split())
wans=0
sans=0
for i in range(31):
    w=100*A*i
    s=0
    if s+w>F:
        break
    for j in range(31):
        w=100*A*i+100*B*j
        s=0
        if s+w>F:
            break
        for k in range(3001):
            w=100*A*i+100*B*j
            s=C*k
            if s+w>F:
                break
            for l in range(3001):
                w=100*A*i+100*B*j
                s=C*k+D*l
                if s+w>F:
                    break
                if w!=0 and s*(100+E)<=(s+w)*E and sans*(s+w)<=s*(sans+wans) and w+s<=F:
                    sans=s
                    wans=w
                #print(sans,sans+wans)
print(sans+wans,sans)

Measured memory_bytes: 3064
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll dim = 3001;
ll dp[dim][dim];
ll n , m ;
string s , t ;
/*ll solve(ll i , ll j){
    if(i==0||j==0)
        return 0 ;
    if(dp[i][j]!=0){
        return dp[i][j];
    }
    if(s[i-1]==t[j-1])
        return dp[i][j]=1+solve(i-1,j-1);
    else
        return dp[i][j]=max(solve(i,j-1),solve(i-1,j));
}*/
int main()
{
    cin >> s >> t ;
    n=s.size();
    m=t.size();
    memset(dp,0,sizeof dp);
    for (ll i = 0; i <= n; i++)
    {
        for (ll j = 0; j <= m; j++)
        {
        if (i == 0 || j == 0)
            dp[i][j] = 0;

        else if (s[i - 1] == t[j - 1])
            dp[i][j] = dp[i - 1][j - 1] + 1;

        else
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string res="";
    ll i = n ;
    ll j = m ;
    while(i>0&&j>0){
        if(s[i-1]==t[j-1]){
            res = s[i-1] + res ;
            i--;
            j--;
        }else if (dp[i-1][j]>=dp[i][j-1]){
            i--;
        }else{
            j--;
        }
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  long long A,B,a,b;
  cin>>A>>B;
  a=A;
  b=B;
  while(a!=b){
    if(a>b){
      a-=b;
    }
    else{
      b-=a;
    }
  }
  cout<<A*B/a<<endl;
}




Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<unistd.h>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

struct Buffer{
    int idx;
    char buf[1025];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, 1024); }
    void check(){ if(idx == 1024){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

int cs[10][10];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    Buffer buf;
    int h = buf.next(), w = buf.next();
    // vector<vector<short>> cs(10, vector<short>(10));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cs[i][j] = buf.next();
        }
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                cs[j][k] = min((int)cs[j][k], cs[j][i] + cs[i][k]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int a = buf.next();
            prints(a);
            if(a != -1){
                ans += cs[a][1];
            }
        }
    }
    cout << ans << '\n';
}


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

using namespace std;

typedef unsigned long long ULL;
int main(){
    ULL ans;
    ULL *A;
    int i;
    int N;
    int count;
    int pos;
    cin >> N;
    A = new ULL[N];

    for(i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A + N,std::greater<ULL>());
    count = 0;
    pos = 1;
    ans = A[0];
    for(i=1;i<N-1;i++){
        ans += A[pos];
        count++;
        if( count == 2){
            count = 0;
            pos++;
        }
    }
    cout << ans << endl;
    return 0;

}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define swapll(x, y) { ll tmp = x; x = y; y = x; }

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

  ll x = c - a - b;
  string ret;
  if(x <= 0
    || 4 * a * b >= x * x)
  {
    ret = "No";
  }
  else
  {
    ret = "Yes";
  }
  
  cout << fixed << ret << endl;
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [[s if s == '#' else 0 for s in input().rstrip()] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            if i-1 >= 0:  # top
                if S[i-1][j] != '#':
                    S[i-1][j] += 1
                if j-1 >= 0 and S[i-1][j-1] != '#':  # left
                    S[i-1][j-1] += 1
                if j+1 < W and S[i-1][j+1] != '#':  # right
                    S[i-1][j+1] += 1
            if j-1 >= 0 and S[i][j-1] != '#':  # mid_left
                S[i][j-1] += 1
            if j+1 < W and S[i][j+1] != '#':  # mid_right
                S[i][j+1] += 1
            if i+1 < H:  # bottom
                if S[i+1][j] != '#':
                    S[i+1][j] += 1
                if j-1 >= 0 and S[i+1][j-1] != '#':  # left
                    S[i+1][j-1] += 1
                if j+1 < W and S[i+1][j+1] != '#':  # right
                    S[i+1][j+1] += 1

for row in S:
    for s in row:
        print(s, end="")
    print()

Measured memory_bytes: 3572
// pairを利用するバージョン

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    vector<pair<int, int> > v;
    int n;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        pair<int, int> P(x, y);
        v.push_back(P);
    }

    // pairを使うと良い感じにソートしてくれる
    sort(v.begin(), v.end());

    for (int i = 0; i < n; ++i) {
        cout << v[i].first << ' ' << v[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 3828
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var char string
		fmt.Scan(&char)
		if char == "Y"{
			fmt.Println("Four")
			return
		}
	}
	fmt.Println("Three")
}


Measured memory_bytes: 512
#include <iostream>
#include <map>

using namespace std;

int main( void )
{
	while (1)
	{
		map <char, char> T;

		int n;
		cin >> n;

		if ( n == 0)
			break;

		for ( int i = 0; i < n; ++i )
		{
			char c;
			cin >> c;
			cin >> T[c];
		}

		string answer;
		int m;
		cin >> m;
		for ( int i = 0; i < m; ++i )
		{
			char c;
			cin >> c;
			if( T.find(c) != T.end() )
				answer += T[c];
			else
				answer += c;
		}

		cout << answer << endl;
	}

	return 0;
}

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

int main(void) {
	int j = 0;
	char s[200001], t[200001];
	scanf("%s",&s);
    scanf("%s",&t);

	for (int i = 0; i <= strlen(s); i++)
		if (s[i] != t[i])
			j++;
	printf("%d", j);
	return 0;
}
//→C++で書き換えると

// #include<iostream>
// #include<string>
// using namespace std;
// int main(void) {
// 	int j = 0;
//     string s,t;
//     cin >> s >> t;
// 	for (int i = 0; i <= s.size(); i++)
// 		if (s[i] != t[i])
// 			j++;
//     cout << j << endl;
// 	return 0;
// }

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

using namespace std;

int main()
{
    int n, c;
    cin >> n >> c;
    int w[n];
    int v[n];
    for(int i = 0;i < n;i++)
    {
        cin >> w[i] >> v[i];
    }
    long long mem[2][c + 1];
    for(int i = 0;i < (c + 1);i++)
        mem[0][i] = 0;
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < (c + 1);j++)
        {
            if(i % 2 == 0)
            {
                if(w[i] <= j)
                {
                    long long val1 = mem[0][j];
                    long long val2 = v[i] + mem[0][j - w[i]];
                    mem[1][j] = max(val1, val2);
                }
                else
                {
                    mem[1][j] = mem[0][j];
                }
            }
            else
            {
                if(w[i] <= j)
                    mem[0][j] = max(mem[1][j] , v[i] + mem[1][j - w[i]]);
                else
                    mem[0][j] = mem[1][j];
            }
        }
    }
    if(n % 2 == 0)
        cout << mem[0][c] << endl;
    else
        cout << mem[1][c] << endl;
    return 0;
}

Measured memory_bytes: 5180
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    map<int, int> m;
    rep(i, n) {
        int d; cin >> d;
        m[d]++;
    }
    cout << m.size() << endl;
    return 0;
}


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

int main ()
{
  //initialization of variables
  int n,d,c,e=0;
  double a,b,x,y;
  //input
  cin>>n>>d;
  //loop for input of x and y and
  //check if the value is smaller than d
  for(c=1;c<=n;c++)
  {
    cin>>x>>y;
    a=(x*x)+(y*y);
    b=sqrt(a);
    //cout<<c<<"th b:"<<b<<endl;

    if(b<=d)
    {
        e=e+1;
        //cout<<c<<"th e:"<<e<<endl<<endl;
    }
  }
  //output
  cout<<e;
  return 0;
}


Measured memory_bytes: 3712
// 2020-08-31 19:01:03
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  int mx = -1, my = -1, mh = -1;
  rep(i, n) {
    cin >> x[i] >> y[i] >> h[i];
    if (chmax(mh, h[i])) {
      mx = x[i];
      my = y[i];
    }
  }
  repc(cx, 100) repc(cy, 100) {
    int ch = mh + abs(cx - mx) + abs(cy - my);
    chmax(ch, 1);
    bool ok = true;
    rep(i, n) {
      int dh = ch - abs(cx - x[i]) - abs(cy - y[i]);
      chmax(dh, 0);
      if (dh != h[i]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << cx << ' ' << cy << ' ' << ch << '\n';
      return;
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>

int main(void){
    int a = 0, x, i = 0;
    int flag;
   while(scanf("%d",&x) != EOF) {
       flag = 1;
       if(x == 2) ;
       else if(x<2 || x%2 == 0) flag = 0;
       else {
            i = 3;
            while(i <= sqrt(x)) {
                if(x%i == 0) {
                    flag = 0;
                }
                i = i + 2;
            }
       }
       if(flag == 1) a++;
   }
   printf("%d\n",a);
   return 0;
}



Measured memory_bytes: 2096
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
namespace IO{
    const int S=20000005;
    char buf[S];
    int pos;
    void Load(){
        fread(buf,1,S,stdin);
        pos=0;
    }
    char getChar(){
        return buf[pos++];
    }
    int getInt(){
        int x=0,f=1;
        char c=getChar();
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getChar();}
        while('0'<=c&&c<='9'){x=x*10+c-'0';c=getChar();}
        return x*f;
    }
}
using IO::getInt;
const int N=100005;
int n,m,inp[N];
int h[N],tot,pre[N];
struct Edge{
    int v,next;
}e[N*2];
int note;
int f[N],g[N];
int lis[N],cnt;
ll ans;
inline int abs(int x){
    return x<0?-x:x;
}
inline void addEdge(int u,int v){
    e[++tot]=(Edge){v,h[u]}; h[u]=tot;
    e[++tot]=(Edge){u,h[v]}; h[v]=tot;
}
void readData(){
    IO::Load();
    n=getInt(); m=getInt();
    tot=1;
    int u,v;
    for(int i=1;i<=m;i++){
        u=getInt(); v=getInt();
        addEdge(u,v);
    }
}
void tree_dfs1(int u,int fa,int dep){
    pre[u]=fa;
    f[u]=(dep&1)?1:-1;
    for(int i=h[u],v;i;i=e[i].next)
        if((i>>1)!=(note>>1)&&(v=e[i].v)!=fa){
            tree_dfs1(v,u,dep^1);
            f[u]+=f[v];
        }
    ans+=abs(f[u]);
}
void solveTree(int u){
    ans=0;
    note=-1;
    tree_dfs1(u,0,0);
    if(f[1]!=0)
        printf("-1\n");
    else
        printf("%lld\n",ans);
}
void tree_dfs2(int u,int fa,int dep){
    f[u]=(dep&1)?1:-1;
    for(int i=h[u],v;i;i=e[i].next)
        if((i>>1)!=(note>>1)&&(v=e[i].v)!=fa){
            tree_dfs2(v,u,dep^1);
            f[u]+=f[v];
            g[u]+=g[v];
        }
    if(g[u]==0) 
        ans+=abs(f[u]);
    else lis[++cnt]=(g[u]==1)?-f[u]:f[u];
}
int sta[N],top;
bool vis[N];
int findCircleEdge(int u,int fa,int &a,int &b,int &eid){
    vis[u]=true;
    sta[++top]=u;
    for(int i=h[u],v;i;i=e[i].next)
        if((v=e[i].v)!=fa){
            if(vis[v]){
                a=u;
                b=v;
                eid=i;
                int len=0;
                for(;sta[top+1]!=v;len++,top--);
                return len&1;
            }
            else{
                int get=findCircleEdge(v,u,a,b,eid);
                if(get!=-1) return get;
            }
        }
    sta[top--]=0;
    return -1;
}
void findMid(){
    sort(lis+1,lis+1+cnt);
    int x=lis[(cnt+1)>>1];
    ans+=abs(x);
    for(int i=1;i<=cnt;i++)
        ans+=abs(x-lis[i]);
    printf("%lld\n",ans);
}
void solveCircle(){
    int oe,u,v;
    oe=findCircleEdge(1,0,u,v,note);
    if(oe==1){
        ans=0;
        tree_dfs1(u,0,1);
        if(f[u]&1)
            printf("-1\n");
        else{
            int delta=-f[u]/2;
            for(int now=v;now;now=pre[now])
                f[now]+=delta;
            f[u]+=delta;
            ans=abs(delta);
            for(int i=1;i<=n;i++)
                ans+=abs(f[i]);
            printf("%lld\n",ans);
        }
    }
    else{
        g[u]++;
        g[v]--;
        tree_dfs2(u,0,0);
        if(f[u])
            printf("-1\n");
        else
            findMid();
    }
}
int main(){
    readData();
    if(m==n-1)
        solveTree(1);
    else   
        solveCircle();
    return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n, k;
	cin >> n >> k;
	vi v(n);
	for(int& x:v) cin >> x;
	sort(ALL(v));
	int ans = 0;
	for(int i = 0; i < k; i++) ans += v[i];
	cout << ans << endl;
		
}





Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

bool ok = false;
bool fact[1000006];
void factors(int x) {
	if (ok)
		return;
	for (int i = 1; i * i <= x; i++) {
		if (x % i == 0) {
			int a = i, b = x / i;
			if (a == b) {
				a = i;
				b = 1;
			}
			if (a != 1) {
				if (fact[a]) {
					ok = true;
					return;
				}
				fact[a] = true;
			}
			if (b != 1) {
				if (fact[b]) {
					ok = true;
					return;
				}
				fact[b] = true;
			}
		}
	}
}

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	memset(fact, false, sizeof fact);
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int gcd = arr[0];
	factors(arr[0]);
	for (int i = 1; i < n; i++) {
		factors(arr[i]);
		gcd = __gcd(gcd, arr[i]);
	}
	if (!ok)
		cout << "pairwise coprime";
	else if (gcd == 1)
		cout << "setwise coprime";
	else
		cout << "not coprime";
	return 0;
}

Measured memory_bytes: 12340
#include<stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	if (a<b&&b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2112
import sys
from bisect import bisect_right

input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    n = [A.pop(-1)]
    A.reverse()
    
    for a in A:
        if n[-1] <= a: n.append(a)
        else: n[bisect_right(n, a)] = a
    
    print(len(n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7968
N, M = map(int, input().split())
D = []

for i in range(N):
    D.append(list(map(int, input().split())))

D.sort()
num = 0
cost = 0
i = 0
while num < M:
    cost += D[i][0] * min(D[i][1], M - num)
    num += min(D[i][1], M - num)
    i += 1

print(cost)


Measured memory_bytes: 27760
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int p[] = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt() - 1;
		}
		Union union = new Union(n);
		int x, y;
		for (int i = 0; i < m; i++) {
			x = sc.nextInt() - 1;
			y = sc.nextInt() - 1;
			union.unite(x, y);
		}
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (union.same(i, p[i])) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

class Union {
	private int[] parent;
	private int[] rank;

	public Union(int n) {
		parent = new int[n];
		rank = new int[n];
		for (int i = 0; i < n; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}

	public boolean same(int a, int b) {
		if (root(a) == root(b)) {
			return true;
		} else {
			return false;
		}
	}

	public int root(int n) {
		if (parent[n] == n) {
			return n;
		}
		return parent[n] = root(parent[n]);
	}

	public void unite(int a, int b) {
		int aroot = root(a);
		int broot = root(b);
		if (aroot == broot) {
			return;
		}
		if (rank[aroot] > rank[broot]) {
			parent[broot] = aroot;
		} else if (rank[aroot] < rank[broot]) {
			parent[aroot] = broot;
		} else {
			parent[broot] = aroot;
			rank[aroot]++;
		}

	}

}

Measured memory_bytes: 89492
// AOJ ALDS1_1_A Insertion Sort
// 2018.4.26 bal4u

#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define MAX_N 102

int a[MAX_N];

void dump(int n)
{
	int i;

	printf("%d", a[0]);
	for (i = 1; i < n; i++) printf(" %d", a[i]);
	putchar('\n');
}

void insertion_sort(int n)
{
	int i, j, key;

	dump(n);
	for (i = 1; i < n; i++) {
		key = a[i];
		j = i-1;
		while (j >= 0 && a[j] > key) a[j+1] = a[j], j--;
		a[j+1] = key;
		dump(n);
	}
}

int main()
{
	int N, i;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	insertion_sort(N);
	return 0;
}



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

#define rep(i, n)     for(int i = 0;      i < int(n); ++i)
#define rep3(i, a, b) for(int i = int(a); i < int(b); ++i)
#define all(x)        (x).begin(),(x).end()
#define sz(x)         int(x.size())
#define mp            make_pair
#define pb            push_back


typedef long long ll;

using namespace std;

int main(){
  int k, even, odd;
  cin >> k;
  even = k / 2;
  odd  = k / 2 + k % 2;

  cout << even * odd << endl;

  return 0;
}



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

using namespace std;

int A, B, C, K;

int main(void) {

	cin >> A >> B >> C >> K;

	int cnt = 0;

	while (A >= B) { B *= 2; cnt++; }
	while (B >= C) { C *= 2; cnt++; }

	if (cnt <= K) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 3592
S = input()
l = len(S) - 1
ans=0
for i in range(2 ** l):
    op = ["-"] * l
    for j in range(l):
        if ((i >> j) & 1):
            op[l - 1 - j] = "+"
    formula = ""
    for j in range(l):
        formula+=S[j]
        if op[j]=="+":
            formula+="+"
    formula+=S[l]
    ans+= eval(formula)
print(ans)

Measured memory_bytes: 9048
int power(int n,int m) { //nのm乗
 int j,s;
 s=1;
 for (j=0;j<m;j++) {
  s=s*n;
 }
 return s;
}

int main() {
int N,M,a,b,c;
scanf("%d",&N);
scanf("%d",&M);
a=1900*M+100*(N-M);
b=power(2,M);
c=a*b;
printf("%d\n",c);
return 0;
}

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

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N + 1), y(M + 1);
    rep(i, N)
    {
        cin >> x[i];
    }
    x[N] = X;
    rep(i, M)
    {
        cin >> y[i];
    }
    y[M] = Y;
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if (y[0] - x[N] > 0)
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int x,int y){
    if(x<y){
        int tmp=x;
        x=y;
        y=tmp;
    }
    while(y>0){
        int r=x%y;
        x=y;
        y=r;
    }
    return x;
}
int main(){
    int ans,x,y;
    cin>>x>>y;
    ans=gcd(x,y);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll ans = 0;
    reps(a, 1, n + 1) {
        reps(b, 1, n + 1) {
            reps(c, 1, n + 1) {
                ans += __gcd(__gcd(a, b), c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: x,y,n
    
    read*, x
    y=100   
    n=0
    do while(y < x)
        y=y+y/100
        n=n+1
    end do
    print'(i0)', n
end program name

Measured memory_bytes: 2924
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main()
{
    int n, q; // 100'000
    string s;
    cin >> n >> q >> s;
    auto is_ac_at = vector<int>(n);
    for (int i = 0; i + 1 < n; ++i) {
        if (s[i] == 'A' && s[i + 1] == 'C')
            is_ac_at[i] = 1;
    }
    auto acc = vector<int>(n + 1);
    acc[0] = 0;
    for (int i = 0; i < n; ++i) {
        acc[i + 1] = acc[i] + is_ac_at[i];
    }

    for (auto a : acc)
        cerr << a << " ";
    cerr << "\n";

    for (int i = 1; i <= q; ++i) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        auto cnt = acc[r] - acc[l];
        cout << cnt << "\n";
    }

    return 0;
}


Measured memory_bytes: 4280
def process(H, W) : 
  str = '#' * (W + 2)
  print(str)
  for i in range(H) : 
    s = '#'
    s += input()
    s += '#'
    print(s)
  print(str)


H, W = tuple(map(int, input().split()))
process(H, W)


Measured memory_bytes: 3060
N,M,T = map(int,input().split())
src = list(map(int,input().split()))
back_time = ans = 0
for t in src:
    if t - M > back_time:
        ans += (t - M - back_time)
    back_time = t + M
ans += max(0, T - back_time)
print(ans)

Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
int main()
{
  int n;
  cin >> n;
  vi t(n), x(n), y(n);
  re(i, n) cin >> t[i] >> x[i] >> y[i];

  bool can = true;
  re(i, n) {
    if (t[i] < x[i] + y[i]) can = false;
  }
  re(i, n) {
    if(t[i] % 2 == 1) {
      if ((x[i] + y[i]) % 2 != 1) can = false;
    } else {
      if ((x[i] + y[i]) % 2 != 0) can = false;
    }
  }

  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  long long int d, n;
  cin >> d >> n;
  if (d == 0) {
    if (n == 100) {
      cout << n+1<< endl;
    } else{
      cout << n << endl;
    }
  } else if (d == 1) {
    if (n == 100) {
      cout << (n+1)*100<< endl;
    } else{
      cout << n*100 << endl;
    }
  } else {
    if (n == 100) {
      cout << (n+1)*10000<< endl;
    } else{
      cout << n*10000 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
while True:
    h, w = [int(i) for i in input().split(' ')]
    if h ==0 and w ==0:
        break
    for i in range(h):
        row = ''
        for j in range(w):
            if (i % 2 == 0 and j % 2 == 0) or (i % 2 != 0 and j % 2 != 0):
                row = row + '#'
            else:
                row = row + '.'
        print(row)
    print('')


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

int main(){
  str s; cin >> s;
  int ans = 700;
  for(int i=0; i<3; i++){
    if(s[i] == 'o'){
      ans += 100;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var H = Number(lines[0].split(" ")[0]);
    var W = Number(lines[0].split(" ")[1]);
    lines.shift();

    var a = lines.map(i => i.split(" ").map(i => Number(i)));
    var ans = [];

    for (var i = 0; i < H - 1; i++) {
        for (var j = 0; j < W; j++) {
            if (a[i][j] % 2 !== 0) {
                a[i][j]--; a[i + 1][j]++;
                var str = (i + 1).toString() + " " + (j + 1).toString() + " " + (i + 2).toString() + " " + (j + 1).toString();
                ans.push(str)
            }
        }
    }

    for (var j = 0; j < W - 1; j++) {
        if (a[H - 1][j] % 2 !== 0) {
            a[H - 1][j]--; a[H - 1][j + 1]++;
            var str = H.toString() + " " + (j + 1).toString() + " " + H.toString() + " " + (j + 2).toString();
            ans.push(str)
        }
    }

    console.log(ans.length)
    for (var value of ans) { console.log(value); }
});

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

#define ll long long

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

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

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

	sort(a, a + n, greater<int>());

	if (a[m - 1] < 0.25 / m * accumulate(a, a + n, 0))
		cout << "No";
	else
		cout << "Yes";
}

Measured memory_bytes: 256
import sys

N = int(input())
H = list(map(int, input().split()))

for i in range(N-1):
    if i:
        if H[i] - H[i+1] >= 2:
            print('No')
            sys.exit()
        elif H[i] <= H[i+1]:
            if H[i] - 1 >= H[i-1]:
                H[i] -= 1
            else:
                continue
        else:
            if H[i] - 1 >= H[i-1]:
                H[i] -= 1
            else:
                print('No')
                sys.exit()
    else:
        if H[i] - H[i+1] >= 2:
            print('No')
            sys.exit()
        elif H[i] <= H[i+1]:
            H[i] -= 1

print('Yes')


Measured memory_bytes: 14976
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var W = new string[N];
        for (int i = 0; i < N; i++)
        {
            W[i] = Console.ReadLine();
        }

        var map = new HashSet<string>();
        string ans = "Yes";
        for (int i = 0; i < N; i++)
        {
            if (map.Contains(W[i]))
            {
                ans = "No";
                break;
            }

            map.Add(W[i]);

            if (i == 0)
            {
                continue;
            }

            var prevEnd = W[i - 1].Last();
            var start = W[i].First();
            if (prevEnd != start)
            {
                ans = "No";
                break;
            }
        }

        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 13280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

    private static final String ZERO = "0";

    public static void main(String[] args) {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String input = null;
        Stack<String> cars = new Stack<String>();

        try {
            while ((input = in.readLine()) != null) {

                if (ZERO.equals(input)) {
                    System.out.println(cars.pop());
                } else {
                    cars.push(input);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Measured memory_bytes: 16872
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
    int n;
    vector<double> vec;
    cin >> n;
    rep(i, n) {
        int v;
        cin >> v;
        vec.push_back(v);
    }

    rep(i, n-1) {
        sort(vec.begin(), vec.end(), greater<int>());
        double min1 = vec.back();
        vec.pop_back();
        double min2 = vec.back();
        vec.pop_back();
        vec.push_back((min1 + min2) / 2.0);
    }
    cout << vec.back() << endl;

    return 0;
}

Measured memory_bytes: 256