akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main()
{
	int count[4][3][10];
	int i, j, k;
	int n, b, f, r, v;
	
	scanf("%d", &n);
	
	for (i = 0; i < 4; i++){
		for (j = 0; j < 3; j++){
			for (k = 0; k < 10; k++){
				count[i][j][k] = 0;
			}
		}
	}
	
	for (i = 0; i < n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		
		count[b - 1][f - 1][r - 1] += v;
	}
	
	for (i = 0; i < 4; i++){
		for (j = 0; j < 3; j++){
			for (k = 0; k < 10; k++){
				printf(" %d", count[i][j][k]);
			}
			printf("\n");
		}
		if (i == 3){
			break;
		}
		
		printf("####################\n");
	}
	
	return (0);
}



Measured memory_bytes: 2052
#include<stdio.h>

int main(){
    char O[51],E[51];
    int i;

    scanf("%s%s",O,E);

    for(i=0;;i++){
        if(E[i]=='\0'){
            if(O[i]=='\0') break;
            else{
                printf("%c",O[i]);
                break;
            }
        }
        printf("%c%c",O[i],E[i]);
    }
    return 0;
}

Measured memory_bytes: 128
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    auto a = aryread();
    a.sort();
    a.take(k).sum().writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2740
N, L, T = map(int, input().split())
X = []
W = []
for _ in range(N):
    x, w = map(int, input().split())
    X.append(x)
    if w == 2:
        w = -1
    W.append(w)

C = 0
for i in range(1, N):
    if W[i] != W[0]:
        C += T // (L / 2)
        if W[0] == 1:
            D = X[i] - X[0]
        else:
            D = X[0] + L - X[i]
        if T % (L / 2) * 2 >= D:
            C += 1

for i in range(N):
    X[i] = (X[i] + T * W[i]) % L

x = X[0]

X.sort()

ng = -1
ok = N
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if X[mid] >= x:
        ok = mid
    else:
        ng = mid
if W[0] == 1 and ok < N-1:
    if X[ok] == X[ok+1]:
        ok += 1

start = int((ok - C * W[0]) % N)
for i in X[start:]:
    print(i)
for i in X[:start]:
    print(i)

Measured memory_bytes: 9740
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int N;
int a[MAXN],b[MAXN],id[MAXN];
bool vis[MAXN];
void Solve() {
	read(N);
	for(int i = 1 ; i <= N ; ++i) {
		read(a[i]);read(b[i]);id[i] = i;
	}
	sort(id + 1,id + N + 1,[](int s,int t){return a[s] + b[s] > a[t] + b[t];});
	int64 ans = 0;
	for(int i = 1 ; i <= N ; ++i) {
		if(i & 1) ans += a[id[i]];
		else ans -= b[id[i]];
	}
	out(ans);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }



void solve()
{
    ll n, ans = 0;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    while(true)
    {
        ll f = 0, mn = inf;
        for(ll i = 0; i < n; i++){
            if(a[i] == 0) f++; //cout << a[i] << " ";
        } //cout << endl;
        if(f == n) break;
        vector<ll> v;
        for(ll i = 0; i < n; i++){
            if(a[i] == 0) {
                if(mn != inf) ans += mn;
                v.pb(mn);
                mn = inf;
            }
            else mn = min(mn, a[i]);
        }
        v.pb(mn);
        if(mn != inf) ans += mn; //printv(v);

        for(ll i = 0; i < n; i++){
            if(a[i] == 0) v.erase(v.begin());
            else a[i] -=v.front();
        }
    }
    cout << ans;
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
/*
	ARIJIT SUR 
	@duke_knight
	@surcode
    @comeback
	IIT ISM 
 */
#include<bits/stdc++.h>
#define SIZE 100008
#define mod (ll)(1e9+7)
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) (a>0?a:-a)
#define all(a) a.begin(),a.end()
#define maxelem(a) *max_element(all(a))
#define minelem(a) *min_element(all(a))
#define pb push_back
#define pi pair<int,int>
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i1=0;i1<a.size();i1++) cin>>a[i1];}
#define display(a) {for(int i1=0;i1<a.size();i1++) cout<<a[i1]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define vi vector<int>
typedef long long ll;
#define ff q.front()

void dfs(int x, int &cnt, vi g[], vector<bool> &vis)
{
    vis[x]=true;
    cnt++;
    int neigh=g[x].size();
    for(int i=0;i<neigh;i++)
    {
        if(!vis[g[x][i]])
        dfs(g[x][i],cnt,g,vis);
    }
}
void friends(){
    int n,m;
    cin>>n>>m;
    vector<int> adj[n+1];
    vector<bool> visited(n+1,0);
    queue<int> q;
    while(m--){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v); adj[v].pb(u);
    }
    int ans =-1;
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            int cnt=0;
            q.push(i);visited[i]=1;
            while(!q.empty()){
                cnt+=1;
                visited[ff]=1;
                for(int j=0;j<adj[ff].size();j++){
                    if(!visited[adj[ff][j]]) q.push(adj[ff][j]),visited[adj[ff][j]]=1;
                }
                q.pop();
            }
            ans = max(ans,cnt);
        }
    }
    cout<<ans<<endl;
}
void solve(){
    int n,m;
        cin>>n>>m;
        
        vector<int> g[n+1];
        vector<bool>vis(n+1);       
        while(m--)
        {
            int x,y;
            cin>>x>>y;
            g[x].pb(y);g[y].pb(x);
        }
        
        int ma=-1;
        for(int u=1;u<=n;u++)
        {
            if(!vis[u])
            {
                int count=0;
                dfs(u,count,g,vis);
                ma=max(count,ma);
            }
        }
        cout<<ma;
}
int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
    	friends();
    }
    return 0;
}

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

int n, k, s = 1, cnt, mx, x[100005];
string a;
vector<int> b, c;
int main()
{
	int i, t, z;
	cin >> n >> k;
	cin >> a;
	t = a[0] - '0';
	if (t == 0) {
		b.push_back(0);
		c.push_back(1);
	}
	for (i = 1; i < n; i++) {
		z = a[i] - '0';
		if (z != t) {
			b.push_back(s);
			c.push_back(t);
			s =1;
		} else s++;
		t = z;
	}
	b.push_back(s);
	c.push_back(t);
	if (t == 0) {
		b.push_back(0);
		c.push_back(1);
	}
	for (i = 0; i < c.size(); i++) if (c[i] == 0) cnt++;
	if (cnt <= k) cout << n;
	else {
		x[0] = b[0];
		for (i = 1; i < b.size(); i++) x[i] = x[i - 1] + b[i];
		for (i = k * 2; i < b.size(); i += 2) mx = max(mx, x[i] - (i - k * 2 > 0 ? x[i - k * 2 - 1] : 0));
		cout << mx;
	}
    return 0;
}


Measured memory_bytes: 1780
n, y = list(map(int, input().split()))

def func(n, y):
    for m in range(n + 1):
        for g in range(n - m + 1):
            s = n - m - g
            if m * 10000 + g * 5000 + s * 1000 == y:
                return m, g, s
    return -1, -1, -1

m, g, s = func(n, y)

print(m, g, s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
using ld=long double;
int32_t main()
{
	int x;
	
	cin>>x;
	
	//cout<<(101*101)/100 <<"\n";
	ld p=100;
	int t=0;

	while(p<x)
	{
		p=p*((ld)101);
		p/=((ld)100);
		p=floor(p);
		t++;
	}
	cout<<t;
	
	
	
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

ll p[50],a[50];

ll func(int N,ll X) {
  if ( N == 0 && X <= 0 ) return 0;
  else if ( N == 0 && X == 1 ) return 1;
  else if ( X <= 1 + a[N-1] ) return func(N-1,X-1);
  else if ( X == 2+a[N-1] ) return p[N-1]+1;
  else if ( X <= 2+2*a[N-1] ) return p[N-1]+1+func(N-1,X-2-a[N-1]);
  else return 2*p[N-1]+1;
}

int main() {
  int N; ll X; cin >> N >> X;
  p[0] = a[0] = 1;
  for ( int i = 1; i <= N; i++ ) {
    p[i] = 2*p[i-1]+1;
  }
  for ( int i = 1; i <= N; i++ ) {
    a[i] = 2*a[i-1]+3;
  }

  cout << func(N,X) << endl;
  return 0;
}


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

int main() {
    vector<string> s;
    string s1, s2;
    int n, l;
    cin >> n >> l;
    for (int i=0; i<n; i++) {
        cin >> s1;
        s.push_back(s1);
    }
    sort(s.begin(), s.end());
    for (int i=0; i<n; i++) {
        s2 += s[i];
    }
    cout << s2;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	Set<Character> news = new HashSet<>(); 
    	for (char c : S.toCharArray()) {
    		news.add(c);
    	}
    	switch (news.size()) {
    	case 1 :
    	case 3 :
    		System.out.println("No");
    		break;
    	case 4 :
    		System.out.println("Yes");
    		break;
    	case 2 :
    		if ((news.contains('N') && news.contains('S')) ||
    				(news.contains('E') && news.contains('W'))) {
    			System.out.println("Yes");
    		} else {
    			System.out.println("No");
    		}
    	}
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#define rep(i, n) for (i = 0; i < n; i++)

int main() {
    int c, a = -1, z = -1, i;
    for (i = 0; (c = getchar()) != '\n'; i++) {
        if (c == 'A' && a == -1) a = i;
        if (c == 'Z' && z < i) z = i;
    }
    printf("%d\n", z - a + 1);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;
  vector<int> v(2 * N);
  rep(i, 2 * N) {
    cin >> v[i];
  }

  sort(v.begin(), v.end());

  int ans = 0;
  rep(i, N) {
    ans += v[i * 2];
  }

  cout << ans << endl;
  
  return 0;
}

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

int main()
{
    int N, sum=0;
    cin >> N;
    vector<vector<int>> data(N, vector<int>(2));

    for (int i = 0; i < N;i++){
        for (int j = 0; j < 2;j++){
            cin >> data.at(i).at(j);
        }
    }

    for (int i = 0; i < N; i++)
    {
        sum = sum + (data.at(i).at(1) - data.at(i).at(0) + 1);
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
def grp(z):
  if z in [1,3,5,7,8,10,12]:
    return 'a'
  elif z in [4,6,9,11]:
    return 'b'
  elif z == 2:
    return 'c'
print('Yes' if grp(x) == grp(y) else 'No')

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, k;
  cin >> n >> k;
  ul mod = 1e9+7;
  // dp[i][j] divide i to j groups
  vector< vector< ul > > dp(n+2, vector< ul >(n+2, 0));
  dp[0][0] = 1;
  for (int i=1; i<=n+1; ++i) {
    for (int j=1; j<=i; ++j) {
      dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
      dp[i][j] %= mod;
    }
  }
  for (int i=1; i<=k; ++i) {
    cout << dp[k][i] * (dp[n-k][i-1] + dp[n-k][i]*2 + dp[n-k][i+1]) % mod << endl;
  }
  return 0;
}


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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct SetUp {
    SetUp() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} setUp;

signed main() {
    int N;
    cin >> N;
    vint A(N);
    int base = 0;
    rep(i, N) { cin >> A[i], base += A[i] * (1 - (i & 1) * 2); }
    rep(i, N) {
        cout << base << endl;
        base *= -1;
        base += A[i] * 2;
    }

}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

mint calc(long long N, long long K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}
int main() {
//cout << fixed << setprecision(12);
ll n,m;
cin>>n>>m;
if(n>=m){
cout << 0 << endl;}
else{
ll l[m]={};
ll a[m]={};
rep(i,m){
cin>>a[i];}
sort(a,a+m);
for(ll i=0; i < m-1; i++){
l[i]=a[i+1]-a[i];}
sort(l,l+m-1);
ll ca=0;
for(ll i=0; i<n-1; i++){
ca+=l[m-2-i];}
cout << a[m-1]-a[0]-ca << endl;}}


Measured memory_bytes: 5148
//I had a dream :)
#include <bits/stdc++.h>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll; typedef pair<int, int> ii;
#define X first
#define Y second
#define vi vector<int>
#define vii vector< ii >
#define pb push_back
int main()
{
    //#ifndef atom freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif
    int n; cin >> n;
    set<char> bst;
    for(int i = 0; i< n; i++)
    {
        char x; cin >> x;
        bst.insert(x);
    }
    int res = bst.size();
    if(res == 3) puts("Three");
    else puts("Four");
}


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

void fall(vector<string> &g) {
    int h = g.size();
    int w = g[0].size();
    for (int j = 0; j < w; j++) {
        int k = h - 1;
        for (int i = h - 1; i >= 0; i--) {
            if (g[i][j] != '0') {
                g[k--][j] = g[i][j];
            }
        }
        while (k >= 0) g[k--][j] = '0';
    }
}

int erase(vector<string> &g, int K) {
    int h = g.size();
    int w = g[0].size();
    int sum = 0;
    for (int i = 0; i < h; i++) {
        int j = 0;
        while (j < w) {
            int k = j;
            while (j < w && g[i][j] == g[i][k]) j++;
            if (j - k >= K) {
                sum += (j - k) * (g[i][k] - '0');
                for (; k < j; k++) g[i][k] = '0';
            }
        }
    }
    return sum;
}

int run(vector<string> &g, int K) {
    int res = 0;
    for (int i = 0;; i++) {
        fall(g);
        int s = erase(g, K);
        if (s == 0) break;
        res += (1 << i) * s;
    }
    return res;
}

int main() {
    int h, w, K;
    cin >> h >> w >> K;
    vector<string> g(h);
    for (int i = 0; i < h; i++) cin >> g[i];

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            auto tmp = g;
            tmp[i][j] = '0';
            ans = max(ans, run(tmp, K));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
M = 256
while (n = gets.to_i) != 0 do
  l = gets.split.map(&:to_i)
  min = Float::INFINITY
  for s in 0..15 do
    for a in 0..15 do
      for c in 0..15 do
        o = Hash.new(0.0)
        r = s
        for i in 1..n do
          r = (a * r + c) % M
          o[(l[i - 1] + r) % M] += 1.0
        end
        h = -(o.inject(0.0){|sum, (key, x)| sum += x / n.to_f * Math::log(x / n.to_f)})
        next if min <= h
        min = h
        answer = [s, a, c]
      end
    end
  end
  puts answer.join(" ")
end

Measured memory_bytes: 7896
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#define MOD 1000000007LL
using namespace std;

int main(){
	string s;
	cin >> s;
	string ans = "";
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '0') ans = ans + "0";
		if(s[i] == '1') ans = ans + "1";
		if(s[i] == 'B' && ans != "") ans.erase(ans.size()-1, 1);
	}
	for(int i = 0; i < ans.size(); i++){
		if(ans[i] != ' ') cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_Q = 50000;
const int MAX_N = 100000;

int binarySearch(int* a, int key, int n) {
    int left = 0;
    int right = n;
    int mid;

    while (left < right) {
        mid = (left + right) / 2;
        if (a[mid] == key) {
            return 1;
        }        
        else if (a[mid] < key) {
            left = mid + 1;
        }
        else {
            right = mid;
        }
    }

    return 0;
}

int main() {
    int n_1, n_2;
    int a[MAX_N];
    int ans = 0;
    int key;

    cin >> n_1;

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

    cin >> n_2;

    for (int i = 0; i < n_2; i++) {
        cin >> key;
        if (binarySearch(a, key, n_1)) {
            ans++;
        }
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 3352
import heapq

def dijkstra(graph, node, start):
    dist = [float("inf") for _ in range(node)]

    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))

    while q:
        cost, cur_node = heapq.heappop(q)

        if dist[cur_node] < cost:
            continue

        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heapq.heappush(q, (dist[nex_node], nex_node))

    return dist


n = int(input())
adj = [[] for _ in range(n)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    adj[a].append((c, b))
    adj[b].append((c, a))
q, k = map(int, input().split())
shortest = dijkstra(adj, n, k - 1)
for i in range(q):
    x, y = map(int, input().split())
    print(shortest[x - 1] + shortest[y - 1])

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

int main() {
 int N;
 cin>>N;
 for(int i=0;i<N;i++){
   int x;
   cin>>x;
   if(x%2==0 && x%3!=0 && x%5!=0){
     cout<<"DENIED";
     break;
   }
   else if(i==N-1){
    cout<<"APPROVED";
  }
   else{
     continue;
   }
 }
  
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static Tuple<int, int> Solve(string s)
        {
            int N = s.Length;
            for (int i = 0; i + 1 < N; ++i)
            {
                if (s[i] == s[i + 1]) { return new Tuple<int, int>(i + 1, i + 2); }
            }
            for (int i = 0; i + 2 < N; ++i)
            {
                if (s[i] == s[i + 2]) { return new Tuple<int, int>(i + 1, i + 3); }
            }
            return new Tuple<int, int>(-1, -1);
        }
        static void Main(string[] args)
        {
            string s = Read();
            var ans = Solve(s);
            Console.WriteLine("{0} {1}", ans.Item1, ans.Item2);
        }
    }
}


Measured memory_bytes: 13280
import sys
N, K = map(int, input().split())
S = input()
S0 = S[0]
SL = S[-1]
if N == 1:
    print(0)
    sys.exit(0)
else:
    cnt = S.count('RL')
    answer = 0
    if S0 == 'L' and SL == 'L':
        answer = N - 1
        answer -= cnt*2
        answer += K*2
        answer = answer if answer < N-1 else N-1
    if S0 == 'L' and SL == 'R':
        answer = N - 1
        answer -= cnt*2+1
        answer += K*2
        answer = answer if answer < N-1 else N-1
    if S0 == 'R' and SL == 'L':
        answer = N - 1
        answer -= cnt*2-1
        answer += K*2
        answer = answer if answer < N-1 else N-1
    if S0 == 'R' and SL == 'R':
        answer = N - 1
        answer -= cnt*2
        answer += K*2
        answer = answer if answer < N-1 else N-1
        
    print(answer)


Measured memory_bytes: 39824
#include <iostream>
#include <string>
#include <sstream>
#include<algorithm>

#include<cstdio>
#include<cctype>
using namespace std;

int main(){
    char ch;
    while(1){
        scanf("%c",&ch);
        if(isalpha(ch)){
            if(islower(ch))printf("%c",toupper(ch));
            else printf("%c",tolower(ch));
        }else printf("%c",ch);
        if(ch == '\n')break;
        
        
        
    }
    
    
    
	return 0;
	
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;

int N;
vector<string> ans(0);
//string a="";
void p(int x,string s){
    if(s.size()==N){cout<<s<<endl;return;}
    rep(i,x){
        string t=s;
        t+='a'+i;
        p(x,t);
    }
    string t=s;
    t+='a'+x;
    p(x+1,t);
}

int main() {
    
    cin>>N;
    
    p(1,"a");
}

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

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

	vector<int> v(n);
	for (auto& i : v) {
		cin >> i;
	}

	int ret = 0;
	vector<int> t(k);
	for (int l = 0; l <= k; ++l) {
		for (int r = 0; r <= k - l; ++r) {
			int d = k - l - r;
			//if (l + r < d) {
			//	continue;
			//}

			if (n < l + r) {
				continue;
			}

			t.clear();

			int cl = 0;
			while (cl != l) {
				t.push_back(v[cl]);
				++cl;
			}

			int cr = 0;
			while (cr != r) {
				t.push_back(v[n-1-cr]);
				++cr;
			}

			sort(t.begin(), t.end());

			int sum = 0;
			int start = 0;
			for (; start < d; ++start) {
				if (start == t.size()) {
					break;
				}
				if (0 < t[start]) {
					break;
				}
			}
		
			for (int i = start; i < t.size(); ++i) {
				sum += t[i];
			}

			if (ret < sum) {
				ret = sum;
			}
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	double DP[n+1][n+1];
	DP[0][0]=1;
	for(int i=1;i<=n;i++){
		double p;
		cin>>p;
		DP[i][0]=DP[i-1][0]*(1-p);
		for(int j=1;j<=i;j++){
			DP[i][j]= DP[i-1][j]*(1-p)+DP[i-1][j-1]*p;
		}
	}
	double ans=0.0;
	for(int i=n/2+1;i<=n;i++){
		ans+=DP[n][i];
	}
	cout<<setprecision(10)<<fixed<<ans<<endl;
}

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

int main(){
    int A[4],i;
    string s;
    cin>>s;
    for(i=0;i<4;i++){
        A[i] = s[i] - '0';
    }
    int j,sum;
    char op[3];
    for(i=0;i<(1<<3);i++){
        sum = A[0];
        for(j=0;j<3;j++){
            if( i & ( 1 << j ) ){
                op[j] = '+';
                sum += A[j+1];
            }else{
                op[j] = '-';
                sum -= A[j+1];
            }
        }
        if( sum == 7 ){
            break;
        }
    }

    for(i=0;i<3;i++){
        printf("%d%c",A[i],op[i]);
    }
    printf("%d=7\n",A[3]);

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    sc.close();

    long ans = lcm(A, B);
    System.out.println(ans);
  }

  private static long lcm(long a, long b) {
    return a / gcd_r(a, b) * b;
  }

  private static long gcd_r(long a, long b) {
    return a < b ? gcd_r(b, a) : b == 0 ? a : gcd_r(b, a % b);
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define loop(i ,a,b) for(int i = a;i<b;i++)
#define rloop(i,a,b) for(int i = a ; i>b;i--)
#define loopll(i,a,b) for( long long int i = a; i<b;i++)
#define rloopll(i,a,b) for(long long int i = a; i>b;i--)
#define eb emplace_back
#define pii pair<int ,int>
#define pll pair<ll ,ll>
#define mk make_pair
#define intmin INT_MIN
#define intmax INT_MAX
#define cout(x) cout<<x<<" ";
using namespace std;
void vec(vector<int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
void vec_ll(vector<long long int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
int parsestring(string temp){
    int num= 0;
    int digs = temp.size() - 1;
    for(int i = 0 ;i<=digs;i++){
        num += pow(10 , digs -i)*(temp[i] - '0');
    }
    return num;
}

int mindig(string & s){
    int temp = INT_MAX;
//    int index = -1;
    for(int i = 0;i<s.size() ; i++){
        if(temp > s[i] - '0'){
            temp = s[i] - '0';
//            index = i;
        }
    }
    return temp;
}
//}
ll power(ll base ,ll exp){
    ll ans = 1;
    for(ll i = 1;i<=exp ; i++){
        ans *= base;
    }
    return ans;
}
//}
//
void factor(ll n ,set<ll> &s ){
        ll x = 2;
        while(n!= 1){
            if(n%x == 0){
                s.insert(x);
                n/= x;
            }
            else{
                x++;
            }
        }
    }

bool prime(int n){
    bool ok = true;
    for(int i = 2 ; i*i <= n ; i++){
        if(n%i == 0){ok =false ; break;}
    }
    return ok;
}
int nmax = 1e5 + 10;
vector<vector<int>> adj(nmax , vector<int>());
vector<int> dis(nmax , 0);
vector<int> indeg(nmax , 0);
vector<bool> vis(nmax , false);
void dfs(int n ){
    if(vis[n]){return;}
    vis[n] = true;
    for(int i = 0;i<adj[n].size();i++){
        dis[adj[n][i]] = max(dis[adj[n][i]] , dis[n] + 1);
        if(indeg[adj[n][i]]){
            indeg[adj[n][i]]--;
        }
        if(indeg[adj[n][i]] == 0){
            dfs(adj[n][i]);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
        for(int j = 0;j<m;j++){
            int x,y;
            cin>>x>>y;
            adj[x].eb(y);
            indeg[y]++;
        }
//    for(int i = 0;i<n;i++){
//        adj[0].eb(i+1);
//        indeg[i+1]++;
//    }
//
//    dfs(0);
    for(int i = 1;i<=n;i++){
        if(indeg[i] == 0 && !vis[i]){
            dfs(i);
        }
    }
    int maxi = INT_MIN;
    for(int i = 1;i<=n;i++){
        maxi = max(maxi , dis[i]);

    }
    cout<<maxi<<endl;
}


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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int dp[3001][3001];

int main(){
    string s,t;
    cin >> s >> t;
    
    rep(i,s.length()){
        dp[i][0] = 0;
    }
    rep(j,t.length()){
        dp[0][j] = 0;
    }

    for(int i=1; i<s.length()+1; i++){
        for(int j=1; j<t.length()+1; j++){
            if(s[i-1]==t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else{
                dp[i][j] = max({dp[i-1][j],dp[i][j-1]});
            }   
        }
    }

    // rep(i,s.length()+1){
    //     rep(j,t.length()+1){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    int i = s.length();
    int j = t.length();
    deque<char> a;
    while(i>0 && j>0){
        if(dp[i][j] == dp[i-1][j]){
            i = i - 1;
        }
        else if(dp[i][j] == dp[i][j-1]){
            j = j - 1;
        }
        else{
            i = i - 1;
            j = j - 1;
            a.push_front(s[i]);
        }
    }

    rep(i,a.size()){
        cout << a[i];
    }
    

    // cout << dp[s.length()-1][t.length()-1];

}


Measured memory_bytes: 35456
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c;
	cin >> a >> b >> c;
	swap(a,b);
	swap(a,c);
	cout << a << " "<< b << " "<< c;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,c[501],s[501],f[501];
int main()
{
	scanf("%d",&n);
	n--;
	for(register int i=1;i<=n;i++)
		scanf("%d%d%d",&c[i],&s[i],&f[i]);
	for(register int i=1;i<=n;i++)
	{
		int sum=c[i]+s[i];
		for(register int j=i+1;j<=n;j++)
		{
			if(sum>s[j])
			{
				if(sum%f[j]!=0)
					sum=(sum/f[j]+1)*f[j];
			}else{
				sum=s[j];
			}
			sum+=c[j];
		}
		printf("%d\n",sum);
	}
	printf("0");
	return 0;
}

Measured memory_bytes: 128
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[]
ans=0
AB=[]
for i in range(N):
    a=list(map(int,input().split()))
    ab=[0]*M
    for i in range(M):
        ab[i]=a[i]*B[i]
    AB.append(ab)
for i in range(N):
    if sum(AB[i])>(-1)*C:
        ans+=1
print(ans)

Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
#define mxn 2100
#define wph 924844033
using namespace std;

int f[mxn<<1][mxn<<1][2];
int n,fac[mxn<<1],k;
int a[mxn<<1],cnt; bool cant[mxn<<1];
int main()
{
	int ff,ans,tmp;
	scanf("%d%d",&n,&k);fac[0]=1;
	for(int i=1;i<=(n<<1);i++)	fac[i] = (ll)fac[i-1]*i%wph;
	for(int i=1;i<=k;i++)
	for(int j=0;j<=1;j++)
	for(int l=i;l<=n;l+=k)
	{
		++cnt;
		if(l==i)	cant[cnt]=1;
	}
	f[0][0][0]=1;
	for(int i=1;i<=cnt;i++)
	for(int j=0;j<=i;j++)
	{
		f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%wph;
		if(!cant[i])	f[i][j][1]=f[i-1][j-1][0];
	}
	ans=0;
	for(int i=0;i<=n;i++)
	{
		ff=i&1?-1:1;
		tmp=((ll)f[cnt][i][0]+f[cnt][i][1])%wph*fac[n-i]%wph;
		ans=((ll)ans+ff*tmp+wph)%wph;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 131456
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;

const int SIZE=2e5+7;
vector<int> chain[SIZE];
vector<int> ch[SIZE];
int n,m,cnt;
int visit[SIZE];

void dfs(int x)
{
	visit[x]=1;
	chain[cnt].push_back(x);
	for(int u:ch[x])
		if(!visit[u])
			dfs(u);
		
}

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m;
	REP(i,m)
	{
		int x,y;
		cin>>x>>y;
		--x,--y;
		ch[x].push_back(y);
		ch[y].push_back(x);
	}
	REP(i,n)if(!visit[i])
	{
		dfs(i);
		cnt++;
	}
	int ans=0;
	REP(i,cnt)ans=max(ans,int(chain[i].size()));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 29904
import fractions
n=int(input())
a=list(map(int,input().split()))
left=[0]*n
right=[0]*n
left[0]=a[0]
right[-1]=a[-1]
for i in range(1,n):
    left[i]=fractions.gcd(left[i-1],a[i])
    right[n-1-i]=fractions.gcd(right[n-i],a[n-1-i])
ans=[0]*n
ans[0]=right[1]
ans[n-1]=left[n-2]
for i in range(1,n-1):
    ans[i]=fractions.gcd(left[i-1],right[i+1])
print(max(ans))

Measured memory_bytes: 16128
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
 
 
class Main
{
    public static void main(String[] args)
    {
        int ans = 0;
        int count = 0;
        int a;
        
        Scanner scanner = new Scanner(System.in);
        String n = scanner.next();
        //int m = scanner.nextInt();
        String[] ar = n.split("");
        a = n.length();
        for(int i = 0; i < a;i++){
            count = count + Integer.parseInt(ar[i]);
        }
        
        if(Integer.parseInt(n) % count == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        //System.out.println(ans);
        scanner.close();
    }
}

Measured memory_bytes: 21204
n = int(input())
nums = list(map(int, input().split()))

unq = list(set(nums))


def answer(ans):
    print(ans)
    exit()

if len(unq) > 3:answer("No")

if len(unq) == 3:
    a,b,c = unq
    if a ^ b ^ c != 0:answer("No")
    if nums.count(a) == nums.count(b) == nums.count(c):answer("Yes")
    else:answer("No")

if len(unq) == 2:
    a,b = sorted(unq)
    if a != 0:answer("No")
    if nums.count(a) * 2 == nums.count(b):answer("Yes")
    else: answer("No")

if len(unq) == 1:
    a = unq[0]
    if a != 0:answer("No")
    else:answer("Yes")

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

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++)
  cin >> vec.at(i);
  int sum = accumulate(vec.begin(), vec.end(), 0);
  
  if ( sum >= H ){
  cout << "Yes" << endl; 
  }
 
  else {
   cout << "No" << endl; 
  }
 
}


Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<cstdio>
#define MAXN 101
using namespace std;
int a[MAXN];
int main()
{
	int n;
	scanf("%d",&n);
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	int mid=sum*1.0/n+0.5;
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=ans+(mid-a[i])*(mid-a[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> val(200200), res(200200);
vector<int> adj[200200];
struct operation{
    int id, val, t;
};
int tmp = 0;
stack<operation> op;
void dfs(int u,int p, vector<int> &lis){
    if(u == 1) lis.pb(val[u]);
    else{
        int p = lower_bound(td(lis), val[u]) - lis.begin();
        if(p == lis.size()){
            op.push({-1,-1, tmp});
            lis.pb(val[u]);
        }
        else{
            op.push({p, lis[p], tmp});
            lis[p] = val[u];
        }
    }
    res[u] = lis.size();
    int t_at = tmp++;
    for(int v : adj[u]){
        if(v==p) continue;
        dfs(v,u,lis);
        while(!op.empty() && op.top().t > t_at){
            if(op.top().id == -1){
                lis.pop_back();
            }
            else{
                lis[op.top().id] = op.top().val;
            }
            op.pop();
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> val[i];
    for(int i=0;i<n-1;i++){
        int a,b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vector<int> lis;
    dfs(1, -1, lis);
    for(int i=1;i<=n;i++){
        cout << res[i] << endl;
    }
}

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

using namespace std;
using ll=long long;

#define rep(i, a, n) for (int i = (n); i < (a); ++i)
int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int a,b,k;cin>>a>>b>>k;
  vector<int> hoge;
  for (int i = a; i <a+k && i<=b; ++i){
    hoge.push_back(i);
  }
  for (int i = b-k+1<a ? a:b-k+1; i <=b; ++i){
    hoge.push_back(i);
  }
  sort(hoge.begin(), hoge.end());
  hoge.erase(unique(hoge.begin(), hoge.end()), hoge.end());
  for(int i:hoge)cout<<i<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
	int n,a,b;
	cin>>n;
	if(n==1)cout<<"Hello World\n";
	else{
		cin>>a>>b;
		cout<<a+b<<endl;
	}
}
/*reveres begin end
cout<<"\n";
  m.insert(std::make_pair('c', 30));
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
int nxt[100009][26];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin>>s>>t;
	int slen=s.size(),tlen=t.size();
	for(int i=0;i<26;i++) nxt[slen][i]=slen;
	for(int i=slen-1;i>=0;i--) {
		for(int j=0;j<26;j++) nxt[i][j]=nxt[i+1][j];
		nxt[i][s[i]-'a']=i;
	}
	int pos=0,ans=0;
	for(int i=0;i<tlen;i++)
		if(nxt[pos][t[i]-'a']==slen) {
			ans++;
			pos=nxt[0][t[i]-'a']+1;
			if(pos==slen+1) {
				cout<<-1<<endl;
				return 0;
			}
		}
		else pos=nxt[pos][t[i]-'a']+1;
	cout<<(long long)ans*slen+pos<<endl;
	return 0;
}

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

int main() 
{
  int N;
  cin >> N;
  int ans;
  vector<int> d(N);
   for (int i = 0; i < N; i++) 
   {
     cin >> d.at(i);
   }

   sort(d.begin(), d.end());
  ans = d.at(N/2)-d.at((N/2)-1);
  cout << ans <<endl;
  

}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
using namespace std;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>k(m);
    vector<vector<int>>s(m);
    int sij;
    for(int i=0;i<m;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>sij;
            sij--;
            s[i].push_back(sij);
        }
    }
    vector<int>p(m);
    for(int i=0;i<m;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=0;i<(1<<n);i++){
        bool on=true;
    //    cout<<i<<"   ppp"<<endl;
        for(int j=0;j<m;j++){
            int on_num=0;
    //        cout<<" j begi"<<j<<endl;
            for(auto itr:s[j]){
    //            cout<<itr<<"   and      "<<(i&(1<<itr))<<endl;
                if((i&(1<<itr))!=0){
                    on_num++;
                }
            }
//            cout<<j<<" on_num "<<on_num<<endl;
            if(on_num%2!=p[j]){
                on=false;
                continue;
            }
        }
        if(on){
    //        cout<<i<<"  plus"<<endl;
            ans++;
        }
    }
    cout<<ans;
    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 n, k;
	cin >> n >> k;
	vector<int> v(n + 1, 0);
	for (int i = 0; i < k; i++) {
		int kk;
		cin >> kk;
		for (int j = 0; j < kk; j++) {
			int t;
			cin >> t;
			v[t]++;
		}
	}
	int res = 0;
	for (int i = 1; i <= n; i++) {
		if (v[i] == 0) res++;
	}
	cout << res << endl;
}


Measured memory_bytes: 3560
#include <iostream>                                                                     
#include <cctype>                                                                       
                                                                                        
using namespace std;                                                                    
                                                                                        
int main(void) {                                                                        
  char buf;                                                                             
                                                                                        
  while (true) {                                                                        
    cin.get(buf);                                                                       
    if (buf == '\n') {                                                                  
      break;                                                                            
    }                                                                                   
                                                                                        
    if(islower(buf)) {                                                                  
      cout << (char)toupper(buf) << flush;                                              
                                                                                        
    }else if(isupper(buf)) {                                                            
      cout << (char)tolower(buf) << flush;                                              
                                                                                        
    } else cout << buf;                                                                 
  }                                                                                     
  cout << endl;                                                                         
}                                                                                       
                                                                                        
                                

Measured memory_bytes: 3100
N, K = map(int, input().split())
a = list(map(int, input().split()))
rui = [0] * (N + 1)

for i in range(N):
    rui[i + 1] = rui[i] + a[i]

for i in range(K, N):
    if rui[i] - rui[i - K] < rui[i + 1] - rui[i - K + 1]:
        print('Yes')
    else:
        print('No')

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

#define M 1000000007
#define MAXX 999999999999999
#define PI 3.14159265358979323846
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;
typedef pair<lli,lli> PLL;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   
//   freopen("input.txt","rt",stdin);

   lli n;
   cin>>n;
   
   vector<ulli> v(n+1,0),suff_sum(n+2,0);
   for(int i=1;i<=n;i++)
      cin>>v[i];
   
   for(int i=n;i>=1;i--)
      suff_sum[i] += (suff_sum[i+1]+v[i]);
   
   ulli ans = 0;
   for(int i=1;i<=n;i++)
   {
      ans += (((v[i]%M)*(suff_sum[i+1]%M))%M);
      ans %= M;
   }
   
   cout<<ans<<"\n";
}


Measured memory_bytes: 6348
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll k,n,m;
    cin>>k>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    for(ll i=0;i<n-1;i++){
        m=max(m,a[i+1]-a[i]);
    }
    m=max(m,a[0]+k-a[n-1]);
    cout<<k-m<<endl;
    return 0;
}

Measured memory_bytes: 1792