akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<string>s(N);
    for(int i=0;i<N;i++){
        string S;
        cin>>S;
        sort(S.begin(),S.end());
        s[i]=S;
    }
    sort(s.begin(),s.end());
    s.push_back("aaaaaaaaaaaa");
    long long count=0,ans=0;
    for(int i=0;i<N;i++){
        if(s[i]==s[i+1]){
            count++;
        }else if(s[i]!=s[i+1]&&count!=0){
            ans+=count*(count+1)/2;
            count=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long power(long long a, long long p){
    long long res = 1ll;
    while(p > 0){
        if(p % 2 == 1) res = (res * a) % mod;
        p /= 2;
        a = (a * a) % mod;
    }
    return res;
}
int main(){
    long long n;
    cin >> n;
    if(n == 1){
        cout << 0;
    }
    else{
        long long ans;
        ans = power(10, n) % mod;
        long long m = power(9, n) % mod;
        ans = ans - 2ll * m;
        m = power(8, n) % mod;
        ans += m;
        cout << (ans + mod + mod + mod) % mod;
    }
    return 0;
}



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

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

    int b_minus_a = b - a;
    int original_height = 0;
    for (int i = 0; i <= b_minus_a - 2; i++){
        original_height += i + 1;
    }
    int ans = original_height - a;

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

Measured memory_bytes: 384
N, M = map(int, input().split())
A = list(map(int,input().split()))

bool = True
for i in range(M):
    if sorted(A, reverse=True)[i] < sum(A)*(1/(4*M)):
        # print(f'{i}: {sorted(A,reverse=True)[i]} | {sorted(A,reverse=True)[i]} < {sum(A)*(1/(4*M))}')
        bool = False
    else:
        # print(f'{i}: {sorted(A,reverse=True)[i]} | {sorted(A,reverse=True)[i]} >= {sum(A)*(1/(4*M))}')
        pass

if bool == True:
    print('Yes')
else:
    print('No')


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int ans =0;
  for(int i=A; i<=B; i++){
    int a, b, c, d, e;
    a=i/10000;
    b=i/1000%10;
    e=i%10;
    d=i%100/10;
    
    if(a==e&&b==d)ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 305
string s; int n; int k;
int dp[MN][MN][MN];
int calc(int l, int r, int x){
    if(dp[l][r][x] != -1) return dp[l][r][x];
    if(r < l){
        dp[l][r][x] = 0;
        return 0;
    }
    if(l == r){
        dp[l][r][x] = 1;
        return 1;
    }
    int mx = 0;
    mx = max(mx, calc(l, r-1, x));
    mx = max(mx, calc(l+1, r, x));
    if(s[l] == s[r]){
        mx = max(mx, calc(l+1, r-1, x)+2);
    } else if(x != 0){
        mx = max(mx, calc(l+1, r-1, x-1)+2);
    }
    dp[l][r][x] = mx;
    return mx;
}

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

    cin >> s >> k; n=s.length();
    memset(dp, -1, sizeof dp);
    cout << calc(0, n-1, k) << "\n";
    
    return 0;
}


Measured memory_bytes: 111104
# ABC079

s = input()

def cal_pm(s, is_plus):
    result = int(s[0])
    for p_idx, p in enumerate(is_plus):
        if p == '1':
            result += int(s[p_idx+1])
        else:
            result -= int(s[p_idx+1])
    return result

res = 0
for i in range(2**(len(s)-1)):
    is_plus ='{i:0={width}b}'.format(i=i, width=len(s)-1) 
    result = cal_pm(s, is_plus)
    if result == 7:
        for idx, n in enumerate(s):
            print(n, end='')
            if idx != len(s) - 1:
                print('+' if is_plus[idx] == '1' else '-', end='')
            else:
                print('=7')
        break

Measured memory_bytes: 3064
// Problem : A - The Number of Even Pairs
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define Ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Test Ios; int tz; cin>>tz; while(tz--)
#define prec(ans) cout<<fixed<<setprecision(20)<<ans<<'\n';
#define all(v) v.begin(), v.end()
#define F first
#define S second

#define sa(a,n)  		int a[n]; for(int zz = 0 ; zz<n; zz++) cin>>a[zz];
#define sda(a,n) 		int n; cin>>n; sa(a,n)
#define pra(a,n)        for(size_t zz=0;zz<n;zz++) cout<<a[zz]<<' '; cout<<'\n';
#define prv(a)          for(auto zz:a) cout<<zz<<' '; cout<<'\n';
#define tr1(x)          cerr <<#x<<": "<<x<<'\n';
#define tr2(x, y)       cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define tr3(x, y, z) 	cerr <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define tr4(a, b, c, d) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';

int32_t main(){
//Test
{
	int n,m;
	cin>>n>>m;
	cout<< (n*(n-1))/2 + (m*(m-1))/2<<'\n';
    
}}


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

  cin >> N >> M;
  //vector<int> A(N);
  for(i=0;i<M;i++){
    cin >> a;
    N-=a;
  }
  if(N>=0)
    cout << N << endl;
  else
    cout << -1 <<endl;
  
  
return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
std::vector<edge>v[1000];

int main() {
	ll a, b, c, n;
	string s, t, r;
	cin >> a >> b >> c;
	if (a + b >= c)cout << "Yes" << endl;
	else cout << "No" << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>


int main(int argc, char *argv[])
{
	int h,a;
	cin >> h>>a;
	

	cout<< (h+a-1)/a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

const int MAX_K = 300000;
bool fact_initialized = false;
long long fact[MAX_K], fact_inv[MAX_K], inv[MAX_K];

void combination_init(int mod)
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;

    for(int i = 2; i < MAX_K; ++i)
    {
        fact[i] = fact[i-1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i-1] * inv[i] % mod;
    }
}

long long combination_mod(int n, int k, int mod)
{
    if (n < k || n < 0 || k < 0) return 0;
    if(!fact_initialized)
    {
        combination_init(mod);
        fact_initialized = true;
    } 
    return fact[n] * (fact_inv[k] * fact_inv[n-k] % mod) % mod;
}

long long MOD = 1000000007;
int main(){
    std::ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;++i)
    {
        cin >> a[i];
    }

    sort(a.rbegin(), a.rend());

    ll ret = 0;
    for(int i=0;i<n;++i)
    {
        ret -= combination_mod(i, k-1, MOD) * a[i];
        ret += combination_mod(n-1-i, k-1, MOD) * a[i];
        ret %= MOD;
    }

    cout << ret << endl;
}

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

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll mod = 1000000007;

mat mul(mat &A, mat &B){
    mat C(A.size(), vec(B[0].size()));
    for(int i = 0; i < A.size(); i++){
        for(int k = 0; k < B.size(); k++){
            for(int j = 0; j < B[0].size(); j++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
            }
        }
    }
    return C;
}

mat pow(mat A, ll n){
    mat B(A.size(), vec(A.size()));
    for(int i = 0; i < A.size(); i++){
        B[i][i] = 1ll;
    }
    while(n > 0){
        if(n & 1)   B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

int main(){
    int n;
    ll k;
    cin >> n >> k;
    mat v(n, vec(n));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> v[i][j];
        }
    }
    v = pow(v, k);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            ans += v[i][j];
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, X, Y; cin >> N >> X >> Y;
  vector<int> C(N, 0);
  for (int i = 1; i < N; i++) {
    for (int j = i+1; j <= N; j++) {
      int dist = 1000000;
      dist = min(dist, j - i);
      int tmp = abs(X - i) + 1 + abs(j - Y);
      dist = min(dist, tmp);
      C.at(dist)++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << C.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
#define FOR(S,X) for(int i=0;i<X;i++)
#define FOR2(S,X) for(int j=0;j<X;j++)
int main() {
	int d,t,s;
	cin >> d>>t>>s;
	if (s*t>=d)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

char S[4];

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

  cin >> S;

  int alpha[3];
  for (int i = 0; i < 3; i++) alpha[i] = 0;
  for (int i = 0; i < 3; i++) alpha[(S[i] - 'a')]++;
  for (int i = 0; i < 3; i++)
    if (alpha[i] != 1) {
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    set<int> a;
    bool ans = true;
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        if (!a.insert(b).second) ans = false;
    }
    
    cout << ((ans) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 9600
N = int(input())
C = input()
a = b = ans = 0
for c in C:
    if c == 'R':
        a += 1
ans = max(a, b)
for c in C:
    if c == 'R':
        a -= 1
    else:
        b += 1
    ans = min(ans, max(a, b))
print(ans)



Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if(a < 9 && b < 9) puts("Yay!");
    else puts(":(");
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
c1=[]
c2=[]
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        c1.append(b)
    if b==N:
        c2.append(a)
c1=set(c1)
c2=set(c2)
if c1&c2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if(x-r>=0 && x+r<=w && y-r>=0 && y+r<=h) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>

#define ll long long
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(5);
    for (int i = 0; i < 5; i++)cin >> a[i];
    ll mi = 1145141919810364364;
    for (int i = 0; i < 5; i++)mi = min(mi, a[i]);
    cout << (n + mi - 1) / mi + 4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int m=1e9+7;
int H,W,A,B;
int pw(int a,int x){
    if(x==0)return 1;
    int r=pw(a,x>>1);
    if(x&1)return ((1ll*r*r)%m*a)%m;
    return (1ll*r*r)%m;
}
int comb(int n,int r){
    if(!r or !(n-r))return 1;
    int nF=1,aF,bF;
    for(int i=1;i<=n;i++){
        nF=(1ll*nF*i)%m;
        if(i==r)aF=nF;
        if(i==n-r)bF=nF;
    }
    return (((1ll*nF*pw(aF,m-2))%m)*pw(bF,m-2))%m;
}
int f(int a,int i,int b,int j,int x,int y){
    int ret=(1ll*x*y)%m;
    x=((1ll*x*(a-i))%m*pw(i+1,m-2))%m;
    y=((1ll*y*(b-j))%m*pw(j+1,m-2))%m;
    if(!x or !y)return ret;
    return (ret+f(a,i+1,b,j+1,x,y))%m;
}
int main(){
    scanf("%d%d%d%d",&H,&W,&A,&B);
    int x=comb(H-A+B-1,B),y=comb(W-B+A-1,A);
    printf("%d\n",f(H-A+B-1,B,W-B+A-1,A,x,y));
}


Measured memory_bytes: 8704
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> x(n);
	for(int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	
	int ans = 0;
	while(1)
	{
		bool flag = true;
		for(int i = 0; i < n; i++)
		{
			if((x[i] % 2) != 0)
			{
				flag = false;
				break;
			}
			else
			{
				x[i] /= 2;
			}
		}
		
		if(flag == false)
		{
			break;
		}
		
		ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int prime(int);

int main()
{
    int *num;
    int n=0,i,count=0;
    
    scanf("%d",&n);
    
    num = (int *)malloc(n * sizeof(int));
    
    for(i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
        if(prime(num[i]) == 1) count++;
    }
    printf("%d\n",count);
    free(num);
    return 0;
}

int prime(int num)
{
    int i,sqrtnum;
    
    if(num == 2) return 1;
    else if(num%2 == 0) return 0;
    sqrtnum = sqrt(num);
    for(i=3;i<=sqrtnum;i+=2)
    {
        if(num%i == 0) return 0;
    }
    return 1;
}


Measured memory_bytes: 2020
{-# LANGUAGE BangPatterns #-}

-- This code was written after reading the editorial.

import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import Debug.Trace
import System.Random
import Control.Monad

solve :: Int -> [Int] -> [Int]
solve n as | n `mod` 2 == 0 = reverse $ sort [sum_even, sum_odd]
           | otherwise = [sum_odd + diff, sum_even - diff]
  where
    sum_all = sum as
    sum_even = f_sum_even as
    sum_odd = sum_all - sum_even
    diff = calc_diff (max 0 (sum_even-sum_odd)) (sum_even + 1) as

f_sum_even as = sub 0 as
  where
    sub !acc []       = acc
    sub !acc [a]      = acc + a
    sub !acc (a:_:as) = sub (acc+a) as

calc_diff dmin dmax as
  | dmax == dmin + 1 = dmin
  | try dmid as = calc_diff dmid dmax as
  | otherwise = calc_diff dmin dmid as
  where
    dmid = (dmax + dmin) `div` 2

try goal [a] = goal <= a
try goal (w0:b0:as@(w1:as'))
  | w0 >= goal && w0 <= b0 = try goal as
  | otherwise              = try goal (w1 + (w0-b0) : as')

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

main = do
  cont <- B.getContents
  let (n:as) = bsReadInts cont
      ans= solve n as
  putStrLn $ unwords $ map show ans


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

int main() {
  int x;
  cin >> x;
  if (x==0) cout << 1 << endl;
  if (x==1) cout << 0 << endl;
  return 0;
}

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

using namespace std;

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;

  double pi = 3.141592653589793238462643383279502884L;
  double at = (H + M / 60) / 12 * 2 * pi;
  double ax = cos(at) * A;
  double ay = sin(at) * A;
  double bt = (M / 60) * 2 * pi;
  double bx = cos(bt) * B;
  double by = sin(bt) * B;
  printf("%.20f\n", hypot(ax - bx, ay - by));
}


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

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const double pi = 3.14159265358979;

const int mod = 998244353;
int n, s, a[3001];

long long modpow(long long x, long long y){
	if(y == 0) return 1;
	long long ret = modpow(x, y / 2);
	ret = (ret * ret) % mod;
	if(y % 2) ret = (x * ret) % mod;
	return ret; 
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> s;
	for(int i = 1; i <= n; i++) cin >> a[i];
	vector<long long> pow(n + 1);
	pow[0] = 1;
	for(int i = 1; i <= n; i++) pow[i] = (pow[i - 1] * 2) % mod;
	vector<vector<long long>> dp(n + 1, vector<long long>(s + 1));
	dp[0][0] = pow[n];
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= s; j++){
			if(j < a[i]) dp[i][j] = dp[i - 1][j];
			else dp[i][j] = (dp[i - 1][j] + (dp[i - 1][j - a[i]] * modpow(2, mod - 2)) % mod) % mod;
		}
	cout << dp[n][s] << "\n";
	return 0;
}

Measured memory_bytes: 73672
//AOJ 0033 Ball
#include<stdio.h>

int main(){
	int l,r,tmp;
	int n;
	scanf("%d",&n);
	while(n--){
		l = r = 0;
		bool flag = true;
		for(int i = 0;i<10;++i){
			scanf("%d",&tmp);
			if(!flag)continue;
			if(tmp<l&&tmp<r){
				flag = false;
				continue;
			}
			if(l>r){
				if(l<tmp)l=tmp;
				else r = tmp;
			}
			else{
				if(r<tmp)r=tmp;
				else l = tmp;
			}
		}
		if(flag)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
} 


Measured memory_bytes: 2696
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using static System.Math;

class P
{
  static int[] Input(){
    return Console.ReadLine().Split().Select(int.Parse).ToArray();
  }
  static int[][] Input2(int n){
    int[][] X = new int[n][];
    for(int i = 0; i < n; i++){
      X[i] = Input();
    }
    return X;
  }
  static void Main()
  {
    int[] NK = Input();
    int X = NK[0];
    int r = 0;
    var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
    for(int i=1; i < 100000; i++){
      if (X <= (i*(i+1))/2) {
        r = i;
        break;
      }
    }
    Console.SetOut(sw);
    Console.WriteLine(r);
    Console.Out.Flush();
  }
}


Measured memory_bytes: 13396
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
	int m;
	cin>>s>>m;
	int n = s.size();
	rep(i, n){
		if(s[i]=='a') continue;
		int a = 'z'-s[i]+1;
		if(a<=m){
			s[i] = 'a';
			m -= a;
		}
	}
	m %= 26;
	s[n-1] += m;
	if(s[n-1]>'z') s[n-1] -= 26;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 512
n = int(input())
fizz = 3 * sum([i + 1 for i in range(n // 3)])
buzz = 5 * sum([i + 1 for i in range(n // 5)])
fizzbuzz = 15 * sum([i + 1 for i in range(n // 15)])
ans = sum([i + 1 for i in range(n)]) - fizz - buzz + fizzbuzz
print(ans)

Measured memory_bytes: 52184
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
ll digitPoor(ll n)
{
    assert(INT_MAX == 2147483647);
    assert(n >= 0);

    if (n < 10)         return 1;
    if (n < 100)        return 2;
    if (n < 1000)       return 3;
    if (n < 10000)      return 4;
    if (n < 100000)     return 5;
    if (n < 1000000)    return 6;
    if (n < 10000000)   return 7;
    if (n < 100000000)  return 8;
    if (n < 1000000000) return 9;
    return 10;
}
struct p{
  ll x;
  bool b;
};
int main(){
    ll a;
    cin>>a;
    
    ll t=1;
    REP1(i,a){
        t=(t*i)%MOD;
    }
    cout<<t;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll a[100010];
ll mi = INF, ma = 0;

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

  rep( i, N )
  {
    std::cin >> a[i];

    chmin( mi, a[i] );
    chmax( ma, a[i] );
  }

  if( llabs(ma-mi) > 1 || ma > N || mi > N )
  {
    puts("No");

    return 0;
  }

  if( ma == mi && (ma == 1 || ma == N-1 || N >= 2*ma) )
  {
    puts("Yes");

    return 0;
  }

  // ma = mi+1

  ll cnt = 0;

  rep( i, N )
  {
    if( a[i] == mi )
      ++cnt;
  }

  ll rest = N-cnt;

  repi( k, 1, rest )
  {
    if( rest-k >= k && cnt+k == ma )
    {
      puts("Yes");

      return 0;
    }
  }

  puts("No");

  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main(){
int a,b,d,r;
double f;

scanf("%d %d",&a,&b);
d=a/b;
r=a%b;
f=(double)a/b;

printf("%d %d %.5f",d,r,f);

return 0;
}

Measured memory_bytes: 1812
#include<iostream>
#define ll long long
#define MOD 1000000007
using namespace std;
ll int dfs(ll int *arr, ll int k,ll int n,ll int **dp)
{
    ll int *prefc=new ll int[k+1]();
    ll int *pref=new ll int[k+1]();
    if(n==0)
        return 0;
    
   for(int i=0;i<=n;i++)
   {
       dp[i][0]=1;
       
   }
    prefc[0]=1;
      pref[0]=1;
    for(int i=1;i<=n;i++)
    {
        
        for(ll int j=1;j<=k;j++)
        {
            if(i!=1)
            {
                if(j-arr[i-1]-1<0)
                    dp[i][j]=(prefc[j]%MOD);
                else
            dp[i][j]=(prefc[j]-prefc[j-arr[i-1]-1]+MOD)%MOD;
            }
            else if(j<=arr[i-1])
                dp[i][j]=1;
           
            pref[j]=(pref[j-1]%MOD+dp[i][j]%MOD)%MOD;
         
        }
       
        prefc=pref;
        pref=new ll int[k+1]();
        pref[0]=1;
    }
    return (dp[n][k]%MOD);
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll int n,k;
    cin>>n>>k;
    ll int *arr=new ll int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll int **dp=new ll int*[n+1];
    for(int i=0;i<=n;i++)
    {
        dp[i]=new ll int[k+1];
        for(int j=0;j<=k;j++)
            dp[i][j]=0;
    }
    cout<<dfs(arr,k,n,dp)%MOD;
    
}


Measured memory_bytes: 162296
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(ab[0] * ab[1]);
        }
    }
}


Measured memory_bytes: 28284
n, m = map(int,input().split())
a_l = []
for i in range(n):
    a_l.append(list(input()))
b_l = []
for i in range(m):
    b_l.append(list(input()))

ans = 'No'
for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        if a_l[i][j] == b_l[0][0]:
            for k in range(m):
                judge = a_l[i+k][j:j+m] == b_l[k]
                if judge == False:
                    break
            else:
                ans = 'Yes'

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i=0; i<N; i++) {
    cin >> s.at(i);
  }

  int M;
  cin >> M;
  vector<string> t(M);
  for (int i=0; i<M; i++) {
    cin >> t.at(i);
  }

  int maxIn = 0;

  for (int sIndex=0; sIndex<N; sIndex++) {

    int tmpMaxIn = 0;
    string str = s.at(sIndex);
    
    for (int tmpSIndex=0; tmpSIndex<N; tmpSIndex++) {
      if (str == s.at(tmpSIndex)) {
        tmpMaxIn += 1;
      }
    }

    for (int tmpTIndex=0; tmpTIndex<M; tmpTIndex++) {
      if (str == t.at(tmpTIndex)) {
        tmpMaxIn -= 1;
      }
    }

    if (maxIn < tmpMaxIn) {
      maxIn = tmpMaxIn;
    }
  }

  cout << maxIn << endl;
}


Measured memory_bytes: 256
a={'m':1000,'c':100,'x':10,'i':1}
for _ in range(int(input())):
    b,s,t=input(),0,1
    for x in b:
        if x==' ':continue
        if x in a:s+=a[x]*t;t=1
        else:t=int(x)
    ans=''
    for k in ['m','c','x','i']:
        c,s=divmod(s,a[k])
        if c:ans+=['',str(c)][c!=1]+k
    print(ans)

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N);
    vi s(N),vec;
    rep(i,N){
        cin>>s[i];
        if(s[i]%10!=0)vec.push_back(s[i]);
    }
    sort(all(vec));
    int ans=0;
    RepA(s)ans+=item;
    if(ans%10!=0)printf("%d\n",ans);
    else{
        if(vec.empty())printf("%d\n",0);
        else printf("%d\n",ans-vec[0]);
    }

    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(){
    int w,h,n; cin >> w >> h >> n;
    vector<vector<bool> > field(w+1,vector<bool>(h+1,true));
    for(int i = 0; i < n; i++) {
        int X,Y,a; cin >> X >> Y >> a;
        if(a==2){
            for(int x = X; x <= w; x++){
                for(int y = 0; y <= h; y++){
                    field[x][y] = false;
                }
            }
        }else if(a==1){
            for(int x = 0; x <= X-1; x++){
                for(int y = 0; y <= h; y++){
                    field[x][y] = false;
                }
            }
        }else if(a==4){
            for(int y = Y; y <= h; y++){
                for(int x = 0; x <= w; x++){
                    field[x][y] = false;
                }
            }
        }else{
            for(int y = 0; y <= Y-1; y++){
                for(int x = 0; x <= w; x++){
                    field[x][y] = false;
                }
            }
        }
        for(int i = 0; i < w; i++){
            for(int j = 0; j < h; j++){
                //cout << field[i][j];
            }
            //cout << endl;
        }
        //cout << " " << endl;
    }
    int count = 0;
    for(int i = 0; i < w; i++){
        for(int j = 0; j < h; j++){
            if(field[i][j] == true) count++;
            //cout << field[i][j];
        }
        //cout << endl;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func main() {
	a, b, k := readInt(), readInt(), readInt()
	for i := a; i <= min(b, a+k-1); i++ {
		fmt.Println(i)
	}
	for i := max(a+k, b-k+1); i <= b; i++ {
		fmt.Println(i)
	}
}


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

int main() {
	string s;
	cin >> s;
    
    int counter=0;
    
    if ( s[0] == '1') ++counter;
	if ( s[1] == '1') ++counter;
    if ( s[2] == '1') ++counter;

 	cout << counter << endl;

}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        System.Diagnostics.Debug.WriteLine("-----TextFile1");
        System.Diagnostics.Debug.WriteLine(process("../TextFile1.txt"));
        System.Diagnostics.Debug.WriteLine("-----TextFile2");
        System.Diagnostics.Debug.WriteLine(process("../TextFile2.txt"));
        System.Diagnostics.Debug.WriteLine("-----TextFile3");
        System.Diagnostics.Debug.WriteLine(process("../TextFile3.txt"));
#endif

        String ret = process(new System.IO.StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
    }

    static string processText(string input) {
        return process(new System.IO.StringReader(input));
    }

    static string process(string filePath) {
        using (var input = new System.IO.StreamReader(filePath)) {
            return process(input);
        }
    }

    static string process(System.IO.TextReader input) {
        var s     = input.ReadLine();
        var spl   = s.Split(' ');
        int n     = int.Parse(spl[0]);
        int d     = int.Parse(spl[1]);

        int[][] ary  = new int[n][];

        for(int i=0; i<n; i++) {
            ary[i] = ToIntArray(input.ReadLine(), d);
        }

        int count = 0;
        for(int i=0; i<n; i++) {
            for(int j=i; j<n; j++) {
                if (i == j) continue;
                if (calc(ary[i], ary[j], d)) count++;
            }
        }

        return count.ToString();
    }

    static bool calc(int[] xi, int[] xj, int size) {
        int v = 0;
        for(int i=0; i<size; i++) {
            int k = xi[i] - xj[i];
            v += k * k;
        }
        for(int i=0; ; i++) {
            int ii = i * i;
            if (ii == v) return true;
            if (ii > v) return false;
        }
    }
    
    static int[] ToIntArray(string strs, int n) {
        int[] ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++) ret[i] = int.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 11220
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

using namespace std;

typedef long long LL;

deque<char> deq;

char s[123456];

int main() {
    scanf("%s", s);
    for (int i = 0; s[i]; ++i) {
        deq.push_back(s[i]);
    }
    bool rev = false;
    int q;
    scanf("%d", &q);
    for (; q--; ) {
        int t;
        scanf("%d", &t);
        if (t == 1) {
            rev = 1 - rev;
        }
        else {
            int f; char c;
            scanf("%d %c", &f, &c);
            assert(c >= 'a' && c <= 'z');
            if (!rev) {
                if (f == 1) deq.push_front(c);
                else deq.push_back(c);
            } else {
                if (f == 1) deq.push_back(c);
                else deq.push_front(c);
            }
        }
    }
    if(rev) reverse(deq.begin(), deq.end());
    for_each(deq.begin(), deq.end(), [](char x) {
        printf("%c", x);
    });
    cout << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
struct UnionFind{
	vector<int> par,rank;
	UnionFind(int N){
		par.assign(N,0);
		rank.assign(N,0);
		for(int i=0;i<N;i++) par[i]=i;
	}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]) swap(x,y);
 
		par[y]=x;
		if(rank[x]==rank[y]) rank[x]++;
	}
};

signed main(){
    int N,m;
    cin>>N>>m;
    UnionFind uf(N);
    vector<int> p(N);
    for(int i=0;i<N;i++)cin>>p[i];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        uf.unite(x,y);
    }

    int res=0;
    for(int i=0;i<N;i++){
        if(uf.same(i,p[i]-1))res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 2560
use std::str::FromStr;
use std::fmt::Debug;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn outputH(){
    println!("Heisei");
}

fn main(){
    let line = read_as_string();

    let v: Vec<_> = line.split('/').collect();

    let _ = v[0].parse::<i32>().unwrap();
    let month = v[1].parse::<i32>().unwrap();
    let day = v[2].parse::<i32>().unwrap();

    if month < 4{
        println!("Heisei");
        return;
    }else if 4 < month{
        println!("TBD");
        return;
    }

    if day <= 30{
        println!("Heisei");
    }else{
        println!("TBD");
    }
}


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

int main(){
    char N[4];
    cin >> N;
    if(N[0] == N[1] && N[1] == N[2]) {
        cout << "Yes" << endl;
    } else if (N[1] == N[2] && N[2] == N[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import math

a,b,c,d = map(int,input().split())
ans = 0.0

e1 = (2 * math.pi) / 12
e2 = (2 * math.pi) / 60
e3 = (2 * math.pi) / (60 * 12)

a2 = c * e1 + d * e3
b2 = e2 * d


dif = abs(a2-b2)

ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(dif)) 


print(ans)

Measured memory_bytes: 9516
#include "bits/stdc++.h"
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define ll long long
#define ld long double
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
typedef pair<ll, ll> pll;
typedef vv<bool> vbool;
typedef vv<ll> vll;
typedef vv<ld> vld;
typedef vv<pll> vpll;
#ifdef LOCAL
#include "prettyprint.hpp"
#define LG(args...)                           \
{                                             \
	string _s = #args;                        \
	replace(_s.begin(), _s.end(), ',', ' ');  \
	stringstream _ss(_s);                     \
	err(istream_iterator<string>(_ss), args); \
	cerr << endl;                             \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
#define fastio
#else
#define LG(...)
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
#define endl "\n"
#endif
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;

int main(){
	fastio;
	ll q,w,e,r;
	cin>>q>>w>>e>>r;
	vll v = {q*e, q*r, w*e, w*r};
	sort(all(v));
	cout<<v.back();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
//#pragma GCC optimize(2)

using namespace std;

#define LL long long
#define Rint register int
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define pii pair<int ,int>
#define MS0(X) memset(X,0,sizeof(X))
#define MSf(X) memset(X,false,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define BR printf("--------------------\n")
#define pb push_back
#define rep(i,a,b) for(Rint i=a;i<=b;++i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dirx[8]={1,0,-1,0,1,-1,-1,1};
int diry[8]={0,1,0,-1,1,1,-1,-1};
LL a[maxn];
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int n;
    cin>>n;
    LL sum=0;
    LL ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=0;i<n;i++)
    {
        ans+=(sum-a[i])*a[i];
    }
    cout<<ans/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p[200005],hzh[200005]={0};
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,k;
    cin>>n>>k;
    for (int i=0;i<n;i++)
    {
        cin>>p[i];
        hzh[i+1]=hzh[i]+p[i];
    }
    int maxn=hzh[k];
    int t=0,o=k-1;
    for (int i=k+1;i<=n;i++)
    {
        if (hzh[i]-hzh[i-k]>maxn) {maxn=hzh[i]-hzh[i-k]; t=i-k; o=i-1;}
    }
    double ans=0;
    for (int i=t;i<=o;i++)
    {
        ans+=1.0*(p[i]+1)/2;
    }
    cout<<setiosflags(ios::fixed)<<setprecision(12)<<ans;
    return 0;
}

Measured memory_bytes: 1792
#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

#[allow(unused_imports)]
use std::cmp::{min,max};

fn main(){
    input!{
        x: [i32; 3],
    }
    let mut x = x;
    x.sort_by(|a,b| b.cmp(a));
    println!("{}", x[0]*10 + x[1] + x[2]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    int cnt=0;
    int f=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==b[i])cnt++;
        else
        {
            if(cnt>=3)f=1;
            cnt=0;
        }
    }
    //cout<<a[1]<<" "<<b[1]; 
    if(cnt>=3)f=1;
    if(f==1)cout<<"Yes";
    else cout<<"No";
        
}

 


Measured memory_bytes: 3628