akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
 
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 
 
 
ll n, m, k, q, l, r, x, y, z;
const ll template_array_size = 1e6 + 1389;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;
 
 
 
void solve(int tc = 0) {
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (ll i = 0; i < n; i++) {
		cin >> b[i];
	}
	
	reverse(b, b + n);
	
	ll lpt = 0, rpt = n - 1;
	
	for (ll i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			if (b[lpt] != b[i] && a[lpt] != b[i]) {
				swap(b[i], b[lpt]);
				++lpt;
			} else if (b[rpt] != b[i] && a[rpt] != b[i]) {
				swap(b[i], b[rpt]);
				--rpt;
			} else {
				cout << "No\n";
				return;
			}
		}
	}
	
	for (ll i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			cout << "No\n";
			return;
		}
	}
	
	cout << "Yes\n";
	for (ll i = 0; i < n; i++) {
		cout << b[i] << " ";
	}
	cout << '\n';
}
 
int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif
	
	send help
 
	#ifndef galen_colin_local
		// usaco("moop");
	#endif
	
	// usaco("cowland");
	
	// freopen("tc.cpp", "r", stdin);
 
	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);
	
	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
} 

Measured memory_bytes: 6792
import numpy as np

N, M, X, Y = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

min_x = np.min(x)
max_x = np.max(x)
min_y = np.min(y)
max_y = np.max(y)

if(X < Y): #ZはXより大きな整数であるため
    if((max_x < min_y) and (max_x < Y) and (min_y > X)):
        print("No War")
    else:
        print("War")
else:
    print("War")

Measured memory_bytes: 20852
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <sstream>
using namespace std;

string toString(int n){
  ostringstream os;
  os << n;
  return os.str();
}

int main(){
  int Q;
  string N;

  cin >> Q;
  while(Q--){
    cin >> N;  
    int i;
    for(i = 0 ; N.size() != 1 ; i++){
      int ans = -1;
      for(int j = 1 ; j < N.size() ; j++){
	string a = N.substr(0, j);
	string b = N.substr(j);
	ans = max(ans, atoi(a.c_str()) * atoi(b.c_str()));
      }
      N = toString(ans);
    }
    cout << i << endl;
  }
  return 0;
}  

Measured memory_bytes: 1232
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma endregion

int main() {
	lint n, m; cin >> n >> m;
	vector<lint> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<pair<lint, lint>> d(m);
	for (int i = 0; i < m; i++) cin >> d[i].second >> d[i].first;
	sort(d.rbegin(), d.rend());
	lint cnt = 0;
	for (auto s : d) {
		for (int i = 0; i < s.second; i++) {
			if (cnt > n) goto Cyan;
			a.emplace_back(s.first);
			cnt++;
		}
	}
Cyan:;
	sort(a.rbegin(), a.rend());
	lint ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}

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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int A, B;
    cin >> A >> B;
    if ((A % 2 != 0) && (B % 2 != 0)) {
        print("Yes");
    } else {
        print("No");
    }
}

signed main() {
    solve();
}


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

#define fi first
#define se second

const int N = 511 * 511;

int a[N];
bool vis[N];

using pii = pair <int, int>;
pii dir[] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

int main() {
	ios :: sync_with_stdio(0);
	int n; cin >> n;
	
	for(int i = 0; i < n; i ++)
		for(int j = 0; j < n; j ++)
			a[i * n + j] = min(min(i, n - i - 1),
				min(j, n - j - 1));
	
	int ans = 0;
	for(int i = 0; i < n * n; i ++) {
		int id; cin >> id; id --;
		ans += a[id];
		vis[id] = 1;
		
		queue <int> q; q.push(id);
		while(!q.empty()) {
			int x = q.front(); q.pop();
			for(auto p : dir) {
				int tx = x / n + p.fi;
				int ty = x % n + p.se;
				if(tx >= 0 && tx < n && ty >= 0 && ty < n)
					if(a[tx * n + ty] > a[x] + 1 - vis[x]) {
						a[tx * n + ty] = a[x] + 1 - vis[x];
						q.push(tx * n + ty);
					}
			}
		}
		
		//~ cout << id << '\n';
		//~ for(int i = 0; i < n; i ++) {
			//~ for(int j = 0; j < n; j ++)
				//~ cout << a[i * n + j] << ' ';
			//~ cout << '\n';
		//~ }
	}
	cout << ans << '\n';
}


Measured memory_bytes: 4812
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;

int main(){

    int n,c;
    scanf("%d%d",&n,&c);
    int tmp,sum=0;
    REP(i,c){
        scanf("%d",&tmp);
        sum+=tmp;
    }

    cout<<sum/(n+1)+(sum%(n+1)>0)<<endl;

    return 0;
}



Measured memory_bytes: 3220
import java.util.Scanner;

public class Main{
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        int H = scanner.nextInt();
        int W = scanner.nextInt();
        while(!(H == 0 && W == 0)){
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    if((i + j) % 2 == 0)
                        System.out.print("#");
                    else
                        System.out.print(".");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
            H = scanner.nextInt();
            W = scanner.nextInt();
        }
    }
}



Measured memory_bytes: 38320
#include <stdio.h>

int main(void)
{
	int i=0,x[10000],y[10000],z[10000];
	while(1){
		scanf("%d %d",&x[i],&y[i]);
		if(x[i]==0&y[i]==0)break;
		if(x[i]>y[i]){
			z[i]=x[i];
			x[i]=y[i];
			y[i]=z[i];
		}
		i++;
	}
	i=0;
	while(1){
		if(x[i]==0&y[i]==0)break;
		printf("%d %d\n",x[i],y[i]);
		i++;
	}

	return 0;
}

Measured memory_bytes: 624
n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
mosters=sum(a)

for i in range(n):
    hunted1 = min(a[i],b[i])
    a[i] -=hunted1
    b[i] -=hunted1
    hunted2 = min(a[i+1],b[i])
    a[i+1] -=hunted2
    b[i] -=hunted2
    
print(mosters-sum(a))

Measured memory_bytes: 24232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n,k;cin>>n>>k;
    ll l[k],r[k];rep(i,0,k-1)cin>>l[i]>>r[i];
    ll desk[n+1];rep(i,0,n)desk[i]=0;
    ll sum[n+1];rep(i,0,n)sum[i]=0;
    desk[1]=1;
    desk[2]=-1;
    
    rep(i,1,n){
        sum[i]=mod(sum[i-1]+desk[i]);
        rep(j,0,k-1){
            if(i+l[j]<=n){
                desk[i+l[j]]=mod(desk[i+l[j]]+sum[i]);
            }
            if(i+r[j]+1<=n){
                desk[i+r[j]+1]=mod(desk[i+r[j]+1]-sum[i]);
            }
        }
    }
    
    cout<<mod(sum[n])<<endl;
    
    return 0;
}





Measured memory_bytes: 6776
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
using namespace std;
const int mod=1e9+7;
const int MAX=2e6+5;
int fact[MAX];
int fastpow(int a,int b)
{
	int wynik=1;
	while (b)
	{
		if (b&1)wynik=(wynik*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return wynik;
}

int binom(int a,int b)
{
	if (b>a)return 0;
	int licznik=fact[a];
	int mianownik=(fact[b]*(fact[a-b]))%mod;
	return (licznik*fastpow(mianownik,mod-2))%mod;
}

int inv(int x)
{
	return fastpow(x,mod-2);
}

int32_t main()
{
  BOOST;
 	int k;
 	string s;
 	cin>>k>>s;
 	int n=sz(s);
 	fact[0]=1;
 	for (int i=1;i<MAX;i++)fact[i]=(fact[i-1]*i)%mod;
 	int ans=0;
 	for (int i=n;i<=n+k;i++)
 	  ans=(ans+(binom(n+k,i)*fastpow(25,n+k-i))%mod)%mod;
 	cout<<ans;
  return 0;
}


Measured memory_bytes: 19832
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	int N; cin>>N;
	long T[N+1],A[N+1]; T[0] = 0; A[N] = 0;
	rep(i,1,N+1) cin>>T[i];
	rep(i,0,N) cin>>A[i];
	long H[N] = {};
	rep(i,0,N){
		if(T[i] < T[i+1]) H[i] = T[i+1];
		if(A[i] > A[i+1]) H[i] = A[i];
		if(T[i] < T[i+1] && A[i] > A[i+1])if(T[i+1] != A[i]){
			cout<<0<<endl;
			return 0;
		}
	}
	long ans = 1;
	rep(i,0,N){
        if(H[i] == 0) (ans *= min(T[i], A[i])) %= mod;
        else if(H[i] > min(T[i+1], A[i])) ans = 0;
    }
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#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;

template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = { -1, 1, 0, 0, 1, -1, -1, 1};

void solve() {
	int n;
	cin >> n;
	vi v(n);
	rep(i, 0, n - 1) cin >> v[i];
	sort(all(v));
	cout << abs(v[n - 1] - v[0]);
}

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


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

	// test
	solve();

	return 0;
}


Measured memory_bytes: 3672
#include<iostream>

using namespace std;

#define ll long long int
#define MOD 1000000007
#define N 200005

ll fact[N], inv[N], finv[N];

ll C(int a, int b) {
    if(a < b || b < 0) return 0;
    return fact[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

int main() {
    int n;
    ll a, b, c;
    cin >> n >> a >> b >> c;

    fact[0] = 1;
    fact[1] = 1;
    inv[1] = 1;
    finv[1] = finv[0] = 1;
    for(int i = 2; i < N; ++i) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
        finv[i] = finv[i -1] * inv[i] % MOD;
    }

    ll ans = 0, pa = a * inv[a + b] % MOD, pb = b * inv[a + b] % MOD;
    ll powa[N], powb[N];
    powa[0] = 1, powb[0] = 1;

    for(int i = 1;i < N; ++i) {
        powa[i] = powa[i - 1] * pa % MOD;
        powb[i] = powb[i - 1] * pb % MOD;
    }

    for(int i = 0; i < n; ++i) {
        ans = (ans + C(n + i - 1, i) * (i + n) % MOD * ((powa[i] * powb[n] % MOD + powb[i] * powa[n] % MOD))%MOD) % MOD;
    }
    ans = ans * inv[100 - c] % MOD * 100 % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8064
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    n = len(s)
    l = []
    for k,v in groupby(list(s)):
        l.append(len(list(v)))
    res = [0]*n
    cnt = 0
    for i in range(len(l)):
        #Rの処理
        if i%2 == 0:
            res[cnt+l[i]-1] += (l[i]+1) // 2
            res[cnt+l[i]] += l[i] // 2
            cnt += l[i]
        #Lの処理
        else:
            res[cnt] += (l[i]+1) // 2
            res[cnt-1] += l[i] // 2
            cnt += l[i]
    print(*res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 56072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
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 const INF = 1001001001;
ll const MOD = 1000000007;


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

int A[4];
string s;
cin >> s;
rep(i,4) A[i] = s[i] - '0';

rep(i,8){
    int tmp = A[0];
    char op1,op2,op3;
    if(i & 1){
        tmp += A[1];
        op1 = '+';
    }else{
        tmp -= A[1];
        op1 = '-';
        }
    if(i & 2){
        tmp += A[2];
        op2 = '+';
    }else{
        tmp -= A[2];
        op2 = '-';
    }
    if(i & 4){
        tmp += A[3];
        op3 = '+';
    }else{
        tmp -= A[3];
        op3 = '-';
    }
    if(tmp == 7){
        cout << A[0] << op1 << A[1] << op2 << A[2] << op3 << A[3] << "=7" << endl;
        return 0;
    }
}

}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <fstream>
#include <typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i, a, b) for (ll i = a; i < b; i++)
#define repj(j, a, b) for (ll j = a; j < b; j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define mod 1000000007
//#define lim 100001

using namespace std;
ll factorial(ll n) { return (n == 1 || n == 0) ? 1 : n * factorial(n - 1); }
int max3(int a, int b, int c) { return max(a, max(c, b)); }
int gcd(int a, int b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
ll power(ll a, ll n)
{
    if (n == 1)
        return a;
    else if (n == 0)
        return 1;
    else
    {
        ll r = power(a, n / 2);
        if (n % 2 == 0)
            return r * r;
        else
            return r * a * r;
    }
}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector<vector<int>> &v, vi &check, int start)
{
    check[start - 1] = 1;
    repj(j, 0, v[start - 1].size())
    {
        if (!check[v[start - 1][j] - 1])
        {
            dfs(v, check, v[start - 1][j]);
        }
    }
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
//works under 2 till 1e12

int printDivisors(int n)
{
    // Note that this loop runs till square root
    int num = INT_MIN;
    for (int i = 1; i <= sqrt(n); i+=2)
    {
        if (n % i == 0)
        {
            // If divisors are equal, print only one
            if (n / i == i){
                num = max(num, i);
            }

                else{
                    if(i==1){
                        num = max(num, i);
                    }
                    else{
                        num = max(num, max(n / i, i));
                    }

            } // Otherwise print both
        }
    }

    return num;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin >> k;
    if(gcd(k,10)!=1){
        cout << -1;
    }
    else{
        ll rem = 7; 
        ll power = 7; 
        ll n = 1; 
        while ((rem % k) != 0) 
        { 
        n++; 
        power = (power * 10) % k; 
        rem = (rem + power) % k; 
        }
    cout << n;
    }

    return 0;
}

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

int main(){

    string s;

    cin >> s;

    int cnt1 = 0;
    int cnt2 = 0;

    for (int i = 0; i < s.length(); i++) {
        
        int color = s[i] - '0';
        if (color == (i % 2)) {
            
            cnt2++;
        } else {
            cnt1++;
        }
        
    }

    cout << min(cnt1 ,cnt2) << endl;

    return 0;
    
    
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

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

    cout << (n-1)*(m-1) << endl;

    return 0;

}

Measured memory_bytes: 256
def main():
    S = input()
    size = len(S)
    ans = 0
    for left in range(size):
        for right in range(left, size):
            T = S[left:right + 1]
            if set(T) <= set("ACGT"):
                ans = max(ans, right - left + 1)
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61380
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if c > b || a > d {
		fmt.Println(0)
		return
	}

	var start, end int
	if a > c {
		start = a
	} else {
		start = c
	}
	if b < d {
		end = b
	} else {
		end = d
	}
	fmt.Println(end - start)
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
    int n, a[10*10*10*10*10*10], ans, cnteven[10*10*10*10*10*10], i;
    int cntodd[10*10*10*10*10*10], maxeven=0, maxodd=0, max=0,
        evenidx, oddidx;
    int maxodd2=0, maxeven2=0;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &a[i]);
        if(a[i]>max) max=a[i];
    }

    for(i=0;i<n;i++){
        if(i%2==0) cnteven[a[i]]++;
        else cntodd[a[i]]++;
    }

    for(i=0;i<=max;i++){
        if(maxeven<cnteven[i]){
            maxeven2=maxeven;
            maxeven=cnteven[i];
            evenidx=i;
        }
        else if(maxeven2<cnteven[i]){
            maxeven2=cnteven[i];
        }
        if(maxodd<cntodd[i]){
            maxodd2=maxodd;
            maxodd=cntodd[i];
            oddidx=i;
        }
        else if(maxodd2<cntodd[i]){
            maxodd2=cntodd[i];
        }
    }

    if(oddidx != evenidx) ans=n-maxeven-maxodd;
    else if(n-maxodd-maxeven2<n-maxodd2-maxeven) ans=n-maxodd-maxeven2;
    else ans=n-maxodd2-maxeven;
    
    printf("%d\n", ans);
    return 0;
}


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

bool solve() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    int cnt = 0;
    rep(i, 0, N) if(A[i] != i + 1) cnt++;
    if(cnt <= 2) return true;
    else return false;
}

int main() {
    cout << (solve() ? "YES" : "NO") << '\n';
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
use std::cmp::{max, min};
#[fastout]
fn main() {
    input! {
        s: Chars
    }
    let mut ans = s.len() - 1;
    for i in b'a'..=b'z' {
        let u = check(s.clone(), i as char);
        ans = min(u, ans);
    }
    println!("{}", ans);
}
fn check(s: Vec<char>, c: char) -> usize {
    let mut a = 0;
    let mut pre = 0;
    for i in 0..s.len() {
        if s[i] == c {
            a = max(a, pre);
            pre = 0;
        } else {
            pre += 1;
        }
    }
    a = max(a, pre);
    a
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
#define mxn 100010
#define LL long long
using namespace std;
LL n,sl,fh,ans,a[mxn],b[mxn];
LL rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
bool cmp(LL x,LL y) {return x>y;}
int main()
{
	n=rd();LL x;
	for(int i=1;i<=n;++i)
	{
		x=rd();
		if(x>=0) a[++a[0]]=x;
		else b[++b[0]]=x;
	}
	sort(a+1,a+a[0]+1);sort(b+1,b+b[0]+1,cmp);
	if(!b[0])
	{
		ans=a[1];
		for(int i=2;i<n;++i) ans-=a[i];
		ans=a[n]-ans;
		printf("%lld\n",ans);
		ans=a[1];
		for(int i=2;i<n;++i) printf("%lld %lld\n",ans,a[i]),ans-=a[i];
		printf("%lld %lld\n",a[n],ans);ans=a[n]-ans;
	}
	else
	{
		ans=b[1];
		for(int i=1;i<a[0];++i) ans-=a[i];
		if(a[0]) ans=a[a[0]]-ans;
		for(int i=2;i<=b[0];++i) ans-=b[i];
		printf("%lld\n",ans);
		ans=b[1];
		for(int i=1;i<a[0];++i) printf("%lld %lld\n",ans,a[i]),ans-=a[i];
		if(a[0]) printf("%lld %lld\n",a[a[0]],ans),ans=a[a[0]]-ans;
		for(int i=2;i<=b[0];++i) printf("%lld %lld\n",ans,b[i]),ans-=b[i];
	}
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
	int n,m;
  	cin >> n >> m;
	vi ac(n),wa(n);
  	rep(i,m){
    	int p;
      	string s;
      	cin >> p >> s;	
     	p--;
      	if(ac[p])continue;
      	if(s == "AC"){
        	ac[p]=1;
        }else{
        	wa[p]++;
        }
    }
  	
  	int ok=0,nok=0;
  	rep(i,n){
    	ok+= ac[i];
      	if(ac[i]==1) nok += wa[i];
    }
  	cout << ok << ' ' << nok << endl;
  	return 0;
}

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

int main(){
	int d_min, d_max, in, dif, k;
	d_min = INT_MAX;
	d_max = 0;
	for(int i=0; i<5; i++){
		cin >> in;
		d_max = max(d_max, in);
		d_min = min(d_min, in);
	}
	cin >> k;
	dif = d_max - d_min;
	if(dif <= k){
		cout << "Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}
	return 0;
}

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

int main()
{
	int N;
	char S[300001];
	scanf("%d", &N);
	scanf("%s", S);
	
	int i, count = 0, max = 0;
	for (i = 0; S[i] != 0; i++) if (S[i] == 'W') count++;
	for (i = 0, count; S[i] != 0; i++) {
		if (S[i] == 'W') count--;
		if (count > max) max = count;
		if (S[i] == 'E') count++;
	}
	
	printf("%d\n", N - max - 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2008
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

class SegmentTree {
  public:
    explicit SegmentTree(int n) : n_(n), v_(4 * n + 1, 0) {}

    ll query(int b, int e) {
      return query_aux(1, 1, n_, b, e);
    }

    void update(int ind, ll value) {
      update_aux(1, 1, n_, ind, value);
    }

  private:
    ll query_aux(int node, int lo, int hi, int b, int e) {
      if (e < lo || b > hi) return 0;
      if (b <= lo && hi <= e) return v_[node];

      int med = (lo + hi) / 2;
      return max(query_aux(2 * node, lo, med, b, e),
                 query_aux(2 * node + 1, med + 1, hi, b, e));
    }

    void update_aux(int node, int lo, int hi, int ind, ll value) {
      if (ind < lo || ind > hi) return;
      if (lo == hi) {
        v_[node] = value;
        return;
      }

      int med = (lo + hi) / 2;
      update_aux(2 * node, lo, med, ind, value);
      update_aux(2 * node + 1, med + 1, hi, ind, value);
      v_[node] = max(v_[2 * node], v_[2 * node + 1]);
    }

    int n_;
    vector<ll> v_;
};

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

  int n;
  cin >> n;

  vector<int> h(n);
  for(int& e : h) cin >> e;
  vector<ll> a(n);
  for(ll& e : a) cin >> e;

  vector<int> w(n);
  iota(begin(w), end(w), 0);

  sort(begin(w), end(w), [&h](int x, int y) { return h[x] < h[y]; });

  ll ans = 0;
  SegmentTree st(n);
  for (int e : w) {
    ll tmp = st.query(1, e + 1);
    ans = max(ans, tmp + a[e]);
    st.update(e + 1, tmp + a[e]);
  }
  cout << ans << endl;

  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll S[101010];

const int prime_max = 100000;
int NP,prime[100000],divp[prime_max];
map<int,int> M;

map<ll,int> PV;
set<ll> did;

void cprime() {
	for(int i=2;i<prime_max;i++) if(divp[i]==0) {
		//M[i]=NP;
		prime[NP++]=i;
		for(ll j=1LL*i*i;j>i&&j<prime_max;j+=i) divp[j]=i;
	}
}


ll hoge(ll n) {
	int i;
	FOR(i,NP) {
		ll a=prime[i];
		if(a>1000) break;
		
		while(n % (a*a*a)==0) n /= a*a*a;
	}
	return n;
}

ll rev(ll n) {
	ll nn=n*n;
	int i;
	FOR(i,NP) {
		ll a=prime[i];
		if(a>1000) break;
		
		while(nn % (a*a*a)==0) nn /= a*a*a;
	}
	return nn;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	cprime();
	int cube=0;
	FOR(i,N) {
		cin>>S[i];
		ll v=hoge(S[i]);
		if(v==1) cube++;
		else PV[v]++;
	}
	
	int ret=N;
	if(cube) ret -= (cube-1);
	FORR(r,PV) {
		if(did.count(r.first)) continue;
		ll rr=hoge(r.first*r.first);
		
		if(PV.count(rr)) ret -= min(r.second,PV[rr]);
		did.insert(rr);
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

#define M 100000
int N,v[M],dp[M];

inline int sol (int ind)
{
	if(ind>=N) return 1e6;
	if(dp[ind]!=-1) return dp[ind];
	return dp[ind]=min(abs(v[ind]-v[ind+1])+sol(ind+1),abs(v[ind]-v[ind+2])+sol(ind+2));
}

int main ()
{
	cin >> N;
	for(int i=0; i<N; i++) cin >> v[i];
	for(int i=0; i<M; i++) dp[i]=-1;
	dp[N-1]=0; cout << sol(0);
}

Measured memory_bytes: 3328
package main

import (
	"fmt"
)

//  < > > > < < > < < < < < > > > <

//  <       < <   < < < < <       <
//   1       1 2   1 2 3 4 5       1

//    > > >     >           > > >
//   3 2 1     1           3 2 1

// 0<3>2>1>0<1<2>0<1<2<3<4<5>2>1>0<1

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var s string
	fmt.Scan(&s)

	resArr := make([]int, len(s)+1)

	// まず純粋に<の数を数えて素直に値を入れていく
	for i, v := range s {
		if v == '<' {
			resArr[i+1] = resArr[i] + 1
		}
	}

	// for _, v := range resArr {
	// 	fmt.Printf(" %d", v)
	// }
	// fmt.Println("")

	// 今度は逆から>の数を数えて値を入れていく
	// すでに入っている値より大きいなら上書きする
	for i := range s {
		j := len(s) - i - 1
		if s[j] == '>' {
			resArr[j] = max(resArr[j], resArr[j+1]+1)
		}
	}

	// for _, v := range resArr {
	// 	fmt.Printf(" %d", v)
	// }
	// fmt.Println("")

	var sum int64 = 0
	for _, v := range resArr {
		sum += int64(v)
	}
	fmt.Println(sum)
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;
int main()
{
    int n;
    cin >> n;
    VL v(n);
    priority_queue<pair<ll, int>> pque;
    rep(i, n)
    {
        cin >> v[i];
        pque.push({ v[i], -(i + 1) });
    }
    ll num = 0;
    ll sum = 0;
    VL ans(n + 1, 0);
    while (!pque.empty()) {
        int idx = -pque.top().second;
        ll val = pque.top().first;
        // cerr << idx << " " << val << endl;
        pque.pop();
        num++;
        sum += val;
        while (!pque.empty()) {
            if (idx < -pque.top().second) {
                sum += pque.top().first;
                num++;
                pque.pop();
            } else {
                break;
            }
        }
        if (pque.empty()) {
            ans[idx] += sum;
            break;
        }
        ans[idx] += (sum - pque.top().first * num);
        sum = pque.top().first * num;
    }
    rep(i, 1, n + 1)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 6364
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#define ll long long
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rep1(i,a) for(ll i = 1;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;



int main(){
	ll n, k; cin >> n >> k;
	vl a(n);
	ll ind = 0;
	rep(i, n){
		cin >> a[i];
		if (a[i] == 1) ind = i;
	}
	if (k == n){
		cout << 1 << endl;
		return 0;
	}
	ll left = ind;
	if (left % (k - 1) != 0){
		ind = min(n - 1, ind + (k - 1) - (left % (k - 1)));
	}
	ll right = n - ind-1;
	cout << ceil(left / (double)(k-1)) + ceil(right / (double)(k-1)) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    cin >> n;
    int ans=0;
    for(int i=1; i<=n; i++){
        if(1<=i && i<10)ans++;
        if(100<=i && i<1000)ans++;
        if(10000<=i && i<100000)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
#include <functional>	
using namespace std;

int main() {
	int n, a;
	cin >> n >> a;
	if (n >= 500) {
		int x = n / 500;
		int xx = n%(x*500);
		if (xx <= a) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if (n <= a) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}




	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int inf = 1e9;

vector<int> decomposition(vector<vector<int> > &adj){
    int n = adj.size();
    vector<int> ord(n, inf);
    for(int i=1; i<n; i++){
        ord[i] = adj[i].size();
    }
    
    queue<int> wait;
    for(int i=0; i<n; i++){
        if(ord[i] == 1) wait.push(i);
    }    
    vector<int> rem(n, false);
    while(!wait.empty()){
        int cur = wait.front();
        wait.pop();
        rem[cur] = true;
        for(int i: adj[cur]){
            ord[i]--;
            if(ord[i] == 1) wait.push(i);
        }
    }
    return rem;
}

int solve(int node, vector<int> &w, vector<bool> &used, vector<vector<int> > &adj){
    if(used[node]) return 0;
    used[node] = true;
    int res = 0;
    for(int v: adj[node]){
        res = max(res, solve(v, w, used, adj));
    }
    return res +w[node];
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> w(n);
    for(int i=0; i<n; i++) cin >> w[i];
    vector<vector<int> > adj(n);
    for(int i=0; i<m; i++){
        int u,v;
        cin >> u >> v;
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    vector<int> rem = decomposition(adj);
    {
        vector<vector<int> > newadj(n);
        for(int i=0; i<n; i++){
            int nvi = rem[i]? i: 0;
            if(i!=0 && nvi==0) w[0] += w[i];
            for(int j: adj[i]){
                int nvj = rem[j]? j: 0;
                if(nvi == nvj) continue;
                newadj[nvi].push_back(nvj);
            }
        }
        for(vector<int> v: newadj){
            sort(v.begin(), v.end());
            v.erase(unique(v.begin(), v.end()), v.end());
        }
        adj = newadj;
    }

    vector<bool> used(n, false);
    cout << solve(0, w, used, adj) << endl;
    return 0;
}



Measured memory_bytes: 20024
s = input()
t = input()
count = 0
def ans(s, t):
    max = pow(10,9)
    if len(s)==len(t):
        max = 0
        for i in range(len(s)):
            if s[i]!=t[i]:
                max+=1
        return max
    else:
        for i in range(len(s)-len(t)+1):
            count = 0
            for j in range(len(t)):
                if s[i+j] != t[j]:
                    count+=1
            if max > count:
                max = count
        return max
print(ans(s,t))

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

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 200005;

int fac[Maxn], inv[Maxn];
int n;
int a[Maxn];
int res;

int toPower(int a, int p)
{
    int res = 1;
    while (p) {
        if (p & 1) res = ll(res) * a % mod;
        p >>= 1; a = ll(a) * a % mod;
    }
    return res;
}

int Inv(int x) { return toPower(x, mod - 2); }

int C(int n, int k)
{
    if (n < 0 || k < 0 || k > n) return 0;
    return ll(fac[n]) * inv[k] % mod * inv[n - k] % mod;
}

int main()
{
    fac[0] = inv[0] = 1;
    for (int i = 1; i < Maxn; i++) {
        fac[i] = ll(fac[i - 1]) * i % mod;
        inv[i] = Inv(fac[i]);
    }
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    sort(a, a + n);
    for (int i = n - 1; i >= 0; i--) {
        int ind = n - 1 - i;
        int ways = (toPower(2, ind) + (ind > 0? ll(ind) * toPower(2, ind - 1) % mod: 0)) % mod;
        ways = ll(ways) * toPower(2, i) % mod;
        res = (res + ll(ways) * a[i]) % mod;
    }
    res = ll(res) * toPower(2, n) % mod;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 2560
# coding: utf-8
# Your code here!

N, K = map(int,input().split())
num = 0
total = float(0)
per = float(1)

for i in range(1, N + 1):
    if i < K:
        j = 1
        while True:
            num = i * pow(2, j)
            per = pow(0.5, j)
            if num >= K:
                total += 1.0 / N * per
                break
            else:
                j += 1
    else:
        total +=  1.0 / N
print(total)

Measured memory_bytes: 3060
#include <cstdio>

int x, y;
int a[] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};

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

    printf("%s\n", a[x - 1] == a[y - 1] ? "Yes" : "No");


    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll dp[105][5][5][5];
ll A = 0, G = 1, C = 2, T = 3;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    memset(dp, 0, sizeof(dp));
    REP(i, 4) {
        REP(j, 4) {
            REP(k, 4) {
                if ((i == A && j == G && k == C) ||
                    (i == A && j == C && k == G) ||
                    (i == G && j == A && k == C))
                    continue;
                dp[3][i][j][k] = 1;
            }
        }
    }
    FOR(i, N, 3) {
        REP(n, 4) {
            REP(p0, 4) {
                REP(p1, 4) {
                    REP(p2, 4) {
                        if ((p1 == A && p0 == C && n == G) ||
                            (p1 == A && p0 == G && n == C) ||
                            (p1 == G && p0 == A && n == C) ||
                            (p2 == A && p1 == G && n == C) ||
                            (p2 == A && p0 == G && n == C))
                            continue;

                        dp[i + 1][p1][p0][n] += dp[i][p2][p1][p0];
                        dp[i + 1][p1][p0][n] %= MOD;
                    }
                }
            }
        }
    }

    ll ans = 0;
    REP(i, 4) {
        REP(j, 4) {
            REP(k, 4) {
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
import sys
import copy
import heapq
from collections import deque

# sys.setrecursionlimit(100001)
INF = sys.maxsize


# ===CODE===
def main():
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    v, e = map(int, input().split())
    tree = UnionFind(v)

    edges = []
    for i in range(e):
        s,t,d = map(int,input().split())
        edges.append((d,s,t))

    edges.sort()

    ans = 0
    for d,s,t in edges:
        if tree.same(s,t):
            continue
        tree.union(s,t)
        ans += d

    print(ans)

# ===main===
if __name__ == '__main__':
    main()



Measured memory_bytes: 23916
// main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<pair<double, double>> v(n);
    cin >> v;
    vector<int> a;
    for (int i = 0; i < n; ++i) {
      a.push_back(i);
    }
    vector<double> w;
    do {
      double sum = 0;
      for (int i = 0; i + 1 < n; ++i) {
        double x = v[a[i]].first - v[a[i + 1]].first;
        double y = v[a[i]].second - v[a[i + 1]].second;
        sum += sqrt(x * x + y * y);
      }
      w.push_back(sum);
    } while (next_permutation(a.begin(), a.end()));
    double sum = accumulate(w.begin(), w.end(), 0.0);
    printf("%.10lf\n", sum / w.size());
  }

  return 0;
}


Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int n, T;
    cin >> n >> T;
    int c[100], t[100];
    for (int i = 0; i < n; i++)
    {
        cin >> c[i] >> t[i];
    }

    int minCost = 1001;

    for (int i = 0; i < n; i++)
    {
        if (t[i] <= T && c[i] < minCost)
        {
            minCost = c[i];
        }
    }

    if (minCost > 1000)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << minCost << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n,k,*a=map(int,open(i:=0).read().split())
a.sort()
p=a.pop
s=b=~k%2or p()
for _ in k//2*'_':
 x=a[i]*a[i+1]
 if x*b>a[-1]*a[-2]*b:s*=x;i+=2
 else:s*=p()*p()
 s%=10**9+7
print(s)

Measured memory_bytes: 31588