akhauriyash/Code-Regression huggingface dataset:
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    auto S = sread();
    writeln(check(S) && check(S[0 .. (S.length - 1) / 2])
            && check(S[(S.length + 3) / 2 - 1 .. $]) ? "Yes" : "No");
}

bool check(string s)
{
    // writeln(s);
    foreach (i; 0 .. s.length)
    {
        if (s.length - 1 - i < i)
            return true;
        if (s[i] != s[$ - 1 - i])
            return false;
    }
    return true;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    REP(i, 2){
        readvec(A[i]);
    }

    int ans = 0;
    REP(i, N){
        int tmp = 0;
        REP(j, i) tmp += A[0][j];
        tmp += A[0][i] + A[1][i];
        FOR(j, i + 1, N) tmp += A[1][j];
        ans = max(ans, tmp);
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
priority_queue<double,vector<double>,greater<double> >q;
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1,x;i<=n;i++)
	scanf("%d",&x),q.push(x);
	for (int i=1;i<n;i++){
		double x=q.top();q.pop();
		double y=q.top();q.pop();
		q.push((x+y)/2);
	}
	printf("%.10lf\n",q.top());
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  	if(a>c){
      cout<<max(min(b,d)-a,0)<<endl;
    }else if(a==c){
		cout<<max(min(b,d)-a,0)<<endl;
    }else{
		cout<<max(min(b,d)-c,0)<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int keta(int n)
{
  int sum=0;
  while(0<n){
  	sum=sum+n%10;
    n=n/10;
  }
  return sum;
}
int main()
{
  int n,a,b;
  int i=0,wa=0,sum=0;
  scanf("%d %d %d",&n,&a,&b);
  for(i=n;0<i;i--){
    wa=keta(i);
  	if(a<=wa && wa<=b){
      sum=sum+i;
    }
   // printf("%d\n",keta(i));
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 1724
def int_multiple():
    return  [int(c) for c in input().split()]

def int_single():
    return int(input())

def str_multiple():
    return [c for c in input().split()]

def str_single():
    return input()

# start

k, x = int_multiple()

s = ""

for i in range(x-(k-1), x+k):
    s += str(i) + " "

print(s[:-1])


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

int main(){
  int mod = 1e9 + 7;

  int N, K; cin >> N >> K;

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

  vector<vector<long long>> dp(N, vector<long long>(K+1, 0));

  for (int i=0; i<N; i++){
    for (int j=0; j<K+1; j++){
      if (j == 0) {
        dp[i][j] = 1;
        continue;
      }
      
      if (i == 0) {
        if (j <= a[i]) dp[i][j] = 1;
        else dp[i][j] = 0;
        continue;
      }

      dp[i][j] = dp[i-1][j] + dp[i][j-1];
      if (j > a[i]) dp[i][j] += mod - dp[i-1][j-1-a[i]];
      dp[i][j] %= mod;
    }
  }
  
  cout << dp[N-1][K] << endl;
  return 0;
}


Measured memory_bytes: 79360
n = int(input())
c = input()
r = 0
left, right = 0, n-1
while left < right:
    if c[left] == 'W' and c[right] == 'R':
        r += 1
        left += 1
        right -= 1
        continue
    if c[left]=='R':
        left += 1
    if c[right]=='W':
        right -= 1
print(r)

Measured memory_bytes: 67708
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int d=b/a;
  printf("%d\n",MIN(c,d));
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
//using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
Graph G;
int p[200010],x[200010];
int d[200010];
int dfs2(int v,int p){
    
    for(auto np: G[v]){
        if(np==p)
            continue;
        d[np]+=d[v];
        dfs2(np ,v);
    }

}

signed main(){
    int n,q;
    cin>>n>>q;
    G.assign(n,vector<int>());
    for (int i = 0; i < n-1; i++)
    {
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);

    }

    for (int i = 0; i < q; i++)
    {
        cin>>p[i]>>x[i];
        p[i]--;
        d[p[i]]+=x[i];
    }
    dfs2(0,-1);
    for (int i = 0; i < n; i++)
    {
        cout<<d[i]<<" ";
    }
    cout<<endl;




    


    return 0;
}

Measured memory_bytes: 27392
#include <stdio.h>

int n,a[30];

int solve(int m,int i){
  if(m==0) return 1;
  if(i>=n) return 0;
    int res = solve(m,i+1)||solve(m-a[i],i+1);
    return res;
}

int main(){
  int i,q,m;

  scanf("%d",&n);

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

  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d ",&m);
    if(solve(m,0)){
      printf("yes\n");
    }
    else{
      printf("no\n");
  }
}
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    string ans="Yes";

    while(true){
        c-=b;
        if(c<=0){
            ans = "Yes";
            break;
        }

        a-=d;
        if(a<=0){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define reg register
#define maxn 1001
using namespace std;
bool hh = true;
int nt[maxn << 1], maxx, x[maxn], go[maxn << 1], n, fi[maxn], dp[maxn][10001], cnt, g[10001], f[10001][2];
void add(int u, int v){
    nt[++cnt] = fi[u]; fi[u] = cnt; go[cnt] = v;
}
void dfs(int u){
    int cntx = 0, sum = 0;
    for(int i = fi[u]; i; i = nt[i]){
        int v = go[i]; dfs(v); cntx++;
    }
    if(cntx == 0){
         f[u][0] = 0, f[u][1] = x[u];    return; 
    }
    dp[u][0] = 1; 
    for(int i = fi[u]; i; i = nt[i]){
        int v = go[i];
        memset(g, 0, sizeof g); sum += f[v][0] + f[v][1];
        for(int j = 0; j <= x[u]; j++){
            if(j >= f[v][0]) g[j] |= dp[u][j - f[v][0]];
            if(j >= f[v][1]) g[j] |= dp[u][j - f[v][1]];
        }
        memcpy(dp[u], g, sizeof dp[u]);
    }
    int t = 0;
    for(int i = x[u]; i >= 0; i--){
        if(dp[u][i]) {sum = sum - i; t = 1; break;}
    }
    if(t == 0) hh = false;
        f[u][0] = sum; f[u][1] = x[u];
}
int main()
{
    cin >> n; int y;
    for(int i = 2; i <= n; i++) cin >> y, add(y, i); 
    for(int i = 1; i <= n; i++) cin >> x[i], maxx = max(maxx, x[i]);
    dfs(1);
    if(hh) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 39040
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main(){
    string s,t;
    cin >> s >> t;
    vector<int> ss(s.size()+1,0),tt(t.size()+1,0);
    rep(i,s.size()) {
        if (s.at(i)=='A') ss.at(i+1)=ss.at(i)+1;
        else ss.at(i+1)=ss.at(i)+2;
    }
    rep(i,t.size()){
        if (t.at(i)=='A') tt.at(i+1)=tt.at(i)+1;
        else tt.at(i+1)=tt.at(i)+2;
    }
    int q;
    cin >> q;
    rep(i,q){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        if ((ss.at(b)-ss.at(a-1))%3==(tt.at(d)-tt.at(c-1))%3) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, a[100005] = {};
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    priority_queue<int> q;
    for (int i = 0; i < n; i++) q.push(a[i]);
    while (m--) {
        int x = q.top();
        q.pop();
        q.push(x / 2);
    }
    ll z = 0;
    while (!q.empty()) z += q.top(), q.pop();
    cout << z;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 1e3+5;

double x[maxn], y[maxn], r[maxn];
double edge[maxn][maxn];
double xs, ys, xt, yt;
int n;

double sq(double x){ return x*x; }

double euc(double x1, double y1, double x2, double y2)
{
	return sqrt(sq(x2-x1)+sq(y2-y1));
}

struct node
{
	int u; double d;
	node(){}
	node(int _u, double _d)
	{
		u = _u; d = _d;
	}
	bool operator < (node other) const
	{
		return d> other.d;
	}
};

priority_queue<node> pq;

double dist[maxn];

int main()
{
	scanf("%lf %lf %lf %lf", &xs, &ys, &xt, &yt);
	scanf("%d", &n);
	for(int i = 1; i<= n; i++) scanf("%lf %lf %lf", &x[i], &y[i], &r[i]);
	for(int i = 1; i<= n; i++)
	{
		for(int j = i+1; j<= n; j++)
		{
			double res = max(0.0,  euc(x[i], y[i], x[j], y[j])-r[i]-r[j]);
			edge[i][j] = edge[j][i] = res;
		}
	}
	for(int i = 1; i<= n; i++)
	{
		double res = max(0.0, euc(xs, ys, x[i], y[i])-r[i]);
		dist[i] = res;
		pq.push(node(i, dist[i]));
	}
	while(!pq.empty())
	{
		node xx = pq.top(); pq.pop();
		int u = xx.u; double d = xx.d;
		if(d> dist[u]) continue;
		for(int i = 1; i<= n; i++)
		{
			if(dist[i]> edge[u][i]+dist[u])
			{
				dist[i] = edge[u][i]+dist[u];
				pq.push(node(i, dist[i]));
			}
		}
	}
	double best = euc(xs, ys, xt, yt);
	for(int i = 1; i<= n; i++)
	{
		double res = max(0.0, euc(xt, yt, x[i], y[i])-r[i]);
		best = min(best, res+dist[i]);
	}
	printf("%.10lf\n", best);
}

Measured memory_bytes: 13552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	cin>>n>>m;
	vvint e(n);
	vector<vector<bool>> f;
	initvv(f, n, n, false);
	rep(i, m){
		int a, b;cin>>a>>b;
		//e[a-1].push_back(b-1);
		//e[b-1].push_back(a-1);
		f[a-1][b-1] = true;
		f[b-1][a-1] = true;
	}
	vint perm;
	rep(i, n-1){perm.push_back(i+1);}
	int ans = 0;
	do{
		int now = 0;
		bool flag = true;
		rep(i, n-1){
			if(!f[now][perm[i]]){
				flag = false;
				break;
			}else{
				now = perm[i];
			}
		}
		if(flag){ans++;}
	}while(next_permutation(all(perm)));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() { 
    int w, h, n;
    cin >> w >> h >> n;
    int x1 = 0, x2 = w, y1 = 0, y2 = h;
    for (int i = 0; i < n; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            x1 = max(x1, x);
            x2 = max(x2, x);
        } else if (a == 2) {
            x1 = min(x1, x);
            x2 = min(x2, x);
        } else if (a == 3) {
            y1 = max(y1, y);
            y2 = max(y2, y);
        } else {
            y1 = min(y1, y);
            y2 = min(y2, y);
        }
    }
    cout << (x2 - x1) * (y2 - y1) << endl;
}




Measured memory_bytes: 3608
n=int(input())
S = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    if i==0:
        if S[i][1]+S[i][2]>S[i][0]:
            print("No")
            exit()
        else:
            if S[i][0]%2==0:
                if (S[i][1]+S[i][2])%2==1:
                    print("No")
                    exit()
            else:
                if (S[i][1]+S[i][2])%2==0:
                    print("No")
                    exit()
    else:
        if abs(S[i][1]-S[i-1][1])+abs(S[i][2]-S[i-1][2])>S[i][0]-S[i-1][0]:
            print("No")
            exit()
        else:
            if S[i][0]%2==0:
                if (S[i][1]+S[i][2])%2==1:
                    print("No")
                    exit()
            else:
                if (S[i][1]+S[i][2])%2==0:
                    print("No")
                    exit()
print("Yes")

Measured memory_bytes: 27380
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(c) (c).begin(), (c).end()

template <class C, class T> inline bool contains(const C& c, const T& x) { return c.find(x) != c.end(); }

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

    int H, W, M; cin >> H >> W >> M;
    set<pair<int, int>> targets;
    REP(i, M) {
        int h, w; cin >> h >> w; --h; --w;
        targets.emplace(h, w);
    }

    vector<int> vertical_counts(W);
    for (auto [y, x] : targets) {
        ++vertical_counts[x];
    }
    int v_max = *max_element(ALL(vertical_counts));
    vector<int> max_cols;
    REP(x, W) {
        if (vertical_counts[x] == v_max)
            max_cols.push_back(x);
    }

    vector<int> horizontal_counts(H);
    for (auto [y, x] : targets) {
        ++horizontal_counts[y];
    }
    int h_max = *max_element(ALL(horizontal_counts));
    vector<int> max_rows;
    REP(y, H) {
        if (horizontal_counts[y] == h_max)
            max_rows.push_back(y);
    }

    if (max_rows.size() * max_cols.size() > (size_t)M) {
        cout << v_max + h_max << '\n';
    } else {
        bool found =
            any_of(ALL(max_rows), [&](int r) {
                return any_of(ALL(max_cols), [&](int c) {
                    return !contains(targets, make_pair(r, c));
                });
            });
        int ans = v_max + h_max - (found ? 0 : 1);
        cout << ans << '\n';
    }
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int n;
    while (cin >> n, n) {
        vector<int> a(n);
        REP(i,n) cin >> a[i];
        int ans = inf;
        REP(i,n) REP(j,n) {
            if (i == j) continue;
            ans = min(ans,abs(a[i]-a[j]));
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>

using namespace std;


int parent[100001];
int pos[100001];

int get_pos(int n){
	if(parent[n] == n)
		return pos[n]; 

	return pos[n] + get_pos(parent[n]);
}

int get_repr(int n){
	if(parent[n] == n)
		return n;

	int repr = get_repr(parent[n]);
	pos[n] += get_pos(parent[n]);
	parent[n] = repr;

	return repr;
}


bool joint(int l, int r, int d){
	if(get_repr(l) == get_repr(r)){
		if(get_pos(r) - get_pos(l) != d)
			return false;
	}else{
		int repr_l = get_repr(l);
		int repr_r = get_repr(r);
		int pos_r = get_pos(r);
		int pos_l = get_pos(l);

		parent[repr_r] = repr_l;
		pos[repr_r] = pos_l + d - pos_r;
	}
	return true;
}

void display(int n){
	for(int i=0; i<n; i++){
		cout << i << "(" << parent[i] << ") " << pos[i]<<endl;
	}
	return;
}

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

	for(int i=0; i<n; i++){
		parent[i] = i;
		pos[i] = 0;
	}

	for(int i=0; i<m; i++){
		//display(n);
		int l,r,d;
		cin >> l >> r >> d;
		if(!joint(l,r,d)){
			cout << "No"<<endl;
			return 0;
		}
	
	}
	cout << "Yes" <<endl;

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005;
int a[N],cnt[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,x;
  cin>>n;
  rep(i,1,n+1)
    {
      cin>>x;
      cnt[x]++;
    }
  int ans=0;
  rep(i,0,N)
    {
      int tmp=0;
      if(i) tmp+=cnt[i-1];
      tmp+=cnt[i];
      if(i<N-1) tmp+=cnt[i+1];
      ans=max(ans,tmp);
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> L(2*N);
  for(int i=0;i<2*N;i++){cin >> L[i];}
  sort(L.begin(), L.end());
  int M=0;
  for(int i=0;i<N;i++){M+=L[2*i];}
  cout << M << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;

    if (A==B)
          cout<<"Draw";
    else if(A==1)
        cout<<"Alice";
    else if(B==1)
        cout<<"Bob";
    else if(A>B)
        cout<<"Alice";
    else if (A<B)
        cout<<"Bob";
}


Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void dfs(string s, char mx, ll N) {
  if (s.length() == N) {
    cout << s << endl;
  } else {
    for (char c = 'a'; c <= mx; c++) {
      dfs(s + c, c == mx ? mx + 1 : mx, N);
    }
  }
}

void solve(ll N) {
  dfs("", 'a', N);
  return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

int x;

int main(void){
    cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3592
from collections import deque
K = int(input())

def solve(K):
    q = deque()
    for i in range(1, 10):
        q.append(i)
    
    # print(q)
    previousval = 0
    idx = 0
    while(idx < K):
        val = q.popleft()
        rem = val%10
        if rem != 0:
            q.append(10*val + rem - 1)
        q.append(10*val + rem)
        if rem != 9:
            q.append(10*val + rem + 1)
        
        previousval = val
        
        idx += 1
    return previousval

print(solve(K))



    


Measured memory_bytes: 11948
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(i) cout<<i<<endl;
const int mod=720720;
int main(){
IOS;
lli x,y,z,k,i,j;
cin>>x>>y>>z>>k;
lli a[x],b[y],c[z];
for(i=0;i<x;i++){
    cin>>a[i];
}
for(i=0;i<y;i++){
    cin>>b[i];
}
for(i=0;i<z;i++){
    cin>>c[i];
}
vector<lli> v;
for(i=0;i<x;i++){
    for(j=0;j<y;j++){
        v.pb(a[i]+b[j]);
    }
}
sort(v.begin(),v.end(),greater<lli>());
vector<lli> newv;
for(i=0;i<min(k,(lli)v.size());i++){
    newv.pb(v[i]);
}
v.clear();
for(i=0;i<newv.size();i++){
    for(j=0;j<z;j++){
        v.pb(newv[i]+c[j]);
    }
}
sort(v.begin(),v.end(),greater<lli>());
i=0;
while(i!=k){
    cout<<v[i]<<endl;
    i++;
}
}


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

int main() {
  int N;
  cin >> N;
  int temp = N;
  int x = 0;
  while (temp > 0) {
    x += temp % 10;
    temp /= 10;
  }

  string s = "No";
  if (N % x == 0) {
    s = "Yes";
  }
  cout << s << endl;
}


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

using namespace std;

using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  int a, b; cin >> a >> b;
  int tmp = (a + b) / 2;
  if((a + b) % 2) cout << "IMPOSSIBLE" << endl;
  else cout << tmp << endl;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[111];

int main() {
    cin >> n;
    li res = 0;
    rin{
        cin >> a[i];
        if (i % 2 == 0 && a[i] % 2 > 0) {
            res++;
        }
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 3628
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let n:i32 = procon_read()[0];
	let a = n.to_string();
	let s:Vec<char> = a.chars().collect();
	let mut flag = false;
	for i in s {
		if i == '7' {
			flag = true;
			break;
		}
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
std::vector<std::vector<long long>> comb(int n, int r) {
	std::vector<std::vector<long long>> v(n + 1, std::vector<long long>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, cnt = 0;
	cin >> n;
	vector<ll>bucket(100,0);
	vector<string>a(n);
	vector<char>aa(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	rep(i, n)aa[i] = a[i][0];
	for (ll i = 0; i < n; i++) {
		bucket[aa[i]]++;
	}
	ll arr1[] = { 65,65,65,65,65,65,67,67,67,72 };
	ll arr2[] = { 67,67,67,72,72,77,72,72,77,77 };
	ll arr3[] = { 72,77,82,77,82,82,77,82,82,82 };
	for (ll i = 0; i < 10; i++) {
		cnt += bucket[arr1[i]] * bucket[arr2[i]] * bucket[arr3[i]];
	}
	cout << cnt << endl;
}


Measured memory_bytes: 5888
n,c,k = map(int,input().split())
t = 0
cnt = c
ans = 0
T = [int(input()) for _ in range(n)]
T.sort()
for i in range(n):
    if cnt == c or T[i] > t:
        ans += 1
        t = T[i] + k
        cnt = 1
    else:
        cnt += 1

print(ans)


Measured memory_bytes: 7384
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define ll long long
#define ull unsigned long long
#define MAXM 1010
#define MAXN 100010
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second
#define mii map<int, int>
#define umii unordered_map<int, int>
#define allof(x) x.begin(), x.end()
#define DEBUG 1
// #define NOT_DMOJ 0
#ifdef DEBUG
	#define D(x...) printf(x)
#else
	#define D(x...)
#endif
using namespace std;

inline int GCD (int a, int b) { return b == 0 ? a : GCD(b, a % b); }
inline int LCM (int a, int b) { return a * b / GCD(a, b); }
inline ll PowMod (ll a, ll b, ll mod) { ll val = 1; while (b) { if (b & 1) val = (val * a) % mod; a = (a * a) % mod; b >>= 1; } return val; }

ll N;
ll h[MAXN], DP[MAXN];

int main (int argc, char const *argv[]) {
	#ifdef NOT_DMOJ
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif // NOT_DMOJ
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N;
	for (int i=1; i<=N; i++) cin >> h[i];
	DP[2] = abs(h[1] - h[2]);
	for (int i=3; i<=N; i++) {
		DP[i] = min(abs(h[i] - h[i - 1]) + DP[i - 1], abs(h[i] - h[i - 2]) + DP[i - 2]);
	}
	cout << DP[N] << "\n";
	return 0;
}

/* 
 * Look for:
 * the exact constraints (multiple sets are too slow for n=10^6 :( ) 
 * special cases (n=1?)
 * overflow (ll vs int?)
 * array bounds
 */

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int sum,temp,subsum;
	
	while(scanf("%d",&sum)){
		if(sum==0)
		break;
		subsum = 0;
		for(int i=0;i<9;i++){
			scanf("%d",&temp);
			subsum+=temp;
		}
		printf("%d\n",sum-subsum);
	}
}

Measured memory_bytes: 3208
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
#define MAX 1000010
long long gcd(long long a,long long b)
{
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}
int main()
{
    long long a,b;
    while(~scanf("%lld%lld",&a,&b))
    {
        long long ans=gcd(a,b);
        printf("%lld %lld\n",ans,a/ans*b);
    }
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>

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

using namespace std;

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

    int N = 0;
    cin >> N;
    vector<string> str;
    REP(i,N) {
        string hoge = "";
        cin >> hoge;
        REP(j,str.size()){
            if(str[j] == hoge){
                printf("No");
                return 0;
            }
        }
        str.push_back(hoge);
    }

    bool flag = false;
    REP(i,N - 1) {
        if(str[i].back() != str[i + 1].front()){
            printf("No");
            return 0;
        }
    }
    printf("Yes");

    return 0;
}

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

template <typename T, typename U>
struct min_cost_flow_graph {
	
	struct edge {
		int from, to;
		T cap, f;
		U cost;
	};
	
	vector<edge> edges;
	vector<vector<int>> g;
	int n, st, fin;
	T required_flow, flow;
	U cost;
	
	min_cost_flow_graph(int n, int st, int fin, T required_flow)
		: n(n), st(st), fin(fin), required_flow(required_flow) {
			assert(0 <= st && st < n && 0 <= fin && fin < n && st != fin);
			g.resize(n);
			flow = 0;
			cost = 0;
	}
	
	void clear_flow() {
		for (const edge &e : edges) {
			e.f = 0;
		}
		flow = 0;
		cost = 0;
	}
	
	void add(int from, int to, T cap = 1, T rev_cap = 0, U cost = 1) {
		assert(0 <= from && from < n && 0 <= to && to < n);
		g[from].emplace_back(edges.size());
		edges.push_back({from, to, cap, 0, cost});
		g[to].emplace_back(edges.size());
		edges.push_back({to, from, rev_cap, 0, -cost});
	}
	
	U min_cost_flow() {
		vector<U> h(n, 0);
		while (flow < required_flow) {
			vector<int> preve(n);
			vector<U> dist(n, numeric_limits<U>::max() / 2);
			priority_queue<pair<U, int>, vector<pair<U, int>>, greater<pair<U, int>>> pq;
			dist[st] = 0;
			pq.emplace(dist[st], st);
			while (!pq.empty()) {
				U expected = pq.top().first;
				int i = pq.top().second;
				pq.pop();
				if (expected != dist[i]) {
					continue;
				}
				for (int id : g[i]) {
					const edge &e = edges[id];
					if (0 < e.cap - e.f && dist[e.from] + e.cost + h[e.from] - h[e.to] < dist[e.to]) {
						dist[e.to] = dist[e.from] + e.cost + h[e.from] - h[e.to];
						preve[e.to] = id;
						pq.emplace(dist[e.to], e.to);
					}
				}
			}
			if (dist[fin] == numeric_limits<U>::max() / 2) {
				return -1;
			}
			for (int i = 0; i < n; i++) {
				h[i] += dist[i];
			}
			T d = required_flow - flow;
			for (int v = fin; v != st; v = edges[preve[v]].from) {
				d = min(d, edges[preve[v]].cap - edges[preve[v]].f);
			}
			flow += d;
			cost += d * h[fin];
			for (int v = fin; v != st; v = edges[preve[v]].from) {
				edges[preve[v]].f += d;
				edges[preve[v] ^ 1].f -= d;
			}
		}
		return cost;
	}
};

int main() {
	int n, m, f;
	cin >> n >> m >> f;
	min_cost_flow_graph<int, int> g(n, 0, n - 1, f);
	for (int i = 0; i < m; i++) {
		int from, to, cap, cost;
		cin >> from >> to >> cap >> cost;
		g.add(from, to, cap, 0, cost);
	}
	cout << g.min_cost_flow() << endl;
	return 0;
}

Measured memory_bytes: 3236
#include<stdio.h>
#include<string.h>
int main(){
	char a[4001],b[4001];
	int anum,bnum,max,i,j,c;
	while(scanf("%s",a)!=EOF){
		scanf("%s",b);
		anum=strlen(a);
		bnum=strlen(b);
		max=0;
		for(i=0;i<anum;i++){
			c=0;
			for(j=0;j<bnum && i+j<anum;j++){
				if(a[i+j]==b[j]) c++;
				else{
					max=(c>max)?c:max;
					c=0;
				}
			}
			max=(c>max)?c:max;
		}
		for(i=0;i<bnum;i++){
			c=0;
			for(j=0;j<anum && i+j<bnum;j++){
				if(b[i+j]==a[j]) c++;
				else{
					max=(c>max)?c:max;
					c=0;
				}
			}
			max=(c>max)?c:max;
		}
		printf("%d\n",max);
	}
  return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <ctime>
#include <set>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <cmath>

#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ull unsigned long long
#define iloop(a,b) for(ll i = a; i < b; ++i)
#define jloop(a,b) for(ll j = a; j < b; ++j)
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(typeofa((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define p(a) cout << a << "\n";
#define p1(a) cout << a << " ";

#define PI 3.141592653589793
#define MOD (ll)(1e9 + 7)

using namespace std;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 

void solve()
{
	int x,a,b;
	cin >> x >> a >> b;
	if(abs(x-a) > abs(x-b))
		p("B")
	else
		p("A")
}
int main()
{
	bool testing = false;
	IOS
	if(testing)
	{
		freopen("test.txt","rt",stdin);
		int start = clock();
		solve();
		int end = clock();
		cout << "time: " << (end - start)/(double)(CLOCKS_PER_SEC)*1000 << " milliseconds\n";
	}
	else
	{
		solve();
	}
} 

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

typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18


int main() {
    int H,W; cin >> H >> W;
    vector<vector<char>> A(H,vector<char>(W));

    set<int> yoko;
    REP(i,H){
        bool ok = true;
        string S;
        cin >> S;
        REP(j,W){
            A[i][j] = S[j];
            if(A[i][j] == '#') ok = false;
        }
        if(ok){
            yoko.insert(i);
        }
    }
    set<int> tate;
    REP(j,W){
        bool ok = true;
        REP(i,H){
            if(A[i][j] == '#') ok = false;
        }
        if(ok){
            tate.insert(j);
        }
    }

    REP(i,H){
        REP(j,W){
            if(yoko.find(i)==yoko.end() && tate.find(j)==tate.end()){
                cout << A[i][j];
            }
        }
        if(yoko.find(i)==yoko.end()){
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e19;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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;
	}
}

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

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
string dir[8] = { "R","L","D","U","RD","RU","LD","LU" };
bool flag[201010];
ll ans[201010];

vector<vector<ll>>to;

void dfs(ll v) {
	flag[v] = true;
	for (auto nv : to[v]) {
		if (flag[nv] == false) {
			ans[nv] += ans[v];
			dfs(nv);
		}
	}
}

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n + 1);
	a[0] = 1;
	for (ll i = 3;i <= n;++i) {
		rep(j, i - 2) {
			a[i] += a[j];
			a[i] %= MOD;
		}
	}
	cout << a[n] << endl;
	return 0;
}


Measured memory_bytes: 3624
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

from heapq import heapify, heappush, heappop, heappushpop, heapreplace
from bisect import bisect_left, bisect_right

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if a[m-1] >= sum(a) / (m * 4):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split())) 
ans = 1
for i in range(N):
  if(A[i] % 2 == 0):
    if(A[i] % 3 != 0 and A[i] % 5 != 0):
      ans = 0
      break
      
if(ans == 1):
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
using namespace std;
int H,W;
char s[1010][1010],ans1[1010][1010],ans2[1010][1010];
int main(){
	cin>>H>>W;
	for(rint i=1;i<=H;++i) {
		scanf("%s",s[i]+1);
	}
	for(rint i=1;i<=H;++i) for(rint j=1;j<=W;++j) ans1[i][j]=ans2[i][j]='.';
	for(rint i=1;i<=H;++i) {
		for(rint j=1;j<=W;++j){
			if(s[i][j]=='#') {
				ans1[i][j]=ans2[i][j]='#';
				continue;
			}
			if(j==1) {ans1[i][j]='#';continue;}
			if(j==W) {ans2[i][j]='#';continue;}
			if(i&1) {
				ans1[i][j]='#';
			}
			else ans2[i][j]='#';
		}
	}
	for(rint i=1;i<=H;++i,cout<<endl) for(rint j=1;j<=W;++j) cout<<ans1[i][j];
	cout<<endl;
	for(rint i=1;i<=H;++i,cout<<endl) for(rint j=1;j<=W;++j) cout<<ans2[i][j];
	return 0;
}

Measured memory_bytes: 5252
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;
	
	boolean go(String s, char c) {
		int lowVal = Integer.MAX_VALUE;
		int lowIdx = 0;
		int prevVal = 0;
		
		int pref = 0;
		
		for (int i = 0; i < s.length(); i++) {
			pref += (s.charAt(i) == c ? 1 : -1);
			if (pref > lowVal) {
				out.println((lowIdx + 1) + " " + (i + 1));
				return true;
			}
			if (prevVal < lowVal) {
				lowVal = prevVal;
				lowIdx = i;
			}
			prevVal = pref;
		}
		
		return false;
	}

	void solve() throws IOException {
		String s = nextToken();
		for (char c = 'a'; c <= 'z'; c++) {
			if (go(s, c)) {
				return;
			}
		}
		out.println("-1 -1");
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

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




int main(){
   int n;
   cin>>n;
   int cnt=0;
   bool b[111]={};
   rep(i,n){
       int d;
       cin>>d;
       if(!b[d]){
           cnt++;
           b[d]=true;
       }
   }
   cout<<cnt<<endl;
   return 0;
}



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

vector<P>E[1500];
int d[1500][1500];
vector<int>pre[1500][1500];
bool b[1500];
int main() {
	int n, r; scanf("%d%d", &n, &r);
	rep(i, r) {
		int s, t, d; scanf("%d%d%d", &s, &t, &d); s--; t--;
		E[s].push_back(P(d, t));
		E[t].push_back(P(d, s));
	}
	priority_queue<P, vector<P>, greater<P>>que;
	memset(d, 0x3f, sizeof(d));
	rep(i, n) {
		d[i][i] = 0;
		que.push(P(0, i));
		while (!que.empty()) {
			P p = que.top(); que.pop();
			if (p.first != d[i][p.second])continue;
			for (P v : E[p.second]) {
				if (d[i][v.second] == p.first + v.first)
					pre[i][v.second].push_back(p.second);
				if (d[i][v.second] > p.first + v.first) {
					pre[i][v.second].clear();
					pre[i][v.second].push_back(p.second);
					d[i][v.second] = p.first + v.first;
					que.push(P(d[i][v.second], v.second));
				}
			}
		}
	}
	int Max = 0;
	rep(i, n)rep(j, n)Max = max(Max, d[i][j]);
	rep(i, n)rep(j, n) {
		if (d[i][j] != Max)continue;
		queue<int>que;
		que.push(j);
		while (!que.empty()) {
			int d = que.front(); que.pop();
			b[d] = true;
			for (int j : pre[i][d])que.push(j);
		}
	}
	list<int>v;
	rep(i, n) {
		if (!b[i])v.push_back(i + 1);
	}
	printf("%d\n", v.size());
	for (int i : v)printf("%d\n", i);
}

Measured memory_bytes: 135264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(br.readLine());
        String numsArray[] = br.readLine().split(" ");
        long sum = 0;
        int max=-1000000;
        int min=1000000;
        int tmp=0;
        for(int i=0; i<num; i++){
            tmp = Integer.parseInt(numsArray[i]);
            if(tmp>max){
                max = tmp;
            }
            if(tmp<min){
                min = tmp;
            }
            sum = sum+tmp;
        }
        System.out.println(min+" "+max+" "+sum);
    }
}
 

Measured memory_bytes: 28336