akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void no() {
    cout << "Impossible\n";
    exit(0);
}

int cnt[MX];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;
    vi a(n);
    fi(0, n) {
        cin >> a[i];
        ++cnt[a[i]];
    }
    sort(all(a));
    int mx = a[n - 1];
    int mn = a[0];

    if (mn != (mx + 1) / 2 || cnt[mx] < 2)
        no();
    fi(mn + 1, mx + 1) 
        if (cnt[i] < 2)
            no();
    if (cnt[mn] != 1 + mx % 2)
        no();
    cout << "Possible\n";
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <cstring>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;
template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();

int main()
{
	ll N; cin >> N;
	vector<string> v( N );
	rep( i, N ) cin >> v[i];

	auto check = [&]( ll a, ll b ) {
		rep( i, N )
		{
			rep( j, N )
			{
				if ( v[(i + a) % N][(j + b) % N] != v[(j + a) % N][(i + b) % N] )
					return ( false );
			}
		}

		return ( true );
	};

	ll ans = 0;
	rep( i, N )
	{
		if ( check( i, 0 ) )
			ans += N;
	}

	cout << ans << endl;

	return ( 0 );
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, x;
  cin>>N>>x;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll ans = big;
  ll tmpans;
  for(int k=0;k<N;++k) {
    multiset<ll> st;
    for(int i=0;i<k;++i) {
      st.insert(A[N-1-i]);
    }
    tmpans = k*x;
    for(int i=0;i<N;++i) {
      st.insert(A[i]);
      tmpans += *st.begin();
      if(i>=k) st.erase(st.find(A[i-k]));
      else st.erase(st.find(A[N-(k-i)]));
    }
    ans = min(ans, tmpans);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;

int x[N], l[N];
pair<int, int> ps[N];

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> l[i];
    }
    for (int i = 0; i < n; i++) {
        ps[i] = make_pair(x[i] + l[i], x[i] - l[i]);
    }
    sort(ps, ps + n);
    int cur = INT_MIN, cnt = 0;
    for (int i = 0; i < n; i++) {
        if (cur <= ps[i].second) {
            ++cnt;
            cur = ps[i].first;
        }
    }
    cout << cnt << '\n';
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI
const ll MOD = 1e9 + 7;

/*

ll Mod(ll a, ll mod) {
    return (a%mod + mod)%mod;
}

ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if (n & 1) {
            res = res*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}

ll modinv(ll a, ll mod) {
    ll x, y;
    extGCD(a, mod, x, y);
    return Mod(x, mod);
}

ll nCr_mod(ll n, ll r, ll mod) {
    if ( n == r || n == 1 || r == 0 ) {
        return 1;
    }

    r = min(r, n-r);
    if ( r == 1 ) {
        return n;
    } else {
        ll n_to_n_r = n;
        ll r_to_1 = r;
        rep2(i, r-1) {
            n_to_n_r *= n-i;
            n_to_n_r %= mod;
            r_to_1 *= r-i;
            r_to_1 %= mod;
        }
        // r_to_1 = pow_mod(r_to_1, mod-2, mod);
        r_to_1 = modinv(r_to_1, MOD);
        return n_to_n_r*r_to_1%mod;
    }
}
*/

int main() {
    ll n, k;
    cin >> n >> k;
    // n++;
    ll ans = 0;

    if ( n+1 == k ) {
        ans++;
    } else {
        /*
        ll num = pow_mod(2, n, MOD)-1;
        rep(i, k) {
            num -= nCr_mod(n, i, MOD);
        }*/
        // ans = num;

        for (ll i = k; i <= n+1; ++i) {
            // ans += nCr_mod(n, i, MOD);
            ll min = i*(i-1)/2;
            ll max = i*(2*n-i+1)/2;
            ans += max-min+1;
        }
    }

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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

int a[1010];

void solve(){

  int n,m;
  cin >> n >> m;
  int s = 0;
  rep(i,n){
    cin >> a[i];
    s += a[i];
  }

  sort(a,a+n, greater<int>());
  bool b=true;
  rep(i,m){
    if(a[i]< double(double(s)/double(4*m))) b=false;
  }

  if(b) cout << "Yes" << endl;
  else cout << "No" << endl;



}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        String S = sc.next();

        for (int i = 0; i < 3; i++) {
            if (S.charAt(i) == S.charAt(i + 1)) {
                System.out.println("Bad");
                return;
            }
        }

        System.out.println("Good");
    }
}

		

Measured memory_bytes: 21844
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  cin >> c;
  vector<int> a(3), b(3);
  for (int i = 0; i < 3; ++i) b[i] = c[i][0];
  for (int i = 1; i < 3; ++i) a[i] = c[0][i] - b[0];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (a[j] + b[i] != c[i][j]) {
        cout << false << endl;
        return 0;
      }
    }
  }
  cout << true << endl;
}



Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M = MI()
AB = [tuple(MI()) for _ in range(N)]
AB.sort()

ans = 0
i = 0
while M > 0:
    A,B = AB[i]
    if M >= B:
        ans += A*B
        M -= B
        i += 1
    else:
        ans += A*M
        break
print(ans)


Measured memory_bytes: 86256
import sys
import math

x, k, d = map(int, input().split())

a = x-k*d
b = x+k*d

if(a >= 0):
	print(a)
elif(b <= 0):
	print(abs(b))
else:
	b = b % (d * 2)
	print(min(abs(b), abs(b - d * 2)))
	

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,k;
  cin>>n>>k;
  long long a[n+1],h[n+1];
  for(int i=1;i<=n;i++)cin>>h[i];
  a[1]=0;
  for(long long i=2;i<=n;i++){
    a[i]=2e9;
    long long dif=i-1ll*1;
    dif=min(dif,k);
     for(long long kk=1;kk<=dif;kk++)a[i]=min(a[i],a[i-kk]+abs(h[i]-h[i-kk]));
  }cout<<a[n];
}

Measured memory_bytes: 1792
#include <string>
#include <iostream>
#include <set>
#include <array>
#include <queue>

using namespace std;

// 文字列一つ受け取る場合
// string s;
// 整数(max 2^31-1 or 10^9)一つ受け取る場合
// int x;
// int k;
int n;
// set<int> a;
string s;

int main()
{
    cin >> n;
    cin >> s;
    set<int> rs;
    set<int> gs;
    set<int> bs;
    set<int> xs;
    set<int> ys;
    set<int> zs;

    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
            rs.insert(i);
        else if (s[i] == 'G')
            gs.insert(i);
        else
            bs.insert(i);
    }
    long long int fullCount = rs.size() * gs.size() * bs.size();
    if (rs.size() < gs.size())
    {
        xs = rs;
        if (gs.size() < bs.size())
        {
            ys = gs;
            zs = bs;
        }
        else
        {
            ys = bs;
            zs = gs;
        }
    }
    else
    {
        xs = gs;
        if (rs.size() < bs.size())
        {
            ys = rs;
            zs = bs;
        }
        else
        {
            ys = bs;
            zs = rs;
        }
    }
    long long int outCount = 0;
    for (auto x = xs.begin(); x != xs.end(); ++x)
    {
        for (auto y = ys.begin(); y != ys.end(); ++y)
        {
            int a = 2 * (*x) - *y;
            int b = 2 * (*y) - *x;
            int c;
            if ((*x + *y) % 2 == 0)
                c = (*x + *y) / 2;
            else
                c = -1;
            if (zs.find(a) != zs.end())
                outCount++;
            if (zs.find(b) != zs.end())
                outCount++;
            if (zs.find(c) != zs.end())
                outCount++;
        }
    }

    cout << fullCount - outCount;
}


Measured memory_bytes: 3508
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"

signed main(){
	cout<<fixed<<setprecision(7);
	int n = 0, m = 0;
	int a = 0, b = 0, c = 0, d = 0, e = 0;
	bool f = false, flag = true;
	string S;
	cin>>S;
	if(S[0] == S[1] &&S[1] == S[2]) f = true;
	if(S[2] == S[3] &&S[1] == S[2]) f = true;
	//cin>>n;
	
	//for(int i = 0; i < n; i++){
	//}
	
	cout<<yn(f)<<endl;
	// cout<<YN(f)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double c = sc.nextDouble()*(Math.PI/180);
        double S,L,h;
        
        S = (a * b * Math.sin(c))/2;
        L = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(c));
        h = (2 * S)/a;
        System.out.printf("%f\n%f\n%f\n",S,L,h);
    }
}


Measured memory_bytes: 28288
#include<iostream>
#include<string>
#include<vector>
#include<queue>
using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    int n=s.length();
    int m=t.length();
    vector<vector<int> > is(26);
    for(int i=0;i<n;i++){
        is[s[i]-'a'].push_back(i);
    }
    for(int i=0;i<n;i++){
        is[s[i]-'a'].push_back(i+n);
    }
    long long ans=0;
    int pos=0;
    for(int i=0;i<m;i++){
        int c = t[i]-'a';
        if(is[c].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        pos = *lower_bound(is[c].begin(),is[c].end(),pos) + 1;
        if(pos >= n){
            pos -=n;
            ans += n;
        }
    }
    ans += pos;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    if ((a + b) % 2LL) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (a + b) / 2LL << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  int c = 0;
  for (int i=0; i<N; i++) {
    int l,r;
    cin >> l >> r;
    c += (r-l+1);
  }
  cout << c << endl;
}




Measured memory_bytes: 3600
import math
num = int(input())
for i in range(num):
    lst = list(map(float, input().split()))
    xa, ya, ra = lst[0], lst[1], lst[2]
    xb, yb, rb = lst[3], lst[4], lst[5]

    d = math.sqrt((xa - xb)**2 + (ya - yb)**2)

    if ra + rb < d:
        print(0)

    elif d + min(ra, rb) < max(ra, rb):
        if ra < rb:
            print(-2)
        else:
            print(2)

    else:
        print(1)


Measured memory_bytes: 5672
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , x = 0;
    cin >> n;
    int a[n];
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
        x += a[i];
    }
    sort( a , a + n );
    if ( x % 10 == 0 ) {
        for ( int i = 0 ; i < n ; i++ ) {
            for ( int j = i ; j < n ; j++ ) {
                if ( ( x - a[j] ) % 10 > 0 ) {
                    cout << x - a[j];
                    return 0;
                }
            }
            x -= a[i];
        }
    } else {
        cout << x;
        return 0;
    }
    cout << 0;
}



Measured memory_bytes: 256
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define en "\n"
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*

/*ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
*/

/*void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; (ll)i*i <= 10000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*i ; j <= 10000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}  */


ll cdigit(ll n)
{ ll c=0,f=0;
 while(n>0){
 ll rem=n%10;
 c+=rem;
n=n/10;}
return c;
} 


ll div(ll n)
{
      ll c=0,i;
for(i=1;i*i<=n;i++)
{
      if(n%i==0)
      {
       c++;
           if(n/i!=i)
           {
                 c++;
           }
            
            
      }
}
      return c;
}



// *#########################################################################################*

int main()
{
      fast
 
    
      ll k,a,b;
      cin>>k>>a>>b;
      ll f=0,i;
      for(i=a;i<=b;i++)
      {
            if(i%k==0)
            {
                  f=1;
                  break;
            }
      }
      
      if(f==1)
      {
            o("OK")
      }
else
{
      o("NG")
}







re}

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

int main()
{
    int d, n;
    cin >> d >> n;
    if (n==100)
    {
        n += 1;
    }
    
    int div_num = 1;
    for (int i=0; i < d; ++i)
    {
        div_num *= 100;
    }
    cout << div_num*n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int r, d, x, xx, i;
    scanf("%d%d%d", &r, &d, &x);
    for (i = 0; i < 10; i ++) {
        xx = r * x - d;
        printf("%d\n", xx);
        x = xx;
    }
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  
  int ans, maxans = 1;
  for(int i = 2; i * i <= n; i++){
    ans = i;
    while(ans * i <= n){
      ans = ans * i;
    }
    if(ans > maxans){
      maxans = ans;
    }
  }
  
  cout << maxans << endl;
}

Measured memory_bytes: 3604
def resolve():
    X, N = map(int, input().split())
    if N != 0:
        P = list(map(int, input().split()))
        S = []
        for _ in range(0, 102):
            if _ in P:
                continue
            else:
                S.append(_)
        if X in S:
            print(X)
        else:
            for i in range(1, 102):
                if X-i in S:
                    print(X-i)
                    exit()
                elif X+i in S:
                    print(X+i)
                    exit()
    else:
        print(X)
resolve()

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

int main(){ 
    string n;
    cin >> n;
    for(int i=0;i<3;i++){
        if(n.at(i) == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" <<endl;
}

Measured memory_bytes: 3632
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    n, m = map(int, read().split())
    h = [int(i) for i in read().split()]
    s = [1] * n
    for _ in range(m):
        a, b = [int(i) - 1 for i in read().split()]
        if h[a] < h[b]:
            s[a] = 0
        elif h[a] > h[b]:
            s[b] = 0
        else:
            s[a] = 0
            s[b] = 0
    print(sum(s))

if __name__ == '__main__':
    main()

Measured memory_bytes: 20120
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	string  S;
	cin >> S;
	ll an = 0;
	rep(i, S.size()-1) {
		if (S.at(i) != S.at(i + 1)) {
			an++;
		}
	}
	cout << an << endl;;

}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  ll X, Y;
  cin >> X >> Y;
  if (X % Y == 0) {
    cout << -1 << endl;
    return 0;
  }
  ll ans = X;
  while (true) {
    if (ans % Y != 0) {
      cout << ans << endl;
      return 0;
    }
    ans += X;
  }
}

Measured memory_bytes: 3588
#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 n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    rep(i, m) cin >> l[i] >> r[i];
    sort(l.begin(), l.end());
    sort(r.begin(), r.end());
    int L = l[m - 1], R = r[0];
    int ans = R - L + 1;
    cout << max(ans, 0) << endl;
    return 0;
}

Measured memory_bytes: 3960
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; n],
    }
    let t = a.iter().sum::<usize>();
    let ans = if a.into_iter().filter(|&ai| ai * 4 * m >= t).count() >= m {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

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

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  // 
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,m;cin>>n>>m;
  int a[200000];
  int b[200000];
  vector<int> v,w;
  vector<int> summ(400000);
  vector<int>::iterator it;
  REP(i,m){
    cin>>a[i]>>b[i];
    if(a[i]==1){
      v.push_back(b[i]);
    }
    if(b[i]==n){
      w.push_back(a[i]);
    }
  }
  int sv=v.size();
  int sw=w.size();
  if(sv==0 || sw==0){
    P("IMPOSSIBLE");
    return 0;
  }
  sort(v.begin(), v.end());
  sort(w.begin(), w.end());
  it = set_intersection(v.begin(), v.end(), w.begin(), w.end(), summ.begin());
  summ.resize(it - summ.begin());
  if(summ.size() > 0){
    P("POSSIBLE");
  }else{
    P("IMPOSSIBLE");
  }
  return 0;
}


Measured memory_bytes: 4340
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    var k = sc.nextInt()

    for (i in Math.min(a, b) downTo 1) {
        if (a % i == 0 && b % i == 0) {
            k--
        }
        if (k == 0) {
            println(i)
            break
        }
    }
}

Measured memory_bytes: 29476
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void) {
    int X;

    scanf("%d", &X);

    if( X < 600 )       printf("8\n");
    else if( X < 800 )  printf("7\n");
    else if( X < 1000 ) printf("6\n");
    else if( X < 1200 ) printf("5\n");
    else if( X < 1400 ) printf("4\n");
    else if( X < 1600 ) printf("3\n");
    else if( X < 1800 ) printf("2\n");
    else if( X < 2000 ) printf("1\n");
    
    return 0;
}


Measured memory_bytes: 1644
# 完成形から考える問題
n = gets.chomp.to_i
s = gets.chomp.chars

black_count = 0

s.each { |val| black_count += 1 if val == "#" }

left_b = 0
left_w = 0
right_b = black_count
right_w = n - black_count

ans = left_b + right_w


n.times do |i|

  if s[i] == '#'
    left_b += 1
    right_b -= 1
  else
    left_w += 1
    right_w -= 1
  end
  ans = [ans, left_b + right_w].min
end

p ans




Measured memory_bytes: 18812
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 100000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 61
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define mat vector<vector<T>>
#define T long long
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define cld complex<long double>
using namespace std;

int main(){
	fast_io();
	int n;cin >> n;
	vector<pll> v(n);
	cu(i,0,n)cin >> v[i].S >> v[i].F;
	sort(all(v));
	ll rsum = 0;
	bool ans = true;
	cu(i,0,n){
		rsum+=v[i].S;
		if(rsum > v[i].F){ans = false;break;}
	}
	cout << (ans?"Yes":"No") << '\n';
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b;
  cin>>a>>b;
  int ans = 0;
  FOR(m,1,13){
    if(a>m || (a==m && b>=m))ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int64_t N, A, ans = 0;
    cin >> N >> A;
    vector<vector<vector<int64_t>>> X(N + 1, vector<vector<int64_t>> (2501, vector<int64_t> (50)));
    for (int i = 0; i < N; i++) {
        int64_t a;
        cin >> a;
        for (int j = 0; j < 2451; j++) {
            if (j == 0) {
                X.at(i + 1).at(a).at(0)++;
                continue;
            }
            for (int k = 1; k < 50; k++){
                if (X.at(i).at(j).at(k - 1) != 0) {
                    X.at(i + 1).at(j + a).at(k) += X.at(i).at(j).at(k - 1);
                }
            }
        }
        if (i != N - 1) {
            X.at(i + 2) = X.at(i + 1);
        }
    }
    for (int i = 1; i < 2501; i++) {
        for (int j = 0; j < 50; j++) {
            if (i / (j + 1) == A && i % (j + 1) == 0) {
                ans += X.at(N).at(i).at(j);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 56192
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

const int maxn = 2010;
int n, k, q;
int a[maxn], tmp[maxn], tt[maxn];
int tot = 0, cnt = 0;
typedef long long ll;
int ans = 0x7fffffff;

vector<int> vec;

int main() {
    scanf("%d%d%d", &n, &k, &q);
    for (int i = 1; i <= n; i++) {scanf("%d", &a[i]); vec.push_back(a[i]);}
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    for (int x = 0; x < vec.size(); x++) {
        int t = vec[x]; tot = 0;
        int lastl = 1;
        for (int i = 1; i <= n; i++) {
            if (a[i] < t) {
                if (i-1 >= lastl) {
                    int l = lastl, r = i-1;
                    cnt = 0;
                    for (int j = l; j <= r; j++) {
                        tmp[++cnt] = a[j];
                    }
                    sort(tmp+1, tmp+cnt+1);
                    int y = cnt-k+1;
                    for (int j = 1; j <= y; j++) tt[++tot] = tmp[j];
                }
                lastl = i+1;
            }
        }
        if (lastl <= n) {
            int l = lastl, r = n;
            cnt = 0;
            for (int j = l; j <= r; j++) {
                tmp[++cnt] = a[j];
            }
            sort(tmp+1, tmp+cnt+1);
            int y = cnt-k+1;
            for (int j = 1; j <= y; j++) tt[++tot] = tmp[j];
        }
        sort(tt+1, tt+tot+1);
        if (tot >= q) {
            ans = min(ans, tt[q]-t);
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int n;
int a[2000];

long long k, m = 0, kl, kr;
long long r[2000], l[2000];
const long long T = 1000000007;

int main()
{	
	cin >> n >> k;

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

	for (int i = 0; i < n; i++) {
		l[i] = 0;
		r[i] = 0;

		for (int j = 0; j < n; j++) {
			if (a[j] < a[i]) {
				if (j < i)
					l[i]++;
				else
					r[i]++;
			}
		}
	}

	if (k % 2 == 0) {
		kl = (k / 2) * (k - 1) % T;
		kr = (k / 2) * (k + 1) % T;
	}
	else {
		kl = ((k - 1) / 2) * k % T;
		kr = ((k + 1) / 2) * k % T;
	}

	for (int i = 0; i < n; i++) {
		m = (m + (l[i] * kl % T)) % T;
		m = (m + (r[i] * kr % T)) % T;
	}

	cout << m << endl;

	return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
H, W = map(int,input().split(' '))
S = []
dj = [-1, -1, -1, 0, 0, 1, 1, 1]
dk = [-1, 0, 1, -1, 1, -1, 0, 1]

for i in range(H):
  S.append(input())
for j in range(H):
  answer = list(S[j])
  for k in range(W):
    cnt = 0
    if S[j][k] == '#':
      pass
    if S[j][k] == '.':
      for d in range(8):
        if 0 <= j+dj[d] <= H-1:
          if 0 <= k+dk[d] <= W-1:
            if S[j + dj[d]][k+dk[d]] == '#':
              cnt += 1
      answer[k] = str(cnt)
  print(''.join(answer))

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

int d[333333];
int op(int a, int b) { return max(a, b); }
int e() { return 0; }
int main() {
    int n, k;
    cin >> n >> k;
    atcoder::segtree<int, op, e> b(333333);
    int r = 0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        int x = b.prod(max(a - k, 0), a + 1);
        int y = b.prod(a, min(a + k + 1, 333333));
        d[i + 1] = max(d[x], d[y]) + 1;
        r = max(r, d[i + 1]);
        b.set(a, i + 1);
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 8836
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    A = kwargs["A"]
    q = kwargs["q"]
    B = kwargs["B"]
    C = kwargs["C"]
    cnt = dict(collections.Counter(A))
    res = [sum(A)]

    for i in range(q):
        if B[i] in cnt.keys():
            res.append(res[-1] + (C[i] - B[i]) * cnt[B[i]])

            if C[i] in cnt.keys():
                cnt[C[i]] += cnt[B[i]]

            else:
                cnt[C[i]] = cnt[B[i]]

            cnt[B[i]] = 0

        else:
            res.append(res[-1])

    res = "\n".join([str(i) for i in res[1:]])
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["n"] = [int(i) for i in cin][0]

    cin = input().split()
    kwargs["A"] = [int(i) for i in cin]

    cin = input().split()
    kwargs["q"] = [int(i) for i in cin][0]

    kwargs["B"] = []
    kwargs["C"] = []
    for i in range(kwargs["q"]):
        cin = input().split()
        b, c = [int(i) for i in cin]
        kwargs["B"].append(b)
        kwargs["C"].append(c)

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 58856
from itertools import product

n, m = map(int, input().split())
switches = []
for _ in range(m):
    x = list(map(int, input().split()))[1:]
    temp = []
    for i in range(n):
        if i + 1 in x:
            temp.append(1)
        else:
            temp.append(0)
    switches.append(temp)
p = list(map(int, input().split()))

ans = 0
for on_off in product([1, 0], repeat=n):
    flag = 1
    for i, switch in enumerate(switches):
        cnt = 0
        for x, y in zip(on_off, switch):
            if x == 1 and y == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            flag = 0
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int n;
int pulus[20010];
int s[20010];
int main(void){
	cin >> n;
	rep(i, 20010) pulus[i] = 0;	
	
	
	rep(i, n){
		int a; cin >> a;
		pulus[a] = i;
	}
	
	

	int now = 1;
	for (int i = 1; i <= n; ++i){
		s[i] = now;
		now += 50000;
	}


	// printf("i %d\n", s[20000]);
	
	for (int i = 1; i <= n; ++i){
		printf("%d ", pulus[i] + s[i]);
	}
	printf("\n");
	for (int i = 1; i <= n; ++i){
		printf("%d ", 1000000000 - s[i]);
	}
	
	printf("\n");
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const int D_MIN=1000000001;
int n,k,diff_min=D_MIN;
int main()
{
  cin>>n>>k;
  int h[n];
  for(int i=0;i<n;++i)
  {
    cin>>h[i];
  }
  sort(h,h+n);
  for(int i=0;i<=(n-1)-(k-1);++i){
    diff_min=min(diff_min,h[i+(k-1)]-h[i]);
  }
  cout<<diff_min;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>

using namespace std;

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

const ll mod = 998244353;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll dp[3100][3100];

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

    ll a[3100];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    for(int i = 0; i < N; i++){
        dp[i][i] = a[i];
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; j + i < N; j++){
            dp[j][j+i] = max(a[j] - dp[j+1][j+i], a[j+i] - dp[j][j+i-1]);
        }
    }

    cout << dp[0][N-1] << endl;

    

    return 0;
}

Measured memory_bytes: 73984
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int x = r * 100 + g * 10 + b;
    cout << ((x % 4 == 0) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int LL;
//Unionfind P.84
int par[100000];
int rnk[100000];
void set(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        rnk[i]=0;
    }
}
int find(int x){//根を探す
    if(par[x]==x)return x;
    else return par[x]=find(par[x]);
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    
    if(rnk[x]<rnk[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(rnk[x]==rnk[y])rnk[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}

int main(void){
    LL n,i,j,ans=0;
    int m,a,b;
    cin>>n>>m;
    set(n);
    for(i=0;i<m;i++){
        cin>>a>>b;
        unite(a-1,b-1);
    }
    for(i=1;i<n;i++){
        if(same(0,i)==false){
            unite(0,i);
            ans++;
        }
    }
    cout<<ans;
    /*for(i=0;i<n;i++){
        cout<<endl<<find(i);
    }
    //*/
}


Measured memory_bytes: 4368
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a=I()
    b=I()
    h=I()
    print(((a+b)*h)//2)

main()


Measured memory_bytes: 38256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<map>
using namespace std;
map<long long,long long>m;
map<long long ,long long> ::iterator it;
long long a[222222];
long long sum=0;
int main()
{
    long long n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(m.count(a[i])==0) m[a[i]]=1;
        else m[a[i]]++;
    }
    for(it=m.begin();it!=m.end();it++)
        if(it->second>=2) sum+=(it->second*(it->second-1)/2);
    for(int i=1;i<=n;i++)
    {
        sum-=(m[a[i]]-1);
        printf("%lld",sum);
        sum+=(m[a[i]]-1);
        puts("");
    }
    
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root, NIL;

void insert(int);
void inorder(Node);
void preorder(Node);
Node treeSearch(Node, int);

int main(){
  
  int n, i, x;
  char com[10];
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( strcmp(com, "insert") == 0 ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( strcmp(com, "find") == 0 ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

void insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  
  if ( y == NIL ){
    root = z;
  }
  else if (z->key < y->key) {
    y->left = z;
  }
  else {
    y->right = z;
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

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

Measured memory_bytes: 19364
s= input()
t = input()
ls = len(s)
lt = len(t)
dp = [[0 for _ in range(lt+1) ]  for _ in range(ls+1)] #dp[i][j] sがi文字目,tがj文字目まででのLCS
for ids in range(1,ls+1):
    for idt in range(1,lt + 1):
        #一致してたら文字を足す
        if s[ids-1] == t[idt-1]:
            dp[ids][idt] =dp[ids-1][idt-1] + 1
        #違っていたら、長い方の文字を採用
        elif s[ids-1] != t[idt-1]:
            if dp[ids][idt-1] >= dp[ids-1][idt]:
                dp[ids][idt] = dp[ids][idt-1]
            else:
                dp[ids][idt] = dp[ids-1][idt]
ans = ''
num=dp[-1][-1]
ids = ls;idt=lt
while num:
    if dp[ids][idt] == dp[ids][idt-1]:
        idt -= 1
    elif dp[ids][idt] == dp[ids-1][idt]:
        ids -=1
    elif dp[ids][idt] ==dp[ids-1][idt-1] + 1:
        ans += s[ids-1]
        num -=1
        idt -= 1
        ids -=1
print(ans[::-1])



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

int main(){
  int n,a;
  cin >> n;
  int count=0;
  int min_count=1000000000;
  
  while(n>0){
    cin >> a;
    while(a%2 == 0){
      count += 1;
      a /= 2;
    }
    
    if(min_count > count){
      min_count = count;
    }
    count = 0;
    n--;
  }
  cout << min_count << endl;
}

Measured memory_bytes: 3552
#include<iostream>
#include<math.h>
#include<string>

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;
	if (A >= 13){
		cout << B << endl;
	}
	else{
		if (A <= 5){
			cout << 0 << endl;
		}
		else{
			cout << B / 2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

ans = 0
for i in range(1, max(h) + 1):
    mode = 0
    for j in range(n):
        if mode == 0:
            if h[j] < i:
                continue
            else:
                mode = 1
                ans += 1
        else:
            if h[j] >= i:
                continue
            else:
                mode = 0

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int N = 100010;
const int oo = 100000000;
int v[N], n, dp[N][2];
int f(int i, int pos){
    if(dp[i][pos] != -1) return dp[i][pos];
    if(i == n - 1) return abs(v[i] - v[i - pos]);
    if(i > n) return oo;
    if(i == n - 2)
        return dp[i][pos] = f(i + 1, 1) + abs(v[i] - v[i - pos]);
    else return dp[i][pos] = min(f(i + 1, 1), f(i + 2, 2)) + abs(v[i] - v[i - pos]);
}
int main(){
    memset(dp, -1, sizeof dp);
	cin >> n;
	for(int i = 0; i < n; i++)
        cin >> v[i];
    cout << min(f(1, 1), f(2, 2)) << "\n";
	return 0;
}


Measured memory_bytes: 7844
import java.util.Scanner;
 public class Main {
 public static void main(String[] args) {
 // ?¨??????\??????????????????????????????????????? 
Scanner sc = new Scanner(System.in);
 int w = sc.nextInt();
 int n = sc.nextInt();
 int i;
 int c = 0;
 int[] values = new int[w];
 for (i = 0; i < values.length; i++) { 
values[i] = i + 1; 
} 
for (i = 0; i < n; i++) {
 String str = sc.next();
 String[] ab = str.split(",");
 int a = Integer.parseInt(ab[0]) - 1;
 int b = Integer.parseInt(ab[1]) - 1;
 // a??¨b????????£???values??????????????????
 c = values[a];
 values[a] =  values[b];
 values[b] =  c; 
}
 // values??????????????????
 for(i = 0;i<w;i++){
   System.out.println(values[i]);
}   
}
 }

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

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    ll max_hp = 0;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        max_hp = max(max_hp, h[i]);
    }
    stack<ll> st;
    ll t_min = 1, t_max = 1000000000;
    ll t;
    while(t_min <= t_max){
        t = (t_min + t_max)/2;
        ll additional = 0;
        for(int i = 0; i < n; i++){
            ll res = max(0LL,h[i]-b*t);
            additional += res/(a-b);
            if(res%(a-b)>0){additional++;}
        }
        if(additional>t){
            t_min = t+1;
        }else if(additional<t){
            st.push(t);
            t_max = t-1;
        }else{
            st.push(t);
            break;
        }
    }

    cout << st.top() << endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
for i in range(0, n - 1):
    diff = h[i + 1] - h[i]
    if diff >= 1:
        h[i + 1] -= 1
    elif diff < 0:
        print("No")
        exit()
print("Yes")

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

int main(){
    long long x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<long long> a(x),b(y),c(z),ans;

    for(long long i = 0; i < x; i++) cin >> a[i];
    for(long long i = 0; i < y; i++) cin >> b[i];
    for(long long i = 0; i < z; i++) cin >> c[i];
    
    sort(a.begin(),a.end(),greater<long long>());
    sort(b.begin(),b.end(),greater<long long>());
    sort(c.begin(),c.end(),greater<long long>());

    for(long long i = 0; i < x; i++)
    {
        for(long long j = 0; j < y; j++)
        {
            if ((i+1)*(j+1)>k) break;
            for(long long l = 0; l < z; l++)
            {
                if ((i+1)*(j+1)*(l+1)>k) break;
                ans.push_back(a[i]+b[j]+c[l]);
            }     
        }       
    }
    
    sort(ans.begin(),ans.end(),greater<>());

    for(long long i = 0; i < k; i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 1404