akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000000000000002
#define N 400003
#define endl "\n"
using namespace std;
ll arr[102][100003];
int main()
{

    ll s[1000][7];ll n,w;cin>>n>>w;
    for(ll i=0;i<n;i++)
    {
        cin>>s[i][0]>>s[i][1];
    }
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            if(i==0||j==0)
            {
                arr[i][j]=0;
            }
            else
            {
            if(s[i-1][0]<=j)
            {
                arr[i][j]=max(arr[i-1][j],s[i-1][1]+arr[i-1][j-s[i-1][0]]);
            }
            else

            {
                arr[i][j]=arr[i-1][j];
            }
            }
        }
    }
    cout<<arr[n][w]<<endl;;

    return 0;
}


Measured memory_bytes: 79104
/*
  Contest 065
  A - Expired?
  Rakesh Kumar --> 31/08/2020
 */

#include <bits/stdc++.h>

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

    int x = 0, a = 0, b = 0;
    std::cin >> x >> a >> b;
    if (b - a <= 0)
        std::cout << "delicious" << std::endl;
    else if (b - a <= x)
        std::cout << "safe" << std::endl;
    else
        std::cout << "dangerous" << std::endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <utility>
#include <climits>
#include <cstring>
#include <cstdio>

#include <complex>
typedef std::complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

using namespace std;
typedef long long int llg;

const int INF = 1000001000;
#define REP(var, count) for(int var=0; var<count; var++)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

int main(void) {

	double p, q;
	scanf("%lf,%lf", &p, &q);
	xy_t P(p,q);
	
	double ret = 0.0;
	
	xy_t prev;
	int N = 0;
	
	while ( !feof(stdin) ) {
		double a, b;
		scanf("%lf,%lf", &a, &b);
		xy_t X(a,b);
		
		if ( N > 0 ) {
			ret += abs( cross_product(X-P,prev-P) / 2 );
		}
		
		prev = X;
		N++;
	}
	
	printf("%lf\n", ret);
}

Measured memory_bytes: 3156
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=110,M=1e6+100;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

const int mod=1e9+7;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};

int X[N],Y[N];
struct P{ int x,y; }p[N];
bool can[N][N],vis[N][N];
int pre[M],suf[M],dis[N][N];
int main()
{
	int n=gi(),m=gi(),T=gi(),i,j,lx=0,ly=0,x,y,ans=0,t;LL sum;
	queue<P>q;
	X[++lx]=Y[++ly]=1;
	for (i=0;i<T;i++) {
		X[++lx]=p[i].x=gi()+1,Y[++ly]=p[i].y=gi()+1;
		if (X[lx]!=n) X[++lx]=p[i].x+1;
		if (Y[ly]!=m) Y[++ly]=p[i].y+1;
	}
	sort(X+1,X+lx+1);lx=unique(X+1,X+lx+1)-X-1;
	sort(Y+1,Y+ly+1);ly=unique(Y+1,Y+ly+1)-Y-1;
	X[lx+1]=n+1;Y[ly+1]=m+1;
	for (i=1;i<=lx;i++)
		for (j=1;j<=ly;j++)
			can[i][j]=true;
	for (i=0;i<T;i++)
		can[find(X+1,X+lx+1,p[i].x)-X][find(Y+1,Y+ly+1,p[i].y)-Y]=false;

	for (i=0;i<T;i++)
		++pre[p[i].x];
	for (i=n;i;i--) suf[i]=(suf[i+1]+m-pre[i])%mod;
	for (i=1,sum=0;i<n;i++) {
		sum+=m-pre[i];
		if (!pre[i]&&!pre[i+1])
			ans=(ans+sum%mod*suf[i+1])%mod;
	}
	for (i=1;i<=n;i++) pre[i]=suf[i]=0;
	for (i=0;i<T;i++)
		++pre[p[i].y];
	for (i=m;i;i--) suf[i]=(suf[i+1]+n-pre[i])%mod;
	for (i=1,sum=0;i<m;i++) {
		sum+=n-pre[i];
		if (!pre[i]&&!pre[i+1])
			ans=(ans+sum%mod*suf[i+1])%mod;
	}
	for (i=1;i<=lx;i++)
		for (j=1;j<=ly;j++)
			if (can[i][j]) {
				for (x=1;x<=lx;x++)
					for (y=1;y<=ly;y++)
						vis[x][y]=can[x][y];
				q.push((P){i,j});vis[i][j]=false;dis[i][j]=0;
				while (!q.empty()) {
					x=q.front().x;y=q.front().y;q.pop();
					if (x>i||(x==i&&y>j))
						ans=(ans+1LL*(X[x+1]-X[x])*(Y[y+1]-Y[y])%mod*(X[i+1]-X[i])%mod*(Y[j+1]-Y[j])%mod*dis[x][y])%mod;
					for (t=0;t<4;t++)
						if (vis[x+dx[t]][y+dy[t]]) {
							dis[x+dx[t]][y+dy[t]]=dis[x][y]+1;
							vis[x+dx[t]][y+dy[t]]=false;
							q.push((P){x+dx[t],y+dy[t]});
						}
				}
			}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int n = s.size()/2;

  while (n > 1) {
    n--;
    if (s.substr(0,n) == s.substr(n,n)) 
      ans = max(ans,2*n);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
// Problem : E - Count Median
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//Mmmmmm......
#include<bits/stdc++.h>
using namespace std;

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
#define re return 
#define vi vector<int>
#define vii vector<pair<int ,int > >
#define F first
#define S second
#define pussy push_back
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 , mod = 1e9 + 7;

void solve() {
	int n;cin >> n ;
	vector<pair<int,int> > v(n);
	for(auto &i : v) cin >> i.F >> i.S;
	vi mn,mx;
	for(auto i : v) {
		mn.pussy(i.F);
		mx.pussy(i.S);
	}
	sort(begin(mn) , end(mn));
	sort(begin(mx) , end(mx));
	int maxx = 0,minn = 0;
	if(n % 2) {
		minn = mn[n/2];
		maxx = mx[n/2];
	} else {
		minn = mn[n/2 - 1] + mn[n/2];
		maxx = mx[n/2 - 1] + mx[n/2];
		w << maxx - minn + 1 << endl;
		re;
	}

	int ans = 0;
	sort(begin(v), end(v));
	for(auto i : v){
		if(minn > maxx)break;
		if(i.S >= minn){
			int till = min(maxx , i.S);
			int st = max(minn , i.F);
			ans += till - st + 1;
			minn = till + 1;
		}
	}
	w << ans  << e;
}

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	int t = 1;
	// cin >> t;
	while(t--) {
		solve();
	}	
}


Measured memory_bytes: 9828
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    rep(i, h) cin >> c[i];

    rep(i, 2 * h){
        cout << c[i / 2] << endl;
    }
    
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dpc[1 << 16], dpn[1 << 16];

signed main() {
    int R, C; cin >> R >> C;
    fill(dpc, dpc + (1<<C), -1);
    fill(dpn, dpn + (1<<C), -1);
    dpc[0] = 0;
    int pn = 0;
    string ps = "";
    for(int i=0; i<R; i++) {
        string s; cin >> s;
        int N = s.length();
        for(int j=0; j<C; j++) {
            for(int bit=0; bit<(1<<C); bit++) {
                if(dpc[bit] < 0) continue;
                // fprintf(stderr, "i = %lld, j = %lld, bit = %lld, dp = %lld\n", i, j, bit, dpc[bit]);
                {
                    int mask1 = (1 << j) - 1;
                    int mask2 = (1 << C) - 1 - mask1;
                    // 置く (j 列目に k 文字目を置く)
                    int k = __builtin_popcount(bit & mask1);
                    int l = pn - __builtin_popcount(bit & mask2);
                    
                    if(k < N) {
                        int c1 = (k > 0 and j > 0 and (bit >> (j-1) & 1) and s[k-1] == s[k]);
                        int c2 = (i > 0 and bit >> j & 1) and (ps[l] == s[k]);

                        int nbit = bit | (1 << j);
                        chmax(dpn[nbit], dpc[bit] + (c1 + c2) * 2);
                    }
                }

                {
                    // 置かない
                    int mask1 = (1 << j) - 1;
                    int k =__builtin_popcount(bit & mask1);
                    // 残りマス数
                    int remA = C - j - 1, remB = N - k;
                    if(remA >= remB) {
                        int nbit = bit;
                        if(nbit >> j & 1) nbit -= (1 << j);
                        chmax(dpn[nbit], dpc[bit]);
                    }
                }
                dpc[bit] = -1;
            }
            swap(dpn, dpc);
        }
        pn = N; ps = s;
    }
    int ans = *max_element(dpc, dpc + (1<<C));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;





struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main()
{
	int n,m;
	cin>>n>>m;
vector<vector<int>> g(n);
UnionFind uf(n);
int ans=n;

	rep(i,m){
		int x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		g[x].emplace_back(y);
		g[y].emplace_back(x);
		if (uf.same(x,y)) continue;
		ans--;
		uf.unite(x,y);

	}
	cout<<ans;



}


Measured memory_bytes: 6520
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    static PrintWriter out;
    static Scanner scanner;
    void solve() {
        int nn = scanner.nextInt();
        seg_init(nn);
        int q = scanner.nextInt();
        while (q-- > 0) {
            int com = scanner.nextInt();
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            if (com == 0) {
                update(x, y);
            } else {
                out.println(query(x, y + 1, 0, 0, n));
            }
        }
    }

    int n, q;
    int seg[];

    void seg_init(int nn) {
        n = 1;
        while (n < nn) {
            n <<= 1;
        }
        seg = new int[n * 2 - 1];
        Arrays.fill(seg, Integer.MAX_VALUE);
    }

    int query(int a, int b, int k, int l, int r) {
        if (a <= l && r <= b) {
            return seg[k];
        }
        if (r <= a || b <= l) {
            return Integer.MAX_VALUE;
        }
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return Math.min(vl, vr);
    }

    void update(int i, int x) {
        i += n - 1;
        seg[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            seg[i] = Math.min(seg[i * 2 + 1], seg[i * 2 + 2]);
        }
    }

    public static void main(String[] args) throws Exception {
        scanner = new Scanner(System.in);

        out = new PrintWriter(System.out);
        new Main().solve();
        out.flush();
    }

}

Measured memory_bytes: 103732
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const ll MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n,a,b;
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// 繰り返し二乗法 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % MOD, n/2);
    if(n&1) ret=(ret*x)%MOD;
    return ret;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    ll ans=pow_mod(2,n)-1;
    ans=(ans+MOD)%MOD;
    ll temp=1;
    for(ll i=1;i<=a;i++){
        temp*=(n-i+1);
         temp%=MOD;
        temp*=modinv(i,MOD);
        temp%=MOD;
    }
    ans-=temp;
    ans=(ans+MOD)%MOD;
    temp=1;
    for(ll i=1;i<=b;i++){
        temp*=(n-i+1);
         temp%=MOD;
        temp*=modinv(i,MOD);
        temp%=MOD;
    }
    ans-=temp;
    ans=(ans+MOD)%MOD;
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a[10000],n,i,max,min;
	long long int sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	max=a[0];
	min=a[0];
	for(i=0;i<n;i++){
		if(max<a[i]) max=a[i];
		if(min>a[i]) min=a[i];
		sum=sum+a[i];
	}
	printf("%d %d %lld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2112
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }

    int A_B = min(N, K), drop, A, B, ans = 0, tmp;
    vector<int> minus;
    for (int i = 0; i <= A_B; i++) {
        drop = K - i;
        for (int j = 0; j <= i; j++) {
            tmp = 0;
            vector<int>().swap(minus);
            A = j, B = i - j;
            for (int a = 0; a < A; a++) {
                if (V[a] >= 0) {
                    tmp += V[a];
                } else {
                    minus.push_back(V[a]);
                }
            }
            for (int b = 0; b < B; b++) {
                if (V[N - 1 - b] >= 0) {
                    tmp += V[N - 1 - b];
                } else {
                    minus.push_back(V[N - 1 - b]);
                }
            }
            sort(minus.begin(), minus.end());
            for (int i = drop; i < minus.size(); i++) {
                tmp += minus[i];
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int n, m; cin >> n >> m;
    int reached[n + 1]; rep(i, n + 1) reached[i] = 0;
    vector<pii> v[n + 1];
    rep(i, m) {
        int l, r, d; cin >> l >> r >> d;
        v[l].push_back({r, d});
        v[r].push_back({l, -d});
    }
    int pos[n + 1]; rep(i, n + 1) pos[i] = -inf;
    rrep(i, 1, n + 1) {
        //cout << i << endl;
        if (reached[i]) continue;
        reached[i] = 1;
        queue<int> q;
        q.push(i);
        pos[i] = 0;
        while (!q.empty()) {
            int now = q.front();
            q.pop();
            rep(j, v[now].size()) {
                //rrep(k, 1, n + 1) cout << pos[k] << " "; cout << endl;
                if (pos[v[now][j].first] == -inf) {
                    pos[v[now][j].first] = pos[now] + v[now][j].second;
                } else {
                    /*
                    cout << pos[now] << " " << v[now][j].second << " "
                    << pos[v[now][j].first] << endl;
                     */
                    if (pos[now] + v[now][j].second != pos[v[now][j].first]) {
                        cout << "No" << endl;
                        return 0;
                    }
                }
                if (reached[v[now][j].first]) continue;
                reached[v[now][j].first] = 1;
                q.push(v[now][j].first);
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pp pair<int, int>
#define ppp pair<pp, int>
#define pp4 pair<pp, pp>
#define pp3 pair<ll, pair<int, int> > 
#define fi first
#define se second
#define N  2020
#define mod 1000000007
#define inf 2000000001
#define esp 1e-9
#define BLOCK 333
#define BITNUM 555
#define BASE 311097
typedef long long ll;
// const ll oo = (ll)1e18 + 1;
using namespace std;
int n;

int main() {
    ios::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    cin >> n;
    int tot = (n / 500) * 1000;
    n %= 500;
    tot += (n - n % 5);
    cout << tot;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+5, M = 1e4+5, OO = 0x3f3f3f3f;
typedef  long long LL;
typedef  long double LD;
#define PI 3.14159265358979323846
#define INF LONG_MAX
const int  MOD = 1e9+7;
int main()
{

    int n; cin>>n;
    LL s = 0;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=n; ++j)
            for (int k=1; k<=n; ++k) {
                int f = __gcd(i,j);
                s+=__gcd(f,k);
            }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
h w
a11 ... a1w
...
ah1 ... ahw

h w 100
 */
int h,w;

int main(){
  cin>>h>>w;
  REP(j,w+2){
    cout<<'#';
  }
  cout<<endl;

  REP(i,h){
    cout<<'#';
    string s;
    cin>>s;
    cout<<s;
    cout<<'#'<<endl;
  }

  REP(j,w+2){
    cout<<'#';
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
import collections
N = int(input())
V = [int(i) for i in input().split()]

C0 = collections.Counter(V[0::2])
C0[0] = 0

C1 = collections.Counter(V[1::2])
C1[0] = 0

if C0.most_common()[0][0] != C1.most_common()[0][0]:
    print(N-C0.most_common()[0][1]-C1.most_common()[0][1])
else:
    print(min(N-C0.most_common()[0][1]-C1.most_common()[1][1],
              N-C0.most_common()[1][1]-C1.most_common()[0][1]))


Measured memory_bytes: 18656
// https://atcoder.jp/contests/abc127/tasks/abc127_c

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

//------------------------------------------------------------------------------
const int IMOS_SIZE = 1e5;

int sz;
int dat[IMOS_SIZE + 1];

void imos_init(int n) {
  sz = n;
}

void imos_add(int l, int r, int x) {
  dat[l] += x;
  dat[r + 1] -= x;
}

void imos_acc() {
  REP(i, sz) dat[i + 1] += dat[i];
}

int imos_query(int i) {
  return dat[i];
}

//------------------------------------------------------------------------------
const int N_MAX = 1e5;
const int M_MAX = 1e5;

int N, M;
int L[M_MAX];
int R[M_MAX];

void solve() {
  imos_init(N);
  REP(i, M) {
    imos_add(L[i] - 1, R[i] - 1, 1);
  }
  imos_acc();
  // DUMP(dat, min(N + 1, 10));a
  int ans = 0;
  REP(i, N) {
    if (imos_query(i) == M) ans++;
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, M) scanf("%d%d", L + i, R + i);
}

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


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            String input = in.readLine();
            StringBuilder out = new StringBuilder();
            for (int i = 0; i < input.length(); i++) {
                if (Character.isUpperCase(input.charAt(i))) {
                    out.append(Character.toLowerCase(input.charAt(i)));
                } else if (Character.isLowerCase(input.charAt(i))) {
                    out.append(Character.toUpperCase(input.charAt(i)));
                } else {
                    out.append(input.charAt(i));
                }
            }

            System.out.println(out);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.exit(0);
    }
}



Measured memory_bytes: 24408
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	a := make([][]int, 10)
	for i := range a {
		a[i] = make([]int, 10)
	}

	for i := 1; i < n+1; i++ {
		nb := []byte(strconv.Itoa(i))
		s, _ := strconv.Atoi(string(nb[0]))
		e, _ := strconv.Atoi(string(nb[len(nb)-1]))
		a[s][e]++
	}

	ans := 0
	for i := range a {
		for j := range a {
			ans += a[i][j] * a[j][i]
		}
	}
	fmt.Println(ans)
}

func main1() {
	n := readInt()
	nstr := strconv.Itoa(n)
	nlen := len(nstr)
	nstart, nmid, nend := n, 1, n
	if nlen > 1 {
		nstart, _ = strconv.Atoi(nstr[0:1])
		nend, _ = strconv.Atoi(nstr[nlen-1:])
	}
	if nlen > 2 {
		nmid, _ = strconv.Atoi(nstr[1 : nlen-1])
	}

	ans := 0
	for i := 1; i <= n; i++ {
		if i%10 == 0 {
			continue
		}

		a := strconv.Itoa(i)
		s, _ := strconv.Atoi(a[len(a)-1:])
		e, _ := strconv.Atoi(a[0:1])

		if s == e {
			ans++
		}

		for j := 0; j <= nlen-2; j++ {
			if j < nlen-2 {
				ans += int(math.Pow(10, float64(j)))
				continue
			}
			if s > nstart {
				break
			} else if s < nstart {
				ans += int(math.Pow(10, float64(j)))
			} else {
				if e <= nend {
					ans += nmid
				} else {
					ans += max(0, nmid-1)
				}
			}
		}
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N,A,B,K=map(int,input().split())
P=998244353
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,P)[0]
Fact=[0 for i in range(N+1)]
Finv=[0 for i in range(N+1)]
Fact[0]=1
Finv[0]=1
for i in range(1,N+1):
    Fact[i]=(i*Fact[i-1])%P
    Finv[i]=(Finv[i-1]*inv(i))%P
ans=0
def NC(k):
    tmp=(Finv[k]*Finv[N-k])%P
    return (Fact[N]*tmp)%P
for x in range(N+1):
    y=(K-x*A)//B
    if x*A+y*B==K and 0<=y<=N:
        ans+=(NC(x)*NC(y))%P
print(ans%P)


Measured memory_bytes: 65420
#include <stdio.h>

int main(void){
    
	int S[3]={0};
	scanf("%d %d %d", &S[0], &S[1], &S[2]);
	for (int i=1; i<3; i++) {
		int j=i;
		do {
		if (S[j] > S[j-1]) {
			int temp =S[j];
			S[j] = S[j-1];
			S[j-1] = temp;
			j--;
	    }
		else break;
		}while (j>0);
	}
	int count =0;
	if (S[0]==S[1]==S[2]) count=0; 
	if (S[0]==S[1] && S[1]>S[2]) {
		do {
			S[2]+=2;
			count +=1;
		}while (S[1]>S[2]);
		if (S[2]-S[1]==1) count +=1;
		if (S[2]-S[1]==0) count +=0;
	
	}
	if (S[0]> S[1]&& S[1]==S[2]) {
	    do {
			S[2]+=1;
	    	S[1]+=1;
			count +=1;
		}while (S[2]!=S[0]);
	}
	if (S[0]> S[1]&& S[1]>S[2]) {
	    do {
			S[2]+=1;
	    	S[1]+=1;
			count +=1;
		}while (S[1]!=S[0]);
		do {
			S[2]+=2;
			count +=1;
		}while (S[1] > S[2]);
		if (S[2]-S[1]==0) count +=0;
		else count+=1; 
		
	}
	printf("%d", count);
    return(0);
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	vector<int> t(4,0);
  int N;
  cin >> N;
  froop1(0,N){
string s;
    cin >> s;
    if(s == "AC"){
      t.at(0)++;
    }else if(s == "WA"){
      t.at(1)++;
    }else if(s == "TLE"){
      t.at(2)++;
    }else if(s == "RE"){
      t.at(3)++;
    }
  }
  cout << "AC x " << t.at(0) << endl;
      cout << "WA x " << t.at(1) << endl;
    cout << "TLE x " << t.at(2) << endl;
    cout << "RE x " << t.at(3) << endl;

return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)(1e9+7)

main(){
	int n,k;
	cin>>n>>k;
	int arr[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	//special move atmost k times
	sort(arr+1,arr+n+1,greater<int>());
	if(n<=k)
		cout<<0<<endl;
	else{
		int ans=0;
		for(int i=k+1;i<=n;i++)
			ans+=arr[i];
		cout<<ans<<endl;
	}
}	


Measured memory_bytes: 1792
// C - Tsundoku
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
ll in(){ll x;cin>>x;return x;}

int main(){
	int n, m; ll k; cin>>n>>m>>k;
	vector<ll> A(1, 0), B(1, 0);
	rep(i, n) A.push_back(A.back() + in());
	rep(i, m) B.push_back(B.back() + in());
	int ans = 0, j = m;
	rep(i, n+1){
		if(A[i] > k) break;
		while(A[i] + B[j] > k) j--;
		ans = max(ans, i+j);
	}
	cout<< ans <<endl;
}


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

int main()
{
  int i = 0;
  char s1[128];
  char s2[128];
  char s3[128];

  scanf("%s %s %s", s1, s2, s3);

  if ((strlen(s2) < 1) || (strlen(s2) > 100))
  {
    //perror("a");
    return 0;
  }
  if ((s2[0] < 'A') || (s2[0] > 'Z'))
  {
    //perror("b");
    return 0;
  }

  for (i = 1; i < strlen(s2); i++)
  {
    if (s2[i] < 'a' || s2[i] > 'z')
    {
      //perror("c");
      return 0;
    }
  }

  printf("%c%c%c\n", s1[0], s2[0], s3[0]);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

const int MAX_N = 200005;

int n;
int a[MAX_N];
int b[MAX_N];
map<int, int> shit;
int result[MAX_N];

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

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

	for (int i = 0; i < n; i++)
	{
		auto itL = lower_bound(b, b + n, a[i]);
		if (itL != b + n)
		{
			auto itR = upper_bound(b, b + n, a[i]);
			int l = int(itL - b), r = int(itR - b) - 1;

			int fL = i - r, fR = i - l;
			for (int lol = -n; lol <= n; lol += n)
			{
				shit[fL + lol]++;
				shit[fR + lol + 1]--;
			}
		}
	}

	int shitCnt = 0;
	for (const auto& pr : shit)
	{
		shitCnt += pr.second;
		int shift = pr.first;
		if (shift < 0 || shift >= n)
			continue;

		if (shitCnt == 0)
		{
			for (int i = 0; i < n; i++)
				result[(i + shift + n) % n] = b[i];

			cout << "Yes\n";
			for (int i = 0; i < n; i++)
				cout << result[i] << ' ';
			cout << '\n';
			return 0;
		}
	}
	cout << "No\n";

	return 0;
}

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

using namespace std;
int a[55];
int main()
{ int n,i,k,t;
 cin>>n>>t;
 for(i=0;i<n;i++)
    cin>>a[i];
 sort(a,a+n,greater<int>());
 k=0;
 for(i=0;i<t;i++)
    k+=a[i];
 printf("%d",k);

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

int main(){
    int n,m;
    while(cin >> n >> m && n){
        vi b(n), p(m);
        rep(i,n) cin >> b[i];
        rep(i,m) cin >> p[i];
        queue<pair<int,vi>> q;
        q.emplace(0,b);
        set<vi> dp;
        while(q.size()){
            int step; vi b;
            tie(step,b) = q.front();
            q.pop();
            vi seq = {1};
            rep(i,b.size()-1){
                if(b[i]==b[i+1])seq.back()++;
                else seq.pb(1);
            }
            if(seq==p){
                cout << step << endl;
                break;
            }
            rep(i,b.size()-1){
                swap(b[i],b[i+1]);
                if(!dp.count(b)){
                    dp.insert(b);
                    q.emplace(step+1,b);
                }
                swap(b[i],b[i+1]);
            }
        }
    }
}

Measured memory_bytes: 2152
S = input() + "R"
#print(S)
N = len(S)-1

ans = [0]*N

num = 0
for i in range(N):
    num += 1
    if S[i+1]=="L" and S[i]=="R":
        ans[i+1] += num//2
        ans[i] += num - num//2
        num = 0
    elif S[i+1]=="R" and S[i]=="L":
        ans[i-num+1] += num - num//2
        ans[i-num] += num//2
        num = 0

print(" ".join(map(str,ans)))


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

using namespace std;

int n,a[15],i,j;

int main(){
	scanf("%d", &n);
	
	int res = pow(3, n);
	int cur = 1;
	
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
		
		if(a[i] % 2 == 0)
		cur *= 2;
	}
	
	printf("%d\n", res - cur);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;

    if(N % 2 == 1){
        cout << "No" << endl;
        return 0;
    }

    bool same = true;
    N /= 2;
    for(int i = 0; i < N; i++){
        if(s[i] != s[N + i]) same = false;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,n,ans;
int main()
{
	cin>>a>>b>>c>>n; 
	for(int s=0;s<=a;s++)
	{
		for(int v=0;v<=b;v++)
		{
			for(int p=0;p<=c;p++)
			{
				if(s*500+v*100+p*50==n)ans++;
				if(s*500+v*100+p*50>n)break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(x) begin(x), end(x)
 
bool ok(int first, long long len, const vector<long long> &a) {
	const int second = lower_bound(a.begin() + first, a.end(), a[first] + len) - a.begin();
	const int third  = lower_bound(a.begin() + second, a.end(), a[second] + len) - a.begin();
	return third < a.size() && len <= a[first] + a.back() - a[third];
}
 
bool check(long long len, const vector<long long> &a) {
	rep(i, a.size()) {
		if(ok(i, len, a)) return true;
	}
	return false;
}
 
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	constexpr long long MAX_A = 1000000000;
 
	int n;
	cin >> n;
 
	vector<long long> a(n + 1, 0);
	REP(i, 1, n + 1) {
		cin >> a[i];
	}
 
	partial_sum(ALL(a), a.begin());
 
	long long L = 0, R = n * MAX_A;
	while(L + 1 < R) {
		const long long M = (L + R) / 2;
		if(check(M, a)) {
			L = M;
		}
		else {
			R = M;
		}
	}

	cout << L << endl;
 
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1788
import bisect
def main():
	while True:
		D=int(input())
		if D==0:
			break
		n=int(input())
		m=int(input())
		d=list()
		d.append(0)
		for i in range(n-1):
			d.append(int(input()))
		d.append(D)
		d.sort()
		ans=0
		for i in range(m):
			k=int(input())
			idx=bisect.bisect_left(d,k)
			ans+=min(abs(d[idx]-k),abs(d[idx-1]-k))
		print(ans)

if __name__=="__main__":
	main()



Measured memory_bytes: 9956
#include<stdio.h>
#define max(a,b)(a>b?a:b)
int max3(int a,int b,int c)
{  
return (a>b)?((a>c)?a:c):((b>c)?b:c);
}
int main()
{
 int n;
scanf("%d",&n);
int val[n+1][3];
for(int i=0;i<n;i++)
for(int j=0;j<3;j++)
scanf("%d",&val[i][j]);
int dp[n][3];
for(int j=0;j<3;j++)
dp[n-1][j]=val[n-1][j];
for(int i=n-2;i>=0;i--)
{
dp[i][0]=max(dp[i+1][1],dp[i+1][2])+val[i][0];
dp[i][1]=max(dp[i+1][0],dp[i+1][2])+val[i][1];
dp[i][2]=max(dp[i+1][0],dp[i+1][1])+val[i][2];
}
int ans=max3(dp[0][0],dp[0][1],dp[0][2]);
printf("%d",ans);
return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE t(n), a(n);
	rep(i, n)cin >> t[i] >> a[i];
	int nowt = 1; int nowa = 1;
	rep(i, n) {
		int tmp = max((nowt + t[i] - 1) / t[i], (nowa + a[i] - 1) / a[i]);
		nowt = tmp * t[i]; nowa = tmp * a[i];
	}
	cout << nowt + nowa << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



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


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

int main() {
	string a;
	cin >> a;
	int count[26] = {0};
	long long ans = 1;
	for(int i=0;i<a.size();i++) {
		int c = a[i] - 'a';
		ans += i - count[c];
		count[c]++;
	}
	cout << ans << endl;
	return 0;
}


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

const string YES = "YES";
void yes() {
  cout << YES << endl;
  exit(0);
}

const string NO = "NO";
void no() {
  cout << NO << endl;
  exit(0);
}

vector<ll> N;

void solve() {
  sort(N.begin(), N.end());

  if( N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9 ) yes();
  no();
}

void input() {
  N = vector<ll>(4);
  for (int i = 0; i < 4; i++) {
    scanf("%lld", &N[i]);
  }
}

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


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

using namespace std;

int main(){
    int a, b, t;

    cin >> a >> b >> t;
    int i, n=0;
    for(i=a;i<t+0.5;i=i+a){
        n += b;
    }   

    cout << n <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int r[210000]={};
  int n=0,max=-999999999,min;
  int i=0,j=0;

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

  min=r[0];
  for(i=1;i<n;i++){
    if(max<r[i]-min) max=r[i]-min;
    if(min>r[i]) min=r[i];
  }
    
  printf("%d\n",max);
  
  return 0;
}



Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
using namespace std;

typedef struct edge{
  int to, cap, rev;
}edge;

//from??????to??????????????????cap???????????°?????????????????????
void add_edge(vector<vector<edge> > &g, int from,int to,int cap){
  g[from].push_back((edge){to, cap, (int)g[to].size()});
  g[to].push_back((edge){from, 0, (int)g[from].size() - 1});
}

class Dinic{
public:
  Dinic(){};
  Dinic(vector<vector<edge> >& _g) {
    g = _g;
    flow_val = -1;
    level.resize(g.size(), -1);
    iter.resize(g.size(), 0);
  };
  int MaxFlow(int s, int t);
  int flow_val;
private:
  void bfs(int s);
  int  dfs(int v, int t, int f);
  vector<vector<edge> > g;
  vector<int>level, iter;
};

int Dinic::MaxFlow(int s, int t){
  if(flow_val >= 0)return flow_val;
  int flow = 0;
  for (;;) {
    bfs(s);
    if(level[t] < 0)return flow_val = flow;
    
    for (int i = 0; i < g.size(); i++) iter[i] = 0;
    int f;
    
    while((f = dfs(s, t, 1e9)) > 0){
      flow += f;
    }
  }
}


//????±???°??????????????????
void Dinic::bfs(int s) { 
  for (int i = 0; i < g.size(); i++) level[i] = -1;
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(not que.empty()){
    int v = que.front();
    que.pop();
    for (int i = 0; i < g[v].size(); i++) {
      edge &e = g[v][i];
      if(e.cap > 0 and level[e.to] < 0){
        level[e.to] = level[v] + 1;
        que.push(e.to);
      }
    }
  }
}

//?¢?????????????dfs??§??¢???
int Dinic::dfs(int v, int t, int f){
  if(v == t)return f;
  for (int &i = iter[v]; i < g[v].size(); i++) {
    edge &e = g[v][i];
    if(e.cap > 0 and level[v] < level[e.to]){
      int d = dfs(e.to, t, min(f, e.cap));
      if(d > 0){
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}


int main(){
  int n, m;
  std::cin >> n >> m;
  vector<vector<edge> > g(n);
  for (int i = 0; i < m; i++) {
    int to, from, cost;
    std::cin >> from >> to >> cost;
    add_edge(g, from, to, cost);
  }
  Dinic dc(g);
  std::cout << dc.MaxFlow(0, n - 1)<< std::endl;
  return 0;
}

Measured memory_bytes: 3196
N = int(input())
S = input()
S0 = list(S)
max_S3 = 0

for i in range(N):
  dic1 = {}
  dic2 = {}
  S1 = S0[:i+1]
  S1 = set(S1)
  S2 = S0[i+1:]
  S2 = set(S2)
  S3 = list(S1 & S2)
  if(max_S3 < len(S3)):
   max_S3 = len(S3)
  
print(max_S3)
  
  

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

int MSB64bit(ll a){
    bitset<64> v(a);
    v |= (v>>1);
    v |= (v>>2);
    v |= (v>>4);
    v |= (v>>8);
    v |= (v>>16);
    v |= (v>>32);
    return v.count()-1;
}

ll hakidasi(ll a, vector<ll> dp){
    
    int asize = MSB64bit(a);
    
    if(dp.size()==1){
        return a;
    }
    
    rep(i,dp.size()-1){
        int isize = MSB64bit(dp[i]);
        
        if(asize>isize)return a;
        if(asize<isize)continue;
        
        if(asize==isize){
            a ^= dp[i];
            if(a==0)return 0;
            asize = MSB64bit(a);
        }
    }
    return a;
}

int main(){
    int t; cin >> t;
    vi rtn(t);
    rep(tt,t){
        int n; cin >> n;
        vector<ll> a(n);
        rep(i,n)cin >> a[i];
        string s; cin >> s;
        
        vector<vector<ll>> dp(n+1);
        dp[n].push_back(0LL);
        
        for(int i=n-1; i>=0; i--){
            
            if(s[i]=='1'){
                if(hakidasi(a[i], dp[i+1])!=0){
                    
                    rtn[tt] = 1;
                    break;
                    
                }else{
                    
                    dp[i] = dp[i+1];
                    
                }
            }else{
                dp[i] = dp[i+1];
                
                ll next = hakidasi(a[i], dp[i+1]);
                
                if(next!=0){
                    dp[i].push_back(next);
                    sort(dp[i].rbegin(), dp[i].rend());
                }
            }
            
        }
        
        if(dp[0].size() && dp[0][0]==0){
            rtn[tt] = 0;
        }
        
    }
    rep(tt,t){
        cout << rtn[tt] << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
long long int n, a[105], i, temp, ans1, ans2;
int main()
{
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    temp=a[0];
    for(i=1;i<n;i++){
        temp=temp+a[i];
    }
    temp=temp/n;
    ans1=0;
    ans2=0;
    for(i=0;i<n;i++){
        ans1=ans1+((a[i]-temp)*(a[i]-temp));
        ans2=ans2+((a[i]-temp-1)*(a[i]-temp-1));
    }
    if(ans1<ans2){
        cout<<ans1<<endl;
    }
    else {
        cout<<ans2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256