akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int N = scan.nextInt();
        int M = scan.nextInt();
        int i;
        int A[] = new int[N + N];
        int B[] = new int[N + N];
        int Flag = 0;
        int x[] = new int[M+1];
        int n[] = new int[M+1];
        for (i = 0; i < M; i++) {
            A[i] = scan.nextInt();
            B[i] = scan.nextInt();
            x[i] = N - A[i];
            if (A[i] >= B[i]) {
                Flag += 1;
            }
        }

        int y = 0;
        if (Flag >= M - 1) {
            System.out.println(0);
        } else {
            for (i = 0; i < M; i++) {
                if (x[i] > 0) {
                    y += 1;
                    n[y] = x[i];
                }
            }
            int zs;
            int min = 0;
            int index = 0;
            int sun = 0;
            int a;
            zs = (M - 1) - Flag;
            for (i = 0; i < zs; i++) {
                for (a = 1; a <= y; a++) {
                    if (a == 1) {
                        min = n[a];
                        index = 1;
                    } else if (min >= n[a]) {
                        min = n[a];
                        index = a;
                    }
                }

                sun += min;
                n[index] = 99999999;
            }
            System.out.println(sun);

        }

    }
}



Measured memory_bytes: 33008
N,K = map(int,input().split())
V = [int(v) for v in input().split()]

ans = 0
for i in range(min(N+1,K+1)):
  que1 = V[:i]
  for j in range(min(N+1-i,K+1-i)):
    que2 = que1 + V[N-j:]
    que2.sort()
    for k in range(min(K+1-i-j,i+j+1)):
      ans = max(ans,sum(que2[k:]))
print(ans)


Measured memory_bytes: 42076
<?php
$S = fgets(STDIN);
$a = str_split($S);
$cnt = count($a);
$ans = 0;
$tmp = 0;
for ($i = 0; $i < $cnt; $i++) {
    if ($a[$i] === 'R') {
        $tmp++;
        $ans = max($ans, $tmp);
    } else {
        $tmp = 0;
    }
}
printf("%d", $ans);


Measured memory_bytes: 16268
#include <stdio.h>
#include <stdlib.h>
#define MAX 101
#define rep(i,n) for(int i=0;i<n;i++)
#define infinity 1e9
typedef struct tuple{
    int a;
    int b;
    int w;
}tuple;
int n,t=0,cost=0;
int G[MAX][MAX],tags[MAX];
tuple v[5010];
int cmpAscW(const void * n1, const void * n2){
    if (((tuple *)n1)->w > ((tuple *)n2)->w)return 1;
	else if (((tuple *)n1)->w < ((tuple *)n2)->w)return -1;
	else return 0;
}
int min(int x,int y){
    if(x < y)return x;
    else return y;
}
int max(int x,int y){
    if(x<y)return y;
    else return x;
}
void Kruskal(){
    int m,temp=0;
    rep(i,t){
        if(tags[v[i].a] != tags[v[i].b]){
            temp = max(tags[v[i].a],tags[v[i].b]);
            m = min(tags[v[i].a],tags[v[i].b]);
            tags[v[i].a] = m;
            tags[v[i].b] = m;
            cost += v[i].w;
            for(int j=m;j<n;j++){
                if(tags[j] == temp)tags[j]=m;
            }
        }
    }
}
int main(){
    scanf("%d",&n);
    rep(i,5010){
        v[i].w = infinity;
    }
    rep(i,n){
        tags[i] = i;
        rep(j,n){
            scanf("%d",&G[i][j]);
            if(i<j){
                if(G[i][j] != -1){
                    v[t].a = i;
                    v[t].b = j;
                    v[t].w = G[i][j];
                    t++;
                }
            }
        }
    }
    qsort(v, t, sizeof(tuple), cmpAscW);
    Kruskal();
    printf("%d\n",cost);
    return 0;
}


Measured memory_bytes: 2832
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    rep(i, N)
    {
        int flag = 1;
        if (a[i] % 2 == 0)
        {
            if (a[i] % 3 == 0 || a[i] % 5 == 0)
            {
            }
            else
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int r[n + 1] = {0};
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    r[a]++;
    r[b]++;
  }
  rep(i, n) cout << r[i + 1] << endl;
  return 0;
}


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

int main()
{
    string S,T;
    cin >> S >> T;
    bool ans = false;
    for(int i = 0; i <= S.size(); i++){
        if(S == T){
            ans = true;
            break;
        }
        S = S.back() + S.substr(0, S.size()-1);
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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


    

int main() {
long long a,b,c,d; 
  long long Max=-1000000000000000000;
cin >>  a >> b >> c>> d; 
  if(a>=0 && c>=0){
    Max=b*d;
  }
   if(b<=0 && d<=0){
    Max=a*c;
  }
  if(a>=0 && d<=0){
    Max=a*d;
  }
  if(c>=0 && b<=0){
    Max=c*b;
  }
  if(a<=0 && b>=0 && c<=0 && d>=0){
    Max=max(a*c,b*d);
  }
  if(a>=0 && b>=0 && d>=0){
    Max=b*d;
  }
  if(b>=0 && c>=0 && d>=0){
    Max=b*d;
  }
  if(a<=0 && c<=0 && d<=0){
    Max=a*c;
  }
  if(a<=0 && c<=0 && b<=0){
    Max=a*c;
  }
  
 
  cout << Max <<endl;
}



Measured memory_bytes: 3628
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    vll s(n), t(m);
    for (ll i = 0; i < n; i++) cin >> s[i];
    for (ll i = 0; i < m; i++) cin >> t[i];

    vvll dp(n + 1, vll(m + 1, 1));
    dp[0][0] = 1;
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < m; j++) {
            if (s[i] == t[j]) dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1]) % MOD;
            else dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + MOD) % MOD;
        }
    }

    cout << dp[n][m] << '\n';
    return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	ll ma[13] = { 0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
	ll x, y;
	cin >> x >> y;
	cout << (ma[x] == ma[y] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N;
  cin >> N;
  vi L(N);
  REP(i, N) { cin >> L.at(i); }
  sort(L.begin(), L.end());
  int ans = 0;
  REP(i, N - 2) {
    int a = L.at(i);
    for (int j = i + 1; j < N - 1; j++) {
      int b = L.at(j);
      if (a == b) continue;
      for (int k = j + 1; k < N; k++) {
        int c = L.at(k);
        if (b == c || a + b <= c) continue;
        ans++;
      }
    }
  }

  cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiil;
typedef pair<pll, ll> pplll;
typedef pair<pli, int> pplii;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<pll>> vvpll;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define pb push_back
#define tostr to_string
#define mkp make_pair
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

void print(ld out) { cout << fixed << setprecision(12) << out << '\n'; }
template<typename T> void print(T out) { cout << out << '\n'; }
template<typename T1, typename T2> void print(pair<T1, T2> out) { cout << out.first << ' ' << out.second << '\n'; }
template<typename T> void print(vector<T> A) { rep(i, 0, A.size()) { cout << A[i]; cout << (i == A.size()-1 ? '\n' : ' '); } }
template<typename T> void print(set<T> S) { vector<T> A(S.begin(), S.end()); print(A); }

template<typename T> inline bool chmax(T &x, T y) { return (y > x) ? x = y, true : false; }
template<typename T> inline bool chmin(T &x, T y) { return (y < x) ? x = y, true : false; }

ll sum(vector<ll> A) { ll res = 0; for (ll a: A) res += a; return res; }
ll max(vector<ll> A) { ll res = -INF; for (ll a: A) chmax(res, a); return res; }
ll min(vector<ll> A) { ll res = INF; for (ll a: A) chmin(res, a); return res; }

ll toint(string s) { ll res = 0; for (char c : s) { res *= 10; res += (c - '0'); } return res; }
int toint(char c) { return c - '0'; }
char tochar(int i) { return '0' + i; }

inline ll pow(int x, ll n) { ll res = 1; rep(_, 0, n) res *= x; return res; }
inline ll pow(ll x, ll n, int mod) { ll res = 1; while (n > 0) { if (n & 1) { res = (res * x) % mod; } x = (x * x) % mod; n >>= 1; } return res; }

inline ll floor(ll a, ll b) { if (a < 0) { return (a-b+1) / b; } else { return a / b; } }
inline ll ceil(ll a, ll b) { if (a >= 0) { return (a+b-1) / b; } else { return a / b; } }

int popcount(ll S) { return __builtin_popcountll(S); }
ll gcd(ll a, ll b) { return __gcd(a, b); }

const ll mod = 2019;
ll dp1[2][mod], dp2[2][mod];
ll N;
string S;
vector<ll> A;

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

    cin >> S;
    N = S.size();
    A.resize(N);
    rep(i, 0, N) A[i] = toint(S[i]);
    
    ll a, nxt, ans;
    rep(i, 0, N) {
        a = A[i];
        dp1[(i+1)&1][a] = 1;
        rep(j, 0, mod) {
            nxt = (j*10+a) % mod;
            dp1[(i+1)&1][nxt] += dp1[i&1][j];
            dp2[(i+1)&1][nxt] += dp1[i&1][j];
            dp2[(i+1)&1][j] += dp2[i&1][j];
        }
        memset(dp1[i&1], 0, sizeof(dp1[i&1]));
        memset(dp2[i&1], 0, sizeof(dp2[i&1]));
    }
    ans = dp2[N&1][0];
    print(ans);
    return 0;
}


Measured memory_bytes: 5080
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
   ll n;
   cin>>n;
   ll i,j;
   ll x,a[n];
   for(i=1;i<=n;i++)
   {
      cin>>a[i];
   }
   x=a[1];
   ll cnt=0;
   for(i=1;i<=n;i++)
   {
       if(x>=a[i])
       {
           x=a[i];
           cnt++;
       }
   }
    cout<<cnt;
    
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;
int main(void){
   int a,b;
   cin>>a>>b;
   int waru=a/b;
   int amari=a%b;
   double syousuu=(double)a/b;
   //cout <<waru<<" "<<amari<<" "<<setprecision(15)<<syousuu<<endl;
   printf("%d %d %.10f\n",waru,amari,syousuu);
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int count=0;
 string s;
  cin>>s;
  int l=s.length();
  for(int i=0;i<l/2;i++)
  {
    if(s[i]!=s[l-1-i])
    {
      count++;
    }
  }
  cout<<count;
}

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

int main( void )
{
    int d;
    cin >> d;
    int r = 25 - d;
    cout << "Christmas";
    for ( int i = 0; i < r; i++ )
    {
        cout << ' ' << "Eve";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u) {
    for (int v = nt[u]; v < n; v++) {
        nt[u] = v + 1;
        if(M[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r) {
    for(int i = 0; i < n; i++) nt[i] = 0;
    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;
    while( !S.empty()) {
        int u = S.top();
        int v = next(u);
        if(v != -1) {
            if(color[v] == WHITE) {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        } else {
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs() {
    for(int i = 0; i < n; i++) {
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;
    for(int u = 0; u < n; u++) {
        if(color[u] == WHITE) dfs_visit(u);
    }
    for(int i = 0; i < n; i++) {
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main() {
    int u, k, v;
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) M[i][j] = 0;
    }
    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for(int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    dfs();
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;

using namespace std;

int main()
{
    ll L, R, t, cnt;    cin >> L >> R;
    vector<int> check(2019,0);
    cnt = 0;
    for(ll i=L; i<R; i++){
        for(ll j=i+1; j<=R; j++){
            t = i*j%2019;
            check[t] = 1;
            cnt++;
            if(cnt > 2019*2019) break;
        }
        if(cnt > 2019*2019) break;
    }
    rep(i,2019){
        if(check[i] == 1){
            cout << i;
            return 0;
        }
    }
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int x,t;

    Scd2(x,t);

    printf ("%d\n", x - t > 0 ? x - t : 0 );

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}

int main() {
	ll a;
	cin >> h >> a;
	ll res = 0;
	if (h % a == 0) {
		res = h / a;
	}
	else {
		res = (h / a)+1;
	}
	cout << res << endl;

}



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

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long res = 0;
        List<long[]> abs = new List<long[]>();
        for (int i = 0; i < n; i++)
        {
            abs.Add(Console.ReadLine().Split().Select(long.Parse).ToArray());
        }
        abs.Reverse();
        foreach (var ab in abs)
        {
            long amari = (ab[0] + res) % ab[1];
            res += (ab[1] - amari) % ab[1];
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 25780
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<ll, int> P;


int main(){
	string s;
	cin >> s;
	for(int i=0;i<s.length();i++){
		if(i==4) cout << ' ';
		cout << s[i];
	}
	cout << endl;
	
	return 0;
}

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

int main() {

  int H, W;
  cin >> H >> W;

  vector<string> a(H);
  for (int i = 0; i < H; i++) {
    string a_;
    cin >> a_;
    a[i] = "#" + a_ + "#";
  }

  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;

  for (int i = 0; i < H; i++) {
    cout << a[i] << endl;
  }

  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#include <atcoder/all>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int N, M;
int ij_to_v(pii ij) {
	return (ij.first * M + ij.second);
}
pii v_to_ij(int v) {
	return (make_pair(v / M, v % M));
}

int main() {
	cin >> N >> M;
	int V = N * M + 2;
	int s = V - 2;
	int t = V - 1;
	mf_graph<int> g(V);
	rep(i, N) {
		rep(j, M) {
			// 盤面は市松模様, 有向辺 : 白->黒
			if (i != N - 1) {
				// 縦向きの辺
				pii ij0 = make_pair(i, j);
				pii ij1 = make_pair(i + 1, j);
				if ((ij0.first + ij0.second) % 2)
					swap(ij0, ij1);
				int u = ij_to_v(ij0);
				int v = ij_to_v(ij1);
				g.add_edge(u, v, 1);
			}
			if (j != M - 1) {
				// 横向きの辺
				pii ij0 = make_pair(i, j);
				pii ij1 = make_pair(i, j + 1);
				if ((ij0.first + ij0.second) % 2)
					swap(ij0, ij1);
				int u = ij_to_v(ij0);
				int v = ij_to_v(ij1);
				g.add_edge(u, v, 1);
			}
		}
	}
	vector<string> S(N);
	rep(i, N) {
		cin >> S[i];
		rep(j, M) {
			char c = S[i][j];
			if (c == '.') {
				pii ij0 = make_pair(i, j);
				int u = ij_to_v(ij0);
				// 出口 or 入口
				if ((ij0.first + ij0.second) % 2)
					g.add_edge(u, t, 1);
				else
					g.add_edge(s, u, 1);
			}
		}
	}
	cout << g.flow(V - 2, V - 1) << endl;
	auto edges = g.edges();
	for (auto e : edges) {
		int u = e.from;
		int v = e.to;
		int tile = e.flow;
		if (u == s || v == t || tile == 0)
			continue;
		if (u > v)
			swap(u, v);
		pii ij0 = v_to_ij(u);
		pii ij1 = v_to_ij(v);
		int i0 = ij0.first;
		int j0 = ij0.second;
		int i1 = ij1.first;
		int j1 = ij1.second;
		if (i0 != i1) {
			// 縦向きの辺
			S[i0][j0] = 'v';
			S[i1][j1] = '^';
		}
		else {
			// 横向きの辺
			S[i0][j0] = '>';
			S[i1][j1] = '<';
		}
	}
	rep(i, N)
		cout << S[i] << endl;
	return 0;
}

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

using ll = long long;

const int maxn = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int tc = 1;
    // cin >> tc;
    while(tc--) {
        int n, q;
        cin >> n;
        vector<int> a(n);
        int all = 0;
        for(int i=0; i<n; i++) {
            cin >> a[i];
            all = all ^ a[i];
        }
        for(int i=0; i<n; i++) {
            a[i] = a[i] ^ all;
            cout << a[i] << " ";
        }
        cout << endl;
    }
    
    return 0;
}

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

int main() {
  
  int ans = 0;
  for (int i = 1; i <= 5; i++) {
    int x;
    cin >> x;
    if(x == 0) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int N, A, B, C, D;
string S;

bool solve1() {
  vector<bool> dpA(N);
  {
    dpA[A] = 1;
    REP(i, 1, N) {
      if (S[i] == '#') continue;
      dpA[i] = dpA[i] || dpA[i - 1];
      if (i - 2 >= 0) dpA[i] = dpA[i] || dpA[i - 2];
    }
  }
  vector<bool> dpB(N);
  {
    dpB[B] = 1;
    REP(i, 1, N) {
      if (S[i] == '#') continue;
      dpB[i] = dpB[i] || dpB[i - 1];
      if (i - 2 >= 0) dpB[i] = dpB[i] || dpB[i - 2];
    }
  }
  return dpA[C] && dpB[D];
}

bool solve2() {
  if (C < D) {
    return 1;
  }

  bool flag = 0;
  REP(i, B - 1, D) {
    if (i + 2 >= N) break;
    if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
      flag = 1;
    }
  }
  return flag;
}

int main() {
  cin >> N >> A >> B >> C >> D >> S;
  A--, B--, C--, D--;
  cout << (solve2() && solve1() ? "Yes\n" : "No\n");
}


Measured memory_bytes: 640
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)
import math
import bisect
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if A==[1]*N:
  print('pairwise coprime')
  exit()
a=A[0]
d=a
if A[0]!=1:
  D={}
  x=0
  for i in range(N):
    if d!=1:
      d=math.gcd(d,A[i])
    c=A[i]
    if x==0:
      F=factorization(A[i])
      for a,b in F:
        if a not in D:
          D[a]=1
        else:
          x=1
        #互いに素じゃない二組がある  
    if x==1 and d==1:
      break

  if x==1 and d==1:
    print('setwise coprime')
  elif x==0 and d==1:
    print('pairwise coprime')
  else:
    print('not coprime')
else:
  l=bisect.bisect_right(A,1)
  A=A[l:]
  D={}
  x=0
  for i in range(len(A)):
    F=factorization(A[i])
    for a,b in F:
      if a not in D:
        D[a]=1
      else:
        x=1
    if x==1:
      break
    
  if x==1:
    print('setwise coprime')
  else:
    print('pairwise coprime')

Measured memory_bytes: 212160
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]

l1=[]
l2=[]
l3=[]
for i in range(m):
    if s[i][0]==1:
        l1.append(s[i])
    elif s[i][0]==2:
        l2.append(s[i])
    elif s[i][0]==3:
        l3.append(s[i])
l1=list(map(list, set(map(tuple, l1))))
l2=list(map(list, set(map(tuple, l2))))
l3=list(map(list, set(map(tuple, l3))))

check=0
if len(l1)>1 or len(l2)>1 or len(l3)>1:#同じ桁に違う数
    check+=1
if n==3 or n==2:
    if len(l1)>0 and l1[0][1]==0:#二桁三桁の時最初が０
        check+=1

if n==3:
    if len(l1)==0:
        l1.append([1,1])
    if len(l2)==0:
        l2.append([2,0])
    if len(l3)==0:
        l3.append([3,0])
if n==2:
    if len(l1)==0:
        l1.append([1,1])
    if len(l2)==0:
        l2.append([2,0])
if n==1:
    if len(l1)==0:
        l1.append([1,0])

if check>=1:
    print(-1)
else:
    ans=[]
    if len(l1)>0:
        ans.append(l1[0][1])
    if len(l2)>0:
        ans.append(l2[0][1])
    if len(l3)>0:
        ans.append(l3[0][1])
    print(int("".join(map(str,ans))))

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long ll;
const ll mod=(1e9)+7;
string A,B,C;

ll mem[100][10],used[100][10];
ll dfs(int idx,int pre){
  if(idx==-1) return pre==0;
  if(used[idx][pre]++)return mem[idx][pre];
  
  ll res=0,u[10][10][10]={},f=idx==0;
  for(int i=f;i<10;i++)
    for(int j=f;j<10;j++)
      for(int k=f;k<10;k++){
	int a=A[idx]=='?'? i:A[idx]-'0';
	int b=B[idx]=='?'? j:B[idx]-'0';
	int c=C[idx]=='?'? k:C[idx]-'0';
	if(u[a][b][c]++||(a+b+pre)%10!=c) continue;
	res=(res+dfs(idx-1,(a+b+pre)/10))%mod;
      }
  return mem[idx][pre] = res;
}

int main(){
  while(1){
    cin>>A;
    if(A=="0")break;
    cin>>B>>C;
    memset(used,0,sizeof(used));
    cout <<dfs(A.size()-1,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3428
#include <bits/stdc++.h>
#define int long long
#define dl long double
#define ff first
#define ss second
#define pb push_back
#define MAXN 20
#define inf 1000000007
#define INI 12332112
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair<int,int> pii;

int pre[(1<<16)+10];
int a[MAXN][MAXN];
int dp[(1<<16)+10];
int full=0;


int32_t main(){
	fastio;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<n;i++){
		full+=(1<<i);
	}
	for(int x=1;x<=full;x++){
		int atual=0;
		for(int b1=0;b1<n;b1++){
			for(int b2=b1+1;b2<n;b2++){
				if(((x&(1<<b1))!=0) && ((x&(1<<b2))!=0)){
					atual+=a[b1][b2];
				}
			}
		}
		pre[x]=atual;
	}
	for(int i=1;i<=full;i++){
		dp[i]=pre[i];
	}
		
	for(int x=1;x<=full;x++){
		for(int g1=x;g1>0;g1=(g1-1)&x){
			int g2=x^g1;
			dp[x] = max(dp[x],dp[g1]+dp[g2]);
		}
	}
	
	cout<<dp[full]<<endl;
		
}

Measured memory_bytes: 1280
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b,c;
  cin>>a>>b>>c;
  if(a<=c && c<=b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn f(b: usize, n: usize) -> usize {
    let mut x = n;
    let mut sum = 0;
    while x >= b {
        sum += x % b;
        x /= b;
    }
    sum += x;
    sum
}

fn main() {
    input! {
        n: usize,
        s: usize,
    }

    if n == s {
        println!("{}", n + 1);
        return;
    } else if n < s {
        println!("-1");
        return;
    }

    let mut i = 2;
    while i * i <= n {
        if f(i, n) == s {
            println!("{}", i);
            return;
        }
        i += 1;
    }

    i = (n as f64).sqrt().floor() as usize;

    while i >= 1 {
        let b = (n - s) / i + 1;
        if b != 1 && f(b, n) == s {
            println!("{}", b);
            return;
        }
        i -= 1;
    }
    println!("-1");
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main() {
	double a, b, c, C, S, L, h;
	cin >> a >> b >> C;

	C = C*2*3.14159265359 / 360;
	c = sqrt(a*a + b*b - 2 * a*b*cos(C));
	S = a*b*sin(C) / 2;
	L = a + b + c;
	h = 2 * S / a;

	printf("%f %f %f\n", S, L, h);
}

Measured memory_bytes: 1260
// 2011/02/19 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		string col;
		cin >> col;
		if(col=="0")
			break;

		if(col[1]>='0'&&col[1]<='7')
			if(col[3]>='0'&&col[3]<='7')
				if(col[5]>='0'&&col[5]<='7')
					cout << "black" << endl;
				else
					cout << "blue" << endl;
			else
				if(col[5]>='0'&&col[5]<='7')
					cout << "lime" << endl;
				else
					cout << "aqua" << endl;
		else
			if(col[3]>='0'&&col[3]<='7')
				if(col[5]>='0'&&col[5]<='7')
					cout << "red" << endl;
				else
					cout << "fuchsia" << endl;
			else
				if(col[5]>='0'&&col[5]<='7')
					cout << "yellow" << endl;
				else
					cout << "white" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#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 N;
    cin >> N;
    if (N % 2 == 0) cout << N / 2 << endl;
    else cout << (N + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 3604
from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces


h, w = na()
sh, sw = na()
gh, gw = na()

map = []
for _ in range(h):
    s = ns()
    map.append([0 if i=="." else 1 for i in s])

visited = [[1000000 for j in range(w)] for i in range(h)]

def warp(nh, nw, now_warp):
    next_p = []
    topleft = [nh-2, nw-2]
    for i in range(5):
        for j in range(5):
            neh = topleft[0]+i
            new = topleft[1]+j
            if check_position(neh, new, now_warp+1):
                next_p.append([neh, new])
    return next_p


def check_position(hi, wi, now_warp):
    if hi<0 or hi>=h or wi<0 or wi>=w or map[hi][wi]==1 or visited[hi][wi] <= now_warp:
        return False
    return True


positions = deque()
positions.append([sh-1, sw-1, 0])
while len(positions)>0:
    warp_positions = deque()
    while len(positions)>0:
        nh, nw, now_warp = positions.popleft()

        if now_warp >= visited[nh][nw]:
            continue

        visited[nh][nw] = now_warp
        move_cnt = 0
        if check_position(nh+1, nw, now_warp):
            positions.append([nh+1, nw, now_warp])
            move_cnt += 1
        
        if check_position(nh, nw+1, now_warp):
            positions.append([nh, nw+1, now_warp])
            move_cnt += 1
        
        if check_position(nh-1, nw, now_warp):
            positions.append([nh-1, nw, now_warp])
            move_cnt += 1
        
        if check_position(nh, nw-1, now_warp):
            positions.append([nh, nw-1, now_warp])
            move_cnt += 1

        if move_cnt<4:
            warp_positions.append([nh, nw, now_warp])
    
    while len(warp_positions)>0:
        nh, nw, now_warp = warp_positions.popleft()
        next_warps = warp(nh, nw, now_warp)
        for p in next_warps:
            positions.append([p[0], p[1], now_warp+1])

print(-1 if visited[gh-1][gw-1]==1000000 else visited[gh-1][gw-1])

Measured memory_bytes: 171700
import java.util.*;

/**
 * スキルサーベイ用Javaプログラム.
 *
 * Created by Yosuke Kobayashi on 2016/07/28.
 */
public class Main {


    /**
     * メイン エントリ.
     * @param args String[]
     */
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int fiveCnt = 0;
        int sevenCnt = 0;

        List<Integer> list = new ArrayList<>();
        list.add(sc.nextInt());
        list.add(sc.nextInt());
        list.add(sc.nextInt());

        for (int value : list) {
            
            if (value == 5) {
                fiveCnt++;
            }

            if (value == 7) {
                sevenCnt++;
            }
        }


        if (fiveCnt == 2 && sevenCnt == 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;

ll dp[200][4][4][4];

void init(){
  dp[0][3][3][3] = 1;
}

ll n;

void solve(){
  for (int len = 0; len < n; len++) {
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 4; k++) {
          if(dp[len][i][j][k] == 0) continue;
          for (int a = 0; a < 4; a++) {
            if(a == 2 && i == 1 && j == 0) continue;
            if(a == 1 && i == 2 && j == 0) continue;
            if(a == 2 && i == 0 && j == 1) continue;
            if(a == 2 && i == 1 && k == 0) continue;
            if(a == 2 && j == 1 && k == 0) continue;

            dp[len+1][a][i][j] += dp[len][i][j][k];
            dp[len+1][a][i][j] %= MOD;
          }
        }
      }
    }
  }
  ll res = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        res += dp[n][i][j][k];
        res %= MOD;
      }
    }
  }

  cout << res << endl;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  init();
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll N, cnt = 0;
  string S;
  cin >> N;
  vector<ll> initial(5, 0);
  for(ll i = 0; i < N; i++) {
    cin >> S;
    if(S.at(0) == 'M') initial.at(0)++;
    else if(S.at(0) == 'A') initial.at(1)++;
    else if(S.at(0) == 'R') initial.at(2)++;
    else if(S.at(0) == 'C') initial.at(3)++;
    else if(S.at(0) == 'H') initial.at(4)++;
  }
  for(ll i = 0; i < 3; i++) {
    for(ll j = i + 1; j < 4; j++) {
      for(ll k = j + 1; k < 5; k++) {
        cnt+= initial.at(i) * initial.at(j) * initial.at(k);
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3640
def solve():
    N = int(input())
    A = list(map(int,input().split()))

    n_negative = 0
    for a in A:
        if a < 0:
            n_negative += 1

    abs_sum = sum(map(abs,A))
    if n_negative % 2 == 0:
        print(abs_sum)
    else:
        print(abs_sum - 2 * min(map(abs,A)))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 64752
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
    ll n,k;
    cin >> n >> k;
    ll a[n+1];
    ll now = 1;
    ll cnt[n+1];
    ll ii;
    for(ll i=1;i<=n;i++)cin >> a[i];
    for(ll i=1;i<=n;i++)cnt[i] = 0;
    for(ll i=1;i<=n+100;i++){
        if(cnt[now]!=0){ii = i-cnt[now];break;}
        cnt[now]=i;
        now = a[now];
    }
    ll kk = (k-cnt[now]) % ii + cnt[now] + ii;
  	ll kkk = k-cnt[now];
    now = 1;
  	if(kkk>=1){
    for(ll i=1;i<=kk;i++){
        now = a[now];
    }
    }
  else 
    for(ll i=1;i<=k;i++){
        now = a[now];
    }
    cout << now << endl;
    return 0;
}


Measured memory_bytes: 6796
s=input()
# dream dreamer erase eraser 
while len(s)>0:
	if (s[-1]=="r") & (s[-7:]=="dreamer"):
		s=s[:-7]
	elif (s[-1]=="r") & (s[-6:]=="eraser"):
		s=s[:-6]
	elif (s[-1]=="e") & (s[-5:]=="erase"):
		s=s[:-5]
	elif (s[-1]=="m") & (s[-5:]=="dream"):
		s=s[:-5]
	else:
		break

if len(s)==0:
	print("YES")
else:
	print("NO")


Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws Exception {

		try {

			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			int topSide = Integer.parseInt(br.readLine());
			int bottomSide = Integer.parseInt(br.readLine());
			int height = Integer.parseInt(br.readLine());


			int areaOfaTrapezoid = getAreaOfaTrapezoid(topSide, bottomSide, height);

			System.out.println(areaOfaTrapezoid);

		} catch (IOException | NumberFormatException e) {
			e.printStackTrace();
			System.exit(0);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}

	}

	public static int getAreaOfaTrapezoid(int topSide, int bottomSide, int height) {
		
		// 台形の面積 =(上底 + 下底) × 高さ ÷	2
		// Area of a trapezoid = (top side + bottom side) * height / 2

		return (topSide + bottomSide) * height / 2;
	}
}

Measured memory_bytes: 19284
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int x = 0, xMax = 0;
		int N  = sc.nextInt();
		String S = sc.next();
		for(int i = 0; i < N; i++) {
			char c = S.charAt(i);
			if(c == 'I') {
				x++;
			}
			else if(c == 'D') {
				x--;
			}
			if(xMax < x) {
				xMax = x;
			}
		}
		System.out.println(xMax);

	}

}


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

namespace AtTest._400Problems_remain_
{
    class CF2017Final_C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] hw = ReadInts();
            int h = hw[0];
            int w = hw[1];
            int[] counts = new int[26];
            for (int i = 0; i < h; i++)
            {
                string s = Read();
                for (int j = 0; j < w; j++)
                {
                    counts[s[j] - 'a']++;
                }
            }
            Array.Sort(counts);
            Array.Reverse(counts);
            int count1 = (h % 2) * (w % 2);
            int count2 = (w / 2) * (h % 2) + (h / 2) * (w % 2);
            int count4 = (h / 2) * (w / 2);
            for (int i = 0; i < counts.Length; i++)
            {
                int minusCount;
                minusCount = Math.Min(counts[i] / 4, count4);
                count4 -= minusCount;
                counts[i] -= minusCount * 4;
                minusCount = Math.Min(counts[i] / 2, count2);
                count2 -= minusCount;
                counts[i] -= minusCount * 2;
                minusCount = Math.Min(counts[i], count1);
                count1 -= minusCount;
                counts[i] -= minusCount;
                if (counts[i] > 0)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class AProduct
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            var a = int.Parse(s[0]);
            var b = int.Parse(s[1]);

            if (a*b%2 == 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }
            Console.ReadLine();
        }
  }
}

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

int main(){
  unsigned int n,t,d=0,p,i;
  cin >> n;
  t = n;
  while(t!=0){
    t = t / 10;
    d++;
  }
  t = n;
  for(i=0;i<d;i++){
    p += (t % 10);
    t /= 10;
  }
  if(n%p == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  string s;
  int cnt=0;
  cin>>s;
  sort(s.begin(),s.end());
  if(s.size()%2==1) cout<<"No"<<endl;
  else{
  for(int i=0;i<s.size();i+=2){
  	if(s.at(i)!=s.at(i+1)) cnt++;
  }
  if(cnt==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,cnt,num1,num2,num3,temp=0;
  // num1=0;                                                                                                                                                                         
  //num2=0;                                                                                                                                                                          
  //num3=0;                                                                                                                                                                          
  scanf("%d",&cnt);
  for(i=0; i<cnt; i++){
    scanf("%d %d %d",&num1,&num2,&num3);
    if(((num1*num1)==((num2*num2)+(num3*num3))) || ((num2*num2)==((num1*num1)+(num3*num3))) || ((num3*num3)==((num1*num1)+(num2*num2)))){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 580
#include <stdio.h>  
int main(void) 
{
	int i, j, n, m, a[100][100], b[100], c[100] = {0};
	
	scanf("%d %d", &n, &m); 
	
	for (i=0; i<n; i++) 
	{
		for (j=0; j<m; j++)
		{     
			scanf("%d", &a[i][j]);
		}    
	}
	
	for (i=0; i<m; i++) 
	{ 
		scanf("%d", &b[i]); 
	}
	
	for (i=0; i<n; i++) 
	{
		for (j=0; j<m; j++)
		{
			c[i] += a[i][j] * b[j];
		}
	}
	
	for (i=0; i<n; i++)
	{
		printf("%d\n", c[i]);   
	}
	return 0; 
}

Measured memory_bytes: 640