akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i=0;i<n;i++) cin >> arr.at(i);
    vector<int> copy = arr;
    sort(arr.begin(),arr.end());
    int max1 = arr.at(n-1);
    int max2 = arr.at(n-2);
    for(int i=0;i<n;i++){
        if(copy.at(i) == max1){
            cout << max2 << endl;
        }else{
            cout << max1 << endl;
        }
    }
}

Measured memory_bytes: 4844
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int n, m, q, from, to;
int Rank[100000];
int parent[100000];

int find(int x) 
{
	if (x == parent[x])return x;
	else 
	{
		return parent[x] = find(parent[x]);
	}
}

bool isSame(int x, int y)
{
	return find(x) == find(y);
}

void unite(int x, int y) 
{
	x = find(x);
	y = find(y);

	if (x == y)return;

	if (Rank[x] < Rank[y]) 
	{
		parent[x] = y;
	}
	else
	{
		parent[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

int main()
{

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++)
	{
		Rank[i] = 0;
		parent[i] = i;
	}

	for (int i = 0; i < m; i++)
	{
		scanf("%d %d", &from, &to);

		if (isSame(from, to))continue;
		unite(from, to);
	}

	scanf("%d", &q);

	int left, right;

	for (int i = 0; i < q; i++)
	{
		scanf("%d %d", &left, &right);

		if (isSame(left, right))printf("yes\n");
		else
		{
			printf("no\n");
		}
	}
	return 0;
}


Measured memory_bytes: 3904
#include <stdio.h>

int main(){
	int i,n;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		int x1,x2,x3;
		scanf("%d %d %d", &x1, &x2, &x3);
		if(x1 * x1 + x2 * x2 == x3 * x3){
			printf("YES\n");
			continue;
		}
		if(x1 * x1 + x3 * x3 == x2 * x2){
			printf("YES\n");
			continue;
		}
		if(x2 * x2 + x3 * x3 == x1 * x1){
			printf("YES\n");
			continue;
		}
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int to0=0,toN=0;
    for(int i=0;i<m;i++){
        int num;
        cin >> num;
        if(num<x) to0++;
        else toN++;
    }
    int ans=min(to0,toN);
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
mod = 10**9+7
if n % 2 == 0 and len(set(l)) == n//2 and l.count(0)==0:
  print(2**(n//2)%mod)
elif not n % 2 == 0 and l.count(0) == 1 and len(set(l))-1==n//2:
  print(2**((n-1)//2)%mod)
else:
  print(0)


Measured memory_bytes: 13880
#include<iostream>
using namespace std;
int main()
{
	string S, T;
	cin >> S;
	cin >> T;
	int n = 0;
	int i = 0;
	while (S[n] != '\0') {
		if (S[n] != T[n])
			i++;
		n++;
	}
	cout << i << endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, d;
  cin >> n >> d;
  VVI x(n, VI(d));
  rep(i, n){
    rep(j, d) cin >> x[i][j];
  }
  int ans = 0;
  rep(i, n-1){
    for(int j = i+1; j < n; ++j){
      int dis = 0;
      rep(k, d) dis += pow((x[i][k] - x[j][k]), 2);
      int m = int(sqrt(dis));
      if(dis - m * m < EPS) ans++;
    }
  }

  out(ans);
  return 0;
}


Measured memory_bytes: 256
import Data.Array.IO
import Data.List
import Control.Monad

type Table = IOUArray Int Int

modN :: Int
modN = 10^9+7

main = do
  [h,w,a,b] <- map read . words <$> getLine :: IO [Int]
  let h' = h - 1
      w' = w - 1
      a' = a - 1
      b' = b - 1
      n = h' + w'
  table <- newArray (0, n+1) 0 :: IO Table
  factTable <- newArray (0, n) 0 :: IO Table
  foldM factT factTable [0..n]
  makeTable table n n
  let path = [b..w']
  ans <- foldl1 (\x y -> flip mod modN $ x + y) <$> mapM (solve table factTable a' w' (h-a-1)) path
  print ans

solve :: Table -> Table -> Int -> Int -> Int -> Int -> IO Int
solve table factTable a w l i = do
  cn1 <- readArray factTable $ l+i
  cn2 <- readArray factTable $ a+w-i
  x <- comb table cn1 (l+i) i
  y <- comb table cn2 (a+w-i) a
  return $ flip mod modN $ x * y

factT :: Table -> Int -> IO Table
factT table 0 = do
  writeArray table 0 1
  return table
factT table n = do
  pre <- readArray table $ n-1
  writeArray table n $ flip mod modN $ pre * n
  return table

--x^n (mod modN)
(|^) :: Int -> Int -> Int
(|^) x n
  | n == 0    = 1
  | even n    = (mod (x * x) modN) |^ (n `div` 2)
  | otherwise = (flip mod modN) . (*x) $ x |^ (n - 1)

--x! (mod modN)
fact :: Int -> Int
fact n
  | n == 0    = 1
  | otherwise = (flip mod modN) . (*n) $ fact (n-1)

--nCk cn:n!
comb :: Table -> Int -> Int -> Int -> IO Int
comb memo cn n k
  |n >= k = do
    ik <- readArray memo k
    ink <- readArray memo $ n - k
    let tmp = flip mod modN $ cn * ik
        ans = flip mod modN $ tmp * ink
    return ans
  | otherwise = return 0

makeTable :: Table -> Int -> Int -> IO Table
makeTable table n (-1) = return table
makeTable table n i
  | n == i = do
    writeArray table i $ (fact n) |^ (10^9+5)
    makeTable table i $ i-1
  | otherwise = do
    ie <- readArray table (i+1)
    writeArray table i $ flip mod modN $ ie * (i+1)
    makeTable table i $ i-1


Measured memory_bytes: 42620
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=5e5+5,P=998244353;
int pw(int a,int m){
    int res=1;
    while(m)m&1?res=1ll*res*a%P:0,a=1ll*a*a%P,m>>=1;
    return res;
}
int fac[N],fnv[N];

int n,m;
int binom(int n,int m){
    if(n<m)return 0;
    return fac[n]*1ll*fnv[m]%P*fnv[n-m]%P;
}
int sig(int x){
    return 1-2*(x&1);
}

int main(){
    scanf("%d%d",&n,&m);
    fac[0]=1;
    if(n<m)swap(n,m);
    FOR(i,1,n)fac[i]=1ll*fac[i-1]*i%P;
    fnv[n]=pw(fac[n],P-2);
    ROF(i,n,1)fnv[i-1]=fnv[i]*1ll*i%P;
    int ans=0;
    FOR(i,0,min(n,m)){
        ans=(ans+binom(n,i)*1ll*binom(m,i)%P*fac[i]%P*pw(m+1,n-i)%P*pw(n+1,m-i)%P*sig(i))%P;
    }
    ans=(ans+P)%P;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4096
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  vector<int> t(n); rep(i, n) cin >> t[i];
  int m; cin >> m;
  vector<int> p(m), x(m); rep(i, m) cin >> p[i] >> x[i];

  for (int i = 0; i < m; i++) {
    int sum = 0;
    for (int j = 1; j <= n; j++) {
      if (j == p[i]) sum += x[i];
      else sum += t[j - 1];
    }
    outl(sum);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
n=int(input())
ans=0
l=list(map(int,input().split()))
for i in range(1,n-1):
  p=max(l[i-1],l[i+1])
  q=min(l[i-1],l[i+1])
  if q<=l[i]<=p:ans+=1
print(ans)


Measured memory_bytes: 2940
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc151_a.cpp
 * time   : Sat May  2 18:57:06 2020
 * quest  : A - Next Alphabet
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  char ch;
  cin >> ch;
  cout << char(ch + 1) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{  int a,b;
    cin>>a>>b;
    if(a<b)
        cout<<"a "<<'<'<<" b"<<endl;
    if(a>b)
        cout<<"a "<<'>'<<" b"<<endl;
    if(a==b)
        cout<<"a "<<"=="<<" b"<<endl;


    return 0;
}



Measured memory_bytes: 3100
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
	int N;
	double D;
	cin >> N >> D;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		double X, Y;
		cin >> X >> Y;
		double dist_sq;
		dist_sq = X * X + Y * Y;
		if (dist_sq <= D * D) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+21);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}
const ll inf = (1e18+4);

void max_self(ll &a, ll b){
    a= max(a,b);
}

void min_self(ll &a, ll b){
    a=min(a,b);
}

ll run() {
    int n,w;
    cin>>n>>w;

    vector<int> wt(n),v(n);
    ll tot = 0;

    for(int i=0;i<n;i++){
        cin>>wt[i]>>v[i];
        tot+=v[i];
    }
    vector<ll> dp(tot+1,inf);
    dp[0]=0;
    for(int item=0;item<n;item++){
        for(int value_already=tot-v[item];value_already>=0;value_already--){
            min_self(dp[value_already+v[item]],dp[value_already]+wt[item]);
        }
    }

    ll ans = 0;
    for(int i=0;i<=tot;i++){
        if(dp[i]<=w){
            max_self(ans,i);
        }
    }
    cout<<ans;

}


Measured memory_bytes: 1024
list1 = [0,0]
S=input()

a1 = S[0]
a2 = "NUM"

if S[1] == a1:
    list1[0]=2
else:
    a2 = S[1]

if S[2]==a1:
    list1[0]=2
else:
    if S[1]==a1:
        a2 =S[2]
    else:
        if S[2]==a2:
            list1[1]=2
        else:
            pass

if S[3]==a1:
    list1[0]=2
else:
    if S[2]==a1 and S[1] == a1:
        a2 = S[3]
    else:
        if S[3]==a2:
            list1[1]=2
        else:
            pass
        
if list1[1]==2 and list1[0]==2:
    print("Yes")
else:
    print("No")

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

int main() {
  int n,k;
  cin >> n >> k;
  int x[n];
  rep(i,0,n){
    cin >> x[i];
  }
  int ans = 0;
  rep(i,0,n){
    ans += 2*(min(x[i],k-x[i]));
  }
  pout(ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {


    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    string ans;

    for(int i = 0; i < n; ++i){
    cin >> s.at(i);
    }

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

    for(int i = 0; i < n; ++i){
        ans += s.at(i);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,y,dis[2009],num[2009];
bool inq[2009];
vector<int>g[2009];
queue<int>q;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>x>>y;
	x--,y--;
	for(int i=0;i<n-1;i++) {
		g[i].push_back(i+1);
		g[i+1].push_back(i);
	}
	g[x].push_back(y);
	g[y].push_back(x);
	for(int i=0;i<n;i++) {
		memset(dis,0x3f,sizeof(dis));
		dis[i]=0;
		q.push(i);
		inq[i]=1;
		while(q.size()) {
			int head=q.front();
			q.pop();
			inq[head]=0;
			for(int j=0;j<g[head].size();j++)
				if(dis[head]+1<dis[g[head][j]]) {
					dis[g[head][j]]=dis[head]+1;
					if(!inq[g[head][j]]) {
						q.push(g[head][j]);
						inq[g[head][j]]=1;
					}
				}
		}
		for(int j=0;j<n;j++) num[dis[j]]++;
	}
	for(int i=1;i<n;i++) cout<<num[i]/2<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    pii hoge=pii(INF,INF);
    rep(i,s.size()){
        if(hoge.first==INF&&s[i]=='A')hoge.first=i;
        if(hoge.second==INF&&s[s.size()-1-i]=='Z')hoge.second=(int)s.size()-1-i;
    }
    cout<<hoge.second-hoge.first+1<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <unordered_set>
#include <tuple>
#include <queue>
#include <set>
#include <cstring>
#include <functional>
#include <random>
#include <chrono>

#define ar array
#define all(arr) (arr).begin(), (arr).end()
#define range(i, n) for (int i=0; i < n; ++i)
#define rall(arr) (arr).rbegin(), (arr).rend()

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const int INFi = 2e9;
const int maxN = 1e6 + 5;
const int md = 998244353;
const int md2 = 1e9 + 7;

double getTime() { return clock() / (double) CLOCKS_PER_SEC; };

int add(int a, int b) {
    if (a + b >= md) return a + b - md;
    return a + b;
}

int sub(int a, int b) {
    if ( a - b < 0) return a - b + md;
    return a - b;
}

void solve() {
    int n, k; cin >> n >> k;
    vector<pair<int, int>> lr(k);
    range(i, k) cin >> lr[i].first >> lr[i].second;
    vector<int> dp(n), pref(n);
    auto get = [&] (int l, int r) {
        if (l == 0) return pref[r];
        return sub(pref[r], pref[l-1] );
    };
    dp[0] = pref[0] = 1;
    for(int i = 1; i < n; ++i) {
        for(auto [l, r]: lr) {
            int lq = i - r;
            int rq = i - l;
            lq = max(lq, 0);
            if (lq > rq) continue;
            dp[i] = add(dp[i], get(lq, rq));
        }
        pref[i] = add(pref[i-1], dp[i]);
    }
    cout << dp[n-1];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout << setprecision(15) << fixed;
    int tests = 1;
    //cin >> tests;
    range(_, tests) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll func(ll b,ll n){
    if(b==1)return -1;
    if(!n)return 0;
    return func(b,n/b) + n%b;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,s;cin>>n>>s;
    ll ans = (1ll<<60);
    for(ll i=2;i*i<=n;i++)if(func(i,n)==s)ans=min(ans,i);
    if(n==s)ans=min(ans,n+1);

    ll d = n-s;
    for(ll i=1;i*i<=d;i++){
        if(d%i)continue;

        if(func(i+1,n)==s)ans=min(ans,i+1);
        if(func(d/i+1,n)==s)ans=min(ans,d/i+1);
    }

    if(ans==(1ll<<60))ans=-1;
    cout<<ans;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int ac = 0;
  int wa = 0;
  map<int, int> pp;
  for (int i=1; i<=n; i++) pp.insert(make_pair(i, 0));
  int p; string s;
  for (int i=0; i<m; i++) {
    cin >> p >> s;
    if (pp.at(p) != -1) {
      if (s == "AC") {
        ac++;
        wa += pp.at(p);
        pp.at(p) = -1;
      }
      else pp.at(p)++;
    }
  }
  cout << ac << " " << wa << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

int main(void)
{
	int i, j;
	int cnt=0, maxcnt;
	int N, M;
	scanf("%d %d", &N,&M);
  	if (N>1){
		for(i=1;i<N;i++){
      cnt+=i;
        }
    }
  	if (M>1){
		for(i=1;i<M;i++){
      cnt+=i;
        }
    }
	printf("%d\n",cnt);

}


Measured memory_bytes: 128
import collections
N=int(input())
S=[]
ans=-1
for i in range(N):
    s=input()
    if s[0] in 'MARCH':
        S.append(s[0])
L=list(collections.Counter(S).values())
if len(L)<3:
    ans=0
else:
    R=[L[i]*L[j]*L[k] for i in range(len(L)-2) for j in range(i+1,len(L)-1) for k in range(j+1,len(L))]
    ans=sum(R)
print(ans)

Measured memory_bytes: 4224
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353



X = list(map(int, sys.stdin.buffer.readline().split()))
print(X.index(0)+1)



Measured memory_bytes: 27248
local n,m,k=io.read("n","n","n")
local a={[0]=0}
for i=1,n do
    a[i]=a[i-1]+io.read("n")
end
local b={[0]=0}
for i=1,m do
    b[i]=b[i-1]+io.read("n")
end

local max=0
local j=m
for i=0,n do
    if a[i]>k then
        break
    end
    while b[j]>k-a[i] do
        j=j-1
    end
    max=math.max(max,i+j)
end
print(max)

Measured memory_bytes: 6668
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()
    val s = (1..n).map { readLine()!! }

    val vote = s.groupBy { it }.mapValues { it.value.size }
    val max = vote.map { it.value }.max()!!
    vote.filter { it.value == max }.map { it.key }.sorted().joinToString("\n")
})

Measured memory_bytes: 136260
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  rep(i, N) { cin >> p[i]; }

  sort(p.begin(), p.end());
  p.push_back(102);
  if (*lower_bound(p.begin(), p.end(), X) != X) {
    cout << X << endl;
  } else {
    int cand = 0;
    int j = lower_bound(p.begin(), p.end(), X) - p.begin();
    for (int i = 0; i <= j; i++) {
      if (*lower_bound(p.begin(), p.end(), p[i] - 1) != p[i] - 1) {
        cand = p[i] - 1;
      }
    }
    for (int i = j; i < N; i++) {
      if (*lower_bound(p.begin(), p.end(), p[i] + 1) != p[i] + 1) {
        if (abs(cand - X) > abs(p[i] + 1 - X)) {
          cand = p[i] + 1;
        }
      }
    }
    cout << cand << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
package main

import "fmt"

func count(n int, factor *[]int) int {
	ans := 0
	for _, f := range *factor {
		if f >= n {
			ans++
		}
	}
	return ans
}

func main() {
	var N int
	fmt.Scan(&N)

	prime := [...]int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}
	factor := make([]int, len(prime))

	for i := 1; i <= N; i++ {
		tmp := i
		p := 0
		for tmp > 1 {
			if tmp%prime[p] == 0 {
				tmp /= prime[p]
				factor[p]++
			} else {
				p++
			}
		}
	}

	ans := 0
	ans += count(74, &factor)
	ans += count(14, &factor) * (count(4, &factor) - 1)
	ans += count(24, &factor) * (count(2, &factor) - 1)
	ans += (count(4, &factor) * (count(4, &factor) - 1) * (count(2, &factor) - 2)) / 2
	fmt.Println(ans)
}


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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

template<class T>
class SegmentTree{
	vector<T> tree;
	size_t n;
	function<T(T,T)> merge;

	public:
	SegmentTree(size_t n_, T init,function<T(T,T)> fn){
		if(n_ == 0)throw std::invalid_argument("n > 0");
		n = 1 << (32 - __builtin_clz(n_-1));
		merge = fn;
		size_t treesize = 2*n;
		tree = vector<T>(treesize,init);
	}
	~SegmentTree(){}

	void update(size_t idx, T x){
		idx += n;
		tree[idx] = x;
		while(idx /= 2){
			tree[idx] = merge(tree[idx*2 +0], tree[idx*2 +1]);
		}
	}

	T query(size_t a, size_t b){
		T ret = tree[0];
		a += n; b += n;
		for(; a < b; a /= 2, b /= 2){
			if(a&1)ret = merge(ret, tree[a++]);
			if(b&1)ret = merge(ret, tree[--b]);
		}
		return ret;
	}
};

signed main(){
	int n,q; cin >> n >> q;
	SegmentTree<int> t(n, INT_MAX, [](int a, int b){return min(a,b);});
	for(int i = 0; i < q; i++){
		int com, x, y;cin >> com >> x >> y;
		if(com){
			cout << t.query(x,y+1) << endl;
		}
		else{
			t.update(x,y);
		}
	}

	return 0;
}




Measured memory_bytes: 3888
#include<stdio.h>
int main(void){
	int before,after;
	int i;
	int flag = 0;
	int flagflag = 0;
	while(scanf("%d %d",&before,&after)){
		if(before == 0 && after == 0){
			break;
		}
		if(flagflag == 1){
			printf("\n");
		}
		for(i = before;i <= after;i++){
			if(i % 4 == 0){
				if(i % 100 != 0){
					flag = 1;
					printf("%d\n",i);
					flagflag = 1;
				}
			}
			if(i % 4 == 0){
				if(i % 400 == 0){
					flag = 1;
					printf("%d\n",i);
					flagflag = 1;
				}
			}
		}
		if(flag == 0){
			printf("NA\n");
			flagflag = 1;
		}
		flag = 0;
	}
	return 0;
}

Measured memory_bytes: 616
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var xx    = ToIntArray(input.ReadLine(), n);

        long min = long.MaxValue;

        for(int i=1; i<=100; i++) {
            var c = 0;
            for (int k=0; k<n; k++) {
                c += (i - xx[k])*(i - xx[k]);
            }
            min = Math.Min(c, min);
        }
        return min;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	int h, n;
	cin >> h >> n;
	int a[n];
	int s=0;
	for(int i=0; i<n; ++i) {
		cin >> a[i];
		s+=a[i];
	}
	cout << (s>=h?"Yes":"No");
}


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

using namespace std;

#define LL long long 
#define N 300000
#define INF 0x3f3f3f3f3f3f3f3fLL

LL n,m,x,y,a[N],b[N],c[N],d[N],f[N],fa[N],sum[N],tot,head[N];
bool vis[N];
struct edge{LL v,nxt;}e[N];
vector<LL> vec[N];

void add(LL x,LL y){e[++tot].v=y; e[tot].nxt=head[x]; head[x]=tot;}

bool cmp(LL x,LL y){return c[x]<c[y];}

LL gfa(LL x){return !fa[x]?x:fa[x]=gfa(fa[x]);}

void dp(LL u){
	sum[u]=b[u]; f[u]=INF;
	for (LL i=0,v;i<(LL)vec[u].size();++i){dp(v=vec[u][i]); sum[u]+=sum[v];}
	if (!vec[u].size()){f[u]=b[u]+c[u]; return;}
	for (LL i=0,v;i<(LL)vec[u].size();++i){
		v=vec[u][i];
		f[u]=min(f[u],sum[u]-sum[v]+max(c[u],f[v]));
	}
}

int main(){
	scanf("%lld%lld",&n,&m);
	for (LL i=1;i<=n;++i){
		scanf("%lld%lld",&a[i],&b[i]);
		a[i]=max(a[i],b[i]);
		c[i]=a[i]-b[i];
		d[i]=i;
	}
	for (LL i=1;i<=m;++i){
		scanf("%lld%lld",&x,&y);
		add(x,y); add(y,x);
	}
	sort(d+1,d+n+1,cmp);
	for (LL i=1;i<=n;++i){
		LL x=d[i];
		for (LL j=head[x];j;j=e[j].nxt)
			if (vis[e[j].v]){
				LL y=gfa(e[j].v);
				if (x!=y){fa[y]=x; vec[x].push_back(y);}
			}
		vis[x]=1;
	}
	dp(d[n]);
	printf("%lld\n",f[d[n]]);
	
	return 0;
}
			

Measured memory_bytes: 37760
using System;
using Microsoft.VisualBasic;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string S = sc.Next();
        int ans = -1;
        for (int len = 2; len < S.Length; len += 2)
        {
            if (C(S.Substring(0, len)))
                ans = Math.Max(len, ans);
        }
        Console.WriteLine(ans);
    }

    private bool C(string s)
    {
        for (int i = 0; i < s.Length / 2; i++)
        {
            if (s[i] != s[s.Length / 2 + i])
                return false;
        }

        return true;
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
    LL N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 1000005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char text[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &k);
    scanf("%s", text);
    string s = text;
    if (s.size() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) + "..." << endl;
    }
    return 0;
}

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

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back


int main(void){
  int n;
  int ans = 0;
  int ans1 = 0;
  cin >> n;
  rep(i,n){
    ans += (i+1);
    if(ans >= n)break;
  }

  rep(i,n){
    if(ans-n==(i+1))continue;
    ans1+=(i+1);
    cout << i+1 << endl;
    if(ans1 == n)break;
  }



  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long n;
int main()
{
    cin >> n;
    if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9)
        cout << "hon";
    else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8)
        cout << "pon";
    else cout << "bon";
    return 0;
}


Measured memory_bytes: 3632
# 全探索を試みるもWAを解決できず
# ゼロの扱いに対する思考が足りなかった

N = int(input())
C = []

for i in range(N):
  x, y, z = map(int, input().split())
  C.append((x, y, z))

for X in range(101):
  for Y in range(101):

    for i in range(N):
      x, y, h = map(int, C[i])
      if h > 0:
        htop = abs(x-X) + abs(y-Y) + h
    
    for i in range(N):
      x, y, h = map(int, C[i])
      if h == 0:
        if htop - (abs(x-X) + abs(y-Y)) > 0:
          break
      if h > 0:
        if htop - (abs(x-X) + abs(y-Y)) != h:
          break
    else:
      print(X, Y, htop)
      exit()

Measured memory_bytes: 3444
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;
int main()
{
    int i,j,k;
    cin>>i>>j;
    if (i<=j){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {
	rapid_pleaseAC_fast;

	int a;
	cin >> a;
	int x = a / 100;
	int y = a % 100;

	if (0 < x && x < 13) {
		if (0 < y && y < 13) {
			cout << "AMBIGUOUS" << rt;
		}
		else {
			cout << "MMYY" << rt;
		}
	}
	else {
		if (0 < y && y < 13) {
			cout << "YYMM" << rt;
		}
		else {
			cout << "NA" << rt;
		}
	}

	please AC;
}
//参考：---

Measured memory_bytes: 256
use std::cmp::max;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
    n: usize,
    a: [[usize; n]; 2]
    }
    let mut s = vec![vec![0; n + 1]; 2];
    for i in 0..2 {
        for j in 0..n {
            s[i][j + 1] = a[i][j] + s[i][j];
        }
    }
    let mut ans = 0;
    for i in 0..n {
        let m = s[0][i + 1] + s[1][n] - s[1][i];
        ans = max(ans, m);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int N; cin >> N;
	for(int i = N; i >= 1; i--){
		for(int j = 1; j*j <= i; j++){
			if(j*j == i){
				cout << i << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

s= S()
t = S()

n = t[:-1]

if s == n:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
class SegmentTree {
private:
	int siz;
	vector<int> dat;
	
public:
	SegmentTree(vector<int> v) {
		siz = 1;
		while(siz < (int) v.size()) siz <<= 1;
		dat.resize(2 * siz - 1, INT_MAX);
		for(int idx = 0; idx < (int) v.size(); idx++) {
			dat[idx + siz - 1] = v[idx];
		}
		for(int idx = siz - 2; idx >= 0; idx--) {
			dat[idx] = min(dat[2 * idx + 1], dat[2 * idx + 2]);
		}
	}
	
	void update(int idx, int val) {
		idx += (siz - 1);
		dat[idx] = val;
		while(idx > 0) {
			idx = (idx - 1) / 2;
			dat[idx] = min(dat[2 * idx + 1], dat[2 * idx + 2]);
		}
	}
	//[a, b)
	int get(int a, int b, int idx = 0, int l = 0, int r = -1) {
		if(r < 0) r = siz;
		if(r <= a || b <= l) return INT_MAX;
		if(a <= l && r <= b) return dat[idx];
		int val1 = get(a, b, 2 * idx + 1, l, (l + r) / 2);
		int val2 = get(a, b, 2 * idx + 2, (l + r) / 2, r);
		return min(val1, val2);
	}
};
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n, x;
	cin >> n >> x;
	vector<int> a(n + n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		a[i + n] = a[i];
	}
	SegmentTree seg(a);
	long long ans = 1LL << 60;
	for (int i = 0; i < n; i++) {
		long long cur = 1LL * i * x;
		for (int j = 0; j < n; j++) {
			cur += seg.get(j, j + i + 1);
		}
		ans = min(ans, cur);
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 384
/*Saidur Rahman Sajol:The Freak*/
  /*Dept. of CSE,IUBAT(162)*/
/*---------------------------*/

#include <bits/stdc++.h>
using namespace std;

#define PI 2*acos(0.0)
#define l long long
#define ll long long 
#define ul unsigned long
#define ull unsigned long long

ull minimum(ull a,ull b){
  return (a<b)?a:b;
}
ull maximum(ull a,ull b){
  return (a>b)?a:b;
}
ull great(ull a,ull b){
	if(b==0) return a;
  return great(b,a%b);
}

int main(){
	int s[3];
	set<int>pb;
	for(int i=0;i<3;i++){
		scanf("%d",&s[i]);
		pb.insert(s[i]);
	}
	int sa[3];
	int j=0;
	for(set<int>::iterator it=pb.begin();it!=pb.end();it++){
		sa[j++]=*it;
	}
	int c=0,c1=0;
	for(int i=0;i<3;i++){
		if(sa[0]==s[i]) c++;
		if(sa[1]==s[i]) c1++;
	}
	if(c==2 && c1==1) cout<<sa[1]<<endl;
	else cout<<sa[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np

N, M = map(int, input().split())

ac = np.zeros(N, dtype = np.int64)
wa = np.zeros(N, dtype = np.int64)

for i in range(M):
    P, S = input().split()
    P = int(P) -1
    if S == "AC":
        ac[P] = 1
    if S == "WA":
        if ac[P] == 1:
            pass
        else:
            wa[P] += 1

for i in range(N):
    if ac[i] == 0:
        wa[i] = 0

print(int(np.sum(ac)), int(np.sum(wa)))

Measured memory_bytes: 15948
#include <iostream>
#include <string>
using namespace std;
string s;
int main(){
	cin >> s;
	if(s[0]=='S' && s[1]=='U') cout << 7 << endl;
	if(s[0]=='M') cout << 6 << endl;
	if(s[0]=='T' && s[1]=='U') cout << 5 << endl;
	if(s[0]=='W' && s[1]=='E') cout << 4 << endl;
	if(s[0]=='T' && s[1]=='H') cout << 3 << endl;
	if(s[0]=='F' && s[1]=='R') cout << 2 << endl;
	if(s[0]=='S' && s[1]=='A') cout << 1 << endl;
}
	

Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int fastpow(int base, int pow, int ans = 1) {
    while (pow) {
        if (pow & 1) ans = ans * base;
        base = base * base, pow >>= 1;
    }
    return ans;
}

int32_t main() {
    fastIO();
    
    int n, k;
    cin >> n >> k;
    cout << k * fastpow(k-1, n-1) << "\n";
    
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define inf (int)(1e9)
#define MAXX 1.1529215e+18
#define INF 999999
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*--------------------------------------------*/
const int MAX_N=100001;
bool compare_by_b_greater(const P &a, const P &b) {
    if(a.second!=b.second){
        return a.second>b.second;
    }else{
        return a.first<b.first;
    }
}
int main(){
    int n;cin>>n;
    vector<P> odd(MAX_N);
    vector<P> even(MAX_N);//firstに値を,secondに頻度を格納
    V v(n+1);
    rep(i,n){
        cin>>v[i];
        if(i%2==0){
            even[v[i]].second++;
            even[v[i]].first=v[i];
        }
        else{
            odd[v[i]].second++;
            odd[v[i]].first=v[i];
        }
    }
    sort(ALL(odd),compare_by_b_greater);//pairのsecondについて逆順にsort
    sort(ALL(even),compare_by_b_greater);
    int a=odd[0].second;//最頻値が第一候補
    int b=even[0].second;
    int aa=odd[1].second;//第二候補
    int bb=even[1].second;//第二候補
    int av=odd[0].first;
    int bv=even[0].first;
    //printf("n=%d\n",n);
    //printf("a,b,aa,bb=%d,%d,%d,%d\n",a,b,aa,bb);
    //printf("av,bv=%d,%d\n",av,bv);
    int ans;
    if(av==bv){//偶奇の値が同じなら第二候補に
        ans=a+bb<b+aa?n-(b+aa):n-(a+bb);
    }else{
        ans=n-(a+b);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2176