akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

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

    vector<int> v(N);
    REP(i, N) { cin >> v[i]; }
    int ma = 0;
    for(int i = 0; i <= K; i++) {
        for(int j = 0; j <= K - i; j++) {
            vector<int> arr;
            int sum = 0;
            REP(k, N) {
                if(k < i || N - j <= k) {
                    arr.push_back(v[k]);
                    sum += v[k];
                }
            }
            SORT(arr);
            REP(k, min(K - i - j, i + j)) {
                if(arr[k] < 0) {
                    sum -= arr[k];
                }
            }
            chmax(ma, sum);
        }
    }
    cout << ma;
    return 0;
}

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

int main(){
    int n;
    int cnt = 0;
    while(cin >> n, n){
        if(cnt != 0) cout << endl;
        cnt++;
        string s[10];
        vector<int> d, e;
        for(int i = 0; i < n; i++){
            int a, b, c;
            cin >> s[i] >> a >> b >> c;
            d.push_back(3 * a + c);
        }
        e = d;
        sort(d.begin(), d.end());
        reverse(d.begin(), d.end());
        bool f[10] = {0};
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(d[i] == e[j] && f[j] == false){
                    f[j] = true;
                    cout << s[j] << "," << d[i] << endl;
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 3008
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct node
{
    int key;
    node* pre;
    node* next;
}node;

void Insert(int x);
void Delete(int x);
int iden_com(char s[]);
void print();

node* head;

int main()
{
    int n;
    char s[100];
    int k;
    node* p;

    scanf("%d", &n);

    // innitialize head node
    head = (node*)malloc(sizeof(node));
    head->key = 0;
    head->next = head;
    head->pre = head;

    for (int i = 0; i < n; i++)
    {
        scanf("%s", s);
        int id = iden_com(s);
        switch(id)
        {
            case 1:
            {
                scanf("%d", &k);
                Insert(k);break;
            }
            case 2:
            {
                scanf("%d", &k);
                Delete(k);break;
            }
            case 3:
            {
                p = head->next;
                p->pre->next = p->next;
                p->next->pre = p->pre;
                free(p);
                break;
            }

            case 4:
            {
                p = head->pre;
                p->pre->next = p->next;
                p->next->pre = p->pre;
                free(p);
                break;
            }
        }
    }
    print();

    return 0;
}

void Insert(int x)
{
    node* p = (node*)malloc(sizeof(node));
    p->key = x;
    p->next = head->next;
    p->next->pre = p;
    p->pre = head;
    head->next = p;
}

void Delete(int x)
{
    node* p = head->next;
    while(p != head )
    {
        if (p->key == x)
        {
            p->pre->next = p->next;
            p->next->pre = p->pre;
            free(p);
            break;
        }
        p = p->next;
    }
}

int iden_com(char s[])
{
    if (!strcmp(s, "insert"))
        return 1;
    else if (!strcmp(s, "deleteFirst"))
        return 3;
    else if (!strcmp(s, "deleteLast"))
        return 4;
    else
        return 2; //num of delete operation is less than other operations
}

void print()
{
    node* p = head->next;
    if(p != head)
    {
        printf("%d", p->key);
        p = p->next;
    }
    while(p != head)
    {
        printf(" %d", p->key);
        p = p->next;
    }
    printf("\n");
}



Measured memory_bytes: 33920
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#include<sstream>
# include<set>
#define in(n, m) for (ll i=n; i<m;i++)
#define inj(n, m)for (ll j=n; j<m;j++)
#define ink(n, m)for (ll k=n; k<m;k++)
using namespace std;
using ll=long long;
const ll N=30000;
bool dp[30009][4][1009];
vector <pair<ll,ll>> A(N);
const ll INF = 1LL << 60;


int main() {
	ll N;
	cin >> N;
	string S;
	cin >> S;
	dp[0][0][0] = true;

	in(0, N) {
		inj(0, 4) {
			ink(0, 1000) {
				if (dp[i][j][k] == false) continue;

				dp[i + 1][j][k] = true;
				if (j <= 2) dp[i + 1][j + 1][k * 10 + (S[i] - '0')] = true;
			}
		}
	}

	int cnt = 0;
	in(0, 1000) if (dp[N][3][i] == true) cnt++;
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 119040
N, K = map(int, input().split())
S = list(input())

if S[K - 1] == "A":
  S[K - 1] = "a"
elif S[K - 1] == "B":
  S[K - 1] = "b"
else:
  S[K - 1] = "c"

for s in S:
  print(s, end = "")
print()

Measured memory_bytes: 2940
hoge=input()
ans=0
for i in range(len(hoge)):
  if((i+1)%2==1 and hoge[i]!="L"):
    ans+=1
  if((i+1)%2==0 and hoge[i]!="R"):
    ans+=1
if(ans==len(hoge)):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
int main() {
	int n, A[10000],cnt=0;
	cin >> n;
	rep(i, n) {
		cin >> A[i];
		while (A[i] % 2 == 0) {
			A[i] /= 2;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string s,t;
    ll rs = 0;

    cin >> s >> t;

    for(ll i = 0;i < s.size();i++){
        if(s.at(i) != t.at(i))
            rs++;
    }

    cout << rs << endl;
}

Measured memory_bytes: 3912
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

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

   int ans = 0, cnt = 0;
   for(int i = 0; i < S.size(); i++){
      const char s = S[i];
      if(s == 'A' || s == 'T' || s == 'G' || s == 'C'){
         cnt++;
         ans = max(ans, cnt);
      }
      else{
         ans = max(ans, cnt);
         cnt = 0;
      }
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb std::ios::sync_with_stdio(false)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
/*** TEMPLATE CODE STARTS HERE ***/
const int maxn = 1e7+50;
bool noprime[maxn+50];
vector <int> p;
int getPrime()
{
    // 华丽的初始化
    memset(noprime,false,sizeof(noprime));
    p.clear();

    int m=(int)sqrt(maxn+0.5);
    // 多姿的线性筛
    for(int i=2;i<=m;i++)
    {
        if(!noprime[i])
        {
            for(int j=i*i;j<=maxn;j+=i)
            {
                noprime[j] = true;
            }
        }
    }
    // 把素数加到vector里
    for(int i=2;i<=maxn;i++)
    {
        if(!noprime[i])
        {
            p.push_back(i);
        }
    }
    //返回vector的大小
    return p.size();

}
int pf[105][2];// 0 -> value 1->count

int getPrifac( ll n,int len)
{
    int pos = 0;
    for(int i=0; p[i]*p[i]<=n&&i<len;i++)
    {
        if( n% p[i] == 0)
        {
            pf[++pos][0]=p[i];
            pf[pos][1]=0;
            // 算质因数的幂数
            while(n%p[i]==0)
            {
                pf[pos][1]++;
                n/=p[i];
            }
        }
    }
    if( n> 1)
    {
        pf[++pos][0] = n;
        pf[pos][1]=1;
    }
    return pos; // 优美的返回有多少个质因数
}
int gcd(int x,int y)
{
    return y==0?x:gcd(y,(x%y));
}
ll quick_pow(ll a,ll b)
{
        ll ans=1;
        while(b)
        {
                if(b&1) ans= ( ans * a);
                a=( a* a);
                b>>=1;
        }
        return ans;
}
int main()
{
    int len=getPrime();
    ll n,p;
    cin>>n>>p;
    if(n==1)
    {
        cout<<p<<endl;
        return 0;
    }
    int cnt=getPrifac(p,len);
    ll ans=1;
    repd(i,1,cnt)
    {
        if(pf[i][1]>=n)
        {
            ans*=quick_pow(pf[i][0],pf[i][1]/n);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 16112
def main():
    n = input()
    bb = map(int, raw_input().split())
    if any(b > i for i, b in enumerate(bb, 1)):
        print -1
        return
    ans = []
    while bb:
        for i in range(len(bb) - 1, -1, -1):
            if bb[i] == i + 1:
                ans.append(i + 1)
                bb.pop(i)
                break
    for a in ans[::-1]:
        print a


if __name__ == "__main__":
    main()


Measured memory_bytes: 28908
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(int i=a; i<b; i++)
#define loopb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool compare(const pii& v1, const pii& v2){
	return v1.f < v2.f;
}
lli solve(){
	lli n, m;
	cin>>n>>m;
	vector<pii> S(n);
	loop(i, 0, n)	cin>>S[i].f>>S[i].s;
	vector<vll> dp(n+1, vll(m+1, 0));
	sort(S.begin(), S.end(), compare);
//	loop(i, 0, n)	cout<<S[i].f<<" "<<S[i].s<<"\n";
	loop(i, 1, n+1){
		loop(j, 1, m+1){
			if(j < S[i-1].f)
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			else
				dp[i][j] = max(dp[i-1][j-S[i-1].f] + S[i-1].s, max(dp[i-1][j], dp[i][j-1]));
		}
	}
	cout<<dp[n][m]<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 80256
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入
// xのn乗%modを計算
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int N,K;
    cin >> N >> K;
    ll ans,tmp;
    ans=0;
    vector<ll> v(K+1,0);
    REP2(i,1,K+1){
        v[i]=mod_pow((ll)(K/i),N,(ll)MOD);
    }
    int next;
    REPD2(i,K,0){
        REP2(j,1,K+1){
            next=i+j*i;
            if(next<=K){
                if(v[i]<v[next]) v[i]+=MOD;
                v[i]-=v[next];
                v[i]%=MOD;
            }else{
                break;
            }
        }
    }

    REP2(i,1,K+1){
        ans+=((v[i]*i)%MOD);
        ans%=MOD;
    }


    cout << ans << endl;
    
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=s.size();
    map<ll,ll> mp;
    ll pow=1,ans=0,now=0;
    mp[0]=1;
    for(ll i=n-1;i>=0;i--){
        ll c=s[i]-'0';
        now+=(c*pow)%2019;
        now%=2019;
        ans+=mp[now];
        mp[now]++;
        pow*=10;
        pow%=2019;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3772
#include<stdio.h>
int main(){
  int a,b;
  int y1,y2;
  double y3;
 
  scanf("%d%d",&a,&b);
  y1=a/b;
  y2=a%b;
  y3=(double)a/b;
 
  printf("%d %d %f\n",y1,y2,y3);
  return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<pair<int,int>> A(N);
    
    rep(i,N){
        A.at(i).second=i+1;
        cin>>A.at(i).first;
    }
    sort(A.begin(),A.end());
    rep(i,N){
        cout<<A.at(i).second;
        if(i<N-1){cout<<" ";}
    }
    cout<<endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

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

using namespace std;

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

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

class modint_t {
public:
    modint_t() = default;
    modint_t(int64_t value):value(value % MOD){}

    bool operator<(const modint_t rhs) const { return value < rhs.value; }
    bool operator<=(const modint_t rhs) const { return value <= rhs.value; }
    bool operator>(const modint_t rhs) const { return value > rhs.value; }
    bool operator>=(const modint_t rhs) const { return value >= rhs.value; }

    modint_t operator+(const modint_t rhs) const { return modint_t(value + rhs.value); }
    modint_t operator+=(const modint_t rhs) { return value = (value + rhs.value) % MOD; }
    modint_t operator-(const modint_t rhs) const { return modint_t(MOD + value - rhs.value); }
    modint_t operator-=(const modint_t rhs) { return value = (MOD + value - rhs.value) % MOD; }

    modint_t operator*(const modint_t rhs) const { return modint_t(value * rhs.value); }
    modint_t operator*=(const modint_t rhs) { return value = value * rhs.value % MOD; }
    modint_t operator/(const modint_t rhs) const { return *this * rhs.invert(); }
    modint_t operator/=(const modint_t rhs) { return *this *= rhs.invert(); }

    modint_t square() const { return *this * *this; }
    modint_t power(int64_t y) const
    {
        if(y == 0) return 1;
        else if(y == 1) return *this;
        else if(y % 2 == 0) return this->power(y/2).square();
        else return *this * this->power(y-1);
    }

    modint_t invert() const
    {
        return power(MOD-2);
    }

    operator int64_t() const
    {
        return value;
    }
private:
    static const int MOD = 1000000007;
    int64_t value = 0;
};

void solution()
{
    int n, k;
    cin >> n >> k;
    modint_t min_sum;
    modint_t max_sum;
    modint_t count;
    for(int i = 0; i <= n + 1; ++i){
        if(i >= k){
            count += (modint_t(1) + max_sum - min_sum);
        }
        min_sum += i;
        max_sum += n - i;
    }
    cout << count << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}


Measured memory_bytes: 3608
#!/usr/bin/env ruby



$visited = []
$pre_vertex = []


def min a,b
  if a<b then return a else b end
end

def init_dfs v,e
  $visited = Array.new(v,false)
  $pre_vertex = Array.new(v,false)
end

#b -> e ??§edges
def dfs b,e,es
  es[b].each_with_index do |c,v|
    if !$visited[v] and c>0 then
      $visited[v] = true
      $pre_vertex[v] = b
      if v==e then
        return
      end
      dfs(v,e,es)
    end
  end
end


def back_trace v,e,es
  flow =[]
  min_c = 10e8

  to = v-1
  from = $pre_vertex[v-1]
  flow=[[from,to]]+flow
  min_c = min(min_c,es[from][to])

  while from != 0
    to = from
    from = $pre_vertex[from]
    flow=[[from,to]]+flow
    min_c = min(min_c,es[from][to])
  end
  return flow,min_c
end



v_size,e_size = gets.chomp.split(/ /).map{|i| i.to_i}

edges = Array.new(v_size).map{ Array.new(v_size,0)}


e_size.times do
  u,v,c = gets.chomp.split(/ /).map{|i| i.to_i}
  edges[u][v]=c
end

  @ans = 0
loop do
  init_dfs(v_size,e_size)
  dfs(0,v_size-1,edges)
  if $visited[v_size-1] then
    f,min_c = back_trace(v_size,e_size,edges)
    f.each do |i|
      edges[i[0]][i[1]]-=min_c
      edges[i[1]][i[0]]+=min_c
    end
    @ans = @ans+ min_c
  else
    p @ans
    break
  end
end

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

using namespace std;
// #define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
// #define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main(){
  int n;
  const long long INF = 1e18;
  const int max_n = 100000;
  long long a[max_n+1];

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

  long long sum = 1;
  long long pre = 0;
  bool flag = 0;
  bool flag0 = 0;

  for(int i = 0; i < n; i++){
    if(a[i] == 0){
      // cout << 0 << endl;
      // return 0;
      flag0 = 1;
    }
  }

  for(int i = 0; i < n; i++){
    sum = sum * a[i];
    if(sum < pre) flag = 1;
    if(sum > INF) flag = 1;
    pre = sum;
  }

  if(flag0) cout << 0 << endl;
  else if(flag) cout << -1 << endl;
  else cout << sum << endl;

  return 0;
}

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

int main(){
    
    int n;
    std::string s;

    std::cin >> n >> s;
    
    for(auto&& e : s){
        if(e + n > 'Z'){
            e = (e + n) % 'Z' + 'A' - 1; 
        }else{
            e += n;
        }
    }

    std::cout << s << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();
        //最大値を格納する変数ans
        long ans = a * c;
        if(a * d > ans){
            ans = a * d;
        }
        if(b * c > ans){
            ans = b * c;
        }
        if(b * d > ans){
            ans = b * d;
        }
        //ansを出力する
        System.out.println(ans);
    }
}

Measured memory_bytes: 35768
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}
///////////
///////////////
#define int long long //**//
///////////////
///////////
int getxor(int x) {
    if (x % 2) {
        if (((x + 1) / 2) % 2)
            return 1;
        else
            return 0;
    }
    else
        return getxor(x + 1) ^ (x + 1);
}

signed main() {
    int a, b;
    cin >> a >> b;
    cout << (getxor(a - 1) ^ getxor(b)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
using namespace std;
int main(){   
   int h,n;
   cin>>h>>n;
   int sum=0;
   rep(i,n){
      int a;
      cin>>a;
      sum+=a;
   }
   sum>=h? cout<<"Yes":cout<<"No";
   return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define IOFAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long
#define for(i,n) for(int i=0;i<n;i++)

#define vec vector<int>

#define pb push_back  
#define f first
#define s second


int main(){
    int n;
    cin>>n;
    int flag=0;
    while(n!=0){
        int d = n%10;
        if(d==7){
            flag=1;
            break;
        }
        n/=10;
        if(n==0){
            break;
        }
    }
    
    if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 3568
#include <iostream>
#include <map>

using namespace std;

int main() {
    int card[3][3];
    for (int i = 0; i < 3; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        card[i][0] = a;
        card[i][1] = b;
        card[i][2] = c;
    }
    int N;
    cin >> N;
    map<int, int> b;
    for (int i = 0; i < N; i++) {
        int bn;
        cin >> bn;
        b[bn] = 1;
    }
    bool hit = false;
    for (int i = 0; i < 3; i++) {
        if (b.find(card[i][0]) != b.end() && b.find(card[i][1]) != b.end() && b.find(card[i][2]) != b.end()) {
            hit = true;
            break;
        }
    }
    for (int j = 0; j < 3; j++) {
        if (b.find(card[0][j]) != b.end() && b.find(card[1][j]) != b.end() && b.find(card[2][j]) != b.end()) {
            hit = true;
            break;
        }
    }
    if (b.find(card[0][0]) != b.end() && b.find(card[1][1]) != b.end() && b.find(card[2][2]) != b.end()) {
        hit = true;
    }
    if (b.find(card[0][1]) != b.end() && b.find(card[1][1]) != b.end() && b.find(card[2][0]) != b.end()) {
        hit = true;
    }
    if (hit) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

// デバッグ用
#define _DEBUG
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
// ここまで
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

vector<int> c;

int main() {
    int N, Q;
    string s;
    cin >> N >> Q >> s;
    c.resize(N);
    vector<int> l(Q), r(Q);
    REP(i, Q) { cin >> l[i] >> r[i]; }

    c[0] = 0;
    REP(i, N - 1) {
        c[i + 1] = c[i];
        if(s[i] == 'A' && s[i + 1] == 'C')
            c[i + 1]++;
    }

    REP(i, Q) {
        int cnt = c[r[i] - 1] - c[l[i] - 1];
        cout << cnt<<endl;
    }

    return 0;
}

Measured memory_bytes: 2176
/*****************************
Filename: dfdkljfd.cpp
Author: hbb
Create: 2020-04-04 20:11:33
 *****************************/
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = INT_MAX >> 1;
typedef long long int LL;

int n;
double m;
double a[maxn];

int main(){
	scanf("%d %lf", &n, &m);
	double sum = 0;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		scanf("%lf", &a[i]);
		sum += a[i];
	}
	for(int i = 1; i <= n; i++){
		if(sum * (1.0 / (4.0 * m)) <= a[i]){
			ans++;
		}
	}
	if(ans >= m) printf("Yes\n");
	else printf("No\n");

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#define MAXN 200001

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int n,a[MAXN],times[MAXN*10];
bool okay[MAXN*10];

int main() {
	read(n);int maxx=0;
	for(int i=1;i<=n;++i) {
		read(a[i]);
		if(a[i]>maxx) maxx=a[i];
		++times[a[i]];
	}
	std::sort(a+1,a+n+1);int ans=0;
	for(int i=1;i<=n;++i) {
		if(okay[a[i]]==1) continue;
		++ans;
		if(times[a[i]]>=2) {
			okay[a[i]]=1;
			--ans;
		}
		int j=a[i]+a[i];
		while(j<=maxx) {
			okay[j]=1;
			j+=a[i];
		}
	}
	std::cout<<ans<<'\n';
	return 0;
}

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



int main()
{
    string s;
    ll k,a=0;
    cin >> s >> k;
    if(s[0]!='1')
        cout << s[0] << endl;
    else{
        for (a; a < s.size(); a++)
        {
            if(s[a]!='1')
                break;
        }
        if(k<=a)
            cout << 1 << endl;
        else
            cout << s[a] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
def backhome():
	s = input()
	if (('N' in s) and ('S' in s)) and not (('W' in s) or ('E' in s)):
		print("Yes")
	elif (('W' in s) and ('E' in s)) and not (('N' in s) or ('S' in s)):
		print("Yes")
	elif (('W' in s) and ('E' in s)) and (('N' in s) and ('S' in s)):
		print("Yes")
	else:
		print("No")

backhome()

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, W;
  cin >> n >> W;
  ll V = 10000;
  vll v(n), w(n);
  REP(i,n) cin >> v[i] >> w[i];

  vvll dp(n+1,vll(V+1,LINF));

  dp[0][0] = 0;

  for(ll i = 1; i <= n; i++){
    for(ll j = 0; j <= V; j++){
      if(j - v[i - 1] < 0) dp[i][j] = dp[i - 1][j];
      dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
    }
  }

  for(ll i = V; i >= 0; i--){
    if(dp[n][i] <= W){
      cout << i <<endl;
      return 0;
    }
  }



  return 0;
}




Measured memory_bytes: 10800
def most_frequent(List):
    counter = 0
    num = List[0]

    for i in List:
        curr_frequency = List.count(i)
        if(curr_frequency> counter):
            counter = curr_frequency
            num = i

    return num

n = int(input())
c = []
for i in range(n):
    x,y = map(int,input().split())
    c.append([x,y])
c = sorted(c)
l = []
for i in range(len(c)-1):
    for j in range(i+1,len(c)):
        l.append([c[j][0]-c[i][0],c[j][1]-c[i][1]])
if(n==1):
    z = most_frequent(c)
else:
    z = most_frequent(l)
l = 1
for i in range(1,len(c)):
    if([c[i][0]-z[0],c[i][1]-z[1]] not in c):
        l+=1
print(l)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(0);
    cout.tie(0);
    int n ;
    vector <int> v;
    cin >> n ;
    int x = n ;
    while(n--)
    {
        int temp ;
        cin >> temp ;
        v.push_back(temp) ;
    }
    int cnt = 0 ;
    int least = 1e7 ;
    for(int i = 0 ; i < x ; i++)
    {
        if(v[i] < least)
        {
            least = v[i] ;
            cnt++ ;
        }
    }
    cout << cnt << endl ;
}

Measured memory_bytes: 4228
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int h, m, s, lh, lm, ls, buf_s, buf_m;

	while(1){

		scanf("%d%d%d", &h, &m, &s);
		if(h == -1 && m == -1 && s == -1)
			break;

		lh = 2; lm = 0; ls = 0;

		if(ls < s){
			ls += 60;
			lm = 59;
			lh--;
			ls -= s;
		}
		if(lm < m){
			lm += 60;
			lh--;
			lm -= m;
		} else
			lm -= m;
		lh -= h;

		printf("%02d:%02d:%02d\n", lh, lm, ls);

		buf_s = (ls * 3) / 60;
		ls = (ls * 3) % 60;
		buf_m = ((lm * 3) + buf_s) / 60;
		lm = ((lm * 3) + buf_s) % 60;
		lh = (lh * 3) + buf_m;

		printf("%02d:%02d:%02d\n", lh, lm, ls);

	}

	return 0;

}

Measured memory_bytes: 612
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  double N, K;
  cin >> N >> K;
  ll ans = (ll)(K * pow(K - 1, N - 1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main{
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int number1 = sc.nextInt();
  int number2 = sc.nextInt();
  int menseki = number1 * number2;
  int shuu = number1 * 2 + number2 * 2;
  System.out.println(menseki + " " + shuu);
 }
}


Measured memory_bytes: 26092
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<int,int>

using namespace std;

int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
pair <int, int> vu[4] = { {0,1}, {0,-1} , {1,0},{-1,0} }; // EWSN

const int max_v = 1e5 + 7;
const int INF = 1e7 + 7;

double n;

int main()
{
	//ios_base::sync_with_stdio(0); cin.tie(0);
	ci(n);
	n /= 3;
	double ans = n * n * n;
	printf("%.6lf", ans);

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<double> x(N), y(N);
    REP(i,N) cin >> x[i] >> y[i];

    vector<int> a(N);
    iota(a.begin(), a.end(), 0);
    double sum = 0.0;
    do{
        for(int i=1;i<N;i++){
            sum += sqrt((x[a[i]] - x[a[i-1]])*(x[a[i]] - x[a[i-1]]) + (y[a[i]] - y[a[i-1]]) * (y[a[i]] - y[a[i-1]]));
        }
    }while(next_permutation(a.begin(), a.end()));
    for(int i=1;i<=N;i++) sum /= (double)i;
    printf("%.12lf\n",sum);
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
#define int long long
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;


int mpow(int a,int x);
int m_inv(int n){return mpow(n,mod-2);}

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

signed main(){
    int N;cin>>N;
    vector<int> a(N);
    rep(i,N) cin>>a[i];
    int left=-100,right=100;
    int ans=0;
    while(left!=right){
    	int lcost=0,mcost=0,rcost=0;
    	int mid=(left+right)/2;
    	rep(i,N){
    		lcost+=mpow(left-a[i],2);
    		rcost+=mpow(right-a[i],2);
    	}
    	if(lcost>rcost){ 
    		if(left!=mid) left=mid;
    		else left=right;
    	}
    	else if(lcost<rcost){ 
    		if(right!=mid) right=mid;
    		else right=left;
    	}
    	else left=right=mid;
    }
    rep(i,N) ans+=mpow(right-a[i],2);
    cout<<ans<<endl;
}

int mpow(int a,int x){
	int ans=1;
	while(x>0){
		if(x%2==1) (ans*=a)%=mod;
		(a*=a)%=mod;
		x>>=1;
	}
	return ans;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin>>S;
  int n=0,s=0,e=0,w=0;
  for(int i=0;i<S.size();++i){
    if(S[i]=='N') ++n;
    if(S[i]=='S') ++s;
    if(S[i]=='E') ++e;
    if(S[i]=='W') ++w;
  }
 
  if(n>0){
    if(s==0) cout<<"No"<<endl;
    else{
      if(e>0 && w==0) cout<<"No"<<endl;
      else if(e>0 && w>0) cout<<"Yes"<<endl;
      else if(e==0 && w==0) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
  }
  else{
    if(s>0) cout<<"No"<<endl;
    else{
      if(e>0 && w==0) cout<<"No"<<endl;
      else if(e>0 && w>0) cout<<"Yes"<<endl;
      else if(e==0 && w==0) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int 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)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, x;
  cin >> N >> x;
  if(x == 1 || x == 2*N-1) {
    cout << "No" << endl;
    return 0;
  }
  vector<int> ans(2*N-1);
  ans[N-1] = x;
  ans[N-2] = x+1;
  ans[N] = x-1;
  int now = 1;
  REP(i, 2*N-1) {
    if(i >= N-2 && i <= N) continue;
    if(now == x-1) now = x+2;
    ans[i] = now;
    now++;
  }
  cout << "Yes" << endl;
  REP(i, 2*N-1) cout << ans[i] << "\n";
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int N = 1e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    init();
    int n;cin>>n;
    cout<<48-n<<endl;

    return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, k = sc.nextInt
    val a = new Array[Long](n)
    for (i <- 0 until n) {
      a(i) = sc.nextLong
    }

    val ans = a.sorted.reverse.slice(k, n).sum
    println(ans)
  }
}


Measured memory_bytes: 73188
from functools import reduce
import fractions
from warnings import simplefilter
simplefilter("ignore")
N, X = map(int, input().split())
xlist = list(map(int, input().split()))
sbn = [abs(x - X) for x in xlist]


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


print(gcd_list(sbn))


Measured memory_bytes: 16284
// ※※※ 解答不能 ※※※
// TangentDay氏.
// https://atcoder.jp/contests/abc142/submissions/7755270
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ALL(c) (c).begin(), (c).end()
typedef pair<int, int> P;
typedef vector<int> VI;

const int N = 1010;
int par[N], visit[N];
VI e[N];

P dfs(int now, int past){
    visit[now] = 1;
    par[now] = past;
    for (int next : e[now]){
        if(visit[next]) return P(now, next);
        P x = dfs(next, now);
        if(x != P(-1, -1)) return x;
    }
    visit[now] = 0;
    par[now] = -1;
    return P(-1, -1);
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    rep(i, m){
        int u, v;
        scanf("%d %d", &u, &v);
        u--, v--;
        e[u].push_back(v);
    }
    vector<int> loop;
    rep(i, n){
        rep(j, n) visit[i] = 0;
        P p = dfs(i, -1);
        if(p == P(-1, -1)) continue;
        int x = p.first, y = p.second;
        loop.push_back(x);
        while(x != y){
            x = par[x];
            loop.push_back(x);
        }
        reverse(ALL(loop));
        break;
    }
    
    if(loop.empty()){
        printf("%d\n", -1);
        return 0;
    }
    
    while(true){
        // for(int x : loop) printf("%d ", x + 1);
        // printf("\n");
        VI p(n, -1);
        rep(i, loop.size()) p[loop[i]] = i;
        int from = -1, to = -1;
        rep(i, loop.size()){
            int x = loop[i];
            for(int y : e[x]){
                if(p[y] != -1 && p[y] != (i + 1) % loop.size()){
                    from = i;
                    to = p[y];
                    break;
                }
            }
            if(from != -1) break;
        }
        if(from == -1) break;
        // printf("%d %d\n", from, to);
        VI loop_next;
        if(from < to){
            rep(i, loop.size()){
                if(i <= from || i >= to) loop_next.push_back(loop[i]);
            }
        }else{
            for(int i = to; i <= from; ++i) loop_next.push_back(loop[i]);
        }
        loop = loop_next;
        if(loop.size() == 2) break;
    }
    printf("%d\n", loop.size());
    for(int x : loop) printf("%d\n", x + 1);
    return 0;
}

Measured memory_bytes: 384
from sys import exit

N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

c = {}
for i in D:
    if i in c:
        c[i] += 1
    else:
        c[i] = 1

if c[0] != 1:
    print(0)
    exit()

result = 1
for i in range(1, max(D) + 1):
    if i not in c:
        print(0)
        exit()
    result = result * (c[i - 1] ** c[i]) % 998244353
print(result)


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

//atcoder need change class name to Main
//H - Grid 1
//https://atcoder.jp/contests/dp/tasks/dp_h


public class Main {
    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
  
        int H = nextInt(); 
        int W = nextInt(); 

       
        // Dp array 
        long[][] dp = new long[H+1][W+1]; 

        dp[0][1] = 1; //set initial start point

        for (int i=1; i<=H;  i++) {
            char[] temp = next().toCharArray();
            for (int j=1; j<=W;  j++) {
                if(temp[j-1] == '#'){//temp is 0 base 
                    dp[i][j] = 0;
                }
                else{
                    dp[i][j] = dp[i-1][j] + dp[i][j-1];
                }
                dp[i][j] = dp[i][j] % (1000000007);
            }
        }
 
        //System.out.println(dp[H][W] % (1000000000 + 7));

        System.out.println(dp[H][W]);
  
    }
    

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 35664
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int main() {
	string h;
	getline(cin, h);
	transform(all(h), h.begin(), ::toupper);
	cout << h << endl;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,L;cin>>N>>L;
  vector<long> A(N);for(int i=0;i<N;i++)cin>>A[i];
  int last=-1;long max_pair=0;
  for(int i=0;i<N-1;i++){
    if(A[i]+A[i+1]>max_pair){
      max_pair=A[i]+A[i+1];last=i;
    }
  }
  if(max_pair<L){cout<<"Impossible";return 0;}
  cout<<"Possible"<<endl;
  for(int i=0;i<last;i++)cout<<i+1<<endl;
  for(int i=N-2;i>last;i--)cout<<i+1<<endl;
  cout<<last+1;
  
  
}

Measured memory_bytes: 1664
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int scoa1=0,scoa2=0;
        String data[] = new String[2];

        int n=sc.nextInt();
        for(int i=0;i<n;i++){
        	data[0] = sc.next();
        	data[1] = sc.next();
        	if(data[0].compareTo(data[1])<=-1){
        		scoa1+=3;
        	}
        	else if(data[0].compareTo(data[1])>=1){
        		scoa2+=3;
        	}
        	else if(data[0].compareTo(data[1])==0){
        		scoa1++;scoa2++;
        	}
        	else{
        		System.out.println("EEE");
        	}
        }
        System.out.println(scoa2+" "+scoa1);
        sc.close();
    }
}


Measured memory_bytes: 29996
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn main() {
    let N = get!(i64);

    // 1桁, 3桁, 5桁の個数を数え上げる
    let ans = cmp::min(9, N) +
        cmp::max(0, cmp::min(999, N) - 99) +
        cmp::max(0, cmp::min(99999, N) - 9999);

    println!("{}", ans);
}


Measured memory_bytes: 4352