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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  priority_queue<ll>que1;
  priority_queue<ll,vector<ll>,greater<ll>>que2;
  ll q;cin>>q;
  ll sum1=0,sum2=0;
  ll sumb=0;
  while(q--){
    ll c;cin>>c;
    if(c==1){
      ll a,b;cin>>a>>b;
      sumb+=b;
      que1.push(a);
      sum1+=a;
      if(que1.size()>que2.size()+1){
        sum1-=que1.top();
        sum2+=que1.top();
        que2.push(que1.top());
        que1.pop();
      }
      if(!que1.empty()&&!que2.empty()&&que1.top()>que2.top()){
        sum1-=que1.top();
        sum2-=que2.top();
        sum1+=que2.top();
        sum2+=que1.top();
        que1.push(que2.top());
        que2.push(que1.top());
        que1.pop();
        que2.pop();
      }
    }
    else{
      ll med=que1.top();
      ll sz1=que1.size(),sz2=que2.size();
      cout<<med spa (sz1*med-sum1)+(sum2-sz2*med)+sumb<<endl;
    }
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  reverse(v.begin(), v.end());
  for (int i = 0; i < N; i++) {
    cout << v.at(i);
    if (i != N - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}



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

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef pair < ll , ll > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

int A[N],n,i,mx,a,b;

main(){
    cin >> n;
    for(i=1;i<=n;i++) { cin >> A[i]; mx = max(A[i] , mx); }

    a = -mod;
    b = mod;
    for(i=1;i<=n;i++){
        if(A[i] <= mx/2) a = max(a , A[i]);
        else b = min(b , A[i]);
    }
    
    if(mx/2 - a <= b - (mx+1)/2) cout << mx << " " << a;
    else cout << mx << " " << b;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
 
void insertionSort(int *,int ,int);
void shellSort(int *,int);
int count;
int main()
{
  int n,i,A[1000001];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  shellSort(A,n);
  for(i=0;i<n;i++)
    {
      printf("%d\n",A[i]);
    }
 
  return 0;
}
  void insertionSort(int *A,int n,int g)
  {
    int i,j,v;
    for(i=g;i<n;i++)
      {
    v=A[i];
    j=i-g;
    while(j>=0 && A[j]>v)
      {
        A[j+g]=A[j];
        j=j-g;
        count++;
      }
    A[j+g]=v;
      }
  
      }
 
  void shellSort(int *A,int n)
  {
    int m=0,G[n],i;
    G[0]=1;
     
    for(i=0;;i++)
      { 
    if(G[i]>n)break;
    G[i+1]=3*G[i]+1;
    m++;
      }
    printf("%d\n",m);
        for(i=m-1;i>=0;i--)
      {
    printf("%d ",G[i]);
    insertionSort(A,n,G[i]);
      }
    printf("\n%d\n",count);
 
  }

Measured memory_bytes: 4512
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
int main()
{
    string s,t;
    cin>>s>>t;
    lg l1=s.length();
    lg l2=t.length();
    lg ans = INT_MAX;
    for(lg i=0;i<=l1-l2;i++)
    {
        lg now=0;
        for(lg j=0;j<l2;j++)
        {
            if(s[i+j]!=t[j])
                now++;
        }
        ans=min(ans,now);
    }
    cout<<ans<<endl;
}


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

  int main() {
    string S;
    cin >> S;
    string T;
    T=S;
    int count=0;
    
    reverse(S.begin(), S.end());
    
    
    for(int i=0; i<S.size(); i++){
      if( S.at(i)==T.at(i) )
        continue;
      
      else
        count++;
    }
    
    cout << count/2 << endl;
  }
      

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

const int MAX_N = 110, MAX_K = 20;
ll dp0[MAX_N][MAX_K];
ll dp1[MAX_N][MAX_K];
int L, K;
char N[MAX_N];

int main()
{
    scanf("%s", N);
    L = strlen(N);
    for(int i = L; i > 0; --i) N[i] = N[i-1]; // 1-indexedにした
    N[0] = '0';
    scanf("%d", &K);

    dp1[0][0] = 1LL; // -1番目を0にしたとき、0～L-1番目の選び方次第でNより大きくなることがあるのでdp0[0][0] = 0
    for(int i = 1; i <= L; ++i) {
        ll k = N[i] - '0';
        dp0[i][0] = dp0[i-1][0] + (k > 0 ? dp1[i-1][0] : 0);
        dp1[i][0] = k > 0 ? 0 : dp1[i-1][0]; // k > 0のとき、dp[i-1][0]から遷移しようにしてもかならずNより大きくなってしまうので0になる
        for(int j = 1; j <= K; ++j) {
            dp0[i][j] = 9LL*dp0[i-1][j-1] + dp0[i-1][j] 
                        + max(0LL, k-1)*dp1[i-1][j-1]
                        + (k > 0LL ? dp1[i-1][j] : 0LL);
            dp1[i][j] = k > 0 ? dp1[i-1][j-1] : dp1[i-1][j];
            
        }
    }
    printf("%lld\n", dp0[L][K] + dp1[L][K]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

#define INF 1000000007;

void print(std::map<int, int> readMap){
    std::for_each(readMap.begin(), readMap.end(), [](auto elem){
        std::cout << elem.first << ", " << elem.second << std::endl;
    });
}

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

    std::map<int, int> mp;
    for(int i = 0; i < n; ++i){
        int val;
        std::cin >> val;

        auto itr = mp.find(val);
        if(mp.end() == itr){
            mp.insert(std::make_pair(val, 1));
        }else{
            ++itr->second;
        }
    }

//    std::cout << mp.size() << std::endl;

//    print(mp);

    bool flg = true;
    auto itr = mp.begin();
    int ref = 1 - n % 2;
    while(flg && mp.end() != itr){
        if(mp.begin() == itr){
            flg = ref == itr->first && ref + 1 == itr->second;
        }else{
            flg = ref == itr->first && 2 == itr->second;
        }
        ref += 2;
        ++itr;
    }


    long long ans = 1;
    if(flg){
        for(int i = 0; i < n / 2; ++i){
            ans *= 2;
            ans %= INF;
        }
    }else{
        ans = 0;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
 
#define pii pair<LL,LL>
#define mem(v, x) memset(v, x, sizeof v)
 
#define si(x) scanf("%d", &x)
#define sii(x, y) scanf("%d %d", &x, &y)
#define siii(x, y, z) scanf("%d %d %d", &x, &y, &z)
 
#define sf(x) scanf("%lf", &x)
#define endl '\n'

#define FOR(i , N) for(int i = 0  ; i < N ; i++)
#define FOR1(i , N) for(int i = 1  ; i <= N ; i++)

template <typename T> T six(T &n){n = 0;bool neg = false;char c = getchar();while( c < '0' || c > '9'){if(c == '-') neg = true;c = getchar();}while(c >= '0' && c <= '9'){n = n*10 + c-48;c = getchar();}if(neg) n = ~(n-1);return n;}

using namespace std;
 
typedef long long LL;
 
int SET(int N,int pos){return N=N | (1<<pos);}
int RESET(int N,int pos){return N= N & ~(1<<pos);}
bool CHECK(int N,int pos){return (bool)(N & (1<<pos));}

int main()
{

#ifndef ONLINE_JUDGE // dont use this in toph/codemarshal
    //freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
   int N;
   cin >> N;
   LL dp[N][3];
   FOR(i , N) {
      int x, y, z;
      cin >> x >> y >> z;
      if(i == 0) dp[i][0] = x, dp[i][1] = y, dp[i][2] = z;
      else {
         dp[i][0] = x + max(dp[i - 1][1], dp[i - 1][2]);
         dp[i][1] = y + max(dp[i - 1][0], dp[i - 1][2]);
         dp[i][2] = z + max(dp[i - 1][1], dp[i - 1][0]);
      }
   }
   cout << max(dp[N - 1][0], max(dp[N - 1][1] , dp[N - 1][2])) << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

bool E1[222222];
bool E2[222222];

int main() {
    int N,M;
    cin>>N>>M;
    for(int i=1;i<=N;i++)
        E1[i]=E2[i]=false;
    for(int i=1;i<=M;i++) {
        int u,v;
        cin>>u>>v;
        if (u==1) {
            E1[v]=true;
        }
        if (v==N)
            E2[u]=true;
    }
    bool ok=false;
    for(int w=2;w<=N-1;w++) {
        if (E1[w]&&E2[w])
            ok=true;
    }
    if(ok) {
        printf("POSSIBLE\n");
    } else {
        printf("IMPOSSIBLE\n");
    }
}

Measured memory_bytes: 640
N, K = map(int, input().split())

ans = 0

if K == 0:
  ans = N ** 2
else:
  for b in range(1, N + 1):
    p, r = divmod(N, b)
    ans += p * max(0, b - K) + max(0, r - K + 1)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    string s;
    cin >> N >> s;
    int min=N;
    vector<int> sa(N+1,0),sb(N+1,0);
    for (int i = 0; i < N; i++) {
        if(s.at(i)=='W') sa.at(i+1) = sa.at(i) + 1;
        else sa.at(i+1) = sa.at(i);
    } 
    for (int i = 0; i < N; i++) {
        if(s.at(i)=='E') sb.at(i+1) = sb.at(i) + 1;
        else sb.at(i+1) = sb.at(i);
    }
    for (int i = 0; i < N; i++) {
        int b = sb.at(N) - sb.at(i+1);
        if(sa.at(i) + b < min) min = sa.at(i) + b;
    }    
    cout << min << endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  set<string> st;
  REP(i,N){
    string S;
    IN(S);
    if(st.find(S)==st.end()) st.emplace(S);
  }

  OUT(st.size());

  return 0;
}


Measured memory_bytes: 19240
import           Control.Exception           (assert)
import           Control.Monad
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

type Edge = (Int, Int, Int)
eFrm  (frm, _, _)  = frm
eTo   (_, to, _)   = to
eCost (_, _, cost) = cost

longestPath :: Int -> V.Vector (Int, Int, Int) -> Int
  -> IO (V.Vector Int)
longestPath s edges numV = do
  let numE = V.length edges
      inf = 10^18 :: Int

  d <- VM.new numV
  VM.set d (-inf)
  VM.write d s 0

  let loop :: Int -> IO ()
      loop i | i > 2*numV = return ()
             | otherwise = do update <- loop2 (i >= numV) 0 False
                              if update
                                then loop (i+1)
                                else return ()

      loop2 :: Bool -> Int -> Bool -> IO Bool
      loop2 cyc j upd
        | j == V.length edges = return upd
        | otherwise = do
            let e = edges V.! j
            d_frm <- VM.read d (eFrm e)
            d_to  <- VM.read d (eTo e)
            let ucond = d_frm /= (-inf) && d_to < d_frm + eCost e
                upd' = upd || ucond
            when (ucond && not cyc) $
              VM.write d (eTo e) (min inf (d_frm + eCost e))
            when (ucond && cyc) $ VM.write d (eTo e) inf
            loop2 cyc (j+1) upd'

  loop 0
  res <- V.freeze d
  return res

main = do
  [n, m] <- getIntList
  edges <- V.replicateM m $ do
    [a, b, c] <- getIntList
    return (a-1, b-1, c)

  costs <- longestPath 0 edges n
  let inf = 10^18 :: Int
      ans = costs V.! (n-1)
  if ans == inf then putStrLn "inf" else print ans

Measured memory_bytes: 1148
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

dic = defaultdict(int)


# 3の倍数個
if N % 3 == 0:
    
    for a in A:
        dic[a] += 1

    n_kind = len(dic.keys())
    values = list(dic.keys())
    cnts = list(dic.values())
        
    # 整数の種類数で分岐
    if n_kind == 3:
        is_xor = False    
        # 3つの整数で xorの関係を作れるか判定
        for i in range(n_kind-2):
            for j in range(i+1, n_kind-1):
                for k in range(j+1, n_kind):
                    if values[i] ^ values[j] ^ values[k] == 0:
                        is_xor = True

        
        # 3つの整数がそれぞれ N/3個であるか判定
        is_n_valid = True
        for cnt in cnts:
            if cnt != N/3:
                is_n_valid = False

            
        if is_xor and is_n_valid:
            print('Yes')
        else:
            print('No')
    
    elif n_kind == 2:
        
        # 2つの整数がそれぞれ 2N/3個であり、0がN/3子であるか判定
        is_n_valid = True
        if 0 in values:
            for k, v in dic.items():
                if k == 0:
                    if v != N/3:
                        is_n_valid = False
                else:
                    if v != N * (2/3):
                        is_n_valid = False
        else:
            is_n_valid = False

        if is_n_valid:
            print('Yes')
        else:
            print('No')


    elif n_kind == 1:
        all_zero = True
        for a in A:
            if a != 0:
                all_zero = False

        if all_zero:
            print('Yes')
        else:
            print('No')        

    else:
        print('No')

# 3の倍数個以外の場合は、全て0である必要がある
else:
    all_zero = True
    for a in A:
        if a != 0:
            all_zero = False

    if all_zero:
        print('Yes')
    else:
        print('No')
           

Measured memory_bytes: 14468
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
  int abcde[5];
  
  int min_idx = 0;
  int min_time = 9;
  for(int i=0; i<5; i++){
    cin >> abcde[i];
    if(abcde[i]%10 != 0 && abcde[i]%10 < min_time){
      min_idx = i;
      min_time = abcde[i]%10;
    }
  }
  int time = 0;
  for(int i=0; i<5; i++){
    if(i == min_idx) time += abcde[i];
    else{
      if(abcde[i]%10 == 0) time += abcde[i];
      else time += (abcde[i]/10+1)*10;
    }
  }
  
  cout << time << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll>Q;

int main(void){
    int n,m;
    cin>>n>>m;
    vector<P>p(m);
    for(int i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        p[i].first = b;
        p[i].second = a;
    }
    sort(p.begin(),p.end());
    int ans = 0;
    ll t = 1;
    for(int i=0;i<m;i++){
        if(t<=p[i].second){
            ans++;
            t = p[i].first;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int n, x, y;
	cin >> n >> x >> y;
	
	vector<int> res (n, 0);
	
	for (int i = 1; i < n; i++){
		for (int j = i+1; j <= n; j++){
			int temp = min(j - i, abs(x - i) + 1 + abs(y - j));
			temp = min(temp, abs(y - i) + 1 + abs(x - j));
			res[temp]++;
		}
	}


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



	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s;
    cin>>s;
    cout<<(s[0]==s[1]&&s[1]==s[2]?"No":"Yes")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define L 200001
long n,k;
bool cmp(pair < long , long > tmp1,pair < long , long > tmp2)
{
    return tmp1.second<tmp2.second;
}
void solve()
{
    long i,x;
    vector < long > tag(L,0);
    vector < pair < long , long > > res;
    for (i=0;i<n;i++)
    {
        cin>>x;
        tag[x]++;
    }
    for (i=1;i<L;i++)
    {
        if (tag[i])
        {
            pair < long , long > tmp;
            tmp.first=i;
            tmp.second=tag[i];
            res.push_back(tmp);
        }
    }
    sort(res.begin(),res.end(),cmp);
    x=res.size();
    if (x<=k) cout<<0;
    else
    {
        long long ans=0;
        for (i=0;i<x-k;i++)
            ans+=res[i].second;
        cout<<ans;
    }
    cout<<endl;
}
int main()
{
    while(cin>>n>>k)
        solve();
}

Measured memory_bytes: 8048
#create date: 2020-07-05 21:01

import sys
stdin = sys.stdin
from itertools import product

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def f(c, hi, wi):
    cnt = 0
    for i, hb in enumerate(hi):
        if hb == 0:
            continue
        for j, wb in enumerate(wi):
            if wb == 0:
                continue
            if c[i][j] == 1:
                cnt += 1
    return cnt



def main():
    h, w, k = na()
    hb = list(product([0,1], repeat=h))
    wb = list(product([0,1], repeat=w))
    c = list()
    for _ in range(h):
        c += [[1 if s == "#" else 0 for s in ns()]]
    #print(c)
    cnt = 0
    for hi in hb:
        for wi in wb:
            if f(c, hi, wi) == k:
                cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9244
#include<stdio.h>
#include<string.h>
long long int sum=0;
long long int sumnum(long long int n)
{
    long long int a;

    if(n/10==0)
    {
        sum+=(n%10);
        return sum;
    }
    else
    {
        sum+=(n%10);
        return sumnum(n/10);
    }
}

int main()
{
    long long num,s;
    scanf("%lld",&num);
    s=sumnum(num);

    if(num%s==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }


    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n,m;
		cin >> n >> m;
		cout << n*(n-1)/2+m*(m-1)/2 << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

from functools import reduce

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(a))

Measured memory_bytes: 3828
from functools import reduce
while True:
    n = input()
    if n == '0000': break
    if len(n) < 4: n = n.zfill(4)
    if reduce(lambda x,y: x and y, [n[0] == s for s in n]):
        print('NA')
    else:
        cnt = 0
        while n != '6174':
            s = ''.join(sorted(n))
            l = s[::-1]
            n = str(int(l)-int(s))
            if len(n) < 4: n = n.zfill(4)
            cnt += 1
        print(cnt)

Measured memory_bytes: 6724
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;

using namespace std;

int main(){
	
	int a[3],ans=0;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	for(int i=1;i<3;i++){
		ans+=abs(a[i]-a[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    a, b, c, k = map(int, args[0].split())

    ret = min(a, k)
    k -= ret
    k = max(0, k-b)
    ret -= k

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

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

int main()
{
  string S;
  cin >> S;
  vector<int> count(3, 0);
  rep(i, S.size())
  {
    count[S[i] - 'a']++;
  }
  SORT(count);
  if(count[2] - count[0] < 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int arr[100002];
int r[100002];

int main()
{
	int n, m;
	int ans = 0;

	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; i++)
	{
		int l, r;
		scanf("%d %d", &l, &r);
		arr[l] += 1;
		arr[r + 1] -= 1;
	}

	for (int i = 1; i <= n; i++)
		r[i] = r[i - 1] + arr[i];
	
	for (int i = 1; i <= n; i++)
		if (r[i] == m)
			ans++;

	printf("%d", ans);
	
	return 0;
}

Measured memory_bytes: 896
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
int main() {
	int N, a = 0;
	cin >> N;
	a = 0;
	for (int i = 1; i < (N + 1) / 2; i++)
	{
		a += (N - 1) / i;
	}
	cout << a + N / 2 << endl;

	return 0;
}

Measured memory_bytes: 3632
from copy import copy
import sys
sys.setrecursionlimit(1000000)

count = 0
a = []
while(1):
    try:
        a.append([int(i) for i in input().split(",")])
        count += 1
    except EOFError:
        break
dim = int(count/2)+1
b = [[0 for i in range(dim+1)] for j in range(dim+1)]
for i in range(dim):
    for j in range(i+1):
        b[i-j][j] = a[i][j]
for i in range(dim-1):
    for j in range(dim-i-1):
        b[dim-1-j][i+1+j] = a[i+dim][j]

dp_ = [[True if i < dim else 0 for i in range(dim+1)] if j < dim else [0 for i in range(dim+1)] for j in range(dim+1)]

def dp(i,j):
    global dp_
    if dp_[i][j] is True:
        dp_[i][j] = b[i][j] + max(dp(i+1,j),dp(i,j+1))
        return dp_[i][j]
    else:
        return dp_[i][j]

print(dp(0,0))


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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int x; cin >> x;
    //vector<int> ab(2*1e4+1);
    vector<int> ab(2*1e4+1);
    for(int i=0; i<1e4; i++) ab.PB(pow(i,5));
    for(int i=0; i<1e4; i++) ab.PB(pow(i,5)*-1);
    sort(all(ab));
    rep(i,ab.size()){
        int a=x+ab[i];
        auto itr=lower_bound(all(ab),a);
        if(*itr-ab[i]==x) {
            if(*itr<0){
                *itr*=-1;
                cout<<-1*pow(*itr,1.0/5.0)<<' ';
            }else{
                cout<<pow(*itr,1.0/5.0)<<' ';
            }

            if(ab[i]<0){
                ab[i]*=-1;
                
                cout<<pow(ab[i],1.0/5.0)*-1<<endl;
                return 0;
            }else{
                
                cout<<pow(ab[i],1.0/5.0)<<endl;
                return 0;
            }
            //cout<<*itr<<' '<<ab[i]<<endl;
        }
    }


    /*
    for(int i=0; i<ab.size(); i++){
        ab[i]=pow(i,5);
    }
    rep(i,ab.size()){
        int a=x-ab[i];
        int b=x+ab[i];
        auto itr1=lower_bound(all(ab),a);
        auto itr2=lower_bound(all(ab),b);
        if(*itr1-ab[i]==x) {cout<<*itr1<<' '<<ab[i]<<endl; return 0;}
        if(*itr1*-1-ab[i]==x) {cout<<*itr1*-1<<' '<<ab[i]<<endl; return 0;}
        if(*itr1*-1+ab[i]==x) {cout<<*itr1*-1<<' '<<-1*ab[i]<<endl; return 0;}
        if(*itr1*+ab[i]==x) {cout<<*itr1*-1<<' '<<ab[i]*-1<<endl; return 0;}
        if(*itr2-ab[i]==x) {cout<<*itr2<<' '<<ab[i]<<endl; return 0;}
        if(*itr2*-1-ab[i]==x) {cout<<*itr2*-1<<' '<<ab[i]<<endl; return 0;}
        if(*itr2*-1+ab[i]==x) {cout<<*itr2*-1<<' '<<-1*ab[i]<<endl; return 0;}
        if(*itr2*+ab[i]==x) {cout<<*itr2*-1<<' '<<ab[i]*-1<<endl; return 0;}

    }
    */
    /*
    for(int i=0; i<1e4; i++){
        ab[i]=-1*pow(i,5);
    }
    for(int i=1e4; i<2*1e4; i++){
        ab[i]=pow(i/1e4,5);
    }
    sort(all(ab));
    rep(i,ab.size()){
        int a=x-ab[i];
        auto itr=lower_bound(all(ab),a);
        if(*itr-ab[i]==x) {
            cout<<*itr << ' ' << ab[i]<<endl;
            return 0;
        }
    }
    */


}

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

int main()
{
    long long int r, ab;
    long long int a, b;
    cin >> a >> b;

    ab = a * b;

    if(a < b) swap(a, b);
    r = a % b;
    while(r) {
        a = b; b = r;
        r = a % b;
    }

    cout << ab / b;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long int lis[300000][2],chef[300000][2];
int main(){
    int N;
    cin>>N;

    long long int maxx=-2100000000,maxy=-2100000000,minx=2100000000,miny=2100000000;
    for(int i=0;i<N;i++){
        cin>>lis[i][0]>>lis[i][1];
        long long int x=lis[i][0]+lis[i][1];
        maxx=max(maxx,x);
        minx=min(minx,x);
        long long int y=lis[i][0]-lis[i][1];
        maxy=max(maxy,y);
        miny=min(miny,y);
    }
    cout<<max(abs(maxx-minx),abs(maxy-miny))<<endl;
    return 0;
}


Measured memory_bytes: 6252
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};

//--global--//



//----------//

void p(ll a, ll b){
    cout << a << " " << b << endl;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll a, b, k;
    cin >> a >> b >> k;
    if(a < k){
        k -= a;
        a = 0;
    }
    else{
        a -= k;
        p(a, b);
        return 0;
    }

    if(b < k){
        k -= b;
        b = 0;
    }
    else{
        b -= k;
        p(a, b);
        return 0;
    }

    p(a, b);
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  int N,M;cin>>N>>M;
  int tmp=0;
  int tmp1=0;
  vector<VI> key(M,vector<int>(N,0));
  vector<int> p(M,0);
  vector<int> s(N,0);
  for(int i=0;i<M;i++){
    cin>>tmp;
    for(int j=0;j<tmp;j++){
      cin>>tmp1;
      tmp1--;
      key[i][tmp1]=1;
    }
  }
  for(int i=0;i<M;i++){
    cin>>p[i];
  }
  int bit=pow(2,N);
  int ans=0;
  int count=0;

  for(int i=0;i<bit;i++){
    for(int t=0;t<N;t++){
      s[t]=0;
    }
    for(int j=0;j<N;j++){
      tmp=pow(2,j);
      if((i&tmp)==tmp){
        s[j]=1;
      }
    }
    for(int j=0;j<M;j++){
      count=0;
      for(int r=0;r<N;r++){
        if(key[j][r]==1&&s[r]==1){
          count=count+1;
        }
      }
      if(count%2==p[j]){
        if(j==M-1){
          ans=ans+1;
        }
      }
      else{break;}
      }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 632
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			int n = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();

			Map<Integer, Integer> map = new LinkedHashMap<Integer, Integer>();
			for (int i = 1; i <= n - 1; i++) {
				map.put(i, n - i);
			}
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					int dist = j - i;
					int adist = Math.abs(i - x) + 1 + Math.abs(j - y);
					if (adist < dist) {
						map.put(dist, map.get(dist) - 1);
						map.put(adist, map.get(adist) + 1);
					}
					// System.out.println(i + " " + j + " " + dist + " " + adist);
				}
			}
			for (Integer string : map.values()) {
				System.out.println(string);
			}

		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

Measured memory_bytes: 62380
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int table[100000];

int main(){

	int N;
	scanf("%d",&N);

	int maximum = 0;

	for(int i = 0; i < N; i++){
		scanf("%d",&table[i]);
		maximum = max(maximum,table[i]);
	}

	vector<int> V;

	for(int i = 1; i <= maximum; i++){
		if(maximum%i == 0)V.push_back(i);
	}

	int ans = 0,index;

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

		for(index = 0; V[index] < table[i]; index++);
		ans += V[index]-table[i];
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int i,k,l;
  k=0;
  cin >> s;
  l=s.size();
 
  for(i=0;i<l;++i)
  {
  k=k+int(s.at(i)-'0')%9;
  k=k%9;
  }
  if(k==0) cout << "Yes";
  else cout << "No";
  
return 0;
}

Measured memory_bytes: 3724
use proconio::input;

fn main() {
    input! {
        n: i32,
        p: [i32; n],
    }

    solve(&p);
}

fn solve(p: &[i32]) {
    let mut cnt = 0;
    for i in 0..p.len() {
        if !(i as i32 + 1 == p[i]) {
            cnt += 1;
        }

        if cnt > 2 {
            println!("NO");
            return;
        }
    }

    println!("YES");
}


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

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

  if (N > 10) {
    cout << R << endl;
  } else {
    cout << R + 100 * (10 - N) << endl; 
  }
}

Measured memory_bytes: 256
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 10**7+9
inf = 10**20

s = input()
q = int(input())


sentou = ""
matubi = ""
reverse = False
for i in range(q):
    l = input().split()
    if l[0]=="1":
        reverse = not(reverse)
    else:
        if l[1]=="1":
            if reverse:
                matubi += l[2][::-1]
            else:
                sentou = l[2] + sentou
        else:
            if reverse:
                sentou = l[2][::-1] + sentou
            else:
                matubi += l[2]
    #print(sentou,s,matubi)

if reverse:
    print(matubi[::-1] + s[::-1] + sentou[::-1])
else:
    print(sentou + s + matubi)


Measured memory_bytes: 6540
#include<bits/stdc++.h>
using namespace std;
int main(){
       int n,k,q;
       cin>>n>>k>>q;
       vector<int>vec(q);
       for(int i;i<q;i++) cin>>vec[i];
       vector<int>point(n);
       for(int i;i<n;i++)point[i]=k-q;
       for(int i=0;i<q;i++){
               point[vec[i]-1]++;
       }
       for(int i=0;i<n;i++){
             if(point[i]>0){
                     cout << "Yes" <<endl;
             }else{
                     cout << "No" << endl;
             }
       }
        
       
}


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

int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> fcan(n+1), scan(n+1);
    priority_queue<int64_t, vector<int64_t>, greater<int64_t>> fpq;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        fpq.push(a);
        fcan[0] += a;
    }
    vector<int64_t> amid(n);
    for (auto& e : amid) cin >> e;
    priority_queue<int64_t> spq;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        spq.push(a);
        scan[n] += a;
    }

    for (int64_t i = 0; i < n; i++) {
        fpq.push(amid[i]);
        fcan[i+1] = fcan[i] + amid[i] - fpq.top(); fpq.pop();
        spq.push(amid[n-1-i]);
        scan[n-i-1] = scan[n-i] + amid[n-1-i] - spq.top(); spq.pop();
    }

    int64_t ans = -1e18;
    for (int64_t i = 0; i <= n; i++) ans = max(ans, fcan[i] - scan[i]);

    cout << ans << endl;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int H, W;
char a[100][100];
bool h[100], w[100];
int main() {
	cin >> H >> W;
	for (int i = 0; i != H; ++i) {
		for (int j = 0; j != W; ++j) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i != H; ++i) {
		for (int j = 0; j != W; ++j) {
			if (a[i][j] == '#')
				h[i] = w[j] = true;
		}
	}
	for (int i = 0; i != H; ++i) {
		if (h[i]) {
			for (int j = 0; j != W; ++j) {
				if (w[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int x;
    cin >> x;
    if(x >= 30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
	
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 10007;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*-----Library-----*/
int n,k;
int sum[210000];
int make_index(int s){
    int t=(sum[s]-(s+1)%k+k)%k;
    return t;
}
signed main(){
    cin>>n>>k;
    int a[210000];
    for(int i=0;i<n;i++)cin>>a[i];
    sum[0]=a[0]%k;
    for(int i=1;i<n;i++)sum[i]=(sum[i-1]+a[i])%k;
    map<int,int> cnt;
    for(int i=0;i<min(k-1,n);i++){
        cnt[make_index(i)]++;
    }
    int ans=0;
    ans+=cnt[0];
    for(int i=0;i<n-1;i++){
        cnt[make_index(i)]--;
        if(i+k-1<=n-1){
            cnt[make_index(i+k-1)]++;
        }
        ans+=cnt[(sum[i]-(i+1)%k+k)%k];
       
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;
  int ans = 0;
  vector<int> d(n + 1, 1);
  for (int i = 2; i <= n; i++) {
    int j = i;
    while (j < n) {
      d[j]++;
      j += i;
    }
  }
  for (int c = 1; c < n; c++) {
    ans += d[n - c];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7088
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			string str = Console.ReadLine();

			switch (str)
			{
				case "SUN":
					Console.WriteLine("7");
					break;
				case "MON":
					Console.WriteLine("6");
					break;
				case "TUE":
					Console.WriteLine("5");
					break;
				case "WED":
					Console.WriteLine("4");
					break;
				case "THU":
					Console.WriteLine("3");
					break;
				case "FRI":
					Console.WriteLine("2");
					break;
				case "SAT":
					Console.WriteLine("1");
					break;
				default:
					break;
			}

			return;

		}


	}

}


Measured memory_bytes: 13152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n;
    cin >> n;
    int maxn = 0;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a[i];
        maxn = max(maxn, a[i]);
    }
    vector<int> cnt(maxn+1, 0);
    for (int i=0; i<n; i++) {
        if (cnt[a[i]] != 0) {
            cnt[a[i]] = 2;
            continue;
        }
        for (int j=1; j*a[i]<=maxn; j++)
            cnt[j*a[i]]++;
    }
    int ans = 0;
    for (int i=0; i<n; i++)
        if (cnt[a[i]] == 1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 7632
//speed test
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,m,a[N],b[N],du[N],ans;
bool vis[N],isok;
vi g[N];
map<int,int> to,sum;

inline void dfs(int x){
	vis[x]=1;
	if(x==a[n]) isok=1;
	for(int y:g[x])
		if(!vis[y]) dfs(y);
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	for(int i=1;i<=n;i++) a[n+1]^=a[i],b[n+1]^=b[i];
	++n;
	for(int i=1;i<=n;i++){
		sum[a[i]]++,sum[b[i]]--;
		if(!to[a[i]]) to[a[i]]=++m;
	}
	for(int i=1;i<=n;i++){
		if(sum[a[i]]){puts("-1");return 0;}
		a[i]=to[a[i]],b[i]=to[b[i]];
	}
	for(int i=1;i<n;i++)
		if(a[i]!=b[i]){
			g[a[i]].pb(b[i]);
			du[a[i]]++;du[b[i]]++;
			ans++;
		}
	if(!ans){puts("0");return 0;}
	g[a[n]].pb(b[n]);
	du[a[n]]++;du[b[n]]++;
	ans++;
	for(int i=1;i<=m;i++)
		if(!vis[i]&&du[i]){
			isok=0;dfs(i);
			if(!isok) ans++; else ans--;
		}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  char a = S[0];
  int counter = 0;
  char b;
  for(int i=0; i<4; i++){
    if(S[i]==a)counter++;
    if(S[i]!=a)b = S[i];
  }
  if(counter==2){
    counter=0;
    for(int i=0; i<4; i++){
      if(S[i]==b)counter++;
    }
    if(counter==2)cout << "Yes" << endl;
    if(counter!=2)cout << "No" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256