akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e18
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b,ll m){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % m;  a = (a * a) % m;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 2e5 + 7;
ll k,i,j;
long double n,m,p;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>k;
    for(i = 1;i <= n;i += 1){
        m = 1;
        j = i;
        while(j < k){
            j *= 2;
            m *= 2;
        }
        p += 1.0 / m;
    }
    p *= (1.0 / n);
    cout<<setprecision(12)<<fixed<<p;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m;
vector<vector<int>> g, ig;
double sp[601][601], sep[601][601];

int main() {
  cin >> n >> m;
  g.resize(n + 1);
  ig.resize(n + 1);
  for (int i = 0; i < m; ++i) {
    int s, t;
    cin >> s >> t;
    g[s].push_back(t);
    ig[t].push_back(s);
  }

  for (int a = 1; a <= n; ++a) {
    sp[a][a] = 1.0;
    for (int u = 1; u <= n; ++u) {
      double deg = g[u].size();
      for (int v : g[u]) {
        sp[a][v] += sp[a][u] / deg;
      }
    }
    for (int u = 1; u <= n; ++u) {
      double deg = g[u].size();
      for (int v : g[u]) {
        sep[a][v] += (sep[a][u] + sp[a][u]) / deg;
      }
    }
  }

  double ans = sep[1][n];
  for (int u = 1; u <= n; ++u) {
    if (g[u].size() <= 1) continue;
    double deg = g[u].size();
    for (int v : g[u]) {
      double f = -sp[1][u] / deg * sep[v][n];
      for (int w : g[u]) {
        if (w != v) {
          f += sp[1][u] * (1.0 / (deg - 1) - 1.0 / deg) * sep[w][n];
        }
      }
      ans = min(ans, sep[1][n] + f);
    }
  }
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 8192
//shadowlink0122さん解法
//1e+9+7を9e15+7に修正 ull to ll
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
// typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 9e15+7;
ll n,m,l;
string s,t;
ll d[100010],dp[100][100];
ll x[100010],y[100010];

struct edge{ll to,cost;};
typedef pair<ll,ll> P;
vector<edge> g[100010];

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P> > que;
  fill(d,d+n,INF);
  d[s] = 0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top();que.pop();
    ll v = p.second;
    if(d[v] < p.first)continue;
    rep(i,0,g[v].sz){
      edge e = g[v][i];
      if(d[e.to] > d[v]+e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main(){
  cin >> n;
  rep(i,1,n){
    ll a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    g[a].pb((edge){b,c});
    g[b].pb((edge){a,c});
  }
  cin >> m >> l;
  rep(i,0,m)cin >> x[i] >> y[i];
  dijkstra(l-1);
  rep(i,0,m){
    print(d[x[i]-1]+d[y[i]-1]);
  }
  return 0;
}


Measured memory_bytes: 12784
def a(c)
  c * 2
end

def b(c,k)
  c + k
end

n = gets.chomp.to_i
k = gets.chomp.to_i

op_a = lambda{|*args| a(*args)}
op_b = lambda{|*args| b(*args)}

c = 1
ans = []
arr = [op_a,op_b]
arr.repeated_permutation(n).each do |op|
  c = 1
  op.each do |o|
    if o == op_a
      c = o[c]
    else
      c = o[c,k]
    end
  end
  ans << c
end

puts ans.min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,m;
    cin>>n>>m;
    double p=m*1900+(n-m)*100;
    double q=pow(0.5,m);
    double ans=0.0;
    double now=1.0;
    FOR(i,1,100000){
        ans+=(now*q)*p*i;
        now=now-(now*q);
    }
    cout<<(int)(ans+0.5)<<endl;
    return 0;
}

Measured memory_bytes: 384
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int>x(n);
  int mi = 100000000;
  rep(i,n) cin >> x.at(i);
  for(int i=1;i<=100;i++){
    int sum = 0;
    for(int j=0;j<n;j++){
      sum += (i-x.at(j))*(i-x.at(j));
    }
    mi = min(mi,sum);
  }
  cout << mi << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
    int n, a, i, f;
    vector<int> b;

    scanf("%d", &n);
    if(n % 2 == 0){
        f = 1;
    }
    else{
        f = 0;
    }
    for(i = 0; i < n; i++){
        scanf("%d", &a);
        if(f){
            b.push_back(a);
            f = 0;
        }
        else{
            b.insert(b.begin(), a);
            f = 1;
        }
    }

    for(i = 0; i < n; i++){
        cout << b[i] << ' ';
    }
    cout << endl;
}

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

int main(){
  ll A,B,N;
  
  cin >> A >> B >> N;
  
  if(B>N)
    cout << floor(A*N/B) << endl;
  else
    cout << floor(A*(B-1)/B) << endl;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  ll n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  ll arr[n][n];
  ll sum[n];
  zero(sum);

  fi(0, n - 1)
    fj(i + 1, n) {
      ll dis = min((ll)j - i, min(abs(i - x) + abs(j - y) + 1, abs(i - y) + abs(j - x) + 1));
      sum[dis]++;
    }
  fi(1, n) {
    cout << sum[i] << endl;
  }
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  long long n;
  cin >> n;
  if(1 == n % 2) {
    cout << 0 << endl;
    return 0;
  }
  
  long long count = 0;
  for(long long k = n / 10; k > 0; k /= 5) {
    count += k / 5;
  }
  cout << (n / 10) + count << 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++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int h, w, k; cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = 0;
    rep(bith, 1<<h){
        rep(bitw, 1<<w){
            int b=0;
            rep(i, h) rep(j, w){
                // 赤で塗られていればcontinue
                if((bith >> i) & 1 || (bitw >> j) & 1) continue;
                if(s[i][j] == '#') b++;
            }
            if(b==k) ans++;
        }
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>

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

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

void solution()
{
    size_t n,k;
    cin >> n >> k;
    vector<int> as(n);
    cin >> as;
    int t = 1;
    vector<int> distance(n);
    int t_prev = 1;
    int d = 0;
    while(!distance[t-1]){
        if(k == 0){
            cout << t << '\n';
            return;
        }
        distance[t-1] = d;
        t_prev = t;
        t = as[t-1];
        k -= 1;
        d += 1;
    }
    int loop_length = distance[t_prev-1] - distance[t-1] + 1;
    //cout << "loop: " << loop_length << '\n';
    if(loop_length > 1){
        k = k % loop_length;
        for(size_t i = 0; i < k; ++i){
            t = as[t-1];
        }
    }
    cout << t << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 4788
n = int(input())
A = list(map(int, input().split()))
meanAs = int(sum(A)/n)
meanAb = meanAs + 1
anss = 0
ansb = 0
for a in A:
    anss += (a-meanAs)**2
    ansb += (a-meanAb)**2
print(min(anss, ansb))

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

int main() {
  string S;
  cin >> S;

  if (S.front() == 'A') {
    int num_C = 0;
    for (int i = 2; i <= S.length() - 2; i++) {
      if (S.at(i) == 'C') num_C++;
    }

    if (num_C == 1) {
      int num_lowercase = 0;
      for (auto s : S) {
        if ('a' <= s && s <= 'z') num_lowercase++;
      }
      if (num_lowercase == S.length() - 2) {
        printf("AC");
        return 0;
      }
    }
  }

  printf("WA");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // setprecision
#include <cmath>

using namespace std;
typedef long long ll;
const double long PI = acos(-1);

void solve() {
  ll N, K, i, c = 0;
  ll hs[100000];
  cin >> N >> K;
  for (i=0;i<N;i++) {
    cin >> hs[i];
  }
  for (i=0;i<N;i++) {
    if (hs[i] >= K) c ++;
  }
  cout << c << endl;
}

int main(void) {
  cout << fixed << setprecision(10);
  solve();
  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);
		int n=sc.nextInt();

		int v[]=new int[n+1];
		int c[]=new int[n+1];
		for(int i=1;i<=n;i++){
			v[i]=sc.nextInt();
		}
		for(int i=1;i<=n;i++){
			c[i]=sc.nextInt();
		}
int ans=0;
		for(int i=1;i<=n;i++){
			if(v[i]-c[i]>=0){
			ans=ans+v[i]-c[i];
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
struct modint {
    ll x;
    modint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    ll value() const {
        return x;
    }
    modint operator-() const {
        return modint(-x);
    }
    modint& operator+=(const modint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator*=(const modint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    modint operator+(const modint a) const {
        modint res(*this);
        return res += a;
    }
    modint operator-(const modint a) const {
        modint res(*this);
        return res -= a;
    }
    modint operator*(const modint a) const {
        modint res(*this);
        return res *= a;
    }
    modint pow(ll t) const {
        if (t == 0) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t % 2 == 1) a *= *this;
        return a;
    }
    modint inv() const {
        return pow(MOD - 2);
    }
    modint& operator/=(const modint a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint a) const {
        modint res(*this);
        return res /= a;
    }
};
struct combination {
    vector<modint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = fact[i - 1] * i;
        }
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--) {
            ifact[i - 1] = ifact[i] * i;
        }
    }
    modint operator()(int n, int k) {
        if (n < k || k < 0) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    modint h(int n, int k) {
        n += k - 1;
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(2002002);
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    modint ans = modint(3).pow(n);
    modint now = 1;
    rep(i, n) {
        if (a[i] % 2 == 0) now *= 2;
    }
    cout << (ans - now).value() << endl;
}

Measured memory_bytes: 31488
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    cout << (N % 10 == 7 || N / 10 % 10 == 7 || N / 100 == 7 
                ? "Yes" : "No") << endl;
    return 0;
};

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int ans = 0;
  string s;
  cin >> s;
  for(int i=0;i<(s.size()+1)/2;i++){
    if(s.at(i) != s.at(s.size()-1-i))
      ans++;
  }
  cout << ans << endl;
}

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

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        PriorityQueue<Integer> a = new PriorityQueue<>();
        PriorityQueue<Integer> b = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            a.add(scanner.nextInt());
        }
        for (int i = 0; i < n; i++) {
            b.add(scanner.nextInt());
        }
        long ans = 1;
        a.add(Integer.MAX_VALUE);
        b.add(Integer.MAX_VALUE);

        long countA = 0;
        long countB = 0;
        while (a.size() > 1 || b.size() > 1) {
            if (a.peek() < b.peek()) {
                a.poll();
                if (countB == 0) {
                    countA++;
                } else {
                    ans = ans * countB % mod;
                    countB--;
                }
            } else {
                b.poll();
                if (countA == 0) {
                    countB++;
                } else {
                    ans = ans * countA % mod;
                    countA--;
                }
            }
        }
        System.out.println(ans);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 46064
def main():
    n = int(input())
    nums = input().split(' ')
    s = set()
    result = 'YES'

    for i in range(n):
        num = nums[i]
        if num in s:
            result = 'NO'
            break
        s.add(num)

    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 36280
#include <stdio.h>
#include <stdlib.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))
#define swap(type, a, b) { type temp = a; a = b; b = temp; }

int N, M;
int * data;

void init() {
  // child: parent's index
  // root: -size
  data = array(N, int);

  rep(i, N) {
    // at first, all data is root and size is -1
    data[i] = -1;
  }
}

int find(int x) {
  if (data[x] < 0) {
    return x;
  }

  return data[x] = find(data[x]);
}

int same(int x, int y) {
  return find(x) == find(y);
}

int unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) {
    return 0;
  }
  // becasue data has minus size, reverse the inequality sign
  if (data[x] > data[y]) {
    swap(int, x, y);
  }
  data[x] += data[y];
  data[y] = x;
  return 1;
}

int size(int x) {
  return -data[find(x)];
}

int main() {
  scanf("%d%d", &N, &M);
  // initialize
  init();

  rep(i, M) {
    int A, B;
    scanf("%d%d", &A, &B);
    A -= 1;
    B -= 1;
    unite(A, B);
  }

  int ans = 0;
  rep(i, N - 1) {
    if (same(i, i + 1)) {
    } else {
      unite(i, i + 1);
      ans += 1;
    }
  }

  printf("%d\n", ans);

  free(data);

  return 0;
}


Measured memory_bytes: 1780
package main

import (
	"bufio"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriterSize(os.Stdout, 1000000)
)

func main() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer writer.Flush()
	n, k, q := scanInt(), scanInt(), scanInt()
	a := make(map[int]int, q)
	for i := 0; i < q; i++ {
		a[scanInt()]++
	}

	for i := 0; i < n; i++ {
		v, ok := a[i+1]
		if !ok {
			v = 0
		}
		if (k - q + v) > 0 {
			writer.WriteString("Yes\n")
		} else {
			writer.WriteString("No\n")
		}
	}
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {
	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}

func perm(n, r int) int {
	ret := 1
	for i := 0; i < r; i++ {
		ret *= n
		n--
	}
	return ret
}

func isPrimeNum(n int) bool {

	if n <= 1 {
		return false
	}

	l := int(math.Sqrt(float64(n)) + 1.)
	for i := 2; i < l; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}


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

int main() {
    string A, B; cin >> A >> B;
    if (A.size() != B.size()) {
        if (A.size() < B.size()) cout << "LESS" << endl;
        else cout << "GREATER" << endl;
    } else {
        if (A == B) {
            cout << "EQUAL" << endl;
        } else {
            int i = 0;
            while (A.at(i) == B.at(i)) {
                i++;
            }
            if (A.at(i) < B.at(i)) cout << "LESS" << endl;
            else cout << "GREATER" << endl;
        }
    }
}

Measured memory_bytes: 3636
inputNumbers = input().split()
snuckNumber = int(inputNumbers[0])
snakeKinds = int(inputNumbers[1])
snuckDict = {}
for i in range(snakeKinds):
    temp = int(input())
    tempSnuckList = input().split()
    for item in tempSnuckList:
        snuckDict[item] = 1;

count = snuckNumber - len(snuckDict)
print(count)

Measured memory_bytes: 9180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#pragma warning(disable:4996)
using namespace std;
 
struct Node {
    int key;
    int left;
    int right;
};
 
int n;
char command[7];
Node tree[500000];
int tree_num;
int root = -1;
 
inline int create_node(int key) {
    Node& node = tree[tree_num];
    node.key = key;
    node.left = -1;
    node.right = -1;
    return tree_num++;
}
 
inline void insert(int key) {
    if (root == -1) {
        root = create_node(key);
        return;
    }
    int node = root, parent = 0;
    while (node != -1) {
        parent = node;
        if (key < tree[node].key) {
            node = tree[node].left;
        }
        else {
            node = tree[node].right;
        }
    }
    int newnode = create_node(key);
    if (key < tree[parent].key) {
        tree[parent].left = newnode;
    }
    else {
        tree[parent].right = newnode;
    }
}
 
inline int find(int key) {
    int node = root;
    while (node != -1) {
        if (tree[node].key == key) {
            return node;
        }
        else if (tree[node].key > key) {
            node = tree[node].left;
        }
        else {
            node = tree[node].right;
        }
    }
    return -1;
}
 
void pre_order(int root) {
    Node& node = tree[root];
    printf(" %d", node.key);
    if (node.left != -1) {
        pre_order(node.left);
    }
    if (node.right != -1) {
        pre_order(node.right);
    }
}
 
void in_order(int root) {
    Node& node = tree[root];
    if (node.left != -1) {
        in_order(node.left);
    }
    printf(" %d", node.key);
    if (node.right != -1) {
        in_order(node.right);
    }
}
 
int main(void) {
    scanf("%d", &n);
    for (int i = 0, key; i < n; ++i) {
        scanf("%s", command);
        if (command[0] == 'i') {
            scanf("%d", &key);
            insert(key);
        }
        else if (command[0] == 'f') {
            scanf("%d", &key);
            int found = find(key);
            printf("%s\n", found != -1 ? "yes" : "no");
        }
        else {
            if (root == -1) { continue; }
            in_order(0);
            printf("\n");
            pre_order(0);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 7908
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
  int N,K;
  cin>>N>>K;
  vector<int64_t>h(110000);
  vector<int64_t>dp(110000,INF);
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  dp[0]=0;

  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
      chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;}

Measured memory_bytes: 1920
#include<stdio.h>
#include<string.h>
int main(){
  int i,count=0;
  char s[200002],t[200002];
  scanf("%s",s);
  scanf("%*c%s",t);
  int len=strlen(t);
  for(i=0;i<len;i++)
    if(s[i]!=t[i])
      count++;
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2124
using System;
using System.Collections.Generic;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            int d = int.Parse(input[3]);

            while(a>=0 || c >= 0)
            {
                c = c - b;
                if (c <= 0) {
                    Console.WriteLine("Yes");
                    break;
                }
                a = a - d;
                if (a <= 0)
                {
                    Console.WriteLine("No");
                    break;
                }
            }

        }
    }
}

Measured memory_bytes: 17892
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int n;
vector<int> a;
vector<int> spf(1e6 + 5, 0);
vector<int> cnt(1e6 + 5, 0);
void sieve(){
    const int MAXN = 1e6 + 5; 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)   
        spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2;   
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}  
void f(int x) { 
    while (x != 1) { 
        int cur = spf[x];
        while(x%cur == 0){
            x /= cur;
        }
        cnt[cur]++;
        // cout << cur << "\n";
    } 
} 
  

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    a.assign(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    int g = a[0];
    sieve();
    for(auto i : a){
        f(i); g = __gcd(i, g);
    }
    bool pw = true;
    for(int i = 2; i < sz(cnt); ++i){
        if(cnt[i] > 1) pw = false;
    }
    if(pw) cout << "pairwise coprime";
    else if(g == 1) cout << "setwise coprime";
    else cout << "not coprime";
    return 0;
}

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

int main(){
  int x, y;
  cin >> x >> y;
  
  string ans = "No";
  
  if(x == 2 && y ==2){
    ans = "Yes";
  }
  if((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11)){
    ans = "Yes";
  }
   if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)){
    ans = "Yes";
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
s=str(input())
t=str(input())
n=len(s)

ans=0
for i in range(n):
    for j in range(n):
        if s[(i+j)%n]!=t[j]:
            break
        if j==n-1:
            ans=1

if ans==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define ft first
#define sd second
#define pb push_back
#define mp(x,y) make_pair(x,y)
//#define int LL
using namespace std;
//const int N   = ;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,n) for (int i=1;i<=n;++i)
#define repp(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,x,t,a[200000+2];
//char s[200000+2];
signed main()
{
	read(n);
	LL ans=0;
	rep(i,n)
	  {
	  	read(a[i]);
	  	if (a[i-1]>a[i])
	  	  ans+=a[i-1]-a[i],a[i]=a[i-1];
	  }
	printf("%lld",ans);
	return 0;
}



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

#define int long long int
#define float long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define mod (int)(1e9+7)
#define inf LLONG_MAX
int exp(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x){return exp(x,mod-2);}


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

	string s;
	cin>>s;
	if(s[s.size()-1]!='s')
		s.pb('s');
	else
	{
		s.pb('e');
		s.pb('s');
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
map<string,int>a;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		a[s]++;
	}
	int mx=0;
	for(auto i:a)
		mx=max(mx,i.second);
	for(auto i:a)
		if(i.second==mx)
			cout<<i.first<<endl;
	return 0;
}

Measured memory_bytes: 25856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int Mult = Integer.parseInt(br.readLine());
		System.out.println(Mult*Mult*Mult);
	}

}



Measured memory_bytes: 24184
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    intmax_t N, L;
    intmax_t ans = 0;

    scanf("%jd%jd", &N, &L);

    if (L >= 0) {
        for (intmax_t i = (L + 1); i < (N + L); i++) ans += i;
    } else {
        if ((N + L) > 0) {
            for (intmax_t i = L; i < (N + L); i++) ans += i;
        } else {
            for (intmax_t i = L; i < (N + L - 1); i++) ans += i;
        }
    }

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 128
import math
import bisect

def main():
    n = int(input())
    primes = {}
    s = [(1+i) * i // 2 for i in range(1, 300000)]
    for i in range(2, int(math.sqrt(n))+2):
        if n % i == 0:
            primes[i] = 0
        else:
            continue
        while n % i == 0:
            n /= i
            primes[i] += 1

    if n != 1:
        primes[n] = 1

    ans = 0
    for _, v in primes.items():
        i = bisect.bisect_right(s, v)
        ans += i

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 87420
// Last Change: 03/24/2019 21:26:24.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

/* note
 * l,rとindexのずれに注意
 *
 *
 */

ll N, Q;
string S;

vector<ll> acInfo;

int main() {
  cin >> N >> Q >> S;
  acInfo.resize(N + 1);

  char last = 'N';
  ll cnt = 0;
  for (ll i = 0; i <= N; ++i) {
    acInfo[i] = cnt;

    if (i == N) {
      break;
    }

    if (last == 'A' and S[i] == 'C') {
      ++cnt;
    } else {
      // do nothing
    }

    last = S[i];
  }

  for (ll i = 0; i < Q; ++i) {
    ll l, r;
    cin >> l >> r;
    cout << acInfo[r] - acInfo[l] << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 1792
from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    N, K = map(int, input().split())
    ans = K - N if K == 0 else 0
    for b in range(K + 1, N + 1):
        c = (N - K) // b
        ans += (b - K) * c + min(N - c * b + 1, b) - K
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  map<char, bool> mp;
  for (char c : s) mp[c] = true;
  REP(i, 26) if (!mp[(char)('a' + i)]) {
    cout << (char)('a' + i) << '\n';
    return 0;
  }
  cout << "None" << '\n';
  return 0;
}


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

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

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

    int dist = 0;
    for (int i = 0; i < n-1; i++) {
        dist += abs(a[i] - a[i+1]);
    }

    cout << dist << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    black_site = []
    for i, c in enumerate(s):
        if c == "B":
            black_site.append(i)
    count = len(s)-1
    ans = 0
    for i in reversed(black_site):
        ans += count - i 
        count -= 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 11368
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum=0;
    
    for (int i=0; cin >> ch; i++) {
        if (ch=='\\') S1.push(i);
        else if (ch=='/' && S1.size()>0) {
            int j = S1.top(); S1.pop();
            sum += i-j;
            int a = i-j;
            while (S2.size() > 0 && S2.top().first > j) {
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }
    
    vector<int> ans;
    while (S2.size() > 0) { ans.push_back(S2.top().second); S2.pop(); }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i=0; i<ans.size(); i++) {
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
    
    return 0;
}


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

const int N = 2e5 + 9;

int cnt[N];

void yo(vector<int> ans, vector<int> a) {
	int n = ans.size();
	for (int i = 0; i < n; i++) {
		if (a[i] == ans[i] || ans[i] == 0) return;
	}
	cout << "Yes\n";
	for (auto i: ans) cout << i << ' '; cout << '\n';
	exit(0);
}

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];

	yo(b, a);

	for (auto i: b) cnt[i]++;
	int mx = 0;
	for (int i = 1; i <= n; i++) mx = max(mx, cnt[i]);
	auto c = b;
	rotate(b.begin(), b.begin() + mx, b.end());
	yo(b, a);
	b = c;

	for (int i = 0; i < 50; i++) {
		set<pair<int, int>> se;
		vector<int> prior(n);
		if (i == 0) {
			for (int k = 0; k < n; k++) prior[k] = k;
		}		
		else if (i == 1) {
			for (int k = 0; k < n; k++) prior[k] = -k;
		}
		else {
			for (int k = 0; k < n; k++) prior[k] = rnd() % n + 1;
		}

		for (auto i: b) se.insert({prior[i], i});
		memset(cnt, 0, sizeof cnt);
		for (auto i: b) cnt[i]++;
		vector<int> ans(n);
		for (int i = 0; i < n; i++) {
			if (se.empty()) break;
			auto it = se.begin();
			if ((*it).second == a[i]) {
				if (se.size() == 1) break;
				++it;
			}
			int k = (*it).second;
			ans[i] = k;
			cnt[k]--;
			if (cnt[k] == 0) se.erase({prior[k], k});
		}
		yo(ans, a);
	}

	memset(cnt, 0, sizeof cnt);
	for (auto i: a) cnt[i]++;
	mx = 0;
	for (int i = 1; i <= n; i++) mx = max(mx, cnt[i]);
	rotate(b.begin(), b.begin() + mx, b.end());
	yo(b, a);

	cout << "No\n";
    return 0;
}

Measured memory_bytes: 13736
fun main(args: Array<String>) {
    val (w, h, n) = readLine()!!.split(" ").map { it.toInt() }
    var l = 0
    var r = w
    var d = 0
    var u = h
    for (i in 0 until n) {
        var(x, y, a) = readLine()!!.split(" ").map { it.toInt() }
        when(a) {
            1 -> l = Math.max(l, x)
            2 -> r = Math.min(r, x)
            3 -> d = Math.max(d, y)
            4 -> u = Math.min(u, y)
        }
    }
    println(Math.max(r-l, 0) * Math.max(u-d, 0))
}

Measured memory_bytes: 36028
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define fst first
#define snd second
using namespace std;
typedef long long ll;

string s;
int cnt[26];
int main(){
	cin >> s;
    fore(x,0,SZ(s))cnt[s[x]-'a']++;
    if(SZ(s)==26){
        string t=s;
        next_permutation(ALL(t));
        if(t>s){
            string last=t;
            while(t>s)last=t,t.pop_back();
            cout << last << "\n";
        }else cout<<"-1\n";
    }else{
        cout << s;
        fore(i,0,26)if(!cnt[i]){cout<<(char)(i+'a');break;}
        cout << "\n";
    }
}


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

int main(void){
char a[100],b[100],c[100];
  int o,p,q;
 scanf("%s",&a);
   scanf("%s",&b);
   scanf("%s",&c);
  o=strlen(a);
  p=strlen(b);
  q=strlen(c);
  if(a[o-1]==b[0]&&b[p-1]==c[0]){printf("YES");}
  else{printf("NO");}
return 0;
}

Measured memory_bytes: 128
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define be begin
#define sz(a) (ll)a.size()
#define INF 1e18
 
typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
 
// ll mod=998244353;
// ll gcd(ll a, ll b){
//     if(a<b) swap(a,b);
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
 
// ll fun(ll x, ll y){
//     ll rem=1;
//     while(y!=0){
//         if(y%2==1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y/=2;
//     }
//     return rem;
// }

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll dp[n+1][3];
	dp[0][0]=dp[0][1]=dp[0][2]=0;
	for(ll i=1,a,b,c;i<=n;i++){
		cin>>a>>b>>c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
	}
	cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << "\n";
	return 0;
}

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

typedef long long ll;

const ll inf=1e18;

int main(){
    int N; cin >> N;
    ll a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    int M=N%2+1;
    vector<vector<ll>> dp(N+10,vector<ll>(M+1,-inf));
    dp[0][0]=0;
    for(int i=0;i<=N;i++){
        for(int j=0;j<M;j++){
            dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]);
        }
        for(int j=0;j<=M;j++){
            dp[i+2][j]=max(dp[i+2][j],dp[i][j]+a[i]);
        }
    }
    cout << dp[N+1][M] << endl;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
ll a[maxn];
void run_case()
{
    int n;
    cin >> n;
    //ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n, greater<int>());
    ll ans = 1ll * a[1];
    int cnt = n - 2;
    for (int i = 2; i <= n; i++)
    {
        if (cnt == 0)
            break;
        ans += 1ll * a[i];
        cnt--;
        if (cnt == 0)
            break;
        ans += 1ll * a[i];
        cnt--;
        if (cnt == 0)
            break;
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 5192