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

void calculate(){
    int N;
    cin >> N;
    for(int i = 1;i <= 9;++i){
        for(int j = 1;j <= 9;++j){
            if(i * j == N)
            {
                cout << "Yes\n";
                return;
            }
        }
    }
    cout << "No\n";
}

int main(int, char**) {
    calculate();
    return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, N);

  vector<i64> a(N + 10);
  vector<i64> cum(N + 10);
  reps(i, 1, N) {
    IN(a[i]);
    cum[i] = cum[i-1] + a[i];
  }

  i64 v1 = 0, v2 = 0;
  vector<i64> new_cum(N + 10);
  vector<i64> new_cum2(N + 10);
  reps(i, 1, N) {

    new_cum[i] = new_cum[i-1] + a[i];

    if (i % 2) {
      if (new_cum[i] <= 0) {
        v1 += abs(1 - new_cum[i]);
        new_cum[i] = 1;
      }
    }

    else {
      if (new_cum[i] >= 0) {
        v1 += abs(-1 - new_cum[i]);
        new_cum[i] = -1;
      }
    }
  }


  reps(i, 1, N) {

    new_cum2[i] = new_cum2[i-1] + a[i];

    if (i % 2) {
      if (new_cum2[i] >= 0) {
        v2 += abs(-1 - new_cum2[i]);
        new_cum2[i] = -1;
      }
    }

    else {
      if (new_cum2[i] <= 0) {
        v2 += abs(1 - new_cum2[i]);
        new_cum2[i] = 1;
      }
    }
  }

  OUTL(min(v1, v2));

  return 0;
}


Measured memory_bytes: 3456
#空リスト作成
str_list = []

#標準入力繰り返す
for _ in range(int(input())):
    
    #aが0ならリストの最後にbを加え、1ならリストのb番目のを出力
    try:
        a,b = map(int,input().split())
        if a == 0:str_list.append(b)
        elif a == 1:print(str_list[b])
        
    #入力数が1個しかなかったらリストの一番最後を消す
    except ValueError:
        str_list.pop(-1)


Measured memory_bytes: 13372
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll N;

void solve() {
	cin >> N;
	ll res = 0;
	for(ll i = 1; i * i <= N; i++) {
		ll a = i;
		if(a != N) {
			ll m1 = N / a - 1;
			if(N / m1 == N % m1) res += m1;
		}
		if(i * i != N) {
			ll b = N / i;
			if(b != N) {
				ll m2 = N / b - 1;
				if(N / m2 == N % m2) res += m2;
			}
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(void){
  int n,t,a,h,i,ans;
  double tem,min=100000000;
  cin >> n >> t >> a;
  for (i=0;i<n;i++){
    cin >> h;
    tem=t-0.006*h;
    if (min>abs(tem-a)){
      min=abs(tem-a);
      ans=i+1;
    }
  }
  cout << ans << endl;
  return 0;
}

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


int main(){
    int a,b;
    cin >> a >> b;
    if(a!=1 && b!=1)
        cout << "1";
    else if(a!=2 && b!=2)
        cout << "2";
    else   
        cout << "3";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  int n;
  n=s.length();
  char ans[n]={0};
  rep(i,n){
     ans[i]='x';
     cout << ans[i];
  }
  cout << endl;
  return 0;
}

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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){

    bool flag=true;

    ll ans=0,sum=0;
    int state,pstate;
    int n,st=1;

    string s1,s2;
    cin >>n;
    cin >>s1>>s2;

    if(s1[0] == s2[0]){
        ans = 3;
        pstate = 1;
    } else {
        ans = 6;
        pstate = -1;
        st++;
    }

    
    
    for (int i = st; i < n; i++){
        
        if(s1[i] == s2[i]){
            state = 1;
            if(pstate != -1)ans=(ans * 2)%MOD;
        }else{
            state = -1;
            if(pstate == -1)ans=(ans * 3)%MOD;
            else ans = (ans * 2)%MOD;
            ++i;
        }

        if(i == n-1)break;

        pstate = state;
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

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

int main() {
    int N;  cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    int MAX_A = 1e6 + 2;
    vector<int> is_prime(MAX_A, 1), min_prime(MAX_A);  // min_prime[i] := i の最小の素因数
    is_prime[0] = is_prime[1] = 0;
    min_prime[0] = min_prime[1] = -1;
    // エラトステネス
    for (int i = 0; i < MAX_A; ++i) {
        if (is_prime[i]) {
            min_prime[i] = i;
            for (int j = 2; i * j < MAX_A; ++j) {
                is_prime[i * j] = 0;
                min_prime[i * j] = i;
            }
        }
    }

    if (N == 1) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    // gcd(A[0], A[1], ..., A[N - 1]) == 1 ??
    int g = 0;
    for (int i = 0; i < N; ++i) g = gcd(g, A[i]);
    if (g != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    vector<int> used(MAX_A);
    for (int i = 0; i < N; ++i) {
        set<int> element;  // A[i] の素因数
        // 高速素因数分解
        int now = A[i];
        while (now != 1) {
            element.insert(min_prime[now]);
            now /= min_prime[now];
        }
        for (int e : element) ++used[e];
    }

    for (int i = 0; i < MAX_A; ++i) {
        if (used[i] > 1) {
            cout << "setwise coprime" << endl;
            return 0;
        }
    }

    cout << "pairwise coprime" << endl;
    return 0;
}


Measured memory_bytes: 18812
#include <stdio.h>


main(){

  int fib[44],n,o,p,q,i;

  scanf("%d",&n);

  fib[0]=1;
  fib[1]=1;

  for(i=2; i<=n; i++){
    fib[i]=fib[i-1]+fib[i-2];
  }
  printf("%d\n",fib[n]);

  return 0;
}

Measured memory_bytes: 596
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int n = readInt();
        ArrayList<Long> list = new ArrayList<>(n);
        long sum = 0;
        int mod = 1000000007;

        for (int i = 0; i < n; i++) {
            long a = readLong();
            sum += a;
            sum %= mod;
            list.add(a);
        }

        long ans = 0;
        for (int i = 0; i < n - 1; i++) {
            long a = list.get(i);
            sum -= a;
            if (sum < 0) sum += mod;
            ans += (a * sum) % mod;
        }

        System.out.print(ans % mod);
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 49260
function spilitInput(input, to_int) {
  if (typeof to_int === 'undefined') to_int = false;
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    if (to_int) {
      splited.push(rows[i].split(' ').map(function(d){return parseInt(d,10);}));
    } else {
      splited.push(rows[i].split(' '));
    }
  }
  return splited;
}

function initDp(N, init_n) { return Array(N+2).fill(init_n); }
function chmin(a, b) { if (a > b) a = b; }
function chmax(a, b) { if (a < b) a = b; }

function Main(input) {
  var splited = spilitInput(input, true);
  var N = splited[0][0];
  var hasons = [];
  for (var i = 1; i < splited.length; i += 1) {
    hasons.push(splited[i][0]);
  }
    
  var dp = initDp(N, 0);
  dp[0] = 1;
  
  for (var i = 1; i <= N; i += 1) {
    if (hasons[0] == i) {
      hasons.shift();
      continue;
    }
    dp[i] += dp[i - 1];
    if (i >= 2) dp[i] += dp[i - 2];
    dp[i] %= 1000000007;
  }

  console.log(dp[N]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 55604
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

for x in M:
  dp = [[0 for _ in range(x+1)] for _ in range(n+1)]
  dp[0][0]=1
  for i in range(n):
    for j in range(x+1):
      if A[i] <= j:
        dp[i+1][j] = dp[i][j - A[i]] or dp[i][j]
      else:
        dp[i+1][j] = dp[i][j]

  if dp[n][x] == 1:
    print ('yes')
  else:
    print ('no')


Measured memory_bytes: 6312
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N;string S;cin>>N>>S;
    int ans=1;
    for(char c='a';c<='z';c++){
        int k=1;
        REP(i,S.size()){
            if(S[i]==c)k++;
        }
        ans*=k;
      	ans%=MOD;
    }
  	ans--;
  	while(ans<0)ans+=MOD;
    cout<<ans<<endl;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    string s;
    cin>>s;

  	map<char,int> m;
	rep(i,4){
      m[s[i]]++;
    }

  	if(m.size()==2 && m[s[0]]==2)cout<<"Yes\n";
    else cout<<"No\n";
  
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n ;
	cin >> n ;
	int a[n] , b[n] , c[n] ;
	for(int i = 0 ; i < n ; i++)
		cin >> a[i] >> b[i] >> c[i] ;
	int dp[n][3] ;
	dp[0][0] = a[0] ;
	dp[0][1] = b[0] ;
	dp[0][2] = c[0] ;
	for(int i = 1 ; i < n ; i++){
		dp[i][0] = a[i] + max(dp[i - 1][1] , dp[i -1][2]) ;
		dp[i][1] = b[i] + max(dp[i - 1][0] , dp[i -1][2]) ;
		dp[i][2] = c[i] + max(dp[i - 1][1] , dp[i -1][0]) ;
	}
	cout << max ( dp[n - 1][0]  , max(dp[n - 1][1] , dp[n - 1][2])) ;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll n,d;cin>>n>>d;
	ll a[n][d];for(ll i=0;i<n;i++)for(ll j=0;j<d;j++)cin>>a[i][j];
	ll res=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			double dis=0;
			for(ll k=0;k<d;k++)
			{
				dis+=pow((abs(a[i][k]-a[j][k])),2);
			}
			dis=sqrt(dis);
			ll dist=dis;
			if(dist==dis)res++;
		}
	}
	cout<<res;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

void solve(){
	int n; cin >> n;
	vector<ll> a(n); cin >> a;
	string s; cin >> s;

	vector<ll> b;
	for(int i=n-1; i>=0; i--){
		ll x = a[i];
		for(ll y: b){
			x = min(x, y^x);
		}
		if(s[i]=='0'){
			if(x) b.push_back(x);
		} else {
			if(x){
				cout << 1 << endl;
				return;
			}
		}
	}
	cout << 0 << endl;
}


int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int t; cin >> t;
	for(int i=0; i<t; i++) solve();
	return 0;
}


Measured memory_bytes: 3472
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    h = int(input().rstrip('\n'))
    w = int(input().rstrip('\n'))
    print((n - h + 1) * (n - w + 1))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
program build_stairs
  implicit none
  integer :: n, h(100000) = 0, i
  read(*,*) n
  read(*,*) h(1:n)
  do i = n-1, 1, -1
    if (h(i) > h(i+1)) h(i) = h(i)-1
    if (h(i) > h(i+1)) then
      write(*,'(a)') "No"
      stop
    end if
  end do
  write(*,'(a)') "Yes"
  stop
end program build_stairs

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

const int N = 2e5 + 5;
int n;
int ans[N];
deque<int> dque;

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	bool rev = false;
	for (int i=1; i<=n; ++i) {
		int x;
		cin >> x;
		if (!rev) dque.push_back(x);
		else dque.push_front(x);
		rev = !rev;
	}
	n = 0;
	for (auto x: dque) ans[++n] = x;
	if (rev) reverse(ans+1, ans+n+1);
	for (int i=1; i<=n; ++i) {
		cout << ans[i];
		if (i == n) cout << '\n';
		else cout << ' ';
	}
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <vector>

using namespace std;

void insortionSort(vector<int> A){
    for(int i = 0;i < A.size();i++){
        int v = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for(int i = 0;i < A.size();i++){
        cout << A[i];
        if(i != A.size()-1){
            cout << ' ';
        }
    }
    cout << endl;
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    insortionSort(A);
}


Measured memory_bytes: 3156
#include <iostream>
#include <map>
#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned int uint;
int in() {
    int x = 0, c;
    for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
    return x;
}

int bit[400001] , N;
int num[400001];
int lst[400001];
map<int,int> xxx;


int add(int x,int a){
	while(x<=N){ bit[x]+=a; x += x & -x; }
}
int get(int x){
	int ans = 0;
	while(x) ans += bit[x] , x -= -x & x; 
	return ans;
}

int getPos(int num){
	int l = 1 , r = N;
	while(l != r){
		int m = (l+r) / 2;
		if(get(m) < num){
			l = m+1;
		}else{
			r = m;
		} 
	}
	return l;
}

int main(){
	int lim;
	while(N = in() , lim = in() , lim){
		memset(bit,0,sizeof(bit));
		memset(num,-1,sizeof(num));
		xxx.clear();
		int cur = 0 , head = 1;
		for(int i = 1 ; i <= N ; i++){
			
			int q,x;
			q = in() , x = in();
			if(q==0){
				xxx[x] = i;
				num[i] = x;
				add(i,1);
				cur++;
			}else if(q==1){
				num[getPos(x)] = -1;
				add(getPos(x),-1);
				cur--;
			}else if(q==2){
				printf("%d\n",num[getPos(x)]);
			}else if(q==3){
				add(xxx[x],-1);
				num[xxx[x]] = -1;
				cur--;
			}
			while(cur > lim){
				if(num[head] != -1){
					num[head] = -1;
					add(head,-1);
					cur--;
				}
				head++;
			}
		}
		puts("end");
	}
}

Measured memory_bytes: 0
#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,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;
static const ll MAX_N = 10000;
static const ll MAX_M = 10000;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}//modpow(a,n,mod)でa^nのmodをとる

int main(){
    string S;
    cin >> S;
    ll dp[100002];//dp[i]は長さiの数列の場合の数
    dp[0] = 1;
    for(int i = 1; i < S.size(); i++){
        dp[i] = 3 * dp[i-1] % MOD;
    }
    //cout << S.size() << dp[1] << endl;
    ll ans = 0, cnt = 0;
    //ans += dp[S.size()-1];
    for(int i = 0; i < S.size(); i++){
        if(i != S.size()-1){
            if(S[i] == '1'){
                ans += dp[S.size()-i-1] * modpow(2,cnt,MOD) % MOD;
                ans %= MOD;
                cnt++;
            }
        }else{
            if(S[i] == '0'){
                ans += modpow(2,cnt,MOD);
            }else{
                ans += 3 * modpow(2,cnt,MOD);
            }
            ans %= MOD;
        }
        //cout << ans << endl;
    }
    p(ans);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    int n; cin >> n;
    vi a(n); for(auto & e : a) cin >> e;

    int res = 1<<30;

    rep(i,-100, 101){
        int cur = 0;
        rep(j, n){
            cur += pow(a[j] - i, 2);
        }
        chmin(res, cur);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

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

    int *A = new int(N);
    for(int i = 0; i < N; i++){
        scanf("%d", (A+i));
    }
    
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += (D - 1) / A[i] + 1;
    }
    printf("%d", sum+X);
}

Measured memory_bytes: 256
N,a,b,c,d = map(int,input().split())
S = input()
a -= 1
b -= 1
c -= 1
d -= 1

if c < d :
    if (S[b:d+1].count("##") == 0) and (S[a:c+1].count("##") == 0) :
        ans = "Yes"
    else :
        ans = "No"
else :
    if (S[b:d+1].count("##") == 0) and (S[a:c+1].count("##") == 0) :
        flg1 = 1
    else :
        flg1 = 0
    

    if S[a:d+1].count("...") >= 1 :
        flg2 = 1
    else :
        flg2 = 0
        
    for i in range(b,d+1) :
        if (S[i-1]+S[i]+S[i+1] == "...") :
            flg3 = 1
            break
    else :
        flg3 = 0
    
    
    if flg1*flg3 :
        ans = "Yes"
    else :
        ans = "No"
print(ans)
    
    

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b + c || b == c + a || c == a + b) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,r,l,lhy,i;//lhy，最新防伪标识!（不是刘浩宇！！！）
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {scanf("%d%d",&l,&r);//l代表左边，r代表右边
    lhy+=r-l+1;}//加一个，头尾都有
    printf("%d\n",lhy);//回车别忘了
    return 0;
}

Measured memory_bytes: 128
import sys


# sys.stdin = open('e1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


debug = False
N = 5600070
if debug:
    print()
    print('N:', N)
    print()


def ask(n):
    if debug:
        res = (n <= N and str(n) <= str(N)) or (n >= N and str(n) >= str(N))
        print('?', n, '\t', res)
        return res
    print('?', n, flush=True)
    return input() in ['y', 'Y']


def solve():
    if ask(10 ** 9):
        # N is a power of 10
        for k in range(10):
            if ask(2 * 10 ** k):
                return 10 ** k

    # Find the number of digits of N
    l = 1
    while ask(10 ** l):
        l += 1

    d = [9] * l
    for p in range(l):

        a = 0
        if p == 0:
            a = 1
        b = 9

        d[p] = a
        n = int(''.join(map(str, d)))
        if ask(10 * n):
            continue

        while b - a > 1:
            m = (a + b) // 2
            d[p] = m
            n = int(''.join(map(str, d)))
            if ask(10 * n):
                b = m
            else:
                a = m
        d[p] = b
    n = int(''.join(map(str, d)))
    return n


def main():
    res = solve()
    print('!', res, flush=True)


if __name__ == '__main__':
    main()


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

void solve()
{
    ll n,a,i;
    string st;
    cin >> n >> st;
    if(n>=st.size())cout << st << "\n";
    else cout << st.substr(0,n) << "..." << "\n";

}

int main()
{
    ll t,i;
    solve();

    return 0;
}



Measured memory_bytes: 3600
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int k,n;
    cin >> k >> n;
    vector<int>a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    vector<int> sec(n,0);
    for(int i = 1;i < n;i++){
        sec[i] = a[i] - a[i - 1];
    }
    sec[0] = a[0] + k - a[n - 1];
    int ans = k;
    for(int i = 0;i < n;i++){
        ans = min(ans,k - sec[i]);
    }
    cout << ans << endl;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S;
	cin >> S;
	int m = stoi(S.substr(5, 2));
	if(m<=4){
		cout << "Heisei" << endl;
	}else{
		cout << "TBD" << endl;
	}
    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 a;
  cin >> a;
  
  if(a[0] == a[2]) cout << "Yes" << endl;
  else cout << "No" << endl;  
  
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s; cin >> s;
    int N = s.size();
    rep(i, N) {
        int tmp = (26+s[i]-'A'-3)%26;
        cout << (char)(tmp+'A');
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3224
import java.io.*;

class Main {
	public static void main(String[] args) {
		// BufferedReader br = new BufferedReader(new
		// InputStreamReader(System.in));
		try {
		        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
			// n:???????????°???k:?????????????????°
			int n = Integer.parseInt(str.split(" ")[0]);
			int k = Integer.parseInt(str.split(" ")[1]);
			// ?????????????´?????????????
			int[] nimotu = new int[n];
			// ??¨????????????????????????????¨?????????????
			int totalWeight = 0;
			int maxweight = 0;
			// ??????????????????????´????????????????????????§??????????±???????
			for (int i = 0; i < n; i++) {
				nimotu[i] = Integer.parseInt(br.readLine());
				totalWeight += nimotu[i];
				if(nimotu[i] > maxweight){
					maxweight = nimotu[i];
				}
			}
			// ???????????????????±???????
			int aver = totalWeight / k;
			//?¨???????????±???????
			int settingVal= 0;
			// ??????????????????????????????????????????????????????????????????????????????????????????????????£??\
			if(maxweight < aver){
				settingVal = aver;
			}else{
				settingVal = maxweight;
			}
			int tracknum;
			while(settingVal <= totalWeight){
				int weight = 0;
				tracknum = 1;
				// ?¨????????????????????¶???????????????????????????????????????????
				for(int i = 0;i < n && tracknum <= k;) {
					// ????????????????????????????????°?????????
					if(weight + nimotu[i] <= settingVal){
						weight += nimotu[i];
						i++;
					//???????????????????????????????????????????????????????????????????????£?????????????????°?¬???????????????????
					} else {
						weight = 0;
						tracknum++;
					}
				}
				/* ???????????¶
				 * ?±???????????°??????????????????????aver?????????????????¨?????????????????????????????????aver????????????????????¨?????????????????°????¨??????????????¶???????????????????
				 * ??\????????????????????????????????????????????°????¶???????????????????????±???????????°????????????????????????§?????????
				 * 1.tracknum = k???????????????????????????????????°????¶???????????????¨
				 * 2.flg = true????????¨?????????????????????????????????????????¨
				*/
				if(tracknum <= k){
					System.out.println(settingVal);
					break;
				}
				// ?????????????????´?????????????????????????¬????
				settingVal++;
			}
		} catch (IOException e) {
			System.out.println("error");
		}
	}
}

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

using namespace std;
#define ll long long
#define mod 1000000007

vector<pair<ll, ll>> v;
ll dp[101][100001];

ll f(ll i, ll rw) {
    if (i == v.size()) return 0;

    if (dp[i][rw] != -1) return dp[i][rw];

    ll ans = f(i + 1, rw);
    if (v[i].first <= rw) {
        ans = max(ans, v[i].second + f(i + 1, rw - v[i].first));
    }
    dp[i][rw] = ans;
    return ans;
}

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

    memset(dp, -1, sizeof(dp));
    ll n, W;
    cin >> n >> W;

    v.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    cout << f(0, W) << "\n";
}


Measured memory_bytes: 82548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


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

    int cnt = 0;
    rep(i, N) {
        if (to_string(i+1).size() % 2 != 0) {
            ++cnt;
        }
    }

    print(cnt);

    return 0;
}



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

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

    int ans = 0;

    for(int i = 0; i <= n-3; i++){
        if(s.substr(i, 3) == "ABC"){
            ans++;
            i += 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

vector<int> shuffle(vector<int> deck, int m)
{
    int n = deck.size();
    queue<int> a, b;

    for(int i=0; i<n; ++i){
        if(i < n / 2)
            b.push(deck[i]);
        else
            a.push(deck[i]);
    }

    vector<int> ret;
    while(!a.empty() || !b.empty()){
        for(int i=0; i<m; ++i){
            if(a.empty())
                break;
            ret.push_back(a.front());
            a.pop();
        }
        for(int i=0; i<m; ++i){
            if(b.empty())
                break;
            ret.push_back(b.front());
            b.pop();
        }
    }

    return ret;
}

int main()
{
    for(;;){
        int n, r;
        if(!(cin >> n >> r))
            return 0;

        vector<int> deck(n);
        for(int i=0; i<n; ++i)
            deck[i] = i;

        for(int i=0; i<r; ++i){
            int m;
            cin >> m;
            deck = shuffle(deck, m);
        }

        cout << deck[n-1] << endl;
    }
}

Measured memory_bytes: 0
import java.util.Scanner;

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

	int x = scan.nextInt();

        double max = 0;
	for(int i = 1; i <= x; i++){
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	}

	System.out.println((int)max);
    }
}


Measured memory_bytes: 21716
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int a;double b;
	cin>>a>>b;
	int c=(int)(b*100 + 0.1);
	int ans=(a*c)/100;
	cout<<ans;
}

Measured memory_bytes: 3664
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline().rstrip()
    count = 0
    for i in range(1000):
        left = 0
        not_found = False
        for c in '{:03}'.format(i):
            for j in range(left, N):
                if S[j] == c:
                    left = j + 1
                    break
            else:
                not_found = True
                break
            if not_found:
                break
        if not not_found:
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
const main = (input) => {
  input = input.trim().split('\n')
  const arr = input[1].split(' ').map(BigInt)

  if (arr.includes(0n)) return console.log(0)

  let ans = 1n
  for (let i=0; i<arr.length; i++) {
    ans *= arr[i]
    if (ans > BigInt(10**18)) return console.log(-1)
  }

  return console.log(ans > BigInt(10**18) ? -1 : `${ans}`)
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 42380
package main

import (
        "fmt"
)

func solution(n, k int) float64 {

        out := 0.0
        for i := 1; i < n+1; i++ {
                x := helper(i, k)
                out += (1 / float64(n)) * x
        }
        return out
}

func helper(i, k int) float64 {
        x, out := i, 1.0
        for k > x {
                x *= 2
                out /= 2
        }
        return out
}

func main() {
        var n, k int
        fmt.Scan(&n, &k)
        fmt.Printf("%.12f\n", solution(n, k))
}

Measured memory_bytes: 1836
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int N, D, integer_distances = 0;
  cin >> N >> D;
  int X[N][D];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      int distance = 0;
      for (int k = 0; k < D; k++) {
        distance += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      if (sqrt(distance) == floor(sqrt(distance))) {
        integer_distances++;
      }
    }
  }
  cout << integer_distances;
  return 0;
}

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

long long int n, m;

void solve() {
	cin >> n >> m;
	int h[n + 1] {};
	int g[n + 1] = {};
	int x, y, c = 0;
	for (int i = 1; i <= n; ++i)
	{
		cin >> h[i];
	}

	for (int i = 1; i <= m; ++i)
	{
		cin >> x >> y;
		if (h[x] < h[y]) {
			g[x] = 1;
		}
		else if (h[x] > h[y]) {
			g[y] = 1;
		}
		else {
			g[x] = 1;
			g[y] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (g[i] == 0) {
			c++;
		}
	}
	cout << c;

}

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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	return 0;
}

Measured memory_bytes: 4444
#include <stdio.h>

int LinearSearch(int A[], int n, int key){
	int i = 0;
	A[n] = key;
	while(A[i] != key)
	i++;
	return i != n;
	
}


int main(){

	int i, n , A[10000], q, key, sum = 0;
	
	scanf("%d\n", &n);
	for(i = 0; i < n; i++)
		scanf("%d", &A[i]);
	
	
	scanf("%d\n", &q);
	for(i = 0; i < q; i++){
	scanf("%d", &key);
	
	
	if (LinearSearch(A, n, key))
	sum++;
	
	}
	printf("%d\n", sum);
	return 0;
}

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

int main(){
   string s,t;  int l=0;
   cin >> s;

    cin >>t;
    rep(i,s.size()){
        if(s.at(i) == t.at(i)){
            l+=1;
        }
    }
            if(l == s.size()){
            cout << "Yes" << endl;
            }else{
            cout << "No" <<endl;
        }
              
            
        
}


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

int main(){
  string S;
  cin>>S;
  long long cnt;
  map<char,long long>mp;
  
  for(int i=0;i<S.size();i++){
    mp[S.at(i)]++;
  }
  
  cnt=(S.size()*(S.size()-1))/2;
  //cout<<cnt<<endl;
  
  if(mp.size()==1){
    cout<<1<<endl;
    return 0;
  }
  
  for(auto itr=mp.begin();itr != mp.end();itr++){
    cnt-=(itr->second)*((itr->second)-1)/2;
    //cout<<(itr->second)*((itr->second)-1)/2<<endl;
  }
  cnt++;
  cout<<setprecision(20)<<cnt<<endl;
  return 0;
}
  

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
#include<iomanip>
#include<bitset>
#include<math.h>
using namespace std;
 
 
int main(){
 
	long long n;
	cin >> n;
	
	vector<long long> v(n);
	for (int i = 1; i < n+1; i++)
	{
		v[i-1] = i;
	}
	vector<long long> p(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	int cnt=0;
	for (int i = 0; i < n; i++)
	{
		if(v[i] != p[i]){
			cnt ++;
		}
	}
	
	if(cnt <= 2){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n; cin >> n;
    int time[101],all=0;
    rep(i,n){
        cin >> time[i];
        all += time[i];
    }
    int m; cin >> m;
    rep(i,m){
        int p,x; cin >> p >> x;
        cout << all-time[p-1]+x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
function main(input){
    let nums = input.split(" ").map(item=>parseInt(item));
    if(nums[0]>nums[1]){
        console.log("a > b");
    }else if(nums[0]<nums[1]){
        console.log("a < b");
    }else{
        console.log("a == b");
    }
    
    
}

main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 15120
/*input
4
4 4 1 1
*/
#include <bits/stdc++.h>
#define ll long long int
#define lld long double
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n;cin>>n;
	int c0=0,c1=0,c2=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;int coun=0;
		while(x%2==0){
			coun++;
			x/=2;
		}
		if(coun==0)
			c0++;
		if(coun==1)
			c1++;
		if(coun>=2)
			c2++;
	}
	vector<int> vec;
	for(int i=1;i<=c1;i++){
		vec.push_back(2);
	}
	for(int i=1;i<=c2;i++){
		vec.push_back(4);
	}
	if(vec.size()==0){
		cout<<"No\n";return 0;
	}
	for(int i=0;i<vec.size();i++){
		if(i==0)
			if(vec[0]==4)
				c0--;
		if(i==1)
			if(vec[1]==4 && vec[0]==4)
					c0--;
		if(i>1)
			if(vec[i]==4  && vec[i-1]!=2)
				c0--;
	}
	if(vec[vec.size()-1]==4)
		c0--;
	int mark=0;
	if(c0>0)
		mark=1;
	if(vec.size()==1 && vec[0]==2)
		mark=1;
	if(!mark)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

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

int main() {
	double x = 0, y = 0;
	double dist, ang = 0, d;
	while (scanf("%lf,%lf", &dist, &d), dist || d) {
		x += sin(ang*M_PI / 180)*dist;
		y += cos(ang*M_PI / 180)*dist;
		ang += d;
	}
	cout << (int)x << endl << (int)y << endl;
}

Measured memory_bytes: 3404
//#include<stdio.h>
//#include<iostream>
//#include<algorithm>
//#include<vector>
//#include<cstring>
//#include<cmath>
//#include<map>
#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf

typedef map<char, int>mpci;
typedef map<int, int>mpii;

int main()
{
    fast;
    string s;
    //mpci mp;
    mpii mp;
    char ch[30];
    while(cin >> s)
    {
        mp.clear();

        int len = s.length() , pen=0;
        bool f=false;

        for(int i=0; i<len; i++)
        {
            if(mp.count(s[i]) == 0)
            {
                //outs(s[i]);
                ch[pen++] = s[i];
               // mp[s[i]-48]++;
                mp[s[i]] = 1;
            }

            else
            {
                mp[s[i]]++;
            }
        }

        for(int i=0; i<pen; i++)
        {
            //cout << ch[i] << " " << mp[ch[i]] << "\n";
            if(mp[ch[i]] % 2 != 0)
            {
                f=true;
                break;
            }
        }

        if(f) outn("No");
       else outn("Yes");
    }

    return 0;
}


Measured memory_bytes: 256