akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
using namespace std;



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

    for(int i = x - k + 1; i < x; i++){
        cout << i << " ";
    }
    for(int i = x; i < k + x; i++){
        if(k + x == i) cout << i << endl;
        else cout << i << " ";
    }

    return 0;
}



Measured memory_bytes: 3552
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n;
long long a[N];
long long b[N];
long long ans[N];

int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i++){
        scanf("%lld" , &a[i]);
        b[i] = a[i] + a[i];
    }
    long long totSUM = 0;
    for(int i = 1; i <= n; i++){
        totSUM += b[i];
    }
    totSUM /= 2;
    for(int i = 1; i <= n - 2; i += 2){
        totSUM -= b[i];
    }
    long long e = totSUM;
    ans[n] = e;
    for(int i = n - 1; i >= 1; i--){
        ans[i] = b[i] - ans[i + 1];
    }
    for(int i = 1; i <= n; i++){
        printf("%lld " , ans[i]);
    }

}

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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> fi(H);
  for (int i = 0; i < H; ++i) cin >> fi[i];
  
  int res = 0;
  for (int bh = 0; bh < (1<<H); ++bh) {
    for (int bw = 0; bw < (1<<W); ++bw) {
      int cnt = 0;
      for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W; ++w) {
          if (bh & (1<<h)) continue;
          if (bw & (1<<w)) continue;
          if (fi[h][w] == '#') ++cnt;
        }
      }
      if (cnt == K) ++res;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
	for (int i = 0; i < 3; i++)cin >> a[i];
	sort(a,a+3);
	for (int i = 0; i < 3 - 1; i++)cout << a[i] << " ";
	cout << a[2] << endl;
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

typedef long long ll;

using namespace std;

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

	vector<int> nums;

	while (n--) {
		cin >> num;
		nums.push_back(num);
	}
	int ans = 0;
	sort(nums.begin(), nums.end());
	for (int i = 0; i < k; i++) {
		ans += nums[i];
	}

	cout << to_string(ans) << endl;
	return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
int n;
ll l,t,x[N],w[N];
pair<ll,int> pos[N];
int main() {
	scanf("%d%lld%lld",&n,&l,&t); l*=10; t=t*10-1;
	rep(i,0,n) {
		scanf("%lld%lld",x+i,w+i); x[i]*=10;
		pos[i]=mp((w[i]==1?(x[i]+t):(x[i]-t)%l+l)%l,i);
	}
	bool gg=0;
	if (w[0]==2) {
		gg=1;
		rep(i,0,n) x[i]=l-x[i],w[i]^=3;
		rep(i,1,n) x[i]+=l;
	}
	sort(pos,pos+n);
	ll hit=0;
	rep(i,0,n) if (w[i]!=w[0]) {
		hit+=(2*t+l-1-(x[i]-x[0]))/l;
	}
	int sf=0;
//	printf("%lld\n",hit);
	rep(i,0,n) if (pos[i].se==0) {
		if (gg) sf=(i+hit)%n; else sf=(i-hit)%n;
	}
	if (sf<0) sf+=n;
	rep(i,0,n) {
		printf("%lld\n",(pos[(sf+i)%n].fi+1)/10);
	}
}

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

int main() {
  string S;
  cin >> S;
  
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
  long long int i,a,b,v,n,k;
  scanf("%lld%lld",&n,&k);
  a=n/k;
  if((n%k)*2>=k)
    b=a+1;
  else
    b=a;
  v=0;v+=a*a*a;
  if(k%2==0)
    v+=b*b*b;
  printf("%lld",v);}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int n,m;cin>>n>>m;
  int ans=0;
  vector<int> mlist(m,0);
  REP(i,n){
    int k;cin>>k;
    REP(j,k){
      int value;cin>>value;
      mlist[value-1]++;
    }
  }
  REP(i,m){
    if(mlist[i]==n){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int c[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    cout << (c[0][0] - c[1][0] == c[0][1] - c[1][1] && c[0][1] - c[1][1] == c[0][2] - c[1][2] && c[1][0] - c[2][0] == c[1][1] - c[2][1] && c[1][1] - c[2][1] == c[1][2] - c[2][2] ? "Yes" : "No") << endl;
}

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

typedef pair<int, int> Pii;

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



signed main(){

    int N, M;
    cin >> N >> M;

    int ans = 100 * (N - M) + 1900 * M;
    ans = ans << M;

    cout << ans;
    
    return 0;
}


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

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(x >= r && y >= r && (H - r) >= y && (W - r) >= x) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2100
import numpy as np


class mod_calc():
    def __init__(self, divisor, max_n):
        # assume prime
        self._divisor = divisor
        # nsq = math.ceil(math.sqrt(max_n))
        # feature fix_n? max_k?
        fact = np.empty((max_n+1,), dtype=int)
        fact[1] = fact[0] = f = 1
        for i in range(2, len(fact)):
            f = (f * i) % divisor
            fact[i] = f
        self._fact = fact
        fact_inv = np.empty((max_n+1,), dtype=int)
        fact_inv[max_n] = fi = pow(int(fact[max_n]), divisor-2, divisor)
        for i in range(max_n, 2, -1):
            fi = (fi * i) % divisor
            fact_inv[i-1] = fi
        fact_inv[1] = fact_inv[0] = 1
        self._fact_inv = fact_inv

    def comb(self, n, k):
        k = min(k, n-k)
        if k == 0 or k == n:
            return 1
        return self.mul(self._fact[n], self._fact_inv[n-k], self._fact_inv[k])

    def pow(self, a, n):
        return pow(a, n, self._divisor)

    def mul(self, *a):
        # TODO montogomery
        # https://ikatakos.com/pot/programming_algorithm/number_theory/montgomery_multiplication
        r = a[0]
        for m in a[1:]:
            r = (r * m) % self._divisor
        return r

    def sum(self, *a):
        r = a[0]
        for m in a[1:]:
            r = (r + m) % self._divisor
        return r


def main():
    N, M, K = [int(x) for x in input().split()]
    if M == 1:
        if K == N - 1:
            return 1
        else:
            return 0
    if N == 1:
        return M
    c = mod_calc(998244353, N-1)
    count = 0
    for k in range(K+1):
        count = c.sum(c.mul(c.comb(N-1,k), M, c.pow(M-1, N-k-1)), count)
    return count


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 29744
N, K = map(int, input().split())
A = list(map(int, input().split()))

# 合計N+Kこになる


l = 0
r = 2 * 10 ** 9 + 10 ** 6
while r - l > 1:
    m = (r + l) // 2
    cnt = 0
    for a in A:
        cnt += (a + m - 1) // m
    if cnt <= N + K:
        r = m
    else:
        l = m

print(r)

Measured memory_bytes: 94216
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;

    ll mn = q*4;
    mn = min(mn, h*2);
    mn = min(mn, s);
    ll ans = n*mn;
    if (n%2 == 0) ans = min(ans, n*d/2);
    else ans = min(ans, n/2*d+mn);
    
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

int n,m;
int a[100001],b[100001];
vector<int> edges[100001];
int g=0;
int vis[100001];

void bfs(int st){
	queue<int> q;
	vis[st]=1;
	q.push(st);
	while (!q.empty()){
		int x=q.front(); q.pop();
		forn(i,0,edges[x].size()){
			int nx=edges[x][i];
			if (vis[nx]) continue;
			q.push(nx);
			vis[nx]=1;
		}
	}
}

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	cin>>n>>m;
	forn(i,0,m){
		cin>>a[i]>>b[i];
		edges[a[i]].push_back(b[i]);
		edges[b[i]].push_back(a[i]);
	}
	int cnt=0;
	forn(i,1,n+1){
		if (vis[i]) continue;
		cnt++;
		bfs(i);
	}
	cout<<cnt-1<<endl;
	return 0;
}

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

#define ll long long
#define pb push_back
#define mp make_pair

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

	/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r+", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w+", stdout);
	#endif*/

    ll n,k;
    cin >> n >> k;
    ll a1 = n % k;
    ll a2 = k - a1;
    if(a1 > a2) {
    	cout << a2;
    }
    else {
    	cout << a1;
    }
}

Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
void build(){

}
map<LL,LL> M;
int n;
void init(){
  n = getint();
  while( n -- )
    M[ getint() ] ++;
}
void solve(){
  LL ans = 0;
  priority_queue<LL> heap;
  for( auto i : M ){
    if( i.second < 2 ) continue;
    heap.push( i.first );
    if( i.second >= 4 )
      ans = max( ans , i.first * i.first );
  }
  if( heap.size() > 1u ){
    LL a1 = heap.top(); heap.pop();
    LL a2 = heap.top(); heap.pop();
    ans = max( ans , a1 * a2 );
  }
  cout << ans << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;

using namespace std;



int main() {
	int n;
	cin >> n;
	VLL v(n + 5,INF);
	v[0] = 0;
	REP(i, n) {
		ll a;
		cin >> a;
		v[i + 1] = v[i] + a;
	}
	ll ans = INFL;
	FOR(i,2, n-1) {
		ll mi, ma, p, q, r, s;
		mi = v[i];
		ma = v[n] - v[i];
		auto indexp = upper_bound(ALL(v), mi / 2);
		p = v[(indexp-v.begin())-1];
		q = v[i] - p;
		auto indexr = upper_bound(ALL(v), mi + ma / 2);
		r = v[(indexr - v.begin())-1] - mi;
		s = ma- r;
		ans = min(ans, max({ p,q,r,s }) - min({ p,q,r,s }));


		p = v[(indexp - v.begin())];
		q = v[i] - p;
		r = v[(indexr - v.begin()) - 1] - mi;
		s = ma - r;
		ans = min(ans, max({ p,q,r,s }) - min({ p,q,r,s }));


		p = v[(indexp - v.begin()) - 1];
		q = v[i] - p;
		r = v[(indexr - v.begin())] - mi;
		s = ma - r;
		ans = min(ans, max({ p,q,r,s }) - min({ p,q,r,s }));


		p = v[(indexp - v.begin())];
		q = v[i] - p;
		r = v[(indexr - v.begin())] - mi;
		s = ma - r;
		ans = min(ans, max({ p,q,r,s }) - min({ p,q,r,s }));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#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 dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    string a, b;
    cin >> a >> b;
    rep(i, min(a.size(), b.size())) cout << a[i] << b[i];
    if(a.size() > b.size()) cout << a.back();
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
Iq=list(i for i in range(1,N+1))
Ip=list(i for i in range(1,N+1))

import math

q = 0
p = 0

for i in range(N):
    q += Iq.index(Q[i])*math.factorial(N-i-1)
    p += Ip.index(P[i])*math.factorial(N-i-1)
    Iq.remove(Q[i])
    Ip.remove(P[i])

print(max(p-q,q-p))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#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 pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n,m;cin >> n >> m;
    vector<deque<ll>> g(n);
    rep(i,n){
        rep(j,m){
            ll a;cin >> a;
            g[i].pb(a);
        }
    }
    ll ans=inf;
    set<ll> st;
    rep(i,m){
        rep(j,n){
            while(st.count(g[j].front())){
                g[j].pop_front();
            }
        }
        map<ll,ll> mp;
        rep(j,n){
            mp[g[j].front()]++;
        }
        ll del=-1,pp=-1;
        for(auto p:mp){
            if(chmax(pp,p.se))del=p.fi;
        }
        chmin(ans,pp);st.ins(del);
    }
    cout << ans <<endl;
} 

Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
#define mode 1000000007
#define ll long long
char s[100010]; ll dp[100001][13];//i代表前几个字符组成，j代表模13的余数
int main()
{
    scanf("%s",s);
   int n=strlen(s);
    memset(dp,0,sizeof(dp));
    if(s[0]=='?')
    {
        for(int i=0; i<10; i++)
            dp[0][i]=1;//1个字符组成的数字模13余数为i的个数
    }
    else
    dp[0][s[0]-'0']=1;
   // cout<<"sdf"<<endl;
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<13;j++)//遍历前一个状态的余数
        {
            if(s[i]!='?')
            {
                int y=j*10+(s[i]-'0');
                dp[i][y%13]=(dp[i][y%13]+dp[i-1][j])%mode;//更新
                continue;//不用枚举0->9
            }

           for(int k=0;k<=9;k++)
            {
                int y=j*10+k;
                dp[i][y%13]=(dp[i][y%13]+dp[i-1][j])%mode;//更新
            }
        }
    }

    cout<<dp[n-1][5]<<endl;
    return 0;
}


Measured memory_bytes: 10496
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  100005
#define mod 1000000007
#define PII pair<int, int>
#define lowbit(x) (x&-x)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int c[4][4];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug1
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
#endif

	int d, sum = 0;
	for (int i = 1; i <= 3; i++)
		for (int j = 1; j <= 3; j++)
			cin >> c[i][j];
	int a1, a2, a3, b1, b2, b3, f = 0;
	for (int i = -1000; i <= 1000; i++)
	{
		a1 = i;
		b2 = c[1][2] - a1;
		b3 = c[1][3] - a1;
		b1 = c[1][1] - a1;
		a2 = c[2][1] - b1;
		a3 = c[3][1] - b1;
		if (c[2][2] == a2 + b2 && c[2][3] == a2 + b3 && c[3][2] == a3 + b2 && c[3][3] == a3 + b3)
		{
			f = 1;
			break;
		}
	}
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

using namespace std;


struct CWW{CWW(){ios::sync_with_stdio(false);cin.tie(0);}}cww;

typedef __int128 Int;
typedef long long LL;
typedef vector<int> V;
typedef vector<LL> VL;
typedef vector<Int> VI;
map<Int,int> pos;
map<Int,LL> memo;
Int allbit;
LL sum(VL &v){
    LL res=0;
    for(auto &it:v)res+=it;
    return res;
}
template<typename T>
ostream& operator<<(ostream& os,vector<T> v){
    for(auto &it:v)os<<it<<" ";
    return os;
}
void dfs(Int used,VI& exists,V &vv,VL val,vector<VL>& edge){
    Int rest=allbit&(~used);
    for(auto &it:vv)rest&=exists[it];
    //cout<<vv<<endl;
    while(rest){
	Int nowbit=rest&(-rest);
	rest-=nowbit;
	if(memo.count(nowbit|used))continue;
	int nowpos=pos[nowbit];
	auto nxtval=val;
	nxtval[nowpos]=1145141919;
	for(auto &it:vv){
	    nxtval[it]=min(nxtval[it],edge[it][nowpos]);
	    nxtval[nowpos]=min(nxtval[nowpos],edge[it][nowpos]);
	}
	memo[nowbit|used]=sum(nxtval);
	vv.push_back(nowpos);
	dfs(used|nowbit,exists,vv,nxtval,edge);
	vv.pop_back();
    }
}

int main(){
    int N,M;
    cin>>N>>M;
    VI exists(N,0);
    vector<VL> edge(N,VL(N,0));
    Int bit=1;
    for(Int i=0;i<N;i++,bit<<=1){
	pos[bit]=i;
    }
    allbit=bit-1;
    while(M--){
	int a,b,c;
	cin>>a>>b>>c;
	a--,b--;
	edge[a][b]=c;
	edge[b][a]=c;
	exists[a]|=((Int)1)<<b;
	exists[b]|=((Int)1)<<a;
    }
    for(int i=0;i<N;i++){
	vector<int> vv(1,i);
	VL val(N,0);
	val[i]=1145141919;
	dfs(((Int)1)<<i,exists,vv,val,edge);
    }
    LL res=0;
    for(auto &it:memo)res=max(res,it.second);
    cout<<res<<endl;
    return 0;
}

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

int main() {
    int64_t h, k=0, ans;
    cin >> h;
    for (int i = 1; i < 61; i++) {
        if (h < pow(2, i)) {
            k = i-1;
            break;
        }
    }
    ans = 1;
    for (int i = 0; i < k; i++)
        ans = ans*2 + 1;
    cout << ans << endl;
}

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

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			string s = Console.ReadLine();
			int k = int.Parse(Console.ReadLine());

			HashSet<string> map = new HashSet<string>();
			for (int j = 0; j < s.Length; j++) {
				for (int i = 1; i <= s.Length - j && i <= 5; i++) {
					//System.Diagnostics.Debug.WriteLine($"{j},{i} = {s.Substring(j, i)}");
					map.Add(s.Substring(j, i));
				}
			}
			string ans = map.OrderBy(p => p, StringComparer.Ordinal).Skip(k - 1).First();
			Console.WriteLine(ans);

		}
	}
}


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

using namespace std;

int main()
{
	long long a,b,t;
	cin >> a >>b;
	if (a%b==0) cout << 0;
	else {
        long long n=a;
        while (n/b!=0) a%=b,n/=b;
        cout << min(a,abs(a-b));
	}
}


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

const int MAX = 110000;
const int MOD = 1000000007;

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

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

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> nums(N);
    for (int i = 0; i < N; i++)
    {
        ll A;
        cin >> A;
        nums.at(i) = A;
    }
    COMinit();
    sort(nums.begin(), nums.end());
    if(nums.at(0) < 0){
        ll firstNum = nums.at(0);
        for(int i = 0; i < N; i++){
            nums.at(i) += firstNum;
        }
    }
    ll answer = 0;
    for (int i = K - 1; i < N; i++)
    {
        answer = (answer + COM(i, K - 1) * nums.at(i)) % MOD;
    }
    for (int i = 0; i < N - K + 1; i++)
    {
        answer = (answer - ((COM(N - i - 1, K - 1) * nums.at(i)) % MOD) + MOD) % MOD;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
	int n, m, D[200001], T[200000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", D + i);
	sort(D, D + n);
	D[n] = 1000000001;
	scanf("%d", &m);
	for (int i = 0; i < m; i++)
		scanf("%d", T + i);
	sort(T, T + m);

	int offset_n = 0, offset_m = 0;
	for (; offset_m < m && offset_n < n; offset_m++) {
		while (D[offset_n] < T[offset_m])
			offset_n++;
		if (D[offset_n] != T[offset_m])
			break;
		offset_n++;
	}

	if (offset_m == m)
		printf("YES\n");
	else
		printf("NO\n");
}

Measured memory_bytes: 1664
//                      YATIN KWATRA

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long 
#define ld                      long double
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                      vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                      unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795
// #define node                    Node

using namespace std;

void INPUT() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


void solve()
{ 

        int n,m;
        cin >> n >> m;

        int x = 2*n - m/2;
        int y = n - x;

        if(x>=0 and y>=0 and (x+y) == n and (2*x+4*y)==m) cout << "Yes\n";
        else cout << "No\n";
    
       
}
int main() {
    
    FIO
    INPUT();
    
    int t;
    t = 1;
 //   cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

void func_A() {

    string s;
    cin >> s;

    if (s == "ABC") cout << "ARC";
    else cout << "ABC";
}

void func_B() {

}

void func_C() {

}

int main() {

    func_A();
    //func_B();
    //func_C();

    return 0;

}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 200005;

int n,Q;
int fa[MAXN];
int a[MAXN];
int b[MAXN];
int c[MAXN];
int sz[MAXN];

ll m;

int getroot(int p)
{
	return p == fa[p] ? p : fa[p] = getroot(fa[p]);
}

int main()
{
	scanf("%d%lld%d",&n,&m,&Q);
	for (int i = 1;i <= n;i++)
		fa[i] = i;
	for (int i = 1;i <= Q;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		a[i]++,b[i]++;
		if (c[i] == 0)
		{
			if (getroot(a[i]) != getroot(b[i]))
				m--;
			fa[getroot(a[i])] = getroot(b[i]);
		}
	}
	bool any1 = 0;
	for (int i = 1;i <= Q;i++)
		if (c[i] == 1)
		{
			any1 = 1;
			a[i] = getroot(a[i]);
			b[i] = getroot(b[i]);
			if (a[i] == b[i])
			{
				puts("No");
				return 0;
			}
		}
	for (int i = 1;i <= n;i++)
		sz[getroot(i)]++;
	ll t = 0;
	for (int i = 1;i <= n;i++)
		t += (sz[i] > 0);
	if (m > t * (t - 1) / 2 || (t == 2 && any1) || m < t - 1 + any1)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int n, m;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> m;
  int r = INF, l = 0;
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    chmax(l, a);
    chmin(r, b);
  }
  cout << (r - l + 1 > 0 ? r - l + 1 : 0) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<set>
#define psi pair<string, int>

using namespace std;

bool check(string str){
    return (str[0]!=str[1]);
}

bool same(string str){
    for(int i=0; i<str.size(); i++){
        if(str[0]!=str[i]) return false;
    }
    return true;
}

char getColor(string str){
    char c1=min(str[0], str[1]);
    char c2=max(str[0], str[1]);
    if(c1=='b'&&c2=='g') return 'r';
    if(c1=='b'&&c2=='r') return 'g';
    if(c1=='g'&&c2=='r') return 'b';
}
int solve(string str){
    queue<psi> qu;
    qu.push(psi(str, 0));
    set<string> done;

    while(!qu.empty()){
        psi w=qu.front(); qu.pop();
        string s=w.first;
        done.insert(s);

        if(same(s)){
            return w.second;
        }

        for(int i=0; i<s.size()-1; i++){
            if(check(s.substr(i, 2))){
                char new_color=getColor(s.substr(i, 2));
                string nx=s;
                nx[i+1]=nx[i]=new_color;
                if(done.count(nx)==1) continue;
                //cout<< nx<< endl;
                qu.push(psi(nx, w.second+1));
                done.insert(nx);
            }
        }
    }
    return -1;
}
int main(){

    while(1){
        string s;
        cin>> s;
        if(s=="0") break;

        int ans=solve(s);
        if(ans==-1){
            cout<< "NA"<< endl;
        }else{
            cout<< ans<< endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4548
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int A, B; cin >> A >> B;

    int ans = -1;

    if (A < B) {
        if ((B - A) % 2 == 0) ans = A + (B - A) / 2;
    } else if (A > B) {
        if ((A - B) % 2 == 0) ans = B + (A - B) / 2;
    }

    if (ans < 0) cout << "IMPOSSIBLE" << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	char c; cin >> c;
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') puts("vowel");
	else puts("consonant");
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i=0; i<n; i++)
        cin>>h[i];
    vector<int> cost(n,INT_MAX);

    cost[0]=0;
    cost[1]=abs(h[0]-h[1]);

    for(int i=2; i<n; i++)
    {
        for(int j=1; j<=k && i-j >=0; j++)
        {
            cost[i] = min( cost[i], abs(h[i]-h[i-j])+cost[i-j]);
        }
    }   
    cout<<cost[n-1];
    return 0;
} 

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> pii;

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<pii> v[n+1];
    vector<pair<pii,int>> vp;
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        vp.push_back({{a,b},c});
        v[a].push_back({b,c});
        v[b].push_back({a,c});
    }
    for(int i = 0; i < k; i++){
        int x;  cin >> x;
        v[0].push_back({x,0});
    }
    vector<int> dp(n+1, 1<<30);
    dp[0] = 0;
    priority_queue<pii> pq;
    pq.push({-0, 0});
    while(!pq.empty()){
        pii p = pq.top();   pq.pop();
        int pos = p.second, cost = -p.first;
        if(dp[pos] != cost) continue;
        for(pii q : v[pos]){
            int next = q.first;
            if(dp[next] > dp[pos]+q.second){
                dp[next] = dp[pos]+q.second;
                pq.push({-dp[next], next});
            }
        }
    }
    int ret = 0;
    for(int i = 0; i < m; i++){
        int a = vp[i].first.first, b = vp[i].first.second, c = vp[i].second;
        ret = max(ret, (dp[a]+dp[b]+c+1)/2);
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 6944
#include<bits/stdc++.h>
using namespace std;
const int Maxn=1e5+10;
int n,a[Maxn],ans;
map <int,int> mp;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();++it){
		if((it->first)>(it->second))
			ans+=it->second;
		else
			ans+=(it->second)-(it->first);
	}
	cout<<ans;

}


Measured memory_bytes: 5120
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc076_a.cpp
 * time   : Wed Apr 29 15:57:33 2020
 * quest  : A - Rating Goal
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  float r, g;
  cin >> r >> g;
  cout << (2 * g) - r << "\n";
  return 0;
}


Measured memory_bytes: 256
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = il()
    print(min(A*N, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_V = 410;

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

    vvl dist(MAX_V, vl(MAX_V));  // dist[v][u] : 頂点vと頂点uの最短距離
    rep(v, n) {
        rep(u, n) {
            if(v != u) {
                dist[v][u] = INF;
            }
        }
    }
    
    vvl a(n, vl(n));
    rep(i, n) {
        rep(j, n) {
            cin >> a[i][j];
            if(dist[i][j] > a[i][j]) {
                dist[i][j] = dist[j][i] = a[i][j];
            }
        }
    }
    
    // ワーシャルフロイド法。計算量はO(V^3)
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    ll ans = 0;
    exrep(u, 0, n-2) {
        exrep(v, u+1, n-1) {
            if(dist[u][v] < a[u][v]) {
                out(-1);
                re0;
            }
            bool ok = true;
            rep(w, n) {
                if(w == u || w == v) {
                    continue;
                }
                if(dist[u][w] + dist[w][v] == dist[u][v]) {
                    ok = false;
                }
            }
            if(ok) {
                ans += a[u][v];
            }
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double D;
const ll mod=1e9+7;
const ll inf=(1ll<<62);
ll POW(ll x,ll y){
    if(y==0)return 1;
    if(y==1)return x;
    ll ans=POW(x,y/2)%mod;
    ans*=ans;
    ans%=mod;
    if(y%2)ans*=x;
    return ans%mod;
}
const int MX=70;
char a[MX][MX];
int n,m,dis[MX][MX],vis[MX][MX];
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};
map<pair<int,int>,pair<int,int> >par;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)scanf("%s",&a[i]);
    queue<pair<int,int > >q;
    q.push({0,0});
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)dis[i][j]=MX*MX;
    dis[0][0]=0;
    while(!q.empty()){
        pair<int,int>p=q.front();q.pop();
        int x=p.first;
        int y=p.second;
        if(vis[x][y])continue;
        vis[x][y]=1;
        for(int i=0;i<4;i++){
            int nx=x+dx[i],ny=y+dy[i];
            if(nx>=n||nx<0||ny>=m||ny<0||a[nx][ny]=='#')continue;
            if(dis[nx][ny]<dis[x][y]+1)continue;
            dis[nx][ny]=dis[x][y]+1;
            q.push({nx,ny});
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i][j]=='.')sum++;
        }
    }
    if(dis[n-1][m-1]==MX*MX)puts("-1");
    else cout<<sum-dis[n-1][m-1]-1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;

int P[nmax_def];
pii Psort[nmax_def];
multiset<int> Pbound;

int main() {
	int N;
	ll ans = 0;
	cin >> N;
	rep(i, N) {
		cin >> P[i];
		Psort[i].first = P[i];
		Psort[i].second = i;
	}
	sort(Psort, Psort + N, greater<pii>());
	Pbound.insert(-1);
	Pbound.insert(-1);
	Pbound.insert(N);
	Pbound.insert(N);
	rep(j, N) {
		int i = Psort[j].second;
		int Ptmp = P[i];
		auto itr = Pbound.lower_bound(i);
		int R1 = *itr;
		++itr;
		int R2 = *itr;
		--itr;
		--itr;
		int L1 = *itr;
		--itr;
		int L2 = *itr;
		ans += Ptmp * ((ll)(i - L1) * (ll)(R2 - R1) + (ll)(R1 - i) * (ll)(L1 - L2));
		Pbound.insert(i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6144
import java.util.Scanner;

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

        sc.close();

        if ((n % 500) <= a) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
k,n = map(int,input().split())
a = map(int, input().split())
a = list(a)
p = 0
s = 0
for i in range(n-1):
    q = a[i+1] - a[i]
    if q > p:
        p = q
        s = i
if k-a[n-1]+a[0] > p:
    s = n-1
    p = k-a[n-1]+a[0]
    print(a[n-1]-a[0])
    exit()
print(k-(a[s+1]-a[s]))


Measured memory_bytes: 26444
r,c=map(int,input().split())
meiro=[list(input()) for i in range(r)]
#迷路の白マスを数える作業
white=[]
for i in range(r):
    for j in range(c):
        if meiro[i][j]==".":
            white.append([i+1,j+1])
#迷路の外を＃で囲む
for i in range(r):
    meiro[i].insert(c,"#")
    meiro[i].insert(0,"#")
meiro.insert(0,["#"]*(c+2))
meiro.append(["#"]*(c+2))
#print(meiro)
def bfs(sx,sy):
    idou=[[0,1],[0,-1],[1,0],[-1,0]]
    tesuu=[[-1]*(c+2) for i in range(r+2)]
    from collections import deque
    tesuu[sx][sy]=0
    #print(tesuu)
    quest=deque([[sx,sy]])#最初に見る場所
    while len(quest)!=0:
        see=quest.popleft()
        for i in idou:
            if meiro[see[0]+i[0]][see[1]+i[1]]=="#":
                continue
            if tesuu[see[0]+i[0]][see[1]+i[1]]!=-1:
                continue
            quest.append([see[0]+i[0],see[1]+i[1]])
            tesuu[see[0]+i[0]][see[1]+i[1]]=tesuu[see[0]][see[1]]+1
    import itertools
    tesuu=list(itertools.chain.from_iterable(tesuu))
    return max(tesuu)
tesuu_=[]
for i in range(len(white)):
    tesuu_.append(bfs(white[i][0],white[i][1]))
print(max(tesuu_))


Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  vector<string> v(n);
  for(int i=0;i<n;i++)
    cin>>v.at(i);
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++)
    cout<<v.at(i);
  cout<<endl;
}

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

void exec(int n);

int main() {
  int tmp;
  while (1) {
    cin >> tmp;
    if (tmp == 0) {
      break;
    }
    exec(tmp);
  }
}

void exec(int n) {
  vector<int> scores(n);
  for (int i = 0; i < n; i++) {
    cin >> scores[i];
  }

  int min_diff = 1000000;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j)  {
        int diff = abs(scores[i] - scores[j]);
        min_diff = min_diff > diff ? diff : min_diff;
      }
    }
  }
  cout << min_diff << endl;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define end end()
#define vec vector<ll>
#define se set<ll>
#define mults multiset<ll>
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b
#define get(a) cin>>a
#define nextl cout<<endl
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
   int n;
   get(n);
   double x;
   if(n%2!=0) x=(n/2)+1;
   else x=n/2;
   double ans=(x/n);
   printf("%0.10f",ans);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "vector"

using namespace std;

int main(int argc, char const *argv[]) {

  vector<vector<int> > a(2, vector<int>());
  vector<int> t1, t2;
  int n;
  int tmp;

  t1.push_back(0);
  t2.push_back(0);

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> tmp;
    a[0].push_back(tmp);
    int back = t1.back();
    t1.push_back(tmp + back);
  }
  for(int i = 0; i < n; i++){
    cin >> tmp;
    a[1].push_back(tmp);
    int back = t2.back();
    t2.push_back(tmp + back);
  }


  /*for(int i = 0; i < n; i++){
    cout << t1[i+1] << " ";
  } cout << endl;
  for(int i = 0; i < n; i++){
    cout << t2[i+1] << " ";
  } cout << endl;*/

  int res = t1.front() + t2.back();
  for(int i = 1; i <= n; i++){
    //int amount1 = t1.back() - t1[i];
    int amount2 = t2.back() - t2[i - 1];
    if(t1[i] + amount2 > res){
        res = t1[i] + amount2;
    }
  }

  cout << res << endl;


  /* code */
  return 0;
}

Measured memory_bytes: 256