akhauriyash/Code-Regression huggingface dataset:
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define INF 1e9 + 1
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	LL c;
	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}
	return b;
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
			n /= i;
		}
	}
	if (n > 2)printf("%d ", n);
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int x, y;
	cin >> x >> y;
	cout << x + (y / 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int X, Y;
bool ans = false;
int main()
{
  cin >> X >> Y;
  REP(i, X+1) {
    if (i*2 + (X-i)*4 == Y) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int n, co;
int main(){
    cin >> n;
    int p[n];
    for (int i=0; i<n; i++){
        cin >> p[i];
        if (i >= 2){ // compare i-1th elem
            if ((p[i-1] < p[i] && p[i-1] > p[i-2])
            || (p[i-1] > p[i] && p[i-1] < p[i-2])){
                co++;
                // cout << p[i-1] << " " << i-1 << "\n";
            }
        }
    }
    cout << co;
}

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

using lint = long long;

int main() {
    int N;
    cin >> N;
    vector<vector<lint>> dist(N, vector<lint>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            lint d;
            cin >> d;
            dist[i][j] = d;
        }
    }

    vector<vector<lint>> wf(N, vector<lint>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            wf[i][j] = dist[i][j];
        }
    }
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
            }
        }
    }

    bool can = true;
    lint ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (dist[i][j] > wf[i][j]) {
                can = false;
                goto result;
            }

            bool need = true;
            for (int k = 0; k < N; k++) {
                if (k != i and k != j) {
                    if (dist[i][j] == dist[i][k] + dist[k][j]) {
                        need = false;
                        break;
                    }
                }
            }

            if (need) {
                ans += dist[i][j];
            }
        }
    }

result:
    if (can == false) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define li long long
#define gc getchar()
#define pc putchar
int a[110],b[110],c[110],d[110];
int n;
int e[110][110];
int mt[110];
bool vst[110];
bool dfs(int q){
	if(vst[q]) return 0;
	vst[q] = 1;
	for(int i = 1;i <= n;++i){
		if(!e[q][i]) continue;
		if(!mt[i] || dfs(mt[i])){
			mt[i] = q;
			return 1;
		}
	}
	return 0;
}
int work(){
	int as = 0;
	for(int i = 1;i <= n;++i){
		memset(vst,0,sizeof(vst));
		if(dfs(i)) ++as;
	}
	return as;
}
int main(){
	int i,j;
	scanf("%d",&n);
	for(i = 1;i <= n;++i) scanf("%d%d",&a[i],&b[i]);
	for(i = 1;i <= n;++i) scanf("%d%d",&c[i],&d[i]);
	for(i = 1;i <= n;++i){
		for(j = 1;j <= n;++j) {
			if(a[i] < c[j] && b[i] < d[j]) e[i][j] = 1;
			else e[i][j] = 0;
 		}
	}
	printf("%d",work());
	return 0;
}

Measured memory_bytes: 256
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    t = str(stdin.readline().rstrip())
    print(t.replace("?","D"))

main()


Measured memory_bytes: 9452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size())
        cout << "GREATER";
    else if(a.size() < b.size())
        cout << "LESS";
    else if(a > b)
        cout << "GREATER";
    else if(b > a)
        cout << "LESS";
    else
        cout << "EQUAL";
}

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

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

    int a, b, t;
    cin >> a >> b >> t;

    int c = a, ans = 0;
    while(c <= t){
        ans += b;
        c += a;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N;
    cin >>N;
    ll p[N];
    
    if(N==1){
        cout<<"Hello World"<<endl;
    }
    else{
        int A,B;
    cin >>A>>B;
        cout<<A+B<<endl;
    }

  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int d;
	cin>>d;
	int c[26];
	rep(i,26)cin>>c[i];
	int lastd[26]={};
	int s[d][26];
	rep(i,d){
		rep(j,26){
			cin>>s[i][j];
		}
	}

	ll ans=0,maxi=0,maxid=0;
	int t[d]={};
	rep(i,d){
		maxi=(-1)*1e9;
		rep(j,26){
			ans=s[i][j];
			rep(k,26){
				if(k==j)continue;
				ans-=c[k]*(i+1-lastd[k]);
			}
			if(ans>maxi){
				maxi=ans;
				maxid=j;
			}
		}
		lastd[maxid]=i+1;
		t[i]=maxid;
	}

	rep(i,d){
		cout<<t[i]+1<<endl;
	}

	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

const ll maxf = 10000000;
ll fact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++){
    fact[i] = (fact[i-1] * i) % MOD;
  }
}

ll comb(ll a, ll b){
  if(a<b || a<0 || b<0) return 0;
  if(fact[0] == 0) fact_init();
  return (fact[a] * modpow((fact[a-b]*fact[b])%MOD, MOD-2)) % MOD;
}

ll naive_comb(ll a, ll b){
  ll res = 1;
  for (ll i = a; i > a - b; i--) res = res * i % MOD;
  for (ll i = 1; i <= b; i++) res = (res * modpow(i, MOD-2)) % MOD;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,a,b; cin>>n>>a>>b;
  ll ans=modpow(2,n);
  ans--;
  ans-=naive_comb(n,a)+naive_comb(n,b);
  while(ans<0) ans+=MOD;
  ans%=MOD;
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
import math

def prime(x):
	for i in range(2,int(math.sqrt(x))+1):
		if x%i == 0:
			return 0
	return 1

n=int(input())
count=0
for i in range(n):
	x=int(input())
	if prime(x):
		count+=1
print(count)


Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N,0);
  
  for (int i =0;i<M;i++){
    int P, Q;
    cin >> P >> Q;
    for(int j =0;j<100;j++){
    	if(j+1 == P){
          ans.at(j) +=1;
        }
    }
      for(int j =0;j<100;j++){
    	if(j+1 == Q){
          ans.at(j) +=1;
        }
    }
  }
 
  for (int i =0;i < ans.size();i++){
  cout << ans.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int k=0,o=0,i,l=0;
	char x[105];
	long long a,b,c,n;
	scanf("%s",x);
	k=strlen(x);
	scanf("%lld",&n);
	while(x[o]=='1'){
		l++;
		o++;
	}
	if(n<=l){
		printf("1\n");
	}
	else{
		for(i=0;i<k;i++){
			if(x[i]>'1'){
				printf("%c\n",x[i]);
				break;
			}
		}
	}
	return 0;
}

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

int m,n,k;

int main(){
  int i,j,a,b,c,sum;
  cin >> a >> b >> c >> k;
  sum = a + b + c;
  i = max(a,max(b,c));
  sum -= i;
  for(j=1;j<=k;j++)i*=2;
  cout << sum+i << endl;

  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int s=min(x,y),ans=0;
	x-=s,y-=s;
	if(2*c<a+b)
		ans+=2*c*s;
	else
		ans+=(a+b)*s;
	if(x>0){
		if(2*c<a)
			ans+=2*c*x;
		else
			ans+=x*a;
	}
	if(y>0){
		if(2*c<b)
			ans+=2*c*y;
		else
			ans+=y*b;
	}
	cout<<ans;
}



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



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
 
 
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k,t=1;

void solve()
{
  cin>>n>>k>>m;
  vector<ll>v(m);
  map<ll,ll>vis,pos;
  vector<ll>ans(n+1);
  for(ll i=1;i<=n;i++)ans[i]=k;
  
 // for(auto p:ans)cout<<p<<" ";
  //cout<<"\n";
  
  for(ll i=0;i<m;i++)cin>>v[i],pos[v[i]]++;
  
  //for(ll i=1;i<=n;i++)cout<<pos[i]<<" ";cout<<"\n";
  
  
  for(ll i=0;i<m;i++)
  {
      if(vis[v[i]]==0)
     ans[v[i]]=ans[v[i]]-(m-pos[v[i]]);
     vis[v[i]]++;
  }
  for(ll i=1;i<=n;i++)
  {
      //cout<<ans[i]<<" ";
      
      
      if(vis[i]==0)
      {
          if(m>=k)cout<<"No"<<"\n";
          else cout<<"Yes"<<"\n";
      }
      else if(ans[i]>0)cout<<"Yes"<<"\n";
      else cout<<"No"<<"\n";
  }
 //if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

 // cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N,M;cin>>N>>M;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector<int64_t>B(N+1);B.at(0)=0;
  for(int i=1;i<=N;i++)
    B.at(i)=(B.at(i-1)+A.at(i-1))%M;
  map<int64_t,int64_t>m;
  for(int i=0;i<=N;i++)
    if(m.count(B.at(i)))
       m.at(B.at(i))++;
       else
       m[B.at(i)]=1;
       int64_t ans=0;
       for(auto p:m){
       auto v=p.second;
         ans+=(v*(v-1))/2;
       }cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8736
#include<iostream>

using namespace std;

int main()
{
    long int n,t;
    long int sum=0;
    cin>>n;
    t=n;
    while(t)
    {
        sum+=t%10;
        t=t/10;
    }
    if(n%sum==0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    h, w = map(int, input().split())
    A = [list(map(int, input().split()))for i in range(h)]
    B = [list(map(int, input().split()))for i in range(h)]
    abss = [[abs(A[i][j]-B[i][j])for j in range(w)] for i in range(h)]
    dp = [[0]*w for i in range(h)]
    dp[0][0] = 1 << (abss[0][0]+13000)    
    for i in range(h):
        for j in range(w):
            if i != h-1:
                dp[i+1][j] = dp[i+1][j] | dp[i][j] << abss[i +
                                                           1][j] | dp[i][j] >> abss[i+1][j]
            if j != w-1:
                dp[i][j+1] = dp[i][j+1] | dp[i][j] << abss[i][j +
                                                              1] | dp[i][j] >> abss[i][j+1]
    a = 0
    ans = dp[-1][-1]
    while True:
        if (ans & (1 << (13000-a))):
            print(a)
            break
        elif (ans & (1 << (13000+a))):
            print(a)
            break
        a += 1


if __name__ == '__main__':
    main()

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

constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int MAX = 1e5+1;

vector<long> fact(MAX), finv(MAX), inve(MAX);

void init() {
  fact.at(0) = fact.at(1) = 1;
  finv.at(0) = finv.at(1) = 1;
  inve.at(1) = 1;
  for (int i = 2; i < MAX; i++) {
    fact.at(i) = fact.at(i - 1) * i % MOD;
    inve.at(i) = MOD - inve.at(MOD % i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i - 1) * inve.at(i) % MOD;
  }
}

long com(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact.at(n) * (finv.at(r) * finv.at(n - r) % MOD) % MOD;
}

int main() {
  init();
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += com(i, K - 1) * A.at(i);
    ans %= MOD;
    ans -= com(N - i - 1, K - 1) * A.at(i);
    ans %= MOD;
    while (ans < 0) ans += MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 6316
#include<bits/stdc++.h>
#define N (300009)
using namespace std;

int n,m,l,r,c[N];
vector<int>L[N];

void U(int x,int k) {for (;x<=m; c[x]+=k,x+=(x&-x));}
int Q(int x) {int s=0; for (;x; s+=c[x],x-=(x&-x)); return s;}

int main()
{
	cin>>n>>m;
	for (int i=1; i<=n; ++i)
		cin>>l>>r, L[r-l+1].push_back(l);
	for (int d=1; d<=m; ++d)
	{
		int ans=n;
		for (int i=d; i<=m; i+=d) ans+=Q(i);
		for (int i=0,sz=L[d].size(); i<sz; ++i)
			U(L[d][i],1), U(L[d][i]+d,-1), --n;
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 12288
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {

int n;
cin>>n;
    drep(i,10){
        if(n>=pow(2,i)){
            fin(pow(2,i));
            return 0;
        }
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string S;
	cin >> S;
	int c_count = 0;
	for (int i = 0; i < S.size(); ++i)
	{
		if (i == 0)
		{
			if (S[i] != 'A')
			{
				cout << "WA";
				return 0;
			}
		}
		else if (2 <= i && i <= S.size() - 2)
		{
			if (S[i] == 'C')
			{
				++c_count;
			}
			else if ('A' <= S[i] && S[i] <= 'Z')
			{
				cout << "WA";
				return 0;
			}
		}
		else if ('A' <= S[i] && S[i] <= 'Z')
		{
			cout << "WA";
			return 0;
		}
	}
	if (c_count != 1)
	{
		cout << "WA";
		return 0;
	}
	cout << "AC";
}

Measured memory_bytes: 256
import java.io.*;


public class Main {

    public static void main(String[] args) {

        int judger;
        int scores[] = new int[100];
        
    
        BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
    
        try {
            for(int x = 0; x < 20; x++) {
                int max = 0;
                int min = 1000;
                String str = input.readLine();
                judger = Integer.parseInt(str.trim());
                
                if(judger == 0) {
                    break;
                } else  {
                    for(int i = 0; i < judger; i++){
                        str = input.readLine();
                        scores[i] = Integer.parseInt(str.trim());
                        if(max < scores[i]) {
                            max = scores[i];
                        }
                        if(min > scores[i]) {
                            min = scores[i];
                        }
                    }
                    System.out.println(average(scores, max, min,judger));
                }
            }
        } catch(IOException e) {
            
        }
    }
    
    private static int average(int[] scores,int max,int min,int judger) {
    
    int sum = 0;
    int average;
    
    for(int i=0;i < judger; i++) {
    sum += scores[i];
    }
    average = ( sum - ( min + max )) / (judger - 2);
    
    return average;
    
    }
}

Measured memory_bytes: 24368
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

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

bool comp(const Pl &a, const Pl &b){
  return a.first < b.first;
}

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<Pl> vec(n);
  rep(i, n)cin >> vec[i].first >> vec[i].second;
  sort(all(vec), comp);
  ll res = 0;
  for(int i = 0; i < n; i++){
    if(m <= vec[i].second){
      res += m * vec[i].first;
      m = 0;
    }else{
      res += vec[i].first * vec[i].second;
      m -= vec[i].second;
    }
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include<algorithm>
using namespace std;

int main() {
	int num[3];
	scanf("%d %d %d",&num[0],&num[1],&num[2]);
	if (num[0]> num[1])
	{
		swap(num[0],num[1]);
	}
	if (num[1] > num[2])
	{
		swap(num[1], num[2]);
	}
	if (num[0] > num[1])
	{
		swap(num[0], num[1]);
	}
	printf("%d %d %d\n",num[0],num[1],num[2]);
}


Measured memory_bytes: 2748
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s, t = "";
	lint x_cnt = 0;
	vector<lint> cnt;
	cin >> s;
	REP(i, SZ(s)) {
		if (s[i] != 'x') {
			t += s[i];
			cnt.push_back(x_cnt);
			x_cnt = 0;
		}
		else {
			x_cnt++;
		}
	}
	cnt.push_back(x_cnt);
	REP(i, SZ(t) / 2) {
		if (t[i] != t[SZ(t) - i - 1]) {
			cout << -1 << endl;
			return 0;
		}
	}
	lint ans = 0;
	REP(i, SZ(cnt) / 2) {
		ans += abs(cnt[i] - cnt[SZ(cnt) - i - 1]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		f,a,b,c,i,j,k,n,m,x,y,ans = 0;
	char	str[256];
	
	scanf("%d %d %d", &m, &f, &b);

	if (m >= b) ans = 0;
	else if ( (m+f) < b ) ans = -1;
	else ans = b - m;
	
	if (ans == -1) {
		printf("NA\n");
	} else {
		printf("%d\n",ans);
	}

	return 0;
}



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

int main(){
  long n,fact,i,j,flag,tmp,result=0,f,max;
  
  scanf("%ld",&n);
  
  //round
  for(i=1;i<=n;i++){
    f=0;
    
    for(j=1;j<=n/i;j++){
      f+=(i*j);
    }
      
    //sum
    result+=f;
  }
  
  printf("%ld",result);
  
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n;
    cin >> n;

    int64_t ans = 0;
    for (int64_t r = 1; r * (r + 1) < n; ++r) {
        if (n % r > 0) {
            continue;
        }

        int64_t m = n / r - 1;
        ans += m;
    }

    cout << ans << endl;
}

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

using namespace std;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

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

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const ll mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//



const int mx = 100000;
ll cnt[mx+1];

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

        for(int i = 0; i < n; i++){
                int a,b;
                cin >> a >> b;
                cnt[a] += b;
        }

        for(int ans = 1; ans <= mx; ans++){
                if(k <= cnt[ans]){
                        cout << ans << endl;
                        break;
                }
                k -= cnt[ans];
        }

        return 0;
}


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

//ライブラリ始まり

//定数
//円周率
const double pi = 3.1415926535897932384;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数
//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}
//to_char
char to_char(int i){
  if (i == 0) {
    return '0';
  }
  if (i == 1) {
    return '1';
  } 
  if (i == 2) {
    return '2';
  } 
  if (i == 3) {
    return '3';
  }
  if (i == 4) {
    return '4';
  } 
  if (i == 5) {
    return '5';
  } 
  if (i == 6) {
    return '6';
  }
  if (i == 7) {
    return '7';
  } 
  if (i == 8) {
    return '8';
  } 
  if (i == 9) {
    return '9';
  }
  return ' ';  
}
//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false; // 1や0,-1は素数ではない
  }
  if (x == 2) {
    return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false; // 割れたら素数じゃない
    }
  }
  return true;
}

//ライブラリ終わり
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  for (int i = K; i <= N + 1; i++) {
    ans++;
    ans += i * (N - i + 1);
    ans %= MOD;
  }
  cout << ans << endl;
}

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

using namespace std;

int n;
int k;
char record[100010];
vector<int> stupid;

int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>record[i];
    int c = 0;
    int idx = 1;

    while(idx < n){
        if(record[idx]==record[idx-1]) c+=1;
        else{
            stupid.push_back(c);
            c = 0;
        }
        idx++;
    }
    stupid.push_back(c);

    int p = stupid.size();
    int ans = 0;
    for(int i=0;i<p;i++)ans+=stupid[i];


    if((p/2)<=k){
        if(p%2==1){
            ans += (p/2)*2;
        }
        else{
            ans += ((p-1)/2)*2 + 1;
        }
    }
    else{
        ans += 2*k;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<pair<int,int>> v(n);
    for(auto& i : v) cin >> i.first >> i.second;

    vector<int> perm(n);
    REP(i, n) perm[i] = i;
    double dist = 0.0;

    do{
        REP(i, n-1){
            dist += sqrt(pow(v[perm[i]].first - v[perm[i+1]].first, 2)
                       + pow(v[perm[i]].second - v[perm[i+1]].second, 2));
        }
    }while(next_permutation(all(perm)));

    REP(i, n){
        dist /= i + 1;
    }

    cout << fixed << setprecision(10) << dist << endl;

    return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int p, x1 = 0, x2 = 0, x3 = 0;
  for (int i = 0; i < N; i++) {
    cin >> p;
    if (p <= A) x1++;
    else if (p <= B) x2++;
    else x3++;
  }
  cout << min({x1, x2, x3}) << endl;
}

Measured memory_bytes: 256
def resolve():
    r1, c1, r2, c2 = map(int, input().split())
    r1 -= 1
    c1 -= 1

    def cmb(n, r, mod):
        if (r<0 or r>n):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7 #出力の制限
    N = 3*10**6
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    print((cmb(r2+c2+2, r2+1, mod) - cmb(r1+c2+2, r1+1, mod) - cmb(r2+c1+2, c1+1, mod) + cmb(r1+c1+2, r1+1, mod))%mod)
resolve()

Measured memory_bytes: 172692
//                          **********  YATIN KWATRA  ********** 

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


using namespace std;

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

}


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

        ll ans = n+n*n+(n*n*n);
        cout << ans << endl;

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


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  if(N%10==9){
  cout<<"Yes"<<endl;
  }else{
  if(N/10==9)
    cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int main(int argc, char* argv[]){
  long int a=0,b=0,c=0,ans=0;
  char s[7];

  scanf("%ld %ld",&a,&b);
  long int d[b],e[b];
  for (int i = 0; i < b; i++) {
    scanf("%ld",&d[i]);
    e[i]=d[i];
  }
  for (int i = 1; i < b; i++) {
    e[i]=d[i]-d[i-1];
  }
  e[0]=a-d[b-1]+d[0];
  long int max=0,l=0;
  for (int i = 0; i < b; i++) {
    if (e[i]>max) {
      max=e[i];
      l=i;
    }
  }
  if (l!=0) {
    printf("%d",a-d[l]+d[l-1]);
  }else{
    printf("%d",d[b-1]-d[0]);
  }
}


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

#define Bye return 0
#define ll long long
const int MAX = 1e6+1;



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

    ll a[n];
    for (int i=0; i<n; i++) cin>>a[i];

    ll h[n];
    h[0] = 0;
    ll sum = 0;
    for (ll i=1; i<n; i++){
        if(a[i]<a[i-1]){
            h[i] = a[i-1] -a[i];
            a[i] += h[i];
        } else
            h[i] = 0;
        sum += h[i];
    }
    cout<<sum<<endl;
}

int main()
{
    solve();
    Bye;
}


Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;


int main() {
int R;
cin >> R;
if (R < 1200) cout << "ABC" << endl;
else if (R < 2800) cout << "ARC" << endl;
else cout << "AGC" << endl;


return 0;
}


Measured memory_bytes: 256
n = int(input())
x = [float(s) for s in input().split()]
y = [float(s) for s in input().split()]

xy = [abs(xi-yi) for xi,yi in zip(x,y)]

D = lambda p:sum([xyi**p for xyi in xy])**(1/p)

print(D(1.0))
print(D(2.0))
print(D(3.0))
print(max(xy))

Measured memory_bytes: 7720
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    long double a,b,c;
    cin >> a >> b >> c;
    long double ans = a+b+(2*sqrt(a*b));
    if(ans < c)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;

public class Main {
	public static void main(String args[]) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(br.readLine());
		}

		Sort s = new Sort();
		s.shellSort(a, n);

		System.out.println(s.G.size());
		for (int i = s.G.size() - 1; i >= 0; i--) {
			System.out.print(s.G.get(i) + ((i == 0) ? "\n" : " "));
		}
		System.out.println(s.cnt);
		for (int i : a) {
			System.out.println(i);
		}
	}

}

class Sort
{
	public int cnt = 0;
	public List<Integer> G = new ArrayList<Integer>();

	public int[] shellSort(int[] a, int n)
	{
		int i = 1;
		while(i <= n) {
			this.G.add(i);
			i = i * 3 + 1;
		}

		for (i = this.G.size() - 1; i >= 0; i--) {
			insertionSort(a, n, this.G.get(i));
		}

		return a;
	}

	private int[] insertionSort(int[] a, int n, int g)
	{
		for (int i = g; i < n; i++) {
			int v = a[i];
			int j = i - g;
			while (j >= 0 && a[j] > v) {
				a[j+g] = a[j];
				j = j - g;
				this.cnt++;
			}
			a[j+g] = v;
		}

		return a;
	}
}


Measured memory_bytes: 106728
from itertools import permutations as permu
import numpy as np


def main():
    n = int(input())
    ps = np.array(list(map(int, input().split())))
    qs = np.array(list(map(int, input().split())))

    nums = [i for i in range(1, n+1)]
    nums_array = np.array(list(permu(nums, n)))
    a = np.where(np.all(nums_array == ps, axis=1))[0][0]
    b = np.where(np.all(nums_array == qs, axis=1))[0][0]
    ans = abs(a - b)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19440
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
char c[10][10]; 
int main(){
	fastio;
	int res=0;
	int h,w,k;
	cin>>h>>w>>k;
	int s=0;
	rb(i,1,h)
		rb(j,1,w) cin>>c[i][j],s+=c[i][j]=='#';
	int n=h+w;
	rep(i,1<<n){
		int cnt=0;
		rep(j,h)
			if(i&(1<<j)){
				rb(k,1,w)
					if(c[j+1][k]=='#') cnt++;
			}
		rep(k,w){
			if(i&(1<<(h+k))){
				rb(j,1,h){
					if(!(i&(1<<(j-1)))){
						
					if(c[j][k+1]=='#') cnt++;
					}
				}
			}
		}
		res+=(s-cnt)==k;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  for(int i = 0; i < n; i++) for(int j = i+1; j < n; j++) ans += a[i] * a[j];
  cout << ans << endl;
}

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

int main(void){
  int p[2000001];
  int k, n, i, j;
  double result=0.0, tmp;
  
  scanf("%d %d", &n, &k);
  for(i=0;i<n;i++) scanf("%d", &p[i]);

  tmp = 0.0;
  for(i=0;i<k;i++){//check zone start
    tmp += (double) p[i];
  }
  result = tmp;
  
  for(i=k;i<n;i++){
    tmp -= (double) p[i-k];
    tmp += (double) p[i];
    
    if(tmp > result) result = tmp;
  }
  
  //check zone end
  
  printf("%.12f", (double) ((k + result) / 2.0));
  
  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string str;
    cin >> str;
    bool a = false, b = false;
    for (auto &ch : str) { if (ch == 'B') a = true; else b = true; }
    if (a && b) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());

		int[] c = new int[4];
		Arrays.fill(c, 0);

		for (int i = 0; i < n; i++) {
			switch (sc.next()) {
			case "AC":
				c[0]++;
				break;
			case "WA":
				c[1]++;
				break;
			case "TLE":
				c[2]++;
				break;
			case "RE":
				c[3]++;
				break;
			default:
				System.exit(1);
			}
		}
		
		System.out.println("AC x " + c[0]);
		System.out.println("WA x " + c[1]);
		System.out.println("TLE x " + c[2]);
		System.out.println("RE x " + c[3]);
	}

}


Measured memory_bytes: 57516
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

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

    cout<<string(s.length(), 'x')<<endl;
}


Measured memory_bytes: 256
use std::io::BufRead;

struct Dice {
    nums: Vec<u8>,
    top: u8,
    front: u8,
    eside: u8,
}
impl Dice {
    fn move_e(&mut self) {
        let top = self.top;
        let eside = self.eside;
        self.top = 5 - eside;
        self.eside = top;
    }
    fn move_w(&mut self) {
        let top = self.top;
        let eside = self.eside;
        self.top = eside;
        self.eside = 5 - top;
    }
    fn move_n(&mut self) {
        let top = self.top;
        let front = self.front;
        self.top = front;
        self.front = 5 - top;
    }
    fn move_s(&mut self) {
        let top = self.top;
        let front = self.front;
        self.top = 5 - front;
        self.front = top;
    }
}

fn main() {
    let handle = std::io::stdin();
    let mut info = handle.lock().lines();
    let nums = info.next().unwrap().unwrap();
    let mut nums_iter = nums.split_whitespace().map(|a| a.parse().unwrap());
    let mut dice = Dice { nums: Vec::new(), top: 0, front: 0, eside: 0, };
    for _ in 0..6 {
        dice.nums.push(nums_iter.next().unwrap());
    }
    dice.top = 0;
    dice.front = 1;
    dice.eside = 2;
    let distances = info.next().unwrap().unwrap();
    let distances_iter = distances.chars();
    for c in distances_iter {
        match c {
            'E' => { dice.move_e(); },
            'W' => { dice.move_w(); },
            'N' => { dice.move_n(); },
            'S' => { dice.move_s(); },
            _ => { panic!("dice move exception ewns!!!"); },
        }
    }
    println!("{}", dice.nums[dice.top as usize]);
}


Measured memory_bytes: 5028
import sys

s = int(input())

sequence = [s] * 1000000

i = 1
while True:
    n = sequence[i - 1]
    if n % 2 == 0:
        sequence[i] = sequence[i - 1] // 2
    else:
        sequence[i] = 3 * sequence[i - 1] + 1

    for j in range(i):
        if sequence[i] == sequence[j]:
            print(i + 1)
            sys.exit()
    i += 1


Measured memory_bytes: 10868