akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 newval) { if(newval>a){a=newval;return true;}else{return false;} }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 newval) { if(newval<a){a=newval;return true;}else{return false;} }

void app() {
  int n,m,s;
  cin>>n>>m>>s;
  vector<vector<int>> g(n);
  vector<vector<int>> mo(n,vector<int>(n)),ti(n,vector<int>(n));
  rep(i,m){
    int u,v,emo,eti;
    cin>>u>>v>>emo>>eti;
    u--;v--;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
    mo[u][v]=mo[v][u]=emo;
    ti[u][v]=ti[v][u]=eti;
  }
  vector<int> smo(n),sti(n);
  rep(i,n){
    cin>>smo[i]>>sti[i];
  }

  int smax=50*n;
  vector<vector<lint>> mincost(n,vector<lint>(smax, 1e18));
  chmin(s,smax);

  using state=pair<lint,pair<int,int>>;
  priority_queue<state,vector<state>,greater<state>> que;

  mincost[0][s]=0;
  que.push({0,{0,s}});

  while(!que.empty()){
    state us=que.top();
    que.pop();
    lint ucost=us.first;
    int u=us.second.first;
    int uwallet=us.second.second;

    // 辺を移動することができ
    for(int v: g[u]){
      lint newcost=ucost+ti[u][v];
      int newwallet=uwallet-mo[u][v];
      if(newwallet>=0){
        if(chmin(mincost[v][newwallet],newcost)){
          que.push({newcost,{v,newwallet}});
        }
      }
    }
    // あるいは両替することができる
    lint newcost=ucost+sti[u];
    int newwallet=uwallet+smo[u];
    chmin(newwallet, smax);  // 実質無限大に達する
    if(chmin(mincost[u][newwallet],newcost)){
      que.push({newcost,{u,newwallet}});
    }
  }

  rep_range(i,1,n){
    lint ans=1e18;
    rep(wallet, smax) chmin(ans,mincost[i][wallet]);
    cout<<ans<<endl;
  }

  return;
}

int main(){app();return 0;}


Measured memory_bytes: 6308
using System;

namespace AOJ.Volume2
{
    public class DividingStudents
    {
        public static int Main()
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }

                for (int i = 0; i < n; i++)
                {
                    var input = Console.ReadLine().Split(' ');
                    int m = int.Parse(input[0]);
                    int e = int.Parse(input[1]);
                    int j = int.Parse(input[2]);

                    // 100???????§?????????????
                    if (m == 100 || e == 100 || j == 100)
                    {
                        Console.WriteLine("A");
                        continue;
                    }

                    // ??°?????¨??±??????????????????90?????\???(=??°?????¨??±??????????¨????180?????\???)
                    if (m + e >= 180)
                    {
                        Console.WriteLine("A");
                        continue;
                    }

                    // 3?§?????????????80?????\???(=3?§????????¨?240?????\???)
                    if (m + e + j >= 240)
                    {
                        Console.WriteLine("A");
                        continue;
                    }

                    // 3?§??????????70?????\???
                    if (m + e + j >= 210)
                    {
                        Console.WriteLine("B");
                        continue;
                    }

                    // 3?§??????????50?????\?????§??°????????±??????80?????\???
                    if ((m + e + j >= 150) && (m >= 80 || e >= 80))
                    {
                        Console.WriteLine("B");
                        continue;
                    }

                    Console.WriteLine("C");
                }
            }
            return 0;
        }
    }
}

Measured memory_bytes: 8864
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;

int main() {
    int H, W, K;
    cin>>H>>W>>K;
    vector<string> S(H);
    for(int i=0;i<H;++i){
        cin>>S[i];
    }

    map<int, int> group;
    map<int, int> white;
    vector<int> bitS;
    int ans = 10000000;
    int tmpans;
    for(int bit=0;bit<(1<<(H-1));++bit){
        tmpans = 0;
        for(int i=0;i<H-1;++i){
            group[i] = 0;
        }
        for(int i=0;i<H;++i){
            white[i] = 0;
        }
        bitS.clear();
        for(int i=0;i<H-1;++i){
            if(bit&(1<<i)) bitS.push_back(i);
        }
        int tmp = 0;
        int index = 0;
        for(int i=0;i<H;++i){
            if(index<bitS.size()){
                if(i>bitS[index]){
                    tmp++;
                    index++;
                }
            }
            group[i] = tmp;
        }
        bool upper;
        bool dame = false;
        for(int j=0;j<W;++j){
            upper = false;
            for(int i=0;i<H;++i){
                if(S[i][j] == '1'){
                    white[group[i]]++;
                    if(white[group[i]]>K)upper = true;
                }
            }
            if(upper){
                tmpans++;
                for(int i=0;i<H;++i){
                    white[i]=0;
                }
                for(int i=0;i<H;++i){
                    if(S[i][j] == '1')white[group[i]]++;
                    if(white[group[i]]>K)dame = true;
                }
            }
            if(dame){
                break;
            }
        }
        if((ans > tmpans + bitS.size()) & !dame){
            ans = tmpans + bitS.size();
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
<?php
list($a,$b,$C)=explode(' ',trim(fgets(STDIN)));

$C=deg2rad($C);

$h=$b*sin($C);
$c=sqrt(pow($a-$b*cos($C),2)+pow($h,2));

echo $a*$h/2,PHP_EOL,$a+$b+$c,PHP_EOL,$h;

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

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;
const int MAX_N = 110;
char A[MAX_N], B[MAX_N], C[MAX_N];

int main(){
    //freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n >> A >> B >> C;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        ans += min({(A[i] != B[i]) + (A[i] != C[i]), (B[i] != A[i]) + (B[i] != C[i]), (C[i] != A[i]) + (C[i] != B[i])});
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int cost = 0;
  if (a+b >= 2*c) {
    cost = 2*c*min(x,y);
    if (x >= y) cost += (x-y) * min(2*c, a);
    else cost += (y-x) * min(2*c, b);
  }
  else {
    cost = x * min(a, 2*c) + y * min(b,2*c);
  }
  cout << cost << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string S[301];
	vpint mojizahyo[26];
	ll count=0;
	scan(N);
	rep(i,N){
		scan(S[i]);
		/*rep(j,N){
			mojizahyo[S[i][j]-'a'].push_back(mp(i,j));
		}*/
	}
	rep(k,N){
		int flag=1;
		rep(i,N-1){
			for(int j=i+1;j<N;j++){
				if(S[(i+k)%N][j]!=S[(j+k)%N][i]){
					flag=0;
					break;
				}
			}
			if(flag==0) break;
		}
		if(flag) count+=N;
	}
	prin(count);
	return 0;
}


Measured memory_bytes: 384
while true do
  right, ans = gets.chomp.split
  break if right == '0'
  hit, blow = 0, 0
  ans.each_char.with_index do |ch, i|
    if ch == right[i] then
        hit += 1
    elsif right.include? ch then
        blow += 1
    end
  end
  puts "#{hit} #{blow}"
end

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

using namespace std;

struct Edge {
	int to, cap, rev;
};

vector< vector<Edge> > G;
vector<bool> used;
int dfs(int s, int t, int f) {
	if (s == t) return f;
	used[s] = true;

	for (int i = 0; i < G[s].size(); ++i) {
		Edge& e = G[s][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(e.cap, f));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int res = 0;
	while (1) {
		int N = G.size();
		used = vector<bool>(G.size(), false);
		int flow = dfs(s, t, 1e9);
		if (flow > 0) {
			res += flow;
		}
		else {
			break;
		}
	}
	return res;
}
void add_edge(int u, int v, int cap) {
	G[u].push_back((Edge){v, cap, G[v].size()});
	G[v].push_back((Edge){u, 0, G[u].size()-1});
}

typedef long double ld;
typedef complex<ld> P;

const ld inf = 1e10;
const ld eps = 1e-12;

int main() {
	int N, M;
	while ( cin >> N >> M, N || M ) {
		int s = N+M, t = N+M+1;
		vector<P> p;
		vector<int> v(N);
		for (int i = 0; i < N; ++i) {
			int x, y; cin >> x >> y >> v[i];
			p.push_back( P(x, y) );
		}
		vector<P> pp;
		for (int i = 0; i < M; ++i) {
			int x, y; cin >> x >> y;
			pp.push_back( P(x, y) );
		}

		ld l = 0, r = 100000;
		for (int q = 0; q < 50; ++q) {
			ld m = (l + r) / 2;
			G = vector< vector<Edge> >(t+1);
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < M; ++j) {
					ld dist = abs(p[i]-pp[j]);
					if (dist/v[i] <= m) {
						add_edge(i, N+j, 1);
					}
				}
			}
			for (int i = 0; i < N; ++i) {
				add_edge(s, i, 1);
			}
			for (int i = 0; i < M; ++i) {
				add_edge(N+i, t, 1);
			}

			if ( max_flow(s, t) == M ) {
				r = m;
			}
			else {
				l = m;
			}
		}
		cout << fixed << setprecision(12) << l << endl;
	}
}

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

int main(){

    string a,b;

    cin >> a >> b;

    if(a[0]=='H'){
        if(b[0]=='H'){
            cout << "H" << endl;
        }else{
            cout << "D" << endl;
        }
    }else{
        if(b[0]=='D'){
            cout << "H" << endl;
        }else{
            cout << "D" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define     ll          long long int
#define     ld          double
#define     REP(i,x,n)    for(ll i=x;i<n;i++)
#define     SZ(v)       (ll)v.size()
#define     endl        "\n"
#define     ff          first
#define     ss          second
#define     PQ_MIN      priority_queue <ll, vector<ll>, greater<ll> >
#define     PQ          priority_queue <int>
#define     pbds        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define     setbit(x)   __builtin_popcount(x)
#define     prec(n)     fixed<<setprecision(n)
#define     pb(n)       push_back(n)
#define     mp(a,b)     make_pair(a,b)
#define     clr(n)      memset(n,0,sizeof(n))
#define     reset(n)    memset(n,-1,sizeof(n))
#define     ii          pair<ll,ll>
#define     vll         vector<ll>
#define     PI          3.1415926535897932384626433832795028841971693993751

using namespace std;
using namespace __gnu_pbds;
bool comp(pair<ll,ll> a,pair<ll,ll> b) {       }
const ll MOD=1e9+7;
void print(vector<vector<ll> >&v)
{
    ll n=v.size();
    ll m=v[0].size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
            cout<<v[i][j]<<" ";
        cout<<"\n";
    }
}
void print(vector<ll>&v)
{
    ll n=v.size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
            cout<<v[i]<<" ";
    }
        cout<<"\n";

}
void print(set<ll>&s)
{

cout<<endl;

set<ll>::iterator it;
for(it=s.begin();it!=s.end();it++)
    cout<<*it<<" ";
cout<<endl;
}
ll __lcm(ll a,ll b)
{
    return ((a*b)/__gcd(a,b));
}
ll power(ll a,ll p)
{
    ll res=1;
    while(p>0)
    {
        if(p&1){
            res=(res*a)%MOD;
            p--;
        }
            a=(a*a)%MOD;
            p/=2;
    }

    return res%MOD;
}
const ll INF=1e16;
const ll nxm=2e5+5;

ll spf[nxm];
void sieve()
{
    memset(spf,-1,sizeof(spf));

    spf[0]=spf[1]=1;

    for(ll i=2;i<nxm;i++)
    {
        if(spf[i]==-1)
            spf[i]=i;
        for(ll j=i*i;j<nxm;j+=i)
        {
            if(spf[j]==-1)
                spf[j]=i;

        }

    }
//    while(x>1)
//    {
//        ll s=spf[x];
//        temp[s]++;
//        x/=s;
//    }


// log n prime factor
}
void solve(){

string s;

cin>>s;

ll a=0;

for(ll i=0;i<s.size();i++)
{
    a+=(s[i]-'0');
    a%=9;
}

if(a%9==0)
cout<<"Yes";
else
    cout<<"No";

















}
int main(){
//    freopen("timber_input", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
    REP(i,1,t+1)
    {
//    cout<<"Case #"<<i<<": ";
		solve();
    }
	return 0;
}
//  bitset<64>(x).to_ullong() // in my com  _ulong()
//  cout<<bitset<64>(ans).to_string().substr(64-m)<<endl;
/*

const int INF = 0x3f3f3f3f;


char s[100];

fgets(s,100,stdin);

stringstream stram(s);

string abc;

bool ok1=0,ok2=0;

while(stram>>abc)

ternary operator for(int i=0;i<23;i++) or while(r-l>eps)


*/


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009ll
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA , vector<PA >, greater<PA > >PQG;

int N, M;
bool c_used[1000010];
vector<int> colors;
vector<PA> E[1000010];
int c_mem[1000010];
vector<int> V[1000010], nodes;
int par[1000010];

vector<int> edge[1000010], line[1000010];
int d[1000010];
bool used[1000010];

signed main()
{
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        if(!c_used[c]){
            colors.pb(c);
            c_used[c] = true;
        }
        E[c].pb(mk(a, b));
    }
    //printf("input_succeeded\n");
    int num = 1;
    for(int i = 0; i < (int)colors.size(); i++){
        int C = colors[i];
        for(int j = 0; j < (int)E[C].size(); j++){
            PA node = E[C][j];
            if(c_mem[node.first] != C){
                c_mem[node.first] = C;
                nodes.pb(node.first);
            }
            if(c_mem[node.second] != C){
                c_mem[node.second] = C;
                nodes.pb(node.second);
            }
            V[node.first].pb(node.second);
            V[node.second].pb(node.first);
        }
        int c_num = num;
        for(int j = 0; j < (int)nodes.size(); j++){
            int pos = nodes[j];
            if(par[pos] >= c_num)continue;
            queue<int> que;
            que.push(pos);
            while(!que.empty()){
                int now = que.front();
                que.pop();
                if(par[now] >= num)continue;
                par[now] = num;
                edge[now].pb(num);
                line[num].pb(now);
                for(int k = 0; k < (int)V[now].size(); k++){
                    que.push(V[now][k]);
                }
            }
            num++;
        }
        for(int j = 0; j < (int)nodes.size(); j++){
            V[nodes[j]].clear();
        }
        nodes.clear();
    }
    //printf("construction_succeeded\n");
    memset(d, -1, sizeof(d));
    queue<PA> que;
    que.push(mk(0, 1));
    d[1] = 0;
    //printf("a\n");
    while(!que.empty()){
        int dis = que.front().first;
        int pos = que.front().second;
        que.pop();
        //printf("start dis:%lld, pos:%lld\n", dis, pos);
        for(int i = 0; i < (int)edge[pos].size(); i++){
            int upto = edge[pos][i];
            if(used[upto])continue;
            used[upto] = true;
            for(int j = 0; j < (int)line[upto].size(); j++){
                int downto = line[upto][j];
                if(d[downto] == -1){
                    d[downto] = dis + 1;
                    que.push(mk(dis + 1, downto));
                }
            }
        }
    }
    cout << d[N] << endl;


    return 0;
}
/*



*/


Measured memory_bytes: 129520
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  int H,W,N;
  cin>>H>>W>>N;
  
  cout<<min((N+H-1)/H,(N+W-1)/W)<<endl;
}

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

using namespace std;

int ans, N, mod, pref[100009], suf[100009], st[100009], dr[100009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N), mod = 1e9 + 7, ans = 1;
for (int i=1; i<=N; i++)
    scanf ("%d", &pref[i]), dr[i] = pref[i];
for (int i=1; i<=N; i++)
    scanf ("%d", &suf[i]), st[i] = 1;
for (int i=1; i<=N; i++)
{
    if (pref[i] != pref[i - 1] || i == 1) st[i] = pref[i];
    if (suf[i] != suf[i + 1] || i == N) st[i] = max (st[i], suf[i]);
    if (suf[i] < dr[i]) dr[i] = suf[i];
    if (st[i] > dr[i])
    {
        printf ("0\n");
        return 0;
    }
    ans = (1LL * ans * (dr[i] - st[i] + 1)) % mod;
}
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 1792
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N, long long K, std::vector<long long> a);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N;
    cin >> N;
    vv(int) F(N);
    vv(vv(int)) P(N, vv(int)(11));
    REP(i, N){
        REP(j, 10){
            F[i] <<= 1;
            int v;
            cin >> v;
            F[i] |= v;
        }
    }
    REP(i, N){
        REP(j, 11){
            cin >> P[i][j];
        }
    }
    ll mx = LONG_LONG_MIN;
    FOR(i, 1<<10, 1){
        ll tmp = 0;
        REP(j, N){
            int m = __builtin_popcount(i&F[j]);
            tmp += P[j][m];
        }
        chmax(mx, tmp);
    }
    cout << mx << el;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s; cin >> s;
    int n = s.length();
    bool ok = false;
    int ans = 0;
    for (int i = n-1; i >= 1; i--)
    {
        if (s[i] == 'Z') {
            ans += i;
            break;
        }
    }
    rep(i,n-1) {
        if (s[i] == 'A') {
            ans -= i;
            break;
        } 
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache
from numba import jit

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	counts = [0,0,0,0]
	for _ in range(n):
		s = S()
		if s == 'AC':
			counts[0] += 1
		elif s == 'WA':
			counts[1] += 1
		elif s == 'TLE':
			counts[2] += 1
		elif s == 'RE':
			counts[3] += 1
	print('AC x '+str(counts[0]))
	print('WA x '+str(counts[1]))
	print('TLE x '+str(counts[2]))
	print('RE x '+str(counts[3]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 91676
#include<iostream>
#include<string>
#include<cstdio>
#include<cctype>
#include<vector>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<stack>
#include<map>
#include<bitset>
#include <cstdlib>
#include<cstring>
#define ll long long;
#define pb push_back
const int MOD = 1e9 + 7;
const int qq = 1e5 + 10;
const int INF = 1e9 + 10;
const double eps = 1e-11;
const double pi = acos(-1.0); 
using namespace std;
using uint = unsigned int;
using int64 = long long;
using uint64 = unsigned long long;
#define ma = 2147483647;
#define mi = -2147483647;

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

	int n, k;
	cin >> n >> k;
	int ans = 0;
	set<int>fuc;
	for (int i = 0; i < k; i++)
	{
		int d; cin >> d;
		for (int j= 0; j< d;j ++)
		{
			int q;
			cin >> q;
			fuc.insert(q);
		}
	}
	cout << n - fuc.size();





	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
#define fin(x) scanf("%lld",&x)
#define fout(x) printf("%lld\n",x)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define cases int t;  scanf("%d",&t);   while(t--)
#define MOD 1000000007
#define MAXN 123456
#define read() freopen("lele.txt","r",stdin)
#define write() freopen("dede.txt","w",stdout)

using namespace std;

int main()
{
    ll gray = 0, brown = 0, green = 0, cyan = 0, blue = 0, yellow = 0, orange = 0, red = 0;
    ll N = 0;
    ll n;
    fin(n);
    for(ll i = 0; i < n; i++)
    {
        ll x;
        fin(x);
        if(x >= 1 && x <= 399)
            gray++;
        else if(x >= 400 && x <= 799)
            brown++;
        else if(x >= 800 && x <= 1199)
            green++;
        else if(x >= 1200 && x <= 1599)
            cyan++;
        else if(x >= 1600 && x <= 1999)
            blue++;
        else if(x >= 2000 && x <= 2399)
            yellow++;
        else if(x >= 2400 && x <= 2799)
            orange++;
        else if(x >= 2800 && x <= 3199)
            red++;
        else
            N++;
    }
    ll C = 0;
    C += (gray > 0);
    C += (brown > 0);
    C += (green > 0);
    C += (cyan > 0);
    C += (blue > 0);
    C += (yellow > 0);
    C += (orange > 0);
    C += (red > 0);
    if(C == 0)
        cout << 1LL << " " << N << endl;
    else
        cout << C << " " << (C + N) << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main()  {
	var n int
	fmt.Scan(&n)
	nums := ScanNums(n)
	ans := 0
	for i := 1; i < n-1; i++ {
		arr := []int{nums[i-1], nums[i], nums[i+1]}
		sort.Ints(arr)
		if arr[1] == nums[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define MAXN 200009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int ans[MAXN],arr[MAXN];
vector<int>adj[MAXN];
void dfs(int nd,int pr,int val){
	val+=arr[nd];
	ans[nd]=val;
	tr(it,adj[nd])
		if(*it!=pr)
			dfs(*it,nd,val);	
}
int main(){
   // freopen("file.in", "r", stdin);
    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=1;i<n;i++){
    	int u,v;
		scanf("%d%d",&u,&v);
		adj[u].pb(v);
		adj[v].pb(u);	
    }
    while(q--){
    	int v,p;
		scanf("%d%d",&p,&v);
		arr[p]+=v;	
    }
    dfs(1,-1,0);
    for(int i=1;i<=n;i++)
    	printf("%d ",ans[i]);
    puts("");	
	return 0;
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
int dp[300000] = {};

int main() {
    int N;
    cin >> N;
    int res = 0;
    for(int i=0; i<N; ++i) {
        int P;
        cin >> P;
        dp[P] = dp[P - 1] + 1;
        res = max(res, dp[P]);
    }
    cout << N - res << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int n,m,a,b,ans,fa[50],ra[50];
vector<P> v1;
int find(int x){
    if(x==fa[x])return x;
    return find(fa[x]);
}
void uni(int x,int y){
    x=find(x);
    y=find(y);
    if(ra[x]<ra[y])swap(x,y);
    fa[y]=find(x);
    if(ra[x]==ra[y])ra[x]++;
    return ;
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        v1.push_back({a,b});
    }
    for(auto y:v1){
        for(int i=0;i<n;i++){
                fa[i]=i;
                ra[i]=0;
            }
        for(auto x:v1){
            if(x.first==y.first&&x.second==y.second)continue;
            if(x.second==y.first&&x.first==y.second)continue;
            uni(x.first,x.second);
        }
        for(int i=0;i<n;i++){
            if(find(i)!=find(0)){ans++;break;}
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <random>

#define ff first
#define ss second

using namespace std;

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;

pii operator+(pii a, pii b)
{
    return {a.ff+b.ff,a.ss+b.ss};
}

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

    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    vector<bool> dp(k+1);
    for(int j=0; j<=k; j++){
        for(int i=0; i<n; i++){
            if(j>=a[i]) dp[j]=(dp[j] || !dp[j-a[i]]);
        }
    }
    if(dp[k]) cout<<"First";
    else cout<<"Second";

    return 0;
}


Measured memory_bytes: 3648
def main():
  import sys
  input=sys.stdin.buffer.readline
  n=int(input())+1
  data=[[0]*n*2for _ in range(26)]
  def update(i,x):
    i+=n
    for d in data:
      j=i
      if d[j]:
        d[j]=0
        j//=2
        while j:
          d[j]=d[j+j]|d[j-~j]
          j//=2
        break
    d=data[x]
    d[i]=1
    i//=2
    while i:
      d[i]=d[i+i]|d[i-~i]
      i//=2
  def query(l,r):
    l+=n
    r+=n
    s=[0]*26
    while l<r:
      if l&1:
        for i,d in enumerate(data):
          s[i]|=d[l]
        l+=1
      if r&1:
        r-=1
        for i,d in enumerate(data):
          s[i]|=d[r]
      l//=2
      r//=2
    return sum(s)
  for i,c in enumerate(input()[:-1],n):
    data[c-97][i]=1
  for d in data:
    for i in range(n-1,0,-1):
      d[i]=d[i+i]|d[i-~i]
  s=[]
  for _ in range(int(input())):
    q,a,b=input().split()
    if q[0]>49:
      s+=query(int(a)-1,int(b)),
    else:
      update(int(a)-1,b[0]-97)
  print(' '.join(map(str,s)))
main()

Measured memory_bytes: 257212
#include <iostream>
#include <algorithm>

using namespace std;
struct Card { char suit,value;};
void bubblesort(struct Card a[],int n){
    int f=1;
    while(f){
        f =0;
        for (int i=n-1;i>0;i--){
            if(a[i].value < a[i-1].value){
                swap(a[i],a[i-1]);
                f=1;
            }
        }
    }
     for (int i=0;i<n-1;i++){
        cout << a[i].suit<<a[i].value <<" ";
    }
    cout << a[n-1].suit<<a[n-1].value<< endl;
    cout << "Stable" << endl;
    }



void selectionsort(Card a[],  int n)
{
    for( int i = 0; i < n; ++i ){
        int min = i;
      
        
        for( int j = i; j < n; ++j )
            if( a[j].value < a[min].value ){

            
                min = j;
            }
        
        if( i != min )
        {
            swap(a[i], a[min]);
    }
    }
  
for (int i=0;i<n-1;i++){
        cout << a[i].suit<<a[i].value <<" ";
    }
    cout << a[n-1].suit<<a[n-1].value<< endl;
}


int main(){
    Card C1[103],C2[103];
    int n;
    cin >>n;
    for (int i=0;i<n;i++){
        cin >> C1[i].suit>>C1[i].value;
        C2[i]=C1[i];
    }
    bubblesort(C1,n);
    selectionsort(C2,n);
    for (int i=0;i<n;i++){
        if(C1[i].suit!=C2[i].suit){
            cout << "Not stable" <<endl;
            return 0;
        }
    }
    cout << "Stable" << endl;
    
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll minArea(ll a, ll b, ll c) {
    return min(a, min(b, c));
}

ll maxArea(ll a, ll b, ll c) {
    return max(a, max(b, c));
}

int main() {
    ll H, W; cin >> H >> W;

    ll ans = LLINF;
    for (ll ah = 1; ah < H; ah++) {
        ll bh = (H - ah) / 2;
        ll ch = H - ah - bh;
        chmin(ans, W*maxArea(ah,bh,ch) - W*(minArea(ah,bh,ch)));
    }
    for (ll ah = 1; ah < H; ah++) {
        ll bh = H - ah;
        ll bw = W / 2;
        ll cw = W - bw;
        chmin(ans, maxArea(ah*W, bh*bw, bh*cw) - minArea(ah*W, bh*bw, bh*cw));
    }
    swap(H, W);
    for (ll ah = 1; ah < H; ah++) {
        ll bh = (H - ah) / 2;
        ll ch = H - ah - bh;
        chmin(ans, W*maxArea(ah,bh,ch) - W*(minArea(ah,bh,ch)));
    }
    for (ll ah = 1; ah < H; ah++) {
        ll bh = H - ah;
        ll bw = W / 2;
        ll cw = W - bw;
        chmin(ans, maxArea(ah*W, bh*bw, bh*cw) - minArea(ah*W, bh*bw, bh*cw));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    int mx = max(a, max(b, max(c, max(d, e))));
    int mn = min(a, min(b, min(c, min(d, e))));
    if(mx - mn > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll n,m;
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
// ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
bool isvalid(ll x,ll y) { return (x>=1&&x<=n&&y>0&&y<=m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////



int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    ll n;

    cin>>n;

    ll ap[n+11];
    for(ll i=0;i<n;i++){
        cin>>ap[i];
    }
    ll ans[n+11];
    ll ans1 = 1;
    ans[n-1] = 1;

    for(ll i=n-2;i>=0;i--){

        if(ap[i+1]<=ap[i]){
            ans[i] = ans[i+1]+1;
            ans1 = max(ans1,ans[i]);
        }else{
            ans[i] = 1;
            // ans1
        }
    }

    cout<<ans1-1;
    
    return 0;
}

Measured memory_bytes: 1024
#D問題
N=int(input())
A=list(map(int,input().split()))
B=A[::]
for i in range(N-1):
    if A[i] > 0:
        pass
    else:
        A[i]=(-1*A[i])
        A[i+1]=(-1*A[i+1])
if min(A) >= 0:
    print(sum(A))
else:
    C=B[::]
    for i in range(N):
        C[i]=max(-1*C[i],C[i])
    print(sum(C)-2*min(C))

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

using namespace std;

#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()

void solve (int u) {

    int n, k;
    cin >> n >> k;

    int a [n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }    
    
    vector <int> dp (n, 1e9 + 5);

    dp[0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= i + k; ++j) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            }
        }
    } 

    cout << dp[n - 1] << "\n";
//    cout << "Case #" << k << ": " << count << "\n";

}

int main () {

    ios::sync_with_stdio(0);
    cin.tie(0);

    //int t;
    //cin >> t;
    //int k = 1;
    //while (t--) {
    //    solve(k);
    //    k++;
    //}

    solve(0);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  string a, s, c;
  cin >> a >> s >> c;
  cout << 'A' << s.at(0) << 'C' << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
typedef string::const_iterator State;
class ParseError {};
string expression(State&);
string ch(State&);
int number(State&);

int m;
string s;
string expression(State &begin) {
	string ret = "", tmp = "";
	int num = 1;
	//cout << *begin << " " << begin - s.begin() << endl;
	if(isdigit(*begin)) {
		num = number(begin);
		//begin++;
	}
	if(*begin == '(') {
		begin++;
		tmp = expression(begin);
		begin++;
	} else if(isupper(*begin)) {
		tmp = ch(begin);
		//begin++;
	}

	//cout << "num:" << num << " tmp:" << tmp << endl;
	REP(i, num) {
		if((int)ret.size() > m) return ret;
		ret += tmp;
	}

	//cout << ret << endl;
	if(begin-s.begin() < (int)s.size() && *begin == ')') return ret;
	if(begin-s.begin() < (int)s.size()) {
		//cout << "end" << *begin << endl;
		ret += expression(begin);
	}
	//cout << *begin << " ret:" << ret << endl;
	return ret;
}

//???????????????
string ch(State &begin) {
	string ret;
	while(1) {
		if(isupper(*begin)) {
			ret += *begin;
			begin++;
		} else {
			break;
		}
	}
	//cout << "char" << ret << endl;
	return ret;
}

int number(State &begin) {
	int ret = 0;
	while(isdigit(*begin)) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}

signed main(void)
{
	while(1) {
		cin >> s >> m;
		if(s == "0" && !m) break;
		//REP(i, n) REP(j, n)
		State begin = s.begin();
		string ans = expression(begin);
		//cout << "ans:" << ans << endl;
		if((int)ans.size() <= m) cout << "0" << endl;
		else cout << ans[m] << endl;
	}
	return 0;
}

Measured memory_bytes: 7492
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int m, nmin, nmax;
	while (cin >> m >> nmin >> nmax, m || nmin || nmax) {
		int P[201];
		REP(i, 0, m) cin >> P[i];

		int gap = 0, ans=0;
		REP(i, nmin, nmax + 1) {
			if (P[i - 1] - P[i] >= gap) {
				gap = P[i - 1] - P[i];
				ans = i;
			}
		}

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

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

int main() {
    int n;
    cin >> n;
    vector<string> title(n);
    vector<int> time(n);
    for(int i = 0; i < n; i++){
        cin >> title.at(i) >> time.at(i);
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum = sum + time.at(i);
    }
    string x;
    cin >> x;
    int xcount = 0;
    for(int i = 0; i < n; i++){
        if(x == title.at(i)){
            xcount = i;
        }
    }
    int xsum = 0;
    for(int i = 0; i <= xcount; i++){
        xsum = xsum + time.at(i);
    }
    cout << sum - xsum << endl;
}

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

#define int long long

const int MAX_DIGIT = 50;
int dp[100][2]; // dp[i][j]: 上からi桁目までみたとき、jはi桁目までで確定してるかどうか

signed main() {
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  fill(dp[0], dp[100], -1);
  dp[MAX_DIGIT][0] = 0; // 初期状態。上位桁から決めていき、最初はマスク値がK以下か確定していない状態

  for (int digit = MAX_DIGIT-1; digit >= 0; digit--) {
    int mask = 1LL << digit; // 上からdigit桁目を立てたマスク

    // Aでもともと上からdigit桁目にビットが立っているものの個数
    int num = 0;
    for (int i = 0; i < N; i++) {
      if (A[i] & mask) {
        num++;
      }
    }

    // マスク値の上からdigit桁目を0, 1にしたときのスコア
    int score0 = mask * num; // 上からdigit桁目のマスクビットを立てない時のスコア
    int score1 = mask * (N - num); // 上からdigit桁目のマスクビットを立てる時のスコア

    // 1 -> 1(マスク値がK以下に確定した状態 -> マスク値がK以下に確定した状態）
    // マスク値がK以下であることは確定しているので、上からdigit桁以降のビットは立てても立てなくても良い
    // なので、ビットを立てたときと立ててないときのスコアの大きい方を採用する
    if (dp[digit+1][1] != -1) {
      dp[digit][1] = max(dp[digit][1], max(dp[digit+1][1] + score0, dp[digit+1][1] + score1));
    }

    // 0 -> 1(マスク値がK以下に確定していない状態 -> マスク値がK以下に確定した状態)
    // Kの立っている上からdigit桁目を引っ込めることでマスク値がK以下に確定する。なのでscore0を採用する
    if (dp[digit+1][0] != 1) {
      if (K & mask) { // Kの上からdigit桁目が立っていたら引っ込める
        dp[digit][1] = max(dp[digit][1], dp[digit+1][0] + score0);
      }
    }

    // 0 -> 0(マスク値がK以下に確定していない状態 -> マスク値がK以下に確定していない状態)
    // Kの上からdigit桁目をそのままにするということ
    // なので、Kの上からdigit桁目が0ならscore0を採用し、 Kの上からdigit桁目が1ならscore1を採用する
    if (dp[digit+1][0] != -1) {
      if (K & mask) { // Kの上からdigit桁目が立ってる
        dp[digit][0] = max(dp[digit][0], dp[digit+1][0] + score1);
      } else { // Kの上からdigit桁目が立ってない
        dp[digit][0] = max(dp[digit][0], dp[digit+1][0] + score0);
      }
    }
  }

  // dp[0][1]: K以下のマスク値を使った時の最大値
  // dp[0][0]: マスク値Kを使った時の最大値
  // cout << max(dp[0][1], dp[0][0]) << endl;
  int tmp = 0;
  for (int i = 0; i < N; i++) {
    tmp += A[i] ^ K;
  }
  cout << max(dp[0][1], tmp) << endl;

  return 0;
}


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

const int MAX = 1e5 + 5;
int dp[MAX];

int main() {

  int n;
  int h[MAX];

  cin >> n;

  for ( int i = 1; i <= n; ++i ) {
    cin >> h[i];
  }

  dp[0] = 1e9;

  for ( int i = 2; i <= n; ++i ) {
    dp[i] = min ( dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]) );
  }

  cout << dp[n] << endl;

  return 0;

}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }


int toi(string s){
  return ctoi(s[0])*10+ctoi(s[1]);
}
int month(string s){
  return 0<toi(s)&&toi(s)<13;
}

int main(void){
  string s,head,tail;cin >> s;
  head=s.substr(0,2);tail=s.substr(2,2);
  if(month(head)&&month(tail))
    cout << "AMBIGUOUS" << endl;
  else if(month(head))
    cout << "MMYY" << endl;
  else if(month(tail))
    cout << "YYMM" << endl;
  else cout << "NA" << endl;


  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
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

main = do
  s <- BS.getLine
  let n = BS.length s
  k <- getInt

  let solve i c set | i >= n && Set.size set >= k   = set
                    | i >= n                        = solve 0 (succ c) set
                    | c /= s `BS.index` i           = solve (i+1) c set
                    | otherwise                     = let set' = loop i i set
                                                      in solve (i+1) c set'
        where loop i j set
                | j >= n || j >= i + k = set
                | otherwise = let ss = BS.take (j - i + 1) $ BS.drop i s
                                  set' = ss `Set.insert` set
                              in loop i (j+1) set'

      xs = toList $ solve 0 'a' Set.empty

      ans = xs !! (k-1)

  BS.putStrLn ans




Measured memory_bytes: 2044
#include<iostream>

using namespace std;

int main()
{
  string a,b,c;

  cin >> a >> b >> c;

  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

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

int main() {
	int x, y, min, max;
	std::cin >> x >> y;
	x > y ? min = y : min = x;
	x < y ? max = y : max = x;
	x = min; y = max;
	while (x != 0) {
		y = y % x;
		x > y ? min = y : min = x;
		x < y ? max = y : max = x;
		x = min; y = max;
	}
	std::cout << y << "\n";
	return 0;
}




Measured memory_bytes: 3088
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numN = nextInt();
		int numM = nextInt();

		out.println((numN - 1) * (numM - 1));
	}

	private void solveB() {
		char[] wk = next().toCharArray();
		out.println("" + wk[0] + (wk.length - 2) + wk[wk.length - 1]);
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 22996