akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (int i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    int D[N];
    REP(i, N) cin >> D[i];

    int ret = 0;
    REP(i, N-1) FOR(j, i+1, N)
    {
        ret += D[i] * D[j];
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
mat = []
for _ in range(N):
    mat.append(list(map(int, input().split())))


def sortkey(a, b, c):
    def f(x):
        return (x[a], x[b], x[c])
    return f


def invertSum(a, b, c):
    def f(x):
        return (-x[0] if a else x[0]) + (-x[1] if b else x[1]) + (-x[2] if c else x[2])
    return f


mp = [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]


mats = []
for sign in mp:
    mats.append(list(map(invertSum(*sign), mat)))

for idx, m in enumerate(mats):
    mats[idx] = sorted(m, reverse=True)


def funcSelectM(M):
    def select(seq):
        return seq[:M]
    return select


from pprint import pprint


takeMmats = list(map(funcSelectM(M), mats))
# for m in takeMmats:
#     pprint(m)
print(max(map(sum, takeMmats)))


Measured memory_bytes: 4332
N,*A=`dd`.split.map &:to_i
x,y=[A,A.reverse].map{|_|
	t=[]
	r=[c=0]
	_.each_with_index{|a,i|
		b=a
		q=1
		while !t.empty?&&t[-1][0]<b
			x,d,n=t.pop
			k=Math.log(b.to_f/x,4).ceil
			b=d*4**k
			c+=n*2*k
			q+=n
		end
		t<<(t.empty? ? [a,0,q] : [a,b,q])
		r<<c
	}
	r
}
p (0..N).map{|i|x[i]+i+y[-1-i]}.min

Measured memory_bytes: 39184
#include <bits/stdc++.h>
using namespace std;
long long quickpow(int x,int y)
{
	if(y==0) 
		return 1;
	long long t=quickpow(x,y/2);
	long long ret=t*t;
	if(y%2==1) 
		ret=ret*x;
	return ret;
}
int main()
{
	long long n,e;
	scanf("%lld%lld",&n,&e);
	if(e==100)
		e++;
	printf("%lld\n",quickpow(100,n)*e);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
ll dp[3001][3001];
void solve()
{
    string s,t;
    cin>>s>>t;
    ll ls=s.length();
    ll lt=t.length();
    for(ll i=1;i<=ls;i++){
        for(ll j=1;j<=lt;j++){
            if(s[i-1] == t[j-1]){
                dp[i][j]=max(dp[i][j],1+dp[i-1][j-1]);
            }
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    //cout << dp[ls][lt] <<"\n";
    string ans;
    ll i=ls,j=lt;
    while(i>0 && j>0)
    {
        if(s[i-1] == t[j-1]){
            ans.pb(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j] > dp[i][j-1])i--;
        else j--;
    }
    reverse(all(ans));
    cout << ans <<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 70656
total, a, b = map(int, input().split())
list = list(input())

passed = 0;
b_passed = 0;
for i, item in enumerate(list):
    if (item == "a" and passed < a + b):
        print("Yes")
        passed += 1
    elif (item == "b" and passed < a + b and b_passed < b):
        print("Yes")
        passed += 1
        b_passed += 1
    else:
        print("No")

Measured memory_bytes: 4704
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
  string S;
  int N;
  int K;
  while (cin >> N >> K >> S) {
    S[K-1] += 0x20;
    cout << S << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,a,b,c;
    cin>>n;
    a=n/500;
    b=n%500;
    b=b/5;
    a=a*1000+b*5;
    cout<<a<<endl;

    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << n / 3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>

using namespace std;

static const int MAX = 100000;
static const int INFTY = (1 << 30);

class Edge {
public:
  int t, w;
  Edge() {}
  Edge(int t, int w)
    : t(t)
    , w(w) {}
};

vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s) {
  for (int i = 0; i < n; i++) {
    d[i] = INFTY;
  }
  queue<int> Q;
  Q.push(s);
  d[s] = 0;
  int u;
  while (!Q.empty()) {
    u = Q.front(); Q.pop();
    for (int i = 0; i < G[u].size(); i++) {
      Edge e = G[u][i];
      if (d[e.t] == INFTY) {
        d[e.t] = d[u] + e.w;
        Q.push(e.t);
      }
    }
  }
}

void solve() {
  bfs(0);
  int maxv = 0;
  int tgt = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] == INFTY) {
      continue;
    }
    if (maxv < d[i]) {
      maxv = d[i];
      tgt = i;
    }
  }

  bfs(tgt);
  maxv = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] == INFTY) {
      continue;
    }
    maxv = max(maxv, d[i]);
  }

  cout << maxv << endl;
}

int main() {
  int s, t, w;
  cin >> n;

  for (int i = 0; i < n -1; i++) {
    cin >> s >> t >> w;

    G[s].push_back(Edge(t, w));
    G[t].push_back(Edge(s, w));
  }

  solve();

  return 0;
}




Measured memory_bytes: 9860
M, D = map(int, input().split())
ans = 0
for m in range(4, M+1):
    for d in range(22, D+1):
        d = str(d)
        d_10, d_1 = int(d[0]), int(d[1])
        if d_10 < 2 or d_1 < 2:
            continue
        if d_10 * d_1 == m:
            ans += 1

print(ans)

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for(int i = 0;i < n;i ++)cin >> a[i];
    for(int i = 0;i < n;i ++)cin >> b[i];
    for(int i = 0;i < n;i ++)cin >> c[i];
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    for(int i = 0;i < n;i ++){
        int mid = b[i];
        ll ca=lower_bound(a.begin(),a.end(),mid)-a.begin(),cc=c.end()-upper_bound(c.begin(),c.end(),mid);
        ans += ca*cc;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    private static final BufferedReader READER = new BufferedReader(new InputStreamReader(System.in));

    private static int getInt() {
        try {
            return Integer.parseInt(READER.readLine());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static int[] getIntArr(int n) {
        int[] ans = new int[n];

        StringTokenizer stringTokenizer = null;
        try {
            stringTokenizer = new StringTokenizer(READER.readLine(), " ");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        for (int i = 0; i < n && stringTokenizer.hasMoreTokens(); i++) {
            ans[i] = Integer.parseInt(stringTokenizer.nextToken());
        }

        return ans;
    }

    private static int solve() {
        int[] nk = getIntArr(2);
        int n = nk[0];
        int k = nk[1];
        if (n == 0 || k == 0) {
            return 0;
        }
        int[] hs = getIntArr(n);
        return solveInternal(n, k, hs);
    }

    private static int solveInternal(int n, int k, int[] hs) {
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(hs[1] - hs[0]);
        for (int i = 2; i < n; i++) {
            int lowBound = Math.max(0, i - k);
            int best = dp[lowBound] + Math.abs(hs[i] - hs[lowBound]);
            for (int j = lowBound + 1; j <= i - 1; j++) {
                int cost = dp[j] + Math.abs(hs[i] - hs[j]);
                if (cost < best) {
                    best = cost;
                }
            }
            dp[i] = best;
        }

//        for (int i = 0; i < dp.length; i++) {
//            System.out.println(dp[i]);
//        }
        return dp[n - 1];
    }

    public static void main(String... args) {
        System.out.println(solve());
//        System.out.println(solveInternal(10, 4, new int[]{40, 10, 20, 70, 80, 10, 20, 70, 80, 60}));
    }
}


Measured memory_bytes: 35096
from collections import Counter

n,m=map(int,input().split())

lis=[]
cnt=0
for i in range(n):
  l=list(map(int,input().split()))
  lis+=l[1:]
  
d=Counter(lis)
for i in d.values():
  if i==n:
    cnt+=1
    
print(cnt)

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

int main(){
  int n;cin>>n;
  vector<int>p(n);
  int ans=0;
  for(int i=0;i<n;++i) cin>>p[i];
  for(int i=0;i<n-2;++i){
    if(p[i]<p[i+1] && p[i+1]<p[i+2]) ++ans;
    if(p[i]>p[i+1] && p[i+1]>p[i+2]) ++ans;
  }
  cout<<ans<<endl;
  return 0;
}

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

char S[ 20 ];


int main()
{
int i;
int N;
int K;
char C;
char cChk;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> S;
	cin >> K;

	cChk = S[ K - 1 ];
	i = 0;
	while( C = S[ i ] )
	{
		if( C != cChk ) S[ i ] = '*';

		i++;
	}

	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[20],dp[1<<13][20];

int main() {
  while(cin >> n && n) {
    int m;
    cin >> m;
    n*=2;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) dp[0][i]=1;
    for(int t=1; t<=m; t++) {
      for(int i=0; i<n; i++) {
        dp[t][i]=0;
        for(int k=1; k<=a[i]; k++) {
          if(t-k>=0) dp[t][i]=max(dp[t][i],dp[t-k][(i+1)%n]^1);
        }
      }
    }
    cout << dp[m][0] << endl;
  }
  return 0;
}


Measured memory_bytes: 3500
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\s/g);
var a = input[0] - 0;
var b = input[1] - 0;
var c = input[2] - 0;
var d = input[3] - 0;
var x = a * b;
var y = c * d;
console.log(Math.max(x, y));

Measured memory_bytes: 10312
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	a := scanInt(sc)
	b := scanInt(sc)
	fmt.Println(lcm(a, b))
}

func lcm(a, b int) int {
	if a > b {
		return lcm(b, a)
	}
	for i := 1; i <= b; i++ {
		n := a * i
		if n%b == 0 {
			return n
		}
	}
	panic("unreachable")
}


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

class UnionFind {
public:
  vector<ll> par, siz;
  UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
    for(int i=0; i<sz_; ++i) par[i]=i;
  }
  void init(ll sz_) {
    par.resize(sz_);
    siz.assign(sz_,1);
    for(int i=0; i<sz_; ++i) par[i]=i;
  }

  ll root(ll x) {
    while(x!=par[x]) {
      x = par[x] = par[par[x]];
    }
    return x;
  }

  void merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x!=y) {
      if(siz[x]<siz[y]) swap(x,y);
      siz[x]+=siz[y];
      par[y]=x;
    }
  }

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  ll size(ll x) {
    return siz[root(x)];
  }
};

int main() {
  int N,M; cin>>N>>M;
  int ans=0;
  UnionFind friends(N);
  for(int i=0; i<M; ++i) {
    int a,b; cin>>a>>b;
    a--; b--;
    friends.merge(a,b);
  }
  for(int i=0; i<N; ++i) ans = max(ans,(int)friends.size((ll)i));
  cout << ans << endl;
}


Measured memory_bytes: 6420
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var K = LnInt();
        var result = 0;
        for(int a= 1; a<= K; a++)
        {
            for(int b = 1; b <= K; b++)
            {
                for(int c = 1; c <= K; c++)
                {
                    result += gcd(a, b, c);
                }
            }
        }
      Console.WriteLine(result);
    }

   static int gcd(int a,int b,int c)
    {
       return Gcd(Gcd(a, b), c);
    }

    public static int Gcd(int a, int b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }

    public static int[] LnInts()
    {
        var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        var ins = new int[vs.Length];
        for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]);
        return ins;
    }

    public static int LnInt()
    {
        var vs = Console.ReadLine().Trim();
        return int.Parse(vs);
    }

    public static string[] LnStrs()
    {
        var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        return vs;
    }
    public static string LnStr()
    {
        var vs = Console.ReadLine().Trim();
        return vs;
    }
}

Measured memory_bytes: 27528
import math
A = list(map(int, input().split()))


L = 30 * A[2] + 0.5 * A[3]
S = 6 * A[3]

x = A[0]*A[0] + A[1]*A[1] - 2*A[0]*A[1]*math.cos(math.radians(min(math.fabs(L-S)%360,360-math.fabs(L-S)%360)))
print(math.sqrt(x))


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9 + 7;

// MOD を取りながら nCm を計算する方法
// フェルマーの小定理を使って逆元を使う
template <typename T>
T pow_mod(T n, T p, T m)  // (n^p) % m
{
    if(p == 0) return 1;
    if(p%2 == 1) return pow_mod<T>(n, p-1, m) * n % m;
    else{
        T tmp = pow_mod<T>(n, p/2, m) % m;
        return tmp * tmp % m;
    }
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    vector<long long> iCK(N+1, 0);
    REP(i, N+1){
        if(i == K) iCK[i] = 1;
        if(i > K){
            iCK[i] = (i*iCK[i-1]) % MOD * pow_mod<long long>(i-K, MOD-2, MOD);
            iCK[i] %= MOD;
        }
    }

    sort(A.begin(), A.end());
    long long ans = 0;
    REP(i, N-K+1){
        ans -= (long long) A[i] * (iCK[N-i] - iCK[N-i-1]);
        ans %= MOD;
    }
    FOR(i, K-1, N){
        ans += (long long) A[i] * (iCK[i+1] - iCK[i]);
        ans %= MOD;
    }
    cout << (ans+MOD)%MOD << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, a[100010], ta;
vector<int> mu;

signed main() {
	cin >> n;
	cin >> a[0];
	ta += abs(a[0] - 0);
	mu.push_back(0);
	mu.push_back(a[0]);
	for (int i = 1; i < n; i++) {
		cin >> a[i];
		mu.push_back(a[i]);
		ta += abs(a[i] - a[i - 1]);
	}
	mu.push_back(0);
	ta += abs(a[n - 1] - 0);
	for (int i = 1; i < n + 1; i++) {
		if ((mu[i] > mu[i - 1] && mu[i] > mu[i + 1]) || (mu[i] < mu[i - 1] && mu[i] < mu[i + 1])) {
			cout << ta - (min(abs(mu[i] - mu[i - 1]), abs(mu[i] - mu[i + 1])) * 2) << endl;
		}
		else cout << ta << endl;
	}
	ggr
}

Measured memory_bytes: 2932
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
typedef long long ll;

// (N*M)C(K)  (N*M-2)C(K-2) * (|x-x|+|y-y|)
// 2C0

ll M = 1000000007;

ll mod(ll x) {
  return (x + M) % M;
}

ll inv(ll x) {
  ll m = M-2;
  ll r = 1;
  ll y = x;
  while (m > 0) {
    if (m & 1) r = mod(r * y);
    y = mod(y * y);
    m >>= 1;
  }
  return r;
}

ll combi(int n, int k) {
  ll p = 1;
  for (int i = n; i > n-k; i--) {
    p = mod(p * i);
  }
  ll q = 1;
  for (int i = k; i > 0; i--) {
    q = mod(q * i);
  }
  return mod(p * inv(q));
}

ll acc(ll x) {
  return mod(mod(x * (x+1)) * inv(2));
}

int main() {
  int N, M, K;
  scanf("%d%d%d", &N, &M, &K);
  ll c = combi(N*M-2, K-2);
  ll s = 0;
  ll xs = 0;
  for (int x1 = 0; x1 < M; x1++) {
    xs = mod(xs + mod(acc(M-1-x1)));
  }
  //printf("xs=%lld\n", xs);
  ll xxs = 0;
  for (int x1 = 0; x1 < M; x1++) {
    xxs = mod(mod(xxs + acc(x1)) + acc(M-1-x1));
  }
  //printf("xxs=%lld\n", xxs);
  for (int y1 = 0; y1 < N; y1++) {
    s = mod(s + xs);
    s = mod(s + xxs * (N-1-y1));
    s = mod(s + mod(mod(M*M) * acc(N-1-y1)));
  }
  ll ans = mod(c * s);
  printf("%lld\n", ans);
}


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

vector<string> bin;

void generateAllBinaryStrings(int n, int arr[], int i)
{ 
    string s = "";
	if (i == n) {
        for (int i = 0; i < n; i++) 
            s+=to_string(arr[i]); 
        bin.push_back(s);
		return;  
	} 
	arr[i] = 0; 
	generateAllBinaryStrings(n, arr, i + 1); 
	arr[i] = 1; 
	generateAllBinaryStrings(n, arr, i + 1); 
}

int main() 
{
    // INPUT 
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(m);
    for (int i=0; i<m; i++)
    {
        int k;
        cin >> k;
        for (int j=0; j<k; j++)
        {
            int s;
            cin >> s;
            v[i].push_back(s);
        }
    }
    vector<int> p(m);
    for (int i=0; i<m; i++)
        cin >> p[i];
    
    // cout << "ok" << endl;
    // for (int i=0; i<v.size(); i++)
    //     {
    //     for (int j=0; j<v[i].size(); j++)
    //         cout << v[i][j] << " ";
    //     cout << "abc " << endl;
    //     }

    // GENERATE COMBINAISONS
    int N = n; 
	int arr[N];
    int ans = 0;
	generateAllBinaryStrings(N, arr, 0); 
    for (int k=0; k<bin.size(); k++)
    {
        bool y = true;
        for (int i=0; i<v.size(); i++)
        {
            int nb_switch = 0;
            for (int j=0; j<v[i].size(); j++)
            {
                int switchid = v[i][j];
                if (bin[k][switchid-1] == '1')
                    nb_switch++;
            }
            // cout << nb_switch << endl;
            if (nb_switch % 2 != p[i])
                y = false;
        }
        if (y == true)
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
 
 
#ifdef __BORLANDC__
    typedef __int64 ll;
#else
    typedef long long ll;
#endif
 
const int N = 333;
const int S = N*N;
const int MOD = 1e9+7;
int n;
int s;
int t[N];
 
void add(int &a, int b){
    a = (a+b)%MOD;
}
 
void input(){
    cin>>n;
    rep(i,n)cin>>t[i];
    cin>>s;
}
 
 
int solve(){
     
    int count[S]={0};
    count[s] = 1;
     
    rep(i,n){
        rep(j,s+1){
            int next = j+t[i];
            if(next >= S)continue;
             
            add(count[j], -count[next]);
        }
    }
     
    int sum = 0;
    rep(i,s+1){
        int v = 1;
        rep(j,n){
            v = (int)((ll)v * i % MOD);
        }
        add(sum, (int)((ll)v * count[i] % MOD));
    }
     
    return (sum+MOD)%MOD;;
}
 
 
int main(){
    input();
    cout<<solve()<<endl;
}

Measured memory_bytes: 1600
#include <stdio.h>

bool chk(int a);

int main(){
    int a, b, ans = 0;
    scanf("%d %d", &a, &b);
    for(int i = a; i <= b; i++){
        if(chk(i)) ans++;
    }
    printf("%d", ans);
}

bool chk(int a){
    int sz = 0, num[5] = { 0 };
    while(a != 0){
        num[sz++] = a % 10;
        a /= 10;
    }
    for(int i = 0; i < sz / 2; i++)
        if(num[i] != num[sz - i - 1]) return false;
    return true;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    int N, M;
    cin >> N >> M;
    int a[101001] = {};
    int cnt[101010] = {};
    for (int i = 0; i < N; i++) {
        cnt[i + 1] = 1;
    }
    a[1] = 1;
    while (M--) {
        int x, y;
        cin >> x >> y;
        cnt[x]--;
        cnt[y]++;
        a[y] |= a[x];
        if (cnt[x] == 0)
            a[x] = 0;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += a[i + 1];
    }
    cout << ans << endl;

    solve();
    return 0;
}


Measured memory_bytes: 5144
s = input()
a = 0
b = len(s)
for i in range(len(s)):
  if s[i] == 'A':
    break
  a += 1
for i in range(len(s)):
  if s[len(s)-i-1] == 'Z':
    break
  b -= 1
print(b-a)

Measured memory_bytes: 3516
#include <iostream>
#include <string>
using namespace std;

int main(int argc, char* argv[]){
  string s;
  int nW = 0;
  int pW = 0;
  long long ians=0;
  cin >> s;

  for(int i=0;i<s.length();i++){
    if(s[i]=='W'){
      ians += i-nW;
      nW++;
    }
  }
  cout << ians << endl;

  return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=sc.nextInt();
        int D=sc.nextInt();
        if((C>=A)&&(C<=B)){
            System.out.println(Math.min(B,D)-C);
        }else if((A>=C)&&(D>=A)){
            System.out.println(Math.min(B,D)-A);
        }else{
            System.out.println(0);
        }

        }
        
        
    }


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

#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 rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int h,w; cin>>h>>w;
  vector<string> a(h);
  rep(i,h) cin>>a[i];

  rep(i,w+2) cout<<"#";
  cout<<endl;

  rep(i,h) {
    cout<<"#";
    cout<<a[i];
    cout << "#" << endl;
  }

  rep(i,w+2) cout<<"#";
  cout<<endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            String digits = "753";
            out.println(dfs("0", n, digits));
        }

        long dfs(String s, long n, String digits) {
            if (Long.parseLong(s) > n) return 0;
            long result = digits.chars().allMatch(c -> s.indexOf(c) != -1) ? 1 : 0;
            for (char c : digits.toCharArray()) {
                result += dfs(s + c, n, digits);
            }
            return result;
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

    }
}



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

int main()
{
    int C[3][3];
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cin >> C[i][j];
        }
    }

    int a[3] = {0};
    int b[3] = {0};

    for(int i = 0; i < 3; i++)
    {
        b[i] = C[0][i] - 0;
    }

    for(int i = 1; i < 3; i++)
    {
        a[i] = C[i][i] - b[i];
    }

    bool flag = true;
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            if(C[i][j] != (a[i] + b[j]))
            {
                flag = false;
            }
        }
    }

    if(flag == true) cout << "Yes" << endl;
    else if(flag == false) cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
/*
ID: qazzaq71
PROG: test
LANG: C++
*/
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>

using namespace std;

#define REP(a,n) for(int a=0;a<(n);++a)
#define FOR(a,b,c) for(int a=(b);a<=(c);++a)
#define FORD(a,b,c) for(int a=(b);a>=(c);--a)
#define swap(t,a,b) t=a,a=b,b=t
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)

typedef long long ll;
typedef unsigned long long ull;

int n,m;

double c[50][3];
double maxDist=-1;
int res[50];

void judge(void){
	double dist=0;
	FOR(i,0,m-1)FOR(j,i+1,m-1){
		dist+=	(c[res[i]][0]-c[res[j]][0])*(c[res[i]][0]-c[res[j]][0])+
				(c[res[i]][1]-c[res[j]][1])*(c[res[i]][1]-c[res[j]][1])+
				(c[res[i]][2]-c[res[j]][2])*(c[res[i]][2]-c[res[j]][2]);
	}
	if(dist>maxDist)maxDist=dist;
}
void dfs(int k,int cur){
	if(k==m){
		judge();
		return ;
	}
	FOR(i,cur,n-1){
		res[k]=i;
		dfs(k+1,i+1);
	}
}
int main(){
#ifdef DEBUG
	FILE * ptrFILE=freopen("a.txt","r",stdin);
	assert(ptrFILE!=NULL);
#endif
	scanf("%d%d",&n,&m);
	memset(c,0,sizeof(c));
	FOR(i,0,n-1)
		scanf("%lf%lf%lf",&c[i][0],&c[i][1],&c[i][2]);
	maxDist=-1;
	dfs(0,0);
	printf("%f\n",maxDist);
    return 0;
}

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

using namespace std;

int main()
{
    map<string,int> m;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string h;
        cin>>h;
        if(m.find(h)!=m.end())
            m[h]+=1;
        else
            m[h]=0;
    }
    int u=0;
    for(auto it=m.begin();it!=m.end();it++)
    {
        if(it->second>=u)
            u=it->second;
    }
    for(auto it=m.begin();it!=m.end();it++)
    {
        if(it->second==u)
        {
            cout<<it->first<<endl;

        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

signed main(){
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int cnt=0;
	rep(i,s.size()-1){
		if(s[i]==s[i+1])++cnt;
	}
	int ans=cnt+2*k;//1回の操作で2個増やせる
	if(ans>=n)ans=n-1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
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++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    double L;  cin >> L;
  	printf("%.7f\n", L*L*L / 27);
    return 0;
}


Measured memory_bytes: 256
N,Y = map(int,input().split())
flag = 0
for a in reversed(range(Y//10000+1)) :
    if flag == 0 and 10000*a <= Y :
        for b in reversed(range(N-a+1)) :
            if flag == 0 and 10000*a+5000*b+1000*(N-a-b) == Y :
                print(a,b,N-a-b)
                flag = 1
                break
if flag == 0 :
    print(-1,-1,-1)
    

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");

        br.close();

        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(in[i]);
        }
        Arrays.sort(p);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += p[i];
        }

        bw.write(String.valueOf(ans));

        bw.flush();

    }
}

Measured memory_bytes: 32856
n = int(input())
s = input()
bc = n*[0]
gc = n*[0]
rc = n*[0]
for i in range(1, n+1):
    mi = n - i
    if s[n - i] == 'B':
        if i == 1:
            bc[mi] = 1
        else:
            bc[mi] = bc[mi+1] + 1
            rc[mi] = rc[mi+1]
            gc[mi] = gc[mi+1]
    elif s[mi] == 'R':
        if i == 1:
            rc[mi] = 1
        else:
            rc[mi] = rc[mi+1] + 1
            bc[mi] = bc[mi+1]
            gc[mi] = gc[mi+1]
    elif s[mi] == 'G':
        if i ==1:
            gc[mi] = 1
        else:
            gc[mi] = gc[mi+1] + 1
            rc[mi] = rc[mi+1]
            bc[mi] = bc[mi+1]
si = 0
for i in range(0, n - 1):
    
    for j in range(i+1, n-1):
        if s[j] != s[i]:
            d = j-i 
            if j+d < n:
                nc = s[j+d]
                if nc in [s[i], s[j]]:
                    l = list(set(['R', 'G', 'B']) - set([s[i], s[j]]))
                    if l[0] == 'R':
                        si+= rc[j+1]
                    elif l[0] == 'G':
                        si += gc[j+1] 
                    else:
                        si += bc[j+1]
                else:
                    l = list(set(['R', 'G', 'B']) - set([s[i], s[j]]))
                    if l[0] == 'R':
                        si+= rc[j+1]-1
                    elif l[0] == 'G':
                        si += gc[j+1] -1
                    else:
                        si += bc[j+1] - 1
            else:
                l = list(set(['R', 'G', 'B']) - set([s[i], s[j]]))
                if l[0] == 'R':
                    si+= rc[j+1]
                elif l[0] == 'G':
                    si += gc[j+1] 
                else:
                    si += bc[j+1]
print(si)

Measured memory_bytes: 69328
// Math = ♥️

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

/*-------------------------------------------------------------------------------------------------------------------------*/
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> ii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<ii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
/*-------------------------------------------------------------------------------------------------------------------------*/

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;

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

    ld dp[n][n + 1];
    for (int i = 0; i <= n; i++)
        dp[0][i] = 0;

    dp[0][0] = (1 - p[0]);
    dp[0][1] = p[0];

    for (int i = 1; i < n; i++)
    {
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
        for (int j = 1; j <= n; j++)
            dp[i][j] = (dp[i - 1][j] * (1 - p[i])) + (dp[i - 1][j - 1] * p[i]);
    }

    ld ans = 0;
    for (int i = n; i > n / 2; i--)
        ans += dp[n - 1][i];


    cout << fixed << setprecision(9) << ans << "\n";
}


Measured memory_bytes: 141056
import java.util.Scanner;


class Main{
 public static void main(String[] args){
  Scanner scanner = new Scanner(System.in);
  int N = scanner.nextInt();
  

 
int i = 0;
for(int a = 1;a <= N; a++){
  if(a % 2 == 1){
    i++;
  }else{
    continue;
  }
}

  System.out.println( (double)i/N );
  
  
}
}


Measured memory_bytes: 21844
N = int(input())
W = list(map(int, input().split()))

S1 = W[0]
S2 = sum(W[1:])
abs_min = abs(S1-S2)

for i in range(1, N-1):
    S1 += W[i]
    S2 -= W[i]
    abs_min = min(abs_min, abs(S1-S2))

print(abs_min)

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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a=0,b=0,counter=0;
    cin>>n;
    vector<int>p(n),q(n),s(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];
    iota(s.begin(), s.end(), 1);                //assignment operator iota
    do
    {
        if(s == p)
            a = counter;
        if(s == q) 
            b = counter;
        counter++;
    }while(next_permutation(s.begin(), s.end()));

    cout<<abs(b-a)<<endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int r=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){r=(r<<1)+(r<<3)+(c^48),c=getchar();}
	return r*f;
}
string a;
int main()
{
	cin>>a;
	int len=a.size();
	int ls=a[0],cnt=0;
	for(int i=1;i<=len-1;i++)
	{
		if(ls!=a[i])
		cnt++,ls=a[i];
	}
	cout<<cnt;
return 0;
}


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


#A = [int(i) for i in input().split()]
#A=[ [int(i) for i in input().split()]
a,b = [int(i) for i in input().split()]
c,d = [int(i) for i in input().split()]
e,f = [int(i) for i in input().split()]

if a>= b:
    a,b=b,a
if c>= d:
    c,d=d,c
if e>= f:
    e,f=f,e
A=[a,b,c,d,e,f]
B=[]
#print(A)
for i in range(1,5):
    c=0
    for j in A:
        if i == j:
            c+=1
    B.append(c)

#print(B)
if set([a,b,c,d,e,f]) == set([1,2,3,4]) and 3 not in B and 4 not in B:
    print("YES")
else:
    print("NO")






Measured memory_bytes: 3064
import sys
import random
d = int(sys.stdin.readline().rstrip())
list_c = list(map(int, sys.stdin.readline().rstrip().split()))
list_s = []
list_t = []
need = 0
for i in range(d):
  list_s.append(list(map(int, sys.stdin.readline().rstrip().split())))
for i in range(d):
  print(random.randint(1,26))

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

int main() {
  int N, M, A, B = 1e9+7;
  cin >> N >> M;

  vector<int> vec(N + 1, -1);
  vec.at(0) = 1;
  vec.at(1) = 1;

  for (int i = 0; i < M; i++) {
    scanf("%d", &A);
    vec.at(A) = 0;
  }

  for (int i = 2; i < N + 1; i++) {
    if (vec.at(i) != 0) vec.at(i) = (vec.at(i - 2) + vec.at(i - 1)) % B;
  }

  cout << vec.at(N) << endl;
}

Measured memory_bytes: 640
//    ######     ######    ######     ######
//    ######    ######     ######    ######
//    ######   ######      ######   ######
//    ######  ######       ######  ######
//    ############         ############
//    ############         ############
//    ######  ######       ######  ######
//    ######   ######      ######   ######
//    ######    ######     ######    ###### 
//    ######     ######    ######     ######
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second
#define mii           map<int,int>
#define msi           map<string,int >
#define mis           map<int,string>
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define f(i,n)            for(int  i=0;i<n;i++)
#define all(v)        v.begin(),v.end()
//#define sort(v)       sort(all(v))
#define sm(v)           accumulate(v.begin(),v.end(),0)
#define pii           pair<int ,int >
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAX           1000000
#define pi            3.1415926536
using namespace std;

signed main()
{
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            #ifndef ONLINE_JUDGE
           // freopen("input.txt","r",stdin);
            //freopen("output.txt","w",stdout);
            #endif
            int t=1;
           // cin>>t;
            while(t--)
            {
                int c=0;
               string s,t;
               cin>>s>>t;
               rep(i,0,3)
               {
                if(s[i]==t[i])
                    c++;
               }
               cout<<c;

}}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


vector<int> fact[maxs];

void pre(){

    for(int i=2;i<maxs;i++){
        if(fact[i].size()==0){
            for(int j=i;j<maxs;j+=i){
                fact[j].push_back(i);
            }
        }
    }


}

void solve(){

    int n;
    cin >> n;
    int a[n+1];
    int g=0;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        g  = __gcd(g,a[i]);
    }
    if(g > 1){
        cout << "not coprime";
    }else{
        map<int,int> cache;
        int flg=0;
        for(int i=1;i<=n;i++){
            int val = a[i];
            for(auto it : fact[val]){
                if(cache.count(it)){
                    flg = 1;
                    break;
                }else{
                    cache[it]++;
                }
            }
            if(flg)break;
        }
        if(flg){
            cout << "setwise coprime";
        }else{
            cout << "pairwise coprime";
        }
    }

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 63016
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        K: i64,
        N: usize,
        As: [i64; N],
    }

    // 1周回る必要はない。
    // 一番遠い An -> An+1 をスキップする動き
    // 時計回りだけ考えればよい
    let mut longest = 0;
    for i in 0..N {
        let l = if i == N - 1 {
            K + As[0] - As[N - 1]
        } else {
            As[i + 1] - As[i]
        };

        longest = std::cmp::max(longest, l);
    }

    let ans = K - longest;
    println!("{}", ans);
}


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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 

#define ll                      long long
#define read1(x)                 cin>>x
#define read2(x,y)               cin>>x>>y
#define print(x)                cout<<x<<endl
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define uset                    unordered_set
#define clr(a,b)                memset(a,b,sizeof a)
#define all(ds)                 ds.begin(), ds.end()
#define rev(ds)                 ds.rbegin(), ds.rend()
#define asc(A)                  sort(A.begin(), A.end())
#define dsc(A)                  sort(A.begin(), A.end(), greater<int>())
#define gcd(x,y)                __gcd(x,y)
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)               for(int i=n-1; i>=0; --i)
#define printVector(v)          for(int i= 0;i<v.size();i++) {cout<<v[i]<<" ";} cout<<endl;
#define precise(x)              cout<<fixed<<setprecision(x)
#define inf                     10000000000000

 

ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }
ll power(ll x, ll y, ll m) { if(!y) return 1; ll p=power(x, y>>1, m)%m; p=p*p%m; return (y&1)?(x*p)%m:p;}
ll modInverse(ll a, ll m){ return power(a, m-2, m); }
bool isPrime(ll num){bool flag=true;for(ll i =2;i<=num/2;i++){if(num%i==0) {flag=false; break;} }return flag;}
ll sumofdigits(ll n){ll c=0;while(n>0){c++;n/=10;}return c;}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) {return a.first > b.first; }
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) {return a.second < b.second; }

//const double PI= 2*acos(0.0);
const long long MOD= 1000000007;



void solve(){
    int x; cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}
int main()
{
#ifndef ONLINE_JUDGE  
    input_output  
#else   
    fastio
#endif

    int t =1 ;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 3596
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [n,x] <- sort .map (read::String->Int) . words <$> getLine
  ms <- map (read::String->Int) . lines <$> getContents
  print $ n + div (x - sum ms) (minimum ms)

Measured memory_bytes: 4268