akhauriyash/Code-Regression huggingface dataset:
using System;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine()) % 10;
        if (N == 3)
        {
            Console.WriteLine("bon");
        }
        else if (N == 0 || N == 1 || N == 6 || N == 8)
        {
            Console.WriteLine("pon");
        }
        else
        {
            Console.WriteLine("hon");
        }
    }
}


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

using namespace std;
//using namespace __gnu_pbds;

/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 3e5 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 8e17 + 51;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

vi a;
int sum = 0, tek, n, k;

void bin (int x, int y) {
    int l = -1, r = n;
    while (r - l > 1) {
        int m = (r + l) >> 1;
        if (x >= a[m]) l = m;
        else r = m;
    }
    if (l == -1) return;
    if (a[l] >= y) sum += l;
    else sum += l + 1;
}

void bin1 (int x, int y) {
    int l = -1, r = n;
    while (r - l > 1) {
        int m = (r + l) >> 1;
        if (x > a[m]) l = m;
        else r = m;
    }
    if (r == n) return;
    if (a[r] <= y) sum += n - r - 1;
    else sum += n - r;
}

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int l = -1e18 - 51, r = 1e18 + 51;
    while (r - l > 1) {
        int m = (r + l) >> 1ll;
        sum = 0, tek = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] == 0) {
                if (m >= 0) sum += n - 1;
                continue;
            }
            if (a[i] > 0) {
               if (m >= 0) bin(m / a[i], a[i]);
               else {
                    if (m % a[i] != 0) bin(m / a[i] - 1, a[i]);
                    else bin(m / a[i], a[i]);
               }
            }
            if (a[i] < 0) {
                if (m < 0) {
                    if (m % a[i] != 0) bin1(m / a[i] + 1, a[i]);
                    else bin1(m / a[i], a[i]);
                }
                else {
                    bin1(m / a[i], a[i]);
                }

            }
        }
        if (sum % 2 != 0) while (true);
        if (sum / 2 + tek < k) l = m;
        else r = m;
    }
    cout << r;

}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            double Two = 2;

            double Input = double.Parse(Console.ReadLine());

            double area = Input * Input * Math.PI;

            double lenght = Input * Two * Math.PI;

            Console.WriteLine("{0} {1}", area, lenght);
        }

    }

}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VVL X(10,VL(10));
  rep(i,N){
    int A=i+1;
    int tmp=A%10;
    while(A/10) A/=10;
    X[A][tmp]++;
  }
  ll ans=0;
  rep(i,10) rep(j,10) ans+=X[i][j]*X[j][i];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

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

  int sum = a + b + c;
  int mx = max({a, b, c});

  int x = sum - mx;
  int y = mx;

  if (x == y)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll n;
    cin>>n;
    vector<ll>dp(n+1);
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=3;j<=n;j++)
        {
            if(i-j>=0)
            {
                dp[i]=(dp[i]+dp[i-j])%mod;
            }
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
using namespace std;
int n,a[300000];
int main(){
    cin>>n;
    for(int i=0;i<3*n;i++)cin>>a[i];
    sort(a,a+3*n);
    long long ans=0;
    for(int i=1;i<=n;i++){
        ans+=a[3*n-2*i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff  first
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 1e5+9;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli digit(lli n){int res=(int)log10(n)+1;return res;}
lli lcm(lli a,lli b){lli ans=(a*b)/(__gcd(a,b));return ans;}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
///=================== ALWAYS CHECK 1 or 0 base case=================================================================================///
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
int main (){
    string a,b;cin>>a>>b;
    if(a.size()>b.size())cout<<"GREATER\n";
    else if(a.size()<b.size())cout<<"LESS\n";
    else
    {
        int n=a.size();
        for(int i=0;i<n;i++)
        {
            if(a[i]>b[i])
            {
                cout<<"GREATER\n";return 0;
            }
            else if(b[i]>a[i])
            {
                cout<<"LESS\n";return 0;
            }
        }
        cout<<"EQUAL\n";
    }
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const int mod=1e9+7;
int mu(int a,int b){
  return (long long)a*b%mod;
}
int ad(int a,int b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
int pw(int a,int b,int c=1){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
int dv(int a,int b){
  return mu(a,pw(b,mod-2));
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  ll ans=0;
  ll two_i=0;
  ll keta = s.size();
  //  cout << keta << endl;
  for(auto i : s){
    if(i=='1'){
      ans = ad(ans,mu(pw(2, two_i), pw(3,keta-1)));
      //      cout << ans << endl;
      two_i++;      
    }    
    keta--;
    if(keta==0){
      //      cout << " " << endl;
      ans = ad(ans,pw(2, two_i));
    }
  }
  cout << ans << endl;

  return 0;
    

}


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

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

  int n,m;
  cin>>n>>m;
  char x[n][m];
  for(int i=0; i<n; ++i){
    string y;
    cin>>y;
    for(int j=0; j<m; ++j){
      x[i][j] = y[j];
    }
  }
  bool print[n][m];
  for(int i=0; i<n; ++i)
    for(int j=0; j<m; ++j)
      print[i][j] = true;

  for(int i=0; i<n; ++i){
    int stat = true;
    for(int j=0; j<m; ++j){
      if( x[i][j] == '#' ){ stat = false;}
    }
    if( stat == true ){
      for(int j=0; j<m; ++j){
        print[i][j] = false;
      }
    }
  }
  for(int j=0; j<m; ++j){
    int stat = true;
    for(int i=0; i<n; ++i){
      if( x[i][j] == '#' ){ stat = false; }
    }
    if( stat == true ){
      for(int i=0; i<n; ++i){
        print[i][j] = false;
      }
    }
  }
  for(int i=0; i<n; ++i){
    bool stat = false;
    for(int j=0; j<m; ++j){
      if(print[i][j] == true){
        cout<<x[i][j];
        stat = true;
      }
    }
   if(stat == true){ cout<<"\n"; }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, sum[5], s1, s2, max;

	while (1){
		for (i = 0; i < 5; i++){
			scanf("%d %d", &s1, &s2);
			if (s1 == 0 && s2 == 0){
				return (0);
			}
			
			sum[i] = s1 + s2;
			
			if (i == 0){
				max = 0;
			}
			else if (sum[max] < sum[i]){
				max = i;
			}
		}
		
		printf("%c %d\n", 'A' + max, sum[max]);
	}	
}

Measured memory_bytes: 600
#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 FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 5e5 + 5;
const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;
 
int arr[N];
int posn[N];
int prime[N];

int DP[N];
int k;

int divisors(int n)
{
	int cnt = 0;
	for(int i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			cnt += 2;
			cnt -= (i * i == n);
		}
	}
	return cnt - 1;
}

int f(int idx)
{
	if(idx < 1)
	{
		return 0;
	}
	if(idx == 1)
	{
		return 1;
	}
	int ret = 0;
	if(idx % k == 0)
	{
		return f(idx / k);
	}
	else
	{
		return ((idx - 1) % k == 0);
	}
}
 
void solve() 
{
	int n, m;
	cin >> n >> m;
	int tot = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		tot += arr[i];
		arr[i] *= 4 * m;
	}
	int cnt = 0;
	for(int i = 0; i < n; i++)
	{
		if(arr[i] >= tot)
		{
			cnt++;
		}
	}
	if(cnt >= m)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}
 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }

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

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (i >= k) {
      ans += h.at(i); 
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
long long a[100010],b[100010],ans = 0,sum = 0;
pair<long long,long long> p[100010];
int main(){
	int i,n,m;
	cin >> n >> m;
	for(i=0;i<n;i++){
		cin >> a[i] >> b[i];
		p[i] = {a[i],b[i]};
	}
	sort(p,p + n);
	for(i=0;i<n;i++){
		if(sum + p[i].second < m){
			sum += p[i].second; ans += p[i].first*p[i].second;
		}else{
			ans += p[i].first*(m - sum);
			cout << ans << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n;
    cin >> n;

    int x, in;
    vector<bool> a(n, false), b(n, false);
    cin >> x;
    FOR(i, 0, x) {
        cin >> in;
        a[--in] = true;
    }
    cin >> x;
    FOR(i, 0, x) {
        cin >> in;
        b[--in] = true;
    }

    int ans = 0;
    cin >> x;
    FOR(i, 0, x) {
        cin >> in;
        if (!a[--in] || b[in])ans++;
    }
    cout << ans << "\n";
}



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

int main () {
    int A, B;
    cin >> A >> B;
    int sum = 0;
    for (int a = 1; a < 10; a++) {
        for (int b = 0; b < 10; b++) {
            for (int c = 0; c < 10; c++) {
                int x = 10001 * a + 1010 * b + 100 * c;
                if (x >= A && x <= B) {
                    sum++;
                }
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
typedef long long LL;
#define ms(a,b) memset(a,b,sizeof(a))
# define eps 1e-8

int A[100005];
int B[100005];
int C[100005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    for(int i=0;i<n;i++) cin>>B[i];
    for(int i=0;i<n;i++) cin>>C[i];
    sort(A,A+n);
    sort(B,B+n);
    sort(C,C+n);
    LL ans=0;
    for(int i=0;i<n;i++){
        LL pos1=lower_bound(A,A+n,B[i])-A;
        LL pos2=upper_bound(C,C+n,B[i])-C;
        ans+=pos1*(n-pos2);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1408
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;

int main() {

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int>A(N+1);
    for (int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        A[a]++;
    }

    for (int i = 1; i <=N ; i++){
        if (K - Q + A[i] > 0)cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}

Measured memory_bytes: 1024
c = input()
alphabet = [
    "a", "b", "c", "d", "e", "f", "g",
    "h", "i", "j", "k", "l", "m", "n",
    "o", "p", "q", "r", "s", "t", "u",
    "v", "w", "x", "y", "z"
]
x = alphabet.index(c)
print(
    alphabet[x+1]
)


Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=998244353;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 2e5+10, M = 1e6+10;
struct node {
	int l, r;
	ll num;
}tr[N * 4];
void pushup(int u) {
	tr[u].num = (tr[u << 1].num + tr[u << 1 | 1].num) % mod;
}
void build(int u, int l, int r) {
	if(l == r) {
		tr[u] = {l, r, 0};
	} else {
		int mid = l + r >> 1;
		tr[u] = {l, r};
		build(u << 1, l, mid);build(u << 1 | 1, mid + 1, r);
		pushup(u);
	}
}
void modify(int u, int x, ll d) {
	if(tr[u].l == x&&tr[u].r == x) {
		tr[u].num = (tr[u].num + d) % mod;
	} else {
		int mid = tr[u].l + tr[u].r >> 1;
		if(x <= mid) modify(u << 1, x, d);
		if(x > mid) modify(u << 1 | 1, x, d);
		pushup(u);
	}
}
ll query(int u, int l, int r) {
	if(tr[u].l >= l&&tr[u].r <= r) {
		return tr[u].num;
	} else {
		int mid = tr[u].l + tr[u].r >> 1;
		ll res = 0;
		if(l <= mid) res = (res + query(u << 1, l, r)) % mod;
		if(r > mid) res = (res + query(u << 1 | 1, l, r)) % mod;
		return res;
	}
}
struct seg {
	int l, r;
	bool operator < (seg t) {
		if(l == t.l) return r < t.r;
		return l < t.l;
	}
}s[N];
int n, k;
int main() {
	cin>>n>>k;
	for(int i = 1;i <= k;i++) {
		cin>>s[i].l>>s[i].r;
	}
	sort(s + 1, s + 1 + k);
	build(1, 1, n);
	modify(1, 1, 1);
	for(int i = 2;i <= n;i++) {
		ll res = 0;
		for(int j = 1;j <= k;j++) {
			if(i < s[j].l) break;
			int l = 0, r = 0;
			if(i >= s[j].l) {
				r = i - s[j].l;
			}
			if(i >= s[j].r) {
				l = i - s[j].r;
			}
			//cout<<l<<" "<<r<<"\n";
			ll tmp = query(1, l, r);
			res = (res + tmp) % mod;
			//cout<<tmp<<"\n";
		}
		//cout<<i<<"\n";
		modify(1, i, res);
	}
	cout<<query(1, n, n);
	return 0;
}

Measured memory_bytes: 11792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b,c;cin>>a>>b>>c;
  set<int> ans;
  ans.insert(a);
  ans.insert(b);
  ans.insert(c);
  cout << btos(ans.size()==2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int n;
	cin>>n;
	int dp[n][3];
	int temp;
	for(int i=0;i<3;i++)
	{
		cin>>temp;
		dp[0][i]=temp;
	}
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>temp;
			if(j==0)
				dp[i][j]=temp+max(dp[i-1][j+1],dp[i-1][j+2]);
			else if(j==1)
				dp[i][j]=temp+max(dp[i-1][j+1],dp[i-1][j-1]);
			else if(j==2)
				dp[i][j]=temp+max(dp[i-1][j-1],dp[i-1][j-2]);
		}
	}
	int max=0;
	for(int i=0;i<3;i++)
	{
		if(max<dp[n-1][i])
			max=dp[n-1][i];
	}
	cout<<max<<endl;
	
	
	return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {

    static <T extends Comparable<? super T>> boolean nextPermutation(T[] sequence) {
        int first = getFirst(sequence);
        if (first == -1) return false;
        int toSwap = sequence.length - 1;
        while (sequence[first].compareTo(sequence[toSwap]) >= 0) --toSwap;
        swap(sequence, first++, toSwap);
        toSwap = sequence.length - 1;
        while (first < toSwap) swap(sequence, first++, toSwap--);
        return true;
    }

    static <T extends Comparable<? super T>> int getFirst(T[] sequence) {
        for (int i = sequence.length - 2; i >= 0; --i)
            if (sequence[i].compareTo(sequence[i + 1]) < 0) return i;
        return -1;
    }

    static <T extends Comparable<? super T>> void swap(T[] sequence, int i, int j) {
        T tmp = sequence[i];
        sequence[i] = sequence[j];
        sequence[j] = tmp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Integer[][] graph = new Integer[N][N];
        for (int i = 0; i < N; ++i) Arrays.fill(graph[i], 0);
        for (int i = 0; i < M; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            graph[a][b] = 1;
            graph[b][a] = 1;
        }

        Integer[] arr = new Integer[N];
        for (int i = 0; i < N; ++i) arr[i] = i;

        int res = 0;
        do {
            if (arr[0] != 0) break;
            boolean flag = true;
            for (int i = 0; i < N-1; ++i) {
                if (graph[arr[i]][arr[i+1]] == 0) flag = false;
            }
            if (flag) ++res;
        } while(nextPermutation(arr));

        System.out.println(res);
    }
}

Measured memory_bytes: 23124
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int m=Integer.parseInt(sc.next());
int[] a=new int[n];
int[] sum=new int[n+1];
sum[0]=0;
for(int i=0;i<n;i++){a[i]=Integer.parseInt(sc.next());sum[i+1]=(sum[i]+a[i])%m;}
HashMap<Integer,Integer> map=new HashMap<>();
for(int i=0;i<=n;i++){map.put(sum[i],0);}
long ans=0;
for(int i=0;i<=n;i++){
int c=map.get(sum[i]);
ans+=c;
c++;
map.put(sum[i],c);
}
System.out.println(ans);
}
}

Measured memory_bytes: 48416
#include<stdio.h>
#include<math.h>
#include<string.h>
void search(int Dice[],int a,int b)
{
  if(a==0)
  {
    if(b==1) printf("%d\n",Dice[2]);
    else if(b==2) printf("%d\n",Dice[4]);
    else if(b==4) printf("%d\n",Dice[3]);
    else printf("%d\n",Dice[1]);
  }
  else if(a==1)
  {
    if(b==2) printf("%d\n",Dice[0]);
    else if(b==0) printf("%d\n",Dice[3]);
    else if(b==3) printf("%d\n",Dice[5]);
    else printf("%d\n",Dice[2]);
  }
  else if(a==2)
  {
    if(b==0) printf("%d\n",Dice[1]);
    else if(b==1) printf("%d\n",Dice[5]);
    else if(b==5) printf("%d\n",Dice[4]);
    else printf("%d\n",Dice[0]);
  }
  else if(a==3)
  {
    if(b==1) printf("%d\n",Dice[0]);
    else if(b==0) printf("%d\n",Dice[4]);
    else if(b==4) printf("%d\n",Dice[5]);
    else printf("%d\n",Dice[1]);
  }
  else if(a==4)
  {
    if(b==0) printf("%d\n",Dice[2]);
    else if(b==2) printf("%d\n",Dice[5]);
    else if(b==5) printf("%d\n",Dice[3]);
    else printf("%d\n",Dice[0]);
  }
  else if(a==5)
  {
    if(b==1) printf("%d\n",Dice[3]);
    else if(b==3) printf("%d\n",Dice[4]);
    else if(b==4) printf("%d\n",Dice[2]);
    else printf("%d\n",Dice[1]);
  }
}
int main(void)
{
  int i,j,Dice[6],q,a,b;
  for(i=0;i<6;i++)
  {
    scanf("%d",&Dice[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++)
  {
    scanf("%d %d",&a,&b);
    for(j=0;j<6;j++)
    {
      if(Dice[j]==a) a=j;
      if(Dice[j]==b) b=j;
    }
    search(Dice,a,b);
  }
//  printf("%d\n",Dice[0]);
  return 0;
}



Measured memory_bytes: 2040
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  solve_1()
}

fn solve_1()  {
  let (n, k) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1])
  };
  let mut s: Vec<char> = read::<String>().chars().collect();

  let mut score = 0;
  for i in 0..n-1 {
    if s[i] == s[i+1] {
      score += 1;
    }
  }

  let ans = min(score + 2*k, n-1);
  println!("{}", ans);
}

fn solve() {
  let (n, k) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1])
  };
  let mut s: Vec<char> = read::<String>().chars().collect();
  let mut k = k;
  let count = count_same_element(&s);
  for (i, &(left, right)) in count.iter().enumerate() {
    if i % 2 == 1 && k > 0 {
      let c = change(s[left]);
      k -= 1;
      for j in left..right+1 {
        s[j] = c;
      }
    }
  }
  let mut ans = 0;
  for i in 0..n-1 {
    if s[i] == s[i+1] {
      ans += 1;
    }
  }
  println!("{}", ans);
}

fn count_same_element<T: Eq + Copy>(v: &Vec<T>) -> Vec<(usize, usize)> {

  let mut res: Vec<(usize, usize)> = Vec::new();
  if v.len() == 0 {
    return res;
  }

  let mut now: T = v[0];
  let mut count: usize = 0;
  let mut left = 0;
  for (i, &e) in v.iter().enumerate() {
    if e == now {
      count += 1;
    }
    else {
      res.push((left, count+left-1));
      count = 1;
      now = e;
      left = i;
    }
  }
  res.push((left, count+left-1));

  res
}

fn change(c: char) -> char {
  match c {
    'R' => 'L',
    _ => 'R',
  }
}


Measured memory_bytes: 4352
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut queries = vec![];
    loop {
        let a = read::<usize>();
        if a == 0 {
            break;
        }
        queries.push(a);
    }
    let max_query = *queries.iter().max().unwrap();
    let mut dp = vec![std::usize::MAX; max_query + 1];
    let mut pyramids = vec![];
    for i in 1.. {
        let number = i * (i + 1) * (i + 2) / 6;
        if number > max_query {
            break;
        }
        pyramids.push(number);
        dp[number] = 1;
    }

    for i in 0..max_query + 1 {
        if dp[i] == std::usize::MAX {
            continue;
        }
        for &number in pyramids.iter() {
            if i + number > max_query {
                continue;
            }
            dp[i + number] = min(dp[i + number], dp[i] + 1);
        }
    }
    let dp = dp;

    let mut dp2 = vec![std::usize::MAX; max_query + 1];
    let mut pyramids = vec![];
    for i in 1.. {
        let number = i * (i + 1) * (i + 2) / 6;
        if number % 2 == 0 {
            continue;
        }
        if number > max_query {
            break;
        }
        pyramids.push(number);
        dp2[number] = 1;
    }

    for i in 0..max_query + 1 {
        if dp2[i] == std::usize::MAX {
            continue;
        }
        for &number in pyramids.iter() {
            if i + number > max_query {
                continue;
            }
            dp2[i + number] = min(dp2[i + number], dp2[i] + 1);
        }
    }

    for q in queries {
        println!("{} {}", dp[q], dp2[q]);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}



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

typedef long long ll;
const ll mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<vector<ll>> prod(vector<vector<ll>>& a, vector<vector<ll>>& b) {
    vector<vector<ll>> ret(a.size(),vector<ll>(b[0].size(),0));
    for (int i = 0;i < a.size();++i) for (int j = 0;j < b[0].size();++j) for (int k = 0;k < a[0].size();++k) {
        ret[i][j] += a[i][k]*b[k][j];
        ret[i][j] %= mod;
    }
    return ret;
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<vector<ll>> a(n,vector<ll>(n,0));
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) cin >> a[i][j];

    vector<vector<ll>> dp(1,vector<ll>(n,1));
    while (k > 0) {
        if (k%2) dp = prod(dp,a);
        a = prod(a,a);
        k >>= 1;
    }
    ll ans = 0;
    for (int i = 0;i < n;++i) {
        ans += dp[0][i];
        ans %= mod;
    }
    cout << (ans+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    s = iss()
    print('Yes' if len(set(s)) == 3 else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> wa(n,0);
    vector<bool> ac(n,false);
    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        p--;
        if(s == "AC"){
            ac.at(p) = true; 
        }else{
            if(!ac.at(p)) wa.at(p)++;
        }
    }
    int AC = 0;
    int WA = 0;
    rep(i,n){
        if(ac.at(i)){
            AC++;
            WA += wa.at(i);
        }
    }
    cout << AC << " " << WA << endl;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 1e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, arr[N], freq[N];



void solve()
{
      cin >> n;

      int g = 0;
      lop(i, 0, n) cin >> arr[i], g = __gcd(arr[i], g);


      lop(i, 0, n)
      {
            freq[ arr[i] ]++;
      }


      int mx = 1;
      lop(i, 2, N)
      {
            int cnt = 0;
            for (int j = i; j < N; j += i) cnt += freq[j];
            // if (cnt) cout << cnt << endl;
            mx = max(mx, cnt);
      }

      if ( mx == 1 ) cout << "pairwise coprime" << endl;
      else if ( g == 1 ) cout << "setwise coprime" << endl;
      else cout << "not coprime" << endl;






}

int32_t main()
{
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

      int test = 1;
      // cin >> test;
      while (test--)solve();


}





















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

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int pm[10010],pe[10010],pj[10010];
    char result[10010];
    cin>>n;
    while( n!=0 ){
        for(int i=0;i<n;i++){
            cin>>pm[i]>>pe[i]>>pj[i];
        }
        for(int i=0;i<n;i++){
            if(pm[i]==100 || pe[i]==100 || pj[i]==100){
                result[i]='A';
            }else if( (pm[i]+pe[i])/2 >= 90){
                result[i]='A';
            }else if( (pm[i]+pe[i]+pj[i])/3 >= 80){
                result[i]='A';
            }else if( (pm[i]+pe[i]+pj[i])/3 >= 70){
                result[i]='B';
            }else if( (pm[i]+pe[i]+pj[i])/3 >= 50 && (pm[i] >= 80 || pe[i] >= 80)){
                result[i]='B';
            }else{
                result[i]='C';
            }
        }
        for(int i=0;i<n;i++){
            cout<<result[i]<<"\n";
        }
        cin>>n;
    }
    return 0;
}




Measured memory_bytes: 3180
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		
		ArrayList<Integer> listX = new ArrayList<>();
		ArrayList<Integer> listY = new ArrayList<>();
		
		//xリストの最大値を求める
		for(int i=0; i<N; i++) {
			listX.add(sc.nextInt());
		}
		Integer maxX = Collections.max(listX);
		
		//yリストの最小値を求める
		for(int i=0; i<M; i++) {
			listY.add(sc.nextInt());
		}
		Integer minY = Collections.min(listY);
		
		//結果比較
		if((maxX < minY) && (maxX < Y-1) && (X+1 < minY)) {
			System.out.println("No War");
		}else{
			System.out.println("War");
		}
	}

}


Measured memory_bytes: 22996
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {
		//入力導入部
		Scanner sc=new Scanner(System.in);
		
			int r=sc.nextInt();
			int c=sc.nextInt();
			int[][] box=new int[r+1][c+1];
			///////////////////////////////////////////////////////////////////
			//計算部			x=n+n-i+n-l
			int total;
		
			for(int i=0;i<r;i++){total=0;
				for(int l=0;l<c+1;l++){
					if(l==c){box[i][c]=total;
					}else total+=box[i][l]=sc.nextInt();
					
					
				}
				
			}
			for(int l=0;l<=c;l++){total=0;
				for(int i=0;i<r+1;i++){
					if(i==r){box[r][l]=total;}
					else{total+=box[i][l];}
			
				}
			}
			for(int i=0;i<r+1;i++){
				for(int l=0;l<c+1;l++){
					if(l==0)System.out.print(box[i][0]);
					else System.out.print(" "+box[i][l]);
				}System.out.println();
			}
			
			
		}}	

Measured memory_bytes: 39448
/*
ID: iCoder0020
PROG: Coins
LANG: C++                  
*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define INF 1e9
#define MOD 1000000007

template <typename T> void max_self(T &a, T b)
{
	a = max(a, b);
}

template <typename T> void min_self(T &a, T b)
{
	a = min(a,b);
}

int32_t main()
{
	int N;
	cin>>N;
	double x;
	vector<double> dp(N+1, 0);
	dp[0] = 1;
	for(int n = 1; n<=N; n++)
	{
		cin>>x;
		for(int i = n; i>=0; i--)
			dp[i] = (i == 0 ? 0: dp[i-1]*x) + dp[i]*(1-x);
	}

	double answer = 0;

	for(int n = (N+1)/2; n<=N; n++)
		answer += dp[n];

	cout<<fixed<<setprecision(10)<<answer<<endl;

	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c; cin >> a >> b >> c;
  a[0] = toupper(a[0]);
  b[0] = toupper(b[0]);
  c[0] = toupper(c[0]);
  cout << a[0] << b[0] << c[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

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

  map<string, ll> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;

  cout << mp[S] << endl;
}

Measured memory_bytes: 256
g = ['L', 'U', 'D']
k = ['R', 'U', 'D']
a = input()
b = 0
for i in range(len(a)):
    if (i+1) % 2 == 0:
        if a[i] in g:
            pass
        else:
            print('No')
            b = 1
            break
    else:
        if a[i] in k:
            pass
        else:
            print('No')
            b = 1
            break
if b == 0:
    print('Yes')

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

int main()
{
    long long n, m, a[101], vote=0, cp;
    cin >> n >> m;
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        vote+=a[i];
    }
    if (vote%(4*m)==0) cp=vote/(4*m)-1;
    else cp=vote/(4*m);
    for (int i=1;i<=n;i++)
    {
        if (a[i]>cp) m--;
    }
    if (m<=0) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define reps(i, c, n) for (int i = c; i < (n); i++)
#define rep(i, n) reps(i, 0, n)

using namespace std;

const int INF = 1000000007;
const int N = 12;
const int M = 12;

int n, m, x;
int c[N];
int a[N][M];

void input()
{
	cin >> n >> m >> x;

	rep(i, n)
	{
		cin >> c[i];
		rep(j, m)
		{
			cin >> a[i][j];
		}
	}
}

bool IsBitOn(int num, int i)
{
	return (num & (1 << i)) > 0;
}

int solve()
{
	int result = INF;

	rep(i, (1 << n))
	{
		int sum[M] = {0};
		int sumn = 0;

		rep(j, n)
		{
			bool isOn = IsBitOn(i, j);

			if (isOn)
			{
				sumn += c[j];
				rep(k, m)
				{
					sum[k] += a[j][k];
				}
			}
		}

		bool isOK = true;
		rep(j, m)
		{
			if (sum[j] < x)
			{
				isOK = false;
			}
		}

		if (isOK)
		{
			result = min(result, sumn);
		}
	}

	if (result == INF)
	{
		return -1;
	}

	return result;
}

int main()
{
	input();
	cout << solve() << endl;
}

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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

//最大公約数
lol gcd(lol x, lol y){ return (y != 0 ? gcd(y, x % y) : x); }
//最小公倍数
lol lcm(lol x, lol y){ return ((x * y) / gcd(max(x, y), min(x, y))); }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a * c, a * d, b * c, b * d}) << '\n';
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long int k,n,f,m,t;
	t=0;
	cin>>n;
    k=sqrt(n)+2;
  
	for(f=1; f<k; f++){
		if(n%f==0){
          m=n/f-1;
          if(m>f){
            t=t+m;
          }
		}
	}
	cout<<t;
}

Measured memory_bytes: 256
#include <stdio.h>
void trace(int A[],int N) {
    int i;
    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}
void insertionSort(int A[], int N) {
    int i,j,v;
    for(i=1;i<N;i++) {
        v=A[i];
        j=i-1;
        while(j>=0 && A[j] >v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(void)
{
    int N, i, j;
    int A[100];
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    trace(A,N);
    insertionSort(A,N);
    return 0;
}


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

def main():
    s = input().strip()

    dic = {}
    ok = True
    for c in s:
        if c in dic:
            ok = False
            break
        else:
            dic[c] = 1
    
    if ok:
        print("yes")
    else:
        print("no")


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include<stdio.h>

typedef long long ll;

ll gcd(ll u,ll v) {
  ll r = u % v;
  if( r == 0LL ) return v;
  return gcd(v,r);
}

int main() {
  ll u,v;
  scanf("%lld %lld",&u,&v);
  printf("%lld\n",gcd(u,v));
  return 0;
}



Measured memory_bytes: 2148
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
long long N,mons[maxn],defs[maxn];
long long ans=0;
int main()
{
    // freopen("in.txt","r",stdin);
    scanf("%lld",&N);for(int i=1;i<=N+1;i++)
    {
        scanf("%lld",&mons[i]);
    }
    for(int i=1;i<=N;i++)
    {
        scanf("%lld",&defs[i]);
    }
    for(int i=1;i<=N;i++)
    {
        int use=min(defs[i],mons[i]);
        ans+=use;
        defs[i]-=use,mons[i]-=use;
        use=min(defs[i],mons[i+1]);
        ans+=use;
        defs[i]-=use,mons[i+1]-=use;
    }
    printf("%lld",ans);
    return 0;
}

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

void fnInput(int64_t& rnNum)
{
  cin >> rnNum;
}

int fnDigitsCheck(int64_t nDivisor)
{
  int nDigitCnt = 0;
  while (nDivisor)
  {
    nDigitCnt++;
    nDivisor /= 10;
  }

  return nDigitCnt;
}

int fnMultiplCheck(int64_t nNum)
{
  int nMinDigit = fnDigitsCheck(nNum);

  for (int64_t n = 2; n * n <= nNum; n++)          // int型 n だとうまく行かない
  {
    if (nNum % n != 0)  continue;
    int64_t nOtr = nNum / n;
    nMinDigit = min(nMinDigit, fnDigitsCheck(nOtr));
  }
  return nMinDigit;
}

int main()
{
  int64_t nNum;
  
  fnInput(nNum);
  cout << fnMultiplCheck(nNum) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> vl;
typedef vector<vector<long long> > vll;
typedef vector<P> vp;
typedef vector<vector<P> > vpp;

int main() {
	int n;
	cin>>n;
	vl p(n);
	REP(i,n) cin>>p[i];
	ll c=0;
	ll buf=0;
	REP(i,n) {
		if(p[i]==i+1) {
			++buf;
		} else {
			if(buf==1) ++c;
			if(buf>1) {
				if(buf%2==0) {
					c+=buf/2;
				} else {
					c+=buf/2+1;
				}
			}
			buf=0;
		}
	}
	if(buf%2==0) {
		c+=buf/2;
	} else {
		c+=buf/2+1;
	}	cout<<c<<endl;
}



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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	h = min(h, 2 * q);
	s = min(s, 2 * h);
	d = min(d, 2 * s);

	ll res = n / 2 * d + (n & 1) * s;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i, n, x;
	
	scanf("%d", &n);

	for(i=1; i<=n; ++i) {	// CHECK_NUM
		x = i;
		if( x % 3 == 0 ) {
			printf(" %d", i);
		} else {
			while(x) {			// INCLUDE3
				if( x % 10 == 3 ) {
					printf(" %d", i);
					break;
				} else {
					x /= 10;
				}
			}
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<algorithm>
using namespace std; 
typedef long long ll;
ll a[100010];
ll b[100010];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
	}
	ll sum1=0;
	for(int i=0;i<n;i++)
	{
		if(b[i]>=a[i])
		{
			sum1+=a[i];
			b[i]-=a[i];
		}
		else if(b[i]<a[i])
		{
			//b[i]-=b[i];
			sum1+=b[i];
				b[i]-=b[i];
		}
		if(b[i]>0)
		{
			ll t=min(b[i],a[i+1]);
			sum1+=t;
			a[i+1]-=t;
		}
	}
	printf("%lld\n",sum1);
	return 0;
}

Measured memory_bytes: 1664