akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(5e6),Finverse(5e6);
void Cinit(){// limit is 5e6 /// write Cinit&pw /// this takes 792ms at AtCoder
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=Factorial[i-1]*i%MOD;
  for(int i=0;i<5e6;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 1;if(k<0)return 0;
  int res=Factorial[n];
  res*=Finverse[k];res%=MOD;
  res*=Finverse[n-k];res%=MOD;
  return res;
}

int N,A,B,C;

int f(int M){
  int res=nCk(M-1,N-1);
  int tmp=pw(A,M-N)*pw(B,N)%MOD+pw(B,M-N)*pw(A,N)%MOD;
  tmp*=M;tmp%=MOD;
  res*=tmp;res%=MOD;
  tmp=pw(100,M-1);
  tmp*=(100-C);tmp%=MOD;
  res*=pw(tmp,MOD-2);res%=MOD;
  return res;
}

signed main(){
  Cinit();
  cin>>N>>A>>B>>C;
  A*=100;A*=pw(100-C,MOD-2);A%=MOD;
  B*=100;B*=pw(100-C,MOD-2);B%=MOD;
  int ans=0;
  for(int M=N;M<2*N;M++)ans+=f(M),ans%=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 78336
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
    pi,si=input().split()
    pi=int(pi)-1
    if ac[pi]==1:
        pass
    elif si=="AC":
        ac[pi]=1
    else:
        wa[pi]+=1
print(sum(ac),sum([wa[x] for x in range(n) if ac[x]==1]))

Measured memory_bytes: 51416
# include<bits/stdc++.h>
using namespace std;
int main(){
	int n, k,res = 0;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
  	int temp;
    cin >> temp;
    if(temp > k-1)
      res += 1;
  }
  cout << res <<'\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
void out(vector<int> a,int n){
    rep(j,n){
        cout << a[j];
        if(j!=n-1) cout << " ";
    }
    cout << endl;
}

void selectionSort(vector<int> a,int n){
    int cnt = 0;
    rep(i,n){
        int minj = i;
        for(int j=i;j<n;j++){
            if(a[j]<a[minj]) minj = j;
        }
        swap(a[i],a[minj]);
        if(i!=minj) cnt++;
    }
    out(a,n);
    cout << cnt << endl;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    selectionSort(a,n);
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    int n = 1;
    while(N > n * (n + 1) / 2) n++;
    while(N > 0){
        int t = min(N, n);
        Out(t);
        N -= t;
        n--;
    }

    return 0;
}


Measured memory_bytes: 256
//#define DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))

#define fi first
#define sc second 
#define pb push_back


#ifdef DEBUG
    #define dbg(s) {s;}
    #define PRELUDE
#endif

#ifndef DEBUG 
    #define PRELUDE { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define dbg(s)
    #define endl "\n"
#endif

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

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

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

// To remove randomization use 0 below:
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int x) { // from [0, n-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

inline ld rf() { // from [0, 1]
    return uniform_real_distribution<ld>(0, 1)(rng);
}

ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    x = x%mod;
    ex = ex % (mod-1);
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e5 + 7;

const ll inf = 1e9 + 7;

int ans[maxn];
int h[maxn];

void solve()
{
    int n, k;
    cin>>n>>k;

    for(int i=1;i<=n;i++)
        cin>>h[i];
    ans[1] = 0;
    for(int i=2;i<=n;i++)
    {
        ans[i] = ans[i-1] + abs(h[i]-h[i-1]);

        for(int j=2;j<=k;j++)
        {
            if(i==j)
                break;
            ans[i] = min(ans[i],ans[i-j] + abs(h[i]-h[i-j]) );
        }
    }

    cout<<ans[n]<<endl;
}

i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);
    
    PRELUDE;
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 1792
def q2(in_num, in_str):
    o_str = ""
    letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    for i in range(len(in_str)):
        o_str += (letters[(letters.index(in_str[i])+int(in_num))%26])
    return o_str

print(q2(input(),input()))

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;  
int main() {  
 int a,b,c;
 cin>>a>>b>>c;
 if(a==b+c||b==a+c||c==a+b){
  cout  <<  "Yes"  <<  endl; 
 }
 else cout << "No" <<endl;
}

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

int main()
{
	int n,sum=0,x;
	cin>>n;
	x=n;
	while(x>0)
	{
		sum+=x%10;
		x=x/10;
	}
	if(n%sum==0) cout<<"Yes"<<endl;
	else         cout<<"No"<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin >> n >> k;
	vector<int> d(k);
	vector<int> s(n+1);
	for (int i = 0; i < k; ++i)
	{
		cin >> d.at(i);
		vector<int> a(d.at(i));
		for (int k = 0; k < d.at(i); ++k)
		{
			cin >> a.at(k);
		}
		for (int j=0;j<d.at(i); ++j)
		{
			s.at(a.at(j))++;
		}
	}
	int count=0;
	for (int i = 0; i < n+1; ++i)
	{
		if(s.at(i)==0){
			count++;
		}
	}
	cout << count-1 << endl;
	}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pb push_back()
#define ll long long
#define pi pair<int,int>
using namespace std;
const int mod = 1e9+7;
ll power(ll a, ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a,b-1)*a)%mod;
	ll q = power(a,b/2);
	return (q*q)%mod;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
  ll n;
  cin>>n;
  ll p1= power(8,n);
  ll p2=power(9,n);
  ll p3 = p2;
  ll p4=(p2+p3-p1+mod)%mod;
  ll p5=power(10,n);
  ll ans  = (p5-p4+mod)%mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
using namespace std;

char bits[11];
int main()
{
    long long ans = 0;
    int N;
    char S[11];
    scanf("%s", S);
    N = strlen(S);
    for (int i = (1 << (N - 1)); i < (1 << N); ++i) {
        for (int j = 0; (1 << j) < (1 << N); ++j) {
            if (((1 << j) & i) != 0) {
                bits[j] = '1';
            } else {
                bits[j] = '0';
            }
        }
        long long nr = S[0] - '0';
        for (int j = 0; (1 << j) < (1 << N - 1); ++j) {
            if (bits[j] == '0') {
                nr = nr * 10 + (S[j + 1] - '0');
            } else {
                ans += nr;
                nr = (S[j + 1] - '0');
            }
        }
        if (nr != 0) {
            ans += nr;
        }
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
 vector<vector<char>> c(2,vector<char>(3));
 rep(i,2){
    rep(j,3){
       cin >> c.at(i).at(j);
    }
 }
 bool a=true;
 if(c.at(0).at(0)!=c.at(1).at(2))a=false;
 else if(c.at(0).at(1)!=c.at(1).at(1))a=false;
 else if(c.at(0).at(2)!=c.at(1).at(0))a=false;
 if(a)cout << "YES" << endl;
 else cout << "NO" << endl;
}

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

int main() {
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int64_t N;
  cin>>N;
  int64_t sum=0;
  int64_t sqsum=0;
  int64_t answer=0;
  vector<int64_t> c(N);
  rep(i,N){
    cin>>c[i];
    sum+=c[i];
    sqsum+=c[i]*c[i];
    sum=sum%2000000014;
    sqsum=sqsum%2000000014;
  }
  sum=sum*sum;
  sum=sum%2000000014;
  answer=(sum-sqsum)%2000000014;
  answer=answer/2;
  answer=answer%1000000007;
  if(answer<0)
    answer=answer+1000000007;
  cout<<answer;
}

Measured memory_bytes: 4836
H, W = map(int, input().split())
L = []
for i in range(H):
 L.append(list(map(str, input().split())))

print("#" * (W + 2))
for i in range(H):
 print("#", end="")
 for j in L[i]:
  print(j, end="")
 print("#")
print("#" * (W + 2))

Measured memory_bytes: 3060
if __name__ == '__main__':

	n = int(input())
	A = list(map(int,input().split()))
	B = []

	for i,j in enumerate(A):
		if j > 0:
			if j not in B:
				B.append(j)
			else:
				print(i+1)
				break

		else:
			if len(B) != 0:
				p = B[-1]
				if p != abs(j):
					print(i+1)
					break
				else:
					B.pop(-1)
			else:
				print(i+1)
				break

	else:
		print("OK")



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    int n;
    cin>>n;
    double sum=0;
    rep(i,n){
        double x;
        string u;
        cin>>x>>u;
        if(u=="JPY") sum+=x;
        else sum+=x*380000;
    }
    cout<<fixed<<setprecision(10)<<sum<<endl;
    return 0;
}

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

using namespace std;

const int N = 3e5 + 7;

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector < pair < int,int > > vt(n);
    for(int i = 0 ; i < n ; ++i) {
        cin >> vt[i].first >> vt[i].second;
    }
    bool can = false;
    for(int i = 0 ; i< n - 2 ; ++i) {
        if(vt[i].first == vt[i].second and vt[i + 1].first == vt[i + 1].second and vt[i + 2].first == vt[i + 2].second) {
            can = true;
            break;
        }
    }
    if(can) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            ReadString();
            var problems = ReadIntArray().GroupBy(x => x).ToDictionary(g => g.Key, g => g.Count());
            ReadString();
            var tests = ReadIntArray();
            bool ans = tests.GroupBy(x => x).All(g => problems.GetValueOrDefault(g.Key) >= g.Count());
            Console.WriteLine(ans ? "YES" : "NO");
        }

        static TValue GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key)
        {
            TValue value;
            dictionary.TryGetValue(key, out value);
            return value;
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 54672
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N;
	pair<long long int, pair<long long int, long long int>> A[100010]; 
	for(int i = 0; i < N; i++){
		cin >> A[i].second.first >> A[i].second.second; 
		A[i].first = A[i].second.first + A[i].second.second; 
	}
	sort(A, A+N); 
	long long int ans = 0; 
	for(int i = 0; i < N; i++){
		if((N-1) % 2 == i % 2){ans += A[i].second.first;} 
		else{ans -= A[i].second.second;}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9 + 7;
pair<ll, ll>s4[4] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
pair<ll, ll>s8[8] = {{ -1, -1}, { -1, 0}, { -1, 1}, {0, -1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}};

void judge() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

void solve() {
	ll n, k;
	cin >> n >> k;
	ll a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	ll sum = 0;
	sort(a, a + n);
	for (int i = 0; i < k; i++) {
		sum += a[i];
	}
	cout << sum << nl;
}

signed main() {
	judge();
	boost;
	solve();
}


Measured memory_bytes: 3664
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL fac[200010],inv[200010];
void pre()
{
	inv[0]=inv[1]=fac[0]=fac[1]=1;
	for(LL i=2;i<=200000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(LL i=2;i<=200000;i++) inv[i]=inv[i-1]*inv[i]%mod,fac[i]=fac[i-1]*i%mod;
}
LL C(LL m,LL n) {return fac[m]*inv[m-n]%mod*inv[n]%mod;}
LL n,m,k,f[3010];
struct node{LL x,y;}a[3010];
bool cmp(node a,node b) {return a.x==b.x?a.y<b.y:a.x<b.x;}
int main()
{
	pre();
	scanf("%lld %lld %lld",&n,&m,&k);
	for(LL i=1;i<=k;i++)
	{
		scanf("%lld %lld",&a[i].x,&a[i].y);
		if((a[i].x==1&&a[i].y==1)||(a[i].x==n&&a[i].y==m)) return puts("0"),0;
	}
	a[++k].x=n;a[k].y=m;
	sort(a+1,a+k+1,cmp);
	for(LL i=1;i<=k;i++)
	{
		f[i]=C(a[i].x+a[i].y-2,a[i].x-1);
		for(LL j=1;j<i;j++)
			if(a[j].x<=a[i].x&&a[j].y<=a[i].y)
			{
				LL x=a[i].x-a[j].x,y=a[i].y-a[j].y;
				(f[i]-=f[j]*C(x+y,x))%=mod;
			}
		//printf("%lld %lld %lld\n",a[i].x,a[i].y,f[i]);
	}
	printf("%lld",(f[k]+mod)%mod);
}


Measured memory_bytes: 3456
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

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

	long a[n];
	rep(i,0,n)
		cin >> a[i];

	long long rui = 0;
	long long ans1 = 0;
	
	rep(i,0,n){
		rui += a[i];
		if( i % 2 ){
			if(rui >= 0){
				ans1 += abs( rui - (-1) );
				rui = -1;
			}
		}
		else{
			if(rui <= 0){
				ans1 += abs( rui - 1 );
				rui = 1;
			}
		}
	}
	

	rui = 0;
	long long ans2=0;
	rep(i,0,n){
		rui += a[i];
		if( i % 2 == 0 ){
			if(rui >= 0){
				ans2 += abs( rui - (-1) );
				rui = -1;
			}
		}
		else{
			if(rui <= 0){
				ans2 += abs( rui - 1 );
				rui = 1;
			}
		}
	}
	

	if( ans1 < ans2 )
		P(ans1);
	else
		P(ans2);
	
	ret 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,t;
	cin>>a>>b>>t;
	puta((t/a)*b);
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

vector<bool> IsPrime;
void e_sieve(int size){
    size=max(2,size);
    IsPrime.assign(size,true);
    IsPrime[0]=false;
    IsPrime[1]=false;
    int chk=2;
    while(chk*chk<=size) {
        int tchk=chk*2;
        while(tchk<=size){
            IsPrime[tchk]=false;
            tchk+=chk;
        }
        chk++;
    }
}

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int q;
    cin >> q;
    vector<int> l(q);
    vector<int> r(q);
    int rx=0;
    for(int i = 0; i < q; i++) {
        cin >> l[i] >> r[i];
        rx=max(r[i],rx);
    }
    rx++;
    e_sieve(rx);
    vector<int> cnt(rx);

    int add=0;
    for(int i = 0; i < rx; i++) {
        if(IsPrime[i]==true && IsPrime[(i+1)/2]==true) add++;
        cnt[i]=add;
//        cout << cnt[i] << " ";
    }
    for(int i = 0; i < q; i++) {
        int tans=cnt[r[i]]-cnt[l[i]-1];
        cout << tans << "\n";
//        cout << cnt[r[i]+1] << " " << cnt[l[i]] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{

	int coin_num, cnt, price, change;
	int coin_kind[] = {500, 100, 50, 10, 5, 1};

	while(scanf("%d", &price), price > 0) {
		coin_num = 0;
		cnt = 0;
		change = 1000 - price;
		while(change > 0) {
			if(change - coin_kind[cnt] >= 0) {
				coin_num++;
				change -= coin_kind[cnt];
			}
			else {
				cnt++;
			}
		}
		printf("%d\n", coin_num);
	}

	return 0;

}

Measured memory_bytes: 600
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

struct num_t {
	int idnum;
	int a;
} ;

int compare_num(const void *a, const void *b) {
  struct num_t *A = (struct num_t *)a;
  struct num_t *B = (struct num_t *)b;
  return A->a - B->a;
}


int main(void)
{
	//変数の宣言
	int n;
	static struct num_t num[100010];;
	static int b[100010];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	//データの読み込み
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&num[i].a);
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<n;i++){
		b[i]=i%2;
		num[i].idnum=i%2;
	}
	
	qsort(num,n,sizeof(struct num_t),compare_num);
	
	for(i=0;i<n;i++){
		ans=ans+(num[i].idnum+b[i])%2;
	}
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%d",ans/2);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 2172
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <limits>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define x first
#define y second
#define sf scanf
#define pf printf
#define vec vector
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define clr(a,b) memset(a,b,sizeof(a))
#define bin_cnt(x) __builtin_popcount(x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define srep(sub,s) for(int sub=s&(s-1);sub;sub=(sub-1)&s)
#define irep(i,a) for(__typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define irrep(i,a) for(__typeof(a.rbegin()) i=a.rbegin();i!=a.rend();i++)
#define inf numeric_limits<int>::max()
#define finf numeric_limits<double>::infinity()
#define eps 1e-8
#pragma GCC optimize ("O3")
#define o3 __attribute__((optimize("O3")))
#pragma comment(linker, "/STACK:32505856")

template<class T> inline T sqr(T a) {return a*a;}
template<class T> inline int gmin(T&a,T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> inline int gmax(T&a,T b) {if(a<b){a=b;return 1;}return 0;}
inline int dcmp(const double &a) {return a>eps?1:(a<-eps?-1:0);}
struct Initializer{Initializer(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}initializer;

int main() {
  ll n;
  cin >> n;
  if (n==1) {
    pf("%d\n",1);
    return 0;
  }
  ll x = 0, y = 1;
  rep (i, 1, 5000) {
    x += i;
    y += i + 1ll;
    if (x < n && n <= y) {
      int rem = y - n;
//      pf("x=%lld y=%lld rem=%d\n",x,y,rem);
      rep(j, 1, i + 1) {
        if (j != rem) pf("%d\n", j);
      }
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll int
#define N 100000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */

ll dp[101][N + 1];
int main()
{
    //    freopen("input.txt", "r", stdin);

    const ll M = 1e9 + 7;
    ll n, k;
    cin >> n >> k;

    ll a[n + 1];
    ll pre[k + 1];
    a[0] = 0;
    f(i, 1, n) cin >> a[i];

    memset(dp, 0, sizeof(dp));
    ll ans = 0;

    rf(i, k, max(k - a[1], 0))
        dp[1][i] = 1;

    f(i, 2, n)
    {

        dp[i][k] = 1;
        rf(j, k - 1, max(k - a[i], 0))
        {
            dp[i][j] = (dp[i][j + 1] + dp[i - 1][j]) % M;
        }

        rf(j, max(k - a[i], 0) - 1, 0)
        {
            dp[i][j] = ((dp[i - 1][j] + dp[i][j + 1]) % M - (dp[i - 1][j + a[i] + 1]) % M + M) % M;
        }
    }

    cout << dp[n][0] << endl;
}


Measured memory_bytes: 39808
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


void solve()
{
  map<int,int> m;
  set<int> s;
  int n;
  cin >> n;
  int a[n];
  f(i,n)
	{
		cin >> a[i];
		s.insert(a[i]);
		m[a[i]]++;
	}
	int ans=0;
   for(auto itr=s.begin();itr!=s.end();itr++)
	   {
		   ans+=max(0ll,(m[*itr]*(m[*itr]-1))/2);
	   }
   f(i,n)
   {
	   int res=ans;
	   res-=(max(0ll,(m[a[i]]*(m[a[i]]-1))/2));
	   m[a[i]]--;
	   res+=max(0ll,(m[a[i]]*(m[a[i]]-1))/2);
	   m[a[i]]++;
     cout << res << '\n';
   }
  return;
}

signed main()
{
   FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 17024
/*
	---------author:O7Oo7oO7O-------------
*/

#include <bits/stdc++.h>

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

using namespace std;

using ll = long long int;



int main()
{
	IOS

	int n,k;
	cin>>n>>k;
	set<int> st;
	while(k--)
	{
		int d;
		cin>>d;
		for(int i=0;i<d;i++)
		{
			int a;
			cin>>a;
			st.insert(a);
		}
	}

	cout<<n-st.size()<<"\n";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
    a-=d;
    c-=b;}
    if(a<=0&&c>0)
    cout<<"No"<<endl;
    else 
    cout<<"Yes"<<endl;
  return 0;
    }


Measured memory_bytes: 3596
object Main {
  def main(args: Array[String]): Unit = {
    for(line <- io.Source.stdin.getLines() if line != "0 0") {
      val H = line.split(" ")(0).toInt
      val W = line.split(" ")(1).toInt

      for (i <- 0 until H) {
        if (i % 2 == 0) {
          println(("#." * W).substring(0, W))
        }
        else {
          println((".#" * W).substring(0, W))
        }
      }
      println()
    }
  }
}

Measured memory_bytes: 45660
import sys
N,Y = map(int,input().split())
for x in range(min(N,Y//10000)+1):
    for y in range(min(N-x,(Y-10000*x)//5000)+1):
        z = N-x-y
        if 10000*x+5000*y+1000*z == Y:
            print(x,y,z)
            sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <stdio.h>
int main ()
{
	int a, b, c, i;
	scanf ("%d%d%d", &a, &b, &c);
	if(a==b&&a!=c||a==c&&b!=c||b==c&&a!=b)
	{
		printf("2\n");
	}
	else if(a!=b&&a!=c&&b!=c)
	{
		printf("3\n");
	}
	else if(a==b&&a==c)
	{
		printf("1\n");
	}
	else;
	return 0;
}

Measured memory_bytes: 128
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np

MOD = 998244353

N = int(readline())
A = np.array(readline().split(),np.int32)

U = 10**6+100
counter = np.bincount(A,minlength=U)

def cumprod(arr):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

x = np.arange(U,dtype=np.int64); x[0] = 1
fact = cumprod(x)
x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
fact_inv = cumprod(x)[::-1]

inv = np.zeros(U,dtype=np.int64)
inv[1:] = fact[:-1] * fact_inv[1:] % MOD

"""
・f(n) = sum_{gcd(a,b) == 1}ab
・g(n) = sum_{n|gcd(a,b)}ab
"""

"""
・S(n) = sum_{n|a} a
・T(n) = sum_{n|a} a^2
"""

x = np.arange(U,dtype=np.int64)*counter%MOD
y = np.arange(U,dtype=np.int64)**2%MOD*counter%MOD
S = np.zeros(U,dtype=np.int64)
T = np.zeros(U,dtype=np.int64)
M = int(U**.5+1)+10
for d in range(1,M):
    S[d] = (x[d::d]).sum()
    T[d] = (y[d::d]).sum()
for d in range(1,M):
    S[M:(U-1)//d+1] += x[M*d:U:d]
    T[M:(U-1)//d+1] += y[M*d:U:d]
S%=MOD
T%=MOD

G = (S*S-T)%MOD*inv[2]%MOD

is_prime = np.zeros(U,dtype=np.int64)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3,M,2):
    if p*p > U:
        break
    if is_prime[p]:
        is_prime[p*p::p+p] = 0
primes = np.where(is_prime)[0]
pi = is_prime.cumsum()

coef = np.ones(U,dtype=np.int64)
for p in primes[:pi[M]]:
    coef[p::p] *= (1-p)
for n in range(1,M):
    p = primes[pi[M]:pi[(U-1)//n]]
    coef[p*n] *= (1-p)

answer = (G*coef%MOD*inv%MOD).sum()%MOD
print(answer)

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  string ans = "YES";
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      ans = "NO";
    }
  }
  cout << ans;
  
  
}


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

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

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

#define sint(a) scanf("%d", &a)
#define sint2(a, b) scanf("%d %d", &a, &b)
#define sll(a) scanf("%lld", &a)
#define sll2(a, b) scanf("%lld %lld", &a, &b)
#define mem(a, i) memset(a, i, sizeof(a))
#define pb push_back
#define int long long
#define ll long long
#define lson node << 1
#define rson (node << 1) + 1
#define endl "\n"

const int maxn = 5e5 + 10;
const int mod = 998244353;
const double pi = acos(-1);

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

int lcm(int a, int b)
{
  return a * b / gcd(a, b);
}

int qpow(int a, int n)
{
  int b = 1;
  while (n)
  {
    if (n & 1)
      b = a * b % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return b;
}

class Prime_Number
{
public:
  int prime[maxn], s, v[maxn];
  void prime_init(int n)
  {
    for (int i = 2; i <= n; i++)
    {
      if (!v[i])
      {
        prime[s++] = i;
        for (int j = 1; j * i <= n; j++)
          v[i * j] = 1;
      }
    }
  }
};

//**************************
int x, y, r[maxn], c[maxn];
vector<int> v[maxn], rr, cc;
set<pair<int,int> >st;
void solve()
{
  int h, w, m;
  cin >> h >> w >> m;
  int mr = 0, mc = 0;
  for (int i = 0; i < m; i++)
  {
    sll2(x, y);
    st.insert(make_pair(x,y));
    r[x]++;
    c[y]++;
    if(mr<r[x])
      {
        mr=r[x];
        rr.clear();
        rr.pb(x);
      }
    else if(mr==r[x])
    {
      rr.pb(x);
    }
    if(mc<c[y])
      {
        mc=c[y];
        cc.clear();
        cc.pb(y);
      }
    else if(mc==c[y])
    {
      cc.pb(y);
    }
  }
  for(int i:rr)
    for(int j:cc)
    {
      if(st.count(make_pair(i,j)))
        continue;
      else 
        {
          cout<<mr+mc;
          return;
        }
    }
  cout << mr+mc-1;
}
signed main()
{
  solve();
  return 0;
}


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

#define rep(i,n) for(int i = 0;i < (int)(n);i++)
int main(){
    int n,x;
    cin >> n;
    for(int i =1;i <= n; i++){
        if(i % 3 == 0){
            cout << " " << i;
            continue;
        }
        x = i;
        while(x != 0){
            if(x % 10 == 3){
                 cout << " " << i;
                 break;
            }
            x = x / 10;
        }
    }
    cout << endl;
}



Measured memory_bytes: 3096
while True:
    N = int(input())
    if N == 1:
        print(1, 1)
    elif N == 0:
        quit()
    else:
        h, w = [0], [0]
        for i in range(N-1):
            n, d = map(int, input().split())
            if d == 0:
                x, y = -1, 0
            elif d == 1:
                x, y = 0, -1
            elif d ==2:
                x, y = 1, 0
            else:
                x, y = 0, 1
            h.append(h[n] + y)
            w.append(w[n] + x)
        print(abs(max(w)-min(w))+1, abs(max(h)-min(h))+1)


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

int main(){
    int n, x, t;
    cin >> n >> x >> t;
    int sum = 0, ans = 0;
    while(sum < n){
        sum += x;
        ans += t;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  char s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  if(s1!=s2 && s2!=s3 && s3!=s1){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
long long int factorial(long long int x){
  return x==0 ? 1 : x*factorial(x-1);
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(){
  int i, j, ct=0, ans=0, l;
  char x[200002];
  cin >> x;
  l=strlen(x);
  for(i=0; i<l; i++){
    if(x[i]=='S') ct++;
    else{
      if(ct>0){
	ct--;
	ans+=2;
      }
    }
  }
  cout << l-ans;
  return 0;
}

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

const ll mod = pow(10, 9) + 7;

int main()
{
  ll n, k;
  cin >> n >> k;
  ll res = 0;
  vector<ll> sum(n + 2 - k);
  for (ll i = k; i <= n + 1; i++) {
    res += (i * (n - i + 1) + 1) % mod;
  }
  cout << res % mod << endl;

  return 0;
}


Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x, n, y;
    int cnt[2000] = {};

    cin >> n >> x >> y;
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dis = min(j - i, abs(x - i) + 1 + abs(y - j));
            cnt[dis]++;
        }
    }

    for (int i = 1; i < n; i++) {
        cout << cnt[i] << endl;
    }
}


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

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 500005;

ll n, m;
ll fact[N], invfact[N];

ll power(ll a,ll n,ll m=M){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a;
        a=a*a;
        n=n>>1;
        ans=ans%m;
        a=a%m;
    }
    return ans;
}

void pre(){
    fact[0] = 1;
    rep(i,1,N)  fact[i] = (fact[i-1] * i) % M;
    rep(i,0,N)  invfact[i] = power(fact[i], M-2);
}

ll nCr(ll n, ll r){
    return ((fact[n] * invfact[r])%M * invfact[n-r]) % M;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    pre();
    ll ans = (nCr(m,n) * fact[n])%M;
    ans = (ans * ans) % M;
    ll g = (nCr(m,n)*fact[n])%M;
    ll cnt = 0;
    rep(i,1,n+1){
        ll p = ((nCr(m-i,n-i)*fact[n-i])%M*nCr(n,i))%M;
        if(i&1) cnt -= p;
        else cnt += p;
        cnt = (cnt%M + M)%M;
    }
    ans = (ans + g * cnt) % M;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11312
/*
Problem:C - Ordinary Beauty
Algorithm:
Status:
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <utility>
#include <list>
#include <ctime>
#include <memory.h>
#include <stack>
#include <stdio.h>
#include <string.h>

using namespace std;

const int INF=1e9+7;

int main()
{
	double n,m,d;
	cin>>n>>m>>d;
	if(d==0){
		printf("%.10f",(m-1)/n);
	}
	else{
		printf("%.10f",((n-d)*(m-1)*2)/(n*n));
	}
	return 0;
}


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

int32_t main(){
	int n, ans = 0;
	cin >> n;
	if(n % 2 == 1){
		cout << 0 << endl;
		return 0;
	}else{
		n /= 2;
		while(n){
			n /= 5;
			ans += n;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

a, b, c = read_int()

def solve():
    if c - a - b > 0:
        if 4 * a * b - pow(c - a - b, 2) < 0:
            return 'Yes'
    return 'No'

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3832
#include<stdio.h>

int main() {
    int Sheep = 0;
    int Wolves = 0;
    scanf("%d%d", &Sheep, &Wolves);
    if (Sheep <= Wolves) {
        printf("unsafe\n");
    }
    else {
        printf("safe\n");
    }
    return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin>>a>>b;
  vector<string> v(b+2,"#");  
  for(int k=0;k<b+2;k++){
  cout<<v.at(k);
  }
  cout<<endl;
   
  for(int i=0;i<a;i++){
    vector<char> w(b+2);
    w.at(0)='#';
    cout<<w.at(0);
    for(int j=1;j<b+1;j++){
      cin>>w.at(b);
      cout<<w.at(b);
    }
    w.at(b+1)='#';
    cout<<w.at(b+1)<<endl;    
  }
  
  for(int k=0;k<b+2;k++){
  cout<<v.at(k);
  }
  cout<<endl;
    
  
}

Measured memory_bytes: 3556
#include<iostream>
using namespace std;
int main() {
  int n,y; cin >> n >> y;
  y /= 1000;
  for (int ten = 0; ten <= n; ten++) {
    for(int five = 0; five + ten <= n; five++) {
      int one = n - ten - five;
      if (ten * 10 + five * 5 + one == y) {
        cout << ten << " " << five << " " << one << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  
  return 0;
}

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

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

int main() {
    // 入力
    int N; long long W;
    cin >> N >> W;
    vector<long long> weight(N), value(N);
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DP テーブル定義
    vector<vector<long long> > dp(N+1, vector<long long>(W+1, 0));

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int w = 0; w <= W; ++w) {

            // i 番目の品物を選ぶ場合
            if (w - weight[i] >= 0) {
                chmax(dp[i+1][w], dp[i][w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][w], dp[i][w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define pb push_back
# define mp make_pair
//# define int ll
using namespace std;


int32_t main(){_
    //freopen("input","r",stdin);
    ll a,b,c;
    cin >> a >> b >> c;
    ll ans = 0;
    while(clock <= 1950)
    {
		if(a & 1) rc(ans);
		if(b & 1) rc(ans);
		if(c & 1) rc(ans);
        ans ++;
        ll aa = a;
        ll bb = b;
        ll cc = c;
        a = (bb + cc) / 2;
        b = (aa + cc) / 2;
        c = (bb + aa) / 2;
    }
	rc(-1);
}


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

int main(void)
{
	char s[27];
	scanf("%s",s);
	int len=strlen(s);
	fprintf(stderr,"%s\n",s);
	int i,j,c;
	for(i=0;i<=len-1;i++)
		{
		c=s[i];
		fprintf(stderr,"%c",c);
		}
	
	fprintf(stderr,"\n");
	
	int check=1;
	for(i=0;i<=len-1;i++)
		{
		for(j=i+1;j<=len-1;j++)
			{
			if(s[i]==s[j]){check=0; printf("no"); break;}
			}
		if(check==0){break;}
		}
	if(check==1){printf("yes");}


	return 0;
}


Measured memory_bytes: 128
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn usize() -> usize {
    read()
}

fn vec_usize(n: usize) -> Vec<usize> {
    let mut vec = Vec::new();
    for _ in 0..n {
        vec.push(usize())
    }
    vec
}

fn main() {
    let ns = vec_usize(2);
    let eight = ns[0] as f64;
    let ten = ns[1] as f64;

    let mut flag = false;
    let mut i = (eight / 0.08).ceil();
    loop {
        let t = (i * 0.1).floor();
        // println!("{} * 0.1 = {}", i, t);
        if t >= ten {
            if t == ten {
                flag = true;
            }
            break;
        }
        i += 1.0;
        let e = (i * 0.08).floor();
        // println!("{} * 0.08 = {}", i, e);
        if e > eight {
            break;
        }
    }
    if flag {
        println!("{}", i);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2580
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
      int[] arr = new int[3];
      arr[0] = a;
      arr[1] = b;
      arr[2] = c;
      Arrays.sort(arr);
      System.out.println(arr[2]*10 + arr[1]+arr[0]);
    }
}

Measured memory_bytes: 22996
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        int N = sc.nextInt();
        String[] S = new String[N];
        ArrayList<String> list = new ArrayList<String>();

        for(int i=0; i<N; i++){
            S[i] = sc.next();
            list.add(S[i]);
        }

        Collections.sort(list);

        int[] sum = new int[N];
        int x = 0;
        int max = 0;
        String[] ans = new String[N];
        for(int i=0; i<N; i++){
            sum[i] = 1;
        }
        for(int i=1; i<N; i++){
            if(list.get(i).equals(list.get(i-1))){
                sum[x] += 1;
            }
            else{
                ans[x] = list.get(i - 1);
                max = Math.max(max, sum[x]);
                x += 1;
            }
            if(i==N-1){
                ans[x] = list.get(i);
                max = Math.max(max, sum[x]);
            }
        }
        for(int i=0; i<=x; i++){
            if(sum[i]==max){
                System.out.println(ans[i]);
            }
        }
    }
}


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

using namespace std;

int arr[200003];

int main(){
    int n, k, dis = 0, ans = 0;
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        int tmp; cin >> tmp;
        if(!arr[tmp]){
            dis++;
            arr[tmp]++;
        }else arr[tmp]++;
    }
    if(dis <= k){
        cout << 0;
        return 0;
    }else{
        sort(arr, arr + 200003);
        int start = 0;
        while(arr[start] == 0)start++;
        for(int i = start; i < 200003; ++i){
            if(dis > k){
                dis--;
                ans += arr[i];
            }
        }
    }
    cout << ans;
    return 0;
}


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

string s;

bool OK(char c) {
	if(c == 'A' || c == 'T' || c == 'C' || c == 'G') return true;
	return false;
}

int main()
{
	while(cin >> s)
	{
		int len = s.length();
		int ans = 0;
		for(int i = 0; i < len; i++) {
			int j = 0;
			for(j = i; j < len; j++) {
				if(!OK(s[j]))
					break;
			}
			ans = max(ans, j - i);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256