akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
int main(){
  int N,i,j,k,x,y;scanf("%d",&N);
  pair<int,int> B[N];map<pair<int,int>,int> mp;
  for(i=0;i<N;i++){
    scanf("%d%d",&x,&y);
    B[i] = make_pair(x,y);
    mp[make_pair(x,y)] = i;
  }
  int ans = N,now,nx,ny;queue<pair<int,int>> q;
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;j++){
      x = B[i].first-B[j].first;y = B[i].second-B[j].second;
      bool use[N] = {};now = 0;
      for(k=0;k<N;k++){
        if(use[k]) continue;
        use[k] = true;
        nx = B[k].first+x;ny = B[k].second+y;
        while(mp.count(make_pair(nx,ny))){
          use[mp[make_pair(nx,ny)]] = true;
          nx += x;ny += y;
        }
        nx = B[k].first-x;ny = B[k].second-y;
        while(mp.count(make_pair(nx,ny))){
          use[mp[make_pair(nx,ny)]] = true;
          nx -= x;ny -= y;
        }
        now++;
      }    
      ans = min(ans,now);
    }
  }
  printf("%d\n",ans);
}

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

int main() {
  char a,b;
  cin>>a>>b;
  if(a=='H'){
    if(b=='H') cout<<"H"<<endl;
    else cout<<"D"<<endl;
  }else{
    if(b=='D') cout<<"H"<<endl;
    else cout<<"D"<<endl;
  }

}


Measured memory_bytes: 256
n=int(input())
s=[input() for _ in range(n)]
d0={}
d1={}
ma=0
mab=0
for si in s:
    a,b=0,0
    for x in si:
        if x=='(':
            b+=1
        else:
            b-=1
        a=min(b,a)
    a=-a
    if b>=0:
        if a in d0:
            d0[a].append([a,b])
        else:
            d0[a]=[[a,b]]
        ma=max(ma,a)
    else:
        if a+b in d1:
            d1[a+b].append([a,b])
        else:
            d1[a+b]=[[a,b]]
        mab=max(mab,a+b)
now=0
for i in range(ma+1):
    if i not in d0:continue
    if now>=i:
        for a,b in d0[i]:
            now+=b
    else:
        print('No')
        exit()
for i in range(mab,-1,-1):
    if i not in d1:continue
    for a,b in d1[i]:
        if now>=a:
            now+=b
        else:
            print('No')
            exit()
if now==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 247244
def main():

    A,B,C,X,Y = map(int,input().split())
    cSet = 2*C

    if X == Y:
        price = min(cSet*X, A*X+B*Y)
    elif X > Y:
        price = min(cSet*X, cSet*Y+A*(X-Y), A*X+B*Y)
    else:
        price = min(cSet*Y, cSet*X+B*(Y-X), A*X+B*Y)
    
    print(price)



 





if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
n, m = map(int, input().split())
s = list(input())[::-1]
i = 0
ans = 0
ans_list = []
while i < n:
    l = s[i+1:i+m+1]
    for next in range(m-1, -2, -1):
        if next == -1:
            print(-1)
            exit()
        if next > len(l)-1:
            continue
        if l[next] == '0':
            ans_list.append(next+1)
            i += next+1
            break
print(' '.join(map(str, ans_list[::-1])))


Measured memory_bytes: 11668
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int dh[4]={0,1,0,-1};
int dw[4]={1,0,-1,0};

ll n,m;
string s,t;

ll lcm(ll a,ll b){
      return (a*b)/__gcd(a,b);
}

int main(){ 
      cin>>n>>m;
      cin>>s>>t;
      ll g=__gcd(n,m);
      bool ok=true;
      for(ll i=0;i<g;i++){
            if(s[(n*i)/g]!=t[(m*i)/g]) ok=false;
      }
      if(ok) cout<<lcm(n,m)<<endl;
      else cout<<-1<<endl;

      return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <list>
#include <map>
#include <set>
using namespace std;

int sc[100005];

int main(void) {
	int n,k,r,p;
	scanf("%d %d %d",&n,&k,&r);
	for(int i = 0;i < r;i ++) {
		scanf("%d",&p);
		sc[p] ++;
	}
	for(int i = 1;i <= n;i ++) {
		if(sc[i] <= r - k) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}

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

const int maxn = 2e5 + 10;
const int N = 1e5 + 1;

int a[maxn], par[maxn], fen[maxn];
int n;

int get(int x){
	int ret = 0;
	for (x += N; x; x -= x & -x)
		ret += fen[x];
	return ret;
}

void add(int x, int val){
	for (x += N; x < maxn; x += x & -x)
		fen[x] += val;
}

ll check(int x){
	for (int i = 1; i <= n; i++)
		par[i] = (a[i] < x ? 1 : -1);
	for (int i = 1; i <= n; i++)
		par[i] += par[i - 1];

	add(par[0], +1);
	ll ret = 0;
	for (int i = 1; i <= n; i++) {
		ret += get(par[i] - 1);
		add(par[i], +1);
	}
	for (int i = 0; i <= n; i++)
		add(par[i], -1);
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	ll tot = 1ll * n * (n + 1) / 2;
	int lo = 1, hi = 1000 * 1000 * 1000 + 1;
	while (hi - lo > 1){
		int mid = (lo + hi) / 2;
		if (check(mid) > tot / 2)
			hi = mid;
		else
			lo = mid;
	}
	cout << lo << endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <unordered_map>
using namespace std;

int main(){
    long long n, a;
    cin >> n;
    unordered_map<long long,long long> m;
    long long arr[n];
    for(long long i = 0; i < n; i++){
        cin >> a;
        arr[i] = a;
        m[a]++;
    }
    long long r = 0;
    for(auto& x : m){
        r += (x.second*(x.second-1))/2;
    }
    for(long long i = 0; i < n; i++){
        long long x = (m[arr[i]]*(m[arr[i]]-1))/2, y = ((m[arr[i]]-1)*(m[arr[i]]-2))/2;
        cout << (r - x + y) << '\n';
    }
}


Measured memory_bytes: 9160
#include<iostream>
#include<vector>
using namespace std;
int main(void){
    int N,a;
    int cost=0;
    cin >> N;
    vector<int> V(N,0);
    vector<int> C(N,0);
    for(int i = 0; i < N; i++){
        cin >> a; V[i] = a;
    }
    for(int i = 0; i < N; i++){
        cin >> a; C[i] = a;
    }
    for(int i = 0; i < N; i++){
        if(V[i] > C[i]) cost += V[i]-C[i];
    }
    cout << cost <<endl;
}

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

int main() {
int N;
cin >> N;
string judge = "No";

for (int j = 9; j > 1; j--) {
    if (N % j == 0) {
        N /= j;
        break;
    }
}
if (N < 10) {
    judge = "Yes";
}
cout << judge << endl;
}

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

#define ll long long
#define rep(i,n) for(ll i=(ll)(0); i<(ll)(n); ++i)
#define irep(i,m,n) for(ll i=(ll)(m); i<(ll)(n); ++i)
#define vi vector<int>

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

const long long MOD = 1e9 + 7;

signed main()
{
  int n;
  cin>>n;
  vi t(n+1), x(n+1), y(n+1);
  irep(i,1,n+1) cin>>t[i]>>x[i]>>y[i];
  t[0]=x[0]=y[0]=0;
  
  
  rep(i,n){
    int T=t[i+1]-t[i];
    int X=abs(x[i+1]-x[i]);
    int Y=abs(y[i+1]-y[i]);
    if(T<X+Y||(X+Y)%2!=T%2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

void Main()
{
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  int cnt = 0;
  if ((A[0]%2 == 0 && A[1]%2 == 0 && A[2]%2 == 1) || 
      (A[0]%2 == 1 && A[1]%2 == 1 && A[2]%2 == 0))
  {cnt++; A[0]++; A[1]++;}
  else if ((A[0]%2 == 1 && A[1]%2 == 0 && A[2]%2 == 0) ||
           (A[0]%2 == 0 && A[1]%2 == 1 && A[2]%2 == 1))
  {
    cnt++; A[1]++;A[2]++;
  } else if ((A[0]%2 == 0 && A[1]%2 == 1 && A[2]%2 == 0) ||
           (A[0]%2 == 1 && A[1]%2 == 0 && A[2]%2 == 1)) {
    cnt++; A[0]++; A[2]++;
  }
  cnt += (A[2]-A[0])/2 + (A[2]-A[1])/2;
  cout << cnt << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    UnionFind tree(N + 1);
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        tree.unite(p[x - 1], p[y - 1]);
    }

    int output = 0;
    for (int i = 0; i < N; i++) {
        if (tree.same(p[i], i + 1)) {
            output++;
        }
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3944
N = int(input())
As = list(map(int, input().split()))

As = [0] + As + [0]
dist = [As[i]-As[i-1] for i in range(1,N+2)]
absdist = [abs(d) for d in dist]
s = sum(absdist)
for i in range(N):
    minus = abs(As[i+1]-As[i]) + abs(As[i+2]-As[i+1])
    plus = abs(As[i+2] - As[i])
    print(s+plus-minus)

Measured memory_bytes: 15296
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1

s = int(input())

l = []
l.append(s)

c = 1

while f(s) not in l:
    s = f(s)
    l.append(s)
    c+=1

print(c+1)

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

#define ll long long
#define mx  500005
#define mod 1000000009
#define lim 1000005
#define inf 2000000000
#define N 18
#define eps 100000
#define PI acos(-1)

using namespace std;
struct utyp
{
	int x,y,a,b;
};

int grid[505][505],vis[505][505],h,w;
vector<utyp>op;
int dy[]={0,0,1,-1};
int dx[]={1,-1,0,0};

void dfs(int uy,int ux,int coin)
{
	vis[uy][ux]=1;
	grid[uy][ux]+=coin;
	coin=0;
	for(int i=0;i<4;i++)
	{
		int vy=uy+dy[i];
		int vx=ux+dx[i];
		if(vy<0 || vx<0 || vy>=h || vx>=w || vis[vy][vx])continue;

		if(grid[uy][ux]&1)coin=1,grid[uy][ux]--;

		if(coin)op.push_back({uy+1,ux+1,vy+1,vx+1});

		dfs(vy,vx,coin);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	memset(vis,0,sizeof(vis));

	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
			cin>>grid[i][j];
	}

	dfs(0,0,0);

	cout<<op.size()<<"\n";

	for(int i=0;i<op.size();i++)
		cout<<op[i].x<<" "<<op[i].y<<" "<<op[i].a<<" "<<op[i].b<<"\n";
	return 0;
}



Measured memory_bytes: 29680
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(){
    ll h,w,n;
    cin>>h>>w>>n;
    ll si,sj;
    cin>>si>>sj;
    string S,T;
    cin>>S>>T;
    //right
    ll pos=sj;
    for(int i=0;i<S.size();i++){
        if(S[i]=='R') pos++;
        if(pos>w){
            cout<<"NO"<<endl;
            return 0;
        }
        if(T[i]=='L'&&pos>1) pos--;
    }
    //left
    pos=sj;
    for(int i=0;i<S.size();i++){
        if(S[i]=='L') pos--;
        if(pos<1){
            cout<<"NO"<<endl;
            return 0;
        }
        if(T[i]=='R'&&pos<w) pos++;
    }
    //up
    pos=si;
    for(int i=0;i<S.size();i++){
        if(S[i]=='U') pos--;
        if(pos<1){
            cout<<"NO"<<endl;
            return 0;
        }
        if(T[i]=='D'&&pos<h) pos++;
    }
    //down
    pos=si;
    for(int i=0;i<S.size();i++){
        if(S[i]=='D') pos++;
        if(pos>h){
            cout<<"NO"<<endl;
            return 0;
        }
        if(T[i]=='U'&&pos>1) pos--;
    }
    cout<<"YES"<<endl;
    return 0;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n, q;
    cin >> n >> q;
    vec<ll> a(n);
    REP(i, n) { cin >> a[i]; }

    vec<ll> con(n, 0);
    vec<ll> sum(n + 1, 0);
    REP(i, n) {
        con[i] = a[i] + (i - 2 >= 0 ? con[i - 2] : 0);
        sum[i + 1] = sum[i] + a[i];
    }

    auto check = [&](ll x, ll i) -> bool {
        if(a[i] <= x)
            return false;
        ll d = a[i] - x;
        ll y = i - (lower_bound(all(a), x - d) - a.begin());
        return y >= n - 1 - i;
    };

    REP(i, q) {
        ll x;
        cin >> x;

        ll l = 0;
        ll r = n;
        while(l + 1 < r) {
            ll m = l + r >> 1;
            if(check(x, m))
                r = m;
            else
                l = m;
        }

        cout << sum[n] - sum[r] + (n - 1 - (n - r) * 2 >= 0 ? con[n - 1 - (n - r) * 2] : 0) << en;
    }
}

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

    solve();
    /*
    ll t;
    cin >> t;
    REP(i, t)
    solve();
    */

    return 0;
}


Measured memory_bytes: 5572
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
int N,K;
cin>>N>>K;
vector<int> l(N);
for(int i=0;i<N;i++){
cin>>l[i];
}
sort(l.begin(),l.end());
int sum =0;
for(int i=0;i<K;i++){
sum += l[N-i-1];
}
cout<< sum <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               ll a,b;
               cin>>a>>b;
               ll n = __gcd(a,b);
               int count=0;
               while(n%2==0)
                    n/=2;
               count++;
               n = __gcd(a,b);
               for(ll i=2;i*i<=__gcd(a,b);i++)
               {
                    if(n%i==0)
                    {
                         while(n%i==0)
                         {
                              n/=i;
                         }
                         count++;
                    }

               }
               if(n>1)
                    count++;
               cout<<count;

       }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int n;
int a[114514];
int main(){
	int ans=0;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)mp[a[i]]++;
	for(auto x:mp){
		if(x.second<x.first)ans+=x.second;
		else ans+=x.second-x.first;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
using namespace std;
int a[100000];
int b[100000];
int main(){
    a[1]=1;
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        b[i]=1;
    }
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        if(a[x]==1) {
            a[y]=1;
            if(b[x]==1) a[x]=0;
        }
        b[y]++;
        b[x]--;
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=a[i];
    }
    cout<<sum;
}

Measured memory_bytes: 1024
h, w, k = map(int, input().split())
fib = [0, 1, 1, 2, 3, 5, 8, 13, 21]
dp = [[0] * (w + 2) for i in range(h + 1)]
dp[0][1] = 1

for j in range(h):
    for l in range(1, w + 1):
        dp[j + 1][l] = fib[l] * fib[w - l + 1] * dp[j][l] + fib[l - 1] * fib[w - l + 1] * dp[j][l - 1] + fib[l] * fib[w - l] * dp[j][l + 1]

print(dp[h][k] % 1000000007)


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

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

S = 0
for i in range(N):
    S += B[A[i]-1]
    if(i > 0 and A[i-1]+1 == A[i]):
        S += C[A[i-1]-1]

print(S) 

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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

void solve() {
    int n;
    cin >> n;

    /**
     * dp[l][r] = max(dp[l-1][r] + Ai * |idx-l|,
     *                  dp[l][r-1] + Ai * |n-idx|)
     */
    vector<pair<ll,ll>> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i].first;
        A[i].second = i; 
    }
    sort(A.begin(), A.end(), greater<pair<ll,ll>>());

    vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            int curr_ele = i+j-1;
            if (curr_ele < 0 || curr_ele >= n) {
                continue;
            }
            if (i > 0) {
                dp[i][j] = max(
                    dp[i][j], 
                    dp[i-1][j] + A[curr_ele].first * abs(A[curr_ele].second - i + 1)
                );
            }
            if (j > 0) {
                dp[i][j] = max(
                    dp[i][j],
                    dp[i][j-1] + A[curr_ele].first * abs(n - j - A[curr_ele].second)
                );
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans = max(ans, dp[i][n-i]);
    }

    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 34580
import sys
from time import time, sleep
from random import random
from bisect import bisect, bisect_left
def inpl(): return list(map(int, input().split()))
start = time()
D = int(input())
C = inpl()
S = [inpl() for _ in range(D)]
X = [0]*D
res = []
max_score = 0

score = 0
A = [[] for _ in range(26)]
used = [1]*26
for i in range(D):
    if (i%26) == 0:
        for j in range(26):
            used[j] = 0
    K = sorted(list(range(26)), key=lambda x: -S[i][x])
    for k in K:
        if not used[k]:
            used[k] = 1
            X[i] = k
            break
    A[X[i]].append(i)
#print(max_score, file=sys.stderr)

from bisect import bisect
while (time() - start < 1.8):
    tmp = 0
    d = int(random() * D)
    x = X[d]
    y = int(random() * 26)
    if x == y:
        continue
    tmp += -S[d][x] + S[d][y]
    di = bisect_left(A[x], d)
    d0 = -1 if di == 0 else A[x][di-1]
    d2 = D - 1 if (di >= len(A[x]) - 1) else A[x][di+1]
    tmp += -(d2-d0)*(d2-d0-1)*C[x]//2 + (d-d0)*(d-d0-1)*C[x]//2 + (d2-d)*(d2-d-1)*C[x]//2

    d0i = bisect_left(A[y], d) - 1
    d0 = -1 if d0i == -1 else A[y][d0i]
    d2 = D - 1 if d0i == len(A[y]) - 1 else A[y][d0i+1]
    tmp += (d2-d0)*(d2-d0-1)*C[y]//2 - (d-d0)*(d-d0-1)*C[y]//2 - (d2-d)*(d2-d-1)*C[y]//2
    if (tmp > 0):
        #print(tmp, file=sys.stderr)
        A[x].pop(di)
        A[y].insert(d0i+1, d)
        X[d] = y
        max_score += tmp
#print(max_score, file=sys.stderr)
for x in X:
    print(x+1)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S, T;
    cin >> S >> T;

    reverse(S.begin(), S.end());

    if(S == T){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, pair<int, int> > p;
 
#define MOD 1000000007

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

    ll x, k, d;
    cin >> x >> k >> d;

    ll c = abs(x) / d;

    if(c >= k) {
        cout << abs(x) - k * d << endl;
        return 0;
    }

    x = abs(x) - c * d;
    k -= c;

    if(k % 2) {
        cout << abs(x - d) << endl;
    } else {
        cout << x << endl;
    }
}

Measured memory_bytes: 3648
n = int(input())
A = list(map(int, input().split()))
cnt = 0
flg = 1
while flg:
    flg = 0
    for i in range(n - 1, 0, -1):
        if A[i] < A[i - 1]:
            A[i], A[i - 1] = A[i - 1], A[i]
            cnt += 1
            flg = 1
print(' '.join(map(str, A)))
print(cnt)


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

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

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

   double ave;
   ave = (v.at(0) + v.at(1))/2.0;
   for (int i=2; i<N; i++){
      ave = (ave + v.at(i))/2.0;
   }

   cout << setprecision(6) << ave << endl;
}



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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   
// mod. m での a の逆元 a^{-1} を計算する
// 逆元をかければ割ったことになる
//かけた後MODするの忘れない
ll modinv(ll a) {
    ll b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,a,b,c;cin>>n>>a>>b>>c;
  vector<ll> x(n+1),y(n+1),z(n+1),l(n+1);
  x[0]=1;y[0]=1;z[0]=1;l[0]=1;
  for(i=1;i<=n;i++){
    x[i]=(x[i-1]*a)%MOD;
    y[i]=(y[i-1]*b)%MOD;
    z[i]=(z[i-1]*100)%MOD;
    l[i]=(l[i-1]*(a+b))%MOD;
    //cout<<x[i] spa y[i] spa z[i] spa l[i]<< endl;
  }
  ll sum=0;
  ll p=1;
  for(i=0;i<n;i++){
    buf=(x[n]*y[i])%MOD;
    buf=(buf*p)%MOD;
    buf=(buf*l[n-i])%MOD;
    buf=(buf*(n+i))%MOD;
    sum=(sum+buf)%MOD;
    p=((n+i)*p)%MOD;
    p*=modinv(i+1);
    p%=MOD;
    //cout<<p<<endl;
  }
  p=1;
  for(i=0;i<n;i++){
    buf=(x[i]*y[n])%MOD;
    //cout<<buf<<endl;
    buf=(buf*p)%MOD;
    //cout<<buf<<endl;
    buf=(buf*l[n-i])%MOD;
    //cout<<buf<<endl;
    buf=(buf*(n+i))%MOD;
    //cout<<buf<<endl;
    sum=(sum+buf)%MOD;
    p=((n+i)*p)%MOD;
    p*=modinv(i+1);
    p%=MOD;
    //cout<<buf<<endl;
  }
  sum*=100;
  sum%=MOD;
  buf2=(l[n]*l[n])%MOD;
  buf2=(buf2*(100-c))%MOD;
  //cout<<sum spa buf2 << endl;
  sum*=modinv(buf2);
  sum%=MOD;
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#define LEN 100005

/*?§????????????????*/
typedef struct pp {
    char name[100];
    int t;
} P;
//????????¨???????????????????????????P??¨?????????????????????

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail+1) %LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head+1)%LEN;
    return x;
}

int min(int a,int b){ return a<b ?a:b;}
// return????????¨if(a<b){return a}else{return b}?????????



int main() {
    int elaps = 0,c;
    int n;
    int q;
    int i;
    P u;
    scanf("%d %d",&n,&q);
    
    for (i=1; i<=n;i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head = 1;
    tail = n+1;
    
    
    while (head != tail){
        u = dequeue();
        c = min(q,u.t);
        u.t -= c;
        elaps += c;
        if(u.t >0) enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}

Measured memory_bytes: 10756
#include<bits/stdc++.h>
using namespace std;
long long GCD(long long a,long long b){return b? GCD(b,a%b):a;}
map<long long,int>prime_factor(long long n){
    map<long long,int> ret;
    for(long long i=2;i*i<=n;i++){
        while(n%i==0){
            ret[i]++;
            n/=i;
        }
    }
    if(n!=1)ret[n]=1;
    return ret;
}
int main(){
           long long A,B;cin>>A>>B;
           long long C=GCD(A,B);
           map<long long,int>s=prime_factor(C);
           int res=1+s.size();
           cout<<res<<endl;

}

Measured memory_bytes: 256
N, M = map(int, input().split())
G = [[] for _ in range(N)]
visited = [False]*N
visited_all = [True]*N
for i in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
ans = [0]
  
def dfs(node):
  visited[node] = True
  if visited == visited_all:
    ans[0] += 1
  else:
    for i in range(len(G[node])):
      next_node = G[node][i]
      if visited[next_node] == True:
        continue
      dfs(next_node)
      visited[next_node] = False

dfs(0)
print(ans[0])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;

#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
struct UnionFind{
    vector<int> parent;
    vector<int> rank;
    UnionFind(int n):parent(n),rank(n){
        for (int i=0;i<n;i++){
            parent[i]=i;
            rank[i]=0;
        }
    }
    int root(int x){
        if (parent[x]==x)return x;
        return parent[x]=root(parent[x]);
    }
    void unite(int x, int y){
        int rx=root(x);
        int ry=root(y);
        if (rx==ry)return;
        if (rank[rx]<rank[ry]) parent[rx]=ry;
        else{
            parent[ry]=rx;
            if (rank[rx]==rank[ry]) rank[rx]++;
        }
    }
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> f[d5],d[d5];
    UnionFind uf(n),ud(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        f[a].push_back(b);
        f[b].push_back(a);
        uf.unite(a,b);
    }
    for(int i=0;i<k;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        d[a].push_back(b);
        d[b].push_back(a);
        ud.unite(a,b);
    }
    unordered_map<int,int> like,hate;
    for(int i=0;i<n;i++){
        like[uf.root(i)]++;
        hate[ud.root(i)]++;
    }
    for(int i=0;i<n;i++){
        int res=like[uf.root(i)]-f[i].size();
        for(auto it:d[i]){
            if(uf.same(i,it)){
                if(ud.same(i,it))res--;
            }
        }
        cout<<res-1<<endl;
    }
}

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

int main() {
	int a, b;
	cin >> a >> b;
	for(int i = 1; i <= 100000; ++i) {
		int r1 = ((long double)i) * 0.08;
		int r2 = ((long double)i) * 0.1;
		if(r1 == a && r2 == b) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[200][200];

int main() {
  clr(d,0);
  ll h,w;
  cin>>h>>w;
  rep(y,0,h){
    string s;
    cin>>s;
    rep(x,0,w){
      if(s[x]=='#'){
        d[100+y][100+x]=1;
      }
    }
  }
  ll dy[8] = {-1,-1,-1,0,0,1,1,1};
  ll dx[8] = {-1,0,1,-1,1,-1,0,1};
  rep(y,0,h){
    rep(x,0,w){
      if(d[100+y][100+x]==1){
        cout << "#";
      }
      else{
        ll c = 0;
        rep(i,0,8){
          if(d[100+y+dy[i]][100+x+dx[i]]==1){
            c++;
          }
        }
        cout << c;
      }
    }
    cout << endl;
  }
  return 0;
}






Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<ll>sum(n+1);
    ll a;
    map<ll,ll>mp;
    rep(i,n){
      cin>>a;
      sum[i+1]=sum[i]+a;
      mp[sum[i+1]]++;
    }
    ll ans=0;
    mp[0]++;
    rep(i,n){
      mp[sum[i+1]]--;
      ans+=mp[sum[i+1]];
    }
    cout<<ans<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 14336
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  string S;
  cin>>S;
  int len=S.length();
  repr(i,len/2-1,1){
    bool ans=true;
    rep(j,i){
      if(S[j]!=S[i+j]) ans=false;
    }
    if(ans){
      cout<< 2*i <<"\n";
      return;
    }
  }
}


//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
program prob4
    implicit none
    integer(8) :: n, m
    integer(8), allocatable :: a(:), b(:)
    integer(8) :: i, ans, cnt, mo
    read(*,*) n, m
    allocate(a(n), b(n))
    do i = 1, n
        read(*,*) a(i), b(i)
    end do
    mo = 1000000
    do i = 1, n
        a(i) = mo * a(i) + b(i)
    end do

    call msort(a)

    do i = 1, n
        b(i) = mod(a(i), mo)
        a(i) = a(i) / mo
    end do
    cnt = 0
    ans = 0
    do i = 1, n
        if(cnt + b(i) < M) then
            ans = ans + b(i) * a(i)
            cnt = cnt + b(i)
        else
            ans = ans + (M - cnt) * a(i)
            cnt = M
            exit
        end if
    end do

    write(*,*) ans

    deallocate(a, b)
    stop
contains


  !
  ! swap two arguments
  !
subroutine swap(a, b)
    implicit none
    integer(8), intent(inout) :: a, b

    integer(8) :: c

    c = a
    a = b
    b = c

  end subroutine swap

  !
  ! merge sort
  !
  recursive subroutine msort(x)
    implicit none
    integer(8), intent(inout) :: x(:)

    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if

    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call msort(x(:mid))
    call msort(x(mid+1:))

    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n))
    tmp = x

    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
    end do

    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n

    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        i = i + 1
      else
        x(k) = tmp(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp)
    return
  end subroutine msort
end program prob4

Measured memory_bytes: 5096
# -*- coding: utf-8 -*-
import sys
N,M,K=map(int, sys.stdin.readline().split())

par=[ i for i in range(N+1) ]
size=[ 1 for i in range(N+1) ]

def root(x):
    while par[x]!=x:
        x=par[x]
    return x

def same(x,y):
	return root(x)==root(y)

def unite(x,y):
    x=root(x)
    y=root(y)
    if x==y: return
    if size[y]<size[x]: x,y=y,x  #yの要素数を大きくする
    size[y]+=size[x]
    par[x]=y

def getsize(x):
	return size[root(x)]

al_ok=[ 0 for i in range(N+1) ]	#隣接で友達関係のカウント

for _ in range(M):
    a,b=map(int, sys.stdin.readline().split())
    unite(a,b)
    al_ok[a]+=1
    al_ok[b]+=1

al_ng=[ 0 for i in range(N+1) ]	#隣接でブロックしている人のカウント
for _ in range(K):
    c,d=map(int, sys.stdin.readline().split())
    if same(c,d):
        al_ng[c]+=1
        al_ng[d]+=1

for i in range(1,N+1):
    print getsize(i)-1-al_ok[i]-al_ng[i],


Measured memory_bytes: 38428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1e9+7;
const ll ARR_MAX = 3e3+1;
const ll INF=1e14;

ll dp[ARR_MAX][ARR_MAX]; //dp[i][j] = maximum value of X-Y when a[i ... j] is left.

void solve(){	
    int n;cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    for(int i=0;i<n;i++){
    	dp[i][i]=a[i];
    }
    int i=0;
    for(int d=1;d<n;d++){
    	for(i=0;i+d<n;i++){
    		dp[i][i+d]=max(a[i]-dp[i+1][i+d],a[i+d]-dp[i][i+d-1]);
    	}
    }
    cout<<dp[0][n-1]<<nl;
}

int main(){
    fastio();
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 70016
package main

import "fmt"
import "strconv"

func main() {
  for i := 1; i <= 9; i++ {
    for j := 1; j <= 9; j++ {
      res := i * j
      fmt.Println(strconv.Itoa(i) + "x" + strconv.Itoa(j) + "=" + strconv.Itoa(res))
    }
  }
}



Measured memory_bytes: 1076
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

char C;

int main() {
    cin >> C;
    printf("%c\n", C+1);
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramB
    {
        static void Main()
        {
            var s = Line;

            if (s.Select((c, i) => (i % 2 == 0 ? 'L' : 'R') == c).Any(b => b))
            {
                System.Console.WriteLine("No");
            }
            else
            {
                System.Console.WriteLine("Yes");
            }
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

vector<ll> V;

int ans = -1;

void recursive(ll N,int index,int count){

	if(N == 1){
		ans = max(ans,count);
		return;
	}

	if(N < V[index] || index == (int)V.size())return;

	recursive(N,index+1,count);

	while(N%V[index] == 0){
		N /= V[index];
		recursive(N,index+1,++count);
	}
}

int main(){

	ll POW[18];

	for(int i = 0; i <= 17; i++){
		POW[i] = pow(10,i);
	}

	ll tmp;
	int limit;

	ll N;
	scanf("%lld",&N);
	if(N == 1){
		printf("-1\n");
		return 0;
	}

	for(int length = 1; length <= 18; length++){
		limit = pow(2,length);
		for(int state = 0; state < limit; state++){
			tmp = 0;
			for(int loop = 0; loop < length; loop++){
				if(state & (1 << loop)){
					tmp += 8*POW[loop];
				}else{
					tmp += 2*POW[loop];
				}
			}
			if(N%tmp == 0){ //?????????????????°????????§??????!!!
				V.push_back(tmp);
			}
		}
	}

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

	if(V.size() == 0){
		printf("-1\n");
		return 0;
	}

	recursive(N,0,0);

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

	return 0;
}

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

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto V = aryread();
    V.sort();
    double ans = V[0];
    foreach (v; V[1 .. $])
    {
        ans = (ans + v) / 2.0;
    }
    writefln("%.10f", ans);
}


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define maxn  200001
#define LL long long
using namespace std;
char s[maxn];
LL len,dp[maxn],num[maxn];
int main(){
	scanf("%s",s+1);
	LL len=strlen(s+1);
	num[s[1]-'a']=1;
	dp[1]=1;
	for(LL i=2;i<=len;i++){
		dp[i]=dp[i-1]+i-1-num[s[i]-'a'];
		num[s[i]-'a']++;
	}
	printf("%lld",dp[len]);
	return 0;
}

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define int ll
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

void solve() {
	int a[5];
	F0R(i,5) cin >>a[i];
	F0R(i,5) {
		if(a[i]==0) {
			cout << i+1;
			break;
		}
	}
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}



Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <numeric>

//#define DEBUG
using namespace std;

int main(){
    vector<int> A(3);
    for(int i = 0; i < 3; i++){
        cin >> A.at(i);
    }
    int five = 0;
    int seven = 0;
    for(int i = 0; i < 3; i++){
        if(A.at(i) == 5){
            five++;
        }
        else if(A.at(i) == 7){
            seven++;
        }
    }
    if(seven == 1 && five == 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i=0;i<n;i++) cin >> A[i];
    for(int i=0;i<=n-1-k;i++){
        if(A[i]<A[i+k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

int main() {
int N , K , X;
cin >> N >> K;
int V = 0;
for (int i = 0; i < N; i++){
  cin >> X;
  if ((K - X )* 2 < 2 * X){
    V += (K - X )* 2;
  }else{
    V +=2 * X;
  }
} 
cout << V << endl;
}

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

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

a = sum(List)/(4*M)
b = max(List)

List.sort(reverse=True)
ans = 1

for i in range(M):
  if List[i] >= a:
    ans = 1
  else:
    ans = 0

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

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int x[MAX_N],y[MAX_N];
int n,w,h;

int main()
{
	scanf("%d%d%d",&n,&w,&h);
	rep(i,n){
        int p,q,r;
		scanf("%d%d%d",&p,&q,&r);
        x[max(p-r,0)]++;
        x[min(p+r,w+1)]--;
        y[max(q-r,0)]++;
        y[min(q+r,h+1)]--;
	}
    rep(i,w){
        x[i+1] += x[i];
    }
    rep(i,h){
        y[i+1] += y[i];
    }
    int flag = 0;;
    rep(i,w){
        if(x[i] <= 0){
            flag++;
            break;
        }
    }
    rep(i,h){
        if(y[i] <= 0){
            flag++;
            break;
        }
    }
    if(flag == 2){
        cout << "No\n";
    }else{
        cout << "Yes\n";
    }
	return 0;
}

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

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int a,b,c;

int main()
{
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String S=scan.next();
		String d[]=S.split("");
		String a="No";
		if(d[2].equals(d[3])){
			if(d[4].equals(d[5])){
				a="Yes";
			}
		}
		System.out.println(a);
	}

}

Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>

using namespace std;

int main(void)
{
    int a,b,c,d;
    cin >>a >>b >>c >>d;


    while(a >= 0 && c >= 0){
        c -= b;
        if(c <= 0){
            printf("Yes\n");
            break;
        }
        a -= d;
        if(a <= 0){
            printf("No\n");
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
n, k = map(int, input().split())

if (n-1)*(n-2)//2 < k:
    print(-1)
    exit()

E = []
for i in range(n-1):
    E.append((1, i+2))

for i in range(2, n):
    for j in range(i+1, n+1):
        E.append((i, j))

m = n-1 + (n-1)*(n-2)//2 - k
print(m)
for i in range(m):
    print(*E[i])


Measured memory_bytes: 43120