akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
  int n, i, r=0, b=0;
  scanf("%d", &n);
  char s[n+1];
  scanf("%s", s);
  for(i=0;i<n;i++){
    if(s[i]=='R'){
      r+=1;
    }else{
      b+=1;
    }
  }
  if(r>b){
    printf("Yes");
  }else{
    printf("No");
  }

  return 0;
}


Measured memory_bytes: 128
import itertools
n, m, q = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(q)]

ans = 0
for i in itertools.combinations_with_replacement(range(1, m + 1), n):
    sub = 0
    for j in range(q):
        if i[ab[j][1] - 1] - i[ab[j][0] - 1] == ab[j][2]:
            sub += ab[j][3]
    
    ans = max(sub, ans)

print(ans)

Measured memory_bytes: 8976
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef int ftype;
typedef complex<ftype> point;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define YES {cout << "Yes\n"; return 0;}

const int MAXN = 1e5+3;
const int MOD = 1e9+7;

int N,K;
char S[MAXN];
int ans;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    int c = 1;
    fore(i,1,N-1) 
        if (S[i] != S[i-1]) c++;

    c = max(1,c-2*K);
    cout << N-c << endl;
    return 0;
}


Measured memory_bytes: 384
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 0, mod = (int) 0;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int x = (int) s.size();
    int y = (int) (s[0] == s[(int) s.size() - 1]);
    if ((x + y) % 2 == 0) {
        cout << "Second\n";
    } else {
        cout << "First\n";
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;


#define _ cin.tie(0);ios::sync_with_stdio(false);

llong n,a;
llong dp[55][55][2505];

int main(){ _;
  cin>>n>>a;
  V x;
  dp[0][0][0]=1;
  REP(i,n){
    llong in;
    cin>>in;
    x.push_back(in);
  }

  REP(j,n){
    REP(k,n+1){
      REP(s,n*a+1){
	dp[j+1][k][s]+=dp[j][k][s];
	if (x[j]+s<n*a+1){
	  dp[j+1][k+1][s+x[j]]+=dp[j][k][s];
	}
      }
    }
  }

  llong ans=0;
  FOR(k,1,n+1)
    ans+=dp[n][k][k*a];

  
  cout<<ans<<endl;
  
    
    

  return 0;
}


Measured memory_bytes: 54528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,k; cin>>n>>k;
  	int ans = 1;
  	for (int i=0;i<n;i++){
    	 if(ans+k>ans*2){
         	ans *=2;
         }else{
         	ans +=k;
         }
    }
  	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
struct Node{
  int key;
  Node *right,*left,*parent; 
};

Node *root,*NIL;

Node * treeMinimum(Node *x){
  while(x->left!=NIL) x=x->left;
  return x;
}

Node * find(Node *u,int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x){
  if(x->right!=NIL) return treeMinimum(x->right);
  Node *y=x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y;
  Node *x;

  if(z->left==NIL||z->right==NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL){
    x=y->left;
  }else{
    x=y->right;
  }

  if(x!=NIL){
    x->parent=y->parent;
  }

  if(y->parent==NIL){
    root=x;
  }else{
    if(y==y->parent->left){
      y->parent->left=x;
    }else{
      y->parent->right=x;
    }
  }

  if(y!=z){
    z->key=y->key;
  }

  free(y);
}

void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;
 
  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
 
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key<y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}
 
void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
 
void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    cin>>com;
    if(com[0]=='f'){
      scanf("%d",&x);
      Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(com=="insert"){
      scanf("%d",&x);
      insert(x);
    }else if(com=="print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(com=="delete"){
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }
  return 0;
}
 

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

using namespace std;

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    bool flag=false;
    for(auto x:s){
        if(x=='7')flag=true;
    }
    if(flag)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final double N = s.nextLong();
			long min = Long.MAX_VALUE;
			for (int i = 0; i < 5; i++) {
				min = Math.min(min, s.nextLong());
			}

			long ret = (long) Math.ceil(N / min) - 1 + 5;
			System.out.println(ret);
		}
	}
}


Measured memory_bytes: 23124
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	int n; ll x;
	cin >> n >> x;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());

	int result = 0;
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (sum <= x)
			result = max(result, i + 1);
	}
	if (result == n && sum != x)
		result--;
	cout << result << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

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

MOD = 998244353

p = defaultdict(int)
for d in D:
    p[d] += 1

if p[0] == 1 and D[0] == 0:
    ans = 1
    for i in range(max(D)):
        ans *= pow(p[i], p[i + 1], MOD)
        ans %= MOD
        if ans == 0:
            break

    print(ans)

else:
    print(0)


Measured memory_bytes: 24376
#include <iostream>

using namespace std;

int gcd(int x, int y) {
    if (x < y) {
        swap(x, y);
    }
    while (y > 0) {
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main() {
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}



Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>


using namespace std;

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



signed main() {

	ll n;
	string s, t;
	cin >> n;
	cin >> s >> t;
	
	rep(i, n) {
		cout << s[i] << t[i];
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define inf (ll)1e15
#define mod 1000000007
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string str_inp(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string line_inp(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;


const int S=10010000;
int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
    int n;
    while(~sf("%d",&n))
    {
        ll ans=0;
        for(ll i=1;i<=n;i++)
        {
            ll x=n/i;
            x=(x*(x+1))/2;
            ans+=(i*x);
        }
        pf("%lld\n",ans);
    }
    return 0;
}
 






































Measured memory_bytes: 3724
def solve():
    n, a, b = map(int, input().split())
    s = 0
    for i in range(1, n+1):
        x = i
        m = 0
        while x:
            m += x % 10
            x //= 10
        if a <= m <= b:
            s += i
    print(s)
    
solve()

Measured memory_bytes: 2940
/*input 
10 10
2 5 6 5 2 1 7 9 7 2
5 5
2 4
6 7
2 2
7 8
7 9
1 8
6 9
8 10
6 8
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=5e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e16;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
pair<pii,int> query[maxn];
int lst[maxn];
int bit[maxn];
int ans[maxn],arr[maxn];
int n;
void upd(int x,int y){
    while(x<=n){
        bit[x]+=y;
        x+=lowb(x);
    }
}
int get(int x){
    int sum=0;
    while(x>0){
        sum+=bit[x];
        x-=lowb(x);
    }
    return sum;
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int q;
    cin>>n>>q;
    REP(i,n) cin>>arr[i];
    REP(i,q){
        cin>>query[i].f.s>>query[i].f.f;
        --query[i].f.s;
        --query[i].f.f;
        query[i].s=i;
    }
    sort(query,query+q);
    REP(i,q) swap(query[i].f.f,query[i].f.s);
    REP1(i,n) lst[i]=-1;
    int cur=0;
    REP(i,n){
        if(lst[arr[i]]!=-1){
            upd(lst[arr[i]]+1,-1);
        }
        lst[arr[i]]=i;
        upd(i+1,1);
        while(cur<q and query[cur].f.s==i){
            ans[query[cur].s]=get(query[cur].f.s+1)-get(query[cur].f.f);
            ++cur;
        }
    }  
    REP(i,q) cout<<ans[i]<<'\n';
}


Measured memory_bytes: 17404
#![allow(unused)]

use std::io::{Read, Stdin, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

macro_rules! debug {
    ($($a:expr),*) => {
	eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

struct TokenReader<'a> {
    lock: StdinLock<'a>,
}

impl<'a> TokenReader<'a> {
    fn new(s: &'a Stdin) -> TokenReader<'a> {
        TokenReader { lock: s.lock() }
    }

    fn read_chars<T: FromIterator<char>>(&mut self) -> T {
        self.lock
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<T>()
    }

    fn read_str(&mut self) -> String {
        self.read_chars::<String>()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read_str().parse().ok().unwrap()
    }
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

fn main() {
    let sin = std::io::stdin();
    let mut tr = TokenReader::new(&sin);

    let s: i64 = tr.read();
    let w: i64 = tr.read();

    println!("{}", if s <= w { "unsafe" } else { "safe" });
}


Measured memory_bytes: 2164
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

static const double pi = 3.141592653589793;
int main()
{
	double a, b, c;
	cin >> a >> b >> c;

	double ret3 = b * sin(c * pi / 180);
	double ret1 = a * ret3 / 2;
	double ret2 = sqrt(pow(ret3, 2) + pow(a - b * cos(c * pi / 180), 2));
	cout << setprecision(10) << ret1 << " " << ret2 + a + b << " " << ret3 << endl;
	return 0;
}



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

int main()
{
    int numn , numk;
    string str;
    cin >> numn >> str >> numk;
    string s = str.substr(numk-1,1);
    string ans;
    for(int i = 0; i< numn; i++){
        if(str.substr(i,1)!=s){
            ans += "*";
        }else{
            ans += str.substr(i,1);
        }
    }

    cout << ans << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    
    string S;
    bool ans=true;
    cin >> S;
    for(int i=0;i<S.size();i++){
        if(i%2==0)
            if(S[i]=='R'|S[i]=='U'|S[i]=='D')
                continue;
            else 
                ans &= false;
        else
            if(S[i]=='L'|S[i]=='U'|S[i]=='D')
                continue;
            else 
                ans &= false;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll n, m;
vector<ll> a;
bool check(ll mid){
    ll res = 0;
    //cout << "MID" << mid << endl;
    for(int i = 0; i < n; i++){
        ll idx = upper_bound(all(a), mid - a[i]) - a.begin();
        //cout << idx << endl;
        res += n - idx ;
    }
    return res < m;
}
int main(void){
    
    cin >> n >> m;
    a.resize(n);
    
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(all(a));

    ll ok = INF;
    ll ng = 0;

    while(abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        } else {
            ng = mid;
        }
    }

    //cout << ok << endl;

    //reverse(all(a));

    ll cnt = 0;
    ll ans = 0;
    vector<ll> sum(n + 1, 0);
    for(int i = 0; i < n; i++){
        sum[i + 1] = sum[i] + a[i];
    }
    //reverse(all(a));
    for(int i = 0; i < n; i++){
        ll idx = upper_bound(all(a), ok - a[i]) - a.begin();
        cnt += n - idx;
        ans += a[i] * (n - idx) + sum[n] - sum[idx];
        // for(int j = 0; a[i] + a[j] > ok && j < n; j++){
        //     ans += a[i] + a[j];
        //     cnt++;
        //     if(cnt >= m) break;
        // }
    }

    while(cnt++ < m) ans += ok;

    cout << ans << endl; 
}   

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), a = in.nextInt();
			out.println(n*n-a);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

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

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

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

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define MAX 300000
using namespace std;

vector<int> v[MAX];
bool mark[MAX];
int par[MAX];
queue<int> q;

int main()
{
    memset(par, -1, sizeof par);
    int n, m;
    cin >> n >> m;
    for( int i = 0; i < m; i++ ){
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    q.push(0);
    mark[0] = true;
    while(!q.empty()){
        int fr = q.front();
        q.pop();
        for( int u : v[fr]){
            if(!mark[u]){
                par[u] = fr + 1;
                q.push(u);
                mark[u] = true;
            }
        }
    }
    bool can = true;
    for( int i = 1; i < n; i++ )
        if(par[i] == -1)
            can = false;
    if(!can)
        cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        for( int i = 1; i < n; i++ )
            cout << par[i] << endl;
    }
    return 0;
}

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

int main(void){
	int h, w, k, i, j, num = 1, cur = -1, fr = 500;
    cin >> h >> w >> k;
    
    vector<vector<int>> ans(h, vector<int>(w, -1));
    vector<int> cp(h, -2);
    for (i = 0; i < h; i++){
    	string s; bool ok = false, first = true;
        cin >> s;
        for (j = 0; j < w; j++) if (s[j] == '#') {ok = true; break;}
        if (!ok) {cp[i] = cur; continue;}

        cur = i; fr = min(fr, i);
        for (j = 0; j < w; j++){
        	if (s[j] == '#'){
            	if (first) ans[i][j] = num, first = false;
                else ans[i][j] = ++num;
            }else{
            	ans[i][j] = num;
            }
        }
      	++num;
    }
    
    for (i = 0; i < h; i++){
      	int idx = cp[i] == -2 ? i : (cp[i] == -1 ? fr :  cp[i]);
		for (j = 0; j < w; j++) printf("%d ", ans[idx][j]);
      	printf("\n");
    }
    
	return 0;
}

Measured memory_bytes: 4064
#include <iostream>
#include <algorithm>

using namespace std;

int h[5];

bool four_card() {
    if ( (h[0] == h[1] && h[1] == h[2] && h[2] == h[3]) ||
         (h[1] == h[2] && h[2] == h[3] && h[3] == h[4]) )
        return true;
    else 
        return false;
}

bool full_house() {
    if ( ((h[0] == h[1] && h[1] == h[2]) && (h[3] == h[4])) || ((h[0] == h[1]) && (h[2] == h[3] && h[3] == h[4])) ) 
        return true;
     else
        return false;
}

bool three_card() {
    if ( (h[0] == h[1] && h[1] == h[2]) ||
         (h[1] == h[2] && h[2] == h[3]) ||
         (h[2] == h[3] && h[3] == h[4]) ) 
        return true;
    else 
        return false;
}

bool straight() {
    if ( (h[0] + 1 == h[1]) &&
         (h[1] + 1 == h[2]) &&
         (h[2] + 1 == h[3]) &&
         (h[3] + 1 == h[4]) )
        return true;
    else {
        if (h[0] == 1 && h[1] == 10 
                      && h[2] == 11
                      && h[3] == 12
                      && h[4] == 13)
            return true;
        return false;
    }
}

bool two_pair() {
    if ( (h[0] == h[1] && h[2] == h[3]) ||
         (h[0] == h[1] && h[3] == h[4]) ||
         (h[1] == h[2] && h[3] == h[4]) )
        return true;
    else 
        return false;
}
        
bool one_pair() {
    if (h[0] == h[1] || h[1] == h[2] || h[2] == h[3] || h[3] == h[4]) 
        return true;
    else 
        return false;
}

void find_hand() {
    sort(h, h+5);
    if (four_card()) {
        cout << "four card" << endl;
    } else if (full_house()) {
        cout << "full house" << endl;
    } else if (straight()) {
        cout << "straight" << endl;
    } else if (three_card()) {
        cout << "three card" << endl;
    } else if (two_pair()) {
        cout << "two pair" << endl;
    } else if (one_pair()) {
        cout << "one pair" << endl;
    } else {
        cout << "null" << endl;
    }
}

int main() {
    char dm;
    while (cin >> h[0] >> dm 
               >> h[1] >> dm
               >> h[2] >> dm
               >> h[3] >> dm
               >> h[4] ) {
        find_hand();
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, char> C;
int N;
C co[36];

C cb[36];
vector<char> so[10];

void check_and_print() {
    cout << cb[0].second << cb[0].first;
    for (int i = 1; i < N; i++) {
        cout << " " << cb[i].second << cb[i].first;
    }
    cout << endl;

    bool stable = true;
    for (int i = 1; i <= 9; i++) {
        if (so[i].size() == 0) { continue; }
        int j;
        for (j = 0; ; j++) {
            if (cb[j].first == i) { break; }
        }
        for (int k = 0; k < (int)so[i].size(); k++) {
            if (cb[j + k].second != so[i][k]) { stable = false; }
        }
    }

    cout << (stable ? "Stable" : "Not stable") << endl;
}

void solve() {
    for (int i = 0; i < N; i++) {
        int v = co[i].first;
        char s = co[i].second;
        so[v].push_back(s);
    }

    for (int i = 0; i < N; i++) { cb[i] = co[i]; }
    for (;;) {
        bool update = false;
        for (int i = 0; i < N - 1; i++) {
            if (cb[i].first > cb[i + 1].first) {
                swap(cb[i], cb[i + 1]);
                update = true;
            }
        }
        if (!update) { break; }
    }

    check_and_print();

    for (int i = 0; i < N; i++) { cb[i] = co[i]; }
    for (int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (cb[minj].first > cb[j].first) { minj = j; }
        }
        swap(cb[minj], cb[i]);
    }

    check_and_print();
}

int main() {
    cin >> N;

    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        char suit = s[0];
        int value = s[1] - '0';
        co[i] = C(value, suit);
    }

    solve();
    return 0;
}

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

int N, M, K;
int g[3030][3030];
ll dp[3030][3030][4];

int main()
{
	scanf("%d %d %d", &N, &M, &K);
	for(int i=1; i<=K; i++)
	{
		int y, x, val;
		scanf("%d %d %d", &y, &x, &val);
		g[y][x] = val;
	}
	for(int i=1; i<=N; i++)
		for(int j=1; j<=M; j++)
			for(int k=0; k<=3; k++)
			{
				ll &ret = dp[i][j][k];
				if (i == 1 && j == 1)
				{
					if (k != 3) ret = g[i][j];
					else ret = 0;
					continue;
				}

				if (i > 1)
				{
					ret = max(ret, dp[i-1][j][0]);
					if (k != 3) ret = max(ret, dp[i-1][j][0] + g[i][j]);
				}
				if (j > 1)
				{
					ret = max(ret, dp[i][j-1][k]);
					if (k != 3) ret = max(ret, dp[i][j-1][k+1] + g[i][j]);
				}
			}
	printf("%lld", dp[N][M][0]);
	return 0;
}

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

					#define mp make_pair
					#define pb push_back
					#define sqr(x) (x) * (x)
					#define sors(s) sort(s.begin(), s.end())
					#define F first
					#define S second

					using namespace std;
					typedef long long ll;
					ll n, m, k, d, t;
					int main()
					{
						cin >> m >> d;	 	
						for(int i = 1; i <= m; i++)
						for(int j = 22; j <= d; j++)
						{
							int x = j % 10, y = j / 10;
							if(x > 1 && x * y == i)
						 		t++;//, cout << i << ' ' << y << x << '\n';	
						}
						cout << t;
					}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
long long GCD(long long seme,long long uke)
{
  if(uke < seme)
    {
      long long tmp;
      tmp = seme;
      seme = uke;
      uke = tmp;      
    }
  if(seme == 0)
    {
      return uke;
    }

  else
    {
      return GCD(uke%seme,seme);
    }

}

int main()
{
  int N;

  cin >> N;
  vector<long long> A(N);
  for(int i=0;i<N;i++)
    {
      cin >> A[i];      
    }
  long long answer = A[0];
  for(int i=0;i<N;i++)
    {
      answer = GCD(A[i],answer);      
    }
  
  cout << answer << endl;
  
}


Measured memory_bytes: 1024
k,n=map(int,input().split())
ai=list(map(int,input().split()))
res = []
for i in range(n-1):
  res.append(ai[i+1]-ai[i])
res.append(k-ai[n-1]+ai[0])
mv = max(res)
res.remove(mv)
print(sum(res))

Measured memory_bytes: 26420
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 N;
  cin >> N;
  vector<double> p(N + 1);
  for(int i = 1;i <= N;i++) cin >> p[i];

  vector<vector<double>> dp(N + 1, vector<double>((N + 1) * 2, 0));
  dp[0][0 + N] = 1;

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

  cout << fixed << setprecision(10);
  double ans = 0;
  for(int i = 1;i <= N;i++) {
    ans += dp[N][i + N];
  }
  cout << ans << endl;
}


Measured memory_bytes: 141056
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
int main(){
  int flag=0,count=0,i;
  string in;
  cin >> in;
  for(i=0;in[i]!='\0';i++){
    if(in[i]=='A') flag=1;
    if(flag==1&&in[i]=='Z'){
      count++;
      flag=0;
    }
  }
  if(count==0) cout << -1;
  else{
    for(i=0;i<count;i++) cout << 'A' << 'Z';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair

int main() {
    int a,b;
    cin>>a>>b;
    cout<<max(a*b,max(a-b,a+b));

    return 0;
    }


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

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

    cout << (s[s.size() - 1] == 's' ? s + "es" : s + "s") << endl;
    return 0;
}


Measured memory_bytes: 3628
function checkFn() {
   while (true) {
      for (var x = 0; x < w ; x++) {
         var yy=[];
         for (var y = h-1; y >=0 ; y--) {
               if(yx[y][x]!=".")yy.push(yx[y][x]);
               yx[y][x]=".";
         }
         for (var y = h-1; y >=0 ; y--) {
            if(yy.length!=0)yx[y][x]=yy.shift();
            else yx[y][x]=".";
         }
      }
      var memo = [];
      for (var y = 0; y < h; y++)
         for (var x = 0; x <= w - n; x++) {
            var color = yx[y][x];
            if (color == ".") continue;
            var flag = true;
            for (var i = 1; i < n; i++) {
               if (yx[y][x + i] != color) flag = false;
            }
            if (flag) {
               for (var i = 0; i < n; i++) memo.push([y, x + i]);
            }
         }
      for (var y = 0; y <= h - n; y++)
         for (var x = 0; x < w; x++) {
            var color = yx[y][x];
            if (color == ".") continue;
            var flag = true;
            for (var i = 1; i < n; i++) {
               if (yx[y + i][x] != color) flag = false;
            }
            if (flag) {
               for (var i = 0; i < n; i++) memo.push([y + i, x]);
            }
         }
      memo.forEach(v => {
         yx[v[0]][v[1]] = ".";
      });
      if (memo.length == 0) break;
   }
   var str = yx.join("");
   return !(/[A-Z]/.test(str));
};

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var [h, w, n] = arr.shift().split(" ").map(Number);
var YX = [];
for (var i = 0; i < h; i++) YX.push(arr.shift().split(""));

var flag = false;
for (var y = 0; y < h; y++) {
   for (var x = 0; x < w - 1; x++) {
      var yx = YX.map(v => v.slice());
      [yx[y][x], yx[y][x + 1]] = [yx[y][x + 1], yx[y][x]];
      if (checkFn()) flag = true;
   }
}

console.log(flag ? "YES" : "NO");


Measured memory_bytes: 20252
n, m = map(int, input().split())
transit = [False] * n
for i in range(m):
    index = float('inf')
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a == 0:
        index = b
    elif b == n - 1:
        index = a
    if index != float('inf'):
        if transit[index]:
            print('POSSIBLE')
            exit()
        else:
            transit[index] = True
print('IMPOSSIBLE')

Measured memory_bytes: 4596
#include <stdio.h>

int main(void)
{
	int num=0;
	int card[4][13];
	int N=0;
	char M;

	int i, j;

	//???????????????.
	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 13; j++)
		{
			card[i][j] = 0;
		}
	}

	scanf("%d", &num);

	//????????????????????????.
	for (i = 0; i<num; i++) {
		scanf(" %c %d", &M, &N);
		if (M == 'S')
			card[0][N - 1] = 1;
		else if (M == 'H')
			card[1][N - 1] = 1;
		else if (M == 'C')
			card[2][N - 1] = 1;
		else if (M == 'D')
			card[3][N - 1] = 1;
	}

	//??????.
	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 13; j++)
		{
			if (card[i][j] == 0)
			{
				if (i == 0)
					printf("S %d\n", j + 1);
				else if (i == 1)
					printf("H %d\n", j + 1);
				else if (i == 2)
					printf("C %d\n", j + 1);
				else if (i == 3)
					printf("D %d\n", j + 1);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 596
import java.util.*;
import java.io.*;
public class Main{
/// functions
static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
// end
static long[] f;
// taking inputs
static BufferedReader s;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
// ends
//......................................@uthor_Alx..............................................
static long cc(int n){
	return ((long)n*(n-1))/2;
}
public static void main(String[] args) throws  IOException{
       assign();
       int n=int_v(read());
       int[] arr=int_arr();
       Map<Integer,Integer> map=new HashMap<>();
       for(int x:arr){map.put(x,map.getOrDefault(x,0)+1);}
       	long res=0;
       for(int x:map.keySet()){
       	res+=cc(map.get(x));
       }
       for(int z:arr){
       	long res1=res-cc(map.get(z))+cc(map.get(z)-1);
       	out.write(res1+"\n");
       }
       
        out.flush();
  }
}


Measured memory_bytes: 70752
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int count(int A)
{
    int ret = 0;

    while (A % 2 == 0)
    {
        A = A / 2;
        ret++;
    }

    return ret;
}

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    int A;
    int min = 1000000000;

    for (int i = 0; i < N; i++)
    {
        if (scanf("%d", &A) < 1) return 0;
        int cnt = count(A);
        min = cnt < min ? cnt : min;
    }

    printf("%d\n", min);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define mod 1000000007

int main(void){
  int N;
  scanf("%d",&N);

  int a[(N+1)/2];
  int A;
  for(int i = 0;i < (N+1)/2;i++) a[i] = 0;
  for(int i = 0;i < N;i++){
    scanf("%d",&A);
    a[A/2]++;
  }

  int flag = 1;
  int cnt = 0;
  for(int i = 0;i < (N+1)/2;i++){
    if(i == 0 && N%2 != 0){
      if(a[i] != 1)
        flag = 0;
    }else{
      if(a[i] != 2) flag = 0;
      else cnt++;
    }
  }

  long long ans = 1;
  while(cnt > 0){
    ans *= 2;
    ans %= mod;
    cnt--;
  }
  if(flag){
    printf("%lld\n",ans);
  }else{
    printf("0\n");
  }

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}
const int N = (int)1e5+5;
const int Q = 301;

void solve() {
  int n;  
  string s,t;
  	cin>>n>>s>>t;
  REP(i,0,n-1) {
  	cout<<s[i]<<t[i];
  }
}
int main() {
    //freopen("class_treasurer.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
string s,t;
vector<int>v[26];
int now=0;
int cnt=0;
signed main(){
	cin>>s>>t;
	rep(i,s.size())v[s[i]-'a'].pb(i);
	rep(i,t.size()){
		int x=t[i]-'a';
		if(v[x].empty()){
			puts("-1");
			return 0;
		}
		if(lower_bound(all(v[x]),now)-v[x].begin()==v[x].size()){
			now=v[x][0]+1;
			cnt++;
		}
		else{
			now=*lower_bound(all(v[x]),now)+1;
		}
	}
	cout<<cnt*s.size()+now<<endl;
	return 0;
}


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

int main(){
	int n,k,cnt=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		int b;
		scanf("%d",&b);
		if(b>=k)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys

n, *s = map(int, sys.stdin.read().split())

def main():
    res = sum(s)
    if res % 10:
        return res
    else:
        not_multiple_of_10 = [x for x in s if x % 10]
        if not_multiple_of_10:
            return res - min(not_multiple_of_10)
        else:
            return 0

if __name__ == '__main__':
    ans = main()
    print(ans)

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

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

  if (s == "SUN")
  {
    ans = 7;
  }
  else if (s == "MON")
  {
    ans = 6;
  }
  else if (s == "TUE")
  {
    ans = 5;
  }
  else if (s == "WED")
  {
    ans = 4;
  }
  else if (s == "THU")
  {
    ans = 3;
  }
  else if (s == "FRI")
  {
    ans = 2;
  }
  else if (s == "SAT")
  {
    ans = 1;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

void work() {
    int n; cin>>n;
    vector<bool> b(1e6+1, false);
    vector<bool> twice(1e6+1, false);
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int a; cin>>a;
        if (b[a]) {
            twice[a] = true;
            continue;
        }
        b[a] = true;
        v.push_back(a);
    }
    for (auto e : v) {
        for (int i = twice[e] ? e : e << 1; i <= 1e6; i += e)
            b[i] = false;
    }
    int ans = 0;
    for (int i = 1; i <= 1e6; ++i) {
        if (b[i]) ++ans;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


Measured memory_bytes: 4420
n,k=map(int,input().split())
cnt=[0]*(k+1)
mod=10**9+7
for i in range(1,k+1):
  cnt[i]=pow(k//i,n,mod)
#print(cnt)
for i in range(k):
  baisu=k//(k-i)
  for j in range(2,baisu+1):
    cnt[k-i]=(cnt[k-i]-cnt[(k-i)*j]+mod)%mod
ans=0
for i in range(1,k+1):
  ans+=i*cnt[i]
  ans%=mod
print(ans)

Measured memory_bytes: 11176
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    ll n, k;
    cin >> n >> k;
    vll a(n);
    rep(i,n){
        ll tmp;
        cin >> tmp;
        a[i] = tmp-1;
    }
    vll visit(n,0);
    vll town_array(n,0);
    ll now = 0;
    ll count = 0;

    while(1){
        if(visit[now] == 2) break;
        visit[now] +=  1;
        if(visit[now] == 1) town_array[count] = now;
        count++;
        now = a[now];
    }
    ll c1 = 0, c2 = 0;
    rep(i,n){
        // cout << town_array[i] << " ";
        if(visit[i] == 1) c1++;
        if(visit[i] == 2) c2++;
    }
    // printf("c1 = %lld, c2 = %lld\n", c1, c2);
    ll ans = 1;
    if(c1 > k){
        ans += town_array[k];
    }else{
        k -= c1;
        k %= c2;
        ans += town_array[c1 + k];
    }
    cout << ans << endl;
}



Measured memory_bytes: 7996
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

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 kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m;

signed main() {
	cin >> n >> m;
	int x = 0;
	if (m % 2)x = m;
	else x = m - 1;
	int cnt = 1;
	for (int i = x; i >= 1; i -= 2) {
		cout << cnt << " " << cnt + i << endl;
		cnt++;
	}
	int y = 0;
	if (m % 2)y = m - 1;
	else y = m;
	cnt = 1;
	for (int i = y; i >= 2; i -= 2) {
		cout << x + 1 + cnt << " " << x + 1 + cnt + i << endl;
		cnt++;
	}
}

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

int main() {
    int T;
    cin >> T;
    for (int z = 0; z < T; z++) {
        int N;
        cin >> N;
        vector<pair<ll, pair<ll, ll>>> camels_l, camels_r;
        ll ans = 0;
        for (int i = 0; i < N; i++) {
            ll K, L, R;
            cin >> K >> L >> R;
            if (K == N) {
                ans += L;
                continue;
            }
            if (L > R) camels_l.push_back({K, {L, R}});
            if (L < R) camels_r.push_back({K, {L, R}});
            ans += min(L, R);
        }
        sort(camels_l.begin(), camels_l.end());
        sort(camels_r.begin(), camels_r.end());
        int pos_l = 0;
        priority_queue<ll, vector<ll>, greater<ll>> pq_l;
        int use_l = 0;
        for (int i = 1; i <= N; i++) {
            while (pos_l < (int)camels_l.size() && camels_l[pos_l].first == i) {
                pq_l.push(camels_l[pos_l].second.first - camels_l[pos_l].second.second);
                pos_l++;
                use_l++;
            }
            while (use_l > i) {
                pq_l.pop();
                use_l--;
            }
        }
        while (!pq_l.empty()) {
            ans += pq_l.top();
            pq_l.pop();
        }
        
        int pos_r = (int)camels_r.size() - 1;
        priority_queue<ll, vector<ll>, greater<ll>> pq_r;
        int use_r = 0;
        for (int i = N; i >= 1; i--) {
            while (pos_r >= 0 && camels_r[pos_r].first+1 == i) {
                pq_r.push(camels_r[pos_r].second.second - camels_r[pos_r].second.first);
                pos_r--;
                use_r++;
            }
            while (use_r > N-i+1) {
                pq_r.pop();
                use_r--;
            }
        }
        while (!pq_r.empty()) {
            ans += pq_r.top();
            pq_r.pop();
        }
        cout << ans << endl;
    }
    
    return 0;
}

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

int main(){
	int n;
  	cin >> n;
  	vector<int> v(n);
  	rep(i, n) cin >> v[i];
  
  	sort(v.begin(), v.end());
  	double ans = v[0];
  	for(int i = 1; i < n; i++) ans = (ans + v[i]) / 2;
  
  	printf("%f", ans);
}

Measured memory_bytes: 3732