akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<int> b(a),c(1000010,0);
  rep(i,a)
    cin>>b[i];
  rep(i,a){
  c[b[i]]+=1;
  }
  if(c[1]==0){
  int d=0;
  rep(i,a){
  int e=1;
  rep(j,sqrt(b[i])+0.1){
    if(j==0){
    if(c[b[i]]>1){
    e=0;
      break;
    }
      
    }
    else{
      if(b[i]!=2&&b[i]!=3){
  if(b[i]%(j+1)==0){
  if((c[j+1])||(c[b[i]/(j+1)])){
  e=0;
    break;
    }
  }
        }
      }
  }
    d+=e;
  }
  out(d);
    }
  else if(c[1]==1)
    out(1);
  else
    out(0);
}


Measured memory_bytes: 12720
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int x,y;
    cin>>x>>y;
    if(x>=2*y)
        cout<<x-2*y<<endl;
    else
        cout<<"0\n";
    return 0;
}



Measured memory_bytes: 3588
a,b=map(int,input().split())
s=[["#" for i in range(100)] for j in range(50)]
t=[["." for i in range(100)] for j in range(50)]

a2,a3=(a-1)//50,(a-1)%50
for i in range(0,2*a2,2):
    for j in range(0,100,2):
        s[i][j]="."
for i in range(0,2*a3,2):
    s[2*a2][i]="."

b2,b3=(b-1)//50,(b-1)%50
for i in range(2,2*b2+2,2):
    for j in range(0,100,2):
        t[i][j]="#"
for i in range(0,2*b3,2):
        t[2*b2+2][i]="#"
print(100,100)
for i in range(50):
    print("".join(s[i]))
for i in range(50):
    print("".join(t[i]))

Measured memory_bytes: 3188
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
struct HeapNode{
	int u;
	int d;
	bool operator < (const HeapNode& rhs)const{
		return d>rhs.d;
	}
};
int d[200005],vis[200005];
int main(){
	int k;
	cin>>k;
	priority_queue<HeapNode>Q;
	Q.push((HeapNode){1,0});
	memset(d,0x3f3f3f3f,sizeof(d));
	d[1]=0;
	
	while (!Q.empty()){
		HeapNode x=Q.top();	Q.pop();
		int u=x.u,v;
		if (vis[u]) continue;
		vis[u]=1;
		for (int v=(u+1)%k,cost=1;cost>=0;v=(u*10)%k,cost--)
			if (d[v]>d[u]+cost){
				d[v]=d[u]+cost;
				Q.push((HeapNode){v,d[v]});
			}
	}
	cout<<d[0]+1<<endl;
}

Measured memory_bytes: 2044
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

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

  int dpt[n];
  int indegree[n];
  for (int i = 0; i < n; i++) { dpt[i] = indegree[i] = 0; }

  vector<vector<int>> s2t(n);
  for (int i = 0; i < m; i++) {
    int s, t;
    cin >> s >> t;
    s2t[s - 1].push_back(t - 1);
    indegree[t - 1]++;
  }

  stack<int> st;
  for (int i = 0; i < n; i++) {
    if (indegree[i] == 0) {
      dpt[i] = 0;
      st.push(i);
    }
  }

  while (!st.empty()) {
    int s = st.top();
    st.pop();
    for (int i = 0; i < s2t[s].size(); i++) {
      int t = s2t[s][i];
      dpt[t] = max(dpt[t], dpt[s] + 1);
      indegree[t]--;
      if (indegree[t] == 0) { st.push(t); }
    }
  }

  int res = 0;
  for (int i = 0; i < n; i++) { res = max(res, dpt[i]); }

  cout << res << endl;
}



Measured memory_bytes: 6528
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int sum = 0;
		for(int i = 0; i < 10; i++) {
			sum += stdIn.nextInt();
		}
		System.out.println(sum);
	}

}

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

using namespace std;

string s[6] = {
	"dreameraser",
	"dreamerase",
	"dreamer",
	"eraser",
	"dream",
	"erase",
};

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

	string inp; cin >> inp;
	
	bool can = true;
	bool tmp = false;
	
	for(int i = 0; i < inp.size() && can; i++) {
		tmp = false;
		for(int j = 0; j < 6 && !tmp; j++) {
			bool com = false;
			if(inp.size()-i >= s[j].size()) {
				com = true;
				for(int k = 0; k < s[j].size(); k++) {
					if(inp[i+k] != s[j][k]) {
						com = false;
						break;
					}
				}
			}
			if(com) {
				tmp = true;
				i += s[j].size() - 1;
				tmp = true;
			}
		}
		if(!tmp)can = false;
	}

	if(can)cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

Measured memory_bytes: 512
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var line = Console.ReadLine().Split(' ');

            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            var c = int.Parse(line[2]);

            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



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

int main() {
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  if(abs(a-b)<=x&&abs(b-c)<=x)cout<<"Yes"<<endl;
  else if(abs(a-c)<=x)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
n   = gets.to_i
ary = gets.split.map &:to_i

min = 100000

n.times do |i|
  count = 0
  while ary[i] % 2 == 0 && count < min
    ary[i] /= 2
    count += 1
  end
  min = [min, count].min
end

puts min


Measured memory_bytes: 1788
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

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


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int min_diff(int i, multiset<int>st, multiset<int> ans){
    if(i==13){
        ans.insert(24);
        int pre=0,minimum=24;
        for(auto a: ans){
            minimum=min(minimum, a-pre);
            pre=a;
        }
        return minimum;
    }

    if(st.count(i)==1){
        auto s1=ans, s2=ans;
        s1.insert(i), s2.insert(24-i);
        return max(min_diff(i+1,st,s1), min_diff(i+1,st,s2));
    }else if(st.count(i)==2){
        ans.insert(i), ans.insert(24-i);
        return min_diff(i+1, st,ans);
    }else if(st.count(i)==0){
        return min_diff(i+1,st, ans);
    }else{
        return 0;
    }
}
int main() {
    int N; cin >> N;
    vector<int> D(N);
    multiset<int> ms, ans;
    rep(i,N){
        cin >> D[i];
        ms.insert(D[i]);
    }

    cout << min_diff(0, ms, ans) << endl;
    return 0;
}

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

using namespace std;

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

typedef long long ll;

int n, uf_par[112345], uf_rnk[112345], m, a[112345];

void uf_init(int size)
{
    REP(i, size)
    {
        uf_par[i] = i;
        uf_rnk[i] = 0;
    }
}

int uf_find(int x)
{
    if (uf_par[x] == x)
        return x;
    else
        return uf_par[x] = uf_find(uf_par[x]);
}

void uf_unite(int x, int y)
{
    x = uf_find(x);
    y = uf_find(y);
    if (x == y)
        return;

    if (uf_rnk[x] < uf_rnk[y])
    {
        uf_par[x] = y;
    }
    else
    {
        uf_par[y] = x;
        if (uf_rnk[x] == uf_rnk[y])
            uf_rnk[x]++;
    }
}

bool uf_same(int x, int y)
{
    return uf_find(x) == uf_find(y);
}

int main()
{
    uf_init(100010);

    cin >> n >> m;
    REP(i, n)
    cin >> a[i];

    REP(i, m)
    {
        int x, y;

        cin >> x >> y;

        uf_unite(x, y);
    }

    priority_queue<int, vector<int>, greater<int>> q[112345];
    vector<int> p;
    bool used[112345] = {false};

    REP(i, n)
    {
        int par = uf_find(i);

        q[par].push(a[i]);

        if (!used[par])
        {
            p.push_back(par);
            used[par] = true;
        }
    }

    if (p.size() == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    ll res = 0;

    vector<int> v;

    for (int i : p)
    {
        res += q[i].top();
        q[i].pop();

        while (q[i].size())
        {
            v.push_back(q[i].top());
            q[i].pop();
        }
    }

    if (v.size() < (p.size() - 1) * 2 - p.size())
    {
        cout << "Impossible" << endl;
        return 0;
    }

    SORT(v);

    for (int i = 0; i < (p.size() - 1) * 2 - p.size(); i++)
    {
        res += v[i];
    }

    cout << res << endl;

    return 0;
}

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

const int MAX = 510000;
const int mod = 1000000007;

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

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

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,k;
    COMinit();
    cin>>n>>k;
    if(k >= n-1){
        ll ans = COM(n+n-1,n);
        cout << ans << endl;
        return 0;
    }
    ll ans = 0;
    for(int i=n-k;i<=n;i++){
        ll ret = COM(n,i);
        ll s = COM(n-i+i-1,n-i);
        s %= mod;
        ret *= s;
        ret %= mod;
        ans += ret;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <limits>
#include <type_traits>

using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    cout << max(0, C-(A-B)) << endl;
 }


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

typedef long long ll;
int n, a[200005];
map<int, int> m;

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

    ll sum = 0;
    for (auto i : m)
        sum += (1ll * i.second * (i.second - 1)) / 2;

    for (int i = 0; i < n; ++i)
    {
        cout << sum - m[a[i]] + 1 << endl;
    }
}

Measured memory_bytes: 8320
using System;

namespace _1_2b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] hoge = Console.ReadLine().Split(' ');
            int a = int.Parse(hoge[0]);
            int b = int.Parse(hoge[1]);
            int c = int.Parse(hoge[2]);

            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m;
ll x[100005], y[100005];
ll MOD = 1000000007;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	FOR(i, n) cin >> x[i];
	FOR(i, m) cin >> y[i];
	ll res1 = 0, res2 = 0;
	FOR(i, n-1) {
		ll l = i+1, r = n-i-1, s = x[i+1]-x[i];
		ll x = l * r % MOD * s % MOD;
		res1 += x;
	}
	FOR(i, m-1) {
		ll l = i+1, r = m-i-1, s = y[i+1]-y[i];
		ll x = l * r % MOD * s % MOD;
		res2 += x;
	}
	res1 %= MOD;
	res2 %= MOD;
	cout << res1 * res2 % MOD << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100010;
int fa[N], A[N], B[N], C[N];
int find(int x) {return x == fa[x] ? x : fa[x] = find(fa[x]);}
inline void merge(int x, int y) {fa[find(x)] = find(y);}
int main() {
    int n, q, flg = 0, ct = 0; LL m, L, R = 0; cin >> n >> m >> q;
    for (int i = 1; i <= n; i++) fa[i] = i;
    for (int i = 1; i <= q; i++) {
        cin >> A[i] >> B[i] >> C[i], A[i]++, B[i]++;
        if (!C[i]) merge(A[i], B[i]);
        else flg = 1;
    }
    for (int i = 1; i <= q; i++) if (C[i] && find(A[i]) == find(B[i])) {
        puts("No"); return 0;
    }
    for (int i = 1; i <= n; i++) if (fa[i] == i) ct++;
    L = n - (!flg), R = n - ct + (LL)ct * (ct - 1) / 2;
    if (m < L || m > R) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include <fstream>
#include <vector>

#define LOCAL  1
#define UPLOAD 2

using namespace std;

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int a, b, c;
    cin >> a >> b >> c;
    
    if((a > c && c > b) || (a < c && c < b)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}


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

int main() {
  int N, X, ans;
  cin >> N >> X;
  vector<int>m(N);
  for (int i = 0; i < N; i++) {
    cin >> m.at(i);
  }
  for (int i = 0; i < N; i++) {
    X -= m.at(i);
  }
  ans = N;
  sort(m.begin(), m.end());
  ans += X / m.at(0);
  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using ll = long long;
using namespace std;


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

    ll* a = new ll[5];

    for(int j =0; j<5;++j) {
        cin >> a[j];
    }

    int bottle_neck_ix = -1; 
    ll bottle_neck_val = 0;
    ll check_max;
    for(int z = 0; z < 5; ++z){
        check_max = ceil((double)n/a[z]);
        if(check_max > bottle_neck_val){
            bottle_neck_ix = z;
            bottle_neck_val = check_max;
        }
    }

    // cout << "ix:" << bottle_neck_ix<< endl;
    // cout << bottle_neck_val << endl;
    cout << bottle_neck_val + 4 << endl;

    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	int n, a, b;

	cin >> n;

	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		cin >> a >> b;
		cout << a + b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(_) for _ in input().split(" ")]

    counter = 0
    loop_flag = True

    while loop_flag:
        num_counter = 0
        for i in range(N):
            if A[i]%2 == 0:
                A[i] = A[i]/2
                num_counter += 1
            else:
                loop_flag = False

        if num_counter == N:
            counter += 1

    print(counter)

main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
	int W, H, N;
	cin >> W >> H >> N;

	int left = 0, right = W, top = 0, bottom = H;
	for (int i = 0; i < N; i++){
		int x, y, a;
		cin >> x >> y >> a;

		switch(a){
		case 1:
			left = max(left, x);
			break;
		case 2:
			right = min(right, x);
			break;
		case 3:
			top = max(top, y);
			break;
		case 4:
			bottom = min(bottom, y);
			break;
		}
	}
	
	cout << max(bottom - top, 0) * max(right - left, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[101][101];
class point {
public: int x, y;
};
point p[101];
int n;
int solve(int left, int right) {
	if (left == right) return dp[left][right] = 0;
	if (dp[left][right]) return dp[left][right];
	else
	{
		int min = 1<<29;
		for (int i = left; i < right; i++) {
			int k = dp[left][i] + dp[i + 1][right] + p[left].x * p[i + 1].x * p[right].y;
			if (k < min) min = k;
		}
		 dp[left][right] = min;
		 return min;
	}
}
int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i].x>>p[i].y;
	}
	for(int l=1;l<n; l++)
	for (int i = 0; i < n; i++) {
		if (i + l < n)
		{
			solve(i, i + l);
		}
	}
	cout << dp[0][n - 1]<<endl;
}


Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemQ
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var xs = new int[N];
            var ls = new int[N];

            for (int i = 0; i < N; i++)
            {
                var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                xs[i] = read[0];
                ls[i] = read[1];
            }

            // sorted by end point
            var sortedIndex = xs.Select((x, i) => new { ind = i, end = x + ls[i] }).OrderBy(x => x.end).Select(x => x.ind);
            var sortedStartPoint = sortedIndex.Select(i => xs[i] - ls[i]).ToArray();
            var sortedEndPoint = sortedIndex.Select(i => xs[i] + ls[i]).ToArray();
            var curEnd = -1000000001;
            var res = 0;
            for (int i = 0; i < N; i++)
            {
                if(curEnd <= sortedStartPoint[i])
                {
                    curEnd = sortedEndPoint[i];
                    res++;
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 53628
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn string() -> String {
    read()
}

fn int() -> i64 {
    read()
}

fn char() -> char {
    read::<String>().pop().unwrap()
}

fn vecchar() -> Vec<char> {
    string().chars().collect()
}

fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let (n, k, x, y) = (int(), int(), int(), int());
    if n <= k {
        println!("{}", n * x);
        return;
    }

    println!("{}", k * x + (n - k) * y)
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

lli gcd(lli a , lli b) {
    if(b == 0) return a;
    a %= b;
    return gcd(b,a);
}

void solve() {
    lli a, b, c, d;
    cin >> a >> b >> c >> d;

    lli lcm = lcm(c, d);
    lli tot = b - a + 1;
    lli ans = (tot - (b/c - (a-1)/c)) +
            (tot - (b/d - (a-1)/d)) -
            (tot - (b/lcm - (a-1)/lcm));
    cout << ans << endl;

}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a==b){
        if(c==d){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    
    else if(a==c){
        if(b==d){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    
    else if(a==d){
        if(b==c){
            cout<<"yes"<<endl;
        }else{
        cout<<"no"<<endl;
        }
    }
    else{
        cout<<"no"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, t, k;
bool base[10010];
vector<pair<int, int> > g[10010];
vector<ll> cands;

ll calc(int from, int parent) {
  vector<ll> nret;
  FORIT(it, g[from]) {
    if (it->first == parent) { continue; }
    ll v = min((ll)it->second, calc(it->first, from));
    nret.push_back(v);
  }
  sort(nret.begin(), nret.end());
  ll ret = 0;
  if (base[from]) {
    ret = 1LL << 60;
    REP(i, nret.size()) { cands.push_back(nret[i]); }
  } else {
    if (nret.size() == 0) {
      ret = 0;
      k++;
    } else {
      ret = nret.back();
      REP(i, nret.size() - 1) { cands.push_back(nret[i]); }
    }
  }
  return ret;
}

int main() {
  int test_case = 0;
  while (scanf("%d %d %d", &n, &t, &k), n|t|k) {
    test_case++;
    MEMSET(base, false);
    cands.clear();
    REP(i, n) { g[i].clear(); }
    REP(i, n - 1) {
      int f, t, c;
      scanf("%d %d %d", &f, &t, &c);
      f--; t--;
      g[f].push_back(make_pair(t, c));
      g[t].push_back(make_pair(f, c));
    }
    REP(i, t) {
      int v;
      scanf("%d", &v);
      base[v - 1] = true;
    }
    calc(0, 0);
    sort(cands.begin(), cands.end());
    ll ans = 0;
    REP(i, k) { ans += cands[i]; }
    printf("Case %d: %lld\n", test_case, ans);
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool f[5001][5001];
int main(){
    int n;
    while(cin>>n,n){
        fill(f[0],f[0]+5001*5001,false);
        int x[3000],y[3000];
        for(int i=0;i<n;i++){
            cin>>x[i]>>y[i];
            f[x[i]][y[i]]=true;
        }
        int Max=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                int xa=x[i],ya=y[i],xb=x[j],yb=y[j];
                if(xa==1&&ya==1)cout<<xa<<" "<<ya<<" "<<xb<<" "<<yb<<" "<<endl;
                if(xa>=xb||ya<yb)continue;
                int xc=xa+(ya-yb),yc=ya+(xb-xa);
                int xd=xb+(ya-yb),yd=yb+(xb-xa);
                if(xc<0||xc>5000||yc<0||yc>5000||!f[xc][yc])continue;
                if(xd<0||xd>5000||yd<0||yd>5000||!f[xd][yd])continue;
                Max=max(Max,(xb-xa)*(xb-xa)+(yb-ya)*(yb-ya));
            }
        }
        cout<<Max<<endl;
    }
}

Measured memory_bytes: 25604
#include <bits/stdc++.h>
#define ll long long 
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define setbit(x,k) (x |= (1 << k))
#define clearbit(x,k) (x &= ~(1ll << k))
#define checkbit(x,k) (x & (1ll << k))
#define mp make_pair
#define scl(x) scanf("%lld",&x)
#define sci(x) scanf("%d",&x)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define pii pair<int,int> 
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
#define nn printf("\n") 
#define mod 10000007
using namespace std;

string s,t,res=""; int ls, lt;
int ans[3003][3003];
int dp[3003][3003];

int solve(int p1, int p2)
{
    if(p1 >= ls || p2 >= lt) return 0; 
    if(dp[p1][p2]!=-1) return dp[p1][p2];
    int mx = 0, res = 0;
    if(s[p1] == t[p2]) {
        res = 1 + solve(p1+1, p2+1);
        if(res > mx){
            mx = res;
            ans[p1][p2] = 0;
        }
    }
    else 
    {
        res = solve(p1+1, p2);
        if(res > mx){
            mx = res;
            ans[p1][p2] = 1;
        }
        res = solve(p1, p2+1);
        if(res > mx){
            mx = res;
            ans[p1][p2] = 2;
        }
    } 
    return dp[p1][p2] = mx;
}

void print_ans(int p1, int p2){
    if(p1 >= ls || p2 >= lt) return;

    if(s[p1]==t[p2]) res += s[p1];
    if(ans[p1][p2]==0) print_ans(p1+1, p2+1);
    if(ans[p1][p2]==1) print_ans(p1+1, p2);
    if(ans[p1][p2]==2) print_ans(p1, p2+1);
}

int main()
{
    memset(dp, -1, sizeof(dp));
    cin>>s>>t;
    ls = s.size();
    lt = t.size();
    solve(0, 0);
    print_ans(0, 0);
    cout << res << "\n";

}

Measured memory_bytes: 74112
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::cmp::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();
    let r: Vec<i64> = sc.vec(n);
    let mut min = 10_000_000_000;
    let mut ans = -10_000_000_000;
    for &x in r.iter() {
        if ans < x - min {
            ans = x - min;
        }
        if min > x {
            min = x;
        }
    }
    println!("{}", ans);
}



Measured memory_bytes: 11136
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    std::map<int, int> cnt;
    for (int n = input<int>(); n != 0; --n) {
        int v = input<int>();
        cnt[v - 1] += 1;
        cnt[v]     += 1;
        cnt[v + 1] += 1;
    }

    int ans = 0;
    for (auto e: cnt)
        ans = max(ans, e.second);

    cout << ans << "\n";
        
    
    return 0;
}


Measured memory_bytes: 4736
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int MAxn = 2e5 + 5;
const int MA_N = 5e3 + 5;

int main(){
	string n;
	cin >> n;
	int l = 0, r = n.size()-1;
	int flag = 0;
	while (l < r){
		if(n[l] != n[r]) flag = 1;
		l++;
		r--;
	}
	if(flag) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

void Sieve(int n)
{
	bool prime[n+1];
	int c=0;
	memset(prime, true, sizeof(prime));

	for (int p=2; p<=n; p++)
	{
		if (prime[p] == true)
		{
			for (int i=p*2; i<=n; i += p)
				prime[i] = false;
		}
	}
	for (int p=2; p<=n; p++)
	if (prime[p])
		c++;
		cout<<c<<endl;
}

int main()
{
	int n;
	while(cin>>n){
        Sieve(n);
	}

	return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int a,b,c,d,e,k;
int dist;
int main(){
    cin >>  a >> b >> c >> d>> e>>k;
    
    // dist = max( a, max(b, max(c, max(d, e))));

    if(e - a <= k){
        cout << "Yay!" << endl;

    }else{
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


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

    char s[100000];
    Int a[100000];
    cin >> s;
    Int len = strlen(s);
    int rl = 0;
    int l=0, r=1;
    char now = 'R';
    for(Int i=0; i<len; i++){
        a[i] = 0;
    }
    for(Int i=1; i<len; i++){
        if(now != s[i]){
            if(now == 'R'){
                rl = i;
                l = 1;
                now = 'L';
            }else{
                a[rl-1] = l/2;
                a[rl-1] += r%2==0 ? r/2 : r/2+1;
                a[rl] = r/2;
                a[rl] += l%2==0 ? l/2 : l/2+1;
                r = 1;
                l = 0;
                now = 'R';
            }
        }else{
            if(now == 'R'){
                r++;
            }else{
                l++;
            }
        }
    }
    a[rl-1] = l/2;
    a[rl-1] += r%2==0 ? r/2 : r/2+1;
    a[rl] = r/2;
    a[rl] += l%2==0 ? l/2 : l/2+1;
    for(Int i=0; i<len; i++){
        cout << a[i] << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	int X, t;
	cin >> X >> t;
	int sand;
	if (X < t) sand = 0;
	else sand = X - t;
	cout << sand << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

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

  long a_max = a[0];
  long a_min = a[0];
  for(int i = 1; i < n; i++){
    if(a[i] > a_max) a_max = a[i];
    if(a[i] < a_min) a_min = a[i];
  }

  long d = a_max - a_min;
  cout << d << endl;

  return 0;
}


Measured memory_bytes: 764
h,w=map(int,input().split())
ans=h*w
for i in range(1,h//2+1):
    S=[i*w,(h-i)*(w//2),(h-i)*(w-w//2)]
    ans=min(ans,max(S)-min(S))
for i in range(1,w//2+1):
    S=[i*h,(w-i)*(h//2),(w-i)*(h-h//2)]
    ans=min(ans,max(S)-min(S))
if h%3==0 or w%3==0:
    ans=0
else:
    ans=min(ans,h,w)
print(ans)

Measured memory_bytes: 3188
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e18
using namespace std;

const int maxn = 210000;

ll L,R;
int n,pos;
bool flag;
int ex[maxn],id,mx;
char str[maxn];
struct node
{
	ll n,s[26];
	node(){n=0;memset(s,0,sizeof s);}
}f[maxn]; int ed;
inline node operator +(node &x,node &y)
{
	node re; re.n=x.n+y.n;
	for(int i=0;i<26;i++) re.s[i]=x.s[i]+y.s[i];
	return re;
}

void dp()
{
	f[0].n=pos;
	for(int i=0;i<pos;i++) f[0].s[str[i]-'a']++;
	f[1].n=n;
	for(int i=0;i<n;i++) f[1].s[str[i]-'a']++;
	
	ed=1;
	while(f[ed].n<inf) 
		f[ed+1]=f[ed]+f[ed-1],ed++;
}
node solve1(ll x)
{
	ll div=x/f[0].n,oth=x%f[0].n;
	node re; for(int i=0;i<26;i++) re.s[i]=f[0].s[i]*div;
	if(oth)
	{
		for(int i=0;i<oth;i++) re.s[str[i]-'a']++;
	}
	return re;
}
node solve2(ll x,int now)
{
	while(now&&f[now-1].n>=x) now--;
	node re;
	if(now<=1)
	{
		for(int i=0;i<x;i++) re.s[str[i]-'a']++;
		return re;
	}
	re=f[now-1];
	node temp=solve2(x-f[now-1].n,now-2);
	re=re+temp;
	return re;
}
node calc(ll x)
{
	node re;
	if(!x) return re;
	if(flag) re=solve1(x);
	else re=solve2(x,ed);
}

int main()
{
	scanf("%s",str); n=strlen(str); n>>=1; str[n]='$';
	id=1,mx=0;
	for(int i=1;i<n;i++)
	{
		if(mx>=i) ex[i]=min(ex[i-id],mx-i);
		while(str[i+ex[i]]==str[ex[i]]) ex[i]++;
		if(i+ex[i]-1>mx) id=i,mx=i+ex[i]-1;
	}
	
	flag=false;
	for(pos=1;pos<n&&pos+ex[pos]-1!=n-1;pos++);
	if(n%pos==0) flag=true;
	dp();
	
	scanf("%lld%lld",&L,&R);
	node a1=calc(R),a2=calc(L-1);
	for(int i=0;i<26;i++) printf("%lld ",a1.s[i]-a2.s[i]);
	
	return 0;
}


Measured memory_bytes: 45312
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> c(h,vector<char>(w));
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            char in;
            cin >> in;
            c[i][j] = in;
        }
    }
    REP(i,h){
        REP(k,2){
            REP(j,w){
                cout << c[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 3484
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

typedef  long long ll;
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;}

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int x,n;
int main(){
    cin>>n;
    vector<vector<int>>a(2);
    rep(i,2)a[i].resize(n);
    for(int j=0;j<2;j++){
        for(int i=0;i<n;i++){
            cin>>a.at(j).at(i);
        }
    }
    int count=0;
    int max=0;
    for(int way=0;way<n;way++){
        int sum=0;
        bool flag = false;
        for(int i=0;i<n;i++){
        if(flag==false){
            sum+=a.at(0).at(i);
        }
        if(way==i){
            flag = true;
        }
        if(flag){
            sum+=a.at(1).at(i);
        }
        }
        chmax(max,sum);
   }
   cout<<max<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a[105];
int main(void){
	int n,m,sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	if(a[n-m]*4*m>=sum){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String args[]){
		int i,j,g,r,x;
		Scanner sc = new Scanner(System.in);
		g=sc.nextInt();
		r=sc.nextInt();
		int[][] map= new int[g+1][r+1];
		for(i=0;i<g+1;i++){
			for(j=0;j<r+1;j++)
			map[i][j]=0;
		}
		for(i=0;i<g;i++){
			for(j=0;j<r;j++)
				map[i][j]=sc.nextInt();
		}
		for(i=0;i<g;i++){
			for(j=0;j<r;j++){
				map[i][r]+=map[i][j];
				map[g][j]+=map[i][j];}
			map[g][r]+=map[i][r];
		}
		for(i=0;i<g+1;i++){
			for(j=0;j<r;j++)
				System.out.print(map[i][j]+" ");
			System.out.println(map[i][r]);
		}
	}
}


Measured memory_bytes: 41280
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;

int main(){
   int x, y;
   cin >> x >> y;
   int a[100]; memset(a,0,sizeof(a));
   bool ok = true;
   int cnt = 0;
   for(int i = 1; i <= 16; i++){
   	cnt++;
   	if(cnt > 100){
   	 	ok = false; break;
   	}
   	int prev = i-1; 
   	if(prev < 1)prev = 16;
    	if(a[i] == 0 && a[prev] != 1){
    	 	a[i] = 1;
    	 	x--; 
    	 	if(x == 0)break;
    	}
    	if(i == 16)i = 0;
   }
   cnt = 0;

   for(int i = 1; i <= 16; i++){
		cnt++;
		int prev = i-1;
		if(prev < 1)prev = 16;
		if(cnt > 100){
		 	ok = false; break;
		}
		if(a[i] == 0 && a[prev] != 2){
		 	a[i] = 2;
		 	y--;
		 	if(y == 0)break;
    	}
    	if(i == 16)i = 0;
   }
   cout << (ok ? "Yay!" : ":(") << endl;
	return 0;
}                  


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

using namespace std;
#define x first
#define y second
const int MAXN=1005;
const double INF=1e13,eps=1e-6;
typedef pair<double,double> P;
P S,T,pos[MAXN];
vector<P> G[MAXN];
int n;double r[MAXN],d[MAXN];

double dist(P a,P b)
{return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}

int main()
{
	scanf("%lf%lf%lf%lf%d",&S.x,&S.y,&T.x,&T.y,&n);
	for(int i=1;i<=n;i++)
		scanf("%lf%lf%lf",&pos[i].x,&pos[i].y,&r[i]);
	pos[0]=S;pos[n+1]=T;
	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=n+1;j++)
			if(i!=j)
			{
				if(r[i]+r[j]>dist(pos[i],pos[j]))
					G[i].push_back(P(j,0));
				else G[i].push_back(P(j,dist(pos[i],pos[j])-r[i]-r[j]));
			}
	
	priority_queue<P,vector<P>,greater<P> > q;
	for(int i=0;i<MAXN;i++) d[i]=INF;
	d[0]=0;q.push(P(0,0));
	while(!q.empty())
	{
		P t=q.top();q.pop();
		
		int u=t.y;
		if(d[u]<t.x) continue;
		for(int i=0;i<G[u].size();i++)
		{
			int v=G[u][i].x;
			if(d[v]>d[u]+G[u][i].y)
				d[v]=d[u]+G[u][i].y,q.push(P(d[v],v));
		}
	}
	printf("%.10lf",d[n+1]);
	return 0;
}

Measured memory_bytes: 22640
A, B = map(int, input().split())
print(100, 100)
grid = [['#'] * 100 for _ in range(50)] + [['.'] * 100 for _ in range(50)]
A -= 1; B -= 1
i, j = 0, 0
while A:
    grid[i][j] = '.'; A -= 1
    if j == 98: i += 2; j = 0
    else: j += 2
i, j = 51, 0
while B:
    grid[i][j] = '#'; B -= 1
    if j == 98: i += 2; j = 0
    else: j += 2
for r in grid:
    print(''.join(r))

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
money=1000
cur=a[0]
for i in range(n):
    cur=min(cur,a[i])
    if a[i]>cur:
        rest=money%cur
        stock =money//cur
        money = rest+stock*a[i]

        cur=a[i]
print(money)


Measured memory_bytes: 9172
#include<iostream>
using namespace std;
int main(){
string S;
  cin>>S;
  if(S=="SAT"){cout<<1;}
  else if (S=="SUN"){cout<<7;}
   else if (S=="MON"){cout<<6;}
   else if (S=="TUE"){cout<<5;}
   else if (S=="WED"){cout<<4;}
   else if (S=="THU"){cout<<3;}
   else if (S=="FRI"){cout<<2;}
  
  
  
 return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
struct trump{
  char moji;
  int num;
};

void bubble(struct trump *,int);
void insertion(struct trump *,int);
int judge(struct trump *,struct trump *,int);

void bubble(struct trump k1[],int n){
  int i,j;
  struct trump tmp;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(k1[j].num < k1[j-1].num) {
	tmp = k1[j];
	k1[j] = k1[j-1];
	k1[j-1] = tmp;
      }
    }
  }
}

void insertion(struct trump k2[],int n){
  int i,j;
  struct trump tmp;
  int minj;
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(k2[minj].num > k2[j].num)minj = j;
    }
    tmp = k2[minj];
    k2[minj]=k2[i];
    k2[i] = tmp;
  }
}

int judge(struct trump k1[],struct trump k2[],int n){
  int i;
  for(i=0;i<n;i++){
    if(k1[i].moji != k2[i].moji) return 0;
  }
  return 1;
}

int main(){
  struct trump k[36], k2[36];
  int i,j,n;
  char ik;
  scanf("%d%c",&n,&ik);
  for(i=0;i<n;i++){
    scanf("%c%d%c",&k[i].moji,&k[i].num,&ik);
  }
  for(i=0;i<n;i++){
    k2[i]=k[i];
  }
  bubble(k,n);
  insertion(k2,n);
  for(i=0;i<n-1;i++){
    printf("%c%d ",k[i].moji,k[i].num);
  }
  
  printf("%c%d\nStable\n",k[i].moji,k[i].num);
  for(i=0;i<n-1;i++){
    printf("%c%d ",k2[i].moji,k2[i].num);
  }
  printf("%c%d\n",k2[i].moji,k2[i].num);
  if(judge(k,k2,n)) printf("Stable\n");
  else printf("Not stable\n");
  
  return 0;
}

Measured memory_bytes: 2740