akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26)cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------//
    vector<P> a;
    rep(i, 26){
        int now = 0;
        rep(j, d)now += s[j][i];
        a.push_back({now, i+1});
    }
    sort(rall(a));
    rep(i, d)cout << a[0].second << endl;
}


Measured memory_bytes: 3680
import sys

input = sys.stdin.readline

def main():
    x = {}
    N = int(input())
    
    for i in range(N):
        s = sorted(input())
        s = ''.join(s)
        if s in x: x[s] += 1
        else: x[s] = 1
    
    ans = 0
    
    for n in x.values():
        ans += (n*(n-1)//2)
        
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 17808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  string S;
  cin >> S;

  int now=0;
  rep(i,sz(S)){
    now+=S.at(i)-'0';
    now%=9;
  }
  if(now==0)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3772
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  --m;
  for (int i = m; i + 1 < n; ++i) {
    if (a[i - m] < a[i + 1]) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define vi vector<int>
#define vii vector<vector<int>>
#define mod 1000000007
#define fo(i,n) for(int i=0;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
typedef long long ll;

void print_Array(int arr[],int start,int end){
    for(int i=start;i<end;i++){
        printf("%d ",arr[i]);
    }
}

void test(){
    ll p,q,x,y,s,l,r,m,n;
    int N,K;
    cin>>N;
    vector<ll> A;
    fo(i,N){
        cin>>p;
        A.push_back(p);
    }
    string S;
    cin>>S;
    set<ll> ltr_moves;
    for(int i=N-1;i>=0;i--){
        x=A[i];
        for(auto it=ltr_moves.rbegin();it!=ltr_moves.rend();it++){
            x=min(x,x^(*it));
        }
        if(x==0) continue;
        if(S[i]=='0'){ ltr_moves.insert(x);}
        else{
            puts("1");
            return;
        }
    }
    puts("0");
}

int main(){
    int p,q,x,y,s,l,r,m,n;
    int N,K;
    int t;
    scanf("%d",&t);
    while(t--){
        test();
    }
    return 0;
}



Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define frn(i,a,n) for(i=a;i<=n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
#define ma 500000
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return power(x*x,n/2);
    else                             //n is odd
        return x*power(x*x,(n-1)/2);
}
int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);  
}
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;  
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}
 
int main()
{
    ll n,i;
    cin>>n;
    string s[n];
    for(i=0;i<n;i++)
    cin>>s[i];
    ll ac=0,tle=0,wa=0,re=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=="AC")
        ac++;
        else if(s[i]=="TLE")
        tle++;
        else if(s[i]=="RE")
        re++;
        else
        wa++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle <<endl;
    cout<<"RE x "<<re<<endl;
return 0;
}


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

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  auto AB = A + B;
  auto CD = C + D;
  cout << ((AB < CD) ? "Right" : ((CD < AB) ? "Left" : "Balanced"));
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
#include<deque>
using namespace std;
int n;
long long a[5005];
int main(){
	int n;
	long long x;
	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i+n]=a[i];
	}
	long long mi=1e18;
	for(int i=0;i<n;i++){
		deque<int> q;
		long long res=0;
		for(int j=n-i;j<n;j++){
			while(!q.empty()&&a[q.back()]>=a[j]) q.pop_back();
			q.push_back(j);
		}
		for(int j=n;j<2*n;j++){
			while(!q.empty()&&q.front()<j-i) q.pop_front();
			while(!q.empty()&&a[q.back()]>=a[j]) q.pop_back();
			q.push_back(j);
			res+=a[q.front()];
		}
		mi=min(mi,res+x*i);
	}
	cout<<mi;
}

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

int n,m;
vector<int> a;

bool isOK(int index, int x){
  if(a[index] <= x) return 1;
  else return 0;
}

int binarysearch(int x){
  int ok = -1, ng=n-1;
  while(ng-ok>1){
    int middle=(ok+ng)/2;
    if(isOK(middle,x)) ok=middle;
    else ng=middle;
  }
  return ok+1;
}

int main(){
  cin>>n>>m;
  a.resize(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  rep(i,m){
    a[n-1]/=2;
    if(n==1) continue;
    int x =a[n-1];
    a.pop_back();
    int index = binarysearch(x);
    a.insert(a.begin()+index,x);
  }
  ll ans=0;
  rep(i,n){
    ans+=a[i];
  }
  cout<<ans<<endl;
}



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

int main(){
  
  int N;
  string S,T;
  bool torf=false;
  int i=0,j=0;
  
  cin >> N >> S >> T;
  
  while(i<N){
  if(T.at(0)==S.at(i)){
    while(j+i<N && T.at(j)==S.at(j+i)){
      if(T.at(N-i-1)==S.at(N-1))
        torf=true;
      
      j++;
    }
    if(torf==true)
      break;
    j=0;
  }
    i++;
  }
  
  
  if(torf==true){
    cout << i+N << endl;
  //cout << i << endl;
  }
  else
    cout << 2*N << endl;
}

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

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,du[N],T[N];
queue <int> q;
vector <int> V[N];
void print(vector<int> v)
{
	for(int i=0;i<v.size();i++)
		printf("%d ",v[i]); puts("");
}
int main()
{
	n=read(); for(int i=2;i<=n;i++)
		T[i]=read(), du[T[i]]++;
	for(int i=1;i<=n;i++) if(!du[i]) q.push(i);
	while(!q.empty())
	{
		int mp=0,lx=q.front();q.pop();
		sort(V[lx].begin(),V[lx].end());
		reverse(V[lx].begin(),V[lx].end());
		for(int i=0;i<V[lx].size();i++)
			mp=max(mp,i+V[lx][i]);
		if(lx==1) cout << mp << endl;
		du[T[lx]]--; V[T[lx]].push_back(mp+1);
		if(!du[T[lx]]) q.push(T[lx]);
	}
	return 0;
}

Measured memory_bytes: 6528
let area =
  [| [1; 3]; [0; 2; 4]; [1; 5]
   ; [0; 4; 6]; [1; 3; 5; 7]; [2; 4; 8]
   ; [3; 7]; [4; 6; 8]; [5; 7] |]

let md = Array.make_matrix 9 9 0

let initialize_md () =
  for i = 0 to 7 do
    for j = 0 to 8 do
      md.(i+1).(j) <- abs (i / 3 - j / 3) + abs (i mod 3 - j mod 3)
    done
  done

let idastar a limit space_i lower goal =
  let rec doit i space_i moved lower =
    if i = limit then begin
      if a = goal then begin
        List.length moved - 1 |> Printf.printf "%d\n"; exit 0
      end;
    end else
      List.iter (fun j ->
        let x = a.(j) in
        if x = List.hd moved then () else
        let lower = lower - md.(x).(j) + md.(x).(space_i) in
        if lower + i > limit then ()
        else begin
          a.(j) <- 0;
          a.(space_i) <- x;
          doit (i + 1) j (x :: moved) lower;
          a.(j) <- x;
          a.(space_i) <- 0;
        end) area.(space_i) in
  doit 0 space_i [-1] lower

let () =
  initialize_md ();
  let a = Array.init 9 (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let rec f i =
    if i = 9 then assert false
    else if a.(i) = 0 then i
    else f (i + 1) in
  let space_i = f 0 in
  let rec g i acc =
    if i = 9 then acc
    else g (i + 1) (acc + md.(a.(i)).(i)) in
  let lower = g 0 0 in
  let goal = [|1; 2; 3; 4; 5; 6; 7; 8; 0|] in
  for limit = lower to 31 do
    idastar a limit space_i lower goal;
  done

Measured memory_bytes: 4376
#include <iostream>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int q;
int n;
int ok[100001];

signed main() {
	int i, j;
	
	for (i = 2; i <= 100000; i++) {
		int yaku = 1;
		for (j = 1; j * j <= i; j++) {
			if (i % j == 0) {
				yaku *= j;
				if (j != i / j && j != 1) yaku *= i / j;
			}
			if (yaku >= 2 * i) break;
		}
		if (yaku >= 2 * i) ok[i] = 1;
	}
	
	for (i = 1; i <= 100000; i++) ok[i] += ok[i - 1];
	
	cin >> q;
	rep(i, q) {
		cin >> n;
		cout << ok[n] << endl;
	}
	return 0;
}


Measured memory_bytes: 3884
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int n,ans=0;
bool used[100]={0};
pair<int,int> x[100],y[100];
int main() {
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i].first>>x[i].second;
	for(int i=0;i<n;i++)cin>>y[i].first>>y[i].second;
	sort(x,x+n);
	sort(y,y+n);
	for(int i=n-1;i>=0;i--){
		int k=999;
		int c=-1;
		for(int j=0;j<n;j++){
			if(x[i].first<y[j].first&&x[i].second<y[j].second&&k>y[j].second&&!used[j]){
				c=j;
				k=y[j].second;
			}
		}
		if(c!=-1){
			used[c]=1;
			ans++;	
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
   char str[21];
   int i;
  
   scanf("%s",str);
   
   i=strlen(str)-1;
   for(;i>=0;i--) {
       printf("%c",str[i]);
   }
   printf("\n");
   
   return 0;
}



Measured memory_bytes: 2032
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 1000009
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
     ll n;
     cin>>n;
     if(n>=30)
        cout<<"Yes\n";
     else cout<<"No\n";

}












Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

ll a, b, c, d;

map<ll, ll> mp;

ll f(ll n) {
    if(n <= 1) return abs(n) * d;
    if(mp.count(n)) {
        return mp[n];
    }
    ll res = inf;
    if(inf / abs(n) > d) chmin(res, abs(n) * d);
    FOR(i, -4, 5) {
        ll m = n + i;
        if(m % 2 == 0 && m / 2 < n) chmin(res, a + abs(i) * d + f(m / 2));
        if(m % 3 == 0 && m / 3 < n) chmin(res, b + abs(i) * d + f(m / 3));
        if(m % 5 == 0 && m / 5 < n) chmin(res, c + abs(i) * d + f(m / 5));
    }
    return mp[n] = res;
}

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

    int t;
    cin >> t;
    while(t--) {
        mp.clear();
        ll n;
        cin >> n >> a >> b >> c >> d;

        cout << f(n) << "\n";
    }

    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int n,k,a,b;
    cin >> n >> k;
    a = n / k;
    b = n % k;
    if(b == 0){
      cout << b << endl;
    }else{
      cout << "1" << endl;
    }

  return 0;
  }

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int mod = 1e9 + 7;
int H, W, A, B;

int fac[300005];
int rev[300005];

int binpow(int x, int p) {
    if (p == 0) return 1;

    if (p % 2 == 0)
        return binpow((x * x) % mod, p / 2);
    else
        return (x * binpow(x, p - 1)) % mod;
}

int nCr(int n, int r) {
    if (r > n) return 0;
    return ((fac[n] * rev[r]) % mod * rev[n - r]) % mod;
}

void precalc(int n) {
    fac[0] = fac[1] = 1;
    FOR(i, 2, n + 2)
    fac[i] = (fac[i - 1] * i) % mod;

    rev[n + 1] = binpow(fac[n + 1], mod - 2) % mod;
    REV(i, n, 0) { rev[i] = (rev[i + 1] * (i + 1)) % mod; }
}

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

    cin >> H >> W >> A >> B;
    precalc(H + W - 2);

    int ans = 0;
    FOR(i, B, W - 1) {
        ans = (ans +
               (nCr(H - A - 1 + i, i) * nCr(A - 1 + W - i - 1, A - 1)) % mod) %
              mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3840
def is_all_switches_on(on_case):
    for i, s in enumerate(S):
        on_switch_num = 0
        for si in s:
            if on_case[si] == '1':
                on_switch_num += 1

        if on_switch_num % 2 != switches[i]:
            return False
    return True

if __name__ == '__main__':
    N, M = map(int, input().split())
    S = []
    for _ in range(M):
        k, *s = map(int, input().split())
        S.append(s)

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

    ans = 0
    for i in range(2 ** N):

        on_case = '0' + bin(i)[2:].zfill(N)
        if is_all_switches_on(on_case):
            ans += 1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator-=(const mint a) {
      if ((x += mod-a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
      if (t&1) a *= *this;
      return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

string s, t;
// dp[上から何桁目][未満フラグ]
mint dp[200200][2];     // 求めたい答え
mint num[200200][2];    // 組み合わせの数

int main() {
    cin >> s >> t;
    int slen = s.length();
    memset(dp, 0, sizeof(dp));
    memset(num, 0, sizeof(num));
    num[0][1] = 1;

    for(int i = 0; i < slen; ++i) {
      int sch = s[i] - '0';
      if(t[i] == '?') {
        // tが?だったとき
        // 未満の時、未満→未満
        for(int d = 0; d <= 9; ++d) {
          dp[i+1][0] += (dp[i][0]*(mint)10 + (mint)d*num[i][0]);
          num[i+1][0] += num[i][0];
        }

        // 一致しているとき、一致→一致or一致→未満
        for(int d = 0; d < sch; ++d) {
          dp[i+1][0] += (dp[i][1]*(mint)10 + (mint)d*num[i][1]);
          num[i+1][0] += num[i][1];
        }
        dp[i+1][1] += (dp[i][1]*(mint)10 + (mint)sch*num[i][1]);
        num[i+1][1] += num[i][1];
        
      }else {
        int tch = t[i] - '0';
        // 未満の時、未満→未満、tchが何であっても処理は一緒
        dp[i+1][0] += (dp[i][0]*(mint)10 + (mint)tch*num[i][0]);
        num[i+1][0] += num[i][0];

        // 一致しているとき、一致→一致or一致→未満
        if(tch == sch) {
          dp[i+1][1] += (dp[i][1]*(mint)10 + (mint)tch*num[i][1]);
          num[i+1][1] += num[i][1];
        }else if(tch < sch) {
          dp[i+1][0] += (dp[i][1]*(mint)10 + (mint)tch*num[i][1]);
          num[i+1][0] += num[i][1];
        }
      }
    }
    mint ans = dp[slen][0] + dp[slen][1];
    cout << ans << endl;
}


Measured memory_bytes: 9852
#include <iostream>
#include <queue>
using namespace std;

int main(){
  int n,k,a,s,m;
  while(cin>>n>>k,n||k){
    a=0;
    queue<int> q;
    n-=k;
    while(k--){
      cin>>s;
      a+=s;q.push(s);
    }
    m=a;
    while(n--){
      cin>>s;
      q.push(s);
      a=a+s-q.front();
      q.pop();
      m=max(m,a);
    }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 1348
N, K = map(int, input().split())
S = input()
ans = 0
temp = 0
for s1, s2 in zip(S, S[1:]):
    temp += 1
    if s1 != s2:
        ans += temp - 1
        temp = 0
ans += temp
ans = min(ans + 2*K, N-1)
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
 
#define ENORMOUS (1<<21)
 
struct Ver{
    int weight;
    int key;
    struct Ver *next;
};
 

 

int n;
int *d;
struct Ver *ver;
  
void Input(int id){
    int k,u,c;
    int i;
 
    scanf("%d",&k);
 
    for(i=0;i<k;i++){
        scanf("%d",&u);
        scanf("%d",&c);
        Create_Vertex(id,u,c);
    }
}
 
void Create_Vertex(int id,int u,int c){
    struct Ver *new,*work;
 
    new=(struct Ver*)malloc(sizeof(struct Ver));
    new->next=NULL;
    new->weight=c;
    new->key=u;
 
    work=&ver[id];
    while(work->next!=NULL) work=work->next;
    work->next=new;
 
}
 
void SSSP(void){
    int S[n];
    int i;
    int s,u;
    struct Ver *work;
 
    for(i=0;i<n;i++){
        S[i]=0;
        d[i]=ENORMOUS;
    }
    s=0;
    d[s]=0;
 
    while(Test_Set(S)==0){
        u=Heap(S);
        S[u]=1;
 
        work=ver[u].next;
        while(work != NULL){
            if(S[work->key]==1){}
            else if(d[u]+work->weight < d[work->key]){
                d[work->key]=d[u]+work->weight;
            }
            work=work->next;
        }
    }
}
 
int Heap(int *S){
    int i;
    int min=ENORMOUS;
    int u;
  
    for(i=0;i<n;i++){
        if(S[i]==1) continue;
          
        if(d[i]<min){
            min=d[i];
            u=i;
        }
    }
  
    return u;
}
 
int Test_Set(int *S){
    int i;
 
    for(i=0;i<n;i++){
        if(S[i]==0) return 0;
    }
    return 1;
}
int main(void){
    int i;
    int id;
 
    scanf("%d",&n);
 
    d=(int*)malloc(sizeof(int)*n);
    ver=(struct Ver*)malloc(sizeof(struct Ver)*n);
    for(i=0;i<n;i++){
        ver[i].weight=-1;
        ver[i].key=-1;
        ver[i].next=NULL;
    }
 
    for(i=0;i<n;i++){
        scanf("%d",&id);
        Input(id);  
    }
 
    SSSP();
 
    for(i=0;i<n;i++) printf("%d %d\n",i,d[i]);
 
    free(d);
 
    return 0;
}
 

Measured memory_bytes: 16220
import fractions
a,b,c,d=map(int,input().split())
cd=int(c*d/(fractions.gcd(c,d)))
#print(cd)
c1=b//c
c2=(a-1)//c
c3=c1-c2
d1=b//d
d2=(a-1)//d
d3=d1-d2
cd1=b//(cd)
cd2=(a-1)//(cd)
cd3=cd1-cd2
print((b-a+1)-(c3+d3-cd3))
#print(str(c3)+" "+str(d3)+" "+str(cd3))

Measured memory_bytes: 5756
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

#define INF 1000000000000000000

int h[100010];
ll dp[100010];

void Main()
{
	int N, K; cin >> N >> K;
	rep(i,N) cin >> h[i];

	rep(i,N) dp[i] = INF;
	dp[0] = 0;
	rep(i,N) {
		REP(j,1,K + 1) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[N - 1] << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const int maxn=1e6+10;
#define p 1000000007
int main(){
	fast;
	string s,t; cin>>s>>t;
	int mn=1000;
	for(auto i=0;i<s.size()-t.size()+1;++i){
		int cnt=0;
		int ii=i,j=0;
		while(j<t.size()){
			if(s[ii]!=t[j])++cnt;
			++ii;
			++j;
		}
		mn=min(mn,cnt);
	}
	cout<<mn<<'\n';
	return 0;
}
//prime func
//subset production
//factorization
//modpow
//modinv ( a^(p-2)=a^(-1) (mod p) )
//sieve
//ncr
//euler totien func (co prime divisiors upto n)
//matrix exponentation
//dsu
//Trees
//Graphs(dfs,bfs,shortes path etc.)
//DP-Recursion

Measured memory_bytes: 3636
import numpy as np

a, b, x = map(int, input().split())
h = x / a ** 2
if 2 * h < b:
    c = 2 * x / (a * b)
    rad = np.arctan(b / c)
else:
    rad = np.arctan(2 * (b - h) / a)
print(rad * 180 / np.pi)


Measured memory_bytes: 21372
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b; //あまりが0ならそれが、最大公約数
}
//あまりが0になるまで a%b (a > bとする)
//あまりが0でなければ、a = b; b = r         bと割ったあまり で　b%r する

int main(){

    ll N,A,B,res;


    cin >> N;

    cin >> A;
    res = A;//1つ目

    REP(i,N)
    {
        cin >> A;   

        res = euclidean_gcd(A,res);

    }

    cout << res << endl;

    return 0;
}



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

using namespace std;

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double kakudo = abs(30 * h + 0.5 * m - 6 * m);
  double rad = M_PI * kakudo / 180.0;
  double ans = a * a + b * b - 2 * a * b * cos(rad);
  ans = sqrt(ans);
  cout << std::setprecision(10) << ans;
  return 0;
}


Measured memory_bytes: 4136
#include<iostream>
using namespace std;
int main()
{
    int n,a,b,x,y,z,i,j,Sn=0;
    cin>>n>>a>>b;
    for(int k=1;k<=n;k++){
        x=k%10;
        y=(k%100-x)/10;
        z=(k%1000-y*10-x)/100;
        i=(k%10000-z*100-y*10-x)/1000;
        j=k/10000;
        if(x+y+z+i+j>=a&&x+y+z+i+j<=b){
            Sn=Sn+k;
        }
    }
    cout<<Sn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

void dfs(void);
void visit(int,int);

int n,a[N][N],color[N],d[N],t; //d=start

int main(){
  int i,j,k,x,u;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      a[i][j] = 0;
    }
  }
  for(i = 0;i < n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j = 0;j < k;j++){ //x=連結
      scanf("%d",&x);
      x--;
      a[u][x] = 1;
    }
  }

  dfs();

  for(i = 0;i < n;i++){
    if(d[i] == 10000000) printf("%d %d\n",i+1,-1);
    else printf("%d %d\n",i+1,d[i]);
  }
 
  return 0;
}

void dfs(void){
  int s,i,u,con;

  for(u = 0;u < n;u++){
    color[u] = 0; //0=白
    d[u] = 10000000;
  }
  color[0] = 1;
  t=0;
  s=0;
  d[0] = 0;
  while(1){
    if(s == n) break;
    if(color[s] == 1){ //1=灰
      for(i = 0;i < n;i++){
	if(a[s][i] == 1){
	  color[i] = 1;
	  if(d[i]>t+1){
	    d[i] = t+1;
	    con = d[i];
	    visit(i,con);
	  }
	}
      }
      color[s] = 2; //2=黒
      s++;
      t=d[s];
      if(color[s] == 0 ){
	while(color[s] == 0){
	  if(s==n)break;
	  s++;
	  t=d[s];
	}
      }	
      con++;
    }
  }
  //t--; 0,1,3,2
  
}

void visit(int s,int t){
  int i,con;
  for(i = 0;i < n;i++){
    if(a[s][i] == 1){
      color[i] = 1;
      if(d[i]>t+1){
	d[i] = t+1;
	con=d[i];
	visit(i,con);
      }
    }
  }
}



Measured memory_bytes: 2112
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::Write;

fn run() {
    input! {
        k: i32,
        x: i32,
    }
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    for (j, i) in ((x - k + 1)..(x + k)).enumerate() {
        if j > 0 {
            write!(out, " ").unwrap();
        }
        write!(out, "{}", i).unwrap();
    }
    write!(out, "\n").unwrap();
}

fn main() {
    run();
}


Measured memory_bytes: 4352
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
//#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
//#define base 1000000000000000000
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c,b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ull ba=233;
const db eps=1e-5;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=200000+10,maxn=1000000+10,inf=0x3f3f3f3f;

int h,w,n,x,y;
char s[N],p[N];
int main()
{
    scanf("%d%d%d%d%d%s%s",&h,&w,&n,&x,&y,s+1,p+1);
    int te=y;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='R')te++;
        if(te>w)return 0*puts("NO");
        if(p[i]=='L'&&te>=2)te--;
    }
    te=y;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='L')te--;
        if(te<1)return 0*puts("NO");
        if(p[i]=='R'&&te<w)te++;
    }
    te=x;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='U')te--;
        if(te<1)return 0*puts("NO");
        if(p[i]=='D'&&te<h)te++;
    }
    te=x;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='D')te++;
        if(te>h)return 0*puts("NO");
        if(p[i]=='U'&&te>1)te--;
    }
    puts("YES");
    return 0;
}
/********************

********************/


Measured memory_bytes: 640
from bisect import bisect_left

N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

def isOverEq(n):
    cnt = 0
    for a in A:
        cnt += N - bisect_left(A, n - a)
    return cnt >= M

overEq = -1
less = 10**7
while less - overEq > 1:
    mid = (less + overEq) // 2
    if isOverEq(mid):
        overEq = mid
    else:
        less = mid

accA = [0] * (N + 1)
for i, a in enumerate(A, start=1):
    accA[i] = accA[i - 1] + a

ans = 0
cnt = 0
for a in A:
    i = bisect_left(A, overEq - a)
    ans += accA[N] - accA[i]
    ans += (N - i) * a
    cnt += N - i

ans -= max(0, cnt - M) * overEq
print(ans)


Measured memory_bytes: 14388
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int X,Y;
    cin>>X>>Y;
    if(((4*X-Y)%2==0&&4*X>=Y)&&((Y-2*X)%2==0&&Y>=2*X)){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#define llint long long

using namespace std;

llint n, k;
llint x[100005], y[100005];
char c[100005];
llint dif[4005][3005];
llint sum[4005][3005];
llint ans[2005][1005];

int main(void)
{
	cin >> n >> k;
	for(llint i = 0; i < n; i++) cin >> x[i] >> y[i] >> c[i];
	
	for(llint i = 0; i < n; i++){
		llint X = x[i] % (2*k) + 1, Y = y[i] % (2*k) + 1;
		if(c[i] == 'B'){
			dif[X][Y]++;
			dif[X+k][Y]--;
			dif[X][Y+k]--;
			dif[X+k][Y+k]++;
		}
		else{
			dif[X+k][Y]++;
			dif[X+2*k][Y]--;
			dif[X+k][Y+k]--;
			dif[X+2*k][Y+k]++;
		}
	}
	
	for(llint x = 1; x <= 4*k; x++){
		for(llint y = 1; y <= 3*k; y++){
			sum[x][y] = sum[x-1][y] + sum[x][y-1] - sum[x-1][y-1] + dif[x][y];
		}
	}
	
	for(llint x = 1; x <= 4*k; x++){
		for(llint y = 1; y <= 3*k; y++){
			llint X = x-1, Y = y-1;
			if((X/k + Y/k) % 2) ans[X%k+k][Y%k] += sum[x][y];
			else ans[X%k][Y%k] += sum[x][y];
		}
	}
	
	llint Ans = 0;
	for(llint x = 0; x < 2*k; x++){
		for(llint y = 0; y < k; y++){
			Ans = max(Ans, ans[x][y]);
		}
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 205696
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int g[20][20];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int main(void){

	int n,m;
	map<char,int>dd;
	dd['N']=0;
	dd['E']=1;
	dd['S']=2;
	dd['W']=3;

	while(cin >> n,n){
		fill(g[0],g[20],0);

		for(int i=0;i<n;i++){
			int x,y;
			cin >> x >> y;
			g[y][x]=1;
		}

		cin >> m;
		int x=10,y=10;
		g[y][x]=0;
		for(int i=0;i<m;i++){
			char dir;
			int dis;
			cin >> dir >> dis;
			for(int k=0;k<dis;k++){
				x+=dx[dd[dir]],y+=dy[dd[dir]];
				g[y][x]=0;
			}
		}

		bool fg=true;
		for(int i=0;i<20;i++)
			for(int j=0;j<20;j++)
				fg&=(g[i][j]==0);

		if(fg)cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
N = int(input())
C = list(input())
ans = 0
l = 0
for i in range(N-1, -1, -1):
    if C[i] == 'R':
        while l < N and C[l] != 'W':
            l += 1
        if l > i or l == N:
            break
        C[i], C[l] = C[l], C[i]
        ans += 1
print(ans)

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

int main() {

    string s;
    cin>>s;
    int p;
    for(int i=0; i<s.size(); i++) {
        if(s[i]=='2'||s[i]=='4'||s[i]=='5'||s[i]=='7'||s[i]=='9')
            p=0;
        else if(s[i]=='0'||s[i]=='1'||s[i]=='6'||s[i]=='8')
            p=1;
        else if(s[i]=='3')
            p=2;
    }
    if(p==0)
        cout<<"hon"<<endl;
    else if(p==1)
        cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using std::cin;
using std::cout;
const int N = 5005;
int n, c[ N ], p[ N ];
long long ans = -0x3f3f3f3f3f3f3f3f, k;
int main( )
{
 std::ios::sync_with_stdio( false );
 cin >> n >> k;
 for( int i = 1; i <= n; ++i )
  cin >> p[ i ];
 for( int i = 1; i <= n; ++i )
  cin >> c[ i ];
 for( int i = 1; i <= n; ++i )
 {
  long long sum = 0, cur = i, num = 0;
  do {
   cur = p[ cur ];
   sum += c[ cur ];
   ++num;
  } while( cur != i );
  long long mx = -0x3f3f3f3f3f3f3f3f, tmp = 0;
  for( int j = 1; j <= std::min( num, k ); ++j )
  {
   cur = p[ cur ];
   tmp += c[ cur ];
   mx = std::max( mx, tmp + ( sum > 0 ? sum * ( ( k - j ) / num ) : 0 ) );
  }
  ans = std::max( ans, mx );
 }
 cout << ans;
 return 0;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;

vector <LL> G[100005];

LL ec = 0,to[200005],nxt[200005],hed[100005] = {0};
void add_edge(LL f,LL t){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec;
}
struct edge{
	LL u,v;
}e[200005]; LL ecc = 0;

LL deg[100005] = {0};

LL ans_link(LL u,LL v){
	deg[u] ++;
	cout << u << ' ' << v << endl;
}

void dfs(LL u,LL f){
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		dfs(v,u);
	}
	if(!f) return;
	if(deg[u] & 1) ans_link(u,f);
	else ans_link(f,u);
}

//dsu
LL fa[200005] = {0};
void init_dsu(){
	for(LL i = 1;i <= 200000;i ++) fa[i] = i;
}
LL getf(LL x){
	if(x == fa[x]) return x;
	return fa[x] = getf(fa[x]);
}
//dsu

int main(){
	ios::sync_with_stdio(false);
	LL n,m,uu,vv;
	cin >> n >> m;
	if(m & 1){ cout << -1 << endl; return 0; }
	init_dsu();
	
	for(LL i = 1;i <= m;i ++){
		cin >> uu >> vv;
		e[++ ecc].u = uu; e[ecc].v = vv;
	}
	for(LL i = 1;i <= ecc;i ++){
		LL fu = getf(e[i].u),fv = getf(e[i].v);
		if(fu == fv) ans_link(e[i].u,e[i].v);
		else{
			add_edge(e[i].u,e[i].v);
			add_edge(e[i].v,e[i].u);
			fa[fu] = fv;
		}
	}
	
	dfs(1,0);
	return 0;
}

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

int main(){
  int N,count=1;
  string S;
  cin>>N>>S;
  for(int i=0; i<N-1; i++){
    if(S.at(i)==S.at(i+1)){
      continue;
    }
    else{
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll ans = LLINF;
void dfs(ll now, ll cou, ll a, ll b, ll sum){
	if(a <= 0)return;
	if(cou == 50){
		ans = min(ans, now);
		return;
	}
	ll A = (a >> cou) & 1;
	ll B = (b >> cou) & 1;
	ll C = (sum >> cou) & 1;

	if((A + B + C) % 2){
		return;
	}

	ll tmp = (1LL << cou);
	dfs(now, cou+1, a, b, sum);
	dfs(now + tmp, cou+1, a - tmp, b + tmp, sum);
}

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

	ll n;cin >> n;
	vector<ll> v(n);REP(i, n)cin >> v[i];
	ll sum = 0;
	for(ll i = 2;i < n;i++)sum ^= v[i];

	dfs(0, 0, v[0], v[1], sum);
	if(ans < v[0]){
		cout << ans << endl;
	}
	else{
		cout << -1 << endl;
	}

	return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

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

ll N;
VL b;

int main() {
    cin >> N;
    REP(i, N) b.emplace_back(IN() - i - 1);
    sort(All(b));
    ll ans = 0;
    REP(i, N) ans += abs(b[i] - b[N / 2]);
    cout << ans;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll a = 1, b = n;
    for(ll i = 2; i * i <= n; i++){
        if(n%i == 0) a = i, b = n/i;
    }

    int ans = 1;
    while(b/10 != 0){
        b/=10;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;

using namespace std;

int main() {
    int n;
    scanf("%d", &n);

    /*
     * 0 : index
     * 1 : name
     * 2: evaluation
     */
    vector<tuple<int, string, int>> restaurants(n);

    for (int i = 0; i < n; i++) {
        get<0>(restaurants[i]) = i + 1;
        char tmp[10];
        scanf("%s", tmp);
        get<1>(restaurants[i]) = tmp;
        scanf("%d", &get<2>(restaurants[i]));
    }

    sort(restaurants.begin(), restaurants.end(),
         [](const auto &s1, const auto &s2) {
             return get<1>(s1) < get<1>(s2);
         }
    );

    auto iterator = restaurants.begin();

    while (1) {
        const auto result_iterator = find_if(iterator, restaurants.end(), [&iterator](auto x) {
            return (get<1>(x) != get<1>(*iterator));
        });

        sort(
                iterator,
                result_iterator,
                [](const auto &x, const auto &y) {
                    return get<2>(x) > get<2>(y);
                }
        );

        if (result_iterator == restaurants.end()) { break; }

        iterator = result_iterator;
    }

    for (const auto &r : restaurants) {
        printf("%d\n", get<0>(r));
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, m;
    cin >> n >> m;
    vector<P> l(m);
    rep(i, m) cin >> l[i].first >> l[i].second;

    int ans = 0;
    int x = 1;
    int y = n;
    rep(i, m) {
        chmax(x, l[i].first);
        chmin(y, l[i].second);
    }
    ans = y-x+1;
    chmax(ans, 0);
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long N = sc.nextLong();
		int n = (int) Math.sqrt((double) N);

//		他人の提出結果見る前のゴミ処理
//		parent: for (int i = n; i >= 0; i--) {
//			for (int j = n; j <= N; j++) {
//				if (i * j == N) {
//					System.out.println(i - 1 + j - 1);
//					break parent;
//				} else if (i * j > N) {
//					break;
//				}
//
//			}
//		}
		while (N % n != 0) {
			n--;
		}
		System.out.println(n + N / n - 2);
		sc.close();
	}

}

Measured memory_bytes: 24148