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


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	ll n;
	cin>>n;
	vll p(n),q(n),r(n);
	for(ll i=0;i<n;i++)
		cin>>p[i];
	for(ll i=0;i<n;i++)
		cin>>q[i];
	for(ll i=0;i<n;i++)
		r[i]=i+1;
	ll a,b,c=0;
	do{
		if(p==r) a=c;
		if(q==r) b=c;
		c++;
	}while(next_permutation(r.begin(),r.end()));
	cout<<abs(a-b);
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
int main(){
  int n,p[101],i,j,k,l,x,m[101][101];
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d %d",&p[i-1],&p[i]);
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INT_MAX;
      for(k=i;k<j;k++){
	x=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(m[i][j]>x)m[i][j]=x;
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}



Measured memory_bytes: 2768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    function<ll(tuple<ll,ll,ll>)> sum=[&](tuple<ll,ll,ll>p){
        ll res=abs(get<0>(p)) + abs(get<1>(p)) + abs(get<2>(p));
        return res;
    };
    int n,m; cin>>n>>m;
    vector<vector<ll>> p(n,vector<ll>(3,0));
    rep(i,n) cin>>p[i][0]>>p[i][1]>>p[i][2];
    ll ans=0;
    rep(i,1<<3){
        vector<int> che(3,0);
        rep(j,3) if(i>>j&1) che[j]=1;
        vector<ll> pp(n,0);
        rep(j,n){
            rep(k,3){
                if(che[k]==0) pp[j]+=p[j][k];
                else pp[j]-=p[j][k];
            }
        }
        sort(etob(pp));
        ll kari=0;
        rep(j,m) kari+=pp[j];
        ans=max(ans,kari);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    map<int, int> mp;
    int n;
    cin >> n;
    int answer = 0;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        ++mp[t];
    }
    for (auto x : mp) {
        if (x.second >= x.first) {
            answer += x.second - x.first;
        } else {
            answer += x.second;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 4736
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL

struct node{
  int key;
  struct node *left;
  struct node *right;
  struct node *p;
};

typedef struct node * Node;

Node root;

/*??£?¨?*/
void Inorder_tree_walk(Node);
void Preorder_tree_walk(Node);
void insert(int);
void find(Node,int);
void delete(Node);
Node tree_Su(Node);
Node treeMini(Node);
Node treeSearch(Node,int);

/*main??¢??°*/
int main(){
  int i,x,num;
  char s[10];
  int check;

  scanf("%d",&num);
  for (i=0; i<num; i++){
    scanf("%s",s);

    if (strcmp("insert",s)==0){
      scanf("%d",&x);
      insert(x);
    }


    if  (strcmp("print",s)== 0){
      Inorder_tree_walk(root);
      puts("");

      Preorder_tree_walk(root);
      puts("");
    }



    if(strcmp("find",s)==0){
      scanf("%d",&x);
      find(root,x);

      }

    if(strcmp("delete",s)==0){
      scanf("%d",&x);
      delete(treeSearch(root,x));
    }


  }
  return 0;
}




/*???????????????*/
void Preorder_tree_walk(Node tree){
  printf(" %d",tree->key);
  if(tree != NIL){
    if((tree->left) != NIL)Preorder_tree_walk(tree->left);
    if((tree->right) != NIL)Preorder_tree_walk(tree->right);
  }
}
/*???????????????*/
void Inorder_tree_walk(Node tree){

  if(tree != NIL){

    if((tree->left) != NIL){Inorder_tree_walk(tree -> left);}

    printf(" %d",tree->key);

    if(tree->right!=NIL){Inorder_tree_walk(tree->right);}
  }
}


/*?????\*/
void insert(int k){
 Node y=NIL;
 Node x=root;
 Node z;

 /*??°??????key????????????*/
    z = malloc(sizeof(struct node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;


     while(x!=NIL){
       y=x;
       if(z->key < x->key) x=x->left;
       else x=x->right;
     }
     z->p=y;

     if(y == NIL) root=z;
     else if((z->key) < (y->key)) y->left=z;
     else y->right=z;
}

 void find(Node tree, int k){

   while (tree != NIL && k != tree->key){

     if(k < tree->key) tree = tree->left;
     else tree=tree->right;
   }
   if( tree==NIL)puts("no");
   if( tree!=NIL)puts("yes");
 }

void delete(Node z){
  Node x,y;


  if(z->left == NIL || z->right == NIL)y=z;
  else y = tree_Su(z);


  if(y->left != NIL)x = y->left;
  else x = y->right;

  if(x!=NIL)x->p = y->p;

  if(y->p == NIL)root=x;
  else if (y ==  y->p->left)y->p->left =x;
    else y->p->right =x;

  if(y != z) z->key = y->key;

}
Node tree_Su(Node x){

  Node y;
  if(x->right != NIL)return treeMini(x->right);

  y=x->p;

  while(y != NIL && x == y->right){

    x=y;
    y=y->p;
  }


return y;
}

Node treeMini(Node x){

  while(x->left != NIL){
    x=x->left;

  }


  return x;
}
Node treeSearch(Node x, int k){

  while(x != NIL && k != x->key){

    if(k < x->key)x = x->left;
    else x=x->right;

  }

  return x;
}

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

int main()
{
    int S, h, m, s, r;
    cin >> S;

    h = S / 3600;
    r = S % 3600;
    m = r / 60;
    r = r % 60;
    s = r;

    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>

using i64 = long long;

template<typename T> T abs(T x) { return x < 0 ? -x : x; }

const int N = 10000 + 7;

int n, m;
i64 x[N], y[N];
i64 c[N];

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld%lld", x + i, y + i);
		if ((x[1] + y[1] - x[i] - y[i]) & 1) return printf("-1"), 0;
	}
	m = 36;
	for (int i = 36; i; --i)
		c[i] = 1ll << 36 - i;
	if ((x[1] + y[1]) % 2 == 0) c[++m] = 1;
	printf("%d\n", m);
	for (int i = 1; i <= m; ++i)
		printf("%lld ", c[i]);
	printf("\n");
	for(int i = 1; i <= n; ++i) {
		i64 u = 0, v = 0;
		for (int j = 1; j <= m; ++j) {
			i64 dx = abs(u - x[i]), dy = abs(v - y[i]);
			if (dx > dy)
				x[i] > u ? (printf("R"), u += c[j]) : (printf("L"), u -= c[j]);
			else
				y[i] > v ? (printf("U"), v += c[j]) : (printf("D"), v -= c[j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 3836
#!/usr/bin/env python
# coding: utf-8

# In[2]:


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


# In[9]:


def main():
    for j in range(K,N):
        if A[j] > A[j-K]:
            print("Yes")
        else:
            print("No")


# In[10]:


if __name__ == '__main__':
    main()


# In[ ]:






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

using namespace std;

typedef long long ll;

int n, m, s;
ll a[51][51], b[51][51];
ll c[51];
ll d[51];

int maxa = 0;

struct Data {
  ll t, s, p;
  bool operator<(const Data& d)const{return t > d.t;}
};

ll dijkstra(int g) {
  priority_queue< Data > Q;
  bool visited[51][2501] = {false};
  Q.push({0, min(s, maxa * (n-1)), 1});

  while(!Q.empty()) {
    Data now = Q.top();
    Q.pop();

    if (now.p == g) {
      return now.t;
    }
    if (visited[now.p][now.s]) continue;
    visited[now.p][now.s] = true;

    if (now.s + c[now.p] <= maxa * (n-1)) {
      Q.push({now.t + d[now.p], now.s + c[now.p], now.p});
    }

    for (int j = 1; j <= n; j++){
      if (a[now.p][j] == 0) continue;

      int ns = now.s - a[now.p][j];
      if (ns < 0) continue;
      Q.push({now.t + b[now.p][j], ns, j});
    }
  }
}

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

  for (int i = 0; i < m; i++) {
    int u, v, aa, bb;
    cin >> u >> v >> aa >> bb;
    a[u][v] = a[v][u] = aa;
    b[u][v] = b[v][u] = bb;
    maxa = max(maxa, aa);
  }
  for (int i = 1; i <= n; i++){
    cin >> c[i] >> d[i];
  }

  for (int i = 2; i <= n; i++) {
    cout << dijkstra(i) << endl;
  }

  return 0;
}


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

int main(){
  ll n,k;
  cin >> n>>k;
  n%=k;
  n=min(n,abs(n-k));
  cout <<n<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(all(A));
    sort(all(B));
    sort(all(C));
    vector<ll> BC(N);
    
    int j = 0;
    rep(i, N) {
        while(B[i] >= C[j] && j < N) j++;
        BC[i] = N - j;
    }
    
    vector<ll> sBC(N);
    ll cur = 0;
    for(int i = (int)N - 1; i >= 0; i--) {
        cur += BC[i];
        sBC[i] = cur;
    }
    
    ll ans = 0;
    j = 0;
    rep(i, N) {
        while(A[i] >= B[j] && j < N) j++;
        ans += sBC[j];
    }
    
    
    output(ans);
    
    
    
    
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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 gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N;
  cin >> N;
  rep(i,N){
    int t,x,y;
    cin >> t >> x >> y;
    if(t<x+y){
      cout << "No" << endl;
      return 0;
    }
    else if(t%2!=(x+y)%2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int64_t gcd(int64_t a, int64_t b)
{
    if (a < b)
    {
        swap(a, b);
    }
    while (b != 0)
    {
        int64_t t = a % b;
        a = b;
        b = t;
    }
    return a;
}

vector<pair<int64_t, int64_t>> p_fact(int64_t n)
{
    vector<pair<int64_t, int64_t>> res;
    for (int64_t p = 2; p * p <= n; p++)
    {
        if (n % p == 0)
        {
            int64_t e = 0;
            while (n % p == 0)
            {
                n /= p;
                e += 1;
            }
            res.push_back(make_pair(p, e));
        }
    }
    if (n != 1)
    {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

int main()
{
    int64_t A, B;
    cin >> A >> B;

    int64_t g = gcd(A, B);
    vector<pair<int64_t, int64_t>> fg = p_fact(g);
    cout << fg.size() + 1 << endl;
}

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

const int MOD = 1000000007;

int main(){
    ll n;
    cin >> n;
    pair<ll, ll> p[200000];
    for (ll i = 0; i < n;i++){
        cin >> p[i].second >> p[i].first;
    }
    sort(p, p + n);
    ll sum = 0;
    for (ll i = 0; i < n;i++){
        sum += p[i].second;
        if(p[i].first < sum){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 3328
S = str(input())
Q = int(input())

fwd = ""
rev = ""
now = 1

for i in range(Q) :
  Qn = list(map(str, input().split()))
  
  if Qn == ["1"] :
    now *=-1
  else :
    if now == 1 :
      if Qn[1] == "1" :
        fwd = Qn[2] + fwd
      if Qn[1] == "2" :
        rev = rev + Qn[2]
    else : 
      if Qn[1] == "1" :
        rev = rev + Qn[2]
      if Qn[1] == "2" :
        fwd = Qn[2] + fwd

ans = fwd + S + rev
if now == -1 :
  ans = ans[::-1]
print(ans)

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

int main() {

    int n; cin >> n;
    vector<int> ans(n + 1, 0);
    for (int i = 2; i <= n; i++) {
        int a; cin >> a;
        ans[a]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4056
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

ll dp[105][100005];

void solve(){
    int n;
    ll k;
    cin>>n>>k;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>sum(k+5);
    dp[0][0]=1;
    rep(i,n){
        sum[0]=0;
        for(int j=0;j<=k;++j)sum[j+1]=(sum[j]+dp[i][j])%mod;
        for(ll j=0;j<=k;++j){
            dp[i+1][j]=(sum[j+1]-sum[max(0LL,j-a[i])]+mod)%mod;//i+1番目までにj個配るとき,i番目までにj-a[i]個配っておかないといけない.
            //cout<<dp[i+1][j]<<"\n";
        }
    }
    cout<<dp[n][k]<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 80128
def main():
    n, m = map(int, input().split())
    g = [[] for i in range(n)]
    for i in range(m):
        l, r, d = map(int, input().split())
        g[l - 1].append((r - 1, d))
        g[r - 1].append((l - 1, -d))
    dis = [0] * n
    visited = [False] * n
    for i in range(n):
        if visited[i]:
            continue
        stack = list([i])
        visited[i] = True
        while len(stack):
            v = stack[-1]
            stack.pop()
            for u, d in g[v]:
                if not visited[u]:
                    dis[u] = dis[v] + d
                    stack.append(u)
                    visited[u] = True
    for v in range(n):
        for u, d in g[v]:
            if dis[v] + d != dis[u]:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;


//a# a# a#
//aba#aba#aba#
//a # a # a
signed main() {
  string s;
  ll K, N, ans=0;
  set<char> se;
  cin >> s >> K;
  N = s.size();
  rep(i,N)
    se.insert(s[i]);

  if (se.size() == 1) {
    ans = (N*K) / 2;
  } else if (K == 1) {
    for (int i=1; i<N; i++) {
      if (s[i] == s[i-1]) {
        s[i] = '#';
        ans++;
      }
    }
  } else if (K == 2) {
    s = s+s;
    for (int i=1; i<2*N; i++) {
      if (s[i] == s[i-1]) {
        s[i] = '#';
        ans++;
      }
    }
  } else {
    string s1 = s, s2 = s, sn = s;
    // 1つめ
    for (int i=1; i<N; i++) {
      if (s1[i] == s1[i-1]) {
        s1[i] = '#';
        ans++;
      }
    }
    // cout << "ans @ 1 = " << ans << endl;
    // 2つめ
    for (int i=0; i<N; i++) {
      if (i==0) {
        if (s2[i] == s1[N-1]) {
          s2[i] = '#';
          ans += K-2;
        }
      } else {
        if (s2[i] == s2[i-1]) {
          s2[i] = '#';
          ans += K-2;
        }
      }
    }
    // cout << "ans @ 2 = " << ans << endl;
    // Nつ目
    for (int i=0; i<N; i++) {
      if (i==0) {
        if (sn[0] == s2[N-1]) {
          sn[i] = '#';
          ans++;
        }
      } else {
        if (sn[i] == sn[i-1]) {
          sn[i] = '#';
          ans++;
        }
      }
    }
    //cout << "ans @ N = " << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class BMixJuice {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n,k;
        cin>>n>>k;
        int a[n];
        for (int i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n);
        int sum=0;
        for (int i=0;i<k;i++)
            sum+=a[i];
        cout<<sum;
	}
};


int main() {
	BMixJuice solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3612
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# 入力が文字のリスト
# S = list(input().split())

#入力が数字のリスト
# A = list(map(int, input().split()))

# 入力がリストのリスト
# S = [list(input()) for i in range(H)]


# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


N = int(input())

# 名前の頭文字のリスト
S = [input()[0] for i in range(N)]

# M, A, R, C, Hで始まる人の人数
headers = [0,0,0,0,0]

# M, A, R, C, Hから3文字選ぶ組み合わせ＝10通り
P = [0,0,0,0,0,0,1,1,1,2]
Q = [1,1,1,2,2,3,2,2,3,3]
R = [2,3,4,3,4,4,3,4,4,4]


for i in range(N):
    if S[i] == 'M':
        headers[0] += 1
    if S[i] == 'A':
        headers[1] += 1
    if S[i] == 'R':
        headers[2] += 1
    if S[i] == 'C':
        headers[3] += 1
    if S[i] == 'H':
        headers[4] += 1

count = 0

for i in range(10):
    count += headers[P[i]] * headers[Q[i]] * headers[R[i]]

print(count)






Measured memory_bytes: 13540
n = int(input())
d = [int(input()) for _ in range(n)]

d.sort()

ans = -float('inf')
for i in range(n):
    stack = [d[i]]
    for j in range(i + 1, n):
        if stack[-1] < d[j]:
            stack.append(d[j])
    ans = max(ans, len(stack))

print(ans)

Measured memory_bytes: 3064
import collections
x,y,aa,bb,cc = map(int,raw_input().split(' '))

aas = map(int, raw_input().split(' '))
bbs = map(int, raw_input().split(' '))
ccs = map(int, raw_input().split(' '))

aas.sort(key = lambda x:-x)
bbs.sort(key = lambda x:-x)
ccs.sort(key = lambda x:-x)
aas = aas[:x]
bbs = bbs[:y]

r = (aas + bbs)
r.sort()

i = 0
j = 0
while(j < len(ccs) and i < len(r)):
	if ccs[j] > r[i]:
		r[i] = ccs[j]
		i+=1
	j+=1

print sum(r)

Measured memory_bytes: 79120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
	int n;
	cin >> n;
	auto list = map<string, vector<pair<int, int>>>();
	for(auto i = 0; i < n; ++i){
		string s;
		int p;
		cin >> s >> p;
		list[s].push_back(make_pair(p, i + 1));
	}
	for(auto&& v : list){
		sort(v.second.begin(), v.second.end(), greater<pair<int, int>>());
	}
	for(auto v : list){
		for(auto i = 0; i < (int)v.second.size(); ++i){
			cout << v.second[i].second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int d[n+1];
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  int m;
  cin>>m;
  int t[m+1];
  for(int i=0;i<m;i++){
    cin>>t[i];
  }
  sort(d,d+n);
  sort(t,t+m);
  int cnt=0;
  for(int i=0;i<n;i++){
    if(d[i]==t[cnt]){
      cnt++;
    }
  }
  if(cnt==m)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return(0);
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> l(m),r(m);
    int lmax=1, rmin=100000;
    for(int i=0; i<m; i++){
        cin >> l.at(i) >> r.at(i);
        lmax=max(l.at(i),lmax);
        rmin=min(r.at(i),rmin);
    }
    if(rmin-lmax+1>0) cout << rmin-lmax+1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3936
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::cmp::*;
use std::collections::*;

fn main() {
    input! {
        n:usize,
        m:usize,
        s:i64,
        uvab:[(usize,usize,i64,i64);m],
        cd:[(i64,i64);n],
    }
    let mut g = Graph::new(n * 2501);
    for e in uvab.iter() {
        for i in e.2..=2500 {
            g.add_directional_edge(
                p2i(e.0 - 1, i as usize),
                p2i(e.1 - 1, (i - e.2) as usize),
                e.3,
            );
            g.add_directional_edge(
                p2i(e.1 - 1, i as usize),
                p2i(e.0 - 1, (i - e.2) as usize),
                e.3,
            );
        }
    }
    for i in 0..n {
        for j in 0..=2500 {
            g.add_directional_edge(p2i(i, j), p2i(i, min(j + cd[i].0 as usize, 2500)), cd[i].1);
        }
    }
    let dist = dijkstra(&g, p2i(0, min(s, 2500) as usize));
    for i in 1..n {
        let mut ans = std::i64::MAX;
        for j in 0..=2500 {
            ans = min(ans, dist[p2i(i, j)]);
        }
        println!("{}", ans);
    }
}

fn p2i(x: usize, y: usize) -> usize {
    x * 2501 + y
}

// グラフの辺
#[derive(Debug, Copy, Clone)]
struct Edge {
    to: usize,
    cost: i64,
}
impl Edge {
    pub fn new(to: usize, cost: i64) -> Edge {
        Edge { to: to, cost: cost }
    }
}
struct Graph {
    adjacency: Vec<Vec<Edge>>,
}
impl Graph {
    pub fn new(size: usize) -> Self {
        Graph {
            adjacency: vec![vec![]; size],
        }
    }
    fn len(&self) -> usize {
        self.adjacency.len()
    }
    fn add_directional_edge(&mut self, from: usize, to: usize, cost: i64) {
        self.adjacency[from].push(Edge::new(to, cost));
    }
    fn add_undirectional_edge(&mut self, from: usize, to: usize, cost: i64) {
        self.add_directional_edge(from, to, cost);
        self.add_directional_edge(to, from, cost);
    }
}
impl std::ops::Index<usize> for Graph {
    type Output = Vec<Edge>;
    fn index(&self, vertex: usize) -> &Self::Output {
        &self.adjacency[vertex]
    }
}

fn dijkstra(g: &Graph, start: usize) -> Vec<i64> {
    use std::cmp::Reverse;
    let mut res = vec![std::i64::MAX; g.len()];
    res[start] = 0;
    let mut heap = std::collections::BinaryHeap::with_capacity(1000000);
    heap.push(Reverse((0, start)));
    while let Some(Reverse((dist, now))) = heap.pop() {
        if res[now] == dist {
            for e in g[now].iter() {
                if res[now] + e.cost < res[e.to] {
                    res[e.to] = res[now] + e.cost;
                    heap.push(Reverse((res[e.to], e.to)));
                }
            }
        }
    }
    res
}

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

int sum(int n, int d){
  int terms = n / d;
  int ret = terms * (2 * d + (terms - 1) * d);
  ret >>= 1;
  return ret;
}

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

    int n;
    cin >> n;
    int cur = n * (n + 1) / 2;
    cur -= sum(n, 3);
    cur -= sum(n, 5);
    cur += sum(n, 15);
    cout << cur << endl;
}




Measured memory_bytes: 3652
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)

# 大きい方からチェック
for i in range(l):
    a = a_ls[-(i+1)]
    s = sum(N[(l-i)-1::(l-i)])%2
    # print(s)
    # print(a)
    if a != s:
        N[-(i+1)]=1
        
sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sum(N))
    print(sen[:-1])


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

int main() {
    int H, W;

    for ( ;; ) {
        cin >> H >> W;

        if ( H == 0 && W == 0 ) break;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++ ) {
                cout << "#" ;
            }
            cout << '\n';
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
  int num;
  int drink;
  int time;
  int kekka;
  cin >> num;
  
  vector<int> vec(num);
  for(int i = 0; i < num; i++){
    cin >> vec.at(i);
    time += vec.at(i);
  }
  
  cin >> drink;
  
  int tmpNum,tmpTime;
  for(int i = 0; i < drink; i++){
    cin >> tmpNum >> tmpTime;
    kekka = time - vec.at(tmpNum-1) + tmpTime;
    cout << kekka - 4197814 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define mo 998244353
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define ms 16
#define endl '\n'

 
using namespace std ;
 
#define N 400005

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{
    
///////////////////////////////////////////
    fastio;

    lli n;
    cin>>n;

    cout<<(n-2)*180;

}

Measured memory_bytes: 256
n = gets().to_i

def bunkai(n)
  rootn = (n**(0.5)).floor
 (1..rootn).to_a.reverse.each{|i|
  if n % i ==0
    return [i,n/i]
  end
   }
end

ary = bunkai(n)
puts ary[0] + ary[1]-2


Measured memory_bytes: 19452
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

void f(int &a, int &b, int &ans) {
  if(a>=b) {
      ans += a;
      a--;
    } 
    else {
      ans += b;
      b--;
    }
}

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  rep(i, 2) f(a, b , ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

v = []
for line in sys.stdin:
    v.append([int(l) for l in line.split()])

n = v[0][0]
m = v[0][1]

a = None
for line in v[1:]:
  if a == None:
    a = line[1:]
  else:
    c = []
    for b in a:
      if b in line[1:]:
        c.append(b)
    a = c
print(len(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

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

  vector<ll> max_after(n+1, 0);
  for (ll i = n; i > 0; i--){
    if (max_after[i] > a[i-1]){
      max_after[i-1] = max_after[i];
    }
    else 
      max_after[i-1] = a[i-1];
  }


  ll ans = 0, m = 0;
  for (ll i = 0; i < n; i++){
    if (m < max_after[i] - a[i]){
      m = max_after[i] - a[i];
      ans = 1;
    }
    else if (m == max_after[i] - a[i]){
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> height(N);
  for (int i = 0; i < N; i++) {
    cin >> height.at(i);
  }
  int watchable;
  for (int i = 0; i < N; i++) {
    bool cansee = true;
    for (int j = 0; j < i; j++) {
      if (height.at(j) > height.at(i)) {
        cansee = false;
      }
    }
    if (cansee) {
      watchable++;
    }
  }
  cout << watchable << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // int型の2次元配列(3×4要素の)の宣言
  vector<vector<int>> data(3, vector<int>(3));
 
  // 入力 (2重ループを用いる)
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data.at(i).at(j);
    }
  }
  int N;
  cin >> N;

  int b;
  for(int i = 0; i < N; i++){
    cin >> b;
    for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if(data.at(i).at(j) == b){
        data.at(i).at(j) = 0;
      }
    }
  }
  }

  if((data.at(0).at(0) == 0 && data.at(0).at(1) == 0 && data.at(0).at(2) == 0) ||
    (data.at(1).at(0) == 0 && data.at(1).at(1) == 0 && data.at(1).at(2) == 0) ||
    (data.at(2).at(0) == 0 && data.at(2).at(1) == 0 && data.at(2).at(2) == 0) ||
    (data.at(0).at(0) == 0 && data.at(1).at(0) == 0 && data.at(2).at(0) == 0) ||
    (data.at(0).at(1) == 0 && data.at(1).at(1) == 0 && data.at(2).at(1) == 0) ||
    (data.at(0).at(2) == 0 && data.at(1).at(2) == 0 && data.at(2).at(2) == 0) ||
    (data.at(0).at(0) == 0 && data.at(1).at(1) == 0 && data.at(2).at(2) == 0) ||
    (data.at(0).at(2) == 0 && data.at(1).at(1) == 0 && data.at(2).at(0) == 0)){
      cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#AからBの排他的論理和　計算短縮版

import math
a,b=map(int,input().split())
c=0
list=[]
d=0


number_of_1=0
sum_of_1=0
nose=0
tail=0

if a%2==0:
	number_of_1=(b+1-a)//2
else:
	number_of_1=(b-a)//2

sum_of_1=number_of_1 % 2

if a%2==0:
	nose=0
else:
	nose=a

if b%2==0:
	tail=b
else:
	tail=0

print(nose^tail^sum_of_1)



Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
int main(void){
    int A,B,C,X,Y;
    scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
    int cash=0;
    if(A+B <= C*2){
        printf("%d",A*X+B*Y);
    }else if(A+B > C*2){
        if(X>=Y){
            cash += C * 2 * Y;
            if(A<=C*2){
                cash += (X-Y)*A;
            }else if(A>C*2){
                cash += (X-Y)*C*2;
            }
        }else if(Y>X){
            cash += C * 2 * X;
            if(B<=C*2){
                cash += (Y-X)*B;
            }else if(B>C*2){
                cash += (Y-X)*C*2;
            }
        }
        printf("%d",cash);
    }
    
}


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

int main(){
    while(true){
        int n;
        string str;
        int l=0, r=0;
        int before=0;
        int cnt=0;
        cin >> n;
        if(!n) break;
        for(int i=0;i<n;++i){
            cin >> str;
            if(str == "lu") l = 1;
            else if(str == "ru") r = 1;
            else if(str == "ld") l = 0;
            else if(str == "rd") r = 0;
            if(l == 1 && r == 1 && before == 0){
                before = 1;
                ++cnt;
            }else if(l == 0 && r == 0 && before == 1){
                before = 0;
                ++cnt;
            }
        }
        cout << cnt << endl;
    }
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 1000005;
int n, sig[MX][26], cn[MX], sz, mp[256];
string s[MX];
ll res;

void insert (string &s) {
	int u = 0;
	for (char c : s) {
		c -= 'a';
		if (!sig[u][c]) sig[u][c] = ++sz;
		u = sig[u][c];
	}
	cn[u]++;
}

int find (string &s) {
	int u = 0, res = 0;

	for (char c : s)
		mp[c - 'a']++;

	forn (i, s.size()) {
		char c = s[i] - 'a';
		res += cn[u];

		if (i + 1 < s.size()) {
			for (int j = 0; j < 26; j++)
				if (j != s[i] - 'a' && mp[j]) {
					res += cn[sig[u][j]];
				}
		}

		u = sig[u][c];
		mp[c]--;
	}

	return res;
}

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

	forn (i, n) {
		cin >> s[i];
		reverse(all(s[i]));
		insert(s[i]);
	}

	forn (i, n) res += find(s[i]);

	cout << res << endl;
	
	return 0;
}


Measured memory_bytes: 140352
n,*t=map(int,open(0).read().split());A=t[:n];B=t[n:];r=0
while 1:
 c=0
 for i in range(n):
  b=B[~-i%n]+B[-~i%n]
  if b<B[i]and A[i]<B[i]:t=(B[i]-A[i])//b;c+=t;B[i]-=t*b
 r+=c
 if c==0:break
print([-1,r][A==B])

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    int sum = 0;
    int count = 0;
    for(int i = 0; i < n; i++)
    {
        sum += v[i];
        //cout << sum << " ";
        if(sum <= x)
        {
            count++;
            //cout << "count" << count << endl;
        }

    }
    cout << count + 1 << endl;


    return 0;
}


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

int main(){
    int N,x,div;
    cin >> N >> x;
    vector<int> l(N);
    for(int i = 0; i < N; i++){
        cin >> l.at(i);
    }
    sort(l.begin(), l.end());
    x = x-accumulate(l.begin(), l.end(),0);
    div = x / l.at(0);
    cout << N + div << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
  n = int(input())

  D = {
    "AC": 0,
    "WA": 0,
    "TLE": 0,
    "RE": 0,
  }

  for _ in range(n):
    D[input()] += 1

  for k, c in D.items():
    print(f"{k} x {c}")


main()


Measured memory_bytes: 9112
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
typedef long long int lli;
lli dp[1001][1001];
int main() {
	int i, j, n, m, d[1000], c[1000], dc;
	fscanf(stdin, "%d%d", &n, &m);
	for (i = 0; i <= m; i++)
		for (j = 0; j <= n; j++)
			dp[i][j] = 1e+15;
	for (i = 0; i < n; i++) fscanf(stdin, "%d", d+i);
	for (i = 0; i < m; i++) fscanf(stdin, "%d", c+i);
	dp[0][0] = 0;
	for(i=0;i<m;i++)
		for (j = 0; j <= n; j++) {
			if (dp[i][j] != 1e+15) {
				if (dp[i][j] < dp[i + 1][j]) dp[i + 1][j] = dp[i][j];
				dc = d[j] * c[i];
				if (dp[i][j] + dc < dp[i + 1][j + 1]) dp[i + 1][j + 1] = dp[i][j] + dc;
			}
		}
	lli ans=1e+15;
	for (i = 1; i <= m; i++) if (ans > dp[i][n]) ans = dp[i][n];
	P(lld, ans);
	return 0;
}

Measured memory_bytes: 8428
#include<bits/stdc++.h>
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
#define all(x) x.begin(),x.end()
ll mob=1000000007;
using namespace std;
int main()
{ 

string h;
cin>>h;
int u=h.length();
int dp[u+1];
dp[u]=0;
int ten =1;
for(int i=u-1;i>=0;i--)
{
  int a=((h[i]-'0')*ten)%2019;
  dp[i]=(dp[i+1]+a)%2019;
  ten*=10;ten=ten%2019;
}
vector<int> cnt(2019,0);
int ans =0;
for(int i=u;i>=0;i--)
{
  ans+=cnt[dp[i]];
  cnt[dp[i]]++;
}
 

cout<<ans;

return 0;
}











Measured memory_bytes: 4516
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string c;
	cin >> c;
	if(c == "a" || c == "i" || c == "u" || c == "e" || c == "o") cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
}

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

int main(){

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

 	int ans=0,n,k,f[1000];
 	cin>>n>>k;
 	for (int i = 0; i < n; ++i)
 	{
 		cin>>f[i];
 	}
 	sort(f,f+n);
 	for (int i = 0; i < k; ++i)
 	{
 		ans+=f[i];
 	}
 	cout<<ans;
 	return 0;
}

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

int main() {
	int n, x;
	cin >> n >> x;
	int m;
	int minm = 1e9;
	for (int i = 0; i < n; i++) {
		cin >> m;
		x -= m;
		minm = min(minm, m);
	}
	int ans = n;
	ans += x / minm;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	double v;
	while(cin >> v)
		cout << ceil((4.9 * pow(v / 9.8, 2.0) + 5) / 5) << endl;	
}

Measured memory_bytes: 0
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> ryokin(m);
    vector<bool> hoge(n+1,false);
    for(int i=0;i<m;i++){
        cin>>ryokin.at(i);
        hoge.at(ryokin.at(i))=true;
    }
    
    int ans1=0;
    int ans2=0;
    
    for(int i=x;i!=0;i--) if(hoge.at(i)==true) ans1++;
    for(int i=x;i!=n;i++) if(hoge.at(i)==true) ans2++;
    
    cout<<min(ans1,ans2)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
//#include<fstream>
#include<stack>
#include<string>
#include <stdlib.h>

using namespace std;

int getTop(stack<int> &s) {
	int tmp = s.top();
	s.pop();
	return tmp;
}

int main() {
//	ifstream fin("in.txt");

	string in;
	stack<int> s;

	int ans = 0;

	while (cin >> in){
		if(in == "+") {
			ans = getTop(s) + getTop(s);
			s.push(ans);
		}
		else if (in == "-") {
			int tmp = getTop(s);
			ans = getTop(s) - tmp;
			s.push(ans);
		}
		else if (in == "*") {
			ans =  getTop(s) * getTop(s);
			s.push(ans);
		}
		else if (in == "/") {
			double tmp = (double)getTop(s);
			double tmp2 = getTop(s) / tmp;
			s.push(1.0 / tmp2);
		}
		else s.push(atoi(in.c_str()));		

	}

	cout << ans << endl;

	return 0;
}

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

int main(){
//srandom((unsigned long)time(NULL));


//yokow+2
//tateh+2
int h,w;
cin>>h>>w;
char s[h+2][w+2];
for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
        s[i][j]='.';
    }
}
for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
        cin>>s[i][j];
    }
}
bool ans=true;
for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
        if(s[i][j]=='#'){
            int probe=1;
            if(s[i-1][j]=='#' || s[i+1][j]=='#' || s[i][j+1]=='#' || s[i][j-1]=='#')probe=0;
            if(probe==1)ans=false;
        }
    }
}



if(ans){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}

return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try (Scanner sc = new Scanner(System.in)){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for(int i=0;i<values.length;i++){
                values[i]=i+1;
            }
            for(int i=0;i<n;i++){
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0])-1;
                int b = Integer.parseInt(ab[1])-1;
                int x;
                x = values[a];
                values[a] = values[b];
                values[b] = x;
            }
            for(int i=0;i<values.length;i++){
                System.out.println(values[i]);
            }
        }
    }
}


Measured memory_bytes: 25836
#include <cstdio>
#include <iostream>
#include <bitset>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

#define ALL(obj) (obj).begin(), (obj).end() 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)

bool c[10005];
int d[10005];

int solve(vector<vector <int> > &t,int n,int k,int now,bool capt,int *ans){
    //首都につながっている場合 capt = ture else capt = false;
    int max=0;
    bool flag = false;
    if(t[now].empty()){
        return 0;
    }else{
        rep(i,t[now].size()){
            int tem = solve(t,n,k,t[now][i],false,ans);
            if(capt){
                if(tem==k){
                    *ans += 1;
                    tem = 0;
                }else flag = true;
            }else{
                if(tem==k-1){
                    *ans += 1;
                    tem = 0;
                }else flag = true;
            }
            if(max < tem) max = tem;
        }
        return flag ? (max + 1) : 0;
    }
}

int main(){
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int>  a(n+1);
    vector<vector <int> > t(n+1);
    rep(i,n) cin >> a[i+1];
    rep(i,10005) c[i] = false;
    if(a[1]!=1){ a[1] = 1; ans++;}
    FOR(i,2,n+1){
        t[a[i]].push_back(i);
    }
    solve(t,n,k,1,true,&ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13952
#include <cstdio>
#include <cstdlib>
#include <cstring>

typedef struct tag{
  int key;
  struct tag *prev, *next;
} Node;

Node *nil;

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node *t){
  if(t != nil){
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
  }
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(cur != nil){
    if(isf++ > 0){
      printf(" ");
    }
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

int main(void) {
  int key, n, i;
  char cmd[20];

  scanf("%d", &n);
  init();
  for(i = 0; i < n; i++){
    scanf("%s", cmd);
    if(cmd[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }else if(cmd[0] == 'd'){
      if(strlen(cmd) > 6){
        if(cmd[6] == 'F') deleteFirst();
        else if(cmd[6] == 'L') deleteLast();
      } else {
        scanf("%d", &key);
        deleteKey(key);
      }
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 32216
n, x, y = map(int, input().split())
x, y = x-1, y-1


def update(dist, queue, d, x):
    if dist[x] >= 0: return dist, queue
    dist[x] = d+1
    queue.append(x)
    return dist, queue

ans = [0 for _ in range(n)]
for i in range(n):
    dist = [-1 for _ in range(n)]
    dist[i] = 0
    queue = [i]
    while True:
        if len(queue) == 0: break
        now = queue.pop(0)
        d = dist[now]
        if now-1 >= 0:
            dist, queue = update(dist, queue, d, now-1)
        if now+1 < n:
            dist, queue = update(dist, queue, d, now+1)
        if now == x:
            dist, queue = update(dist, queue, d, y)
        if now == y:
            dist, queue = update(dist, queue, d, x)
    for d in dist:
        ans[d] += 1

for a in ans[1:]:
    print(a//2)

Measured memory_bytes: 50908
A = [int(input()) for i in range(5)]
k = int(input())

def antena():
    for i in range(len(A) - 1):
        for j in range(len(A) - i - 1):
            if A [i+j+1] - A[i] > k:
                return ':('
    return 'Yay!'

print(antena())


Measured memory_bytes: 2940
get_string(String) :-
  current_input(Input),
  read_string(Input, ' \n', '', _, String).

get_number(Number) :-
  get_string(String),
  number_string(Number, String).

insert_sort(L1,L2) :-
        insert_sort(L1,[],L2).

insert_sort([],L,L).
insert_sort([A|R],L1,L) :-
        insert(A,L1,L2),
        insert_sort(R,L2,L).

insert(A,[],[A]).
insert(A,[B|R],[A,B|R]) :-
        A @=< B,!.
insert(A,[B|R1],[B|R2]) :-
        A @> B,
        insert(A,R1,R2).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :-
  get_number(X),
  N1 is N - 1,
  get_numbers(N1, Xs).

get_k_nums(X, 0, 0).
get_k_nums([X|Xs], C, Sum) :-
  C1 is C - 1,
  get_k_nums(Xs, C1, Nextsum),
  Sum is Nextsum + X.

main :-
  get_number(N),
  get_number(K),
  get_numbers(N, A),
  insert_sort(A, B),
  get_k_nums(B, K, Ans),
  write(Ans).

:- main.


Measured memory_bytes: 8740