akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> x(N), y(N);
    vector<ll> xary(N), yary(N);
    rep(i, 0, N)
    {
        cin >> x[i] >> y[i];
        xary[i] = x[i];
        yary[i] = y[i];
    }
    sort(xary.begin(), xary.end());
    sort(yary.begin(), yary.end());

    ll ans = (xary[N - 1] - xary[0]) * (yary[N - 1] - yary[0]);

    rep(xi, 0, N) rep(xj, xi + 1, N) rep(yi, 0, N) rep(yj, yi + 1, N)
    {
        int num = 0;
        ll lx = xary[xi], rx = xary[xj];
        ll by = yary[yi], uy = yary[yj];

        rep(i, 0, N)
        {
            if (x[i] >= lx && x[i] <= rx && y[i] >= by && y[i] <= uy)
            {
                ++num;
            }
        }

        if (num >= K) chmin(ans, (rx - lx) * (uy - by));
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<climits>
#include<algorithm>
#define RG register
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define clear(x, y) memset(x, y, sizeof(x))

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while(ch != '-' && (!isdigit(ch))) ch = getchar();
	if(ch == '-') w = -1, ch = getchar();
	while(isdigit(ch)) data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int maxn(2e5 + 10);
struct edge { int next, to, dis; } e[maxn << 1];
int head[maxn], e_num;
inline void add_edge(int from, int to, int dis)
{
	e[++e_num] = (edge) {head[from], to, dis};
	head[from] = e_num;
}

struct node { int x, y; long long w; } a[maxn * 50];
inline int cmp(const node &lhs, const node &rhs) { return lhs.w < rhs.w; }
int n, m, W[maxn], SIZE, size[maxn], root, _max, vis[maxn];
void getRoot(int x, int fa)
{
	int max = 0; size[x] = 1;
	for(RG int i = head[x]; i; i = e[i].next)
	{
		int to = e[i].to; if(vis[to] || to == fa) continue;
		getRoot(to, x); size[x] += size[to]; max = std::max(max, size[to]);
	}
	max = std::max(max, SIZE - size[x]);
	if(max < _max) _max = max, root = x;
}

int pos; long long val;
void dfs(int x, int fa, long long dep)
{
	if(dep + W[x] < val) val = dep + W[x], pos = x;
	for(RG int i = head[x]; i; i = e[i].next)
	{
		int to = e[i].to; if(vis[to] || to == fa) continue;
		dfs(to, x, dep + e[i].dis);
	}
}

void link(int x, int fa, long long dep)
{
	a[++m] = (node) {x, pos, val + W[x] + dep};
	for(RG int i = head[x]; i; i = e[i].next)
	{
		int to = e[i].to; if(vis[to] || to == fa) continue;
		link(to, x, dep + e[i].dis);
	}
}

void solve(int x)
{
	vis[x] = 1; val = LLONG_MAX >> 1; pos = 0;
	dfs(x, 0, 0); link(x, 0, 0);
	for(RG int i = head[x]; i; i = e[i].next)
	{
		int to = e[i].to; if(vis[to]) continue;
		SIZE = _max = size[to]; getRoot(to, x);
		solve(root);
	}
}

long long ans; int fa[maxn];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }

int main()
{
	SIZE = _max = n = read();
	for(RG int i = 1; i <= n; i++) W[i] = read();
	for(RG int i = 1, x, y, z; i < n; i++)
		x = read(), y = read(), z = read(),
		add_edge(x, y, z), add_edge(y, x, z);
	getRoot(1, 0); solve(root);
	std::sort(a + 1, a + m + 1, cmp);
	for(RG int i = 1; i <= n; i++) fa[i] = i;
	for(RG int i = 1; i <= m; i++)
	{
		if(find(a[i].x) == find(a[i].y)) continue;
		fa[find(a[i].x)] = find(a[i].y); ans += a[i].w;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 77184
N,M = map(int,input().split())
target = [[num-1 for num in list(map(int,input().split()))[1:]] for _ in range(M)]
judge = list(map(int,input().split()))
cnt = 0

for i in range(2**N):
  switches = [0]*M
  for k in range(M):
    for j in range(N):
      if ((i>>j)&1) and j in target[k]:
        switches[k] += 1
  switches =  [switch%2 for switch in switches]
  if switches == judge:
    cnt += 1
print(cnt)

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

int main()
{
	int x,h;
	double halfx;
	double s;
	while(1){
		cin >> x >> h;
		if(x == 0 && h == 0)	return 0;
		halfx = x / 2.0;
		s = x * x + 4 * ((x*sqrt((double)(halfx*halfx + h*h)))/2);
		printf("%.7lf\n",s);
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<ll,ll>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,k;cin >> n >> k;
    vi h(n);
    rep(i,n) cin >> h[i];

    vl dp(n+1,LINF);
    dp[0] = 0;
    rep(i,n){
        for(int j=1;j<=k && i+j<n;++j){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n;
int a[15];
unordered_map<ll,ll> dp[15][130][3];
ll asum,aprod=1;

int main(){
  {
    string in;
    cin>>in;
    n=in.size();
    rep(i,n){
      a[i]=in[i]-'0';
      asum+=a[i];
      aprod*=a[i]+1;
    }
  }
  dp[0][0][1][1]=1;
  rep(i,n){
    rep(j,130){
      rep(k,3){
        for(P p : dp[i][j][k]){
          rep(nxtd,10){
            if(k==0||k==2){
              dp[i+1][j+nxtd][k][p.fi*(nxtd+1)]+=p.se;
            }else{
              if(nxtd<a[i]){
                dp[i+1][j+nxtd][0][p.fi*(nxtd+1)]+=p.se;
              }else if(nxtd==a[i]){
                dp[i+1][j+nxtd][1][p.fi*(nxtd+1)]+=p.se;
              }else if(nxtd>a[i]){
                dp[i+1][j+nxtd][2][p.fi*(nxtd+1)]+=p.se;
              }
            }
          }
        }
      }
    }
  }
  ll res=0;
  rep(j,130)rep(k,3){
    for(P p : dp[n][j][k]){
      if(j<asum||(j==asum&&p.fi<aprod)||(j==asum&&p.fi==aprod&&k<2))res+=p.se;
    }
  }
  cout<<res-1<<endl;
  return 0;
}



Measured memory_bytes: 51872
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

ll fac[1000001];

void pre(){
    fac[0]=fac[1]=1;
    for(int i=2;i<=1000001;i++)
{

    fac[i]=(fac[i-1]*1LL*i)%mod;
}
}

ll binpower(ll a,ll n){
    ll res=1;
    while(n){

    if(n%2)
        res = (res*1LL*a)%mod;

        n/=2;
        a=(a*1LL*a)%mod;

    }
    return res;

}

ll nCrmod(ll n,ll r){


ll res= fac[n];
res = (res*1LL*binpower(fac[r],mod-2))%mod;
res= (res*1LL*binpower(fac[n-r],mod-2))%mod;
return res;

}

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll modexp(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  modexp(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*modexp(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return modexp(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
     pre();
    ll s;cin>>s;
    ll p = s/3;
    ll ans=0;
    ll cur=1;
    for(ll i=1;i<=p;i++){
       ll k= s-i*3;
       //cout<<k<<endl;
       ans=(ans+nCrmod(k+i-1,i-1))%mod;
       // cout<<ans<<endl;
    }
    cout<<ans%mod<<endl;
    return 0;
}


Measured memory_bytes: 11456
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;

    cin>>s>>t;

    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());

    if(s<t)cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    return 0;
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

ll MAX_V = 2e5 + 5;
vector<vector<ll>> G(MAX_V);//隣接リスト(添え字は始点、値は終点)

//引数は各頂点(0-indexed)の入次数
vector<ll>tsort(vector<ll>v){
  ll n=v.size();
  vector<ll>ret(n);
  stack<ll>st;
  for(ll i=0;i<n;i++)if(v[i]==0)st.push(i);
  for(ll i=0;i<n;i++){
    if(st.empty())return vector<ll>();//閉路がある
    ll x=st.top();
    st.pop();
    ret[x]=i;
    for(ll j=0;j<G[x].size();j++){
      v[G[x][j]]--;
      if(v[G[x][j]]==0)st.push(G[x][j]);
    }
  }
  return ret;
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>num(n);
  rep(i,0,m){
    ll u,v;cin>>u>>v;
    G[u-1].PB(v-1);
    num[v-1]++;
  }
  auto v=tsort(num);
  ans(v.size()==0,0,-1);
  return 0;
}

Measured memory_bytes: 4992
#include <cstdio>

using namespace std;

int main()
{
    int n;
    while( scanf( "%d", &n ) != EOF )
    {
        if( n == 1 )
        {
            printf( "%d\n", 2 );
        }
        else
        {
            printf( "%d\n", ( ( n + 1 ) * n + 2 ) / 2 );
        }
    }
    return 0;
}


Measured memory_bytes: 2704
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x) for( int i=0;i<(x);i++)
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
 int main()
 {
   long double n,s=0;
   cin>>n;
   s=ceil(n/2);
   cout<<s<<endl;
 }

Measured memory_bytes: 384
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

	int n;
	cin >> n;

	vector<string> assign(10);
	assign[1] = ".,!? ";
	assign[2] = "abc";
	assign[3] = "def";
	assign[4] = "ghi";
	assign[5] = "jkl";
	assign[6] = "mno";
	assign[7] = "pqrs";
	assign[8] = "tuv";
	assign[9] = "wxyz";
	
	for(int i = 0; i < n; ++i) {
		string input, output;
		cin >> input;

		int cnt = 0;
		string candidate = "";
		for(int j = 0; j < (int)input.size(); ++j) {
			if(input[j] == '0') {
				output += candidate;
				candidate = "";
				cnt = 0;
			}
			else {
				const string& str = assign[input[j] - '0'];
				candidate = str[cnt];
				cnt = (cnt + 1) % str.size();
			}
		}

		cout << output << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1216
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let l: u64 = itr.next().unwrap().parse().unwrap();
    let r: u64 = itr.next().unwrap().parse().unwrap();

    if r - l >= 2019 {
        println!("0");
    } else {
        let mut ans = 1u64 << 60;
        for i in l..r + 1 {
            for j in i + 1..r + 1 {
                ans = std::cmp::min(ans, i % 2019 * j % 2019);
            }
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;
  cin>>n;
  
  vi h(n);
  rep(i,n)cin>>h[i];
  
  int ans=0;
  int tmp=0;
  rep(i,n-1){
    if(h[i]>=h[i+1]) tmp++;
    else tmp=0;
    
    chmax(ans,tmp);
  }
  
  cout(ans);
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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 T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    Yn(n/10%10==9||n/1%10==9);

    return 0;
}

Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: i
    character(3):: c1,c2

    read*, c1
    read*, c2

    do i=1,3
        if (c1(i:i) /= c2(4-i:4-i)) then
            print'(a)', 'NO'
            stop
        end if
    end do
    print'(a)', 'YES'
end program main

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int x,y;
int main(){
    cin>>x>>y;
    for(int i=0;i<=x;i++){
        if(y==2*i+4*(x-i)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
)

var n int
var az string = "abcdefghijklmnopqrstuvwxyz"

var wr = bufio.NewWriter(os.Stdout)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func rec(s string, x int) {
	if len(s) == n {
		wr.WriteString(s + "\n")
		return
	}
	for i := 0; i < x+1; i++ {
		rec(s+az[i:i+1], max(x, i+1))
	}
}

func main() {
	fmt.Scan(&n)

	rec("", 0)
	wr.Flush()
}


Measured memory_bytes: 4096
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = 10**18
for i in range(n-k+1):
    x_s, x_e = x[i], x[i+k-1]
    if x_e <= 0:
        ans_tmp = -x_s
    elif x_s < 0 and 0 < x_e:
        ans_tmp = min(x_e-2*x_s, 2*x_e-x_s)
    else:
        ans_tmp = x_e
    ans = min(ans, ans_tmp)
print(ans)


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

int main() {
  int N, x; cin >> N >> x; 
  vector<int> a(N);
  for(int i=0; i<N; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  int sum=0, count=-1;
  if(a.at(0)>x){
    count=0;
  }else{
    for(int i=0; i<N; i++){
      sum+=a.at(i);
      if(sum==x){
        count=i+1; break;
      }else if(sum>x){
        count=i; break;
      }
    }
    if(count==-1) count=N-1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
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)

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; }

const int INF = 1<<29;
int N, Ma, Mb;
int a[51], b[51], c[51];

int dp[51][500][500];

int main() {
  while (cin >> N >> Ma >> Mb) {
	for (int i = 0; i < N; ++i) cin >> a[i] >> b[i] >> c[i];
	for (int i = 0; i < 51; ++i) for (int j = 0; j < 500; ++j) for (int k = 0; k < 500; ++k) dp[i][j][k] = INF;
	dp[0][0][0] = 0;

	for (int i = 0; i < N; ++i) {
	  for (int j = 0; j <= 400; ++j) {
		for (int k = 0; k <= 400; ++k) {
		  chmin(dp[i+1][j][k], dp[i][j][k]);
		  chmin(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
		}
	  }
	}
	int res = INF;
	for (int j = 1; j <= 400; ++j) {
	  for (int k = 1; k <= 400; ++k) {
		if (j * Mb != k * Ma) continue;
		chmin(res, dp[N][j][k]);
	  }
	}
	if (res < INF) cout << res << endl;
	else cout << -1 << endl;
  }
}


Measured memory_bytes: 50048
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=1e5+5;
const ll M=1e9+7;
const ll inf=1e18+5;


vector<ll> dp,pre;

void rec(int i,vector<int>& rest,ll score,int mask,int group)
{
	if(i == (int)rest.size())
	{
		dp[mask] = max(dp[mask],score+pre[group]);
		return;
	}
	// we have 2 possibilities
	rec(i+1,rest,score,mask,group); 	// do not consider this one
	rec(i+1,rest,score,mask^(1<<rest[i]),group^(1<<rest[i]));	// consider this one
}

int main()
{
	int n;
	scn(n);
	int m = 1<<n;
	pre.resize(m);
	vector<vector<ll>> a(n,vector<ll>(n));

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			lscn(a[i][j]);
		}
	}
	// preprocessing
	// pre[mask] stores the score of 1 group having elementa(as rabbits) corresponding to bitset in the mask
	for(int mask = 0;mask<m;mask++){
		for(int i = 0;i<n;i++){
			if(mask&(1<<i)){
				for(int j=i+1;j<n;j++){
					if(mask&(1<<j)){
						pre[mask]+=a[i][j];
					}
				}					
			}
		}			
	}
	// dp[mask] stores the best possbile score considering all the possible sets of bits in the mask
	dp.resize(m,-inf);
	dp[0] = 0;
	for(int mask=0;mask<m;mask++)
	{
		vector<int> rest;
		for(int i=0;i<n;i++)
		{
			if(!(mask&(1<<i)))
				rest.pb(i);
		}
		rec(0,rest,dp[mask],mask,0);
	}
	lpri(dp[m-1]);		// all the rabbit is taken	
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> super_set;

#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
#define log sdfdsfdsf

const ll DIM = 1E5+7;
const ll MOD = 1e9+7;
const ll M1 = 1e9+7;
const ll INF = 1E17;
const ld eps = 0.00000000000001;
const ld PI = 3.14159265358979323846;
int getInt(int a = 0, int b = INT_MAX){
	static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	return uniform_int_distribution <int> (a, b)(rng);
}

ll gi(char ch){
    return ch-'0';
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin>>n;
    ll prev = 0;
    ll res = 0;
    forn(i,n){
        ll x;
        cin>>x;
        if (x<prev){
            res+=prev-x;
            x = prev;
        }
        prev = x;
    }
    cout<<res<<endl;


    return 0;
}


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

using namespace std;
int a,b,gs; 
int main()
{
	cin>>a>>b;
	gs=b-a+1;
	if(a>0) cout<<"Positive";
	else if(a<=0 && b>0) cout<<"Zero";
	else if(a<=0 && b<=0 && gs%2==1) cout<<"Negative";
	else cout<<"Positive";
	cout<<"\n";

	return 0;
}


Measured memory_bytes: 256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 1001000
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
ll binary(ll a[],ll n,ll key)
{
    ll l=0,r=n-1,mid;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(a[mid]==key)
            return mid;
        else if(a[mid]>key)
            r=mid-1;
        else
            l=mid+1;
    }
    return -1;
}
ll lowerbound(ll a[],ll n,ll key)
{
    ll l=0,r=n-1,mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(a[mid]==key)
        {
            r=mid-1;
            ans=mid;
        }
        else if(a[mid]<key)
            l=mid+1;
        else
            r=mid-1;
    }
    return ans;
}
ll upperbound(ll a[],ll n,ll key)
{
    ll l=0,r=n-1,mid,ans=-1;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(a[mid]==key)
        {
            ans=mid;
            l=mid+1;
        }
        else if(a[mid]>key)
            r=mid-1;
        else
            l=mid+1;
    }
    return (ans+1==n?-1:ans+1);
}
vector<ll> g[2001];
ll shor[10000];
void bfs(ll source,map<ll,vector<pll>> &m)
{
    queue<ll> q;
    ll dist[2001];
    ll vis[2001]={0};
    dist[source]=0;
    q.push(source);
    vis[source]=1;
    while(q.size()!=0)
    {
        ll f=q.front();q.pop();
        for(auto it:g[f])
        {
            if(!vis[it])
            {
                vis[it]=1;
                dist[it]=dist[f]+1;
//                cout<<"source= "<<source<<" distit= "<<dist[it]<<endl;
                if(source<it)
                    shor[dist[it]]++;
                q.push(it);
                m[source].pb({it,dist[it]});
            }
        }
    }
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin.sync_with_stdio(false);
    ll t;
    t=1;
//    cin>>t;
    while(t--)
    {
        ll n;cin>>n;
        for(ll i=1;i<n;i++)
        {
            g[i].push_back(i+1);
            g[i+1].pb(i);
        }
        ll x,y;cin>>x>>y;
        g[min(x,y)].pb(max(x,y));
        map<ll,vector<pll>> m;
        for(ll i=1;i<=n;i++)
            bfs(i,m);
        for(ll i=1;i<n;i++)
        {
            cout<<shor[i]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 64640
N,M = map(int,input().split())

from collections import defaultdict

sc = defaultdict(set)

for _ in range(M):
    s,c = map(int,input().split())

    sc[s].add(c)

ans = ""

if N == 1:
    if len(sc[1]) > 1:
        print(-1)
    elif len(sc[1]) == 1:
        tmp = sc[1].pop()
        print(tmp)
    else:
        print(0)
    exit()

for i in range(1,N+1):
    if len(sc[i]) > 1:
        print(-1)
        exit()
    elif len(sc[i]) == 1:
        tmp = sc[i].pop()
        if i == 1 and tmp == 0:
            print(-1)
            exit()
        else:
            ans += str(tmp)
    else:
        if i == 1:
            ans += "1"
        else:
            ans += "0"

print(ans)

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

int main()
{
    string a;
    string b;
    string c;
    cin>>a;
    cin>>b;
    string::iterator it;
    int i;
    for(i=0;i<b.size();i++){
        c=b.substr(b.size()-1,1);
        b=b.substr(0,b.size()-1);
        b=c+b;
        if(b==a){
            cout<<"Yes";
            break;
        }
    }
    if(i==b.size())
        cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define float long double 

int32_t main()
{
  IOS;
  int a;
  cin>>a;

  cout<<(a+a*a+a*a*a)<<endl;
  return 0;
}

Measured memory_bytes: 3492
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	string s;
	cin>>s;
	int cnt=0;
	int ans=0;
	REP(i,s.size()){
		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') cnt++;
		else{
			ans=max(cnt,ans);
			cnt=0;
		}
	}
	ans=max(cnt,ans);
	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 2e5+10;
const int MAXQ = 2e5+10;

int n, q;
int a[MAXN], b[MAXN], p[MAXQ], x[MAXQ];
bool visited[MAXN];
ll cnt[MAXN];
vector<int> graph[MAXN];

void dfs(int cur) {
  visited[cur] = true;
  for (int i=0;i<graph[cur].size();i++) {
    int next = graph[cur][i];
    if (!visited[next]) {
      cnt[next] += cnt[cur];
      dfs(next);
    }
  }
}

void solve() {
  for (int i=0;i<n-1;i++) {
    graph[a[i]].push_back(b[i]);
    graph[b[i]].push_back(a[i]);
  }
  for (int i=0;i<q;i++) {
    cnt[p[i]] += x[i];
  }
  dfs(0);
  for (int i=0;i<n;i++) {
    if (i) {
      cout << " ";
    }
    cout << cnt[i];
  }
  cout << endl;
}

int main() {
  cin >> n >> q;
  for (int i=0;i<n-1;i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  for (int i=0;i<q;i++) {
    cin >> p[i] >> x[i];
    p[i]--;
  }
  solve();
}


Measured memory_bytes: 27520
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int a,b;
    scanf("%d%d", &a, &b);
    if((a+b)%2==0) {
        printf("%d\n", (a+b)/2);
    }
    else {
        printf("IMPOSSIBLE\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main() {
  int a,b,c,d,e;
  scanf("%d", &a);
  b=a/1000;
  c=(a-b*1000)/100;
  d=(a-b*1000-c*100)/10;
  e=a%10;
  if(b==c || c==d || d==e){
 printf("Bad");
}else{
  printf("Good");
}
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){return powm(a,m-2,m);}int main()
{
fastIO
ll n,m,i,j,k,x,y,z,t,e,f,p,q,g,l,r,o,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>n;
if(n==1)
{
  cout<<"0\n";
  return 0;
}
p=powm(10,n);
q=powm(9,n);
q*=2;
q%=MOD;
a=powm(8,n);
sum=p+a;
sum%=MOD;
sum=(sum-q+MOD)%MOD;
cout<<sum;
}


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

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

    vector<vector<int>> D(N, vector<int>(2));
    rep(i, N) rep(j, 2) cin >> D.at(i).at(j);

    int cnt = 0;

    int max_cnt = 0;
    rep(i, N)
    {
        if (D.at(i).at(0) == D.at(i).at(1))
        {
            cnt++;
        }
        else
        {
            max_cnt = max(max_cnt, cnt);
            cnt = 0;
        }
    }
    max_cnt = max(max_cnt, cnt);

    cout << (max_cnt >= 3 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
  int m,n;
  cin >> m >> n;
  vector<int> a(m);
  for(int i=0;i<m;i++) cin >> a[i];
  sort(a.begin(),a.end());
  priority_queue<int, vector<int>, greater<int>> b;
  for(int i=0;i<m-n+1;i++){
    b.push(a[i+n-1]-a[i]);
  }
  cout << b.top() <<endl;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1_000_000_007
#define INF 10*10
#define EPS 1e-9

//----***パーツ***----
#define fr first
#define se second

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

int N,M,K;
string S;

signed main(){
  cin>>N;
  print((2*N*3.1415926535))

}


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

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define endl '\n'
#define int ll

const double PI = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;
const int MX = 777777 + 5;
const int mod = 1777777777;
const double EPS = 1e-10;
const ll MXP = 8999251775770639633;

inline int len(string s){return s.size();}
inline int len(int* A){return (sizeof(A))/sizeof(A[0]);}
template <typename T>inline int len(vector<T> v){return v.size();}
template <typename T>inline int len(set<T> v){return v.size();}
template <typename T,typename S>inline int len(map<T,S> v){return v.size();}

int fac[MX+5];
int power(int x, int y, int p)
{
    int res = 1;

    x = x % p;

    while (y)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}

int C(int n, int r, int p)
{
    if (r==0)
        return 1;

    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}

void init(int mod){
    fac[0] = 1;
    for (int i=1 ; i<=MX; i++)
        fac[i] = fac[i-1]*i%mod;
}

int CC(int a, int b){
    int res = 1;
    rep(i,a+1,a-b+1)res *= i,res/=a-i+1;
//    rep(i,1,b+1)res /= i;
    return res;
}

bool equal(double a, double b) {
    return std::fabs(a - b) < std::numeric_limits<double>::epsilon();
}


void _() {
    int n;
    cin >> n;
    int a;
    cin >> a;
    for (int i = 1; i < n; ++i) {
        int t;
        cin >> t;
        a = __gcd(a,t);
    }
    cout << a;

};

#undef int
int main() {
#if __MINGW32__
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Input.txt", "r", stdin);
    freopen("C:\\Users\\hiroo\\CLionProjects\\competitive\\Output.txt", "w", stdout);

#endif

    _();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


}

Measured memory_bytes: 256
N = int(input())

a = list(map(int,input().split()))

x = {}

for i in range(N):

    ai = a[i]

    temp = x.get(ai-1, 0)
    temp += 1
    x[ai-1] = temp

    temp = x.get(ai, 0)
    temp += 1
    x[ai] = temp

    temp = x.get(ai+1, 0)
    temp += 1
    x[ai+1] = temp

X = max(x.values())
print(X)


Measured memory_bytes: 18760
#include <stdio.h>

#define SIZE 4

int board[SIZE][SIZE];
const int goal[SIZE][SIZE] = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,0}};

void read_board() {
  for (int i = 0; i < SIZE; i++)
    for (int j = 0; j < SIZE; j++)
      scanf("%d", &board[i][j]);
}

void print() {
  for (int i = 0; i < SIZE; i++) {
    for (int j = 0; j < SIZE; j++)
      printf("%2d ", board[i][j]);
    printf("\n");
  }
}

void find(int num, int *row, int *col) {
  for (int i = 0; i < SIZE; i++) {
    for (int j = 0; j < SIZE; j++) {
      if (board[i][j] == num) {
        *row = i;
        *col = j;
      }
    }
  }
}

void switch_board(int row1, int col1, int row2, int col2) {
  int tmp = board[row1][col1];
  board[row1][col1] = board[row2][col2];
  board[row2][col2] = tmp;
}

int get_distance() {
  int sum = 0;
  int d[SIZE*SIZE][2];
  for (int i = 0; i < SIZE; i++) {
    for (int j = 0; j < SIZE; j++) {
      d[board[i][j]][0] = i;
      d[board[i][j]][1] = j;
    }
  }
  for (int i = 0; i < SIZE; i++) {
    for (int j = 0; j < SIZE; j++) {
      d[goal[i][j]][0] -= i;
      d[goal[i][j]][1] -= j;
    }
  }
  for (int i = 1; i < SIZE*SIZE; i++) {
    if (d[i][0] >= 0) sum += d[i][0]; else sum -= d[i][0];
    if (d[i][1] >= 0) sum += d[i][1]; else sum -= d[i][1];
  }
  return sum;
}

const int NOT_FOUND = 0;
const int FOUND = 1;

const int INITDIR = 0, N = 1, S = 2, W = 3, E = 4;

int iddfs(int step, int max, int row, int col, int dir) {
  if (step == max) {
    for (int i = 0; i < SIZE; i++)
      for (int j = 0; j < SIZE; j++)
        if (board[i][j] != goal[i][j]) return NOT_FOUND;
    return FOUND;
  }

  if (step + get_distance() > max) return NOT_FOUND;

  if (dir != W && row > 0) {
    switch_board(row, col, row-1, col);
    if (iddfs(step + 1, max, row-1, col, E) == FOUND) return FOUND;
    switch_board(row, col, row-1, col);
  }
  if (dir != E && row < 3) {
    switch_board(row, col, row+1, col);
    if (iddfs(step + 1, max, row+1, col, W) == FOUND) return FOUND;
    switch_board(row, col, row+1, col);
  }
  if (dir != S && col > 0) {
    switch_board(row, col, row, col-1);
    if (iddfs(step + 1, max, row, col-1, N) == FOUND) return FOUND;
    switch_board(row, col, row, col-1);
  }
  if (dir != N && col < 3) {
    switch_board(row, col, row, col+1);
    if (iddfs(step + 1, max, row, col+1, S) == FOUND) return FOUND;
    switch_board(row, col, row, col+1);
  }
  return NOT_FOUND;
}

int main() {
  int row, col, i;
  read_board();
  find(0, &row, &col);
  for (i = 0; i <= 45; i++)
    if (iddfs(0, i, row, col, INITDIR) == FOUND) break;
  printf("%d\n", i); 
  return 0;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e2 + 10;

int N, Nr[MAX_N];
int main() {
	cin >> N;
	ll sum = 0;
	for(int i=1; i<=N; i++) scanf("%d", &Nr[i]), sum += Nr[i];
	int Q; cin >> Q;
	while(Q--) {
		int x, v; scanf("%d%d", &x, &v);
		printf("%lld\n", sum - Nr[x] + v);
	}
	return 0;
}


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

using namespace std;

int main()
{
    int x, y, n, m, a, ok=0;
    cin>>n>>m>>x>>y;
    int v[n], g[m];
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    for(int i=0; i<m; i++)
        cin>>g[i];
    sort(v, v+n);
    sort(g, g+m);

    for(int i=x+1; i<=y; i++){
        if(i>v[n-1] && i<=g[0]){
            ok=1;
            break;
        }
    }


    if(ok==0)
    cout<<"War";
    else
        cout<<"No War";

    return 0;
}


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

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

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
            _out.println(0);
            return;
        }
        if (A == B && B == C) {
            _out.println(-1);
            return;
        }

        long cnt = 0;
        while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
            int ta = B / 2 + C / 2;
            int tb = A / 2 + C / 2;
            int tc = A / 2 + B / 2;
            A = ta;
            B = tb;
            C = tc;
            ++cnt;
        }
        _out.println(cnt);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 25428
extern crate core;

use std::str::FromStr;
use std::fmt;
use std::cmp::{Ordering, max};
use std::fmt::{Display, Error, Formatter};

macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}

macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn main() {
    let_all!(n: usize);
    let mut count = vec![0 as i32; n + 1];
    for _ in 0 .. n {
        let_all!(a: usize, b: usize);
        if a <= n + 1 {
            count[a - 1] += 1;
        }
        if b <= n {
            count[b] -= 1;
        }
    }
    let mut max = 0;
    for i in 1 .. n + 1 {
        count[i] += count[i - 1];
        if count[i] >= i as i32 {
            max = i;
        }
    }
    println!("{}", max);
}



Measured memory_bytes: 5056